-
Notifications
You must be signed in to change notification settings - Fork 7.1k
/
CounterClockwise.js
39 lines (35 loc) · 1 KB
/
CounterClockwise.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
/**
* @author Richard Davey <rich@phaser.io>
* @copyright 2013-2024 Phaser Studio Inc.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
var CONST = require('../const');
/**
* 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:
*
* ```javascript
* var converted = CounterClockwise(gameobject.rotation);
* ```
*
* All values for this function are in radians.
*
* @function Phaser.Math.Angle.CounterClockwise
* @since 3.16.0
*
* @param {number} angle - The angle to convert, in radians.
*
* @return {number} The converted angle, in radians.
*/
var CounterClockwise = function (angle)
{
if (angle > Math.PI)
{
angle -= CONST.PI2;
}
return Math.abs((((angle + CONST.TAU) % CONST.PI2) - CONST.PI2) % CONST.PI2);
};
module.exports = CounterClockwise;