Class: Cartesian3

Cartesian3

new Cartesian3(x, y, z)

Three dimensional Cartesian coordinate point class.

Name Type Default Description
x Number 0.0 optional

X component.

y Number 0.0 optional

Y component.

z Number 0.0 optional

Z component.

See:

Members

xNumber

X component.

Default Value:
0.0

yNumber

Y component.

Default Value:
0.0

zNumber

Z component.

Default Value:
0.0

(static, constant) ONECartesian3

An immutable Cartesian3 instance initialized to (1.0, 1.0, 1.0).

static packedLengthNumber

The number of elements used to package objects into an array.

(static, constant) UNIT_XCartesian3

An immutable Cartesian3 instance initialized to (1.0, 0.0, 0.0).

(static, constant) UNIT_XYZCartesian3

An immutable Cartesian3 instance initialized to (1.0, 1.0, 1.0).

(static, constant) UNIT_YCartesian3

An immutable Cartesian3 instance initialized to (0.0, 1.0, 0.0).

(static, constant) UNIT_ZCartesian3

An immutable Cartesian3 instance initialized to (0.0, 0.0, 1.0).

(static, constant) ZEROCartesian3

An immutable Cartesian3 instance initialized to (0.0, 0.0, 0.0).

Methods

clone(result){Cartesian3}

Copy this Cartesian3 instance.

Name Type Description
result Cartesian3 optional

The object that stores the results.

Returns:
Type Description
Cartesian3 The modified result parameters or a new Cartesian3 instance (if not provided).

equals(right){Boolean}

Compare this Cartesian component with the provided Cartesian component, return true if they are equal, otherwise return false.

Name Type Description
right Cartesian3 optional

Cartesian on the right.

Returns:
Type Description
Boolean If they are equal, it is true; otherwise, it is false.

equalsEpsilon(right, relativeEpsilon, absoluteEpsilon){Boolean}

Compare this Cartesian component with the provided Cartesian component. If they pass the absolute or relative tolerance test, return true; otherwise, return false.

Name Type Default Description
right Cartesian3 optional

Cartesian on the right.

relativeEpsilon Number

Relative epsilon tolerance for equality testing.

absoluteEpsilon Number relativeEpsilon optional

Absolute epsilon tolerance for equality testing.

Returns:
Type Description
Boolean If they are within the provided epsilon, it is true; otherwise, it is false.

toString()

Convert Cartesian coordinates to string format (x, y, z).

static abs(cartesian, result){Cartesian3}

Calculate the absolute value of the Cartesian coordinates provided.

Name Type Description
cartesian Cartesian3

To calculate the Cartesian coordinates of its absolute value.

result Cartesian3

The object that stores the results.

Returns:
Type Description
Cartesian3 The modified result parameters.

static add(left, right, result){Cartesian3}

Calculate the sum of two Cartesian components.

Name Type Description
left Cartesian3

The first Cartesian.

right Cartesian3

The second Cartesian.

result Cartesian3

The object that stores the results.

Returns:
Type Description
Cartesian3 The modified result parameters.

static angleBetween(left, right){Number}

Return the angle (in radians) between the provided Cartesians.

Name Type Description
left Cartesian3

The first Cartesian.

right Cartesian3

The second Cartesian.

Returns:
Type Description
Number The perspective between Cartesians.

static clone(cartesian, result){Cartesian3}

Copy an instance of Cartesian3.

Name Type Description
cartesian Cartesian3

Object to be copied.

result Cartesian3 optional

The object that stores the results.

Returns:
Type Description
Cartesian3 If the modified result parameters are not provided, return a new Cartesian3 instance. If the carton is undefined, return undefined.

static cross(left, right, result){Cartesian3}

Calculate the cross product of two Cartesian coordinate systems.

Name Type Description
left Cartesian3

The first Cartesian.

right Cartesian3

The second Cartesian.

result Cartesian3

The object that stores the results.

Returns:
Type Description
Cartesian3 Cross product.

static distance(left, right){Number}

Calculate the distance between two points.

Name Type Description
left Cartesian3

The first point used to calculate distance.

right Cartesian3

The second point used for calculating distance.

Returns:
Type Description
Number The distance value between two points.
Example
// Calculate the distance between two points and return 1.0.
var d = SuperMap3D.Cartesian3.distance(new SuperMap3D.Cartesian3(1.0, 0.0, 0.0), new SuperMap3D.Cartesian3(2.0, 0.0, 0.0));

static distanceSquared(left, right){Number}

Calculate the square distance between two points. Comparing the squares of distances using this function is more effective than comparing distances using Cartesian3 # distance.

Name Type Description
left Cartesian3

Calculate the first point of distance.

right Cartesian3

Calculate the second point of distance.

