c++ - Rotate around a point with a 3x3 matrix and a translation vector -


i have 3x3 matrix in opengl format , translation vector. confused when rotating around point because rotate function not consider translation.

for rotating assumed change 3x3 matrix quaternion, rotate , change back. not work when rotating other objects current position.

the normal procedure 4x4 matrcies is:

translate point -(point - position)

rotate

translate point (point - position)

optional advice:

bullet physics uses format , why considering using data format store transformations. have convert 4x4 matrix projection, not matter much. bullet's format attractive because removes useless shear data. worth bother keep transformations in bullet format or no?

came one. matrix math. create rotation matrix manually or quaternion , multiply them. bullet i'll show bullet internally too.

*psuedo code

void transform::rotatearoundpoint(axis, angle, point) { matrix3x3 mat = creatematrixfromquaternion(axis, angle); transform rotatetransform; trans.basis = mat; // <- 3x3 matrix trans.origin = vector3(0,0,0); // <- translation vector  // "this" pointer transform being edited since decided write  // member function.  vector3 pos = this->origin; this->origin = this->origin - point;  (*this) = rotatetransform * (*this); this->origin = this->origin + point; }  // internally bullet resulttransform.basis = t1.basis * t2.basis; resulttransform.origin = t1.basis * t2.origin + t1.origin; 

i have not tested code yet. little bit terrified may suffer gimbal lock in actual code going quaternion math when have multiply 2 basis matricies.


Comments

Popular posts from this blog

how to insert data php javascript mysql with multiple array session 2 -

multithreading - Exception in Application constructor -

windows - CertCreateCertificateContext returns CRYPT_E_ASN1_BADTAG / 8009310b -