Class: Cartesian2

Cartesian2

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:

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
result Cartesian2 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
right Cartesian2 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
right Cartesian2 optional

Cartesian on the right.

relativeEpsilon Number

Relative epsilon tolerance for equality testing.

absoluteEpsilon Number 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
cartesian Cartesian2

To calculate the Cartesian coordinates of its absolute value.

result Cartesian2

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
left Cartesian2

The first Cartesian.

right Cartesian2

The second Cartesian.

result Cartesian2

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
left Cartesian2

The first Cartesian.

right Cartesian2

The second Cartesian.

Returns:
Type Description
Number The perspective between Cartesians.

static clone(cartesian, result){Cartesian2}

Copy Cartesian2 instance.

Name Type Description
cartesian Cartesian2

The Cartesian coordinates to be copied.

result Cartesian2 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
left Cartesian2

Calculate the first point of distance.

right Cartesian2

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
left Cartesian2

Calculate the first point of distance.

right Cartesian2

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
cartesian Cartesian2

Cartesian is divided.

scalar Number

The scalar to be divided by.

result Cartesian2

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
left Cartesian2

The first Cartesian.

right Cartesian2

The second Cartesian.

result Cartesian2

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
left Cartesian2

The first Cartesian.

right Cartesian2

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
left Cartesian2 optional

The first Cartesian

right Cartesian2 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
left Cartesian2 optional

The first Cartesian

right Cartesian2 optional

The second Cartesian

relativeEpsilon Number

Relative epsilon tolerance for equality testing.

absoluteEpsilon Number 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
array Array.<Number>

Its two consecutive elements correspond to arrays of x and y components, respectively.

startingIndex Number 0 optional

The offset of the first element in the array, corresponding to the x-component

result Cartesian2 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
cartesian Cartesian3

To create a Cartesian3 instance from it.

result Cartesian2 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
cartesian Cartesian4

To create a Cartesian4 instance from it.

result Cartesian2 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
x Number

The x-coordinate.

y Number

Y-coordinate.

result Cartesian2 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
start Cartesian2

At 0.0, it corresponds to the value of t.

end Cartesian2

At 1.0, it corresponds to the value of t.

t Number

The point interpolated along t.

result Cartesian2

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
cartesian Cartesian2

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
cartesian Cartesian2

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
first Cartesian2

Compare the first cartoon.

second Cartesian2

Compare the second cartoon.

result Cartesian2

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
cartesian Cartesian2

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
first Cartesian2

Compare the first cartoon.

second Cartesian2

Compare the second cartoon.

result Cartesian2

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
cartesian Cartesian2

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
cartesian Cartesian2

Find the Cartesian coordinates of the most orthogonal axis.

result Cartesian2

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
cartesian Cartesian2

Cartesian coordinates to be scaled.

scalar Number

The scalar to be multiplied with.

result Cartesian2

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
left Cartesian2

The first Cartesian.

right Cartesian2

The second Cartesian.

result Cartesian2

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
cartesian Cartesian2

Cartesian who needs to be denied.

result Cartesian2

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
cartesian Cartesian2

To standardize Cartesian coordinates.

result Cartesian2

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
value Cartesian2

The value to be packaged.

array Array.<Number>

The array to be packaged.

startingIndex Number 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
array Array.<Cartesian2>

The Cartesians array to be packaged.

result Array.<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
left Cartesian2

The first Cartesian.

right Cartesian2

The second Cartesian.

result Cartesian2

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
array Array.<Number>

Packaged array.

startingIndex Number 0 optional

The starting index of the element to be unpacked.

result Cartesian2 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
array Array.<Number>

The component array to be unpacked.

result Array.<Cartesian2>

An array for storing results.

Returns:
Type Description
Array.<Cartesian2> The decompressed array.