2

Problem

I am a bit confused on how Cesium calculates geodetic and geocentric surface normal. Planes, generated from calculated normal do not actually tangent to ellipsoid surface in a given point, more then, the plane created from geodetic surface normal is just the same as one generated from geocentric surface normal.

Example & why do I need this

In this Sandcastle XYZ axis along with planes that should be tangent to ellipsoid are drawn when you click on the globe surface.

What I need is to get an XY plane tangent to Ellipsoid at given point and then project other points onto this plane. The problem is as I see the plane is not tangent to ellipsoid at all.

By the way - when I use built in method: Cesium.EllipsoidTangentPlane(); I also get strange result - plane is still not tangent to ellipsoid and also floating somewhere in space. Here is sandcastle.

Appreciate any help because I do not understand what happens here.

1 Answers1

1

The normal of the plane is defined at the local coordinate system of the plane, of which x, y, and z-axis indicate the east, north, and up direction in the earth(world or ECEF ), respectively. So if the normal vector of a plane is given in the ECEF, you have to convert it at the plane's local coordinate system like this.

    // get the local coordinate system of the plane
    var transform = Cesium.Transforms.eastNorthUpToFixedFrame(clickedPoint);
    // get invert matrix
    var inv = Cesium.Matrix4.inverseTransformation(transform, new Cesium.Matrix4());
    // in this case actually world normal coincide with up direction(z axis of coordinate system)
    // to avoid error we slightly extend it.
    var extendedWordNormal = Cesium.Cartesian3.multiplyByScalar(clickedPoint, 1.001, new Cesium.Cartesian3());
    
    // it will be nearly same as (0, 0, 1)
    var localNormal = Cesium.Matrix4.multiplyByPoint(inv, extendedWordNormal, new Cesium.Cartesian3());

    //var localNormal = new Cesium.Cartesian3(0, 0, 1);

Please check this sandcastle and this sample

ZhefengJin
  • 930
  • 8
  • 17
  • Man, thanks! I've spent lot of time trying to understand what's happening, now everything is clear. – Ilia Shevelev Jul 05 '21 at 08:21
  • 1
    happy to help you! – ZhefengJin Jul 05 '21 at 11:13
  • I have one more question - do I understand right that when I use PlaneGraphics the plane normal should be defined in plane's local coordinates but if need to project Cartesian3 point onto the plane, the plane's normal should be defined in ECEF coordinates? I ask because when I project the point on the plane with normal defined in plane's local coordinates and then draw this point it does not appears in the right place. Unfortunately I cant share sandcastle because of Stackoverflow maximum message length restrictions. – Ilia Shevelev Jul 05 '21 at 11:14
  • Unfortunately I cant, here is the error I got: `Too long by 2844 characters`. But I've shared an examples on Cesium forum, here is the link: https://community.cesium.com/t/planes-normal-coordinate-system-solved/14184/4 – Ilia Shevelev Jul 06 '21 at 12:13