Rotate Points on Sphere by Theta and Phi

In summary: This implies that he wants to rotate the four points in a specific plane. If he only cares about two specific rotations, then he only needs to specify two angles, not three.The OP says "My goal is to rotate the four points by... and phi 160." This implies that he wants to rotate the four points in a specific plane. If he only cares about two specific rotations, then he only needs to specify two angles, not three.
  • #1
James_1978
37
3
Dear Forum,

My goal is to rotate several points on a sphere by a theta and phi. For example, I have a sphere where the elevation is theta (90 to -90) and the azimuthal is phi (-180 to 180). I have the following points on the sphere:

theta = [45 45 45 45]
phi = [-180 90 90 180]

This generate several points to define a circle on the top of the circle. My goal is to rotate the four points by theta 115 (or theta = -25) and phi 160. With this the center of the circle will have the vector (theta=115,phi=160) and the four points will be around the center and new theta,phi locations.

I have been unsuccessful trying trying to do this with a rotation matrix. I appreciate any ideas to help me solve this problem.

Regards,
JC
 
Physics news on Phys.org
  • #2
James_1978 said:
I have been unsuccessful trying trying to do this with a rotation matrix.
Please show us what you have tried. That not only saves us from repeating things you know, but also gives us an idea of any misunderstandings you may have.

Also note that a rotation in three dimensions generally is parametrised by three angles, not two. This can be seen from rotating one point on the sphere to another (this requires two angles) and then you have the freedom to rotate around the axis of the sphere containing that point. Typically, Euler angles would be used.

There are also always two fixed points of any rotation so saying that you generally want to rotate points by some ##\theta## and ##\phi## is not really a good description of a rotation. You need three angles to define a rotation - the axis of rotation can be specified by two and then you need an angle of rotation.
 
  • Like
Likes FactChecker
  • #3
Orodruin said:
Please show us what you have tried. That not only saves us from repeating things you know, but also gives us an idea of any misunderstandings you may have.

Also note that a rotation in three dimensions generally is parametrised by three angles, not two. This can be seen from rotating one point on the sphere to another (this requires two angles) and then you have the freedom to rotate around the axis of the sphere containing that point. Typically, Euler angles would be used.

There are also always two fixed points of any rotation so saying that you generally want to rotate points by some ##\theta## and ##\phi## is not really a good description of a rotation. You need three angles to define a rotation - the axis of rotation can be specified by two and then you need an angle of rotation.
Three rotation angles are needed for the general rotation, but if this is a physical object, like a robotic arm, with only 2 axes of rotation then there is no need for a third angle.
 
  • #4
FactChecker said:
Three rotation angles are needed for the general rotation, but if this is a physical object, like a robotic arm, with only 2 axes of rotation then there is no need for a third angle.
No. This does not have to do with physical objects, but with how robot arms work. A general asymmetric physical object will need three angles to be rotated into any predetermined position.
 
  • #5
Orodruin said:
No. This does not have to do with physical objects, but with how robot arms work. A general asymmetric physical object will need three angles to be rotated into any predetermined position.
Yes, I agree. But the OP does not say that he has to deal with all possible rotations. It is very likely that he only cares about a reduced set of rotations that can be specified by two angles. In fact, it sounds like he only cares about two specific rotations of specific angles. There are three angles, but he does not have to use all of them.
 
  • #6
FactChecker said:
Yes, I agree. But the OP does not say that he has to deal with all possible rotations. It is very likely that he only cares about a reduced set of rotations that can be specified by two angles. In fact, it sounds like he only cares about two specific rotations of specific angles. There are three angles, but he does not have to use all of them.
I do not think this can be deduced from the OP alone. In fact, referring to rotations by the spherical coordinates in itself poses questions regarding the understanding of rotations. We will simply not know until the OP returns and clarifies what he intends to do.
 
  • #7
Orodruin said:
I do not think this can be deduced from the OP alone. In fact, referring to rotations by the spherical coordinates in itself poses questions regarding the understanding of rotations. We will simply not know until the OP returns and clarifies what he intends to do.
The OP says "My goal is to rotate the four points by theta 115 (or theta = -25) and phi 160."
That seems clear to me. He does not mention any roll angle.
 
Last edited:
  • #8
FactChecker said:
The OP says "My goal is to rotate the four points by theta 115 (or theta = -25) and phi 160."
That seems clear to me.
It most certainly is not in my book. Theta and phi are angles on the sphere according to OP and therefore define a point on the sphere, not a rotation (unless you specify which point should be mapped there and even then there is the remaining ambiguity regarding additional rotations around that axis). While changing all phi angles by a fixed amount does correspond to a rotation, doing the same for theta certainly does not. Hence the request for OP to show what he tried specifically.
James_1978 said:
phi = [-180 90 90 180]
OP, please also note that your first and last points are the same as well as your second and third. If you want four points around the pole, you should include phi=0 and phi =-90.
 
  • #9
Dear All,

Here is what I have tried. I first make 5 points very close to the top of the pole if you will.

Code:
phi_vals = [-180:90:180]
theta_vals = 1.5*ones(5,1)*(180/pi)

My goal is to rotate these points so that they are projected toward a theta,phi. However, they will be around the center by a ~ 1 degree. I write a loop to generate a v with the different points.

Code:
for i=1:length(phi_vals)

s1 = cosd(phi_vals(i))*sind(theta_vals(i))
s2 = sind(phi_vals(i))*sind(theta_vals(i))
s3 = cosd(theta_vals(i))