Returns:
Type Description
Number The distance between two points.
Example
// Returns 4.0, not 2.0
var d = SuperMap3D.Cartesian3.distanceSquared(new SuperMap3D.Cartesian3(1.0, 0.0, 0.0), new SuperMap3D.Cartesian3(3.0, 0.0, 0.0));

static divideByScalar(cartesian, scalar, result){Cartesian3}

Divide the provided Cartesian component by the provided scalar.

Name Type Description
cartesian Cartesian3

Divided Cartesian.

scalar Number

The scalar to be divided by.

result Cartesian3

The object that stores the results.

Returns:
Type Description
Cartesian3 The modified result parameters.

static divideComponents(left, right, result){Cartesian3}

Calculate the component quotient of two Cartesians.

Name Type Description
left Cartesian3

The first Cartesian.

right Cartesian3

The second Cartesian.

result Cartesian3

The object that stores the results.

Returns:
Type Description
Cartesian3 The modified result parameters.

static dot(left, right){Number}

Calculate the dot (scalar) product of two Cartesians.

Name Type Description
left Cartesian3

The first Cartesian.

right Cartesian3

The second Cartesian.

Returns:
Type Description
Number Dot product.

static equals(left, right){Boolean}

Compare the provided Cartesian components, return true if they are equal, otherwise return false.

Name Type Description
left Cartesian3 optional

The first Cartesian.

right Cartesian3 optional

The second Cartesian.

Returns:
Type Description
Boolean If they are equal, it is true; otherwise, it is false.

static equalsEpsilon(left, right, relativeEpsilon, absoluteEpsilon){Boolean}

Compare the provided Cartesian components and return true if they pass absolute or relative tolerance tests, otherwise return false.

Name Type Default Description
left Cartesian3 optional

The first Cartesian.

right Cartesian3 optional

The second Cartesian.

relativeEpsilon Number

Relative epsilon tolerance for equality testing.

absoluteEpsilon Number relativeEpsilon optional

Absolute epsilon tolerance for equality testing.

Returns:
Type Description
Boolean Within the provided epsilon, it is true; otherwise, it is false.

static fromArray(array, startingIndex, result){Cartesian3}

Create a Cartesian3 instance based on the three consecutive elements of the array.

Name Type Default Description
array Array.<Number>

Array object, where three consecutive elements in the array correspond to x, y, and z components respectively.

startingIndex Number 0 optional

The offset of the first element in the array, which is the x-component corresponding to the "startingIndex+1" th element of the array.

result Cartesian3 optional

The object that stores the results.

Returns:
Type Description
Cartesian3 If the modified result parameters are not provided, return a new Cartesian3 instance.
Example
// Create a Cartesian3 instance (1.0, 2.0, 3.0).
var v = [1.0, 2.0, 3.0];
var p = SuperMap3D.Cartesian3.fromArray(v);

// Create a Cartesian3 instance (1.0, 2.0, 3.0). If an offset of 2 is specified, the third data corresponds to the x component.
var v2 = [0.0, 0.0, 1.0, 2.0, 3.0];
var p2 = SuperMap3D.Cartesian3.fromArray(v2, 2);

static fromCartesian4(cartesian, result){Cartesian3}

Create a Cartesian3 instance based on the known Cartesian4. Retain the x, y, and z components of Cartesian4 and discard the w component.

Name Type Description
cartesian Cartesian4

Cartesian4 object used to create Cartesian3 instances.

result Cartesian3 optional

The object that stores the results.

Returns:
Type Description
Cartesian3 If the modified result parameters are not provided, return a new Cartesian3 instance.

static fromDegrees(longitude, latitude, height, ellipsoid, result){Cartesian3}

Convert longitude and latitude values in degrees to Cartesian coordinates.

Name Type Default Description
longitude Number

The longitude value measured in degrees.

latitude Number

The latitude value measured in degrees.

height Number 0.0 optional

The height of an ellipsoid measured in meters.

ellipsoid Ellipsoid Ellipsoid.WGS84 optional

Ellipsoid body.

result Cartesian3 optional

The object that stores the results.

Returns:
Type Description
Cartesian3 The converted position coordinates.
Example
var position = SuperMap3D.Cartesian3.fromDegrees(-115.0, 37.0);

static fromDegreesArray(coordinates, ellipsoid, result){Array.<Cartesian3>}

Given an array of longitude and latitude values in degrees, return a Cartesian position array.

Name Type Default Description
coordinates Array.<Number>

A list of longitude and latitude values. Value alternation [longitude, latitude, longitude, latitude...].

ellipsoid Ellipsoid Ellipsoid.WGS84 optional

The ellipsoid where the coordinates are located.

result Array.<Cartesian3> optional

The Cartesian3 object array to store the results.

