Class: Point

CoreControls.Math. Point

A utility class that represents a point with an x and y coordinate.

new Point(x, y)

Creates a new Point with an x and y coordinate.
Parameters:
Name Type Description
x number the x-coordinate
y number the y-coordinate
Properties:
Name Type Description
x number the x-coordinate
y number the y-coordinate

Members


<static> Origin

Gets a point at (0, 0).

Methods


add(vec)

Adds two vectors together.
Parameters:
Name Type Description
vec CoreControls.Math.Point A delta vector
Returns:
The combined vector representing a new direction
Type
CoreControls.Math.Point

angle(vec [, inRadians])

Gets the angle between this point and another relative to the origin.
Parameters:
Name Type Argument Default Description
vec CoreControls.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:
Name Type Description
vec CoreControls.Math.Point The other vector
Returns:
A cross product object with X, Y, Z properties
Type
any

distance(vec)

Gets the distance between this point and another.
Parameters:
Name Type Description
vec CoreControls.Math.Point The other point
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:
Name Type Description
vec CoreControls.Math.Point The other vector
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:
Name Type Description
vec The other point
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:
Name Type Description
vec The other vector
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
CoreControls.Math.Point

perpendicular()

Gets a perpendicular vector from this one.
Returns:
The perpendicular vector
Type
CoreControls.Math.Point

reverse()

. Reverses the direction of this vector
Returns:
The reverse vector
Type
CoreControls.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 CoreControls.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:
Name Type Description
vec CoreControls.Math.Point A delta vector
Returns:
The resulting vector representing a new direction
Type
CoreControls.Math.Point

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.<CoreControls.Math.Point> <optional>
Additional rows to add.
Returns:
The matrix that represents this point.
Type
CoreControls.Math.Matrix

transform(transform)

Applies a transformation matrix to this point.
Parameters:
Name Type Description
transform CoreControls.Math.Matrix The transformation matrix.

translate()

Translates this point by some delta values.