Cartesian2

new Cartesian2(x, y)

A 2D Cartesian point.

Name Type Default Description
x Number 0.0 optional

The X component.

y Number 0.0 optional

The Y component.

Members

The X component.

Default Value: 0.0

The Y component.

Default Value: 0.0

static constant Cartesian2.ONE : Cartesian2

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

static constant Cartesian2.UNIT_X : Cartesian2

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

static constant Cartesian2.UNIT_Y : Cartesian2

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

static constant Cartesian2.ZERO : Cartesian2

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

Methods

Duplicates this Cartesian2 instance.

Name Type Description
result Cartesian2 optional

The object onto which to store the result.

Returns:

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

Normalize this 2-dimensions vector.

Returns:

this object.

toString()String

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

Returns:

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

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

Computes the componentwise sum of two Cartesians.

Name Type Description
left Cartesian2

The first Cartesian.

right Cartesian2

The second Cartesian.

result Cartesian2

The object onto which to store the result.

Returns:

The modified result parameter.

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

Constrain a value to lie between two values.

Name Type Description
value Cartesian2

The value to clamp.

min Cartesian2

The minimum bound.

max Cartesian2

The maximum bound.

result Cartesian2

The object into which to store the result.

Returns:

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

static Cartesian2.clone(cartesian, result)Cartesian2

Duplicates a Cartesian2 instance.

Name Type Description
cartesian Cartesian2

The Cartesian to duplicate.

result Cartesian2 optional

The object onto which to store the result.

Returns:

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

static Cartesian2.cross(left, right)Number

Computes the magnitude of the cross product that would result from implicitly setting the Z coordinate of the input vectors to 0

Name Type Description
left Cartesian2

The first Cartesian.

right Cartesian2

The second Cartesian.

Returns:

The cross product.

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

Divides the provided Cartesian componentwise by the provided scalar.

Name Type Description
cartesian Cartesian2

The Cartesian to be divided.

scalar Number

The scalar to divide by.

result Cartesian2

The object onto which to store the result.

Returns:

The modified result parameter.

static Cartesian2.dot(left, right)Number

Computes the dot (scalar) product of two Cartesians.

Name Type Description
left Cartesian2

The first Cartesian.

right Cartesian2

The second Cartesian.

Returns:

The dot product.

static Cartesian2.equals(left, right)Boolean

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

Name Type Description
left Cartesian2 optional

The first Cartesian.

right Cartesian2 optional

The second Cartesian.

Returns:

true if left and right are equal, false otherwise.

static Cartesian2.fromCartesian3(cartesian, result)Cartesian2

Creates a Cartesian2 instance from an existing Cartesian3. This simply takes the x and y properties of the Cartesian3 and drops z.

Name Type Description
cartesian Cartesian3

The Cartesian3 instance to create a Cartesian2 instance from.

result Cartesian2 optional

The object onto which to store the result.

Returns:

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

static Cartesian2.fromCartesian4(cartesian, result)Cartesian2

Creates a Cartesian2 instance from an existing Cartesian4. This simply takes the x and y properties of the Cartesian4 and drops z and w.

Name Type Description
cartesian Cartesian4

The Cartesian4 instance to create a Cartesian2 instance from.

result Cartesian2 optional

The object onto which to store the result.

Returns:

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

static Cartesian2.fromElements(x, y, result)Cartesian2

Creates a Cartesian2 instance from x and y coordinates.

Name Type Description
x Number

The x coordinate.

y Number

The y coordinate.

result Cartesian2 optional

The object onto which to store the result.

Returns:

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

static Cartesian2.magnitude(cartesian)Number

Computes the Cartesian's magnitude (length).

Name Type Description
cartesian Cartesian2

The Cartesian instance whose magnitude is to be computed.

Returns:

The magnitude.

static Cartesian2.magnitudeSquared(cartesian)Number

Computes the provided Cartesian's squared magnitude.

Name Type Description
cartesian Cartesian2

The Cartesian instance whose squared magnitude is to be computed.

Returns:

The squared magnitude.

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

Multiplies the provided Cartesian componentwise by the provided scalar.

Name Type Description
cartesian Cartesian2

The Cartesian to be scaled.

scalar Number

The scalar to multiply with.

result Cartesian2

The object onto which to store the result.

Returns:

The modified result parameter.

static Cartesian2.negate(cartesian, result)Cartesian2

Negates the provided Cartesian.

Name Type Description
cartesian Cartesian2

The Cartesian to be negated.

result Cartesian2

The object onto which to store the result.

Returns:

The modified result parameter.

static Cartesian2.normalize(cartesian, result)Cartesian2

Computes the normalized form of the supplied Cartesian.

Name Type Description
cartesian Cartesian2

The Cartesian to be normalized.

result Cartesian2

The object onto which to store the result.

Returns:

The modified result parameter.

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

Computes the componentwise difference of two Cartesians.

Name Type Description
left Cartesian2

The first Cartesian.

right Cartesian2

The second Cartesian.

result Cartesian2

The object onto which to store the result.

Returns:

The modified result parameter.