Returns:
Type Description
Array.<Cartesian3> Position array.
Example
var positions = SuperMap3D.Cartesian3.fromDegreesArray([-115.0, 37.0, -107.0, 33.0]);

static fromDegreesArrayHeights(coordinates, ellipsoid, result){Array.<Cartesian3>}

Given an array of longitude, latitude, and altitude values, where longitude and latitude are measured in degrees, return a Cartesian position array.

Name Type Default Description
coordinates Array.<Number>

A list of longitude, latitude, and altitude values. Value alternation [longitude, latitude, altitude, longitude, latitude, altitude...].

ellipsoid Ellipsoid Ellipsoid.WGS84 optional

The ellipsoid where the position is located.

result Array.<Cartesian3> optional

The Cartesian3 object array to store the results.

Returns:
Type Description
Array.<Cartesian3> Position array.
Example
var positions = SuperMap3D.Cartesian3.fromDegreesArrayHeights([-115.0, 37.0, 100000.0, -107.0, 33.0, 150000.0]);

static fromElements(x, y, z, result){Cartesian3}

Create Cartesian3 instances based on x, y, and z coordinates.

Name Type Description
x Number

The x-coordinate.

y Number

Y-coordinate.

z Number

Z coordinate.

result Cartesian3 optional

The object that stores the results.

Returns:
Type Description
Cartesian3 If the modified result parameters are not provided, return a new Cartesian3 instance.

static fromRadians(longitude, latitude, height, ellipsoid, result){Cartesian3}

Convert longitude and latitude values in radians to Cartesian coordinates.

Name Type Default Description
longitude Number

The longitude value measured in radians.

latitude Number

The latitude value measured in radians.

height Number 0.0 optional

The height of an ellipsoid measured in meters.

ellipsoid Ellipsoid Ellipsoid.WGS84 optional

Ellipsoid body.

result Cartesian3 optional

The object that stores the results.

Returns:
Type Description
Cartesian3 The converted position coordinates.
Example
var position = SuperMap3D.Cartesian3.fromRadians(-2.007, 0.645);

static fromRadiansArray(coordinates, ellipsoid, result){Array.<Cartesian3>}

Given an array of longitude and latitude values in radians, return a Cartesian 3 position array.

Name Type Default Description
coordinates Array.<Number>

A list of longitude and latitude values. Value alternation [longitude, latitude, longitude, latitude...].

ellipsoid Ellipsoid Ellipsoid.WGS84 optional

The ellipsoid where the coordinates are located.

result Array.<Cartesian3> optional

The Cartesian3 object array to store the results.

Returns:
Type Description
Array.<Cartesian3> Position array.
Example
var positions = SuperMap3D.Cartesian3.fromRadiansArray([-2.007, 0.645, -1.867, .575]);

static fromRadiansArrayHeights(coordinates, ellipsoid, result){Array.<Cartesian3>}

Return a Cartesian position array of the given longitude, latitude, and altitude values, where longitude and latitude are measured in radians.

Name Type Default Description
coordinates Array.<Number>

A list of longitude, latitude, and altitude values. Value alternation [longitude, latitude, altitude, longitude, latitude, altitude...].

ellipsoid Ellipsoid Ellipsoid.WGS84 optional

The ellipsoid where the position is located.

result Array.<Cartesian3> optional

The Cartesian3 object array to store the results.

Returns:
Type Description
Array.<Cartesian3> Position array.
Example
var positions = SuperMap3D.Cartesian3.fromRadiansArrayHeights([-2.007, 0.645, 100000.0, -1.867, .575, 150000.0]);

static fromSpherical(spherical, result){Cartesian3}

Convert spherical coordinates to Cartesian coordinates.

Name Type Description
spherical Spherical

The spherical coordinates to be converted.

result Cartesian3 optional

The object that stores the results.

Returns:
Type Description
Cartesian3 If the modified result parameters are not provided, return a new Cartesian3 instance.

static lerp(start, end, t, result){Cartesian3}

Use the provided Cartesian algorithm to calculate linear interpolation or extrapolation at point t.

Name Type Description
start Cartesian3

At 0.0, it corresponds to the value of t.

end Cartesian3

At 1.0, it corresponds to the value of t.

t Number

The point interpolated along t.

result Cartesian3

The object that stores the results.

Returns:
Type Description
Cartesian3 The modified result parameters.

static magnitude(cartesian){Number}

Calculate the size (length) of Cartesian.

Name Type Description
cartesian Cartesian3

To calculate the size of a Cartesian instance.

Returns:
Type Description
Number range.

static magnitudeSquared(cartesian){Number}

Calculate the provided Cartesian squared amplitude.

Name Type Description
cartesian Cartesian3

To calculate the Cartesian instance of its square magnitude.

Returns:
Type Description
Number Square amplitude.

static maximumByComponent(first, second, result){Cartesian3}

