Hide menu
Loading...
Searching...
No Matches
XY

Implements 2D point interface and operations.

Implements

Constructors

new XY()

new XY(x?, y?): XY

Parameters

x?

number

X coordinate of 2D point.

y?

number

Y coordinate of 2D point.

Returns

XY

Accessors

x

Get Signature

get x(): number

Returns x coordinate of 2D point.

Returns

number

Set Signature

set x(x): void

Sets x coordinate of 2D point.

Parameters

x

number

X coordinate.

Returns

void

X coordinate of 2D point.

Implementation of

BaseXY.x


y

Get Signature

get y(): number

Returns y coordinate of 2D point.

Returns

number

Set Signature

set y(y): void

Sets y coordinate of 2D point.

Parameters

y

number

Y coordinate.

Returns

void

Y coordinate of 2D point.

Implementation of

BaseXY.y

Methods

add()

add(other): this

Adds other point coordinates to this point coordinates.

Parameters

other

XY

Other point.

Returns

this


added()

added(other): XY

Returns new XY object with coordinates received by performing a add() operation to this object.

Parameters

other

XY

Other point.

Returns

XY


angle()

angle(other): number

Returns angle between this and other points.

Parameters

other

XY

Other point.

Returns

number


clone()

clone(): XY

Creates new XY point with coordinates same as this.

Returns

XY


copy()

copy(other): this

Copies the coordinates of the other point to this.

Parameters

other

XY

Copied object.

Returns

this


crossed()

crossed(other): number

Returns cross product of this and other points.

Parameters

other

XY

Other point.

Returns

number


divide()

divide(scalar): this

Divide this point coordinates by scalar value.

Parameters

scalar

number

Scalar value.

Returns

this


divided()

divided(scalar): XY

Returns new XY object with coordinates received by performing a divide() operation to this object.

Parameters

scalar

number

Scalar value.

Returns

XY


dot()

dot(other): number

Returns dot product of this and other points.

Parameters

other

XY

Other point.

Returns

number


get()

get(index): number

Returns coordinate value of 2D point:

  • X coordinate if index equals 0
  • Y coordinate if index equals 1

Throws exception if index is not in range [0, 1].

Parameters

index

number

Coordinate index.

Returns

number


isEqual()

isEqual(other, tolerance): boolean

Returns true if other point coordinates are equal to this point coordinated within provided tolerance (1e-7 by default). Returns false otherwise.

Parameters

other

XY

Other 2D point.

tolerance

number = XY.coincidenceTolerance

Coordinates comparison tolerance;

Returns

boolean


isNormal()

isNormal(other, tolerance): boolean

Returns true if other point is perpendicular to this within provided tolerance (1e-7 by default).

Parameters

other

XY

Other point.

tolerance

number = XY.angularTolerance

Returns

boolean


isOpposite()

isOpposite(other, tolerance): boolean

Returns true if other point is opposite to this within provided tolerance (1e-7 by default).

Parameters

other

XY

Other point.

tolerance

number = XY.angularTolerance

Returns

boolean


isParallel()

isParallel(other, tolerance): boolean

Returns true if other point is parallel to this within provided tolerance (1e-7 by default).

Parameters

other

XY

Other point.

tolerance

number = XY.angularTolerance

Returns

boolean


modulus()

modulus(): number

Returns modulus of this point.

Returns

number


multiplied()

Call Signature

multiplied(other): XY

Returns new XY object with coordinates received by performing a multiply() operation to this object.

Parameters

other

XY

Other point.

Returns

XY

Call Signature

multiplied(scalar): XY

Returns new XY object with coordinates received by performing a multiply() operation to this object.

Parameters

scalar

number

Scalar value.

Returns

XY

Call Signature

multiplied(matrix): XY

Returns new XY object with coordinates received by performing a multiply() operation to this object.

Parameters

matrix

Matrix2d

2D matrix.

Returns

XY


multiply()

Call Signature

multiply(other): this

Multiplies this point coordinates with other point coordinates.

Parameters

other

XY

Other point.

Returns

this

Call Signature

multiply(matrix): this

Multiplies this point coordinates with 2D matrix.

Parameters

matrix

Matrix2d

2D matrix.

Returns

this

Call Signature

multiply(scalar): this

Multiplies this point coordinates with scalar value.

Parameters

scalar

number

Scalar value.

Returns

this


normalize()

normalize(): this

Normalizes coordinates of this point.

Returns

this


normalized()

normalized(): XY

Returns new XY object with normalized coordinates of this point.

Returns

XY


reverse()

reverse(): this

Reverses coordinates of this point.

Returns

this


reversed()

reversed(): XY

Returns new XY object with coordinates received by performing a reverse() operation to this object.

Returns

XY


set()

set(index, value): this

Sets coordinate value of 2D point:

  • X coordinate if index equals 0
  • Y coordinate if index equals 1

Throws exception if index is not in range [0, 1].

Parameters

index

number

Coordinate index.

value

number

Coordinate value.

Returns

this


setCoord()

setCoord(x?, y?): this

Sets x and y coordinates of this object.

Parameters

x?

number

X coordinate of 2D point.

y?

number

Y coordinate of 2D point.

Returns

this


setX()

setX(x): this

Sets x coordinate of 2D point.

Parameters

x

number

X coordinate.

Returns

this


setY()

setY(y): this

Sets y coordinate of 2D point.

Parameters

y

number

Y coordinate.

Returns

this


subtract()

subtract(other): this

Subtracts other point coordinates from this point coordinates.

Parameters

other

XY

Other point.

Returns

this


subtracted()

subtracted(other): XY

Returns new XY object with coordinates received by performing a subtract() operation to this object.

Parameters

other

XY

Other point.

Returns

XY


toJSON()

toJSON(): BaseXY

Returns JSON representation of this point.

Returns

BaseXY


toString()

toString(precision): string

Returns string representation of this point with provided precision (3 by default).

Parameters

precision

number = 3

Precision.

Returns

string


fromXY()

static fromXY(xy): XY

Creates new XY object from object implementing BaseXY interface.

Parameters

xy

BaseXY

Object implementing BaseXY interface.

Returns

XY