new Cartesian2(x, y)
Two dimensional Cartesian coordinate point class
| 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
-
xNumber
-
Part X.
- Default Value: 0.0
yNumber
Part Y.
- Default Value: 0.0
static packedLengthNumber
The number of elements used to package objects into an array.
(static, constant) UNIT_XCartesian2
An immutable Cartesian2 instance initialized to (1.0, 0.0).
(static, constant) UNIT_YCartesian2
An immutable Cartesian2 instance initialized to (0.0, 1.0).
(static, constant) ZEROCartesian2
An immutable Cartesian2 instance initialized to (0.0, 0.0).
Methods
-
clone(result){Cartesian2}
-
Copy this Cartesian2 instance.
Name Type Description resultCartesian2 optional The object that stores the results.
Returns:
Type Description Cartesian2 The modified result parameters or a new Cartesian2 instance (if not provided). -
equals(right){Boolean}
-
Compare this Cartesian component with the provided Cartesian component, return true if they are equal, otherwise return false.
Name Type Description rightCartesian2 optional Cartesian on the right.
Returns:
Type Description Boolean If they are equal, it is true; otherwise, it is false. -
equalsEpsilon(right, relativeEpsilon, absoluteEpsilon){Boolean}
-
Compare this Cartesian component with the provided Cartesian component. If they pass the absolute or relative tolerance test, return true; otherwise, return false.
Name Type Default Description rightCartesian2 optional Cartesian on the right.
relativeEpsilonNumber Relative epsilon tolerance for equality testing.
absoluteEpsilonNumber relativeEpsilon optional Absolute epsilon tolerance for equality testing
Returns:
Type Description Boolean If they are within the provided epsilon, it is true; otherwise, it is false. -
toString(){String}
-
Create a string representing this Cartesian coordinate in the format of '(x, y)'.
Returns:
Type Description String A string representing the provided Cartesian coordinates in the format of '(x, y)'. -
static abs(cartesian, result){Cartesian2}
-
Calculate the absolute value of the Cartesian coordinates provided.
Name Type Description cartesianCartesian2 To calculate the Cartesian coordinates of its absolute value.
resultCartesian2 The object that stores the results.
Returns:
Type Description Cartesian2 The modified result parameters. -
static add(left, right, result){Cartesian2}
-
Calculate the sum of two Cartesian components.
Name Type Description leftCartesian2 The first Cartesian.
rightCartesian2 The second Cartesian.
resultCartesian2 The object that stores the results.
Returns:
Type Description Cartesian2 The modified result parameters. -
static angleBetween(left, right){Number}
-
Return the angle (in radians) between the provided Cartesians.
Name Type Description leftCartesian2 The first Cartesian.
rightCartesian2 The second Cartesian.
Returns:
Type Description Number The perspective between Cartesians. -
static clone(cartesian, result){Cartesian2}
-
Copy Cartesian2 instance.
Name Type Description cartesianCartesian2 The Cartesian coordinates to be copied.
resultCartesian2 optional The object that stores the results.
Returns:
Type Description Cartesian2 The modified result parameters or a new Cartesian2 instance (if not provided). (If Cartesian is undefined, return undefined) -
static distance(left, right){Number}
-
Calculate the distance between two points.
Name Type Description leftCartesian2 Calculate the first point of distance.
rightCartesian2 Calculate the second point of distance.
Returns:
Type Description Number The distance between two points. Example
// Returns 1.0 var d = SuperMap3D.Cartesian2.distance(new SuperMap3D.Cartesian2(1.0, 0.0), new SuperMap3D.Cartesian2(2.0, 0.0)); -
static distanceSquared(left, right){Number}
-
Calculate the square distance between two points. Comparing the squares of distances using this function is more effective than using Cartesian2 # distance.
Name Type Description leftCartesian2 Calculate the first point of distance.
rightCartesian2 Calculate the second point of distance.
Returns:
Type Description Number The distance between two points. Example
// Returns 4.0, not 2.0 var d = SuperMap3D.Cartesian2.distance(new SuperMap3D.Cartesian2(1.0, 0.0), new SuperMap3D.Cartesian2(3.0, 0.0)); -
static divideByScalar(cartesian, scalar, result){Cartesian2}
-
Divide the provided Cartesian component by the provided scalar.
Name Type Description cartesianCartesian2 Cartesian is divided.
scalarNumber The scalar to be divided by.
resultCartesian2 The object that stores the results.
Returns:
Type Description Cartesian2 The modified result parameters. -
static divideComponents(left, right, result){Cartesian2}
-
Calculate the component quotient of two Cartesians.
Name Type Description leftCartesian2 The first Cartesian.
rightCartesian2 The second Cartesian.
resultCartesian2 The object that stores the results.
Returns:
Type Description Cartesian2 The modified result parameters. -
static dot(left, right){Number}
-
Calculate the dot (scalar) product of two Cartesians.
Name Type Description leftCartesian2 The first Cartesian.
rightCartesian2 The second Cartesian.
Returns:
Type Description Number Dot product. -
static equals(left, right){Boolean}
-
Compare the provided Cartesian components, return true if they are equal, otherwise return false.
Name Type Description leftCartesian2 optional The first Cartesian
rightCartesian2 optional The second Cartesian
Returns:
Type Description Boolean If left and right are equal, it is true; otherwise, it is false. -
static equalsEpsilon(left, right, relativeEpsilon, absoluteEpsilon){Boolean}
-
Compare the provided Cartesian components and return true if they pass absolute or relative tolerance tests, otherwise return false.
Name Type Default Description leftCartesian2 optional The first Cartesian
rightCartesian2 optional The second Cartesian
relativeEpsilonNumber Relative epsilon tolerance for equality testing.
absoluteEpsilonNumber relativeEpsilon optional Absolute epsilon tolerance for equality testing.
Returns:
Type Description Boolean Within the provided epsilon, it is true; otherwise, it is false. -
static fromArray(array, startingIndex, result){Cartesian2}
-
Create Cartesian2 from two consecutive elements in an array.
Name Type Default Description arrayArray.<Number> Its two consecutive elements correspond to arrays of x and y components, respectively.
startingIndexNumber 0 optional The offset of the first element in the array, corresponding to the x-component
resultCartesian2 optional The object that stores the results.
Returns:
Type Description Cartesian2 The modified result parameters or a new Cartesian2 instance (if not provided). Example
// Create a Cartesian2 with (1.0, 2.0) var v = [1.0, 2.0]; var p = SuperMap3D.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 = SuperMap3D.Cartesian2.fromArray(v2, 2); -
static fromCartesian3(cartesian, result){Cartesian2}
-
Create a Cartesian2 instance from the existing Cartesian3. This is simply using the x and y properties of Cartesian3 and removing z.
Name Type Description cartesianCartesian3 To create a Cartesian3 instance from it.
resultCartesian2 optional The object that stores the results.
Returns:
Type Description Cartesian2 The modified result parameters or a new Cartesian2 instance (if not provided). -
static fromCartesian4(cartesian, result){Cartesian2}
-
Create a Cartesian2 instance from the existing Cartesian4. This is simply using the x and y properties of Cartesian4 and removing z and w.
Name Type Description cartesianCartesian4 To create a Cartesian4 instance from it.
resultCartesian2 optional The object that stores the results.
Returns:
Type Description Cartesian2 The modified result parameters or a new Cartesian2 instance (if not provided). -
static fromElements(x, y, result){Cartesian2}
-
Create Cartesian2 instances from x and y coordinates.
Name Type Description xNumber The x-coordinate.
yNumber Y-coordinate.
resultCartesian2 optional The object that stores the results.
Returns:
Type Description Cartesian2 The modified result parameters or a new Cartesian2 instance (if not provided). -
static lerp(start, end, t, result){Cartesian2}
-
Use the provided Cartesian algorithm to calculate linear interpolation or extrapolation at point t.
Name Type Description startCartesian2 At 0.0, it corresponds to the value of t.
endCartesian2 At 1.0, it corresponds to the value of t.
tNumber The point interpolated along t.
resultCartesian2 The object that stores the results.
Returns:
Type Description Cartesian2 The modified result parameters. -
static magnitude(cartesian){Number}
-
Calculate the size (length) of Cartesian.
Name Type Description cartesianCartesian2 To calculate the size of a Cartesian instance.
Returns:
Type Description Number range. -
static magnitudeSquared(cartesian){Number}
-
Calculate the square magnitude of the given Cartesian coordinates.
Name Type Description cartesianCartesian2 To calculate the Cartesian instance of its square magnitude.
Returns:
Type Description Number Square amplitude. -
static maximumByComponent(first, second, result){Cartesian2}
-
Compare two Cartesians and calculate the Cartesian that contains the maximum component of the provided Cartesian.
Name Type Description firstCartesian2 Compare the first cartoon.
secondCartesian2 Compare the second cartoon.
resultCartesian2 The object that stores the results.
Returns:
Type Description Cartesian2 The Cartesian curve with the maximum component. -
static maximumComponent(cartesian){Number}
-
Calculate the value of the maximum component of the Cartesian coordinates provided.
Name Type Description cartesianCartesian2 The Cartesian to be used.
Returns:
Type Description Number The value of the maximum component. -
static minimumByComponent(first, second, result){Cartesian2}
-
Compare two Cartesians and calculate the Cartesian that contains the minimum component of the provided Cartesian.
Name Type Description firstCartesian2 Compare the first cartoon.
secondCartesian2 Compare the second cartoon.
resultCartesian2 The object that stores the results.
Returns:
Type Description Cartesian2 The Cartesian curve with the smallest component. -
static minimumComponent(cartesian){Number}
-
Calculate the value of the minimum component of the Cartesian coordinates provided.
Name Type Description cartesianCartesian2 The Cartesian to be used.
Returns:
Type Description Number The value of the minimum component. -
static mostOrthogonalAxis(cartesian, result){Cartesian2}
-
Return the axis that is most orthogonal to the provided Cartesian coordinates.
Name Type Description cartesianCartesian2 Find the Cartesian coordinates of the most orthogonal axis.
resultCartesian2 The object that stores the results.
Returns:
Type Description Cartesian2 The most orthogonal axis. -
static multiplyByScalar(cartesian, scalar, result){Cartesian2}
-
Multiply the provided Cartesian component by the provided scalar.
Name Type Description cartesianCartesian2 Cartesian coordinates to be scaled.
scalarNumber The scalar to be multiplied with.
resultCartesian2 The object that stores the results.
Returns:
Type Description Cartesian2 The modified result parameters. -
static multiplyComponents(left, right, result){Cartesian2}
-
Calculate the product of two Cartesian components.
Name Type Description leftCartesian2 The first Cartesian.
rightCartesian2 The second Cartesian.
resultCartesian2 The object that stores the results.
Returns:
Type Description Cartesian2 The modified result parameters. -
static negate(cartesian, result){Cartesian2}
-
Deny the Cartesian provided.
Name Type Description cartesianCartesian2 Cartesian who needs to be denied.
resultCartesian2 The object that stores the results.
Returns:
Type Description Cartesian2 The modified result parameters. -
static normalize(cartesian, result){Cartesian2}
-
Calculate the normalized form of the Cartesian coordinates provided.
Name Type Description cartesianCartesian2 To standardize Cartesian coordinates.
resultCartesian2 The object that stores the results.
Returns:
Type Description Cartesian2 The modified result parameters. -
static pack(value, array, startingIndex){Array.<Number>}
-
Store the provided instance in the provided array.
Name Type Default Description valueCartesian2 The value to be packaged.
arrayArray.<Number> The array to be packaged.
startingIndexNumber 0 optional Start packaging the array index of elements.
Returns:
Type Description Array.<Number> The loaded array. -
static packArray(array, result){Array.<Number>}
-
Flatten the Cartesian2 array into a component array.
Name Type Description arrayArray.<Cartesian2> The Cartesians array to be packaged.
resultArray.<Number> An array for storing results.
Returns:
Type Description Array.<Number> Package the array. -
static subtract(left, right, result){Cartesian2}
-
Calculate the component difference between two Cartesians.
Name Type Description leftCartesian2 The first Cartesian.
rightCartesian2 The second Cartesian.
resultCartesian2 The object that stores the results.
Returns:
Type Description Cartesian2 The modified result parameters. -
static unpack(array, startingIndex, result){Cartesian2}
-
Retrieve instances from the packaged array.
Name Type Default Description arrayArray.<Number> Packaged array.
startingIndexNumber 0 optional The starting index of the element to be unpacked.
resultCartesian2 optional The object that stores the results.
Returns:
Type Description Cartesian2 The modified result parameters or a new Cartesian2 instance (if not provided). -
static unpackArray(array, result){Array.<Cartesian2>}
-
Decompress a set of Cartesian components into a set of Cartesian 2s.
Name Type Description arrayArray.<Number> The component array to be unpacked.
resultArray.<Cartesian2> An array for storing results.
Returns:
Type Description Array.<Cartesian2> The decompressed array.