Skip to content

KBE3D / KBCore / Cesium / Cartesian3

类: Cartesian3

A 3D Cartesian point.

参数

The X component.

参数

The Y component.

参数

The Z component.

属性

packedLength

static packedLength: number

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


ZERO

readonly static ZERO: Cartesian3

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


ONE

readonly static ONE: Cartesian3

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


UNIT_X

readonly static UNIT_X: Cartesian3

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


UNIT_Y

readonly static UNIT_Y: Cartesian3

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


UNIT_Z

readonly static UNIT_Z: Cartesian3

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


x

x: number

The X component.


y

y: number

The Y component.


z

z: number

The Z component.

方法

fromSpherical()

static fromSpherical(spherical: Spherical, result?: Cartesian3): Cartesian3

Converts the provided Spherical into Cartesian3 coordinates.

参数

spherical

Spherical

The Spherical to be converted to Cartesian3.

result?

Cartesian3

The object onto which to store the result.

返回

Cartesian3

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


fromElements()

static fromElements(x: number, y: number, z: number, result?: Cartesian3): Cartesian3

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

参数

x

number

The x coordinate.

y

number

The y coordinate.

z

number

The z coordinate.

result?

Cartesian3

The object onto which to store the result.

返回

Cartesian3

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


clone()

static clone(cartesian: Cartesian3, result?: Cartesian3): Cartesian3

Duplicates a Cartesian3 instance.

参数

cartesian

Cartesian3

The Cartesian to duplicate.

result?

Cartesian3

The object onto which to store the result.

返回

Cartesian3

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


pack()

static pack(value: Cartesian3, array: number[] | TypedArray, startingIndex?: number): number[] | TypedArray

Stores the provided instance into the provided array.

参数

value

Cartesian3

The value to pack.

array

The array to pack into.

number[] | TypedArray

startingIndex?

number

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

返回

number[] | TypedArray

The array that was packed into


unpack()

static unpack(array: number[] | TypedArray, startingIndex?: number, result?: Cartesian3): Cartesian3

Retrieves an instance from a packed array.

参数

array

The packed array.

number[] | TypedArray

startingIndex?

number

The starting index of the element to be unpacked.

result?

Cartesian3

The object into which to store the result.

返回

Cartesian3

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


packArray()

static packArray(array: Cartesian3[], result?: number[] | TypedArray): number[] | TypedArray

Flattens an array of Cartesian3s into an array of components.

参数

array

Cartesian3[]

The array of cartesians to pack.

result?

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

number[] | TypedArray

返回

number[] | TypedArray

The packed array.


unpackArray()

static unpackArray(array: number[] | TypedArray, result?: Cartesian3[]): Cartesian3[]

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

参数

array

The array of components to unpack.

number[] | TypedArray

result?

Cartesian3[]

The array onto which to store the result.

返回

Cartesian3[]

The unpacked array.


maximumComponent()

static maximumComponent(cartesian: Cartesian3): number

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

参数

cartesian

Cartesian3

The cartesian to use.

返回

number

The value of the maximum component.


minimumComponent()

static minimumComponent(cartesian: Cartesian3): number

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

参数

cartesian

Cartesian3

The cartesian to use.

返回

number

The value of the minimum component.


minimumByComponent()

static minimumByComponent(first: Cartesian3, second: Cartesian3, result: Cartesian3): Cartesian3

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

参数

first

Cartesian3

A cartesian to compare.

second

Cartesian3

A cartesian to compare.

result

Cartesian3

The object into which to store the result.

返回

Cartesian3

A cartesian with the minimum components.


maximumByComponent()

static maximumByComponent(first: Cartesian3, second: Cartesian3, result: Cartesian3): Cartesian3

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

参数

first

Cartesian3

A cartesian to compare.

second

Cartesian3

A cartesian to compare.

result

Cartesian3

The object into which to store the result.

返回

Cartesian3

A cartesian with the maximum components.


clamp()

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

Constrain a value to lie between two values.

