Members
x
Properties:
Name | Type | Description |
---|---|---|
x
|
Number | x value |
- Source:
y
Properties:
Name | Type | Description |
---|---|---|
y
|
Number | y value |
- Source:
z
Properties:
Name | Type | Description |
---|---|---|
z
|
Number | z value, it's a pure property and doesn't take part in caculation for now. |
- Source:
Methods
set() [source]
Set point or coordinate's x, y value
Returns:
Coordinate|Point: thisabs() [source]
Return abs value of the point
Returns:
Coordinate|Point: abs pointround() [source]
Like math.round, rounding the point's xy.
Returns:
Coordinate|Point: rounded pointdistanceTo(point) [source]
Returns the distance between the current and the given point.
Parameter | Type | Description |
---|---|---|
point
|
Coordinate | Point | another point |
Returns:
Number: distancemag() [source]
Return the magnitude of this point: this is the Euclidean
distance from the 0, 0 coordinate to this point's x and y
coordinates.
Returns:
Number: magnitudecopy() [source]
Returns a copy of the coordinate
Returns:
Coordinate|Point: copyadd(x, yopt) [source]
Returns the result of addition of another coordinate.
Parameter | Type | Description |
---|---|---|
x
|
Coordinate | Point | Array | Number | coordinate to add |
y
opt
|
Number | optional, coordinate to add |
Returns:
Coordinate|Point: resultsub(x, yopt) [source]
Returns the result of subtraction of another coordinate.
Parameter | Type | Description |
---|---|---|
x
|
Coordinate | Point | Array | Number | coordinate to add |
y
opt
|
Number | optional, coordinate to add |
Returns:
Coordinate|Point: resultsubstract(x, yopt) [source]
Alias for sub
Parameter | Type | Description |
---|---|---|
x
|
Coordinate | Point | Array | Number | coordinate to add |
y
opt
|
Number | optional, coordinate to add |
Returns:
Coordinate|Point: resultmulti(ratio) [source]
Returns the result of multiplication of the current coordinate by the given number.
Parameter | Type | Description |
---|---|---|
ratio
|
Number | ratio to multi |
Returns:
Coordinate|Point: resultdiv(n) [source]
Returns the result of division of the current point by the given number.
Parameter | Type | Description |
---|---|---|
n
|
Number | number to div |
Returns:
Coordinate|Point: resultequals(c) [source]
Compare with another coordinate to see whether they are equal.
Parameter | Type | Description |
---|---|---|
c
|
Coordinate | Point | coordinate to compare |
Returns:
Boolean:isZero() [source]
Whether the coordinate/point is zero
toArray() [source]
Convert to a number array [x, y]
Returns:
Array.<Number>: number arraytoFixed(n) [source]
Formats coordinate number using fixed-point notation.
Parameter | Type | Description |
---|---|---|
n
|
Number | The number of digits to appear after the decimal point |
Returns:
Coordinate: fixed coordinatetoJSON() [source]
Convert to a json object {x : .., y : ..}