jiandingzhe wrote:Here I got the first confusion: How to convert the vector torque to a quaternion torque? Just using the vector length as a angle, and the normalized vector as the axis?
that question does not make sence, you cant conver a vectore torque to a quaternion torque, the tow thiong do no have teh same unit.
quaternion are angular values while are rationanl forces.
for a torque to generat roation it need time, and soem instia to operation on,
if you have teh inertia of a body say I
the the euler equation for truqe is this
T = g * I
I is moment of intertia, and g in the nagular acceleration, the is valid on all coodinate system as long as the inertia frame they are in, is not rotating.
The most convenienet coodinate system to work with angular values is the instantaneus local frame of the body, so if the above equation is in global space and the bnody has a matrix M
you can write this expresion
Tw = gw * Iw
where w means global space. To rotate to local space you apply teh rotation matrix
Tw * tr(M) = gw * Iw * tr(m)
ts(m) is the transpose of the matrix
now you can write
Tw * tr(M) = gw * tr(m) * m * Iw * tr(m)
where tr(m) * m is an identity matrix
now you can write
Tw * tr(M) = [gw * tr(m)] * [m * Iw * tr(m)]
Tl = gl * Il
now you have a equation that relate teh local Inertia whi is a diagonal matrix Il[ixx, Iyy, Izz] to teh local acceleration an dteh local torque
this is not an angular value still, now you have to apply time so that the local torque rotate on the body.
the importance of making the above algegratic manipulation is because you can not integrate the expresion T = g * I very eassilly
g and I are two time variant quantities, you will have to apply the equations of calculus of varations to get a correct result.
appling the algebraic manipulation you get Tl = gl * Il where Il is a constant, threfore the integration of Tl is proportional to the integration of gl
now we can safatelly integrate Tl by multipling Tl by the inverse of Il or we can caluet a delt impoulse by simpel mutiplyu Tl by dt
gl = Tl * inv (Il)
or
Tl * dt = gl * I; * dt;
and applying the delta time
gl * dt = Tl * inv (Il) * dt
you can rotate that impulse back to global space and add it to the total impuse of the body.