参数

value

Cartesian3

The value to clamp.

min

Cartesian3

The minimum bound.

max

Cartesian3

The maximum bound.

result

Cartesian3

The object into which to store the result.

返回

Cartesian3

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


magnitudeSquared()

static magnitudeSquared(cartesian: Cartesian3): number

Computes the provided Cartesian's squared magnitude.

参数

cartesian

Cartesian3

The Cartesian instance whose squared magnitude is to be computed.

返回

number

The squared magnitude.


magnitude()

static magnitude(cartesian: Cartesian3): number

Computes the Cartesian's magnitude (length).

参数

cartesian

Cartesian3

The Cartesian instance whose magnitude is to be computed.

返回

number

The magnitude.


distance()

static distance(left: Cartesian3, right: Cartesian3): number

Computes the distance between two points.

参数

left

Cartesian3

The first point to compute the distance from.

Cartesian3

The second point to compute the distance to.

返回

number

The distance between two points.

示例

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

distanceSquared()

static distanceSquared(left: Cartesian3, right: Cartesian3): number

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

参数

left

Cartesian3

The first point to compute the distance from.

right

Cartesian3

The second point to compute the distance to.

返回

number

The distance between two points.

示例

ts
// Returns 4.0, not 2.0
const d = Cesium.Cartesian3.distanceSquared(new Cesium.Cartesian3(1.0, 0.0, 0.0), new Cesium.Cartesian3(3.0, 0.0, 0.0));

normalize()

static normalize(cartesian: Cartesian3, result: Cartesian3): Cartesian3

Computes the normalized form of the supplied Cartesian.

参数

cartesian

Cartesian3

The Cartesian to be normalized.

result

Cartesian3

The object onto which to store the result.

返回

Cartesian3

The modified result parameter.


dot()

static dot(left: Cartesian3, right: Cartesian3): number

Computes the dot (scalar) product of two Cartesians.

参数

left

Cartesian3

The first Cartesian.

right

Cartesian3

The second Cartesian.

返回

number

The dot product.


multiplyComponents()

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

Computes the componentwise product of two Cartesians.

参数

left

Cartesian3

The first Cartesian.

right

Cartesian3

The second Cartesian.

result

Cartesian3

The object onto which to store the result.

返回

Cartesian3

The modified result parameter.


divideComponents()

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

Computes the componentwise quotient of two Cartesians.

参数

left

Cartesian3

The first Cartesian.

right

Cartesian3

The second Cartesian.

result

Cartesian3

The object onto which to store the result.

返回

Cartesian3

The modified result parameter.


add()

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

Computes the componentwise sum of two Cartesians.

参数

left

Cartesian3

The first Cartesian.

right

Cartesian3

The second Cartesian.

result

Cartesian3

The object onto which to store the result.

返回

Cartesian3

The modified result parameter.


subtract()

static subtract(left: Cartesian3, right: Cartesian3, result: Cartesian3): Cartesian3

Computes the componentwise difference of two Cartesians.

参数

left

Cartesian3

The first Cartesian.

right

Cartesian3

The second Cartesian.

result

Cartesian3

The object onto which to store the result.

返回

Cartesian3

The modified result parameter.


multiplyByScalar()

static multiplyByScalar(cartesian: Cartesian3, scalar: number, result: Cartesian3): Cartesian3

Multiplies the provided Cartesian componentwise by the provided scalar.

参数

cartesian

Cartesian3

The Cartesian to be scaled.

scalar

number

The scalar to multiply with.

result

Cartesian3

The object onto which to store the result.

返回

Cartesian3

The modified result parameter.


divideByScalar()

static divideByScalar(cartesian: Cartesian3, scalar: number, result: Cartesian3): Cartesian3

Divides the provided Cartesian componentwise by the provided scalar.

参数

cartesian

Cartesian3

The Cartesian to be divided.

scalar

number

The scalar to divide by.

result

Cartesian3

The object onto which to store the result.

返回

Cartesian3

