Hello everyone.

We have decided to phase out the Mixed Reality Forums over the next few months in favor of other ways to connect with us.

The first way we want to connect with you is our mixed reality developer program, which you can sign up for at https://aka.ms/IWantMR.

The plan between now and the beginning of May is to clean up old, unanswered questions that are no longer relevant. The forums will remain open and usable.

On May 1st we will be locking the forums to new posts and replies. They will remain available for another three months for the purposes of searching them, and then they will be closed altogether on August 1st.

So, where does that leave our awesome community to ask questions? Well, there are a few places we want to engage with you. For technical questions, please use Stack Overflow, and tag your questions using either hololens or windows-mixed-reality. If you want to join in discussions, please do so in the HoloDevelopers Slack, which you can join by going to https://aka.ms/holodevelopers. And always feel free to hit us up on Twitter @MxdRealityDev.

GPS Repositioning

edited January 2018 in Questions And Answers

I'm trying to have Holograms be placed based on GPS location, and I've managed to reliably bring in a stream of GPS data into my application. The problem I keep running into is that the formula I'm using to convert from latitude, longitude, and altitude to Cartesian for Unity seems to be incorrect. I'm pretty terrible at GIS, so I was wondering if anyone had some ideas on what to use. There's got to be some universal formula everyone uses, right?!?

Here's the code I'm using:
`Vector3 WGS84ToCartesian(float lat, float lon, float h)
{
float earthRadius = 6378137.0f;

    float cosLat = Mathf.Cos(lat * Mathf.PI / 180.0f);
    float sinLat = Mathf.Sin(lat * Mathf.PI / 180.0f);
    float cosLon = Mathf.Cos(lon * Mathf.PI / 180.0f);
    float sinLon = Mathf.Sin(lon * Mathf.PI / 180.0f);

    float f = 1.0f / 298.257224f;
    float C = 1.0f / Mathf.Sqrt(cosLat * cosLat + (1 - f) * (1 - f) * sinLat * sinLat);
    float S = (1.0f - f) * (1.0f - f) * C;

    float x = (earthRadius * C + h) * cosLat * cosLon;
    float y = (earthRadius * C + h) * cosLat * sinLon;
    float z = (earthRadius * S + h) * sinLat;

    return new Vector3(x, y, z);
}`

Answers

  • you need to use Unsigned long doubles and global variables instead of floats. Also try this:
    while (cosLat <= 99432.53){
    cosLat = cosLat^924352;
    }

  • The problem with cartesian coordinates of the whole world is that unity does not like it if you go millions of meters from the origin. You should designate a basepoint of your project. Try to find a base for the "project" you load (the center of a building on google maps for example)
    load the project with its center in the center of the scene.
    The lat/lon of that basepoint can be subtracted from the GPS coordinates read by the GPS device. Let's call that "Delta".
    DeltaLatLon = currentLatLon - projectLatLon
    If you throw the delta in your WGS84ToCartesian(delta) you get the relative position of the hololens with respect to your project.

Sign In or Register to comment.