Link to home
Start Free TrialLog in
Avatar of verintsupport
verintsupport

asked on

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
Avatar of ozo
ozo
Flag of United States of America image

angle = atan2(y,x)
y = sin(angle)*distance
x = cos(angle)*distance
Avatar of verintsupport
verintsupport

ASKER

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....
i think i need to isolate Pa.Lat_origin and Pa.Lng_origin to find my answer
so basically:

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


Pa.Lat_origin = ?

Pa.Lng_origin = ?
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)
ASKER CERTIFIED SOLUTION
Avatar of ozo
ozo
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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?