Cartesian3

new Cartesian3(x, y, z)

A 3D 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.

Members

The X component.

Default Value: 0.0

The Y component.

Default Value: 0.0

The Z component.

Default Value: 0.0

static constant Cartesian3.ONE : Cartesian3

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

static constant Cartesian3.UNIT_X : Cartesian3

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

static constant Cartesian3.UNIT_Y : Cartesian3

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

static constant Cartesian3.UNIT_Z : Cartesian3

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

static constant Cartesian3.ZERO : Cartesian3

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

Methods

clamp(min, max)Cartesian3

Constrain a value to lie between two values.

Name Type Description
min Cartesian3 | Number

The minimum bound.

max Cartesian3 | Number

The maximum bound.

Returns:

The clamped value such that min <= value <= max.

Duplicates this Cartesian3 instance.

Name Type Description
result Cartesian3 optional

The object onto which to store the result.

Returns:

The modified result parameter or a new Cartesian3 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 Cartesian3 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 Cartesian3 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 3-dimensions vector.

Returns:

this object.

toString()String

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

Returns:

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

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

Computes the componentwise sum of two Cartesians.

Name Type Description
left Cartesian3

The first Cartesian.

right Cartesian3

The second Cartesian.

result Cartesian3

The object onto which to store the result.

Returns:

The modified result parameter.

static Cartesian3.clamp(value, min, max, result)Cartesian3

Constrain a value to lie between two values.

Name Type Description
value Cartesian3

The value to clamp.

min Cartesian3 | Number

The minimum bound.

max Cartesian3 | Number

The maximum bound.

result Cartesian3

The object into which to store the result.

Returns:

The clamped value such that min <= value <= max.

static Cartesian3.clone(cartesian, result)Cartesian3

Duplicates a Cartesian3 instance.

Name Type Description
cartesian Cartesian3

The Cartesian to duplicate.

result Cartesian3 optional

The object onto which to store the result.

Returns:

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

static Cartesian3.cross(left, right, result)Cartesian3

Computes the cross (outer) product of two Cartesians.

Name Type Description
left Cartesian3

The first Cartesian.

right Cartesian3

The second Cartesian.

result Cartesian3

The object onto which to store the result.

Returns:

The cross product.

static Cartesian3.distance(left, right)Number

Computes the distance between two points.

Name Type Description
left Cartesian3

The first point to compute the distance from.

right Cartesian3

The second point to compute the distance to.

Returns:

The distance between two points.

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

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

Divides the provided Cartesian componentwise by the provided scalar.

Name Type Description
cartesian Cartesian3

The Cartesian to be divided.

scalar Number

The scalar to divide by.

result Cartesian3

The object onto which to store the result.

Returns:

The modified result parameter.

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

Computes the componentwise quotient of two Cartesians.

Name Type Description
left Cartesian3

The first Cartesian.

right Cartesian3

The second Cartesian.

result Cartesian3

The object onto which to store the result.

Returns:

The modified result parameter.

static Cartesian3.dot(left, right)Number

Computes the dot (scalar) product of two Cartesians.

Name Type Description
left Cartesian3

The first Cartesian.

right Cartesian3

The second Cartesian.

Returns:

The dot product.

static Cartesian3.equals(left, right)Boolean

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

Name Type Description
left Cartesian3 optional

The first Cartesian.

right Cartesian3 optional

The second Cartesian.

Returns:

true if left and right are equal, false otherwise.

static Cartesian3.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 Cartesian3 optional

The first Cartesian.

right Cartesian3 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 Cartesian3.fromElements(x, y, z, result)Cartesian3

Creates a Cartesian3 instance from x, y and z coordinates.

Name Type Description
x Number

The x coordinate.

y Number

The y coordinate.

z Number

The z coordinate.

result Cartesian3 optional

The object onto which to store the result.

Returns:

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

static Cartesian3.fromSpherical(spherical, result)Cartesian3

Converts the provided Spherical into Cartesian3 coordinates.

Name Type Description
spherical Spherical

The Spherical to be converted to Cartesian3.

result Cartesian3 optional

The object onto which to store the result.

Returns:

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

static Cartesian3.magnitude(cartesian)Number

Computes the Cartesian's magnitude (length).

Name Type Description
cartesian Cartesian3

The Cartesian instance whose magnitude is to be computed.

Returns:

The magnitude.

static Cartesian3.magnitudeSquared(cartesian)Number

Computes the provided Cartesian's squared magnitude.

Name Type Description
cartesian Cartesian3

The Cartesian instance whose squared magnitude is to be computed.

Returns:

The squared magnitude.

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

Multiplies the provided Cartesian componentwise by the provided scalar.

Name Type Description
cartesian Cartesian3

The Cartesian to be scaled.

scalar Number

The scalar to multiply with.

result Cartesian3

The object onto which to store the result.

Returns:

The modified result parameter.

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

Computes the componentwise product of two Cartesians.

Name Type Description
left Cartesian3

The first Cartesian.

right Cartesian3

The second Cartesian.

result Cartesian3

The object onto which to store the result.

Returns:

The modified result parameter.

static Cartesian3.negate(cartesian, result)Cartesian3

Negates the provided Cartesian.

Name Type Description
cartesian Cartesian3

The Cartesian to be negated.

result Cartesian3

The object onto which to store the result.

Returns:

The modified result parameter.

static Cartesian3.normalize(cartesian, result)Cartesian3

Computes the normalized form of the supplied Cartesian.

Name Type Description
cartesian Cartesian3

The Cartesian to be normalized.

result Cartesian3

The object onto which to store the result.

Returns:

The modified result parameter.

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

Stores the provided instance into the provided array.

Name Type Default Description
value Cartesian3

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 Cartesian3.subtract(left, right, result)Cartesian3

Computes the componentwise difference of two Cartesians.

Name Type Description
left Cartesian3

The first Cartesian.

right Cartesian3

The second Cartesian.

result Cartesian3

The object onto which to store the result.

Returns:

The modified result parameter.