PDA

View Full Version : Where can i find a formulae for increment a lat-lon position?

Manuel Ambulo
15 Jan 2007, 23:19
Hi,

I just wanted to know if anyone, know a place where i can find a formulae for extrapolate a lat-lon position?.

Example, my aircraft's current position is:

latitude: 9.45678 (in degrees units)
longitude: -89.234324 (in degrees units)
altitude: 2000 (in feet units)

the aircraft is flying with this velocity:

north velocity: 100 feet/second
east velocity: 100 feet/second
vertical velocity: 500 feet/second

How can i get the increments to add to the current position so i get the new position of the aircraft? if delta time is 0.25 seconds?....

This is more like a physic or math question, but i do really need this formulae.

Best Regards,

Manuel Ambulo

lc0277
16 Jan 2007, 03:53
My method (which is probably not the best) would be :

- convert "north" and "east" speeds (respectively vx and vy) to angular velocity (wx and wy) :
wx = vx / (R +alt)
with R the radius of Earh (use same units, ie feets here) and alt current altitude above ground. wx will be in rad/seconds, so convert it to deg/s if you are working with degrees coordinates.

- For each time frame, increment position using this angular velocity. The formula for calculating position between two frames will be:
x(t+dt) = x(t) + wx * dt
With dt the time between two frames.
and same for y(t+dt). If you are working into a simconnect event or similar, you would probably calculate dt manually (time difference between each frame) since it can vary slightly for each frame.

For the "Z" altitude axis, no need to convert speed to angular velocity.

However, I don't know how FS will react to this. The object you are simulating will probably looks like "jumping" from one position to another if the speed is too fast. And you need to calculate pitch/bank/heading angles to get a realistic motion.

I have also this kind of problem actually for an addon I'm programming, and I really think
that the best solution is to let FS do the simulation job. Either setup an aircraft simobject
container for your object and use it's flight dynamic with waypoints, or use slew motion.
When in slew, you only need to send the value of velocity on each axis and FS will calculate the position.

Manuel Ambulo
17 Jan 2007, 16:02
My method (which is probably not the best) would be :

- convert "north" and "east" speeds (respectively vx and vy) to angular velocity (wx and wy) :
wx = vx / (R +alt)
with R the radius of Earh (use same units, ie feets here) and alt current altitude above ground. wx will be in rad/seconds, so convert it to deg/s if you are working with degrees coordinates.

- For each time frame, increment position using this angular velocity. The formula for calculating position between two frames will be:
x(t+dt) = x(t) + wx * dt
With dt the time between two frames.
and same for y(t+dt). If you are working into a simconnect event or similar, you would probably calculate dt manually (time difference between each frame) since it can vary slightly for each frame.

For the "Z" altitude axis, no need to convert speed to angular velocity.

Thanks very much, lc0277...:) . I also has a question, eeh the what is the radius of the earth?,...i think that value is in the Scenery SDKs, of i think in the FS2002 SDKs, but dont know where it is...i know that i can search the web and find it, but if u have that value "in the hand" (just next to you), i would appreacite if you could give it to me....:o..(sorry by the inconvence...but again thanks very much for the formulae)

About converting the rad/seconds to degrees/second, i think that i should use:

to convert to degrees/second right?...i others words:

the "wx_rad" is the same result i get from the:

wx = vx / (R +alt)

Another thing, the alt in the above formulae, can i use the altitude provided by the "PLANE ALTITUDE" variable (found in the SIMULATION VARIABLES list?)...Im asking because the add-on im working in, gets part of the information from FS2002/2004 multiplayer packet send from others Flight Simulators...and it pickups the altitude from there...but i can modify it in a way so it can also send the altitude above the ground (AGL), but before doing that modification (which takes time to do...hehehe)...just wanted to be sure that if it MUST BE AGL (above ground), or it can be the altitude of the aircraft MSL (mean sea level)...

About delta time (dt) i can get it from an event that i can suscribe to the SimConnect server, which can return the visual frame rate, so then i just do: (1/fps), and it should give the delta time in seconds, of the current visual frame rate which varies....

I have also this kind of problem actually for an addon I'm programming, and I really think
that the best solution is to let FS do the simulation job. Either setup an aircraft simobject
container for your object and use it's flight dynamic with waypoints, or use slew motion.
When in slew, you only need to send the value of velocity on each axis and FS will calculate the position.

Yes, the best solution is giving to the AI aircrafts the waypoints, but im working the add-on based in multiplayer, so i dont have more choices to just create the aircrafts movements by my own (from the add-on), thats why i need to extrapolate the position every certain time until it arrives a new packet from the remote aircraft, telling the new position and current velocity...

A BIG THANKS, lc0277,

Best Regards,

Manuel Ambulo

Javier
17 Jan 2007, 17:31
I don't know the exact web but Google for GFC or GFCSharp. They are C++ and c# libs and both have that function (and many others, with source code).

Best Regards,
Javier.

lc0277
17 Jan 2007, 19:25
I also has a question, eeh the what is the radius of the earth?,...i think that value is in the Scenery SDKs, of i think in the FS2002 SDKs, but dont know where it is.

I personnally use 6378137 meters, which is close to values you can find on the web. But remember that the Earth on FSX is not round, it's ellipsoid. Consequently, radius is not constant. In many applications, the approximation error is insignificant, but I don't know exactly how much. It will probably not be noticeable for such "little" variations.

correct

Another thing, the alt in the above formulae, can i use the altitude provided by the "PLANE ALTITUDE" variable (found in the SIMULATION VARIABLES list?)...

Yes, it's the plane altitude above "earth radius", meaning sea level, invariant of altimeter settings and so PLANE ALTITUDE is good.

Yes, the best solution is giving to the AI aircrafts the waypoints, but im working the add-on based in multiplayer, so i dont have more choices to just create the aircrafts movements by my own (from the add-on), thats why i need to extrapolate the position every certain time until it arrives a new packet from the remote aircraft, telling the new position and current velocity...

Slew mode could be also a good choice.
In slew mode, you only send values of speed on each axis, so the simulator will continue
to animate planes even if it did not receive values for a long time. No need to calculate position, just feed speed & direction of movement. The main problem will be to convert plane speed values to slew axis values, which are not linear :eek:

Manuel Ambulo
21 Jan 2007, 13:54
Hi,

Thanks VERY MUCH guys, i got it working i mean, i got the way to move an AI aircraft updating it's position every visual frame, and it move just fine, i need just a few tests, but from what i can see, it works very nice, so again THANKS, lc0277 and Javier. I tried using SLEW, but when i wanted to set things like FLAPS, SPOILERS or any moving part, they dont move during SLEW mode, so i chose by extrapolating every visual frame until a new position/velocity packet arrives...so THANKS again :)

Best Regards,

Manuel Ambulo