• Which the release of FS2020 we see an explosition of activity on the forun and of course we are very happy to see this. But having all questions about FS2020 in one forum becomes a bit messy. So therefore we would like to ask you all to use the following guidelines when posting your questions:

    • Tag FS2020 specific questions with the MSFS2020 tag.
    • Questions about making 3D assets can be posted in the 3D asset design forum. Either post them in the subforum of the modelling tool you use or in the general forum if they are general.
    • Questions about aircraft design can be posted in the Aircraft design forum
    • Questions about airport design can be posted in the FS2020 airport design forum. Once airport development tools have been updated for FS2020 you can post tool speciifc questions in the subforums of those tools as well of course.
    • Questions about terrain design can be posted in the FS2020 terrain design forum.
    • Questions about SimConnect can be posted in the SimConnect forum.

    Any other question that is not specific to an aspect of development or tool can be posted in the General chat forum.

    By following these guidelines we make sure that the forums remain easy to read for everybody and also that the right people can find your post to answer it.

Latlonalt

JVD

Messages
6
Country
belgium
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
 
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
 
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
 
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
 
Back
Top