polar coordinates of a vector in three-dimensional space - math

polar coordinates of a 2 dimensional vector are:
x = r cos θ
y = r sin θ
What will be the polar coordinates of a vector in 3D (x, y, z)?

From Wikipedia:
x = r sin θ cos φ
y = r sin θ sin φ
z = r cos θ

It depends on what coordinate system you want in 3D. The above 2D transformation can be extended to both spherical and cylindrical coordinates via two clear geometrical analogues. For the case of cylindrical coordinates you would keep the above transformation for both x and y, but for z, the transformation would be given simply by z = z. So the transformation would be
(x, y, z) -> (r, theta, z)
For spherical coordinates there is an introduction of an additional coordinate transformation in the z-direction (see Ignacio Vazque-Abrams answer above) and also changes to the x and y transforms. In this case you have
(x, y, z) -> (r, theta, phi)
I think in your case you would be best using cylindrical coordinates. I hope this helps.

You can use the spherical coordinate system:
http://en.wikipedia.org/wiki/Spherical_coordinate_system
The link shows the conversions to x,y,z.

A goo definition for 3-dimensional polar coordinates appears in this link.
https://www.bing.com/videos/search?q=3+dimensional+polar+coordinates&&view=detail&mid=89E852F2356FEC20286E89E852F2356FEC20286E&&FORM=VRDGAR&ru=%2Fvideos%2Fsearch%3Fq%3D3%2520dimensional%2520polar%2520coordinates%26qs%3Dn%26form%3DQBVDMH%26%3D%2525eManage%2520
If you try to use the Mathematica function CoordinateTransform to conert a 3D cartesian point into a polar point, a message will appear saying it can't be done.
If you try to use the Mathematica function ToPolarCoordinates, an incorrect answer will appear with no indication that the result is wrong.
I can't figure out why there is so little literature on 3D polar coordinates or why Mathematica has not supported it correctly by now.
By the way, 3D polar coordinates are not the same as spherical or cylindrical coordinates.

Related

Finding a point in 3d space on a plane using 2d coordinates

visualization
I am searching the location of a point that lies on a plane. The relative location on the plane is given in u/v-Coordinates.
The normal vector n is equal to the vector from (0,0,0) to the center of the plane (or any other distance ≠ 0, if more convenient)
The plane has no rotation around the n vector - u is always on the xy axis and v on the z (up) axis
I feel like there should be a simple formula for this, given Vector3 n along with the coordinates u and v, but i'm stuck here.
You have the coordinates of the origin of the plane, namely (x, y, z)
Now we need the unit vectors u and v in global coordinates.
u is (y, -x, 0), normalized.
v is (-zx/r, -zy/r, r), normalized, where r=(x2+y2)1/2
Now you can add the location of the point in uv coordinates to the location of the plane origin in xyz coordinates.

Draw a 2d plane with scatterplot3d

I am trying to plot a plane with scatterplot3d that is perpendicular to a direction vector described by two angles, say theta and phi. The points are described by the (xyz)-coordinates satisfying the following equation, where R is the distance from the origin.
x cos(theta)cos(phi) + y sin(theta) cos(phi) + z sin(phi) = R
I guess I should use plane3d, but I can't figure out how to get this plane right based on my description. Can anyone help?
In other words, I am trying to plot the plane perpendicular to the blue line at distance R from the origin in this figure.
I assume this should be straightforward, but cannot figure it out.
Using plane3d and calculating the intercept and coefficients, this turned out to be quite straightforward:
spl$plane3d(Intercept, x.coeff, y.coeff, col=5, draw_polygon=T, lty=NULL)
The Intercept would just be R/sin(phi), and the x- and y-coefficients are the coefficients in front of X and Y: x.coeff = cos(theta)/tan(phi) and y.coeff = sin(theta)/tan(phi).
This gives the plane, as desired.

From line in cartesian coordinates to polar coordinates with youth style

I have line like in 2D defined by ax+by+c = 0 so (a,b,c).
I need to compute a polar representation of this line like Hough approach with rho an theta.
How to do this?
A line in cartesian coordinates is not as easily represented in polar coordinates.
You can simply substitute x,y with their respective polar equivalents, r*cos(theta), r*sin(theta), giving you
a*r*cos(theta) + b*r*sin(theta) + c = 0
This implicit equation is not as easy to figure out, however. But, if you first convert your implicit line equation to a parametric vector equation of the form (x,y) = R(t) = R0 + t*V, where R0,V are cartesian vectors which you can derive from a,b,c, you can then write
(r*cos(theta), r*sin(theta)) = R0 + t*V
and solve this system of equations for r and theta in terms of t.
However, polar coordinates are not the same as the Hough transform.
In the Hough system, the line is defined by the length rho of a perpendicular line that crosses (0,0) , which is theta = atan(b/a). Figuring out rho seems more difficult at first, but this tutorial explains it.

