Appearance
KBE3D / KBCore / Cesium / Cartesian2
类: Cartesian2
A 2D Cartesian point.
参数
The X component.
参数
The Y component.
属性
packedLength
staticpackedLength:number
The number of elements used to pack the object into an array.
ZERO
readonlystaticZERO:Cartesian2
An immutable Cartesian2 instance initialized to (0.0, 0.0).
ONE
readonlystaticONE:Cartesian2
An immutable Cartesian2 instance initialized to (1.0, 1.0).
UNIT_X
readonlystaticUNIT_X:Cartesian2
An immutable Cartesian2 instance initialized to (1.0, 0.0).
UNIT_Y
readonlystaticUNIT_Y:Cartesian2
An immutable Cartesian2 instance initialized to (0.0, 1.0).
x
x:
number
The X component.
y
y:
number
The Y component.
方法
fromElements()
staticfromElements(x:number,y:number,result?:Cartesian2):Cartesian2
Creates a Cartesian2 instance from x and y coordinates.
参数
x
number
The x coordinate.
y
number
The y coordinate.
result?
Cartesian2
The object onto which to store the result.
返回
Cartesian2
The modified result parameter or a new Cartesian2 instance if one was not provided.
clone()
staticclone(cartesian:Cartesian2,result?:Cartesian2):Cartesian2
Duplicates a Cartesian2 instance.
参数
cartesian
Cartesian2
The Cartesian to duplicate.
result?
Cartesian2
The object onto which to store the result.
返回
Cartesian2
The modified result parameter or a new Cartesian2 instance if one was not provided. (Returns undefined if cartesian is undefined)
pack()
staticpack(value:Cartesian2,array:number[] |TypedArray,startingIndex?:number):number[] |TypedArray
Stores the provided instance into the provided array.
参数
value
Cartesian2
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()
staticunpack(array:number[] |TypedArray,startingIndex?:number,result?:Cartesian2):Cartesian2
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?
Cartesian2
The object into which to store the result.
返回
Cartesian2
The modified result parameter or a new Cartesian2 instance if one was not provided.
packArray()
staticpackArray(array:Cartesian2[],result?:number[] |TypedArray):number[] |TypedArray
Flattens an array of Cartesian2s into an array of components.
参数
array
Cartesian2[]
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 * 2 components, else a DeveloperError will be thrown. If it is a regular array, it will be resized to have (array.length * 2) elements.
number[] | TypedArray
返回
number[] | TypedArray
The packed array.
unpackArray()
staticunpackArray(array:number[],result?:Cartesian2[]):Cartesian2[]
Unpacks an array of cartesian components into an array of Cartesian2s.
参数
array
number[]
The array of components to unpack.
result?
Cartesian2[]
The array onto which to store the result.
返回
Cartesian2[]
The unpacked array.
maximumComponent()
staticmaximumComponent(cartesian:Cartesian2):number
Computes the value of the maximum component for the supplied Cartesian.
参数
cartesian
Cartesian2
The cartesian to use.
返回
number
The value of the maximum component.
minimumComponent()
staticminimumComponent(cartesian:Cartesian2):number
Computes the value of the minimum component for the supplied Cartesian.
参数
cartesian
Cartesian2
The cartesian to use.
返回
number
The value of the minimum component.
minimumByComponent()
staticminimumByComponent(first:Cartesian2,second:Cartesian2,result:Cartesian2):Cartesian2
Compares two Cartesians and computes a Cartesian which contains the minimum components of the supplied Cartesians.
参数
first
Cartesian2
A cartesian to compare.
second
Cartesian2
A cartesian to compare.
result
Cartesian2
The object into which to store the result.
返回
Cartesian2
A cartesian with the minimum components.
maximumByComponent()
staticmaximumByComponent(first:Cartesian2,second:Cartesian2,result:Cartesian2):Cartesian2
Compares two Cartesians and computes a Cartesian which contains the maximum components of the supplied Cartesians.
参数
first
Cartesian2
A cartesian to compare.
second
Cartesian2
A cartesian to compare.
result
Cartesian2
The object into which to store the result.
返回
Cartesian2
A cartesian with the maximum components.
clamp()
staticclamp(value:Cartesian2,min:Cartesian2,max:Cartesian2,result:Cartesian2):Cartesian2
Constrain a value to lie between two values.
参数
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.
返回
Cartesian2
The clamped value such that min <= result <= max.
magnitudeSquared()
staticmagnitudeSquared(cartesian:Cartesian2):number
Computes the provided Cartesian's squared magnitude.
参数
cartesian
Cartesian2
The Cartesian instance whose squared magnitude is to be computed.
返回
number
The squared magnitude.
magnitude()
staticmagnitude(cartesian:Cartesian2):number
Computes the Cartesian's magnitude (length).
参数
cartesian
Cartesian2
The Cartesian instance whose magnitude is to be computed.
返回
number
The magnitude.
distance()
staticdistance(left:Cartesian2,right:Cartesian2):number
Computes the distance between two points.
参数
left
Cartesian2
The first point to compute the distance from.
right
Cartesian2
The second point to compute the distance to.
返回
number
The distance between two points.
示例
ts
// Returns 1.0
const d = Cesium.Cartesian2.distance(new Cesium.Cartesian2(1.0, 0.0), new Cesium.Cartesian2(2.0, 0.0));distanceSquared()
staticdistanceSquared(left:Cartesian2,right:Cartesian2):number
Computes the squared distance between two points. Comparing squared distances using this function is more efficient than comparing distances using Cartesian2#distance.
参数
left
Cartesian2
The first point to compute the distance from.
right
Cartesian2
The second point to compute the distance to.
返回
number
The distance between two points.
示例
ts
// Returns 4.0, not 2.0
const d = Cesium.Cartesian2.distance(new Cesium.Cartesian2(1.0, 0.0), new Cesium.Cartesian2(3.0, 0.0));normalize()
staticnormalize(cartesian:Cartesian2,result:Cartesian2):Cartesian2
Computes the normalized form of the supplied Cartesian.
参数
cartesian
Cartesian2
The Cartesian to be normalized.
result
Cartesian2
The object onto which to store the result.
返回
Cartesian2
The modified result parameter.
dot()
staticdot(left:Cartesian2,right:Cartesian2):number
Computes the dot (scalar) product of two Cartesians.
参数
left
Cartesian2
The first Cartesian.
right
Cartesian2
The second Cartesian.
返回
number
The dot product.
cross()
staticcross(left:Cartesian2,right:Cartesian2):number
Computes the magnitude of the cross product that would result from implicitly setting the Z coordinate of the input vectors to 0
参数
left
Cartesian2
The first Cartesian.
right
Cartesian2
The second Cartesian.
返回
number
The cross product.
multiplyComponents()
staticmultiplyComponents(left:Cartesian2,right:Cartesian2,result:Cartesian2):Cartesian2
Computes the componentwise product of two Cartesians.
参数
left
Cartesian2
The first Cartesian.
right
Cartesian2
The second Cartesian.
result
Cartesian2
The object onto which to store the result.
返回
Cartesian2
The modified result parameter.
divideComponents()
staticdivideComponents(left:Cartesian2,right:Cartesian2,result:Cartesian2):Cartesian2
Computes the componentwise quotient of two Cartesians.
参数
left
Cartesian2
The first Cartesian.
right
Cartesian2
The second Cartesian.
result
Cartesian2
The object onto which to store the result.
返回
Cartesian2
The modified result parameter.
add()
staticadd(left:Cartesian2,right:Cartesian2,result:Cartesian2):Cartesian2
Computes the componentwise sum of two Cartesians.
参数
left
Cartesian2
The first Cartesian.
right
Cartesian2
The second Cartesian.
result
Cartesian2
The object onto which to store the result.
返回
Cartesian2
The modified result parameter.
subtract()
staticsubtract(left:Cartesian2,right:Cartesian2,result:Cartesian2):Cartesian2
Computes the componentwise difference of two Cartesians.
参数
left
Cartesian2
The first Cartesian.
right
Cartesian2
The second Cartesian.
result
Cartesian2
The object onto which to store the result.
返回
Cartesian2
The modified result parameter.
multiplyByScalar()
staticmultiplyByScalar(cartesian:Cartesian2,scalar:number,result:Cartesian2):Cartesian2
Multiplies the provided Cartesian componentwise by the provided scalar.
参数
cartesian
Cartesian2
The Cartesian to be scaled.
scalar
number
The scalar to multiply with.
result
Cartesian2
The object onto which to store the result.
返回
Cartesian2
The modified result parameter.
divideByScalar()
staticdivideByScalar(cartesian:Cartesian2,scalar:number,result:Cartesian2):Cartesian2
Divides the provided Cartesian componentwise by the provided scalar.
参数
cartesian
Cartesian2
The Cartesian to be divided.
scalar
number
The scalar to divide by.
result
Cartesian2
The object onto which to store the result.
返回
Cartesian2
The modified result parameter.
negate()
staticnegate(cartesian:Cartesian2,result:Cartesian2):Cartesian2
Negates the provided Cartesian.
参数
cartesian
Cartesian2
The Cartesian to be negated.
result
Cartesian2
The object onto which to store the result.
返回
Cartesian2
The modified result parameter.
abs()
staticabs(cartesian:Cartesian2,result:Cartesian2):Cartesian2
Computes the absolute value of the provided Cartesian.
参数
cartesian
Cartesian2
The Cartesian whose absolute value is to be computed.
result
Cartesian2
The object onto which to store the result.
返回
Cartesian2
The modified result parameter.
lerp()
staticlerp(start:Cartesian2,end:Cartesian2,t:number,result:Cartesian2):Cartesian2
Computes the linear interpolation or extrapolation at t using the provided cartesians.
参数
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.
返回
Cartesian2
The modified result parameter.
angleBetween()
staticangleBetween(left:Cartesian2,right:Cartesian2):number
Returns the angle, in radians, between the provided Cartesians.
参数
left
Cartesian2
The first Cartesian.
right
Cartesian2
The second Cartesian.
返回
number
The angle between the Cartesians.
mostOrthogonalAxis()
staticmostOrthogonalAxis(cartesian:Cartesian2,result:Cartesian2):Cartesian2
Returns the axis that is most orthogonal to the provided Cartesian.
参数
cartesian
Cartesian2
The Cartesian on which to find the most orthogonal axis.
result
Cartesian2
The object onto which to store the result.
返回
Cartesian2
The most orthogonal axis.
equals()
staticequals(left?:Cartesian2,right?:Cartesian2):boolean
Compares the provided Cartesians componentwise and returns <code>true</code> if they are equal, <code>false</code> otherwise.
参数
left?
Cartesian2
The first Cartesian.
right?
Cartesian2
The second Cartesian.
返回
boolean
true if left and right are equal, false otherwise.
equalsEpsilon()
staticequalsEpsilon(left?:Cartesian2,right?:Cartesian2,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?
Cartesian2
The first Cartesian.
right?
Cartesian2
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.
fromCartesian3()
staticfromCartesian3(cartesian:Cartesian3,result?:Cartesian2):Cartesian2
Creates a Cartesian2 instance from an existing Cartesian3. This simply takes the x and y properties of the Cartesian3 and drops z.
参数
cartesian
The Cartesian3 instance to create a Cartesian2 instance from.
result?
Cartesian2
The object onto which to store the result.
返回
Cartesian2
The modified result parameter or a new Cartesian2 instance if one was not provided.
fromCartesian4()
staticfromCartesian4(cartesian:Cartesian4,result?:Cartesian2):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.
参数
cartesian
The Cartesian4 instance to create a Cartesian2 instance from.
result?
Cartesian2
The object onto which to store the result.
返回
Cartesian2
The modified result parameter or a new Cartesian2 instance if one was not provided.
fromArray()
staticfromArray(array:number[],startingIndex?:number,result?:Cartesian2):Cartesian2
Creates a Cartesian2 from two consecutive elements in an array.
参数
array
number[]
The array whose two consecutive elements correspond to the x and y components, respectively.
startingIndex?
number
The offset into the array of the first element, which corresponds to the x component.
result?
Cartesian2
The object onto which to store the result.
返回
Cartesian2
The modified result parameter or a new Cartesian2 instance if one was not provided.
示例
ts
// Create a Cartesian2 with (1.0, 2.0)
const v = [1.0, 2.0];
const p = Cesium.Cartesian2.fromArray(v);
// Create a Cartesian2 with (1.0, 2.0) using an offset into an array
const v2 = [0.0, 0.0, 1.0, 2.0];
const p2 = Cesium.Cartesian2.fromArray(v2, 2);clone()
clone(
result?:Cartesian2):Cartesian2
Duplicates this Cartesian2 instance.
参数
result?
Cartesian2
The object onto which to store the result.
返回
Cartesian2
The modified result parameter or a new Cartesian2 instance if one was not provided.
equals()
equals(
right?:Cartesian2):boolean
Compares this Cartesian against the provided Cartesian componentwise and returns <code>true</code> if they are equal, <code>false</code> otherwise.
参数
right?
Cartesian2
The right hand side Cartesian.
返回
boolean
true if they are equal, false otherwise.
equalsEpsilon()
equalsEpsilon(
right?:Cartesian2,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?
Cartesian2
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)'.
返回
string
A string representing the provided Cartesian in the format '(x, y)'.
构造函数
构造函数
new Cartesian2(
x?:number,y?:number):Cartesian2
参数
x?
number
y?
number
返回
Cartesian2
