diff --git a/packages/redgeometry/src/internal/bezier.ts b/packages/redgeometry/src/internal/bezier.ts index 5a1beee..4c929c4 100644 --- a/packages/redgeometry/src/internal/bezier.ts +++ b/packages/redgeometry/src/internal/bezier.ts @@ -217,8 +217,8 @@ export function getArcLengthConic(c: BezierRCurve2): number { } export function getParameterAtArcLengthQuadratic(c: Bezier2Curve2, d: number): number { - const d1 = c.p1.sub(c.p0).len(); - const d2 = c.p2.sub(c.p1).len(); + const d1 = c.p1.distanceTo(c.p0); + const d2 = c.p2.distanceTo(c.p1); const r = solveQuadratic(d2 - d1, d1, -d); @@ -231,9 +231,9 @@ export function getParameterAtArcLengthQuadratic(c: Bezier2Curve2, d: number): n } export function getParameterAtArcLengthCubic(c: Bezier3Curve2, d: number): number { - const d1 = c.p1.sub(c.p0).len(); - const d2 = c.p2.sub(c.p1).len(); - const d3 = c.p2.sub(c.p1).len(); + const d1 = c.p1.distanceTo(c.p0); + const d2 = c.p2.distanceTo(c.p1); + const d3 = c.p2.distanceTo(c.p1); const r = solveCubic(d3 - 2 * d2 + d1, d2 - d1, d1, -d); @@ -245,8 +245,8 @@ export function getParameterAtArcLengthCubic(c: Bezier3Curve2, d: number): numbe } export function getParameterAtArcLengthConic(c: BezierRCurve2, d: number): number { - const d1 = c.p1.sub(c.p0).len(); - const d2 = c.p2.sub(c.p1).len(); + const d1 = c.p1.distanceTo(c.p0); + const d2 = c.p2.distanceTo(c.p1); const dw = c.w * d1; const r = solveQuadratic(d2 - 2 * dw - d1, dw, -d); diff --git a/packages/redgeometry/src/internal/path-dash.ts b/packages/redgeometry/src/internal/path-dash.ts index 34d906c..35e2fd2 100644 --- a/packages/redgeometry/src/internal/path-dash.ts +++ b/packages/redgeometry/src/internal/path-dash.ts @@ -217,7 +217,7 @@ export function getDashStart(dashArray: number[], dashOffset: number): [number, } export function getDashArcLengthLinear(c: Bezier1Curve2): number { - return c.p1.sub(c.p0).len(); + return c.p1.distanceTo(c.p0); } export function getDashParameterLinear(c: Bezier1Curve2, length: number): number { diff --git a/packages/redgeometry/src/primitives/bezier.ts b/packages/redgeometry/src/primitives/bezier.ts index 8cd791d..86036fd 100644 --- a/packages/redgeometry/src/primitives/bezier.ts +++ b/packages/redgeometry/src/primitives/bezier.ts @@ -957,8 +957,8 @@ export class BezierRCurve2 { public static fromCenterPoint(p0: Point2, p1: Point2, p2: Point2, pc: Point2): BezierRCurve2 { const pm = p0.lerp(p2, 0.5); - const dm = pm.sub(pc).len(); - const d1 = p1.sub(pc).len(); + const dm = pm.distanceTo(pc); + const d1 = p1.distanceTo(pc); const w = Math.sqrt(dm / d1); return new BezierRCurve2(p0, p1, p2, w); } diff --git a/packages/redgeometry/src/primitives/edge.ts b/packages/redgeometry/src/primitives/edge.ts index af888eb..5c0cd06 100644 --- a/packages/redgeometry/src/primitives/edge.ts +++ b/packages/redgeometry/src/primitives/edge.ts @@ -88,7 +88,7 @@ export class Edge2 { const p0 = e1.getValueAt(t); const p1 = e2.getValueAt(u); - return p0.sub(p1).len(); + return p0.distanceTo(p1); } public static getClosestParameter(e1: Edge2, e2: Edge2): [number, number] { @@ -299,7 +299,7 @@ export class Edge2 { } public getClosestPointDistance(p: Point2): number { - return this.getClosestPoint(p).sub(p).len(); + return this.getClosestPoint(p).distanceTo(p); } /** @@ -453,7 +453,7 @@ export class Edge3 { } public getClosestPointDistance(p: Point3): number { - return this.getClosestPoint(p).sub(p).len(); + return this.getClosestPoint(p).distanceTo(p); } /**