Class: Point

Point(x, y)

Class containing a simple 2D point

Constructor

new Point(x, y)

Create a point by its coordinates
Parameters:
Name Type Description
x number x-coordinate
y number y-coordinate
Source:

Members

x

Returns the point x coordinate
Source:

x

Sets the point x coordinate
Source:

y

Returns the point y coordinate
Source:

y

Sets the point y coordinate
Source:

Methods

add(other) → {Point}

Add another point to this point
Parameters:
Name Type Description
other Point other point
Source:
Returns:
this point after addition
Type
Point

copy() → {Point}

Return a copy of the point
Source:
Returns:
copy of the point
Type
Point

distance(other) → {number}

Return the distance between two points
Parameters:
Name Type Description
other Point other point
Source:
Returns:
distance between the two points
Type
number

equals(other) → {number}

Returns true if the point is equal to another point
Parameters:
Name Type Description
other Point other point
Source:
Returns:
true if the points are equal
Type
number

lerp(other, t) → {Point}

Linearly interpolate between this point and another point
Parameters:
Name Type Description
other Point other point
t number interpolation factor [0, 1]
Source:
Returns:
this point after interpolation
Type
Point

multiply(scalar) → {Point}

Multiply this point by a scalar
Parameters:
Name Type Description
scalar number scalar value
Source:
Returns:
this point after multiplication
Type
Point

subtract(other) → {Point}

Subtract another point from this point
Parameters:
Name Type Description
other Point other point
Source:
Returns:
this point after subtraction
Type
Point

toString() → {string}

Returns the point as a string
Source:
Returns:
string representation of the point
Type
string