# (gradually) Rotate towards a point

Chat about anything not covered in these forums, but keep it civil!

### » Thu Sep 02, 2010 12:25 pm

Hi,

I'm developing an Android game in Java, obviously. I would like to know how the devs did the rotate towards a point (gradually) function in Construct. Probably you used vector math, that's not a problem.

EDIT: Actually, I have a variable that stores an angle, calculated thanks to the angle formed by the inclination of two accelerometer axis (X & Y):

resultingAngle = (float) Math.toDegrees(Math.atan2(accelerometerActualX, accelerometerActualY));

So, my car should gradually turn CW or CCW towards that angle.

Thanks
B
2
S
2
G
3
Posts: 193
Reputation: 1,636

### » Thu Sep 02, 2010 12:40 pm

Search for the word "rotate" on this page and you can see the actual source:

http://construct.svn.sourceforge.net/sv ... ctions.cpp
Spriter Dev
B
103
S
22
G
12
Posts: 3,283
Reputation: 17,147

### » Thu Sep 02, 2010 12:51 pm

I was looking for this. Thank you!

[code:1zlty283]resultingAngle = (float) Math.toDegrees(Math.atan2(accelerometerActualX, accelerometerActualY));
angle = main.RotateTowards(angle, resultingAngle, 1 * speed);[/code:1zlty283]

It's just perfect.
B
2
S
2
G
3
Posts: 193
Reputation: 1,636