confusions on angular properties

A place to discuss everything related to Newton Dynamics.

Moderators: Sascha Willems, walaber

confusions on angular properties

Postby jiandingzhe » Thu May 31, 2012 9:46 am

This question is not about the Newton engine, but this forum is the only place I know to get help on such questions...

I'm used to work with angular properties using quaternions, as they are easy to be combined, and fast to be applied on points. However, some angular properties are natually generated in the form of vector. For example, torque = arm X force.

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?

In addition, in a demo engine, I got a torque accumulator like this:
Code: Select all
// suppose vector is a trivial 3D vector class
class Body {
    vector force_accum;
    vector torque_accum;
    vector position;

    void addForce(vector& force, vector& point) {
        force_accum += force;
        vector3 arm = point - position;
        torque_accum += cross(vector,force);
    }
};

Here I got more confusion on the additivity of vector rotation. It seems if torque is a quaternion, we have torque_accum *= torque. But why rotation vectors are able to be added?

Thanks for a lot!
User avatar
jiandingzhe
 
Posts: 48
Joined: Fri Jul 08, 2011 11:21 am
Location: Beijing

Re: confusions on angular properties

Postby Julio Jerez » Thu May 31, 2012 10:56 am

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.
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: confusions on angular properties

Postby jiandingzhe » Thu May 31, 2012 9:17 pm

Julio Jerez wrote:
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.


I know torque needs time to produce rotation, just like force needs time to produce velocity. The "torque_accum" in previous code just means a sum of many torques, not means integration by time.

So the things like inertia tensor are designed to work with the vector torque?

And this piece of code is used to integrate rotation:
Code: Select all
void RigidBody::integrate(real duration) {
    Vector3 angularAcceleration = inverseInertiaTensorWorld.transform(torqueAccum);
    rotation.addScaledVector(angularAcceleration, duration);
}

void addScaledVector(const Vector3& vector, real scale)
{
    Quaternion q(0,
        vector.x * scale,
        vector.y * scale,
        vector.z * scale);
    q *= *this;
    r += q.r * ((real)0.5);
    i += q.i * ((real)0.5);
    j += q.j * ((real)0.5);
    k += q.k * ((real)0.5);
}

So although torque is something angle and axis, it can only be represented by a 3D vector? And only when being integrated with time, it can be added to a quaternion using the mysterious method above?
User avatar
jiandingzhe
 
Posts: 48
Joined: Fri Jul 08, 2011 11:21 am
Location: Beijing


Return to General Discussion

Who is online

Users browsing this forum: No registered users and 1 guest

cron