Converting from spherical coordinates to cartesian around arbitrary vector N

So if I'm given an arbitrary unit vector N and another vector V defined in spherical coordinates theta (polar angle between N and V) and phi (azimuthal angle) and r = 1. How do I convert vector V into cartesian coordinates?
Now, I know that in general the conversion from spherical to cartesian is as follows:
x = r * sin theta * cos phi
y = r * sin theta * sin phi
z = r * cos theta
However, since the angles theta and phi are defined respective to the vector N and not the axes, the above conversion wouldn't work, yes? So how would I go about modifying the conversion?
I feel that this is simply not possible given the information you have to hand.
You cannot have a vector V with spherical polar components defined relative to another vector. In a standard spherical polar coordinate system, the coordinates of a point P are given by (r,theta,phi) where theta is the polar angle, phi azimuthal angle, and r the Euclidean distance from the origin. The polar angle is the angle between the z-axis and the line joining the origin to the point P. The azimuthal angle is defined as the angle between the x-axis and the line that joins the origin to the orthogonal projection of P onto the xy plane.
Sometimes the definitions of these two angles are reversed. The above is clearly illustrated at the wiki page http://en.wikipedia.org/wiki/Spherical_polars
The point here is that the angles are defined relative to two mutually orthogonal axes - z and x in this case. Thus you cannot have both of your polar and azimuthal angles defined relative to a single vector N - You can have ONE of them measured relative to N but not both.
As it stands, your problem cannot be solved without providing another vector orthogonal to your N that provides the axis to which the other angle (either polar or azimuthal) is measured.
Your description of N indicates that this is the z-axis of some rotated coordinate system that V takes its polar angle relative to. You need another vector that gives the x-axis of the same rotated coordinate system that V takes measures its azimuthal angle relative to. With that information you can obtain the rotation matrix that maps your rotated coordinate system axes onto the cartesian coordinate axes - from there you will have sufficient information to obtain the cartesian coordinates of V that you require.
Look at this one: http://www.ewerksinc.com/refdocs/coordinate%20and%20unit%20vector.pdf
On page 7 you'll find the conversion formulas between spherical and cartesian vectors.

Given start point, angles in each rotational axis and a direction, calculate end point

I have a start point in 3D coordinates, e.g. (0,0,0).
I have the direction I am pointing, represented by three angles - one for each angle of rotation (rotation in X, rotation in Y, rotation in Z) (for the sake of the example let's assume I'm one of those old logo turtles with a pen) and the distance I will travel in the direction I am pointing.
How would I go about calculating the end point coordinates?
I know for a 2D system it would be simple:
new_x = old_x + cos(angle) * distance
new_y = old_y + sin(angle) * distance
but I can't work out how to apply this to 3 dimensions
I suppose another way of thinking about this would be trying to find a point on the surface of a sphere, knowing the direction you're pointing and the sphere's radius.
First of all, for positioning a point in 3D you only need two angles (just like you only needed one in 2D)
Secondly, for various reasons (slow cos&sin, gimbal lock, ...) you might want to store the direction as a vector in the first place and avoid angles alltogether.
Anyway, Assuming direction is initially z aligned, then rotated around x axis followed by rotation around y axis.
x=x0 + distance * cos (angleZ) * sin (angleY)
Y=y0 + distance * sin (Anglez)
Z=z0 + distance * cos (angleZ) * cos (angleY)
Based in the three angles you have to construct the 3x3 rotation matrix. Then each column of the matrix represents the local x, y and z directions. If you have a local direction you want to move by, then multiply the 3x3 rotation with the direction vector to get the result in global coordinates.
I made a little intro to 3D coordinate transformations that I think will answer your question.
3D Coordinates
First, it is strange to have three angles to represent the direction -- two would be enough. Second, the result depends on the order in which you turn about the respective axes. Rotations about different axes do not commute.
Possibly you are simply looking for the conversion between spherical and Cartesian coordinates.

Resources