From 40d85508b390426910b7ec5ef66c0953ec7d01a2 Mon Sep 17 00:00:00 2001 From: cha0s Date: Tue, 20 Apr 2021 06:26:13 -0500 Subject: [PATCH] fix: radians -> angle --- packages/math/src/math.js | 2 +- packages/math/test/math.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/math/src/math.js b/packages/math/src/math.js index a69ace8..1577fd2 100644 --- a/packages/math/src/math.js +++ b/packages/math/src/math.js @@ -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), diff --git a/packages/math/test/math.js b/packages/math/test/math.js index 019c04e..51ea336 100644 --- a/packages/math/test/math.js +++ b/packages/math/test/math.js @@ -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); });