# 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`

Parameters:
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

 number x = 0 Position of the point on the x axis number y = 0 Position of the point on the y axis

### Methods from Point

 IPointData add(other: IPointData, outPoint: IPointData) Adds `other` to `this` point and outputs into `outPoint` or a new Point. PIXI.Point clone() this copyFrom(p: IPointData) T copyTo(p: T) number cross(other: IPointData) number dot(other: IPointData) boolean equals(p: IPointData) number magnitude() Computes the magnitude of this point (Euclidean distance from 0, 0). number magnitudeSquared() IPointData multiply(other: IPointData, outPoint: IPointData) Multiplies component-wise `other` and `this` points and outputs into `outPoint` or a new Point. IPointData multiplyScalar(scalar: number, outPoint: IPointData) Multiplies each component of `this` point with the number `scalar` and outputs into `outPoint` or a new Point. IPointData normalize(outPoint: IPointData) Computes a normalized version of `this` point. IPointData project(onto: IPointData, outPoint: IPointData) Computes vector projection of `this` on `onto`. IPointData reflect(normal: IPointData, outPoint: IPointData) this set(x: number, y: number) IPointData subtract(other: IPointData, outPoint: IPointData) Subtracts `other` from `this` point and outputs into `outPoint` or a new Point.

## Public Properties x
``x: number = 0``

Position of the point on the x axis y
``y: number = 0``

Position of the point on the y axis

## Public Methods add
``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.

Parameters:
Name Type Attributes Description
other IPointData

The point to add to `this`.

outPoint IPointData

<optional>

A Point-like object in which to store the value, optional (otherwise will create a new Point).

Returns:
Type Description
IPointData

The `outPoint` reference or a new Point, with the result of the addition. clone
``clone() → {PIXI.Point}``

Creates a clone of this point

Returns:
Type Description
PIXI.Point

A clone of this point copyFrom
``copyFrom(p: IPointData) → {this}``

Copies `x` and `y` from the given point into this point

Parameters:
Name Type Description
p IPointData

The point to copy from

Returns:
Type Description
this

The point instance itself copyTo
``copyTo(p: T) → {T}``

Copies this point's x and y into the given point (`p`).

Parameters:
Name Type Description
p T

The point to copy to. Can be any of type that is or extends `IPointData`

Returns:
Type Description
T

The point (`p`) with values updated cross
``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.

Parameters:
Name Type Description
other IPointData

The other point to calculate the cross product with `this`.

Returns:
Type Description
number

The z component of the result of the cross product. dot
``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.

Parameters:
Name Type Description
other IPointData

The other point to calculate the dot product with `this`.

Returns:
Type Description
number

The result of the dot product. This is an scalar value. equals
``equals(p: IPointData) → {boolean}``

Accepts another point (`p`) and returns `true` if the given point is equal to this point

Parameters:
Name Type Description
p IPointData

The point to check

Returns:
Type Description
boolean

Returns `true` if both `x` and `y` are equal magnitude
``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.

Returns:
Type Description
number

The magnitude (length) of the vector. magnitudeSquared
``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.

Returns:
Type Description
number

The magnitude squared (length squared) of the vector. multiply
``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.

Parameters:
Name Type Attributes Description
other IPointData

The point to multiply with `this`.

outPoint IPointData

<optional>

A Point-like object in which to store the value, optional (otherwise will create a new Point).

Returns:
Type Description
IPointData

The `outPoint` reference or a new Point, with the component-wise multiplication. multiplyScalar
``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.

Parameters:
Name Type Attributes Description
scalar number

The number to multiply both components of `this`.

outPoint IPointData

<optional>

A Point-like object in which to store the value, optional (otherwise will create a new Point).

Returns:
Type Description
IPointData

The `outPoint` reference or a new Point, with the multiplication. normalize
``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.

Parameters:
Name Type Attributes Description
outPoint IPointData

<optional>

A Point-like object in which to store the value, optional (otherwise will create a new Point).

Returns:
Type Description
IPointData

The normalized point. project
``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.

Parameters:
Name Type Attributes Description
onto IPointData

A non zero vector describing a line on which to project `this`.

outPoint IPointData

<optional>

A Point-like object in which to store the value, optional (otherwise will create a new Point).

Returns:
Type Description
IPointData

The `this` on `onto` projection. reflect
``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.

Parameters:
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).

Returns:
Type Description
IPointData

The reflection of `this` on your reflecting plane. set
``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`.

Parameters:
Name Type Attributes Default Description
x number

<optional>

0

position of the point on the `x` axis

y number

<optional>

x

position of the point on the `y` axis

Returns:
Type Description
this

The point instance itself subtract
``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.

Parameters:
Name Type Attributes Description
other IPointData

The point to subtract to `this`.

outPoint IPointData

<optional>

A Point-like object in which to store the value, optional (otherwise will create a new Point).

Returns:
Type Description
IPointData

The `outPoint` reference or a new Point, with the result of the subtraction.