diff --git a/packages/editor/src/lib/editor/shapes/shared/arrow/curved-arrow.ts b/packages/editor/src/lib/editor/shapes/shared/arrow/curved-arrow.ts index 03e3c2ad4..a8a755df5 100644 --- a/packages/editor/src/lib/editor/shapes/shared/arrow/curved-arrow.ts +++ b/packages/editor/src/lib/editor/shapes/shared/arrow/curved-arrow.ts @@ -389,9 +389,9 @@ function getArcInfo(a: VecLike, b: VecLike, c: VecLike): TLArcInfo { const sweepFlag = +Vec.Clockwise(a, c, b) // The base angle of the arc in radians - const ab = Math.hypot(a.y - b.y, a.x - b.x) - const bc = Math.hypot(b.y - c.y, b.x - c.x) - const ca = Math.hypot(c.y - a.y, c.x - a.x) + const ab = ((a.y - b.y) ** 2 + (a.x - b.x) ** 2) ** 0.5 + const bc = ((b.y - c.y) ** 2 + (b.x - c.x) ** 2) ** 0.5 + const ca = ((c.y - a.y) ** 2 + (c.x - a.x) ** 2) ** 0.5 const theta = Math.acos((bc * bc + ca * ca - ab * ab) / (2 * bc * ca)) * 2 diff --git a/packages/editor/src/lib/primitives/Mat.ts b/packages/editor/src/lib/primitives/Mat.ts index c895ded76..b2388fcb1 100644 --- a/packages/editor/src/lib/primitives/Mat.ts +++ b/packages/editor/src/lib/primitives/Mat.ts @@ -218,10 +218,10 @@ export class Mat { let rotation if (m.a !== 0 || m.c !== 0) { - const hypotAc = Math.hypot(m.a, m.c) + const hypotAc = (m.a * m.a + m.c * m.c) ** 0.5 rotation = Math.acos(m.a / hypotAc) * (m.c > 0 ? -1 : 1) } else if (m.b !== 0 || m.d !== 0) { - const hypotBd = Math.hypot(m.b, m.d) + const hypotBd = (m.b * m.b + m.d * m.d) ** 0.5 rotation = HALF_PI + Math.acos(m.b / hypotBd) * (m.d > 0 ? -1 : 1) } else { rotation = 0 @@ -234,12 +234,12 @@ export class Mat { let scaleX, scaleY, rotation if (m.a !== 0 || m.c !== 0) { - const hypotAc = Math.hypot(m.a, m.c) + const hypotAc = (m.a * m.a + m.c * m.c) ** 0.5 scaleX = hypotAc scaleY = (m.a * m.d - m.b * m.c) / hypotAc rotation = Math.acos(m.a / hypotAc) * (m.c > 0 ? -1 : 1) } else if (m.b !== 0 || m.d !== 0) { - const hypotBd = Math.hypot(m.b, m.d) + const hypotBd = (m.b * m.b + m.d * m.d) ** 0.5 scaleX = (m.a * m.d - m.b * m.c) / hypotBd scaleY = hypotBd rotation = HALF_PI + Math.acos(m.b / hypotBd) * (m.d > 0 ? -1 : 1) diff --git a/packages/editor/src/lib/primitives/Vec.ts b/packages/editor/src/lib/primitives/Vec.ts index 48beec6c1..898e0578f 100644 --- a/packages/editor/src/lib/primitives/Vec.ts +++ b/packages/editor/src/lib/primitives/Vec.ts @@ -315,7 +315,7 @@ export class Vec { // Get the distance between two points. static Dist(A: VecLike, B: VecLike): number { - return Math.hypot(A.y - B.y, A.x - B.x) + return ((A.y - B.y) ** 2 + (A.x - B.x) ** 2) ** 0.5 } // Get whether a distance between two points is less than a number. This is faster to calulate than using `Vec.Dist(a, b) < n`. @@ -355,7 +355,7 @@ export class Vec { } static Len(A: VecLike): number { - return Math.hypot(A.x, A.y) + return (A.x * A.x + A.y * A.y) ** 0.5 } /**