new Cartesian2
A 2D Cartesian point.
Parameters:
Name | Type | Argument | Default | Description |
---|---|---|---|---|
x |
Number |
<optional> |
0.0 | The X component. |
y |
Number |
<optional> |
0.0 | The Y component. |
See:
Source:
Members
-
x :Number
-
The Y component.
- Default Value:
- 0.0
-
y :Number
-
The X component.
- Default Value:
- 0.0
-
<static> UNIT_X
-
An immutable Cartesian2 instance initialized to (1.0, 0.0).
-
<static> UNIT_Y
-
An immutable Cartesian2 instance initialized to (0.0, 1.0).
-
<static> ZERO
-
An immutable Cartesian2 instance initialized to (0.0, 0.0).
Methods
-
abs
-
Computes the absolute value of this Cartesian.
Parameters:
Name Type Argument Description result
Cartesian2 <optional>
The object onto which to store the result. Returns:
Cartesian2 The modified result parameter or a new Cartesian2 instance if one was not provided. -
add
-
Computes the componentwise sum of this Cartesian and the provided Cartesian.
Parameters:
Name Type Argument Description right
Cartesian2 The right hand side Cartesian. result
Cartesian2 <optional>
The object onto which to store the result. Throws:
DeveloperError : right is required.Returns:
Cartesian2 The modified result parameter or a new Cartesian2 instance if one was not provided. -
angleBetween
-
Returns the angle, in radians, between this Cartesian and the provided Cartesian.
Parameters:
Name Type Description right
Cartesian2 The right hand side Cartesian. Throws:
-
DeveloperError : left is required.
-
DeveloperError : right is required.
Returns:
Number The angle between the Cartesians. -
-
clone
-
Duplicates this Cartesian2 instance.
Parameters:
Name Type Argument Description result
Cartesian2 <optional>
The object onto which to store the result. Returns:
Cartesian2 The modified result parameter or a new Cartesian2 instance if one was not provided. -
divideByScalar
-
Divides this Cartesian componentwise by the provided scalar.
Parameters:
Name Type Argument Description scalar
Number The scalar to divide by. result
Cartesian2 <optional>
The object onto which to store the result. Throws:
DeveloperError : scalar is required and must be a number.Returns:
Cartesian2 The modified result parameter or a new Cartesian2 instance if one was not provided. -
dot
-
Computes the dot (scalar) product of this Cartesian and a supplied cartesian.
Parameters:
Name Type Description right
Cartesian2 The right hand side Cartesian. Throws:
DeveloperError : right is required.Returns:
Number The dot product. -
equals
-
Compares this Cartesian against the provided Cartesian componentwise and returns
true
if they are equal,false
otherwise.Parameters:
Name Type Argument Description right
Cartesian2 <optional>
The right hand side Cartesian. Returns:
Booleantrue
if they are equal,false
otherwise. -
equalsEpsilon
-
Compares this Cartesian against the provided Cartesian componentwise and returns
true
if they are within the provided epsilon,false
otherwise.Parameters:
Name Type Argument Description right
Cartesian2 <optional>
The right hand side Cartesian. epsilon
Number The epsilon to use for equality testing. Throws:
DeveloperError : epsilon is required and must be a number.Returns:
Booleantrue
if they are within the provided epsilon,false
otherwise. -
getMaximumComponent
-
Computes the value of the maximum component for this Cartesian.
Returns:
Number The value of the maximum component. -
getMinimumComponent
-
Computes the value of the minimum component for this Cartesian.
Returns:
Number The value of the minimum component. -
lerp
-
Computes the linear interpolation or extrapolation at t using this Cartesian and the provided cartesian. This cartesian is assumed to be t at 0.0.
Parameters:
Name Type Argument Description end
The value corresponding to t at 1.0. t
The point along t at which to interpolate. result
Cartesian2 <optional>
The object onto which to store the result. Throws:
-
DeveloperError : end is required.
-
DeveloperError : t is required and must be a number.
Returns:
Cartesian2 The modified result parameter or a new Cartesian2 instance if one was not provided. -
-
magnitude
-
Computes this Cartesian's magnitude (length).
Returns:
Number The magnitude. -
magnitudeSquared
-
Computes this Cartesian's squared magnitude.
Returns:
Number The squared magnitude. -
mostOrthogonalAxis
-
Returns the axis that is most orthogonal to the this Cartesian.
Parameters:
Name Type Argument Description result
Cartesian2 <optional>
The object onto which to store the result. Returns:
Cartesian2 The most orthogonal axis. -
multiplyByScalar
-
Multiplies this Cartesian componentwise by the provided scalar.
Parameters:
Name Type Argument Description scalar
Number The scalar to multiply with. result
Cartesian2 <optional>
The object onto which to store the result. Throws:
DeveloperError : scalar is required and must be a number.Returns:
Cartesian2 The modified result parameter or a new Cartesian2 instance if one was not provided. -
multiplyComponents
-
Computes the componentwise product of this Cartesian and the provided Cartesian.
Parameters:
Name Type Argument Description right
Cartesian2 The right hand side Cartesian. result
Cartesian2 <optional>
The object onto which to store the result. Throws:
DeveloperError : right is required.Returns:
Cartesian2 The modified result parameter or a new Cartesian2 instance if one was not provided. -
negate
-
Negates this Cartesian.
Parameters:
Name Type Argument Description result
Cartesian2 <optional>
The object onto which to store the result. Returns:
Cartesian2 The modified result parameter or a new Cartesian2 instance if one was not provided. -
normalize
-
Computes the normalized form of this Cartesian.
Parameters:
Name Type Argument Description result
Cartesian2 <optional>
The object onto which to store the result. Returns:
Cartesian2 The modified result parameter or a new Cartesian2 instance if one was not provided. -
subtract
-
Computes the componentwise difference of this Cartesian and the provided Cartesian.
Parameters:
Name Type Argument Description right
Cartesian2 The right hand side Cartesian. result
Cartesian2 <optional>
The object onto which to store the result. Throws:
DeveloperError : right is required.Returns:
Cartesian2 The modified result parameter or a new Cartesian2 instance if one was not provided. -
toString
-
Creates a string representing this Cartesian in the format '(x, y)'.
Returns:
String A string representing the provided Cartesian in the format '(x, y)'. -
<static> abs
-
Computes the absolute value of the provided Cartesian.
Parameters:
Name Type Argument Description cartesian
Cartesian2 The Cartesian whose absolute value is to be computed. result
Cartesian2 <optional>
The object onto which to store the result. Throws:
DeveloperError : cartesian is required.Returns:
Cartesian2 The modified result parameter or a new Cartesian2 instance if one was not provided. -
<static> add
-
Computes the componentwise sum of two Cartesians.
Parameters:
Name Type Argument Description left
Cartesian2 The first Cartesian. right
Cartesian2 The second Cartesian. result
Cartesian2 <optional>
The object onto which to store the result. Throws:
-
DeveloperError : left is required.
-
DeveloperError : right is required.
Returns:
Cartesian2 The modified result parameter or a new Cartesian2 instance if one was not provided. -
-
<static> angleBetween
-
Returns the angle, in radians, between the provided Cartesians.
Parameters:
Name Type Description left
Cartesian2 The first Cartesian. right
Cartesian2 The second Cartesian. Throws:
-
DeveloperError : left is required.
-
DeveloperError : right is required.
Returns:
Number The angle between the Cartesians. -
-
<static> clone
-
Duplicates a Cartesian2 instance.
Parameters:
Name Type Argument Description cartesian
Cartesian2 The Cartesian to duplicate. result
Cartesian2 <optional>
The object onto which to store the result. Returns:
Cartesian2 The modified result parameter or a new Cartesian2 instance if one was not provided. (Returns undefined if cartesian is undefined) -
<static> distance
-
Computes the distance between two points
Parameters:
Name Type Description left
Cartesian2 The first point to compute the distance from. right
Cartesian2 The second point to compute the distance to. Throws:
DeveloperError : left and right are required.Returns:
Number The distance between two points.Example
// Returns 1.0 var d = Cartesian2.distance(new Cartesian2(1.0, 0.0), new Cartesian2(2.0, 0.0));
-
<static> divideByScalar
-
Divides the provided Cartesian componentwise by the provided scalar.
Parameters:
Name Type Argument Description cartesian
Cartesian2 The Cartesian to be divided. scalar
Number The scalar to divide by. result
Cartesian2 <optional>
The object onto which to store the result. Throws:
-
DeveloperError : cartesian is required.
-
DeveloperError : scalar is required and must be a number.
Returns:
Cartesian2 The modified result parameter or a new Cartesian2 instance if one was not provided. -
-
<static> dot
-
Computes the dot (scalar) product of two Cartesians.
Parameters:
Name Type Description left
Cartesian2 The first Cartesian. right
Cartesian2 The second Cartesian. Throws:
-
DeveloperError : left is required.
-
DeveloperError : right is required.
Returns:
Number The dot product. -
-
<static> equals
-
Compares the provided Cartesians componentwise and returns
true
if they are equal,false
otherwise.Parameters:
Name Type Argument Description left
Cartesian2 <optional>
The first Cartesian. right
Cartesian2 <optional>
The second Cartesian. Returns:
Booleantrue
if left and right are equal,false
otherwise. -
<static> equalsEpsilon
-
Compares the provided Cartesians componentwise and returns
true
if they are within the provided epsilon,false
otherwise.Parameters:
Name Type Argument Description left
Cartesian2 <optional>
The first Cartesian. right
Cartesian2 <optional>
The second Cartesian. epsilon
Number The epsilon to use for equality testing. Throws:
DeveloperError : epsilon is required and must be a number.Returns:
Booleantrue
if left and right are within the provided epsilon,false
otherwise. -
<static> fromArray
-
Creates a Cartesian2 from two consecutive elements in an array.
Parameters:
Name Type Argument Default Description values
Array The array whose two consecutive elements correspond to the x and y components, respectively. offset
Number <optional>
0 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. Throws:
-
DeveloperError : values is required.
-
DeveloperError : offset + 2 is greater than the length of the array.
Returns:
Cartesian2 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 = 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 = Cartesian2.fromArray(v2, 2);
-
-
<static> fromCartesian3
-
Creates a Cartesian2 instance from an existing Cartesian3. This simply takes the x and y properties of the Cartesian3 and drops z.
Parameters:
Name Type Argument Description cartesian
Cartesian3 The Cartesian3 instance to create a Cartesian2 instance from. result
Cartesian2 <optional>
The object onto which to store the result. Throws:
DeveloperError : cartesian is required.Returns:
Cartesian2 The modified result parameter or a new Cartesian2 instance if one was not provided. -
<static> fromCartesian4
-
Creates a Cartesian2 instance from an existing Cartesian4. This simply takes the x and y properties of the Cartesian4 and drops z and w.
Parameters:
Name Type Argument Description cartesian
Cartesian4 The Cartesian4 instance to create a Cartesian2 instance from. result
Cartesian2 <optional>
The object onto which to store the result. Throws:
DeveloperError : cartesian is required.Returns:
Cartesian2 The modified result parameter or a new Cartesian2 instance if one was not provided. -
<static> fromElements
-
Creates a Cartesian2 instance from x and y coordinates.
Parameters:
Name Type Argument Description x
Number The x coordinate. y
Number The y coordinate. result
Cartesian2 <optional>
The object onto which to store the result. Returns:
Cartesian2 The modified result parameter or a new Cartesian2 instance if one was not provided. -
<static> getMaximumComponent
-
Computes the value of the maximum component for the supplied Cartesian.
Parameters:
Name Type Description The
Cartesian2 cartesian to use. Throws:
DeveloperError : cartesian is required.Returns:
Number The value of the maximum component. -
<static> getMinimumComponent
-
Computes the value of the minimum component for the supplied Cartesian.
Parameters:
Name Type Description The
Cartesian2 cartesian to use. Throws:
DeveloperError : cartesian is required.Returns:
Number The value of the minimum component. -
<static> lerp
-
Computes the linear interpolation or extrapolation at t using the provided cartesians.
Parameters:
Name Type Argument Description start
The value corresponding to t at 0.0. end
The value corresponding to t at 1.0. t
The point along t at which to interpolate. result
Cartesian2 <optional>
The object onto which to store the result. Throws:
-
DeveloperError : start is required.
-
DeveloperError : end is required.
-
DeveloperError : t is required and must be a number.
Returns:
Cartesian2 The modified result parameter or a new Cartesian2 instance if one was not provided. -
-
<static> magnitude
-
Computes the Cartesian's magnitude (length).
Parameters:
Name Type Description cartesian
Cartesian2 The Cartesian instance whose magnitude is to be computed. Throws:
DeveloperError : cartesian is required.Returns:
Number The magnitude. -
<static> magnitudeSquared
-
Computes the provided Cartesian's squared magnitude.
Parameters:
Name Type Description cartesian
Cartesian2 The Cartesian instance whose squared magnitude is to be computed. Throws:
DeveloperError : cartesian is required.Returns:
Number The squared magnitude. -
<static> mostOrthogonalAxis
-
Returns the axis that is most orthogonal to the provided Cartesian.
Parameters:
Name Type Argument Description cartesian
Cartesian2 The Cartesian on which to find the most orthogonal axis. result
Cartesian2 <optional>
The object onto which to store the result. Throws:
DeveloperError : cartesian is required.Returns:
Cartesian2 The most orthogonal axis. -
<static> multiplyByScalar
-
Multiplies the provided Cartesian componentwise by the provided scalar.
Parameters:
Name Type Argument Description cartesian
Cartesian2 The Cartesian to be scaled. scalar
Number The scalar to multiply with. result
Cartesian2 <optional>
The object onto which to store the result. Throws:
-
DeveloperError : cartesian is required.
-
DeveloperError : scalar is required and must be a number.
Returns:
Cartesian2 The modified result parameter or a new Cartesian2 instance if one was not provided. -
-
<static> multiplyComponents
-
Computes the componentwise product of two Cartesians.
Parameters:
Name Type Argument Description left
Cartesian2 The first Cartesian. right
Cartesian2 The second Cartesian. result
Cartesian2 <optional>
The object onto which to store the result. Throws:
-
DeveloperError : left is required.
-
DeveloperError : right is required.
Returns:
Cartesian2 The modified result parameter or a new Cartesian2 instance if one was not provided. -
-
<static> negate
-
Negates the provided Cartesian.
Parameters:
Name Type Argument Description cartesian
Cartesian2 The Cartesian to be negated. result
Cartesian2 <optional>
The object onto which to store the result. Throws:
DeveloperError : cartesian is required.Returns:
Cartesian2 The modified result parameter or a new Cartesian2 instance if one was not provided. -
<static> normalize
-
Computes the normalized form of the supplied Cartesian.
Parameters:
Name Type Argument Description cartesian
Cartesian2 The Cartesian to be normalized. result
Cartesian2 <optional>
The object onto which to store the result. Throws:
DeveloperError : cartesian is required.Returns:
Cartesian2 The modified result parameter or a new Cartesian2 instance if one was not provided. -
<static> subtract
-
Computes the componentwise difference of two Cartesians.
Parameters:
Name Type Argument Description left
Cartesian2 The first Cartesian. right
Cartesian2 The second Cartesian. result
Cartesian2 <optional>
The object onto which to store the result. Throws:
-
DeveloperError : left is required.
-
DeveloperError : right is required.
Returns:
Cartesian2 The modified result parameter or a new Cartesian2 instance if one was not provided. -