Rotation around arbirary point in 2D space

Started by
0 comments, last by vlat456 14 years, 5 months ago
Hello ! Probally my question is quite easy, and I'm sorry to bother yours with such easy things, but I always had a problems with geometry :-) I'm writing GPS-alike plugin for X-Plane flight simulator. The idea behind it is, the plugin receive WGS84 coordinates of navigation points from simulator, and then projects them into planar surface (the screen of GPS receiver in my case). Assuming that simulated geo-sphere is ideal sphere, I do Geodesy -> Cartesian coordinate convertion using next code: void GeoToXY (double lat, double lon, double *outX, double *outY) { double R = 6378.0; *outX = R * cos((-lon*PI)) * cos((lat*PI)); *outY = R * sin((lat*PI)); } where R is radius of the Earth. And it seems this code is working right, I'm able to see all pre-programmed Nav-aids in right order in right place on 2D surface. However, since I'm using "direct projection" (assuming the aircraft "stay in place, and world is moving around it"), I have to rotate my projected navigation points around the aircraft position. The problem is that, the aircraft position is far not 0,0, it can be anything, since I receive it's position as WGS, and convert it to cartesian too. So, the question is, how to rotate a points(navaids) in planar space around a given point(aircraft) ? I tried x' = dist*sin(angle) / y' = dist*cos(angle) ,where dist is the distance from the aircraft to a point, but it wasn't worked (every position was screwed up). Any help will be highly appreceated!
Advertisement
Problem solved :-)

I completely forgot about

x' = xcos(a) - ysin(a)
y' = xsin(a) + xcos(a)

This topic is closed to new replies.

Advertisement