Fix arc negative radians issue

This commit is contained in:
Mark Tolmacs 2025-01-07 12:27:29 +01:00
parent fb113e2054
commit b2fcf787e2
No known key found for this signature in database
2 changed files with 20 additions and 13 deletions

View file

@ -60,8 +60,14 @@ export const normalizeRadians = (angle: Radians): Radians => {
export const cartesian2Polar = <P extends GenericPoint>([
x,
y,
]: P): PolarCoords =>
polar(Math.hypot(x, y), normalizeRadians(radians(Math.atan2(y, x))));
]: P): PolarCoords => {
const [radius, angle] = polar(
Math.hypot(x, y),
normalizeRadians(radians(Math.atan2(y, x))),
);
return [radius, normalizeRadians(angle)] as PolarCoords;
};
/**
* Convert an angle in degrees into randians