feat: toAngle

This commit is contained in:
cha0s 2021-02-03 13:47:50 -06:00
parent 477fb196aa
commit 20b52ee997

View File

@ -1,4 +1,5 @@
import {
angleFromRad,
SQRT_2_2,
EIGHTH_PI,
QUARTER_PI,
@ -264,6 +265,10 @@ export function toRadians(v) {
return (Math.atan2(v[1], v[0]) + Math.PI * 2) % (Math.PI * 2);
}
export function toAngle(v) {
return angleFromRad(toRadians(v));
}
export function fromRadians(angle) {
return [Math.cos(angle), -Math.sin(angle)];
}
@ -388,16 +393,6 @@ export function describe() {
},
],
},
toRadians: {
type: 'number',
label: 'To radians',
args: [
{
label: 'Vector',
type: 'vector',
},
],
},
sub: {
type: 'vector',
label: '$1 minus $2',
@ -412,6 +407,26 @@ export function describe() {
},
],
},
toAngle: {
type: 'number',
label: 'To angle',
args: [
{
label: 'Vector',
type: 'vector',
},
],
},
toRadians: {
type: 'number',
label: 'To radians',
args: [
{
label: 'Vector',
type: 'vector',
},
],
},
},
type: 'object',
};