Use atan2

This commit is contained in:
Mark Tolmacs 2025-05-24 18:44:25 +02:00
parent 001df5bade
commit b2b6d69477
No known key found for this signature in database
2 changed files with 4 additions and 4 deletions

View File

@ -298,9 +298,9 @@ export class LinearElementEditor {
element.points[selectedIndex === 0 ? 1 : selectedIndex - 1];
customLineAngle =
linearElementEditor.customLineAngle ??
Math.atan(
(element.points[selectedIndex][1] - referencePoint[1]) /
(element.points[selectedIndex][0] - referencePoint[0]),
Math.atan2(
element.points[selectedIndex][1] - referencePoint[1],
element.points[selectedIndex][0] - referencePoint[0],
);
const [width, height] = LinearElementEditor._getShiftLockedDelta(

View File

@ -145,7 +145,7 @@ export const getLockedLinearCursorAlignSize = (
let width = x - originX;
let height = y - originY;
const angle = Math.atan(height / width) as Radians;
const angle = Math.atan2(height, width) as Radians;
let lockedAngle = (Math.round(angle / SHIFT_LOCKING_ANGLE) *
SHIFT_LOCKING_ANGLE) as Radians;