Help with Mathematica: 3D Point Definition

  • Mathematica
  • Thread starter dg88
  • Start date
  • Tags
    Mathematica
In summary, the speaker is trying to simulate a laser scattering experiment in Mathematica and is having trouble defining a set of 3D points. They provide a program in C++ as an example and ask how to define these points in Mathematica. The suggested solution is to create an empty matrix and use AppendTo or Reap and Sow to add elements in a loop.
  • #1
dg88
10
0
Hello,

1) I am trying trying to simulate a laser scattering experiment in Mathematica. So the first trouble I have is how to define a set of 3D points. I did this program in C++ like this:
for (int i=0; i<3; i++)
{
pyr[0].point[0]=0;
}
for (int a=1; a<3; a++)
{
for (int b=0; b<3; b++)
{
if (b == 1) // adding sqrt(2) to the Y cordinate
{
pyr[a].point[0]=pyr[a-1].point[0]+ sqrt(2.0);
}
else
{
pyr[a].point[0]=pyr[a-1].point[0];
}
}
}
for (int c=0; c<3;c++)
{
if (c==0)
{
pyr[3].point[0][c]=pyr[0].point[0][c]+ sqrt(2.0);
}
else
{
pyr[3].point[0][c]=pyr[0].point[0][c];
}

}
for(int d=4;d<6; d++)
{
for (int e=0;e<3;e++)
{
if (e == 1) // adding sqrt(2) to the Y cordinate
{
pyr[d].point[0][e]=pyr[d-1].point[0][e]+ sqrt(2.0);
}
else
{
pyr[d].point[0][e]=pyr[d-1].point[0][e];
}
}
}
for (int f=0; f<3;f++)
{
if (f==0)
{
pyr[6].point[0][f]=pyr[3].point[0][f]+ sqrt(2.0);
}
else
{
pyr[6].point[0][f]=pyr[3].point[0][f];
}
}
for(int g=7;g<9; g++)
{
for (int h=0;h<3;h++)
{
if (h == 1) // adding sqrt(2) to the Y cordinate
{
pyr[g].point[0][h]=pyr[g-1].point[0][h]+ sqrt(2.0);
}
else
{
pyr[g].point[0][h]=pyr[g-1].point[0][h];
}
}
}


The question is, how do I define these points in Mathematica? Is there a way I can have multidimensional arrays and define the points like above and then use then for further calculations?

Thanks in advance
dg
 
Physics news on Phys.org
  • #2
Define an empty matrix then use AppendTo (or Reap and Sow) to add elements in a loop or whatever.
 

What is Mathematica and how does it relate to 3D point definition?

Mathematica is a software program used for mathematical computations, data analysis, and visualization. It has powerful 3D graphics capabilities which allow for the definition and manipulation of 3D points and objects.

How do I define a 3D point in Mathematica?

To define a 3D point in Mathematica, you can use the Point[ ] function and specify the coordinates of the point as a list of three numbers. For example, Point[{1,2,3}] defines a 3D point with coordinates (1,2,3).

Can I plot multiple 3D points in Mathematica?

Yes, you can plot multiple 3D points in Mathematica by using the Graphics3D[ ] function. Simply provide a list of Point[ ] functions with the coordinates of each point, and they will be plotted in the 3D space.

How can I manipulate 3D points and objects in Mathematica?

Mathematica has a variety of built-in functions for manipulating 3D points and objects, such as Translate, Rotate, and Scale. These functions allow you to move, rotate, and resize points and objects in the 3D space.

Are there any resources available for learning more about 3D point definition in Mathematica?

Yes, there are many resources available for learning about 3D point definition in Mathematica. The Mathematica documentation has extensive information and examples on working with 3D graphics, and there are also online tutorials and forums where users share tips and techniques for 3D point definition in Mathematica.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
257
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
565
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
1K
  • Calculus and Beyond Homework Help
Replies
2
Views
152
Back
Top