Hi there,
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.
Still need help. If anyone can provide any assistance that would be just great.
Ok, the problem is solved thank to ZhefengJin:
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);
And here is the link to the Sandcastle he provided.
One more thing - as I can see when I use PlaneGraphics the plane normal should be defined in the plane’s local coordinates but if I need to project Cartesian3 point onto the plane, the plane’s normal should be defined in ECEF coordinates.
Here are two sandcastles:
@Ilia_Shevelev
I am glad to see that the core issue has been resolved. A big thanks to @ZhefengJin for all your support. I looked over the sandcastle demos that you send - are you suggesting that there is a bug related to how a plane’s normal is defined?
-Sam
@sam.rothstein ,
I assume that it is not a bug but it may be useful for other beginners to mention in documentation that planes normal in Cesium.PlaneGraphics
should be defined in plane’s local coordinates.
It is a bit controversial that to project a point onto the plane its normal should be defined in ECEF while if you need to draw a plane with Cesium.PlaneGraphics
its normal should be defined in plane’s local coordinates. So if you need for example to do both - additional transformation is required.
1 Like