Skip to content

Commit

Permalink
Merge pull request #964 from AnalyticalGraphicsInc/polygonBoundingSphere
Browse files Browse the repository at this point in the history
Polygon bounding sphere
  • Loading branch information
mramato committed Jul 18, 2013
2 parents ddf5f83 + e92e6a5 commit 2789bfe
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
6 changes: 3 additions & 3 deletions Source/Core/PolygonGeometry.js
Expand Up @@ -262,9 +262,9 @@ define([
geometry = PolygonPipeline.scaleToGeodeticHeight(geometry, height, ellipsoid);

var center = boundingSphere.center;
var mag = center.magnitude();
ellipsoid.geodeticSurfaceNormal(center, center);
Cartesian3.multiplyByScalar(center, mag + height, center);
ellipsoid.geodeticSurfaceNormal(center, scratchNormal);
Cartesian3.multiplyByScalar(scratchNormal, height, scratchNormal);
Cartesian3.add(center, scratchNormal, center);

var attributes = new GeometryAttributes();

Expand Down
18 changes: 18 additions & 0 deletions Specs/Core/PolygonGeometrySpec.js
@@ -1,17 +1,21 @@
/*global defineSuite*/
defineSuite([
'Core/PolygonGeometry',
'Core/BoundingSphere',
'Core/Cartesian3',
'Core/Cartographic',
'Core/Ellipsoid',
'Core/Math',
'Core/Shapes',
'Core/VertexFormat'
], function(
PolygonGeometry,
BoundingSphere,
Cartesian3,
Cartographic,
Ellipsoid,
CesiumMath,
Shapes,
VertexFormat) {
"use strict";
/*global jasmine,describe,xdescribe,it,xit,expect,beforeEach,afterEach,beforeAll,afterAll,spyOn,runs,waits,waitsFor*/
Expand Down Expand Up @@ -194,4 +198,18 @@ defineSuite([
expect(p.indices.length).toEqual(3 * 10);
});

it('computes correct bounding sphere at height 0', function() {
var ellipsoid = Ellipsoid.WGS84;
var center = new Cartographic(0.2930215893394521, 0.818292397338644, 1880.6159971414636);
var positions = Shapes.computeCircleBoundary(ellipsoid, ellipsoid.cartographicToCartesian(center), 10000);

var p = PolygonGeometry.fromPositions({
vertexFormat : VertexFormat.ALL,
positions : positions,
granularity : CesiumMath.PI_OVER_THREE
});

expect(p.boundingSphere).toEqual(BoundingSphere.fromPoints(positions));
});

}, 'WebGL');

0 comments on commit 2789bfe

Please sign in to comment.