Is there a function that does the inverse of setLinearVelocity?

Version 2.58a

The function linearVelocity does not return global linear velocity referenced to the global frame.

eg
getting the component of velocity of object obj
vx = obj.scene.linearVelocity[0]
vy = obj.scene.linearVelocity[1]
vz = obj.scene.linearVelocity[2]

The components vx. vy and vz are referenced to the object’s frame. If the object is not rotating and the x, y and z axes ([0], [1], and [2]) of the object are aligned to the global axes then the returned values are the same for both the object and global frames.

If the axes of the object are not aligned with the global axes then a calculation is required to convert to the global frame. The object may be rotating and the alignment continually changing.

Is there a function that returns the linearVelocity of an object referenced to the global frame or do I need to do the calculations?


To put it another way.

obj.scene.setLinearVelocity([x, y, z]) sets each component of the objects linearVelocity with respect to the global frame. linearVelocity is not the inverse of setLinearVelocity.

Is there a function that does the inverse of setLinearVelocity?

Maybe “object.worldLinearVelocity = Vector”?

Edit: I’m not sure why you have “.scene” in your calls. You can directly access the properties of an object once you have the object reference.

Incidentally, setLinearVelocity can take two arguments. If you use object.setLinearVelocity(Vector, True) you can set the velocity locally. The second argument defaults to False to apply the velocity in world coordinates so is usually left out. You might have known this already, but I thought I’d mention it just in case.

Thank you,

worldLinearVelocity did the trick.