Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- normalizeAngle = angle => {
- let newAngle = angle;
- if (newAngle <= -180) newAngle += 360;
- if (newAngle > 180) newAngle -= 360;
- return newAngle;
- };
- calculateAngle = point => {
- return (Math.atan2(point.y - INITIAL_POINT.y, point.x - INITIAL_POINT.x) * 180 / Math.PI) + 90;
- };
- calculateCoordinates = angle => {
- if (!angle) return { x: 0, y: 0 };
- const length = VECTOR_LEGHT;
- const angleInRadians = (angle - 90) * Math.PI / 180;
- return {
- x: length * Math.cos(angleInRadians) + INITIAL_POINT.x,
- y: length * Math.sin(angleInRadians) + INITIAL_POINT.y,
- };
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement