new Point([x], [y])
name | type | arguments | Default | description |
---|---|---|---|---|
x | number | <optional> | 0 |
The x coordinate of this Point. |
y | number | <optional> | x |
The y coordinate of this Point. |
The geometry constant type of this object: GEOM_CONST.POINT
.
Used for fast type comparisons.
The x coordinate of this Point.
The y coordinate of this Point.
Set the x and y coordinates of the point to the given values.
name | type | arguments | Default | description |
---|---|---|---|---|
x | number | <optional> | 0 |
The x coordinate of this Point. |
y | number | <optional> | x |
The y coordinate of this Point. |
This Point object.
Apply Math.ceil()
to each coordinate of the given Point.
name | type | description |
---|---|---|
point | Phaser.Geom.Point |
The Point to ceil. |
The Point with Math.ceil()
applied to its coordinates.
Clone the given Point.
name | type | description |
---|---|---|
source | Phaser.Geom.Point |
The source Point to clone. |
The cloned Point.
Copy the values of one Point to a destination Point.
name | type | description |
---|---|---|
source | Phaser.Geom.Point |
The source Point to copy the values from. |
dest | Phaser.Geom.Point |
The destination Point to copy the values to. |
The destination Point.
A comparison of two Point
objects to see if they are equal.
name | type | description |
---|---|---|
point | Phaser.Geom.Point |
The original |
toCompare | Phaser.Geom.Point |
The second |
Returns true if the both Point
objects are equal.
Apply Math.ceil()
to each coordinate of the given Point.
name | type | description |
---|---|---|
point | Phaser.Geom.Point |
The Point to floor. |
The Point with Math.floor()
applied to its coordinates.
Get the centroid or geometric center of a plane figure (the arithmetic mean position of all the points in the figure). Informally, it is the point at which a cutout of the shape could be perfectly balanced on the tip of a pin.
name | type | arguments | description |
---|---|---|---|
points | Array.<Phaser.Types.Math.Vector2Like> |
An array of Vector2Like objects to get the geometric center of. |
|
out | Phaser.Geom.Point | <optional> |
A Point object to store the output coordinates in. If not given, a new Point instance is created. |
A Point object representing the geometric center of the given points.
Calculate the magnitude of the point, which equivalent to the length of the line from the origin to this point.
name | type | description |
---|---|---|
point | Phaser.Geom.Point |
The point to calculate the magnitude for |
The resulting magnitude
Calculates the square of magnitude of given point.(Can be used for fast magnitude calculation of point)
name | type | description |
---|---|---|
point | Phaser.Geom.Point |
Returns square of the magnitude/length of given point. |
Returns square of the magnitude of given point.
Calculates the Axis Aligned Bounding Box (or aabb) from an array of points.
name | type | arguments | description |
---|---|---|---|
points | Array.<Phaser.Types.Math.Vector2Like> |
An array of Vector2Like objects to get the AABB from. |
|
out | Phaser.Geom.Rectangle | <optional> |
A Rectangle object to store the results in. If not given, a new Rectangle instance is created. |
A Rectangle object holding the AABB values for the given points.
Returns the linear interpolation point between the two given points, based on t
.
name | type | arguments | description |
---|---|---|---|
pointA | Phaser.Geom.Point |
The starting |
|
pointB | Phaser.Geom.Point |
The target |
|
t | number | <optional> |
The amount to interpolate between the two points. Generally, a value between 0 (returns the starting |
out | object | Phaser.Geom.Point | <optional> |
An optional |
Either the object from the out
argument with the properties x
and y
set to the result of the interpolation or a newly created Point
object.
Swaps the X and the Y coordinate of a point.
name | type | description |
---|---|---|
point | Phaser.Geom.Point |
The Point to modify. |
The modified point
.
Inverts a Point's coordinates.
name | type | arguments | description |
---|---|---|---|
point | Phaser.Geom.Point |
The Point to invert. |
|
out | Phaser.Geom.Point | <optional> |
The Point to return the inverted coordinates in. |
The modified out
Point, or a new Point if none was provided.
Calculates the vector projection of pointA
onto the nonzero pointB
. This is the
orthogonal projection of pointA
onto a straight line parallel to pointB
.
name | type | arguments | description |
---|---|---|---|
pointA | Phaser.Geom.Point |
Point A, to be projected onto Point B. |
|
pointB | Phaser.Geom.Point |
Point B, to have Point A projected upon it. |
|
out | Phaser.Geom.Point | <optional> |
The Point object to store the position in. If not given, a new Point instance is created. |
A Point object holding the coordinates of the vector projection of pointA
onto pointB
.
Calculates the vector projection of pointA
onto the nonzero pointB
. This is the
orthogonal projection of pointA
onto a straight line paralle to pointB
.
name | type | arguments | description |
---|---|---|---|
pointA | Phaser.Geom.Point |
Point A, to be projected onto Point B. Must be a normalized point with a magnitude of 1. |
|
pointB | Phaser.Geom.Point |
Point B, to have Point A projected upon it. |
|
out | Phaser.Geom.Point | <optional> |
The Point object to store the position in. If not given, a new Point instance is created. |
A unit Point object holding the coordinates of the vector projection of pointA
onto pointB
.
Changes the magnitude (length) of a two-dimensional vector without changing its direction.
name | type | description |
---|---|---|
point | Phaser.Geom.Point |
The Point to treat as the end point of the vector. |
magnitude | number |
The new magnitude of the vector. |
The modified Point.