Is there a way to calculate the linear velocity (relative to world space) of a point on an object in PhysiJS, utilizing the object's linear and angular velocity?
I considered creating an invisible vertex on the object for this task, but it seems like the API doesn't support that functionality. Do I have to manually calculate it based on the translational and rotational velocity of the object? (And if so, does THREE.js or PhysiJS provide a straightforward method for doing so?)
Starting from the basics:
- Given
object.position
(1) - Given the position of the point in world space
object.localToWorld(point)
(2) - Given
object.getLinearVelocity()
(3) - Given
object.getAngularVelocity()
(4)
Therefore, I need to:
- Subtract (1) from (2) to find the point's offset in world space (5)
- Utilize (4) and (5) to determine the linear velocity of the point relative to the object (6)
- Add (6) and (3) to obtain the total linear velocity of the point
To achieve the first and third steps, I can utilize Three.js's Vector3 methods .sub(Vector3)
and .add(Vector3)
. However, the middle operation is challenging me, although I suspect it involves some form of multiplication. What operation should I employ, considering that (4) can be either a Euler angle or a Quaternion?
My familiarity with matrices is quite limited (and rusty!), and I have no experience with quaternions.
You can access Three.js's API documentation here.
Thank you!