/
CircleOutlineGeometry.js
83 lines (77 loc) · 3.2 KB
/
CircleOutlineGeometry.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
/*global define*/
define([
'./defaultValue',
'./defined',
'./DeveloperError',
'./EllipseOutlineGeometry'
], function(
defaultValue,
defined,
DeveloperError,
EllipseOutlineGeometry) {
"use strict";
/**
* A description of the outline of a circle on the ellipsoid.
*
* @alias CircleOutlineGeometry
* @constructor
*
* @param {Cartesian3} options.center The circle's center point in the fixed frame.
* @param {Number} options.radius The radius in meters.
* @param {Ellipsoid} [options.ellipsoid=Ellipsoid.WGS84] The ellipsoid the circle will be on.
* @param {Number} [options.height=0.0] The height above the ellipsoid.
* @param {Number} [options.granularity=0.02] The angular distance between points on the circle in radians.
* @param {Number} [options.extrudedHeight=0.0] The height of the extrusion relative to the ellipsoid.
* @param {Number} [options.numberOfVerticalLines = 16] Number of lines to draw between the top and bottom of an extruded circle.
*
* @exception {DeveloperError} center is required.
* @exception {DeveloperError} radius is required.
* @exception {DeveloperError} radius must be greater than zero.
* @exception {DeveloperError} granularity must be greater than zero.
*
* @see CircleOutlineGoemetry.createGeometry
*
* @example
* // Create a circle.
* var ellipsoid = Ellipsoid.WGS84;
* var circle = new CircleOutlineGeometry({
* ellipsoid : ellipsoid,
* center : ellipsoid.cartographicToCartesian(Cartographic.fromDegrees(-75.59777, 40.03883)),
* radius : 100000.0
* });
* var geometry = CircleOutlineGeometry.createGeometry(circle);
*/
var CircleOutlineGeometry = function(options) {
options = defaultValue(options, defaultValue.EMPTY_OBJECT);
var radius = options.radius;
if (!defined(radius)) {
throw new DeveloperError('radius is required.');
}
if (radius <= 0.0) {
throw new DeveloperError('radius must be greater than zero.');
}
var ellipseGeometryOptions = {
center : options.center,
semiMajorAxis : radius,
semiMinorAxis : radius,
ellipsoid : options.ellipsoid,
height : options.height,
extrudedHeight : options.extrudedHeight,
granularity : options.granularity,
numberOfVerticalLines : options.numberOfVerticalLines
};
this._ellipseGeometry = new EllipseOutlineGeometry(ellipseGeometryOptions);
this._workerName = 'createCircleOutlineGeometry';
};
/**
* Computes the geometric representation of an outline of a circle on an ellipsoid, including its vertices, indices, and a bounding sphere.
* @memberof CircleOutlineGeometry
*
* @param {CircleOutlineGeometry} circleGeometry A description of the circle.
* @returns {Geometry} The computed vertices and indices.
*/
CircleOutlineGeometry.createGeometry = function(circleGeometry) {
return EllipseOutlineGeometry.createGeometry(circleGeometry._ellipseGeometry);
};
return CircleOutlineGeometry;
});