Warn more about NaN

This commit is contained in:
be5invis 2021-04-17 16:07:08 -07:00
parent b67e8acca5
commit 8baf9518da
2 changed files with 5 additions and 0 deletions

View file

@ -50,6 +50,9 @@ class ContourGeometry extends GeometryBase {
return !this.m_points.length;
}
measureComplexity() {
for (const z of this.m_points) {
if (!isFinite(z.x) || !isFinite(z.y)) return 0xffff;
}
return this.m_points.length;
}
toShapeStringOrNull() {

View file

@ -157,10 +157,12 @@ class SpiroExpansionContext2 {
if (this.nKnotsProcessed === 1) {
const angle = computeNormalAngle(this.gizmo, arc.deriveX0, arc.deriveY0);
if (isFinite(angle)) this.controlKnots[0].normalAngle = angle;
else throw new Error("NaN angle detected.");
}
{
const angle = computeNormalAngle(this.gizmo, arc.deriveX1, arc.deriveY1);
if (isFinite(angle)) this.controlKnots[this.nKnotsProcessed].normalAngle = angle;
else throw new Error("NaN angle detected.");
}
this.nKnotsProcessed += 1;
}