Cartesian4

new Cartesian4(x, y, z, w)

A 4D Cartesian point.

Name Type Default Description
x Number 0.0 optional

The X component.

y Number 0.0 optional

The Y component.

z Number 0.0 optional

The Z component.

w Number 0.0 optional

The W component.

Members

The W component.

Default Value: 0.0

The X component.

Default Value: 0.0

The Y component.

Default Value: 0.0

The Z component.

Default Value: 0.0

Methods

Duplicates this Cartesian4 instance.

Name Type Description
result Cartesian4 optional

The object onto which to store the result.

Returns:

The modified result parameter or a new Cartesian4 instance if one was not provided.

equals(right)Boolean

Compares this Cartesian against the provided Cartesian componentwise and returns true if they are equal, false otherwise.

Name Type Description
right Cartesian4 optional

The right hand side Cartesian.

Returns:

true if they are equal, false otherwise.

equalsEpsilon(right, relativeEpsilon, absoluteEpsilon)Boolean

Compares this Cartesian against the provided Cartesian componentwise and returns true if they pass an absolute or relative tolerance test, false otherwise.

Name Type Default Description
right Cartesian4 optional

The right hand side Cartesian.

relativeEpsilon Number 0 optional

The relative epsilon tolerance to use for equality testing.

absoluteEpsilon Number relativeEpsilon optional

The absolute epsilon tolerance to use for equality testing.

Returns:

true if they are within the provided epsilon, false otherwise.

Normalize this 4-dimensions vector.

Returns:

this object.

toString()String

Creates a string representing this Cartesian in the format '(x, y, z, w)'.

Returns:

A string representing the provided Cartesian in the format '(x, y, z, w)'.

static Cartesian4.add(left, right, result)Cartesian4

Computes the componentwise sum of two Cartesians.

Name Type Description
left Cartesian4

The first Cartesian.

right Cartesian4

The second Cartesian.

result Cartesian4

The object onto which to store the result.

Returns:

The modified result parameter.

static Cartesian4.clone(cartesian, result)Cartesian4

Duplicates a Cartesian4 instance.

Name Type Description
cartesian Cartesian4

The Cartesian to duplicate.

result Cartesian4 optional

The object onto which to store the result.

Returns:

The modified result parameter or a new Cartesian4 instance if one was not provided. (Returns undefined if cartesian is undefined)

static Cartesian4.distance(left, right)Number

Computes the 4-space distance between two points.

Name Type Description
left Cartesian4

The first point to compute the distance from.

right Cartesian4

The second point to compute the distance to.

Returns:

The distance between two points.

Example:
// Returns 1.0
const d = Cartesian4.distance(
  new Cartesian4(1.0, 0.0, 0.0, 0.0),
  new Cartesian4(2.0, 0.0, 0.0, 0.0));

static Cartesian4.divideByScalar(cartesian, scalar, result)Cartesian4

Divides the provided Cartesian componentwise by the provided scalar.

Name Type Description
cartesian Cartesian4

The Cartesian to be divided.

scalar Number

The scalar to divide by.

result Cartesian4

The object onto which to store the result.

Returns:

The modified result parameter.

static Cartesian4.divideComponents(left, right, result)Cartesian4

Computes the componentwise quotient of two Cartesians.

Name Type Description
left Cartesian4

The first Cartesian.

right Cartesian4

The second Cartesian.

result Cartesian4

The object onto which to store the result.

Returns:

The modified result parameter.

static Cartesian4.dot(left, right)Number

Computes the dot (scalar) product of two Cartesians.

Name Type Description
left Cartesian4

The first Cartesian.

right Cartesian4

The second Cartesian.

Returns:

The dot product.

static Cartesian4.equals(left, right)Boolean

Compares the provided Cartesians componentwise and returns true if they are equal, false otherwise.

Name Type Description
left Cartesian4 optional

The first Cartesian.

right Cartesian4 optional

The second Cartesian.

Returns:

true if left and right are equal, false otherwise.

static Cartesian4.equalsEpsilon(left, right, relativeEpsilon, absoluteEpsilon)Boolean

Compares the provided Cartesians componentwise and returns true if they pass an absolute or relative tolerance test, false otherwise.

Name Type Default Description
left Cartesian4 optional

The first Cartesian.

right Cartesian4 optional

The second Cartesian.

relativeEpsilon Number 0 optional

The relative epsilon tolerance to use for equality testing.

absoluteEpsilon Number relativeEpsilon optional

The absolute epsilon tolerance to use for equality testing.

Returns:

true if left and right are within the provided epsilon, false otherwise.

static Cartesian4.magnitude(cartesian)Number

Computes the Cartesian's magnitude (length).

Name Type Description
cartesian Cartesian4

The Cartesian instance whose magnitude is to be computed.

Returns:

The magnitude.

static Cartesian4.magnitudeSquared(cartesian)Number

Computes the provided Cartesian's squared magnitude.

Name Type Description
cartesian Cartesian4

The Cartesian instance whose squared magnitude is to be computed.

Returns:

The squared magnitude.

static Cartesian4.multiplyByScalar(cartesian, scalar, result)Cartesian4

Multiplies the provided Cartesian componentwise by the provided scalar.

Name Type Description
cartesian Cartesian4

The Cartesian to be scaled.

scalar Number

The scalar to multiply with.

result Cartesian4

The object onto which to store the result.

Returns:

The modified result parameter.

static Cartesian4.multiplyComponents(left, right, result)Cartesian4

Computes the componentwise product of two Cartesians.

Name Type Description
left Cartesian4

The first Cartesian.

right Cartesian4

The second Cartesian.

result Cartesian4

The object onto which to store the result.

Returns:

The modified result parameter.

static Cartesian4.negate(cartesian, result)Cartesian4

Negates the provided Cartesian.

Name Type Description
cartesian Cartesian4

The Cartesian to be negated.

result Cartesian4

The object onto which to store the result.

Returns:

The modified result parameter.

static Cartesian4.normalize(cartesian, result)Cartesian4

Computes the normalized form of the supplied Cartesian.

Name Type Description
cartesian Cartesian4

The Cartesian to be normalized.

result Cartesian4

The object onto which to store the result.

Returns:

The modified result parameter.

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

Stores the provided instance into the provided array.

Name Type Default Description
value Cartesian4

The value to pack.

array Array.<Number>

The array to pack into.

startingIndex Number 0 optional

The index into the array at which to start packing the elements.

Returns:

The array that was packed into

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

Flattens an array of Cartesian4s into an array of components.

Name Type Description
array Array.<Cartesian4>

The array of cartesians to pack.

result Array.<Number> optional

The array onto which to store the result. If this is a typed array, it must have array.length * 4 components, else a DeveloperError will be thrown. If it is a regular array, it will be resized to have (array.length * 4) elements.

Returns:

The packed array.

static Cartesian4.subtract(left, right, result)Cartesian4

Computes the componentwise difference of two Cartesians.

Name Type Description
left Cartesian4

The first Cartesian.

right Cartesian4

The second Cartesian.

result Cartesian4

The object onto which to store the result.

Returns:

The modified result parameter.