PDA

View Full Version : Latlonalt


JVD
29 Oct 2007, 20:45
Hi, quick question.
Does anyone know the format of the LATLONALT structure used by FS9? References can for example be found in gps_info.h.

typedef struct LATLONALT
{
SIF48 lat;
ANGL48 lon;
SIF48 alt;
}

typedef union SIF48
{
struct
{
UINT16 pad;
UINT16 f;
SINT32 i;
};

SINT64 i64;

}

typedef union ANGL48
{
struct
{
UINT16 pad;
UINT16 lo;
UINT32 hi;
};

UINT64 i64;

}

It seems to be very poorly documented as I could not find much information on the internet. Any easy way to get this to degrees or radians in one 8-byte double variable?

Joris

lmoelleb
30 Oct 2007, 13:16
They are documented in the FS 2000 Scenery SDK. Here is some selective copy paste but for full detail you better dig up the document (it might be in a newer SDK somewhere as well, I do not know):


SIF48: 48-bit fixed point value with 32-bits of integer and 16-bits of fraction.

ANGL48 32-bit PseudoDegrees used for Longitude. This usually has 2 parts: “lo” which is the low 16-bits and “hi” which is the upper 32-bits. (dd and dw in MASM)

The term pseudodegrees is used throughout BGL documentation. In practical terms, using pseudodegrees means letting a binary byte, word, or multiprecision word’s full binary range represent the values between 0–360 degrees

jean DV0961
10 Nov 2007, 17:25
Hi, quick question.
Does anyone know the format of the LATLONALT structure used by FS9? References can for example be found in gps_info.h.

It seems to be very poorly documented as I could not find much information on the internet. Any easy way to get this to degrees or radians in one 8-byte double variable?

Joris

what I know for FS9 is that
You can have
your_plane.position.DistanceTo(GivenLat, GivenLon) (degrees)
your_plane.position.BearingTo(GivenLat, GivenLon) (degrees)
your_plane.position.magneticVariation (degrees)
your_plane.position.Altitude (feet)

the POSITION object contains lat, lon, and alt as floating-point decimal degrees

Hop it will help

beatle
11 Nov 2007, 14:30
Basically the best way to think about the PsuedoDegree and the Fractional portion of a SIF values, is this:

RealVal = fract_val / 2 ^ N-Bits

where Fract_val is either the PsuedoDegree or fraction value and N-Bits is the number of bits in the fractional number.

For a SIF48, N-Bits would be 16, and once you got a floating point value from the above equation, you would add in the integer portion of the number.

For an ANGL48, N-Bits would be 48, and once you got a floating point unit value (ie between 0 and 1), you can multiply that by either 360 (to get degrees) or by 2*pi if you want radians.

There are other bit-sized versions of these, so make sure you are using the right N-Bits value when dealing with these data types.

As a little history into why these types exists, back in the good ole days (or maybe not so good ole :-> ) most computers didn't have a floating point processor unit, so we had to rely on integer approximation routines to do our floating point calcs and our data types reflected that as well.

Now adays the math is done using regular floating point numbers and functions as thats now a default part of computers, but the data types still linger.

The trick above can be used to scale any interger number across the full value range of an int var. Say you want to store a value between 0 and 100, using 16 bits, and you want the most resolution possible in the values between those. You could divide the number by 100, multiply it by 65536 (2 ^ 16), and you now have a 16-bit int value that encodes the 0 to 100 range while maintaining the highest resolution (ie all 16-bits are being used). This also allows dropping lower bits if you need to change the precision (drop the lower 8 bits (ie shift the whole number 8 bits to the right), and you now have an 8-bit value representing the same input number).

Tim