setAngularVelocity() help


I need a little clarification on how to use this function. Mainly on the structure of a angular velocity vector. Also I am wondering how I could use this angular velocity vector to make an object make itself copy another objects orientation using .worldOrientation.

Figured it out:

nodRot = obj1.worldOrientation.to_euler()
tarRot = obj2.worldOrientation.to_euler()
tmp = 30
dirRot = [(nodRot[0]-tarRot[0])*tmp,(nodRot[1]-tarRot[1])*tmp,(nodRot[2]-tarRot[2])*tmp]

where tmp is strength/speed it moves.

Angular velocity is just the angular velocity at the current logic tick from the physics engine. Just directly assign the rotation using worldOrientation.

I want it to slowly move to position with physics stopping the movement if it is in the way. obj1.worldOrientation = obj2.worldOrientation just doesn’t cut it.

I have a ragdoll of which I am trying to animate. So I am trying to set the angles of the ragdoll bone to match an armature. If I use obj1.worldOrientation = obj2.worldOrientation the limbs will snap to their positions with no “give” because they are there next frame. Using angular velocity makes the limbs “glide” there with an editable force. Though as I keep testing I find my ragdoll to spaz out, which is currently what I am trying to fix.

I never worked on a ragdoll. As far as I understood the concept you use an invisible physics model to simulate ragdoll (with rigid body joints etc.). To make it visible you copy the orientations of the ragdoll components to the bones of the armature.

You do not smooth out anything. This is done by the physics engine on the calculated physical behavior.

But I might be wrong with that.

incredible, work … almost , if there more axis to rotate , not much .
euler seem handly but is not reliable as matrices or quaternion :rolleyes:

I have been trying many different methods, using rotation matrices and quaterions. I can’t seem to get anything to work properly so I am dropping it from my game for the moment. but here is my quaternion code, it also doesn’t work well.

def quatDiv(q,r):
    out = q.copy()
    #        (r0^2+r1^2+r2^2+r3^2)
    div = r.w*r.w+r.x*r.x+r.y*r.y+r.z*r.z
    #        (r0q0+r1q1+r2q2+r3q3)
    out.w = (r.w*q.w+r.x*q.x+r.y*q.y+r.z*q.z)/div
    #        (r0q1-r1q0-r2q3+r3q2)
    out.x = (r.w*q.x-r.x*q.w-r.y*q.z+r.z*q.y)/div
    #        (r0q2+r1q3-r2q0-r3q1)
    out.y = (r.w*q.y+r.x*q.z-r.y*q.w-r.z*q.x)/div
    #        (r0q3-r1q2+r2q1-r3q0)
    out.z = (r.w*q.z-r.x*q.y+r.y*q.x-r.z*q.w)/div
    return out

                    nodRot = i[0].worldOrientation.to_quaternion()
                    tarRot = i[1].worldOrientation.to_quaternion()#to_euler()
                    quatBet = quatDiv(nodRot,tarRot)
                    rotVec = quatBet.axis

                    inert = i[1].localInertia
                    rotVec.x = rotVec.x*inert.x
                    rotVec.y = rotVec.y*inert.y
                    rotVec.z = rotVec.z*inert.z


eh, i also have tried with matrices (this is right surely) but i guess the problem is when you have to transform in euler.

otherwise was :

mDif = (ob1.worldOrientation.inverted() * ob2.worldOrientation)
eDif = mDif.toEuler()

but work only in some circumstance, bad

you are sure to need angularVelocity?
because if you want that follow the rotation just not too abrupt , you can do this :

ob1.worldOrientation = ob1.worldOrientation.lerp(ob2.worldOrientation, 0.1)

this work perfectly

or , with angularVelocity:

it seem that work: (bit long)

c1 = own
c2 = obs["Cube"]
x1,y1,z1 = c1.worldOrientation.transposed()
x2,y2,z2 = c2.worldOrientation.transposed()

q1 = x1.rotation_difference(x2)
q2 = y1.rotation_difference(y2)
q3 = q1 * q2
e = q3.to_euler()

c1.worldAngularVelocity = e

c1.worldPosition = c2.worldPosition

what you think
is buggy euler ?

Both of those codes work rather nicely, much better than what I am currently using, thank you. :smiley:

i not know , to me seem all bugged more or less :smiley: , except the second that not use angularVelocity (…and not use euler!)