# angle of rotation to face the goal • ### Question

• I am working on to drive Eddie toward the goal in simulated Reference platform robot 2011. My problem is how to calculate the angle of rotation that is required to face the goal. For example if the initial position of eddie is (4, 0.003, 8.3) with orientation (0,0,0) and the goal position (tv stand) is (9.582, 0.204,14.227) in simulation environment, then how much rotation is needed for desired heading to the goal?
I tried to calculate angle from coordinates using arctangent function (theta=atan(y/x)). However it returns an small angle that is not sufficient for desired heading to the goal.

Tuesday, November 5, 2013 7:36 AM

• Note that .NET System.Math APIs are in *radians*, while simulation entity rotation values are in degrees!

Also note that the coordinate frame is such that x and z are the position on the floor, and y rotation is the heading (in degrees).

This expression might be what you're looking for?

`Math.Atan2(tv.X - robot.X, tv.Z - robot.Z) * Radians2Degrees`

I get 43.3 for the coordinates you give, which looks reasonable.

Wednesday, November 6, 2013 7:33 PM