Class: Cartesian4

Cartesian4

new Cartesian4(x, y, z, w)

Four 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.

w Number 0.0 optional

W component.

See:

Members

wNumber

W component.

Default Value:
0.0

xNumber

X component.

Default Value:
0.0

yNumber

Y component.

Default Value:
0.0

zNumber

Z component.

Default Value:
0.0

static packedLengthNumber

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

(static, constant) UNIT_WCartesian4

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

(static, constant) UNIT_XCartesian4

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

(static, constant) UNIT_YCartesian4

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

(static, constant) UNIT_ZCartesian4

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

(static, constant) ZEROCartesian4

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

Methods

clone(result){Cartesian4}

Copy this Cartesian instance.

Name Type Description
result Cartesian4 optional

The object that stores the results.

Returns:
Type Description
Cartesian4 If no new Cartesian4 instance is provided for the modified result parameters, a new Cartesian4 instance will be 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 Cartesian4 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(){String}

Create a string representing this Cartesian coordinate in the format of '(x, y)'.

Returns:
Type Description
String A string representing the provided Cartesian coordinates in the format of '(x, y)'.

static abs(cartesian, result){Cartesian4}

Calculate the absolute value of the Cartesian coordinates provided.

Name Type Description
cartesian Cartesian4

To calculate the Cartesian coordinates of its absolute value.

result Cartesian4

The object that stores the results.

Returns:
Type Description
Cartesian4 The modified result parameters.

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

Calculate the sum of two Cartesian components.

Name Type Description
left Cartesian4

The first Cartesian.

right Cartesian4

The second Cartesian.

result Cartesian4

The object that stores the results.

Returns:
Type Description
Cartesian4 The modified result parameters.

static clone(cartesian, result){Cartesian4}

Copy Cartesian4 instance.

Name Type Description
cartesian Cartesian4

The Cartesian coordinates to be copied.

result Cartesian4 optional

The object that stores the results.

Returns:
Type Description
Cartesian4 The modified result parameters or a new Cartesian4 instance (if not provided). (If Cartesian is undefined, return undefined)

static distance(left, right){Number}

Calculate the spatial distance between two points.

Name Type Description
left Cartesian4

Calculate the first point of distance.

right Cartesian4

Calculate the second point of distance.

