Axis/Angle Rotation
Community Forums/General Help/Axis/Angle Rotation
| ||
Hey, admittedly I am [not] stuck at that problem. I tried various solutions assembled from wikipedia. I tried this function from Leadwerks - Function RotatePointAroundVector2( x_:Double, y_:Double, z_:Double, u_:Double, v_:Double, w_:Double, a_:Double, target_x_:Double Ptr, target_y_:Double Ptr, target_z_:Double Ptr ) Local ux_:Double = u_* x_ ' Local vy_:Double = v_* y_ ' Local wz_:Double = w_* z_ ' Local uu_:Double = u_* u_ Local vv_:Double = v_* v_ Local ww_:Double = w_* w_ Local uxvywz_:Double = ux_+ vy_+ wz_ Local sa_:Double = Sin( a_ ) Local ca_:Double = Cos( a_ ) target_x_[0] = ( u_* uxvywz_ )+ .. ( ( ( x_* ( vv_+ ww_ ) )- ( u_* ( vy_+ wz_ ) ) )* ca_ )+ .. ( ( ( -w_* y_ )+ v_* z_ )* sa_ ) target_y_[0] = ( v_* uxvywz_ )+ .. ( ( ( y_* ( uu_+ ww_ ) )- ( v_* ( ux_+ wz_ ) ) )* ca_ )+ .. ( ( w_* x_- u_* z_ )* sa_ ) target_z_[0] = ( w_* uxvywz_ )+ .. ( ( ( z_* ( uu_+ vv_ ) )- ( w_* ( ux_+ vy_ ) ) )* ca_ )+ .. ( ( ( -v_* x_ )+ u_* y_ )* sa_ ) End Function [EDIT:] I just found the all deciding typo. Well, that function from Josh is actually fine, I just made a typo when translating it from B3D *sigh*.. nevermind me ;/ .. corrected, so it will work for you folks too if you need it (kudos to josh for permanent awesomeness!) Function RotatePointAroundVector( x_:Double, y_:Double, z_:Double, u_:Double, v_:Double, w_:Double, a_:Double, target_x_:Double Ptr, target_y_:Double Ptr, target_z_:Double Ptr ) Local mat_:Float[16] glMatrixMode GL_MODELVIEW glPushMatrix glLoadIdentity glRotated a_, u_, v_, w_ glGetFloatv GL_MODELVIEW_MATRIX, Varptr mat_[0] glPopMatrix 'multiply the returned matrix with our favorite vector target_x_[0] = mat_[0]*x_ + mat_[4]*y_ + mat_[8]*z_ target_y_[0] = mat_[1]*x_ + mat_[5]*y_ + mat_[9]*z_ target_z_[0] = mat_[2]*x_ + mat_[6]*y_ + mat_[10]*z_ End Function I just want a clean and straightforward mathy solution.. but I simply cant get my head around the how. So.. any suggestions on this? (I'd be satisfied with the content of glRotateD() :) |