0 like 0 dislike
0 like 0 dislike
If I have two points on a unit sphere with coords (theta, phi), how can I calculate the axis and magnitude of a single rotation that would orient point 1 to point 2.

1 Answer

0 like 0 dislike
0 like 0 dislike
Convert both points to Cartesian coordinates, calculate the cross product a×b. The direction of a×b is the axis and the magnitude is

|a×b| = |a| |b| sin(α)

where α is the angle between a,b (i.e. the rotation angle which maps a to b).

Conversion to Cartesian coordinates depends upon the interpretation of θ,φ.

If θ is the angle relative to the positive Z axis, θ∈[0,π), and φ is 0 on the X-Z plane and π/2 on the Y-Z plane, φ∈[0,2π), then

x = r sin(θ) cos(φ)

y = r sin(θ) sin(φ)

z = r cos(θ)

Different conventions for θ,φ will produce similar equations but with x,y,z permuted, θ,φ permuted, and/or sin,cos permuted.

Using r=1 => |a|=|b|=1 => |a×b| = sin(α)

[x1,y1,z1] × [x2,y2,z2] = [y1 z2 - y2 z1, x2 z1 - x1 z2, x1 y2 - x2 y1]

Caveat: any value of sin(α) gives you two possible values for α. One will rotate a to b, the other will rotate a to -b (so the vectors will be parallel but in opposite directions). You can use the dot product:

[x1,y1,z1] · [x2,y2,z2] = x1 x2 + y1 y2 + z1 z2

to determine which to use. If a·b is positive, the angle between them is less than π/2, and α should be the principal arcsine (i.e. the value which asin() will return). If a·b is negative, the angle is greater than π/2 so you need to use π-asin(α).

Another caveat: magnitude is always positive so sin(α) and α will always be positive. If you swap the order of the vectors, b×a = -(a×b), i.e. you'll still get a positive rotation but the axis will be pointing in the opposite direction.

Final caveat: if the vectors are exactly perpendicular, floating-point rounding error can result in |a×b| being slightly larger than 1, which will result in asin() reporting a domain error (because sin(x)∈[-1,1]), so you might want to check for that.

Related questions

0 like 0 dislike
0 like 0 dislike
1 answer
MSR_Tlse asked Jun 21
Are the S3/S4 Edexcel Further Maths units useful to become an actuary? Topics include sampling, unbiased and biased estimators, confidence intervals and significance test...
MSR_Tlse asked Jun 21
0 like 0 dislike
0 like 0 dislike
2 answers
driveshift asked Jun 21
I did this all wrong but got the right answer? Took half of .075, used d=(1+i)/i to get discount rate, and just added. Decimal was off, but i got the numbers right. Luck?...
driveshift asked Jun 21
0 like 0 dislike
0 like 0 dislike
4 answers
GCFtalk asked Jun 21
For GHDP, if you had to choose one of the below study material packages.
GCFtalk asked Jun 21
by GCFtalk
0 like 0 dislike
0 like 0 dislike
3 answers
piyu_logy asked Jun 21
Are insurers prepared to handle the legalization of psilocybin?
piyu_logy asked Jun 21
0 like 0 dislike
0 like 0 dislike
0 answers
stefchura asked Jun 21
Introduction to the Theory of Statistics - Mood, Graybill, and Boes
stefchura asked Jun 21

24.8k questions

103k answers

0 comments

33.7k users

OhhAskMe is a math solving hub where high school and university students ask and answer loads of math questions, discuss the latest in math, and share their knowledge. It’s 100% free!