Skip to content

Commit 45c2ddf

Browse files
authored
Ellipsoid: calculate normal at surface point in getPositionToCartographic (#1531) (#1532)
1 parent 6ba948d commit 45c2ddf

2 files changed

Lines changed: 25 additions & 1 deletion

File tree

src/three/renderer/math/Ellipsoid.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ export class Ellipsoid {
353353
// From Cesium function Ellipsoid.cartesianToCartographic
354354
// https://github.com/CesiumGS/cesium/blob/665ec32e813d5d6fe906ec3e87187f6c38ed5e49/packages/engine/Source/core/renderer/Ellipsoid.js#L463
355355
this.getPositionToSurfacePoint( pos, _vec );
356-
this.getPositionToNormal( pos, _norm );
356+
this.getPositionToNormal( _vec, _norm );
357357

358358
const heightDelta = _vec2.subVectors( pos, _vec );
359359

test/three/Ellipsoid.test.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,30 @@ describe( 'Ellipsoid', () => {
178178

179179
} );
180180

181+
it( 'should match Cesium Cartesian to Cartographic results.', () => {
182+
183+
const HEIGHT_EPSILON = 1e-5;
184+
const LAT_LON_EPSILON = 1e-7;
185+
const LAT = 40;
186+
const LON = - 75;
187+
const HEIGHT = 5000;
188+
const cart = new Cesium.Cartographic( LON, LAT, HEIGHT );
189+
190+
c_wgsEllipse.cartographicToCartesian( cart, c );
191+
v.set( c.x, c.y, c.z );
192+
193+
const cesiumResult = new Cesium.Cartographic();
194+
c_wgsEllipse.cartesianToCartographic( c, cesiumResult );
195+
196+
const result = {};
197+
wgsEllipse.getPositionToCartographic( v, result );
198+
199+
compareCoord( result.lon, cesiumResult.longitude, LAT_LON_EPSILON );
200+
compareCoord( result.lat, cesiumResult.latitude, LAT_LON_EPSILON );
201+
compareCoord( result.height, cesiumResult.height, HEIGHT_EPSILON );
202+
203+
} );
204+
181205
it( 'should match the expected elevation.', () => {
182206

183207
//ellipsoid rotation

0 commit comments

Comments
 (0)