Compare two Cartesians and calculate the Cartesian that contains the maximum component of the provided Cartesian.

Name Type Description
first Cartesian3

The first Cartesian coordinate.

second Cartesian3

The second Cartesian coordinate.

result Cartesian3

The object that stores the results.

Returns:
Type Description
Cartesian3 Cartesian coordinates with the maximum component.

static maximumComponent(cartesian){Number}

Calculate the value of the maximum component of the Cartesian coordinates provided.

Name Type Description
cartesian Cartesian3

The Cartesian to be used.

Returns:
Type Description
Number The value of the maximum component.

static midpoint(left, right, result){Cartesian3}

Calculate the midpoint between two given Cartesian coordinate parameters

Name Type Description
left Cartesian3

The first Cartesian coordinate value.

right Cartesian3

The second Cartesian coordinate value.

result Cartesian3

The object that stores the results.

Returns:
Type Description
Cartesian3 Middle point.

static minimumByComponent(first, second, result){Cartesian3}

Compare two Cartesians and calculate the Cartesian that contains the minimum component of the provided Cartesian.

Name Type Description
first Cartesian3

The first Cartesian.

second Cartesian3

The second Cartesian.

result Cartesian3

The object that stores the results.

Returns:
Type Description
Cartesian3 Cartesian with the least component.

static minimumComponent(cartesian){Number}

Calculate the value of the minimum component of the Cartesian coordinates provided.

Name Type Description
cartesian Cartesian3

The Cartesian to be used.

Returns:
Type Description
Number The value of the minimum component.

static mostOrthogonalAxis(cartesian, result){Cartesian3}

Return the axis that is most orthogonal to the provided Cartesian coordinates.

Name Type Description
cartesian Cartesian3

Find the Cartesian coordinates of the most orthogonal axis.

result Cartesian3

The object that stores the results.

Returns:
Type Description
Cartesian3 The most orthogonal axis.

static multiplyByScalar(cartesian, scalar, result){Cartesian3}

Multiply the provided Cartesian component by the provided scalar.

Name Type Description
cartesian Cartesian3

Cartesian needs to be scaled.

scalar Number

The scalar to be multiplied with.

result Cartesian3

The object that stores the results.

Returns:
Type Description
Cartesian3 The modified result parameters.

static multiplyComponents(left, right, result){Cartesian3}

Calculate the product of two Cartesian components.

Name Type Description
left Cartesian3

The first Cartesian.

right Cartesian3

The second Cartesian.

result Cartesian3

The object that stores the results.

Returns:
Type Description
Cartesian3 The modified result parameters.

static negate(cartesian, result){Cartesian3}

Deny the Cartesian provided.

Name Type Description
cartesian Cartesian3

Cartesian who needs to be denied.

result Cartesian3

The object that stores the results.

Returns:
Type Description
Cartesian3 The modified result parameters.

static normalize(cartesian, result){Cartesian3}

Calculate the normalized form of the Cartesian coordinates provided.

Name Type Description
cartesian Cartesian3

To standardize Cartesian coordinates.

result Cartesian3

The object that stores the results.

Returns:
Type Description
Cartesian3 The modified result parameters.

static pack(value, array, startingIndex){Array.<Number>}

Store the provided instance in the provided array.

Name Type Default Description
value Cartesian3

The value to be packaged.

array Array.<Number>

The array to be loaded.

startingIndex Number 0 optional

Start packaging the index of the array of elements.

Returns:
Type Description
Array.<Number> The array that has been loaded.

static packArray(array, result){Array.<Number>}

Flatten the Cartesian3 array into a component array.

Name Type Description
array Array.<Cartesian3>

The Cartesians array to be packaged.

result Array.<Number>

An array for storing results.

Returns:
Type Description
Array.<Number> Packaged array.

static subtract(left, right, result){Cartesian3}

Calculate the component difference between two Cartesians.

Name Type Description
left Cartesian3

The first Cartesian.

right Cartesian3

The second Cartesian.

result Cartesian3

The object that stores the results.

Returns:
Type Description
Cartesian3 The modified result parameters.

static unpack(array, startingIndex, result){Cartesian3}

Retrieve instances from the packaged array.

Name Type Default Description
array Array.<Number>

Package the array.

startingIndex Number 0 optional

The starting index of the element to be decompressed.

result Cartesian3 optional

The object that stores the results.

Returns:
Type Description
Cartesian3 If no new Cartesian3 instance is provided, use the modified result parameters.

static unpackArray(array, result){Array.<Cartesian3>}

Decompress a set of Cartesian components into a set of Cartesian 3s.

Name Type Description
array Array.<Number>

The component array to be unpacked.

result Array.<Cartesian3>

An array for storing results.

Returns:
Type Description
Array.<Cartesian3> The decompressed array.