# Cartesian2

#### new Cesium.Cartesian2(x, y)
Core/Cartesian2.js 19

A 2D Cartesian point.

Name | Type | Default | Description
--- | --- | --- | ---
`x` | Number | `0.0` | optional The X component.
`y` | Number | `0.0` | optional The Y component.

##### See:

- Cartesian3
- Cartesian4
- Packable

### Members

#### x : Number
Core/Cartesian2.js 25

The X component.

Default Value: `0.0`

#### y : Number
Core/Cartesian2.js 32

The Y component.

Default Value: `0.0`

#### static constant Cesium.Cartesian2.ONE : Cartesian2
Core/Cartesian2.js 727

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

#### static Cesium.Cartesian2.packedLength : Number
Core/Cartesian2.js 99

The number of elements used to pack the object into an array.

#### static constant Cesium.Cartesian2.UNIT_X : Cartesian2
Core/Cartesian2.js 735

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

#### static constant Cesium.Cartesian2.UNIT_Y : Cartesian2
Core/Cartesian2.js 743

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

#### static constant Cesium.Cartesian2.ZERO : Cartesian2
Core/Cartesian2.js 719

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

### Methods

#### clone(result) → Cartesian2
Core/Cartesian2.js 751

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.

#### equals(right) → Boolean
Core/Cartesian2.js 762

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

Name | Type | Description
--- | --- | ---
`right` | Cartesian2 | optional The right hand side Cartesian.

##### Returns:

`true` if they are equal, `false` otherwise.

#### equalsEpsilon(right, relativeEpsilon, absoluteEpsilon) → Boolean
Core/Cartesian2.js 776

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` | Cartesian2 |  | 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.

#### toString() → String
Core/Cartesian2.js 794

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

##### Returns:

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

#### static Cesium.Cartesian2.abs(cartesian, result) → Cartesian2
Core/Cartesian2.js 570

Computes the absolute value of the provided Cartesian.

Name | Type | Description
--- | --- | ---
`cartesian` | Cartesian2 | The Cartesian whose absolute value is to be computed.
`result` | Cartesian2 | The object onto which to store the result.

##### Returns:

The modified result parameter.

#### static Cesium.Cartesian2.add(left, right, result) → Cartesian2
Core/Cartesian2.js 473

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 Cesium.Cartesian2.angleBetween(left, right) → Number
Core/Cartesian2.js 613

Returns the angle, in radians, between the provided Cartesians.

Name | Type | Description
--- | --- | ---
`left` | Cartesian2 | The first Cartesian.
`right` | Cartesian2 | The second Cartesian.

##### Returns:

The angle between the Cartesians.

#### static Cesium.Cartesian2.clone(cartesian, result) → Cartesian2
Core/Cartesian2.js 60

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 Cesium.Cartesian2.cross(left, right) → Number
Core/Cartesian2.js 416

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 Cesium.Cartesian2.distance(left, right) → Number
Core/Cartesian2.js 334

Computes the distance between two points.

Name | Type | Description
--- | --- | ---
`left` | Cartesian2 | The first point to compute the distance from.
`right` | Cartesian2 | The second point to compute the distance to.

##### Returns:

The distance between two points.

##### Example:

    // Returns 1.0
    var d = Cesium.Cartesian2.distance(new Cesium.Cartesian2(1.0, 0.0), new Cesium.Cartesian2(2.0, 0.0));

#### static Cesium.Cartesian2.distanceSquared(left, right) → Number
Core/Cartesian2.js 356

Computes the squared distance between two points. Comparing squared distances using this function is more efficient than comparing distances using `Cartesian2#distance`.

Name | Type | Description
--- | --- | ---
`left` | Cartesian2 | The first point to compute the distance from.
`right` | Cartesian2 | The second point to compute the distance to.

##### Returns:

The distance between two points.

##### Example:

    // Returns 4.0, not 2.0
    var d = Cesium.Cartesian2.distance(new Cesium.Cartesian2(1.0, 0.0), new Cesium.Cartesian2(3.0, 0.0));

#### static Cesium.Cartesian2.divideByScalar(cartesian, scalar, result) → Cartesian2
Core/Cartesian2.js 533

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 Cesium.Cartesian2.divideComponents(left, right, result) → Cartesian2
Core/Cartesian2.js 453

Computes the componentwise quotient 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 Cesium.Cartesian2.dot(left, right) → Number
Core/Cartesian2.js 400

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 Cesium.Cartesian2.equals(left, right) → Boolean
Core/Cartesian2.js 660

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 Cesium.Cartesian2.equalsEpsilon(left, right, relativeEpsilon, absoluteEpsilon) → Boolean
Core/Cartesian2.js 688

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

Name | Type | Default | Description
--- | --- | --- | ---
`left` | Cartesian2 |  | optional The first Cartesian.
`right` | Cartesian2 |  | 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 Cesium.Cartesian2.fromArray(array, startingIndex, result) → Cartesian2
Core/Cartesian2.js 226

Creates a Cartesian2 from two consecutive elements in an array.