Returns:
Type Description
Number The distance between two points.
Example
// Returns 1.0
var d = SuperMap3D.Cartesian4.distance(
  new SuperMap3D.Cartesian4(1.0, 0.0, 0.0, 0.0),
  new SuperMap3D.Cartesian4(2.0, 0.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 Cartesian4 # distance.

Name Type Description
left Cartesian4

Calculate the first point of distance

right Cartesian4

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.Cartesian4.distance(
  new SuperMap3D.Cartesian4(1.0, 0.0, 0.0, 0.0),
  new SuperMap3D.Cartesian4(3.0, 0.0, 0.0, 0.0));

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

Divide the provided Cartesian component by the provided scalar.

Name Type Description
cartesian Cartesian4

Divided Cartesian.

scalar Number

The scalar to be divided by.

result Cartesian4

The object that stores the results.

Returns:
Type Description
Cartesian4 The modified result parameters.

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

Calculate the component quotient of two Cartesians.

Name Type Description
left Cartesian4

The first Cartesian.

right Cartesian4

The second Cartesian.

result Cartesian4

The object that stores the results.

Returns:
Type Description
Cartesian4 The modified result parameters.

static dot(left, right){Number}

Calculate the scalar product of two Cartesian points.

Name Type Description
left Cartesian4

The first Cartesian.

right Cartesian4

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 Cartesian4 optional

The first Cartesian.

right Cartesian4 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 Cartesian4 optional

The first Cartesian

right Cartesian4 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){Cartesian4}

Create Cartesian4 from four consecutive elements in an array.

Name Type Default Description
array Array.<Number>

Its four consecutive elements correspond to arrays of x, y, z, and w components, respectively.

startingIndex Number 0 optional

The offset of the first element in the array corresponds to the x-component.

result Cartesian4 optional

The object that stores the results.

Returns:
Type Description
Cartesian4 The modified result parameters or a new Cartesian4 instance (if not provided).
Example
// Create a Cartesian4 with (1.0, 2.0, 3.0, 4.0)
var v = [1.0, 2.0, 3.0, 4.0];
var p = SuperMap3D.Cartesian4.fromArray(v);

// Create a Cartesian4 with (1.0, 2.0, 3.0, 4.0) using an offset into an array
var v2 = [0.0, 0.0, 1.0, 2.0, 3.0, 4.0];
var p2 = SuperMap3D.Cartesian4.fromArray(v2, 2);

static fromColor(color, result){Cartesian4}

Create a Cartesian4 instance from Color. Red, green, blue, and alpha are mapped to x, y, z, and w, respectively.

Name Type Description
color Color

Source color.

result Cartesian4 optional

The object that stores the results.

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

static fromElements(x, y, z, w, result){Cartesian4}

Create Cartesian4 instances from x, y, z, and w coordinates.

Name Type Description
x Number

The x-coordinate.

y Number

Y-coordinate.

z Number

Z coordinate.

w Number

W coordinate.

result Cartesian4 optional

The object that stores the results.

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

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

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

Name Type Description
start Cartesian4

At 0.0, it corresponds to the value of t.

end Cartesian4

At 1.0, it corresponds to the value of t.

t Number

The point interpolated along t.

result Cartesian4

The object that stores the results.

Returns:
Type Description
Cartesian4 The modified result parameters.

static magnitude(cartesian){Number}

Calculate the size (length) of Cartesian.

Name Type Description
cartesian Cartesian4

To calculate the size of a Cartesian instance.

Returns:
Type Description
Number range.

static magnitudeSquared(cartesian){Number}

Calculate the Cartesian squared amplitude provided.

Name Type Description
cartesian Cartesian4

To calculate the Cartesian instance of its square magnitude.

Returns:
Type Description
Number Square amplitude.

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

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

Name Type Description
first Cartesian4

The first Cartesian coordinate.

second Cartesian4

The second Cartesian coordinate.

result Cartesian4

The object that stores the results.

Returns:
Type Description
Cartesian4 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 Cartesian4

The Cartesian to be used.

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

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

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

Name Type Description
first Cartesian4

The first Cartesian.

second Cartesian4

The second Cartesian.

result Cartesian4

The object that stores the results.

Returns:
Type Description
Cartesian4 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 Cartesian4

The Cartesian to be used.

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

static mostOrthogonalAxis(cartesian, result){Cartesian4}

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

Name Type Description
cartesian Cartesian4

Find the Cartesian coordinates of the most orthogonal axis.

result Cartesian4

The object that stores the results.

Returns:
Type Description
Cartesian4 The most orthogonal axis.

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

Multiply the provided Cartesian component by the provided scalar.

Name Type Description
cartesian Cartesian4

Cartesian needs to be scaled.

scalar Number

The scalar to be multiplied with.

result Cartesian4

The object that stores the results.

Returns:
Type Description
Cartesian4 The modified result parameters.

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

Calculate the product of two Cartesian components.

Name Type Description
left Cartesian4

The first Cartesian.

right Cartesian4

The second Cartesian.

result Cartesian4

The object that stores the results.

Returns:
Type Description
Cartesian4 The modified result parameters.

static negate(cartesian, result){Cartesian4}

Deny the Cartesian provided.

Name Type Description
cartesian Cartesian4

Cartesian who needs to be denied.

result Cartesian4

The object that stores the results.

Returns:
Type Description
Cartesian4 The modified result parameters.

static normalize(cartesian, result){Cartesian4}

Calculate the normalized form of the Cartesian coordinates provided.

Name Type Description
cartesian Cartesian4

To standardize Cartesian coordinates.

result Cartesian4

The object that stores the results.

Returns:
Type Description
Cartesian4 The modified result parameters.

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

Store the provided instance in the provided array.

Name Type Default Description
value Cartesian4

The value to be packaged.

array Array.<Number>

The array to be packaged.

startingIndex Number 0 optional

Start packaging the array index of elements.

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

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

Flatten the Cartesian4 array into a component array.

Name Type Description
array Array.<Cartesian4>

The Cartesians array to be packaged.

result Array.<Number>

The array in which to store the results.

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

static packFloat(value, result){Cartesian4}

Package a floating-point value into an object represented by 4 unsigned integers of 8-byte type

Name Type Description
value Number

A floating-point numerical point

result Cartesian4 optional

If no new Cartesian4 instance is provided, use the modified result parameters.

Returns:
Type Description
Cartesian4 A Cartesian4 representing the float packed to values in x, y, z, and w.

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

Calculate the component difference between two Cartesians.

Name Type Description
left Cartesian4

The first Cartesian.

right Cartesian4

The second Cartesian.

result Cartesian4

The object that stores the results.

Returns:
Type Description
Cartesian4 The modified result parameters.

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

Retrieve instances from the packaged array.

Name Type Default Description
array Array.<Number>

Packaged array.

startingIndex Number 0 optional

The starting index of the element to be unpacked.

result Cartesian4 optional

The object that stores the results.

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

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

Unpack a set of Cartesian components into a set of Cartesian 4s.

Name Type Description
array Array.<Number>

The component array to be unpacked.

result Array.<Cartesian4>

An array for storing results.

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