# A question about rotating around a object

So I noticed when you use sin and cos to make an object rotate around another,the closest object seems to rotate slower than the object farthest. Why does this happen? How can I make the farthest have the slowest speed and the nearest the fastest?@OMTL(sorry if you didn’t want to get tagged.)
Can you guys help?

11 Likes

Try @Stradyvarious’s solution and tell us if it worked!

2 Likes

I’m gonna need a screenshot of this. I can’t exactly picture it.

1 Like

Hi @Aariv what you’ve noticed is the difference between rotational velocity & linear velocity.

I’ll explain this better a bit later in the day when I have more time, but when 2 objects turn at the same rate (rotational velocity), the one making the larger circle will be moving faster (linear velocity). It moves faster because the circumference of the larger circle is greater.

4 Likes

I am using 1 variable for all of the orbiting objects.

Hi again @Aariv

Here’s an example of what I think you’re trying to do:

https://c.gethopscotch.com/p/zlr3i8lgs

In the example both orbiting “planets” travel at the same linear or tangential speed. That means that even though their respective circles are different diameters, they’re moving at the same Arc Length per frame. Arc Length per frame is a linear speed that’s analogous to meters per second (m/s) as opposed to revolutions per second (RPM) which is a rotational speed.

This is relatively easy to do with a little math. Here’s how:

C = 2πR

where,
C is circumference
π is pi (~3.14)

S = C(θ/360)

where,
S is arc length
θ is angle (the angular change per frame)

Then solving for θ
θ = 360S/(2πR)

In the example project I refer to θ as “Rotational Speed”.

Then we use this by incrementing the “Rotational Position” by the “Rotational Speed” every frame (in a When 7=7 block)

Also every frame we reposition the rotating objects using the cosine and sine formulas.

X Position formula:
(Radius * Cosine(Rotational_Position)) + X_position_of _center

Y Position formula:
(Radius * Sine(Rotational_Position)) + Y_position_of _center

And that’s it (this should make more sense if you look at the code in the example project)

5 Likes

Thanks for the help,@ThinBuffalo!

1 Like

@Stradyvarious, I didn’t quite understood what you said there. Could you simplify it?

1 Like