The modified result parameter.


negate()

static negate(cartesian: Cartesian3, result: Cartesian3): Cartesian3

Negates the provided Cartesian.

参数

cartesian

Cartesian3

The Cartesian to be negated.

result

Cartesian3

The object onto which to store the result.

返回

Cartesian3

The modified result parameter.


abs()

static abs(cartesian: Cartesian3, result: Cartesian3): Cartesian3

Computes the absolute value of the provided Cartesian.

参数

cartesian

Cartesian3

The Cartesian whose absolute value is to be computed.

result

Cartesian3

The object onto which to store the result.

返回

Cartesian3

The modified result parameter.


lerp()

static lerp(start: Cartesian3, end: Cartesian3, t: number, result: Cartesian3): Cartesian3

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

参数

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.

返回

Cartesian3

The modified result parameter.


angleBetween()

static angleBetween(left: Cartesian3, right: Cartesian3): number

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

参数

left

Cartesian3

The first Cartesian.

right

Cartesian3

The second Cartesian.

返回

number

The angle between the Cartesians.


mostOrthogonalAxis()

static mostOrthogonalAxis(cartesian: Cartesian3, result: Cartesian3): Cartesian3

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

参数

cartesian

Cartesian3

The Cartesian on which to find the most orthogonal axis.

result

Cartesian3

The object onto which to store the result.

返回

Cartesian3

The most orthogonal axis.


projectVector()

static projectVector(a: Cartesian3, b: Cartesian3, result: Cartesian3): Cartesian3

Projects vector a onto vector b

参数

a

Cartesian3

The vector that needs projecting

b

Cartesian3

The vector to project onto

result

Cartesian3

The result cartesian

返回

Cartesian3

The modified result parameter


equals()

static equals(left?: Cartesian3, right?: Cartesian3): boolean

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

参数

left?

Cartesian3

The first Cartesian.

right?

Cartesian3

The second Cartesian.

返回

boolean

true if left and right are equal, false otherwise.


equalsEpsilon()

static equalsEpsilon(left?: Cartesian3, right?: Cartesian3, relativeEpsilon?: number, absoluteEpsilon?: number): boolean

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

参数

left?

Cartesian3

The first Cartesian.

right?

Cartesian3

The second Cartesian.

relativeEpsilon?

number

The relative epsilon tolerance to use for equality testing.

absoluteEpsilon?

number

The absolute epsilon tolerance to use for equality testing.

返回

boolean

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


cross()

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

Computes the cross (outer) product of two Cartesians.

参数

left

Cartesian3

The first Cartesian.

right

Cartesian3

The second Cartesian.

result

Cartesian3

The object onto which to store the result.

返回

Cartesian3

The cross product.


midpoint()

static midpoint(left: Cartesian3, right: Cartesian3, result: Cartesian3): Cartesian3

Computes the midpoint between the right and left Cartesian.

参数

left

Cartesian3

The first Cartesian.

right

Cartesian3

The second Cartesian.

result

Cartesian3

The object onto which to store the result.

返回

Cartesian3

The midpoint.


fromDegrees()

static fromDegrees(longitude: number, latitude: number, height?: number, ellipsoid?: Ellipsoid, result?: Cartesian3): Cartesian3

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

参数

longitude

number

The longitude, in degrees

latitude

number

The latitude, in degrees

height?

number

The height, in meters, above the ellipsoid.

ellipsoid?

Ellipsoid

The ellipsoid on which the position lies.

result?

Cartesian3

The object onto which to store the result.

返回

Cartesian3

The position

示例

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

fromRadians()

static fromRadians(longitude: number, latitude: number, height?: number, ellipsoid?: Ellipsoid, result?: Cartesian3): Cartesian3

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

参数

longitude

number

The longitude, in radians

latitude

number

The latitude, in radians

height?

number

The height, in meters, above the ellipsoid.

ellipsoid?

Ellipsoid

The ellipsoid on which the position lies.

result?

Cartesian3

The object onto which to store the result.

