15 lines
409 B
TypeScript
Raw Normal View History

2022-11-29 15:55:47 +01:00
export function roundToOneDecimal(num: number): number {
return Math.round(num * 10) / 10;
}
2022-12-05 12:19:46 +01:00
export function randomPositiveOrNegative(): number {
return Math.random() < 0.5 ? 1 : -1;
}
2022-12-15 11:14:35 +01:00
export function getDegreeAngleFromDirection(x: number, y: number): number {
const radianAngle = Math.atan2(y, x);
2023-01-02 12:46:56 +01:00
const angle = (radianAngle / Math.PI) * 180;
return angle < 0 ? angle + 360 : angle;
2022-12-15 11:14:35 +01:00
}