Translating Speed into rotation degress\sec

Hi all!

If I understand correctly, then transform.rotatearound uses three variables. The first is a transform to orbit, the second is the direction of the rotation and the thid (which is what I wish to discuss) is the speed of the rotation calculated via degrees per second (or whatever timeframe you choose).

What I wish to ask is - Say that an object moves in a certain speed and is then oredered to orbit another object via the RotateAround command. How to I assign it a correct degrees per sec value that will maintain it’s current speed perfectly and (if needed) translate it back into speed should I wish it to lose its’ orbit?

I know it has something to do with the distance between them but my brain just can’t figure out the physics…

Lastly, and on a related note - the Direction. How do I make sure that, given the velocity vector of an object A and it’s relation in space to object B, said object A enters orbit in a direction that fits its’ inital velocity. I managed to figure out a very VERY rough system with many “if” clauses to figure out all possible cases for this but I was wondering if maybe there is a more elegant approach :slight_smile:

much obliged!

The linear velocity v = w * R, where w is the angular velocity and R is the radius, thus w = v / R. Converting this from radians we have the formula for the velocity (degrees per second): w = 180 * v / ( pi * R ).

The rotation axis is [ v, ( B - A ) ], where B - A is the vector from the center of rotation to your object (they should not be collinear in order to get a non-zero axis). So you can rotate around Vector3.Cross( v, B-A ).normalized. If it goes in the wrong direction then change the sign of the vector. :slight_smile: