# Cartesian3

#### new Cesium.Cartesian3(x, y, z)
Core/Cartesian3.js 30

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.

##### See:

- Cartesian2
- Cartesian4
- Packable

### Members

#### x : Number
Core/Cartesian3.js 36

The X component.

Default Value: `0.0`

#### y : Number
Core/Cartesian3.js 43

The Y component.

Default Value: `0.0`

#### z : Number
Core/Cartesian3.js 50

The Z component.

Default Value: `0.0`

#### staticCesium.Cartesian3.packedLength : Number
Core/Cartesian3.js 135

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

#### static constantCesium.Cartesian3.UNIT_X : Cartesian3
Core/Cartesian3.js 1029

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

#### static constantCesium.Cartesian3.UNIT_Y : Cartesian3
Core/Cartesian3.js 1037

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

#### static constantCesium.Cartesian3.UNIT_Z : Cartesian3
Core/Cartesian3.js 1045

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

#### static constantCesium.Cartesian3.ZERO : Cartesian3
Core/Cartesian3.js 1021

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

### Methods

#### clone(result) → Cartesian3
Core/Cartesian3.js 1053

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
Core/Cartesian3.js 1064

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
Core/Cartesian3.js 1078

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

#### isNaN() → Boolean
Core/Cartesian3.js 1095

hys 是否是无效值

##### Returns:

如果有无效值则返回false 都是正常值则返回true

#### toString() → String
Core/Cartesian3.js 1087

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

##### Returns:

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

#### staticCesium.Cartesian3.abs(cartesian, result) → Cartesian3
Core/Cartesian3.js 596

Computes the absolute value of the provided Cartesian.

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

##### Returns:

The modified result parameter.

#### staticCesium.Cartesian3.add(left, right, result) → Cartesian3
Core/Cartesian3.js 494

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.

#### staticCesium.Cartesian3.angleBetween(left, right) → Number
Core/Cartesian3.js 640

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

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

##### Returns:

The angle between the Cartesians.

#### staticCesium.Cartesian3.clone(cartesian, result) → Cartesian3
Core/Cartesian3.js 106

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)

#### staticCesium.Cartesian3.cross(left, right, result) → Cartesian3
Core/Cartesian3.js 757

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.

#### staticCesium.Cartesian3.distance(left, right) → Number
Core/Cartesian3.js 368

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
    var d = Cesium.Cartesian3.distance(new Cesium.Cartesian3(1.0, 0.0, 0.0), new Cesium.Cartesian3(2.0, 0.0, 0.0));

#### staticCesium.Cartesian3.distanceSquared(left, right) → Number
Core/Cartesian3.js 390

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

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 4.0, not 2.0
    var d = Cesium.Cartesian3.distanceSquared(new Cesium.Cartesian3(1.0, 0.0, 0.0), new Cesium.Cartesian3(3.0, 0.0, 0.0));

#### staticCesium.Cartesian3.divideByScalar(cartesian, scalar, result) → Cartesian3
Core/Cartesian3.js 557

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.

#### staticCesium.Cartesian3.divideComponents(left, right, result) → Cartesian3
Core/Cartesian3.js 473

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.

#### staticCesium.Cartesian3.dot(left, right) → Number
Core/Cartesian3.js 435

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.

#### staticCesium.Cartesian3.equals(left, right) → Boolean
Core/Cartesian3.js 711

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.

#### staticCesium.Cartesian3.equalsEpsilon(left, right, relativeEpsilon, absoluteEpsilon) → Boolean
Core/Cartesian3.js 740

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

#### staticCesium.Cartesian3.fromArray(array, startingIndex, result) → Cartesian3
Core/Cartesian3.js 258

Creates a Cartesian3 from three consecutive elements in an array.

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

##### Example:

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

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

#### staticCesium.Cartesian3.fromCartesian4(cartesian, result) → Cartesian3
Core/Cartesian3.js 129

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

Name | Type | Description
--- | --- | ---
`cartesian` | Cartesian4 | The Cartesian4 instance to create a Cartesian3 instance from.
`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.

#### staticCesium.Cartesian3.fromDegrees(longitude, latitude, height, ellipsoid, result) → Cartesian3
Core/Cartesian3.js 815

Returns a Cartesian3 position from longitude and latitude values given in degrees.

Name | Type | Default | Description
--- | --- | --- | ---
`longitude` | Number |  | The longitude, in degrees
`latitude` | Number |  | The latitude, in degrees
`height` | Number | `0.0` | optional The height, in meters, above the ellipsoid.
`ellipsoid` | Ellipsoid | `Ellipsoid.WGS84` | optional The ellipsoid on which the position lies.
`result` | Cartesian3 |  | optional The object onto which to store the result.

##### Returns:

The position

##### Example:

    var position = Cesium.Cartesian3.fromDegrees(-115.0, 37.0);

#### staticCesium.Cartesian3.fromDegreesArray(coordinates, ellipsoid, result) → Array.<Cartesian3>
Core/Cartesian3.js 880

Returns an array of Cartesian3 positions given an array of longitude and latitude values given in degrees.

Name | Type | Default | Description
--- | --- | --- | ---
`coordinates` | Array.<Number> |  | A list of longitude and latitude values. Values alternate [longitude, latitude, longitude, latitude...].
`ellipsoid` | Ellipsoid | `Ellipsoid.WGS84` | optional The ellipsoid on which the coordinates lie.
`result` | Array.<Cartesian3> |  | optional An array of Cartesian3 objects to store the result.

##### Returns:

The array of positions.

##### Example:

    var positions = Cesium.Cartesian3.fromDegreesArray([-115.0, 37.0, -107.0, 33.0]);

#### staticCesium.Cartesian3.fromDegreesArrayHeights(coordinates, ellipsoid, result) → Array.<Cartesian3>
Core/Cartesian3.js 952

Returns an array of Cartesian3 positions given an array of longitude, latitude and height values where longitude and latitude are given in degrees.

Name | Type | Default | Description
--- | --- | --- | ---
`coordinates` | Array.<Number> |  | A list of longitude, latitude and height values. Values alternate [longitude, latitude, height, longitude, latitude, height...].
`ellipsoid` | Ellipsoid | `Ellipsoid.WGS84` | optional The ellipsoid on which the position lies.
`result` | Array.<Cartesian3> |  | optional An array of Cartesian3 objects to store the result.

##### Returns:

The array of positions.

##### Example:

    var positions = Cesium.Cartesian3.fromDegreesArrayHeights([-115.0, 37.0, 100000.0, -107.0, 33.0, 150000.0]);

#### staticCesium.Cartesian3.fromElements(x, y, z, result) → Cartesian3
Core/Cartesian3.js 88

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.

#### staticCesium.Cartesian3.fromRadians(longitude, latitude, height, ellipsoid, result) → Cartesian3
Core/Cartesian3.js 843

Returns a Cartesian3 position from longitude and latitude values given in radians.

Name | Type | Default | Description
--- | --- | --- | ---
`longitude` | Number |  | The longitude, in radians
`latitude` | Number |  | The latitude, in radians
`height` | Number | `0.0` | optional The height, in meters, above the ellipsoid.
`ellipsoid` | Ellipsoid | `Ellipsoid.WGS84` | optional The ellipsoid on which the position lies.
`result` | Cartesian3 |  | optional The object onto which to store the result.

##### Returns:

The position

##### Example:

    var position = Cesium.Cartesian3.fromRadians(-2.007, 0.645);

#### staticCesium.Cartesian3.fromRadiansArray(coordinates, ellipsoid, result) → Array.<Cartesian3>
Core/Cartesian3.js 916

Returns an array of Cartesian3 positions given an array of longitude and latitude values given in radians.

Name | Type | Default | Description
--- | --- | --- | ---
`coordinates` | Array.<Number> |  | A list of longitude and latitude values. Values alternate [longitude, latitude, longitude, latitude...].
`ellipsoid` | Ellipsoid | `Ellipsoid.WGS84` | optional The ellipsoid on which the coordinates lie.
`result` | Array.<Cartesian3> |  | optional An array of Cartesian3 objects to store the result.

##### Returns:

The array of positions.

##### Example:

    var positions = Cesium.Cartesian3.fromRadiansArray([-2.007, 0.645, -1.867, .575]);

#### staticCesium.Cartesian3.fromRadiansArrayHeights(coordinates, ellipsoid, result) → Array.<Cartesian3>
Core/Cartesian3.js 989

Returns an array of Cartesian3 positions given an array of longitude, latitude and height values where longitude and latitude are given in radians.

Name | Type | Default | Description
--- | --- | --- | ---
`coordinates` | Array.<Number> |  | A list of longitude, latitude and height values. Values alternate [longitude, latitude, height, longitude, latitude, height...].
`ellipsoid` | Ellipsoid | `Ellipsoid.WGS84` | optional The ellipsoid on which the position lies.
`result` | Array.<Cartesian3> |  | optional An array of Cartesian3 objects to store the result.

##### Returns:

The array of positions.

##### Example:

    var positions = Cesium.Cartesian3.fromRadiansArrayHeights([-2.007, 0.645, 100000.0, -1.867, .575, 150000.0]);

#### staticCesium.Cartesian3.fromSpherical(spherical, result) → Cartesian3
Core/Cartesian3.js 60

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.

#### staticCesium.Cartesian3.lerp(start, end, t, result) → Cartesian3
Core/Cartesian3.js 618

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

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

##### Returns:

The modified result parameter.

#### staticCesium.Cartesian3.magnitude(cartesian) → Number
Core/Cartesian3.js 351

Computes the Cartesian's magnitude (length).

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

##### Returns:

The magnitude.

#### staticCesium.Cartesian3.magnitudeSquared(cartesian) → Number
Core/Cartesian3.js 337

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.

#### staticCesium.Cartesian3.maximumByComponent(first, second, result) → Cartesian3
Core/Cartesian3.js 318

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

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

##### Returns:

A cartesian with the maximum components.

#### staticCesium.Cartesian3.maximumComponent(cartesian) → Number
Core/Cartesian3.js 266

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

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

##### Returns:

The value of the maximum component.

#### staticCesium.Cartesian3.midpoint(left, right, result) → Cartesian3
Core/Cartesian3.js 788

Computes the midpoint between the right and left Cartesian.

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

#### staticCesium.Cartesian3.minimumByComponent(first, second, result) → Cartesian3
Core/Cartesian3.js 296

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

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

##### Returns:

A cartesian with the minimum components.

#### staticCesium.Cartesian3.minimumComponent(cartesian) → Number
Core/Cartesian3.js 280

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

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

##### Returns:

The value of the minimum component.

#### staticCesium.Cartesian3.mostOrthogonalAxis(cartesian, result) → Cartesian3
Core/Cartesian3.js 661

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

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

##### Returns:

The most orthogonal axis.

#### staticCesium.Cartesian3.multiplyByScalar(cartesian, scalar, result) → Cartesian3
Core/Cartesian3.js 536

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.

#### staticCesium.Cartesian3.multiplyComponents(left, right, result) → Cartesian3
Core/Cartesian3.js 452

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.

#### staticCesium.Cartesian3.negate(cartesian, result) → Cartesian3
Core/Cartesian3.js 577

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.

#### staticCesium.Cartesian3.normalize(cartesian, result) → Cartesian3
Core/Cartesian3.js 407

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.

#### staticCesium.Cartesian3.pack(value, array, startingIndex) → Array.<Number>
Core/Cartesian3.js 146

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

#### staticCesium.Cartesian3.packArray(array, result) → Array.<Number>
Core/Cartesian3.js 192

Flattens an array of Cartesian3s into an array of components.

Name | Type | Description
--- | --- | ---
`array` | Array.<Cartesian3> | The array of cartesians to pack.
`result` | Array.<Number> | The array onto which to store the result.

##### Returns:

The packed array.

#### staticCesium.Cartesian3.projectVector(a, b, result) → Cartesian3
Core/Cartesian3.js 692

Projects vector a onto vector b

Name | Type | Description
--- | --- | ---
`a` | Cartesian3 | The vector that needs projecting
`b` | Cartesian3 | The vector to project onto
`result` | Cartesian3 | The result cartesian

##### Returns:

The modified result parameter

#### staticCesium.Cartesian3.subtract(left, right, result) → Cartesian3
Core/Cartesian3.js 515

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.

#### staticCesium.Cartesian3.unpack(array, startingIndex, result) → Cartesian3
Core/Cartesian3.js 169

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` | Cartesian3 |  | optional The object into which to store the result.

##### Returns:

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

#### staticCesium.Cartesian3.unpackArray(array, result) → Array.<Cartesian3>
Core/Cartesian3.js 217

Unpacks an array of cartesian components into an array of Cartesian3s.

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

##### Returns:

The unpacked array.