I want to rotate a point on a sphere surface . I was instructed as I can use Rodrigues rotation formula , (I thank ja72 very much). I tried to use the formula but it did not work . I can not find where I was wrong . I wrote a short Scilab program for explanation of my current understanding on the formula. Please someone point out where I am wrong.
Thank you very much .
Formula: rotation_matrix = I + sin(θ) * [k]x + (1 - cosθ) * [k]x ^2
In details , the center is at [ 0,0,0 ] and the radius = 1 . I named the point to rotate as point_before . The axis is decided by point_axis and the center point . The angle of rotation = 120 degree.
Scilab code .
//center = [ 0 , 0 , 0 ]
//radius ; point to rotate ; point to decide axis ; and its unit vector matrix; angle
radius = 1.0
point_before = [ radius ; 0 ;0 ]
point_axis = [ 1 , 2 , 3 ]
vector_axis33 = [ 0 , -3 , 2 ; 3 ,0 ,-1 ; -2 , 1 , 0 ] / sqrt( 1 + 2*2 + 3*3 )
angle120 = 3.141592 * 2 / 3
//Identity matrix ; the number in the formula ;the number in the formula
Identity=[ 0,1,0 ; 0,1,0 ; 0,0,1 ]
sin_120 = sin( angle120 )
cos_120 = cos( 1 - angle120 )
//rename variables as short names
I = Identity
uv = vector_axis33
uv2 = uv * uv
//use the formula
rotation_matrix = I + sin_120 * uv + cos_120 * uv2
//the point after the rotation
point_after = rotation_matrix * point_before
//the output ; it is not on the original sphere
- 0.4258284 0.7598773 - 0.3646421