3D coordinates on a sphere to Latitude and Longitude

后端 未结 7 716
慢半拍i
慢半拍i 2020-11-30 19:25

I\'ve got the following information:

There exists a sphere with origin (0,0,0) and radius R. After doing a ray-sphere intersection I know a point (XYZ) in 3D space t

相关标签:
7条回答
  • 2020-11-30 20:03

    This helped using Javascript/THREE.js:

    var lat = 90 - (Math.acos(y / RADIUS_SPHERE)) * 180 / Math.PI;
    var lon = ((270 + (Math.atan2(x , z)) * 180 / Math.PI) % 360) -180;
    
    0 讨论(0)
  • 2020-11-30 20:04

    I guess it should not be difficult to find the spherical polar coordinates from x,y,z (3d-coordinate system).

    1. r is always constant if it's on surface.

      enter image description here

    2. (90 - θ) your latitude (negative means it's on the bottom) as it's measured from top.

      enter image description here

    3. φ is your longitude. (but not quite sure about longitude system)

      enter image description here

    Also check this diagram from wikipedia.

    enter image description here

    0 讨论(0)
  • 2020-11-30 20:05

    After working on getting a straightforward solution to placing objects on a sphere using lat/lng, I came up with a simple class to let you do it using three.js.

    var earth = new THREE.GeoSpatialMap(geometry, material);
    earth.setTexturesEdgeLongitude(-180.806168);
    
    for (i = 0; i < continentData.length; i += step) {
    
        var lat = continentData[i];
        var lng = continentData[i + 1];
    
        var light = new THREE.PointLight(0x0099ff);
        var plant = new org.good.ecology.Plant();
        plant.scale.x = plant.scale.y = plant.scale.z = Math.random() * 3;
    
        console.log("Adding symbol at: " + lat + " : " + lng);
        earth.addGeoSymbol(
            new THREE.GeoSpatialMap.GeoSymbol(plant, {
                phi: lat,
                lambda: lng
            })
        );
    
    
        plant.lookAt(earth.position);
    
    }
    

    https://github.com/scottbyrns/Three.js-Geospatial-Mapping

    0 讨论(0)
  • 2020-11-30 20:10
    lat=atan2(z,sqrt(x*x+y*y))
    lng=atan2(y,x)
    

    Using formulas with atan2() is more convenient. You don't have to add/subtract pi/2 or care about sign issues in different quadrants or division by zero.

    lat will be >0 in the northern hemisphere
    lat will be <0 in the southern hemisphere
    lng will be >0 in the eastern hemisphere
    lng will be <0 in the western hemisphere

    0 讨论(0)
  • 2020-11-30 20:16

    Edit - having reread you question my answer isn't necessarily applicable, but I'll leave it up for reference.

    It depends how accurate you wan to be an dwhat purpose you are going to use the result for. There is no single latitude and logitude system, eg WGS84 (USA GPS) or ETRS89 (European GPS) differ slightly and are diverging as the Atlantic Ocean widens.

    http://www.ordnancesurvey.co.uk/oswebsite/gps/information/coordinatesystemsinfo/guidecontents/guide5.html

    http://www.ordnancesurvey.co.uk/oswebsite/gps/information/coordinatesystemsinfo/guidecontents/guide6.html

    Finally this should address your question directly.

    http://www.ordnancesurvey.co.uk/oswebsite/gps/information/coordinatesystemsinfo/guidecontents/guideb.html

    or

    http://www.ordnancesurvey.co.uk/oswebsite/gps/docs/convertingcoordinates3D.pdf

    0 讨论(0)
  • 2020-11-30 20:20
    r=sqrt(x^2+y^2+z^2)  
    phi = arccos(sqrt(x^2+y^2)/r)*sign(y)  
    lambda = arccos(x/sqrt(x^2+y^2))  
    latitude = 180/pi * phi  
    longitude = 180/pi * lambda 
    

    you might have to tinker with the signs a little

    0 讨论(0)
提交回复
热议问题