# Namespace: Angle

## Phaser.Math. Angle

### Methods

#### <static> Between(x1, y1, x2, y2)

Find the angle of a segment from (x1, y1) -> (x2, y2).

##### Parameters:
Name Type Description
`x1` number

The x coordinate of the first point.

`y1` number

The y coordinate of the first point.

`x2` number

The x coordinate of the second point.

`y2` number

The y coordinate of the second point.

Since: 3.0.0
Source: src/math/angle/Between.js (Line 7)

Type
number

#### <static> BetweenPoints(point1, point2)

Find the angle of a segment from (point1.x, point1.y) -> (point2.x, point2.y).

Calculates the angle of the vector from the first point to the second point.

##### Parameters:
Name Type Description
`point1` Phaser.Geom.Point | object

The first point.

`point2` Phaser.Geom.Point | object

The second point.

Since: 3.0.0
Source: src/math/angle/BetweenPoints.js (Line 7)

Type
number

#### <static> BetweenPointsY(point1, point2)

Find the angle of a segment from (point1.x, point1.y) -> (point2.x, point2.y).

The difference between this method and Phaser.Math.Angle.BetweenPoints is that this assumes the y coordinate travels down the screen.

##### Parameters:
Name Type Description
`point1` Phaser.Geom.Point | object

The first point.

`point2` Phaser.Geom.Point | object

The second point.

Since: 3.0.0
Source: src/math/angle/BetweenPointsY.js (Line 7)

Type
number

#### <static> BetweenY(x1, y1, x2, y2)

Find the angle of a segment from (x1, y1) -> (x2, y2).

The difference between this method and Phaser.Math.Angle.Between is that this assumes the y coordinate travels down the screen.

##### Parameters:
Name Type Description
`x1` number

The x coordinate of the first point.

`y1` number

The y coordinate of the first point.

`x2` number

The x coordinate of the second point.

`y2` number

The y coordinate of the second point.

Since: 3.0.0
Source: src/math/angle/BetweenY.js (Line 7)

Type
number

#### <static> CounterClockwise(angle)

Takes an angle in Phasers default clockwise format and converts it so that 0 is North, 90 is West, 180 is South and 270 is East, therefore running counter-clockwise instead of clockwise.

You can pass in the angle from a Game Object using:

``````var converted = CounterClockwise(gameobject.rotation);
``````

All values for this function are in radians.

##### Parameters:
Name Type Description
`angle` number

The angle to convert, in radians.

Since: 3.16.0
Source: src/math/angle/CounterClockwise.js (Line 9)

Type
number

#### <static> Normalize(angle)

Normalize an angle to the [0, 2pi] range.

##### Parameters:
Name Type Description
`angle` number

The angle to normalize, in radians.

Since: 3.0.0
Source: src/math/angle/Normalize.js (Line 7)

Type
number

#### <static> Reverse(angle)

Reverse the given angle.

##### Parameters:
Name Type Description
`angle` number

The angle to reverse, in radians.

Since: 3.0.0
Source: src/math/angle/Reverse.js (Line 9)

Type
number

#### <static> RotateTo(currentAngle, targetAngle [, lerp])

Rotates `currentAngle` towards `targetAngle`, taking the shortest rotation distance. The `lerp` argument is the amount to rotate by in this call.

##### Parameters:
Name Type Argument Default Description
`currentAngle` number

`targetAngle` number

The target angle to rotate to, in radians.

`lerp` number <optional>
0.05

The lerp value to add to the current angle.

Since: 3.0.0
Source: src/math/angle/RotateTo.js (Line 9)

Type
number

#### <static> ShortestBetween(angle1, angle2)

Gets the shortest angle between `angle1` and `angle2`.

Both angles must be in the range -180 to 180, which is the same clamped range that `sprite.angle` uses, so you can pass in two sprite angles to this method and get the shortest angle back between the two of them.

The angle returned will be in the same range. If the returned angle is greater than 0 then it's a counter-clockwise rotation, if < 0 then it's a clockwise rotation.

TODO: Wrap the angles in this function?

##### Parameters:
Name Type Description
`angle1` number

The first angle in the range -180 to 180.

`angle2` number

The second angle in the range -180 to 180.

Since: 3.0.0
Source: src/math/angle/ShortestBetween.js (Line 7)
##### Returns:

The shortest angle, in degrees. If greater than zero it's a counter-clockwise rotation.

Type
number

#### <static> Wrap(angle)

Wrap an angle.

Wraps the angle to a value in the range of -PI to PI.

##### Parameters:
Name Type Description
`angle` number

The angle to wrap, in radians.

Since: 3.0.0
Source: src/math/angle/Wrap.js (Line 9)

Type
number

#### <static> WrapDegrees(angle)

Wrap an angle in degrees.

Wraps the angle to a value in the range of -180 to 180.

##### Parameters:
Name Type Description
`angle` number

The angle to wrap, in degrees.

Since: 3.0.0
Source: src/math/angle/WrapDegrees.js (Line 9)
##### Returns:

The wrapped angle, in degrees.

Type
number