Rotation and Radius around mesh

Hi! In this example
i want with help of 2 sliders (one for radius and one for angle) to rotate and change radius of the black sphere around red sphere. Can someone help me??

Hi M. I worked with it for a little while. Interesting quaternion func, there. I’m certainly no pro with quaternions/.rotationQuaternion… I’m more familiar with Euler angles/rotations.

I put pseudo_pivot2.rotateAroundPivot on the renderLoop in line 151, and fed it some values. In this demo, the pivot point is ALWAYS the red sphere position, but the radius slider is a position setting for the black sphere. It sort-of acts the same as a radius.

It’s starting to work. Put some time and experiments into it, and you should be rolling. I think the whole thing could be re-coded using Euler angles, and might be much easier to understand. But there are SOME reasons to use Quaternions, too.

That center Axis slider really needs 3 separate sliders… but I was too lazy. :slight_smile: I don’t really like how it is currently acting.

The third slider… is essentially acting like a “step” or “speed” in this case (with an animation like this). I didn’t analyze what is happening in rotateAroundPivot very carefully… it sort of scares me. :slight_smile: But that angle setting appears to be “angle added/subtracted to/from current angle”… and thus… can be used as a “reverse”, too… via negative/positive switching.

I hope I’ve been helpful. Others may comment and/or modify that playground, soon. And if you have questions… there may be some Quaternion gurus nearby.

Thank you for your quick responce. I want to set the radius as you do it. But the rotation i want to set it with the slider only on xz axis. I want to rotate and change radio only with sliders and only on xz axis … To be more clear. When i rotate with slider around the sphere when i change the radius i want to change it in the spesific position (not only x axis but xz).
The function for rotation is a copy from forum

Hi again. Ok, I removed the quaternion function… and used Euler values instead.

Pretty basic. I changed some variable names.

Lines 55, 85, 136 (identical lines) are pretty important, and that’s why it needs to be done “initially”, and then re-done after any slider adjustment.

Lots of good info here: Set and Use a Pivot - Babylon.js Documentation

Are we getting closer to what is wanted? I think I’m missing the goal, but maybe you can adjust.

Only circular orbits… no elliptical orbits. I’m not sure how to do elliptical orbits, if needed.

And, as you noticed, no “automated orbiting” here. Using angle slider for orbiting… which is simply rotating the orbiter mesh. Because its pivotPoint is quite “offset”… it rotates around a “remote point”… which happens to be the position of the pivot mesh (because of those 3 position-subtracting, pivotPoint-setting code lines).


Thank you my friend!!! Extactly what i need!!!

1 Like