• Status: Solved
• Priority: Medium
• Security: Public
• Views: 1534

# opposite of Atan2? in c# or in regular math

I have:

Pa.Lat_origin=Pa.Lat-Pb.Lat;
Pa.Lng_origin=(Pa.Lng-Pb.Lng)*Math.Cos(Pb.Lat*Math.PI/180);
(Math.Atan2(Pa.Lat_origin,Pa.Lng_origin))*180/Math.PI = angle

I want to isolate angle....

Math.Atan2((Pa.Lat-Pb.Lat),((Pa.Lng-Pb.Lng)*Math.Cos(Pb.Lat*Math.PI/180))) = angle*Math.PI/180

How do i do the opposite of Atan2?

Basically this method is the one i use to find an angle....

Now i want to find a point based on an angle.

Thanks

Richard
0
verintsupport
• 4
• 3
1 Solution

Commented:
angle = atan2(y,x)
y = sin(angle)*distance
x = cos(angle)*distance
0

Author Commented:
angle in rad or in degree?

y = sin(angle)*distance
x = cos(angle)*distance
is good in a cartesian plan but in lat longs, i need to modify my long according to the lat

this is what i did when finding the angle.... how do i reverse that?
Pa.Lng_origin=(Pa.Lng-Pb.Lng)*Math.Cos(Pb.Lat*Math.PI/180);

Maybe i'm complicating things to much....
0

Author Commented:
i think i need to isolate Pa.Lat_origin and Pa.Lng_origin to find my answer
0

Author Commented:
so basically:

if Angle = (Math.Atan2(Pa.Lat_origin,Pa.Lng_origin))*180/Math.PI

Pa.Lat_origin = ?

Pa.Lng_origin = ?
0

Commented:
if Angle = (Math.Atan2(Pa.Lat_origin,Pa.Lng_origin))*180/Math.PI
Pa.Lat_origin = distance*sin(Angle*Math.PI/180)
Pa.Lng_origin = distance*cos(Angle*Math.PI/180)
0

Commented:
In lat longs, Angle = (Math.Atan2(Pa.Lat_origin,Pa.Lng_origin))*180/Math.PI may not be an appropriate equation, but if that's what Angle is, then
Pa.Lat_origin = distance*sin(Angle*Math.PI/180)
Pa.Lng_origin = distance*cos(Angle*Math.PI/180)
also holds, where
distance = sqrt(Pa.Lat_origin*Pa.Lat_origin+Pa.Lng_origin*Pa.Lng_origin)
0

Author Commented:
ok so i get:

So if the point i'm looking for is Pa then:

(distance*sin(Angle*Math.PI/180))+Pb.Lat = Pa.Lat
(distance*cos(Angle*Math.PI/180))/Math.Cos(Pb.Lat*Math.PI/180)+Pb.Lng = Pa.Lng

right?
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.