Constructor
new Point2D(x, y)
Creates a new Point2D with the given coordinates.
Name | Type | Description |
---|---|---|
x | number | The x-coordinate of the point. |
y | number | The y-coordinate of the point. |
- Source
Classes
Members
direction
Gets the direction angle with respect to (0, 0) of the Point2D.
- Source
magnitude
Returns the magnitude of the Point2D.
- Source
magnitude_squared
Returns the squared magnitude of the Point2D.
- Source
normalized
Returns the normalized Point2D.
- Source
x
The x-coordinate of the point.
- Source
x
The x-coordinate of the point.
- Source
y
The y-coordinate of the point.
- Source
y
The y-coordinate of the point.
- Source
Methods
angle(other) → {number}
Returns the angle between two Point2Ds.
Name | Type | Description |
---|---|---|
other | Point2D | The other point. |
- Source
The angle between the two points.
- Type:
- number
clone() → {Point2D}
Clones the Point2D.
- Source
- Type:
- Point2D
distance(other) → {number}
Returns the distance between two Point2Ds.
Name | Type | Description |
---|---|---|
other | Point2D | The other point. |
- Source
The distance between the two points.
- Type:
- number
distance_squared(other) → {number}
Returns the distance between two Point2Ds.
Name | Type | Description |
---|---|---|
other | Point2D | The other point. |
- Source
The distance between the two points.
- Type:
- number
dot(other) → {number}
Returns the dot product of Point2D objects.
Name | Type | Description |
---|---|---|
other | Point2D | The other point. |
- Source
The dot product of the two points.
- Type:
- number
equals(other, toleranceopt) → {boolean}
Checks if two Point2D objects are equal within a given tolerance.
Name | Type | Attributes | Description |
---|---|---|---|
other | Point2D | The other point. | |
tolerance | number | | <optional> | The tolerance. |
- Source
A boolean indicating whether the two points are equal.
- Type:
- boolean
is_finite() → {boolean}
Checks if a point is finite
- Source
A boolean indicating whether the point is finite.
- Type:
- boolean
project_onto_line(start, end) → {number}
Projects a point onto a line given the start and end points of the line.
Name | Type | Description |
---|---|---|
start | Point2D | The start point of the line. |
end | Point2D | The end point of the line. |
- Source
The proportion of the line.
- Type:
- number
rotate_around(center, angle) → {Point2D}
Returns the Point2D rotated around a given center point by a given angle.
Name | Type | Description |
---|---|---|
center | Point2D | The center point to rotate around. |
angle | number | The angle to rotate by. |
- Source
The rotated point.
- Type:
- Point2D
(static) from_polar(radius, angle) → {Point2D}
Gets a cartesian point from polar coordinates.
Name | Type | Description |
---|---|---|
radius | number | The radius of the point. |
angle | number | The angle of the point. |
- Source
A 2D point.
- Type:
- Point2D
(static) lerp(point1, point2, t) → {Point2D}
Linearly interpolates between two Point2D objects.
Name | Type | Description |
---|---|---|
point1 | Point2D | The start point. |
point2 | Point2D | The end point. |
t | number | The progress value. |
- Source
The interpolated point.
- Type:
- Point2D