Rotating around a moving point
See original GitHub issueTrying to get some solar system action going (not really, but similar mechanics) with three.js. I have code that kinda works but seems far from elegant. Also, the whole adding and subtracting the position business is off.
What would be the proper way to do this? I don’t think I can use a dummy object (see #1593) in this program because the center point may change during runtime.
Code: http://jsfiddle.net/HVBAP/1/
The crucial pieces are:
mat1 = new THREE.Matrix4();
axis = new THREE.Vector3();
axis.sub(two.position, one.position);
axis.crossSelf(new THREE.Vector3(1,0,0));
axis.normalize();
mat1.makeRotationAxis(axis, 0.005);
and in animate():
two.applyMatrix(mat1);
two.position.addSelf(one.position);
two.updateMatrix();
renderer.render( scene, camera );
two.position.subSelf(one.position);
two.updateMatrix();
Pardon my ignorance, I’m new to 3d.
Issue Analytics
- State:
- Created 11 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
Rotation Around a Point - Expii
To rotate a shape or object means to spin it around a specific point (center), without moving it in any other way. Rotation...
Read more >mechanics - Rotation about a moving axis - Britannica
Rotation about a moving axis ; space may be described as a combination of ; axis through the centre of mass. The ;...
Read more >Rotation around a fixed axis - Wikipedia
Rotation around a fixed axis is a special case of rotational motion. The fixed-axis hypothesis excludes the possibility of an axis changing its...
Read more >Maths - Rotation about a point - Martin Baker - EuclideanSpace
The point that we rotate around must by equidistant to the chosen point on each body, therefore it must lie on a line...
Read more >Best way to rotate objects around a moving point?
The first problem is rotating all those parts around a constantly moving part, and the second problem is rotating the top without an...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

It’s much simpler than that… 😃
Just to take this one step further, if anyone wants to orbit a moon around the earth, I ended up doing something like this: