fix: radians -> angle
This commit is contained in:
parent
0c15cd0f94
commit
40d85508b3
|
@ -52,7 +52,7 @@ export const add = (l, r) => l + r;
|
|||
export const div = (l, r) => l / r;
|
||||
export const frac = (number) => number % 1;
|
||||
export const angleFromRad = (r) => (
|
||||
(360 + ((2 * Math.PI - (r + HALF_PI)) % (Math.PI * 2)) / -PI_180) % 360
|
||||
(360 + ((2 * Math.PI - ((Math.PI - r) + HALF_PI + Math.PI)) % (Math.PI * 2)) / -PI_180) % 360
|
||||
);
|
||||
export const angleRange = (angle, delta) => ({
|
||||
min: 360 + (angle - delta),
|
||||
|
|
|
@ -4,8 +4,8 @@ import {angleFromRad, HALF_PI, PI} from '../src/math';
|
|||
|
||||
it('can translate radians into degrees', () => {
|
||||
expect(angleFromRad(0)).to.equal(90);
|
||||
expect(angleFromRad(HALF_PI)).to.equal(180);
|
||||
expect(angleFromRad(HALF_PI)).to.equal(0);
|
||||
expect(angleFromRad(PI)).to.equal(270);
|
||||
expect(angleFromRad(PI + HALF_PI)).to.equal(0);
|
||||
expect(angleFromRad(PI + HALF_PI)).to.equal(180);
|
||||
expect(angleFromRad(2 * PI)).to.equal(90);
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue
Block a user