• 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.

[SOLVED]Getting Nose wheel position

Messages
578
Country
france
Hello guys

back in P3D days I've worked on an Addons that used nose wheel position in order to calculate some distances, my method to get this position was to request attachpoint world position of a taxi light effect used by the aircraft developer
this method used to work very well.

Now, I'm developing for MSFS and I don't see no request attach point data in the simconnect docs nor the H file.
so I tried to calculate this position my self using the position of the aircraft, the distance to the nose wheel, and the aircraft heading

I ended up with this code :


C++:
WorldPos User;
WorldPos Nosecoord;
double distance;
_angle = deg2rad(_angle);

Nosecoord.Latitude = User.Latitude + (MeterToCoordinates(_distance * cos(_angle)));
Nosecoord.Longitude = User.Longitude + (MeterToCoordinates(_distance * sin(_angle)));

unfortunately, this code works perfectly only in the center of the earth map, or the surrounding areas, once I'm at EGLL or some northern airports, the wheel position calculation seems off, the offset varies from 2 to 8 meters depending on the heading of the aircraft

I tried this solution I found on the net but still no luck (the calculation is very offff)

Code:
// _coord is user position and coord is nose position

    double R = 6378.1; //Radius of the Earth
        double brng = deg2rad(_angle);
        double d = _distance * 1000; // in Km
_coord.Latitude = deg2rad(_coord.Latitude);//
        _coord.Longitude = deg2rad(_coord.Longitude);
        coord.Latitude = asin(sin(_coord.Latitude) * cos(d / R) +
            cos(_coord.Latitude) * sin(d / R) * cos(brng));

        coord.Longitude = _coord.Latitude + atan2(sin(brng) * sin(d / R) * cos(_coord.Latitude),
            cos(d / R) - sin(coord.Latitude) * sin(coord.Latitude));


I tried to use contact points in the flightmodel.cfg but it only gives the distance to the wheel

Any Idea ??

thanks in advance :)
 
I've done this before.

If you don't know what you're doing then you're going to have a bad time.

I could post my code by it uses the coords of a weapons station relative to the aircraft position and pitch, bank and heading to produce latitude, longitude and altitude to spawn a weapon so it's probably a fair bit more complicated than what you need.

I think this is what I have for converting to account for the shrinkage in longitude as you go north/south in latitude.

Code:
    float lat1 = float(tlatitude / 180 * MYPI);
    lat1 = cos (lat1);
    if ( lat1 == 0 ) lat1 = float(0.0000001);
    rlon = rlon / lat1;

Firstly you need to calculate the position as if you were on the equator
lat1 is just a temp variable, I think the first line is converting to radians.
tlatitude is the latitude you have calculated.
MYPI is 3.14159 etc
You need to account for lat1 being zero so you don't divide by zero (this will be at the north and south poles)
rlon is the longitude you have calculated.

I think that might work. Essentially, as you go up in latitude the longitude is divided by the cos of the latitude. It's probably something you want to draw on paper first and then run through a spreadsheet. Like I said, you need to think about this to get the results you want.
 
I don't seem to be able to make it work
here is the code I'm ending up with (I think you forgot to convert rlon to rad)

C++:
    WorldPos _coord; // input
    WorldPos coord; // output

    _angle = deg2rad(_angle);
    coord.Latitude = _coord.Latitude + (MeterToCoordinates(_distance * cos(_angle)));
    coord.Longitude = _coord.Longitude + (MeterToCoordinates(_distance * sin(_angle)));
 
    double lat1 = deg2rad(coord.Latitude);
    lat1 = cos(lat1);
    if (lat1 == 0) lat1 = double(0.000000001);
    double rlon = deg2rad(coord.Longitude);

    rlon = rlon / lat1;

    coord.Longitude= rad2deg(rlon);
   
    return coord;

here is what meters to coordinates is doing :


C++:
double MeterToCoordinates(double m)
{
    return m / (1852 * 60);
}


ps. it only works at the equator
 
Last edited:
The distance for a degree of longitude changes based on the latitude value. Your code does not take that into account.
 
The distance for a degree of longitude changes based on the latitude value. Your code does not take that into account.
I thought about it, but the difference is minimal because we're talking about meters to really significant coordinates

@Anthony31 I would like to thank you
I reread this sentence and I somehow I coded it :
Essentially, as you go up in latitude the longitude is divided by the cos of the latitude

here is the final code:
C++:
coord.Latitude = _coord.Latitude + (MeterToCoordinates(_distance * cos(_angle)));
    coord.Longitude = _coord.Longitude + (MeterToCoordinates(_distance * sin(_angle))) / cos(deg2rad(coord.Latitude));
 
I thought about it, but the difference is minimal because we're talking about meters to really significant coordinates

@Anthony31 I would like to thank you
I reread this sentence and I somehow I coded it :


here is the final code:
C++:
coord.Latitude = _coord.Latitude + (MeterToCoordinates(_distance * cos(_angle)));
    coord.Longitude = _coord.Longitude + (MeterToCoordinates(_distance * sin(_angle))) / cos(deg2rad(coord.Latitude));
Just make sure you never get a zero for cos(deg2rad(coord.Latitude)) which I think will happen at exactly 90 degrees north otherwise you're going to get a divide by zero error.

Things do get a bit sketchy around the poles though because even the latitude would need to be adjusted. When you think about it, if you are 10 metres from the north pole then the latitude is going to be a circle with a 10 metre radius so to be pin point accurate you'd have to use some other formula to adjust for that. In theory you could have a 747 where the aircraft is at 89.9999N 45W and the front wheel would be at 89.9999N 135E (ie, straddling the pole). In practice, it's only going to be a problem if you're flying very close to the poles.
 
I will write it with a red font " Addon not to be used around the poles"

Seriously though, it would be interesting to solve this problem. I'm thinking about normalizing the coordinates, instead of having N89.9999999 I will normalize it to be lat = lat - 45° and then add 45° at the end while accounting for coordinates switching from east to west or vice versa

But for now, the poles will be a no fly zone for my addon
 
I thought about it, but the difference is minimal because we're talking about meters to really significant coordinates
Using the cosine of the latitude to calculate the longitude is doing exactly what I pointed out you needed. 🙃
 
Back
Top