-
add(vec)
-
Adds two vectors together.
Parameters:
Returns:
The combined vector representing a new direction
-
Type
-
Core.Math.Point
-
angle(vec [, inRadians])
-
Gets the angle between this point and another relative to the origin.
Parameters:
Name |
Type |
Argument |
Default |
Description |
vec |
Core.Math.Point
|
|
|
The other point |
inRadians |
boolean
|
<optional>
|
false
|
Whether the result should be in radians. Default: false |
Returns:
The angle between these two points. Returns radians if inRadians is true
-
Type
-
number
-
clone()
-
Clones this point.
Returns:
Returns a new instance of the same point.
-
cross(vec)
-
Gets the cross product of this vector and another. This operation is non-commutative.
Parameters:
Returns:
A cross product object with X, Y, Z properties
-
Type
-
any
-
distance(vec)
-
Gets the distance between this point and another.
Parameters:
Returns:
The distance between these two points
-
Type
-
number
-
dot(vec)
-
Gets the dot product of this vector and another. This operation is commutative.
Parameters:
Returns:
The dot product
-
Type
-
number
-
equals(vec)
-
Compares this point to another. Points are considered the same if they are within 0.00001 units of each other.
Parameters:
Returns:
Returns true if points are 0.00001 units of each other. Otherwise false.
-
equalTo(vec)
-
Compares this point to another. Evaluates the same way as
equals.
Parameters:
Name |
Type |
Description |
vec |
|
The other point |
Returns:
Returns true if points are 0.00001 units of each other. Otherwise false.
-
getX()
-
Returns the X value of this point.
Returns:
The X value
-
Type
-
number
-
getY()
-
Returns the Y value of this point.
Returns:
The Y value
-
Type
-
number
-
isParallelTo(vec)
-
Checks whether this vector is parallel to another vector.
Parameters:
Returns:
Returns true if both vectors are parallel (same slope). Otherwise false.
-
normalize()
-
Normalizes the vector to get a unit vector of length 1.
Returns:
The unit vector
-
Type
-
Core.Math.Point
-
perpendicular()
-
Gets a perpendicular vector from this one.
Returns:
The perpendicular vector
-
Type
-
Core.Math.Point
-
reverse()
-
.
Reverses the direction of this vector
Returns:
The reverse vector
-
Type
-
Core.Math.Point
-
rotate(angle [, inRadians] [, withRespectTo])
-
Rotates this point around another point clockwise. By default, this will rotate around the origin.
Parameters:
Name |
Type |
Argument |
Default |
Description |
angle |
number
|
|
|
The angle to rotate by |
inRadians |
boolean
|
<optional>
|
false
|
Whether the amount is in radians. Default: false |
withRespectTo |
Core.Math.Point
|
<optional>
|
|
The point to rotate around. Default: (0, 0) |
-
rotate(s)
-
Scales the point by a scaling factor.
Parameters:
Name |
Type |
Description |
s |
|
The amount to scale by |
-
subtract(vec)
-
Subtracts two vectors from each other.
Parameters:
Returns:
The resulting vector representing a new direction
-
Type
-
Core.Math.Point
-
toJSON()
-
Serialize a Point object to a JSON object, which can be saved for further use.
Calling 'JSON.stringify()' on a Point object will call this function automatically.
Returns:
The converted Point JSON object.
-
toMatrix( [vecs])
-
Gets a matrix that represents this point. You can include additional rows to add to the final matrix.
Parameters:
Name |
Type |
Argument |
Description |
vecs |
Array.<Core.Math.Point>
|
<optional>
|
Additional rows to add. |
Returns:
The matrix that represents this point.
-
Type
-
Core.Math.Matrix
-
-
Applies a transformation matrix to this point.
Parameters:
-
translate(x, y)
-
Translates this point by the specified delta values.
Parameters:
Name |
Type |
Description |
x |
number
|
the unit in the x-axis to translate by |
y |
number
|
the unit in the y-axis to translate by |