Name | Type | Default | Description
--- | --- | --- | ---
`array` | Array.<Number> |  | The array whose two consecutive elements correspond to the x and y components, respectively.
`startingIndex` | Number | `0` | optional The offset into the array of the first element, which corresponds to the x component.
`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.

##### Example:

    // Create a Cartesian2 with (1.0, 2.0)
    var v = [1.0, 2.0];
    var p = Cesium.Cartesian2.fromArray(v);

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

#### static Cesium.Cartesian2.fromCartesian3(cartesian, result) → Cartesian2
Core/Cartesian2.js 82

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 Cesium.Cartesian2.fromCartesian4(cartesian, result) → Cartesian2
Core/Cartesian2.js 93

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 Cesium.Cartesian2.fromElements(x, y, result) → Cartesian2
Core/Cartesian2.js 43

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 Cesium.Cartesian2.lerp(start, end, t, result) → Cartesian2
Core/Cartesian2.js 591

Computes the linear interpolation or extrapolation at t using the provided cartesians.

Name | Type | Description
--- | --- | ---
`start` | Cartesian2 | The value corresponding to t at 0.0.
`end` | Cartesian2 | The value corresponding to t at 1.0.
`t` | Number | The point along t at which to interpolate.
`result` | Cartesian2 | The object onto which to store the result.

##### Returns:

The modified result parameter.

#### static Cesium.Cartesian2.magnitude(cartesian) → Number
Core/Cartesian2.js 317

Computes the Cartesian's magnitude (length).

Name | Type | Description
--- | --- | ---
`cartesian` | Cartesian2 | The Cartesian instance whose magnitude is to be computed.

##### Returns:

The magnitude.

#### static Cesium.Cartesian2.magnitudeSquared(cartesian) → Number
Core/Cartesian2.js 303

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 Cesium.Cartesian2.maximumByComponent(first, second, result) → Cartesian2
Core/Cartesian2.js 285

Compares two Cartesians and computes a Cartesian which contains the maximum components of the supplied Cartesians.

Name | Type | Description
--- | --- | ---
`first` | Cartesian2 | A cartesian to compare.
`second` | Cartesian2 | A cartesian to compare.
`result` | Cartesian2 | The object into which to store the result.

##### Returns:

A cartesian with the maximum components.

#### static Cesium.Cartesian2.maximumComponent(cartesian) → Number
Core/Cartesian2.js 234

Computes the value of the maximum component for the supplied Cartesian.

Name | Type | Description
--- | --- | ---
`cartesian` | Cartesian2 | The cartesian to use.

##### Returns:

The value of the maximum component.

#### static Cesium.Cartesian2.minimumByComponent(first, second, result) → Cartesian2
Core/Cartesian2.js 264

Compares two Cartesians and computes a Cartesian which contains the minimum components of the supplied Cartesians.

Name | Type | Description
--- | --- | ---
`first` | Cartesian2 | A cartesian to compare.
`second` | Cartesian2 | A cartesian to compare.
`result` | Cartesian2 | The object into which to store the result.

##### Returns:

A cartesian with the minimum components.

#### static Cesium.Cartesian2.minimumComponent(cartesian) → Number
Core/Cartesian2.js 248

Computes the value of the minimum component for the supplied Cartesian.

Name | Type | Description
--- | --- | ---
`cartesian` | Cartesian2 | The cartesian to use.

##### Returns:

The value of the minimum component.

#### static Cesium.Cartesian2.mostOrthogonalAxis(cartesian, result) → Cartesian2
Core/Cartesian2.js 634

Returns the axis that is most orthogonal to the provided Cartesian.

Name | Type | Description
--- | --- | ---
`cartesian` | Cartesian2 | The Cartesian on which to find the most orthogonal axis.
`result` | Cartesian2 | The object onto which to store the result.

##### Returns:

The most orthogonal axis.

#### static Cesium.Cartesian2.multiplyByScalar(cartesian, scalar, result) → Cartesian2
Core/Cartesian2.js 513

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 Cesium.Cartesian2.multiplyComponents(left, right, result) → Cartesian2
Core/Cartesian2.js 433

Computes the componentwise product 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 Cesium.Cartesian2.negate(cartesian, result) → Cartesian2
Core/Cartesian2.js 552

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 Cesium.Cartesian2.normalize(cartesian, result) → Cartesian2
Core/Cartesian2.js 373

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 Cesium.Cartesian2.pack(value, array, startingIndex) → Array.<Number>
Core/Cartesian2.js 110

Stores the provided instance into the provided array.

Name | Type | Default | Description
--- | --- | --- | ---
`value` | Cartesian2 |  | 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 Cesium.Cartesian2.packArray(array, result) → Array.<Number>
Core/Cartesian2.js 155

Flattens an array of Cartesian2s into and array of components.

Name | Type | Description
--- | --- | ---
`array` | Array.<Cartesian2> | 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 * 2 components, else a `DeveloperError` will be thrown. If it is a regular array, it will be resized to have (array.length * 2) elements.

##### Returns:

The packed array.

#### static Cesium.Cartesian2.subtract(left, right, result) → Cartesian2
Core/Cartesian2.js 493

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.

#### static Cesium.Cartesian2.unpack(array, startingIndex, result) → Cartesian2
Core/Cartesian2.js 132

Retrieves an instance from a packed array.

Name | Type | Default | Description
--- | --- | --- | ---
`array` | Array.<Number> |  | The packed array.
`startingIndex` | Number | `0` | optional The starting index of the element to be unpacked.
`result` | Cartesian2 |  | optional The object into which to store the result.

##### Returns:

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

#### static Cesium.Cartesian2.unpackArray(array, result) → Array.<Cartesian2>
Core/Cartesian2.js 185

Unpacks an array of cartesian components into and array of Cartesian2s.

Name | Type | Description
--- | --- | ---
`array` | Array.<Number> | The array of components to unpack.
`result` | Array.<Cartesian2> | optional The array onto which to store the result.

##### Returns:

The unpacked array.