返回

Cartesian3

The position

示例

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

fromDegreesArray()

static fromDegreesArray(coordinates: number[], ellipsoid?: Ellipsoid, result?: Cartesian3[]): Cartesian3[]

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

参数

coordinates

number[]

A list of longitude and latitude values. Values alternate [longitude, latitude, longitude, latitude...].

ellipsoid?

Ellipsoid

The ellipsoid on which the coordinates lie.

result?

Cartesian3[]

An array of Cartesian3 objects to store the result.

返回

Cartesian3[]

The array of positions.

示例

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

fromRadiansArray()

static fromRadiansArray(coordinates: number[], ellipsoid?: Ellipsoid, result?: Cartesian3[]): Cartesian3[]

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

参数

coordinates

number[]

A list of longitude and latitude values. Values alternate [longitude, latitude, longitude, latitude...].

ellipsoid?

Ellipsoid

The ellipsoid on which the coordinates lie.

result?

Cartesian3[]

An array of Cartesian3 objects to store the result.

返回

Cartesian3[]

The array of positions.

示例

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

fromDegreesArrayHeights()

static fromDegreesArrayHeights(coordinates: number[], ellipsoid?: Ellipsoid, result?: Cartesian3[]): Cartesian3[]

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

参数

coordinates

number[]

A list of longitude, latitude and height values. Values alternate [longitude, latitude, height, longitude, latitude, height...].

ellipsoid?

Ellipsoid

The ellipsoid on which the position lies.

result?

Cartesian3[]

An array of Cartesian3 objects to store the result.

返回

Cartesian3[]

The array of positions.

示例

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

fromRadiansArrayHeights()

static fromRadiansArrayHeights(coordinates: number[], ellipsoid?: Ellipsoid, result?: Cartesian3[]): Cartesian3[]

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

参数

coordinates

number[]

A list of longitude, latitude and height values. Values alternate [longitude, latitude, height, longitude, latitude, height...].

ellipsoid?

Ellipsoid

The ellipsoid on which the position lies.

result?

Cartesian3[]

An array of Cartesian3 objects to store the result.

返回

Cartesian3[]

The array of positions.

示例

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

fromCartesian4()

static fromCartesian4(cartesian: Cartesian4, result?: Cartesian3): Cartesian3

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

参数

cartesian

Cartesian4

The Cartesian4 instance to create a Cartesian3 instance from.

result?

Cartesian3

The object onto which to store the result.

返回

Cartesian3

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


fromArray()

static fromArray(array: number[], startingIndex?: number, result?: Cartesian3): Cartesian3

Creates a Cartesian3 from three consecutive elements in an array.

参数

array

number[]

The array whose three consecutive elements correspond to the x, y, and z components, respectively.

startingIndex?

number

The offset into the array of the first element, which corresponds to the x component.

result?

Cartesian3

The object onto which to store the result.

返回

Cartesian3

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

示例

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

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

clone()

clone(result?: Cartesian3): Cartesian3

Duplicates this Cartesian3 instance.

参数

result?

Cartesian3

The object onto which to store the result.

返回

Cartesian3

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


equals()

equals(right?: Cartesian3): boolean

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

参数

right?

Cartesian3

The right hand side Cartesian.

返回

boolean

true if they are equal, false otherwise.


equalsEpsilon()

equalsEpsilon(right?: Cartesian3, relativeEpsilon?: number, absoluteEpsilon?: number): boolean

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

参数

right?

Cartesian3

The right hand side Cartesian.

relativeEpsilon?

number

The relative epsilon tolerance to use for equality testing.

absoluteEpsilon?

number

The absolute epsilon tolerance to use for equality testing.

返回

boolean

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


toString()

toString(): string

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

返回

string

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

构造函数

构造函数

new Cartesian3(x?: number, y?: number, z?: number): Cartesian3

参数

x?

number

y?

number

z?

number

返回

Cartesian3

KBE3D @3.0.0 Copyright © 2024-present KBE3D