saharan / OimoPhysics

A cross-platform 3D physics engine
MIT License
863 stars 68 forks source link

How to rotate a rigid body around a point or any axis, and around three-quarters of the body, rather than around the center #13

Closed WREQI closed 6 years ago

WREQI commented 6 years ago

How to rotate a rigid body around a point or any axis, and around three-quarters of the body, rather than around the center

saharan commented 6 years ago

You can use Mat3#appendRotation to make a rotation matrix around an arbitrary axis. There's no method to directly rotate a rigid body around a specified point, so you should apply some translation after the rotation to get desired effect. RigidBody#getWorldPoint and RigidBody#translate may help you to do that.

WREQI commented 6 years ago

Thank you @saharan

WREQI commented 6 years ago

@saharan Is it possible to use hinge joints? Or in three.js, by adding objects to the parent object, by rotating the parent object, the child object can be rotated around any point, or in oimo by adding a parent object rigid body?

saharan commented 6 years ago

Yes, revolute joints play the same role as hinge joints (as written in README.md). There are no parent-child relationships between rigid bodies, though.