rot_theta=116
rot_phi=160

t1 = cosd(rot_phi)*sind(rot_theta)
t2 = sind(rot_phi)*sind(rot_theta)
t3 = cosd(rot_theta)

v = [s1;s2;s3]
axis=[t1;t2;t3]
theta = acos(dot(v,axis));        % angle between vectors

axis = axis/(sqrt(dot(axis,axis)))
a=cos(theta/2)
val = -axis*sin(theta/2)
b=val(1)
c=val(2)
d=val(3)
aa=a*a;bb=b*b;cc=c*c;dd=d*d;
bc=b*c;ad=a*d;ac=a*c;ab=a*b;bd=b*d;cd=c*d;
%%%%  Euler–Rodrigues Rotation %%%%
er_array=[(aa + bb - cc - dd) (2*(bc + ad)) (2*(bd - ac));(2*(bc - ad)) (aa + cc - bb - dd) (2*(cd + ab));(2*(bd + ac)) (2*(cd - ab)) (aa + dd - bb - cc)]
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
rot_array = er_array*v
[az,el,r]=cart2sph(rot_array(1),rot_array(2),rot_array(3));
rec_phi(i) = az*(180/pi)
rec_theta(i) = 90-el*(180/pi)

My thinking is that I would have five points that very close to theta=116 and phi=160. However, the points are too far a way from 116,160 to make sense. Any idea what I am missing?

I am following this guide
https://en.wikipedia.org/wiki/Euler–Rodrigues_formula
 
  • #10
James_1978 said:
theta_vals = 1.5*ones(5,1)*(180/pi)
Not entirely sure what you are doing here. This will give theta values of ca 85 - i.e., around the equator.

Edit: No wait, you are using inclination instead of the polar angle, yes that will be close to a pole.

Edit 2: No wait again, your formulas indicate that you are using it as the polar angle ...

James_1978 said:
rot_theta=116
rot_phi=160

t1 = cosd(rot_phi)*sind(rot_theta)
t2 = sind(rot_phi)*sind(rot_theta)
t3 = cosd(rot_theta)

v = [s1;s2;s3]
axis=[t1;t2;t3]
theta = acos(dot(v,axis)); % angle between vectors
It is not clear to me what you are trying to do here. You are defining an axis and letting "theta" equal the angle between the defined point and that axis. There are many things awry here.

James_1978 said:
axis = axis/(sqrt(dot(axis,axis)))
You don't need to do this based on your previous code. Your axis is already normalised by construction.

James_1978 said:
a=cos(theta/2)
val = -axis*sin(theta/2)
b=val(1)
c=val(2)
d=val(3)
You seem to be using the axis containing the point you want to rotate to as the rotation axis and the angle between the point and the axis as the rotation angle. This will not work. If you want to rotate the point to theta = 116 and phi = 160, you cannot have that point as the rotation axis because it will make that point a fixed point of the rotation, which means no other point can map to it. You should also not be using different rotations for different points. You need to construct your rotation matrix based on what you want to do, which is to make a single rotation rotating the center of your points to the desired direction and seeing what the rotation does to your other points.

If you take a point on the sphere and want to rotate it to theta = 116 and phi = 160 by using the angle between the vectors as the rotation angle, then your rotation axis needs to be perpendicular to both the target point and the point of origin. You can obtain a perpendicular vector through the cross product.
 
  • #11
Dear Orodruin,

Thank you for the response. I have attached a picture to better explain what I am trying to do. Please let me know if this helps.
 

Attachments

  • 0415221041b.jpg
    0415221041b.jpg
    39.4 KB · Views: 147

FAQ: Rotate Points on Sphere by Theta and Phi

1. How do I calculate the coordinates of a point on a sphere after rotating it by theta and phi?

The coordinates of a point on a sphere after rotation can be calculated using the following formula:x' = x*cos(phi)*cos(theta) - y*sin(theta) + z*sin(phi)*cos(theta)y' = x*sin(theta)*cos(phi) + y*cos(theta) + z*sin(phi)*sin(theta)z' = -x*sin(phi) + z*cos(phi)where (x, y, z) are the original coordinates of the point, and (x', y', z') are the new coordinates after rotation.

2. What are theta and phi in terms of spherical coordinates?

Theta and phi are the two angles used to describe a point on a sphere in spherical coordinates. Theta is the angle measured from the positive z-axis to the point, and phi is the angle measured from the positive x-axis to the projection of the point on the xy-plane.

3. How do I rotate a point on a sphere by a specific angle?

To rotate a point on a sphere by a specific angle, you can use the formula mentioned in the first question. Simply substitute the desired values for theta and phi, and calculate the new coordinates of the point.

4. What is the purpose of rotating points on a sphere by theta and phi?

Rotating points on a sphere by theta and phi is useful in various applications such as computer graphics, navigation systems, and geolocation. It allows us to change the orientation of a point on a sphere, which can be helpful in visualizing data or finding the location of a point relative to other points on the sphere.

5. Can I rotate a point on a sphere by any values of theta and phi?

Yes, you can rotate a point on a sphere by any values of theta and phi. However, it is important to note that the resulting coordinates may not always be valid, depending on the size of the sphere and the range of values chosen for theta and phi. It is recommended to use values within a certain range to avoid any issues.

Similar threads

Replies
33
Views
945
Replies
3
Views
1K
Replies
17
Views
1K
Replies
3
Views
1K
Replies
7
Views
5K
Replies
8
Views
1K
Replies
7
Views
3K
Back
Top