new Point(x, y) [source]
var point = new Point(1000, 1000);
var point = new Point([1000,1000]);
var point = new Point({x:1000, y:1000});
Parameter | Type | Description |
---|---|---|
x
|
Number | x value |
y
|
Number | y value |
Members
x
Properties:
Name | Type | Description |
---|---|---|
x
|
Number | x value |
- Source:
y
Properties:
Name | Type | Description |
---|---|---|
y
|
Number | y value |
- Source:
Methods
abs() [source]
Return abs value of the point
Returns:
Point: abs pointcopy() [source]
Returns a copy of the point
Returns:
Point: copyround() [source]
Like math.round, rounding the point's xy.
Returns:
Point: rounded pointequals(c2) [source]
Compare with another point to see whether they are equal.
Parameter | Type | Description |
---|---|---|
c2
|
Point | point to compare |
Returns:
Boolean:distanceTo(point) [source]
Returns the distance between the current and the given point.
Parameter | Type | Description |
---|---|---|
point
|
Point | another point |
Returns:
Number: distanceadd(point) [source]
Returns the result of addition of another point.
Parameter | Type | Description |
---|---|---|
point
|
Point | point to add |
Returns:
Point: resultsubstract(point) [source]
Returns the result of subtraction of another point.
Parameter | Type | Description |
---|---|---|
point
|
Point | point to substract |
Returns:
Point: resultmulti(n) [source]
Returns the result of multiplication of the current point by the given number.
Parameter | Type | Description |
---|---|---|
n
|
Number | number to multi |
Returns:
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:
Point: result_isNaN() [source]
Whether the point is NaN
Returns:
Boolean:toArray() [source]
Convert the point to a number array [x, y]
Returns:
Array.<Number>: number arraytoJSON() [source]
Convert the point to a json object {x : .., y : ..}
Returns:
Object: jsonmag() [source]
Return the magitude of this point: this is the Euclidean
distance from the 0, 0 coordinate to this point's x and y
coordinates.
Returns:
Number: magnitudeunit() [source]
Calculate this point but as a unit vector from 0, 0, meaning
that the distance from the resulting point to the 0, 0
coordinate will be equal to 1 and the angle from the resulting
point to the 0, 0 coordinate will be the same as before.
Returns:
Point: unit vector pointperp() [source]
Compute a perpendicular point, where the new y coordinate
is the old x coordinate and the new x coordinate is the old y
coordinate multiplied by -1