2023-01-02 12:46:56 +01:00

15 lines
409 B
TypeScript

export function roundToOneDecimal(num: number): number {
return Math.round(num * 10) / 10;
}
export function randomPositiveOrNegative(): number {
return Math.random() < 0.5 ? 1 : -1;
}
export function getDegreeAngleFromDirection(x: number, y: number): number {
const radianAngle = Math.atan2(y, x);
const angle = (radianAngle / Math.PI) * 180;
return angle < 0 ? angle + 360 : angle;
}