PIXI.Point
class Point implements {IPoint}
The Point object represents a location in a two-dimensional coordinate system, where x
represents
the position on the horizontal axis and y
represents the position on the vertical axis
Constructor
new PIXI.Point(x: number, y: number) → {}
Creates a new Point
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
x | number |
<optional> |
0 |
position of the point on the x axis |
y | number |
<optional> |
0 |
position of the point on the y axis |
Summary
Properties from Point
Methods from Point
IPointData |
Adds |
PIXI.Point |
|
this |
|
T |
|
number |
|
number |
|
boolean |
|
number |
Computes the magnitude of this point (Euclidean distance from 0, 0). |
number |
|
IPointData |
Multiplies component-wise |
IPointData |
Multiplies each component of |
IPointData |
Computes a normalized version of |
IPointData |
Computes vector projection of |
IPointData |
|
this |
|
IPointData |
Subtracts |
Public Properties
Public Methods
add(other: IPointData, outPoint: IPointData) → {IPointData}
Adds other
to this
point and outputs into outPoint
or a new Point.
Note: Only available with @pixi/math-extras.
Name | Type | Attributes | Description |
---|---|---|---|
other | IPointData |
The point to add to |
|
outPoint | IPointData |
<optional> |
A Point-like object in which to store the value, optional (otherwise will create a new Point). |
Type | Description |
---|---|
IPointData |
The |
clone() → {PIXI.Point}
Creates a clone of this point
Type | Description |
---|---|
PIXI.Point |
A clone of this point |
copyFrom(p: IPointData) → {this}
Copies x
and y
from the given point into this point
Name | Type | Description |
---|---|---|
p | IPointData |
The point to copy from |
Type | Description |
---|---|
this |
The point instance itself |
copyTo(p: T) → {T}
Copies this point's x and y into the given point (p
).
Name | Type | Description |
---|---|---|
p | T |
The point to copy to. Can be any of type that is or extends |
Type | Description |
---|---|
T |
The point ( |
cross(other: IPointData) → {number}
Computes the cross product of other
with this
point.
Given two linearly independent R3 vectors a and b, the cross product, a × b (read "a cross b"),
is a vector that is perpendicular to both a and b, and thus normal to the plane containing them.
While cross product only exists on 3D space, we can assume the z component of 2D to be zero and
the result becomes a vector that will only have magnitude on the z axis.
This function returns the z component of the cross product of the two points.
Note: Only available with @pixi/math-extras.
Name | Type | Description |
---|---|---|
other | IPointData |
The other point to calculate the cross product with |
Type | Description |
---|---|
number |
The z component of the result of the cross product. |
dot(other: IPointData) → {number}
Computes the dot product of other
with this
point.
The dot product is the sum of the products of the corresponding components of two vectors.
Note: Only available with @pixi/math-extras.
Name | Type | Description |
---|---|---|
other | IPointData |
The other point to calculate the dot product with |
Type | Description |
---|---|
number |
The result of the dot product. This is an scalar value. |
equals(p: IPointData) → {boolean}
Accepts another point (p
) and returns true
if the given point is equal to this point
Name | Type | Description |
---|---|---|
p | IPointData |
The point to check |
Type | Description |
---|---|
boolean |
Returns |
magnitude() → {number}
Computes the magnitude of this point (Euclidean distance from 0, 0).
Defined as the square root of the sum of the squares of each component.
Note: Only available with @pixi/math-extras.
Type | Description |
---|---|
number |
The magnitude (length) of the vector. |
magnitudeSquared() → {number}
Computes the square magnitude of this point. If you are comparing the lengths of vectors, you should compare the length squared instead as it is slightly more efficient to calculate.
Defined as the sum of the squares of each component.
Note: Only available with @pixi/math-extras.
Type | Description |
---|---|
number |
The magnitude squared (length squared) of the vector. |
multiply(other: IPointData, outPoint: IPointData) → {IPointData}
Multiplies component-wise other
and this
points and outputs into outPoint
or a new Point.
Note: Only available with @pixi/math-extras.
Name | Type | Attributes | Description |
---|---|---|---|
other | IPointData |
The point to multiply with |
|
outPoint | IPointData |
<optional> |
A Point-like object in which to store the value, optional (otherwise will create a new Point). |
Type | Description |
---|---|
IPointData |
The |
multiplyScalar(scalar: number, outPoint: IPointData) → {IPointData}
Multiplies each component of this
point with the number scalar
and outputs into outPoint
or a new Point.
Note: Only available with @pixi/math-extras.
Name | Type | Attributes | Description |
---|---|---|---|
scalar | number |
The number to multiply both components of |
|
outPoint | IPointData |
<optional> |
A Point-like object in which to store the value, optional (otherwise will create a new Point). |
Type | Description |
---|---|
IPointData |
The |
normalize(outPoint: IPointData) → {IPointData}
Computes a normalized version of this
point.
A normalized vector is a vector of magnitude (length) 1
Note: Only available with @pixi/math-extras.
Name | Type | Attributes | Description |
---|---|---|---|
outPoint | IPointData |
<optional> |
A Point-like object in which to store the value, optional (otherwise will create a new Point). |
Type | Description |
---|---|
IPointData |
The normalized point. |
project(onto: IPointData, outPoint: IPointData) → {IPointData}
Computes vector projection of this
on onto
.
Imagine a light source, parallel to onto
, above this
.
The light would cast rays perpendicular to onto
.
this.project(onto)
is the shadow cast by this
on the line defined by onto
.
Note: Only available with @pixi/math-extras.
Name | Type | Attributes | Description |
---|---|---|---|
onto | IPointData |
A non zero vector describing a line on which to project |
|
outPoint | IPointData |
<optional> |
A Point-like object in which to store the value, optional (otherwise will create a new Point). |
Type | Description |
---|---|
IPointData |
The |
reflect(normal: IPointData, outPoint: IPointData) → {IPointData}
Reflects this
vector off of a plane orthogonal to normal
.
normal
is not normalized during this process. Consider normalizing your normal
before use.
Imagine a light source bouncing onto a mirror.
this
vector is the light and normal
is a vector perpendicular to the mirror.
this.reflect(normal)
is the reflection of this
on that mirror.
Note: Only available with @pixi/math-extras.
Name | Type | Attributes | Description |
---|---|---|---|
normal | IPointData |
The normal vector of your reflecting plane. |
|
outPoint | IPointData |
<optional> |
A Point-like object in which to store the value, optional (otherwise will create a new Point). |
Type | Description |
---|---|
IPointData |
The reflection of |
set(x: number, y: number) → {this}
Sets the point to a new x
and y
position.
If y
is omitted, both x
and y
will be set to x
.
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
x | number |
<optional> |
0 |
position of the point on the |
y | number |
<optional> |
x |
position of the point on the |
Type | Description |
---|---|
this |
The point instance itself |
subtract(other: IPointData, outPoint: IPointData) → {IPointData}
Subtracts other
from this
point and outputs into outPoint
or a new Point.
Note: Only available with @pixi/math-extras.
Name | Type | Attributes | Description |
---|---|---|---|
other | IPointData |
The point to subtract to |
|
outPoint | IPointData |
<optional> |
A Point-like object in which to store the value, optional (otherwise will create a new Point). |
Type | Description |
---|---|
IPointData |
The |