diff --git a/.idea/brepts.iml b/.idea/brepts.iml index 797df2e..5031792 100644 --- a/.idea/brepts.iml +++ b/.idea/brepts.iml @@ -5,7 +5,7 @@ - + @@ -14,5 +14,6 @@ + \ No newline at end of file diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml index 058b2b1..7720632 100644 --- a/.idea/inspectionProfiles/Project_Default.xml +++ b/.idea/inspectionProfiles/Project_Default.xml @@ -5,6 +5,7 @@ + diff --git a/.idea/jsLibraryMappings.xml b/.idea/jsLibraryMappings.xml new file mode 100644 index 0000000..a58f571 --- /dev/null +++ b/.idea/jsLibraryMappings.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.npmignore b/.npmignore index d64df71..fb3c467 100644 --- a/.npmignore +++ b/.npmignore @@ -1,9 +1,7 @@ -*~ -*.swp -node_modules/ -.git -.coveralls.yml -tests/results +* -# WebStorm -.idea \ No newline at end of file +!lib/**/* +!src/**/* +src/shaders +src/ignore +!README.md diff --git a/dist/bundle.js b/dist/bundle.js deleted file mode 100644 index 348f911..0000000 --- a/dist/bundle.js +++ /dev/null @@ -1,12954 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, '__esModule', { value: true }); - -var ts3dutils = require('ts3dutils'); -var tsgl = require('tsgl'); -var _ = require('.'); -var __ = require('..'); -var opentype = require('opentype.js'); -var chroma = require('chroma.ts'); -var svgPathdata = require('svg-pathdata'); -var javasetmap_ts = require('javasetmap.ts'); -var earcut = require('earcut'); -var nerdamer = require('nerdamer'); - -function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } - -var earcut__default = /*#__PURE__*/_interopDefaultLegacy(earcut); -var nerdamer__default = /*#__PURE__*/_interopDefaultLegacy(nerdamer); - -const { abs, acos, acosh, asin, asinh, atan, atanh, atan2, ceil, cbrt, expm1, clz32, cos, cosh, exp, floor, fround, hypot, imul, log, log1p, log2, log10, max, min, pow, random, round, sign, sin, sinh, sqrt, tan, tanh, trunc, E, LN10, LN2, LOG10E, LOG2E, PI, SQRT1_2, SQRT2, } = Math; - -let insideIsInfosWithCurve = false; -class Curve extends ts3dutils.Transformable { - constructor(tMin, tMax) { - super(); - this.tMin = tMin; - this.tMax = tMax; - ts3dutils.assertNumbers(tMin, tMax); - ts3dutils.assert("number" === typeof tMin && !isNaN(tMin)); - ts3dutils.assert("number" === typeof tMax && !isNaN(tMax)); - ts3dutils.assert(tMin < tMax, "tMin < tMax " + tMin + " < " + tMax); - } - static integrate(curve, startT, endT, steps) { - const step = (endT - startT) / steps; - let length = 0; - let p = curve.at(startT); - let i = 0, t = startT + step; - for (; i < steps; i++, t += step) { - const next = curve.at(t); - length += p.distanceTo(next); - p = next; - } - return length; - } - static ispsRecursive(curve1, tMin, tMax, curve2, sMin, sMax) { - // the recursive function finds good approximates for the intersection points - // curve1 function uses newton iteration to improve the result as much as possible - function handleStartTS(startT, startS) { - if (!result.some((info) => ts3dutils.eq(info.tThis, startT) && ts3dutils.eq(info.tOther, startS))) { - const f1 = (t, s) => curve1.tangentAt(t).dot(curve1.at(t).minus(curve2.at(s))); - const f2 = (t, s) => curve2.tangentAt(s).dot(curve1.at(t).minus(curve2.at(s))); - // f = (b1, b2, t1, t2) = b1.tangentAt(t1).dot(b1.at(t1).minus(b2.at(t2))) - const dfdt1 = (b1, b2, t1, t2) => b1.ddt(t1).dot(b1.at(t1).minus(b2.at(t2))) + - b1.tangentAt(t1).squared(); - const dfdt2 = (b1, b2, t1, t2) => -b1.tangentAt(t1).dot(b2.tangentAt(t2)); - const ni = ts3dutils.newtonIterate2dWithDerivatives(f1, f2, startT, startS, 16, dfdt1.bind(undefined, curve1, curve2), dfdt2.bind(undefined, curve1, curve2), (t, s) => -dfdt2(curve2, curve1, s, t), (t, s) => -dfdt1(curve2, curve1, s, t)); - ts3dutils.assert(isFinite(ni.x)); - ts3dutils.assert(isFinite(ni.y)); - if (ni == undefined) - console.log(startT, startS, curve1.sce, curve2.sce); - result.push({ tThis: ni.x, tOther: ni.y, p: curve1.at(ni.x) }); - } - } - // returns whether an intersection was immediately found (i.e. without further recursion) - function findRecursive(tMin, tMax, sMin, sMax, curve1AABB, curve2AABB, depth = 0) { - const EPS = ts3dutils.NLA_PRECISION; - if (curve1AABB.touchesAABBfuzzy(curve2AABB)) { - const tMid = (tMin + tMax) / 2; - const sMid = (sMin + sMax) / 2; - if (Math.abs(tMax - tMin) < EPS || Math.abs(sMax - sMin) < EPS) { - handleStartTS(tMid, sMid); - return true; - } - else { - const curve1AABBleft = curve1.getAABB(tMin, tMid); - const curve2AABBleft = curve2.getAABB(sMin, sMid); - let curve1AABBright, curve2AABBright; - // if one of the following calls immediately finds an intersection, we don't want to call the others - // as that will lead to the same intersection being output multiple times - findRecursive(tMin, tMid, sMin, sMid, curve1AABBleft, curve2AABBleft, depth + 1) || - findRecursive(tMin, tMid, sMid, sMax, curve1AABBleft, (curve2AABBright = curve2.getAABB(sMid, sMax)), depth + 1) || - findRecursive(tMid, tMax, sMin, sMid, (curve1AABBright = curve1.getAABB(tMid, tMax)), curve2AABBleft, depth + 1) || - findRecursive(tMid, tMax, sMid, sMax, curve1AABBright, curve2AABBright, depth + 1); - } - } - return false; - } - const result = []; - findRecursive(tMin, tMax, sMin, sMax, curve1.getAABB(tMin, tMax), curve2.getAABB(sMin, sMax)); - return ts3dutils.fuzzyUniquesF(result, (info) => info.tThis); - } - /** - * Searches a 2d area for (an) implicit curve(s). - * @param implicitCurve - * @param bounds Defines area to search. - * @param uStep Granularity of search in s-direction. - * @param vStep Granularity of search in t-direction. - * @param stepSize step size to take along the curve - * @return - */ - static breakDownIC(implicitCurve, bounds, uStep, vStep, stepSize, validUV) { - //undefined == didu && (didu = (u, v) => (implicitCurve(u + EPS, v) - implicitCurve(u, v)) / EPS) - //undefined == didv && (didv = (u, v) => (implicitCurve(u, v + EPS) - implicitCurve(u, v)) / EPS) - const { uMin, uMax, vMin, vMax } = bounds; - const deltaS = uMax - uMin, deltaT = vMax - vMin; - const sRes = ceil(deltaS / uStep), tRes = ceil(deltaT / vStep); - const grid = new Array(sRes * tRes).fill(0); - // const printGrid = () => - // console.log( - // arrayFromFunction(tRes, i => - // grid - // .slice(sRes * i, sRes * (i + 1)) - // .map(v => (v ? 'X' : '_')) - // .join(''), - // ).join('\n'), - // ) - const get = (i, j) => grid[j * sRes + i]; - const set = (i, j) => 0 <= i && i < sRes && 0 <= j && j < tRes && (grid[j * sRes + i] = 1); - const result = []; - const logTable = []; - for (let i = 0; i < sRes; i++) { - search: for (let j = 0; j < tRes; j++) { - if (get(i, j)) - continue; - set(i, j); - let u = uMin + (i + 0.5) * uStep, v = vMin + (j + 0.5) * vStep; - const startS = u, startT = v; - // basically curvePoint - for (let k = 0; k < 8; k++) { - const fp = implicitCurve(u, v); - const dfpdx = implicitCurve.x(u, v), dfpdy = implicitCurve.y(u, v); - if (0 === Math.pow(dfpdx, 2) + Math.pow(dfpdy, 2)) { - // top of a hill, keep looking - continue search; - } - const scale = fp / (Math.pow(dfpdx, 2) + Math.pow(dfpdy, 2)); - u -= scale * dfpdx; - v -= scale * dfpdy; - } - const li = floor((u - uMin) / uStep), lj = floor((v - vMin) / vStep); - logTable.push({ - i, - j, - li, - lj, - startS, - startT, - u, - v, - "bounds(u, v)": uvInAABB2(bounds, u, v), - "ic(s,t)": implicitCurve(u, v), - }); - if (!(i == li && j == lj) && get(li, lj)) { - continue search; - } - set(li, lj); - // u, v are now good starting coordinates to use follow algorithm - if (uvInAABB2(bounds, u, v) && - validUV(u, v) && - ts3dutils.eq0(implicitCurve(u, v))) { - const subResult = mkcurves(implicitCurve, u, v, stepSize, bounds, validUV); - for (const curveData of subResult) { - ts3dutils.assert(curveData.points.length > 2); - for (const { x, y } of curveData.points) { - const lif = (x - uMin) / uStep, ljf = (y - vMin) / vStep; - set((lif - 0.5) | 0, (ljf - 0.5) | 0); - set((lif - 0.5) | 0, (ljf + 0.5) | 0); - set((lif + 0.5) | 0, (ljf - 0.5) | 0); - set((lif + 0.5) | 0, (ljf + 0.5) | 0); - } - } - //printGrid() - result.push(...subResult); - } - } - } - // console.table(logTable) - for (const { points } of result) { - for (let i = 0; i < points.length - 1; i++) { - ts3dutils.assert(!points[i].equals(points[i + 1])); - } - } - return result; - } - toString() { - return this.toSource(); - } - toSource(rounder = (x) => x) { - return ts3dutils.callsce.call(undefined, "new " + this.constructor.name, ...this.getConstructorParameters(), this.tMin, this.tMax); - } - withBounds(tMin = this.tMin, tMax = this.tMax) { - //assert(this.tMin <= tMin && tMin <= this.tMax) - //assert(this.tMin <= tMax && tMax <= this.tMax) - return new this.constructor(...this.getConstructorParameters(), tMin, tMax); - } - /** - * The point on the line that is closest to the given point. - */ - closestPointToPoint(p) { - return this.at(this.closestTToPoint(p)); - } - isValidT(t) { - return ts3dutils.le(this.tMin, t) && ts3dutils.le(t, this.tMax); - } - diff(t, eps) { - return this.at(t).to(this.at(t + eps)); - } - // TODO: tmin/tmax first - closestTToPoint(p, tStart, tMin = this.tMin, tMax = this.tMax) { - // this.at(t) has minimal distance to p when this.tangentAt(t) is perpendicular to - // the vector between this.at(t) and p. This is the case iff the dot product of the two is 0. - // f = (this.at(t) - p) . (this.tangentAt(t) - // df = this.tangentAt(t) . this.tangentAt(t) + (this.at(t) - p) . this.ddt(t) - // = this.tangentAt(t)² + (this.at(t) - p) . this.ddt(t) - const f = (t) => this.at(t).minus(p).dot(this.tangentAt(t)); // 5th degree polynomial - const df = (t) => this.tangentAt(t).squared() + this.at(t).minus(p).dot(this.ddt(t)); - //checkDerivate(f, df, tMin, tMax) - const STEPS = 32; - if (undefined === tStart) { - tStart = ts3dutils.withMax(ts3dutils.arrayFromFunction(STEPS, (i) => tMin + ((tMax - tMin) * i) / (STEPS - 1)), (t) => -this.at(t).distanceTo(p)); - } - return ts3dutils.newtonIterateWithDerivative(f, tStart, 16, df); - } - /** - * So different edges on the same curve do not have different vertices, they are always generated - * on fixed points this.at(k * this.tIncrement), with k taking integer values - * - */ - calcSegmentPoints(aT, bT, a, b, reversed, includeFirst) { - ts3dutils.assert(this.tIncrement, "tIncrement not defined on " + this); - const inc = this.tIncrement; - const result = []; - if (includeFirst) - result.push(a); - ts3dutils.assert(reversed != aT < bT); - if (aT < bT) { - const start = Math.ceil((aT + ts3dutils.NLA_PRECISION) / inc); - const end = Math.floor((bT - ts3dutils.NLA_PRECISION) / inc); - for (let i = start; i <= end; i++) { - result.push(this.at(i * inc)); - } - } - else { - const start = Math.floor((aT - ts3dutils.NLA_PRECISION) / inc); - const end = Math.ceil((bT + ts3dutils.NLA_PRECISION) / inc); - for (let i = start; i >= end; i--) { - result.push(this.at(i * inc)); - } - } - result.push(b); - return result; - } - calcSegmentTs(aT, bT, reversed, includeFirst) { - ts3dutils.assert(this.tIncrement, "tIncrement not defined on " + this); - const inc = this.tIncrement; - const result = []; - if (includeFirst) - result.push(aT); - ts3dutils.assert(reversed != aT < bT); - if (aT < bT) { - const start = Math.ceil((aT + ts3dutils.NLA_PRECISION) / inc); - const end = Math.floor((bT - ts3dutils.NLA_PRECISION) / inc); - for (let i = start; i <= end; i++) { - result.push(i * inc); - } - } - else { - const start = Math.floor((aT - ts3dutils.NLA_PRECISION) / inc); - const end = Math.ceil((bT + ts3dutils.NLA_PRECISION) / inc); - for (let i = start; i >= end; i--) { - result.push(i * inc); - } - } - result.push(bT); - return result; - } - /** - * - * @param p - * @param tStart Defines interval with tEnd in which a start value for t will be searched. - * Result is not necessarily in this interval. - * @param tEnd - */ - distanceToPoint(p, tStart, tEnd) { - const closestT = this.closestTToPoint(p, tStart, tEnd); - return this.at(closestT).distanceTo(p); - } - asSegmentDistanceToPoint(p, tStart, tEnd) { - let t = this.closestTToPoint(p, tStart, tEnd); - t = ts3dutils.clamp(t, tStart, tEnd); - return this.at(t).distanceTo(p); - } - /** - * Behavior when curves are colinear: self intersections - */ - isInfosWithCurve(curve) { - if (insideIsInfosWithCurve) { - return Curve.ispsRecursive(this, this.tMin, this.tMax, curve, curve.tMin, curve.tMax); - } - else { - try { - insideIsInfosWithCurve = true; - const infos = curve.isInfosWithCurve(this); - return infos.map((info) => { - ts3dutils.assert(info); - const { tThis, tOther, p } = info; - return { tOther: tThis, tThis: tOther, p }; - }); - } - finally { - insideIsInfosWithCurve = false; - } - } - } - isTsWithSurface(surface) { - if (surface instanceof PlaneSurface) { - return this.isTsWithPlane(surface.plane); - } - if (surface instanceof ProjectedCurveSurface) { - const projPlane = new P3(surface.dir.unit(), 0); - const projThis = this.project(projPlane); - const projEllipse = surface.baseCurve.project(projPlane); - return projEllipse.isInfosWithCurve(projThis).map((info) => info.tOther); - } - if (surface instanceof EllipsoidSurface) { - const thisOC = this.transform(surface.matrixInverse); - if (!thisOC.getAABB().touchesAABBfuzzy(new ts3dutils.AABB(ts3dutils.V3.XYZ.negated(), ts3dutils.V3.XYZ))) { - return []; - } - const f = (t) => thisOC.at(t).length() - 1; - const df = (t) => thisOC.at(t).unit().dot(thisOC.tangentAt(t)); - const stepSize = 1 / (1 << 11); - const result = []; - for (let startT = this.tMin; startT <= this.tMax; startT += stepSize) { - const dt = stepSize * thisOC.tangentAt(startT).length(); - if (abs(f(startT)) <= dt) { - //const t = newtonIterate1d(f, startT, 16) - let t = ts3dutils.newtonIterateWithDerivative(f, startT, 16, df); - if (!ts3dutils.eq0(f(t)) || ts3dutils.eq0(df(t))) { - t = ts3dutils.newtonIterate1d(df, startT, 16); - //if (f(a) * f(b) < 0) { - // t = bisect(f, a, b, 16) - //} else if (df(a) * df(b) < 0) { - // t = bisect(df, a, b, 16) - //} - } - if (ts3dutils.eq0(f(t)) && !result.some((r) => ts3dutils.eq(r, t))) { - result.push(t); - } - } - } - return result.filter((t) => surface.containsPoint(this.at(t))); - } - throw new Error(); - } - arcLength(startT, endT, steps = 1) { - ts3dutils.assert(startT < endT, "startT < endT"); - return ts3dutils.glqInSteps((t) => this.tangentAt(t).length(), startT, endT, steps); - } - equals(obj) { - if (this === obj) - return true; - return (ts3dutils.hasConstructor(obj, this.constructor) && - ts3dutils.arrayEquals(this.getConstructorParameters(), obj.getConstructorParameters())); - } - hashCode() { - return ts3dutils.arrayHashCode(this.getConstructorParameters()); - } - getAABB(tMin = this.tMin, tMax = this.tMax) { - tMin = isFinite(tMin) ? tMin : this.tMin; - tMax = isFinite(tMax) ? tMax : this.tMax; - const tMinAt = this.at(tMin), tMaxAt = this.at(tMax); - const roots = this.roots(); - const mins = [0, 0, 0]; - const maxs = [0, 0, 0]; - for (let dim = 0; dim < 3; dim++) { - const tRoots = roots[dim]; - mins[dim] = Math.min(tMinAt.e(dim), tMaxAt.e(dim)); - maxs[dim] = Math.max(tMinAt.e(dim), tMaxAt.e(dim)); - for (const tRoot of tRoots) { - if (tMin < tRoot && tRoot < tMax) { - mins[dim] = Math.min(mins[dim], this.at(tRoot).e(dim)); - maxs[dim] = Math.max(maxs[dim], this.at(tRoot).e(dim)); - } - } - } - return new ts3dutils.AABB(ts3dutils.V3.fromArray(mins), ts3dutils.V3.fromArray(maxs)); - } - reversed() { - throw new Error(); - } - clipPlane(plane) { - const ists = this.isTsWithPlane(plane).filter((ist) => this.tMin <= ist && ist <= this.tMax); - return ts3dutils.mapFilter(ts3dutils.getIntervals(ists, this.tMin, this.tMax), ([a, b]) => { - const midT = (a + b) / 2; - return (!ts3dutils.eq(a, b) && - plane.distanceToPointSigned(this.at(midT)) < 0 && - this.withBounds(a, b)); - }); - } -} -Curve.hlol = 0; -function mkcurves(implicitCurve, sStart, tStart, stepSize, bounds, validUV) { - const start = ts3dutils.V(sStart, tStart); - ts3dutils.assert(stepSize > 0); - // checkDerivate(s => implicitCurve(s, 0), s => didu(s, 0), -1, 1, 0) - // checkDerivate(t => implicitCurve(0, t), t => didv(0, t), -1, 1, 0) - const { points, tangents } = followAlgorithm2d(implicitCurve, start, stepSize, bounds, validUV); - if (points.length > 4 && - points[0].distanceTo(ts3dutils.getLast(points)) <= abs(stepSize)) { - // this is a loop: split it - for (let i = 0; i < points.length - 1; i++) { - ts3dutils.assert(!points[i].equals(points[i + 1])); - } - const half = floor(points.length / 2); - const points1 = points.slice(0, half), points2 = points.slice(half - 1, points.length); - const tangents1 = tangents.slice(0, half), tangents2 = tangents.slice(half - 1, tangents.length); - //tangents2[tangents2.length - 1] = tangents1[0] - //points2[tangents2.length - 1] = points1[0] - for (let i = 0; i < points1.length - 1; i++) { - ts3dutils.assert(!points1[i].equals(points1[i + 1])); - } - for (let i = 0; i < points2.length - 1; i++) { - ts3dutils.assert(!points2[i].equals(points2[i + 1])); - } - return [ - { points: points1, tangents: tangents1 }, - { points: points2, tangents: tangents2 }, - ]; - } - else { - // not a loop: check in the other direction - const { points: reversePoints, tangents: reverseTangents, } = followAlgorithm2d(implicitCurve, start, -stepSize, bounds, validUV); - const result = followAlgorithm2d(implicitCurve, ts3dutils.getLast(reversePoints), stepSize, bounds, validUV, undefined, ts3dutils.getLast(reverseTangents).negated()); - ts3dutils.assert(result.points.length > 2); - return [result]; - } -} -function breakDownPPCurves(ps1, ps2, uStep, vStep, stepSize) { - const { uMin, uMax, vMin, vMax } = ps1; - const bounds = uvInAABB2.bind(undefined, ps1); - const bounds2 = uvInAABB2.bind(undefined, ps2); - const deltaU = uMax - uMin, deltaV = vMax - vMin; - const sRes = ceil(deltaU / uStep), tRes = ceil(deltaV / vStep); - const grid = new Array(sRes * tRes).fill(0); - //const printGrid = () => console.log(arrayFromFunction(tRes, i => grid.slice(sRes * i, sRes * (i + 1)).map(v => v ? 'X' : '_').join('')).join('\n')) - const at = (i, j) => grid[j * sRes + i]; - const set = (i, j) => 0 <= i && i < sRes && 0 <= j && j < tRes && (grid[j * sRes + i] = 1); - const result = []; - const logTable = []; - for (let i = 0; i < sRes; i++) { - search: for (let j = 0; j < tRes; j++) { - if (at(i, j)) - continue; - set(i, j); - const startU = uMin + (i + 0.5) * uStep, startV = vMin + (j + 0.5) * vStep; - // assume point is valid, currently (TODO) - const curvePointPPResult = curvePointPP(ps1, ps2, ps1.pUV(startU, startV)); - if (undefined === curvePointPPResult) { - continue search; - } - const { p: startP, st1: { x: u, y: v }, st2: { x: u2, y: v2 }, } = curvePointPPResult; - const li = floor((u - uMin) / uStep), lj = floor((v - vMin) / vStep); - logTable.push({ - i, - j, - li, - lj, - startU, - startV, - u, - v, - "bounds(u, v)": bounds(u, v), - }); - if (!(i == li && j == lj) && at(li, lj)) { - continue search; - } - set(li, lj); - // u, v are now good starting coordinates to use follow algorithm - if (bounds(u, v) && bounds2(u2, v2)) { - console.log(ts3dutils.V(u, v).sce); - const subResult = mkPPCurves(ps1, ps2, startP, stepSize, bounds, bounds2); - for (const curveData of subResult) { - ts3dutils.assert(curveData.st1s.length > 2); - for (const { x, y } of curveData.st1s) { - const lif = (x - uMin) / uStep, ljf = (y - vMin) / vStep; - set((lif - 0.5) | 0, (ljf - 0.5) | 0); - set((lif - 0.5) | 0, (ljf + 0.5) | 0); - set((lif + 0.5) | 0, (ljf - 0.5) | 0); - set((lif + 0.5) | 0, (ljf + 0.5) | 0); - } - } - //printGrid() - result.push(...subResult); - } - } - } - console.table(logTable); - for (const { points } of result) { - for (let i = 0; i < points.length - 1; i++) { - ts3dutils.assert(!points[i].equals(points[i + 1])); - } - } - return result.map(({ points, tangents, st1s }) => { - return new PPCurve(points, tangents, ps1, ps2, st1s, undefined, stepSize, 1); - }); -} -function mkPPCurves(ps1, ps2, startPoint, stepSize, bounds1, bounds2) { - // checkDerivate(s => implicitCurve(s, 0), s => didu(s, 0), -1, 1, 0) - // checkDerivate(t => implicitCurve(0, t), t => didv(0, t), -1, 1, 0) - const { points, tangents, st1s } = followAlgorithmPP(ps1, ps2, startPoint, stepSize, bounds1, bounds2); - if (points[0].distanceTo(ts3dutils.getLast(points)) < stepSize && points.length > 2) { - // this is a loop: split it - for (let i = 0; i < points.length - 1; i++) { - ts3dutils.assert(!points[i].equals(points[i + 1])); - } - const half = floor(points.length / 2); - const points1 = points.slice(0, half), points2 = points.slice(half - 1, points.length); - const tangents1 = tangents.slice(0, half), tangents2 = tangents.slice(half - 1, tangents.length); - const st1s1 = st1s.slice(0, half), st1s2 = st1s.slice(half - 1, tangents.length); - tangents2[tangents2.length - 1] = tangents1[0]; - points2[tangents2.length - 1] = points1[0]; - st1s2[tangents2.length - 1] = st1s1[0]; - for (let i = 0; i < points1.length - 1; i++) { - ts3dutils.assert(!points1[i].equals(points1[i + 1])); - } - for (let i = 0; i < points2.length - 1; i++) { - ts3dutils.assert(!points2[i].equals(points2[i + 1])); - } - return [ - { points: points1, tangents: tangents1, st1s: st1s1 }, - { points: points2, tangents: tangents2, st1s: st1s2 }, - ]; - } - else { - // not a loop: check in the other direction - const { points: reversePoints } = followAlgorithmPP(ps1, ps2, startPoint, -stepSize, bounds1, bounds2); - const result = followAlgorithmPP(ps1, ps2, ts3dutils.getLast(reversePoints), stepSize, bounds1, bounds2); - ts3dutils.assert(result.points.length > 2); - return [result]; - } -} -function AABB2(uMin, uMax, vMin, vMax) { - return { uMin, uMax, vMin, vMax }; -} -function uvInAABB2(aabb2, u, v) { - return (aabb2.uMin <= u && u <= aabb2.uMax && aabb2.vMin <= v && v <= aabb2.vMax); -} -/** - * Finds a point on a 2D implicit curve. - * - * @param implicitCurve The curve follows the path where implicitCurve(u, v) is zero. - * @param startPoint The point from which to start looking (only .x = u and .y = v will be read). - * @param didu Derivative of implicitCurve in the first parameter. - * @param didv Derivative of implicitCurve in the second parameter. - */ -function curvePoint(implicitCurve, startPoint, didu, didv) { - let p = startPoint; - for (let i = 0; i < 8; i++) { - const fp = implicitCurve(p.x, p.y); - const dfpdx = didu(p.x, p.y); - const dfpdy = didv(p.x, p.y); - const scale = fp / (dfpdx * dfpdx + dfpdy * dfpdy); - p = p.minus(new ts3dutils.V3(scale * dfpdx, scale * dfpdy, 0)); - } - return p; -} -function curvePointMF(mf, startPoint, steps = 8, eps = 1 / (1 << 30)) { - let p = startPoint; - for (let i = 0; i < steps; i++) { - const fp = mf(p.x, p.y); - const dfpdx = mf.x(p.x, p.y); - const dfpdy = mf.y(p.x, p.y); - const scale = fp / (dfpdx * dfpdx + dfpdy * dfpdy); - p = p.minus(new ts3dutils.V3(scale * dfpdx, scale * dfpdy, 0)); - if (abs(fp) <= eps) - break; - } - return p; -} - -class XiEtaCurve extends Curve { - constructor(center, f1, f2, tMin, tMax) { - super(tMin, tMax); - this.center = center; - this.f1 = f1; - this.f2 = f2; - this.tMin = tMin; - this.tMax = tMax; - ts3dutils.assertVectors(center, f1, f2); - this.normal = f1.cross(f2); - if (!this.normal.likeO()) { - this.normal = this.normal.unit(); - this.matrix = ts3dutils.M4.forSys(f1, f2, this.normal, center); - this.matrixInverse = this.matrix.inversed(); - } - else { - this.matrix = ts3dutils.M4.forSys(f1, f2, f1.unit(), center); - const f1p = f1.getPerpendicular(); - // prettier-ignore - this.matrixInverse = new ts3dutils.M4(1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1).times(ts3dutils.M4.forSys(f1, f1p, f1.cross(f1p), center).inversed()); - } - } - /** - * Intersection of the unit curve with the line ax + by = c. - */ - static intersectionUnitLine(a, b, c, tMin, tMax) { - throw new Error("abstract"); - } - /** - * Returns a new EllipseCurve representing an ellipse parallel to the XY-plane - * with semi-major/minor axes parallel t the X and Y axes. - * - * @param a length of the axis parallel to X axis. - * @param b length of the axis parallel to Y axis. - * @param center center of the ellipse. - */ - static forAB(a, b, center = ts3dutils.V3.O) { - return new this(center, ts3dutils.V(a, 0, 0), ts3dutils.V(0, b, 0)); - } - static XYLCValid(pLC) { - throw new Error("abstract"); - } - static XYLCPointT(pLC, tMin, tMax) { - throw new Error("abstract"); - } - static unitIsInfosWithLine(anchorLC, dirLC, anchorWC, dirWC, tMin, tMax) { - throw new Error("abstract"); - } - addToMesh(mesh, res = 4, radius = 0, pointStep = 1) { - const baseNormals = ts3dutils.arrayFromFunction(res, (i) => ts3dutils.V3.polar(1, (ts3dutils.TAU * i) / res)); - const baseVertices = ts3dutils.arrayFromFunction(res, (i) => ts3dutils.V3.polar(radius, (ts3dutils.TAU * i) / res)); - const inc = this.tIncrement; - const start = Math.ceil((this.tMin + ts3dutils.NLA_PRECISION) / inc); - const end = Math.floor((this.tMax - ts3dutils.NLA_PRECISION) / inc); - for (let i = start; i <= end; i += pointStep) { - const t = i * inc; - const start = mesh.vertices.length; - if (0 !== i) { - for (let j = 0; j < res; j++) { - tsgl.pushQuad(mesh.TRIANGLES, true, start - res + j, start + j, start - res + ((j + 1) % res), start + ((j + 1) % res)); - } - } - const point = this.at(t), tangent = this.tangentAt(t); - const matrix = ts3dutils.M4.forSys(this.normal, tangent.cross(this.normal), tangent, point); - mesh.normals.push(...matrix.transformedVectors(baseNormals)); - mesh.vertices.push(...matrix.transformedPoints(baseVertices)); - } - } - getConstructorParameters() { - return [this.center, this.f1, this.f2]; - } - isInfosWithCurve(curve) { - if (curve instanceof L3) { - return this.isInfosWithLine(curve.anchor, curve.dir1, this.tMin, this.tMax, curve.tMin, curve.tMax); - } - if (curve instanceof BezierCurve) { - return this.isInfosWithBezier(curve); - } - if (curve instanceof XiEtaCurve) { - if (!this.normal.isParallelTo(curve.normal)) { - return ts3dutils.mapFilter(this.isTsWithPlane(curve.getPlane()), (tThis) => { - const p = this.at(tThis); - if (curve.containsPoint(p)) { - return { tThis, tOther: curve.pointT(p), p }; - } - return undefined; - }); - } - } - return super.isInfosWithCurve(curve); - } - transform(m4) { - return new this.constructor(m4.transformPoint(this.center), m4.transformVector(this.f1), m4.transformVector(this.f2), this.tMin, this.tMax); - } - equals(obj) { - return (this == obj || - (undefined != obj && - this.constructor == obj.constructor && - this.center.equals(obj.center) && - this.f1.equals(obj.f1) && - this.f2.equals(obj.f2))); - } - hashCode() { - let hashCode = 0; - hashCode = hashCode * 31 + this.center.hashCode(); - hashCode = hashCode * 31 + this.f1.hashCode(); - hashCode = hashCode * 31 + this.f2.hashCode(); - return hashCode | 0; - } - likeCurve(curve) { - return (ts3dutils.hasConstructor(curve, this.constructor) && - this.center.like(curve.center) && - this.f1.like(curve.f1) && - this.f2.like(curve.f2)); - } - normalP(t) { - return this.tangentAt(t).cross(this.normal); - } - getPlane() { - return P3.normalOnAnchor(this.normal, this.center); - } - isTsWithPlane(planeWC) { - ts3dutils.assertInst(P3, planeWC); - /* - this: x = center + f1 * cos t + f2 * sin t (1) - plane: - n := plane.normal1 - n DOT x == plane.w (2) - plane defined by f1/f2 - x = center + f1 * xi + f2 * eta (3) - intersection plane and planef1/f2: - insert (3) into (2): - n DOT center + n DOT f1 * xi + n DOT f2 * eta = plane.w | -n DOT center - n DOT f1 * xi + n DOT f2 * eta = plane.w - n DOT center (4) - points on ellipse have additional condition - eta * eta + xi * xi = 1 (5) - g1 := n DOT f1 - g2 := n DOT f2 - g3 := w - n DOT center - solve system (5)/(6) - g1 * xi + g2 * eta = g3 (6) - */ - if (planeWC.normal1.isParallelTo(this.normal)) { - return []; - } - const n = planeWC.normal1, w = planeWC.w, center = this.center, f1 = this.f1, f2 = this.f2, g1 = n.dot(f1), g2 = n.dot(f2), g3 = w - n.dot(center); - return this.constructor.intersectionUnitLine(g1, g2, g3, this.tMin, this.tMax); - } - pointT(p) { - ts3dutils.assertVectors(p); - const pLC = this.matrixInverse.transformPoint(p); - return this.constructor.XYLCPointT(pLC); - } - containsPoint(p) { - const pLC = this.matrixInverse.transformPoint(p); - return (ts3dutils.eq0(pLC.z) && - this.isValidT(this.constructor.XYLCPointT(pLC, this.tMin, this.tMax))); - } - isInfosWithLine(anchorWC, dirWC, tMin = this.tMin, tMax = this.tMax, lineMin = -100000, lineMax = 100000) { - const anchorLC = this.matrixInverse.transformPoint(anchorWC); - const dirLC = this.matrixInverse.transformVector(dirWC); - if (ts3dutils.eq0(dirLC.z)) { - // local line parallel to XY-plane - if (ts3dutils.eq0(anchorLC.z)) { - // local line lies in XY-plane - return this.constructor.unitIsInfosWithLine(anchorLC, dirLC, anchorWC, dirWC, tMin, tMax); - } - } - else { - // if the line intersects the XY-plane in a single point, there can be an intersection there - // find point, then check if distance from circle = 1 - const otherTAtZ0 = anchorLC.z / dirLC.z; - const isp = dirLC.times(otherTAtZ0).plus(anchorLC); - if (this.constructor.XYLCValid(isp)) { - // point lies on unit circle - return [ - { - tThis: this.constructor.XYLCPointT(isp), - tOther: otherTAtZ0, - p: anchorWC.plus(dirWC.times(otherTAtZ0)), - }, - ]; - } - } - return []; - } - isTsWithSurface(surface) { - if (surface instanceof PlaneSurface) { - return this.isTsWithPlane(surface.plane); - } - else if (surface instanceof EllipsoidSurface) { - const isEllipses = surface.isCurvesWithPlane(this.getPlane()); - return isEllipses - .flatMap((isEllipse) => this.isInfosWithCurve(isEllipse)) - .filter((info) => surface.containsPoint(info.p)) - .map((info) => info.tThis); - } - else if (surface instanceof ProjectedCurveSurface || - surface instanceof ConicSurface) { - return surface - .isCurvesWithPlane(this.getPlane()) - .flatMap((curve) => this.isInfosWithCurve(curve)) - .map((info) => info.tThis); - } - else { - throw new Error(); - } - } - isInfosWithBezier(bezierWC) { - const bezierLC = bezierWC.transform(this.matrixInverse); - if (new PlaneSurface(P3.XY).containsCurve(bezierLC)) { - return this.isInfosWithBezier2D(bezierWC); - } - else { - const infos = ts3dutils.mapFilter(bezierLC.isTsWithPlane(P3.XY), (tOther) => { - const pLC = bezierLC.at(tOther); - if (this.constructor.XYLCValid(pLC)) { - return { - tOther: tOther, - p: bezierWC.at(tOther), - tThis: this.constructor.XYLCPointT(pLC), - }; - } - return undefined; - }); - return infos; - } - } - isInfosWithBezier2D(bezierWC, sMin = bezierWC.tMin, sMax = bezierWC.tMax) { - return Curve.ispsRecursive(this, this.tMin, this.tMax, bezierWC, sMin, sMax); - } - isOrthogonal() { - return this.f1.isPerpendicularTo(this.f2); - } - at2(xi, eta) { - ts3dutils.assertNumbers(xi, eta); - // center + f1 xi + f2 eta - return this.center.plus(this.f1.times(xi)).plus(this.f2.times(eta)); - } - debugInfo() { - return { - points: [ - this.center, - this.at2(0.5, 0), - this.at2(0, 1 / 3), - this.at2(0, 2 / 3), - ], - lines: [this.center, this.at2(0, 1), this.center, this.at2(1, 0)], - }; - } -} -/** - * Transforms the unit 4d parabola - * P(t) = t² (0, 1, 0, 0) + t (1, 0, 0, 0) + (0, 0, 0, 1) using m and projects - * the result into 3d. This is used for the transform4 implementation of conics. - * The parabola may not cross the vanishing plane of m in the interval - * [tMin, tMax], as that would result in discontinuities. - */ -function parabola4Projection(m, tMin, tMax) { - const w1 = m.m[12]; - const w2 = m.m[13]; - const wc = m.m[15]; - // if the 4d parabola crosses the vanishing plane, it will lead to multiple/infinite hyperbolas, both of which we - // want to avoid. Hence, we must check that the entire interval [tMin, tMax] is on one side of the vanishing plane. - // Checking tMax, tMin and the extremas is enough. - const extremas = ts3dutils.solveCubicReal2(0, w2, w1, wc); - const wx0 = (x) => Number.isFinite(x) ? ts3dutils.snap0(Math.pow(x, 2) * w2 + x * w1 + wc) : sign(w2) * Infinity; - if (wx0(tMin) * wx0(tMax) < 0 || - extremas.some((x) => wx0(x) * (wx0(tMin) + wx0(tMax)) < 0)) { - console.log(m.str); - throw new Error("The entire interval must be on one side of the vanishing plane. P=" + - ts3dutils.toSource(P3.vanishingPlane(m))); - } - if (ts3dutils.eq0(wc)) { - // the following matrix maps a curve C onto itself, with the parameter being inverted: - // C2(t) = C(-1/t). This makes C(0) a real value, which is necessary for the projection calculation. - // the sign inversion is so the tangent direction does not change. - // prettier-ignore - const mm = new ts3dutils.M4(-1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0); - if (!ts3dutils.eq0(w2)) { - return parabola4Projection(m.times(mm), -1 / tMin, -1 / tMax); - } - // wc == w2 == 0 => degenerates to a line: - // C(t) = (t² f2 + t f1 + c) / (t w1) - // C(t) = (t f2 + f1 + c) / (t w2 + w1) - // substitute t = (1/s - w1) / w2 - // C(s) = f2 / w2 + s (f1 - f2 w1 / w2), which is a line - // we can multiply the direction vector by w2 to avoid divisions: - // C(t) = f2 / w2 + s (f1 w2 - f2 w1) - const f1 = m.col(0); - const f2 = m.col(1); - return L3.anchorDirection(f2.p3(), f1.V3().times(f2.w).minus(f2.V3().times(f1.w))); - } - { - // ensure that the bottom-right value = 1. this does not change the 3d result. - m.m[15] !== 1 && (m = m.divScalar(m.m[15])); - const w2 = m.m[13]; - const w1 = m.m[12]; - const wc = m.m[15]; - // we want to split m into X * P, such that X is a transformation with no projective component (first three - // values of the bottom row = 0), which can be handled by the usual .transform() method, and P which has only a - // projective component (only the last row differs from the identity matrix). This simplifies the following - // calculation. X * P = m => X * P * P^-1 = m * P^-1 => X = m * P^-1 - // prettier-ignore - const Pinv = new ts3dutils.M4(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -m.m[12], -m.m[13], -m.m[14], 1); - const X = m.times(Pinv); - // P'(t) = 0 is true for t = 0 and t1. The center is in between P(0) and P(t1), or P(t1) / 2, as P(0) = O - const delta = 4 * w2 * wc - Math.pow(w1, 2); - const center = new ts3dutils.V3((-w1 * wc) / delta, (2 * Math.pow(wc, 2)) / delta, 0); - // f2 is parallel to P'(0), i.e. horizontal. Solve Py(t2) = Cy = Py(t1) / 2 for t2 and simplify - // f2x = Px(t2) - Cx = Px(t2) - Px(t1) / 2 to get the x-component of f2: - const f2x = 1 / sqrt(abs(delta)) / wc; - const f2 = new ts3dutils.V3(f2x, 0, 0); - let result; - if (ts3dutils.eq0(delta)) { - result = new ParabolaCurve(ts3dutils.V3.O, ts3dutils.V3.X, ts3dutils.V3.Y, tMin, tMax); - } - else if (0 < delta) { - const tMapInv = (t) => { - const wt = Math.pow(t, 2) * w2 + t * w1 + wc; - const xi = 1 - - (delta / 2 / Math.pow(wc, 2)) * (Number.isFinite(t) ? Math.pow(t, 2) / wt : 1 / w2); - const xx = acos(xi); - const p = Number.isFinite(t) - ? new ts3dutils.V3(t, Math.pow(t, 2), 0).div(wt) - : new ts3dutils.V3(0, 1 / w2, 0); - const pLC = ts3dutils.M4.forSys(center.negated(), f2, ts3dutils.V3.Z, center) - .inversed() - .transformPoint(p); - const angle = pLC.angleXY(); - if (t > 0 && pLC.y < 0) { - return angle + ts3dutils.TAU; - } - else if (t < 0 && pLC.y > 0) { - return angle - ts3dutils.TAU; - } - return angle; - }; - result = EllipseCurve.andFixTs(center, center.negated(), f2, tMapInv(tMin), tMapInv(tMax)); - } - else { - const tMapInv = (t) => sign(t) * - acosh(1 - - (delta / 2 / Math.pow(wc, 2)) * - (Number.isFinite(t) - ? Math.pow(t, 2) / (Math.pow(t, 2) * w2 + t * w1 + wc) - : 1 / w2)); - result = new HyperbolaCurve(center, center.negated(), f2, tMapInv(tMin), tMapInv(tMax)); - } - return result.transform(X); - } -} - -class ImplicitCurve extends Curve { - constructor(points, tangents, dir = 1, generator, tMin = 1 == dir ? 0 : -(points.length - 1), tMax = 1 == dir ? points.length - 1 : 0) { - super(tMin, tMax); - this.points = points; - this.tangents = tangents; - this.dir = dir; - this.generator = generator; - ts3dutils.assert(points.length > 2); - ts3dutils.assert(0 <= tMin && tMin <= points.length - 1, tMin, points.length); - ts3dutils.assert(0 <= tMax && tMax <= points.length - 1, tMax, points.length); - } - likeCurve(curve) { - throw new Error("Method not implemented."); - } - toSource(rounder = (x) => x) { - return this.generator || super.toSource(rounder); - } - containsPoint(p) { - ts3dutils.assertVectors(p); - return !isNaN(this.pointT(p)); - } - equals(obj) { - return (this == obj || - (Object.getPrototypeOf(obj) == PICurve.prototype && - this.points[0].equals(obj.points[0]) && - this.tangents[0].equals(obj.tangents[0]))); - } - hashCode() { - return ts3dutils.arrayHashCode([this.points[0], this.tangents[0]]); - } - tangentP(pWC) { - ts3dutils.assertVectors(pWC); - ts3dutils.assert(this.containsPoint(pWC), "this.containsPoint(pWC)" + this.containsPoint(pWC)); - const t = this.pointT(pWC); - return this.tangentAt(t); - } - tangentAt(t) { - t = ts3dutils.clamp(t, this.tMin, this.tMax); - return ts3dutils.V3.lerp(this.tangents[floor(t)], this.tangents[ceil(t)], t % 1); - } - at(t) { - ts3dutils.assert(isFinite(t)); - return ts3dutils.V3.lerp(this.points[floor(t)], this.points[ceil(t)], t % 1); - } - getConstructorParameters() { - throw new Error(); - } - roots() { - const allTs = ts3dutils.arrayRange(0, this.points.length); - return [allTs, allTs, allTs]; - } - /** - * @param mesh - * @param res - * @param radius default to 0. Use the shader to achieve dynamic scaling. - * @param pointStep - */ - addToMesh(mesh, res = 4, radius = 0, pointStep = 1) { - const baseNormals = ts3dutils.arrayFromFunction(res, (i) => ts3dutils.V3.polar(1, (ts3dutils.TAU * i) / res)); - const baseVertices = ts3dutils.arrayFromFunction(res, (i) => ts3dutils.V3.polar(radius, (ts3dutils.TAU * i) / res)); - let prevTangent = ts3dutils.V3.Z, prevMatrix = ts3dutils.M4.IDENTITY; - for (let i = 0; i < this.points.length; i += pointStep) { - const start = mesh.vertices.length; - if (0 !== i) { - for (let j = 0; j < res; j++) { - tsgl.pushQuad(mesh.TRIANGLES, true, start - res + j, start + j, start - res + ((j + 1) % res), start + ((j + 1) % res)); - } - } - const point = this.points[i], tangent = this.tangents[i]; - const tangentMatrix = ts3dutils.M4.rotateAB(prevTangent, tangent).times(prevMatrix); - mesh.normals.push(...tangentMatrix.transformedVectors(baseNormals)); - const baseMatrix = ts3dutils.M4.translate(point).times(tangentMatrix); - mesh.vertices.push(...baseMatrix.transformedPoints(baseVertices)); - prevTangent = tangent; - prevMatrix = tangentMatrix; - } - } - rootsApprox() { - const roots = [[], [], []]; - const points = this.points; - let lastDiff = points[1].minus(points[0]); - for (let i = 2; i < points.length; i++) { - const diff = points[i].minus(points[i - 1]); - for (let dim = 0; dim < 3; dim++) { - if (Math.sign(lastDiff.e(dim)) != Math.sign(diff.e(dim))) { - roots[dim].push(i); - } - } - lastDiff = diff; - } - return roots; - } - pointT(pWC) { - const startT = ts3dutils.withMax(ts3dutils.arrayRange(floor(this.tMin), ceil(this.tMax), 1), (t) => -pWC.distanceTo(this.points[t])); - if (undefined === startT) - throw new Error(); - if (this.points[startT].like(pWC)) - return startT; - const a = max(0, startT - 1), b = min(this.points.length - 1, startT + 1); - const tangent = this.tangentAt(startT); - const f = (t) => this.at(t).to(pWC).dot(tangent); - // const df = (t: number) => -this.tangentAt(clamp(t, 0, this.points.length - 1)).dot(tangent) - //checkDerivate(f, df, 0, this.points.length - 2, 3) - const t = ts3dutils.bisect(f, a, b, 32); - if (!isFinite(t) || !ts3dutils.eq0(this.at(t).distanceTo(pWC))) { - return NaN; - } - return t; - } -} -ImplicitCurve.prototype.tIncrement = 1; -/** - * isInfosWithLine for an ImplicitCurve defined as the intersection of two surfaces. - */ -function surfaceIsICurveIsInfosWithLine(surface1, surface2, anchorWC, dirWC, tMin, tMax, lineMin, lineMax) { - const line = new L3(anchorWC, dirWC.unit()); - const psTs = surface1.isTsForLine(line); - const isTs = surface2.isTsForLine(line); - const commonTs = psTs.filter((psT) => isTs.some((isT) => ts3dutils.eq(psT, isT))); - const commonTInfos = commonTs.map((t) => ({ - tThis: 0, - tOther: t / dirWC.length(), - p: line.at(t), - })); - const result = commonTInfos.filter((info) => this.containsPoint(info.p)); - result.forEach((info) => (info.tThis = this.pointT(info.p))); - return result; -} - -/** - * Bezier curve with degree 3. - */ -class BezierCurve extends Curve { - constructor(p0, p1, p2, p3, tMin = -0.1, tMax = 1.1) { - super(tMin, tMax); - ts3dutils.assertVectors(p0, p1, p2, p3); - ts3dutils.assert(isFinite(tMin) && isFinite(tMax)); - //assert(!L3.throughPoints(p0, p3).containsPoint(p1) || !L3.throughPoints(p0, p3).containsPoint(p2)) - this.p0 = p0; - this.p1 = p1; - this.p2 = p2; - this.p3 = p3; - } - get points() { - return [this.p0, this.p1, this.p2, this.p3]; - } - /** - * Returns a new BezierCurve with curve.at(x) == V(x, ax³ + bx² + cx + d, 0). - */ - static graphXY(a, b, c, d, tMin, tMax) { - // d = p0y - // c = -3 p0y + 3 p1y => p1y = c/3 + p0y - // b = 3 p0y - 6 p1y + 3 p2y => p2y = b/3 - p0y + 2 p1y - // a = -p0y + 3 p1y -3 p2y + p3y => p3y = a + p0y - 3 p1y + 3 p2y - const p0y = d; - const p1y = c / 3 + p0y; - const p2y = b / 3 - p0y + 2 * p1y; - const p3y = a + p0y - 3 * p1y + 3 * p2y; - return new BezierCurve(ts3dutils.V(0, p0y), ts3dutils.V(1 / 3, p1y), ts3dutils.V(2 / 3, p2y), ts3dutils.V(1, p3y), tMin, tMax); - } - static quadratic(a, b, c, tMin = 0, tMax = 1) { - const line = L3.throughPoints(a, c); - if (line.containsPoint(b)) { - return line; - } - else { - // p1 = 1/3 a + 2/3 b - // p2 = 1/3 c + 2/3 b - return new BezierCurve(a, b.times(2).plus(a).div(3), b.times(2).plus(c).div(3), c, tMin, tMax); - } - } - /** - * Returns a bezier curve which approximates a CCW unit circle arc starting at V3.X of angle phi - * phi <= PI / 2 is recommended - * - * Formula from here: https://pomax.github.io/bezierinfo/#circles_cubic - */ - static approximateUnitArc(phi) { - const f = (4 / 3) * Math.tan(phi / 4); - return new BezierCurve(ts3dutils.V3.X, new ts3dutils.V3(1, f, 0), new ts3dutils.V3(cos(phi) + f * sin(phi), sin(phi) - f * cos(phi), 0), ts3dutils.V3.sphere(phi, 0), 0, 1); - } - getConstructorParameters() { - return [this.p0, this.p1, this.p2, this.p3]; - } - at(t) { - // = s^3 p0 + 3 s^2 t p1 + 3 s t^2 p2 + t^3 p3 - ts3dutils.assertNumbers(t); - const p0 = this.p0, p1 = this.p1, p2 = this.p2, p3 = this.p3; - const s = 1 - t, c0 = s * s * s, c1 = 3 * s * s * t, c2 = 3 * s * t * t, c3 = t * t * t; - return new ts3dutils.V3(p0.x * c0 + p1.x * c1 + p2.x * c2 + p3.x * c3, p0.y * c0 + p1.y * c1 + p2.y * c2 + p3.y * c3, p0.z * c0 + p1.z * c1 + p2.z * c2 + p3.z * c3); - } - /** - * s := (1 - t) - * at(t) := s³ p0 + 3 s² t p1 + 3 s t² p2 + t³ p3 - * tangent(t) := 3 s² (p1 - p0) + 6 s t (p2 - p1) + 3 t² (p3 - p2) - * := 3 (1 - t)² (p1 - p0) + 6 (1 - t) t (p2 - p1) + 3 t² (p3 - p2) - * := 3 (1 - 2 t + t²) (p1 - p0) + 6 (t - t²) (p2 - p1) + 3 t² (p3 - p2) - * := (3 (p3 - p2) - 6 (p2 - p1) + 3 (p1 - p0)) t²* - * + (-6 (p1 - p0) + (p2 - p1)) t - * + 3 (p1 - p0) - */ - tangentAt(t) { - ts3dutils.assertNumbers(t); - const p0 = this.p0, p1 = this.p1, p2 = this.p2, p3 = this.p3; - const s = 1 - t, c01 = 3 * s * s, c12 = 6 * s * t, c23 = 3 * t * t; - return new ts3dutils.V3((p1.x - p0.x) * c01 + (p2.x - p1.x) * c12 + (p3.x - p2.x) * c23, (p1.y - p0.y) * c01 + (p2.y - p1.y) * c12 + (p3.y - p2.y) * c23, (p1.z - p0.z) * c01 + (p2.z - p1.z) * c12 + (p3.z - p2.z) * c23); - } - ddt(t) { - ts3dutils.assertNumbers(t); - const p0 = this.p0, p1 = this.p1, p2 = this.p2, p3 = this.p3; - const c012 = 6 * (1 - t), c123 = 6 * t; - return new ts3dutils.V3((p2.x - 2 * p1.x + p0.x) * c012 + (p3.x - 2 * p2.x + p1.x) * c123, (p2.y - 2 * p1.y + p0.y) * c012 + (p3.y - 2 * p2.y + p1.y) * c123, (p2.z - 2 * p1.z + p0.z) * c012 + (p3.z - 2 * p2.z + p1.z) * c123); - } - normalP(t) { - const tangent = this.tangentAt(t); - const rot = tangent.cross(this.ddt(t)); - return rot.cross(tangent); - } - isTsWithPlane(planeWC) { - ts3dutils.assertInst(P3, planeWC); - /* - We are solving for t: - n := plane.normal1 - this.at(t) DOT n == plane.w // according to plane definition - (a t³ + b t² + c t + d) DOT n == plane.w // bezier curve as cubic equation - (a DOT n) t³ + (b DOT n) t³ + (c DOT n) t + d DOT n - plane.w == 0 // multiply out DOT n, minus plane.w - */ - const { p0, p1, p2, p3 } = this; - const n = planeWC.normal1; - const a = p1.minus(p2).times(3).minus(p0).plus(p3); - const b = p0.plus(p2).times(3).minus(p1.times(6)); - const c = p1.minus(p0).times(3); - const d = p0; - return ts3dutils.solveCubicReal2(a.dot(n), b.dot(n), c.dot(n), d.dot(n) - planeWC.w).filter((t) => ts3dutils.between(t, this.tMin, this.tMax)); - } - isTsWithSurface(surfaceWC) { - if (surfaceWC instanceof CylinderSurface) { - const projPlane = new P3(surfaceWC.dir.unit(), 0); - const projThis = this.project(projPlane); - const projEllipse = surfaceWC.baseCurve.project(projPlane); - return projEllipse - .isInfosWithBezier2D(projThis) - .map((info) => info.tOther); - } - return super.isTsWithSurface(surfaceWC); - } - likeCurve(curve) { - return (this == curve || - (ts3dutils.hasConstructor(curve, BezierCurve) && - this.p0.like(curve.p0) && - this.p1.like(curve.p1) && - this.p2.like(curve.p2) && - this.p3.like(curve.p3))); - } - equals(obj) { - return (this == obj || - (ts3dutils.hasConstructor(obj, BezierCurve) && - this.p0.equals(obj.p0) && - this.p1.equals(obj.p1) && - this.p2.equals(obj.p2) && - this.p3.equals(obj.p3))); - } - hashCode() { - let hashCode = 0; - hashCode = hashCode * 31 + this.p0.hashCode(); - hashCode = hashCode * 31 + this.p1.hashCode(); - hashCode = hashCode * 31 + this.p2.hashCode(); - hashCode = hashCode * 31 + this.p3.hashCode(); - return hashCode | 0; - } - /** - * Checks if this curve is colinear to the passed curve, i.e. - * for every t:number there exists a s:number with this.at(t) = curve.at(s) - */ - isColinearTo(curve) { - if (this === curve || this.likeCurve(curve)) - return true; - if (!(curve instanceof BezierCurve)) - return false; - // first, find out where/if curve.p0 and curve.p3 are on this - // then split this at curve.p0 --> curve.p3 to compare points p1 and p2 - let curveP0T, curveP3T; - // assign in if condition to exploit short-circuit - if (isNaN((curveP0T = this.pointT(curve.p0))) || - isNaN((curveP3T = this.pointT(curve.p3)))) { - return false; - } - let thisSplit; - if (ts3dutils.eq(1, curveP0T)) { - // this.split(curveP0T).right is degenerate in this case, so we need to handle it separately - // this.split(curveP3T): 0 --> curveP3T --> 1 - // .right: curveP3T --> 1 - // .reversed(): 1 --> curveP3T - thisSplit = this.split(curveP3T)[1].reversed(); - } - else { - // curveP3T describes the point on this - // adjust it so it describes the same point on this.split(curveP0T).right - // this: 0 p0t p3t 1 - // | | | | - // this.split(curveP0T).right: 0 p3tad 1 - const curveP3Tadjusted = (curveP3T - curveP0T) / (1 - curveP0T); - thisSplit = this.split(curveP0T)[1].split(curveP3Tadjusted)[0]; - } - return curve.likeCurve(thisSplit); - } - selectPart(t0, t1) { - const t1Adjusted = (t1 - t0) / (1 - t0); - return this.split(t0)[1].split(t1Adjusted)[0]; - } - reversed() { - return new BezierCurve(this.p3, this.p2, this.p1, this.p0, 1 - this.tMax, 1 - this.tMin); - } - getCoefficients() { - const { p0, p1, p2, p3 } = this; - // calculate cubic equation coefficients - // a t³ + b t² + c t + d = 0 - // multiplying out the cubic Bézier curve equation gives: - // a = -p0 + 3 p1 - 3 p2 + p3 - // b = 3 p0 - 6 p1 + 3 p2 - // c = -3 p0 + 3 p1 - // d = p0 - p - const a = p1.minus(p2).times(3).minus(p0).plus(p3); - const b = p0.plus(p2).times(3).minus(p1.times(6)); - const c = p1.minus(p0).times(3); - const d = p0; - return [a, b, c, d]; - } - tangentCoefficients() { - const { p0, p1, p2, p3 } = this; - const p01 = p1.minus(p0), p12 = p2.minus(p1), p23 = p3.minus(p2); - const a = p01.plus(p23).times(3).minus(p12.times(6)); - const b = p12.minus(p01).times(6); - const c = p01.times(3); - return [ts3dutils.V3.O, a, b, c]; - } - pointT2(p, tMin = this.tMin, tMax = this.tMax) { - const t = this.closestTToPoint(p, undefined, tMin, tMax); - ts3dutils.assert(this.at(t).like(p)); - return t; - } - pointT(p) { - const { p0, p1, p2, p3 } = this; - // calculate cubic equation coefficients - // a t³ + b t² + c t + d = 0 - // multiplying out the cubic Bézier curve equation gives: - // a = -p0 + 3 p1 - 3 p2 + p3 - // b = 3 p0 - 6 p1 + 3 p2 - // c = -3 p0 + 3 p1 - // d = p0 - p - const a = p1.minus(p2).times(3).minus(p0).plus(p3); - const b = p0.plus(p2).times(3).minus(p1.times(6)); - const c = p1.minus(p0).times(3); - const d = p0.minus(p); - // a t³ + b t² + c t + d = 0 is 3 cubic equations, some of which can be degenerate - const maxDim = ts3dutils.NLA_PRECISION < a.maxAbsElement() - ? a.maxAbsDim() - : ts3dutils.NLA_PRECISION < b.maxAbsElement() - ? b.maxAbsDim() - : ts3dutils.NLA_PRECISION < c.maxAbsElement() - ? c.maxAbsDim() - : ts3dutils.assertNever(); - const results = ts3dutils.solveCubicReal2(a.e(maxDim), b.e(maxDim), c.e(maxDim), d.e(maxDim)).filter((t) => this.at(t).like(p)); - if (0 == results.length) - return NaN; - if (1 == results.length) - return results[0]; - throw new Error("multiple intersection " + this.toString() + p.sce); - } - pointT3(p) { - const { p0, p1, p2, p3 } = this; - // calculate cubic equation coefficients - // a t³ + b t² + c t + d = 0 - // multiplying out the cubic Bézier curve equation gives: - // a = -p0 + 3 p1 - 3 p2 + p3 - // b = 3 p0 - 6 p1 + 3 p2 - // c = -3 p0 + 3 p1 - // d = p0 - p - const a = p1.minus(p2).times(3).minus(p0).plus(p3).els(); - const b = p0.plus(p2).times(3).minus(p1.times(6)).els(); - const c = p1.minus(p0).times(3).els(); - const d = p0.minus(p).els(); - let results = undefined; - // assume passed point is on curve and that curve does not self-intersect, - // i.e. there is exactly one correct result for t - // try to find a single result in the x-dimension, if multiple are found, - // filter them by checking the other dimensions - for (let dim = 0; dim < 3; dim++) { - if (ts3dutils.eq0(a[dim]) && ts3dutils.eq0(b[dim]) && ts3dutils.eq0(c[dim])) { - // for case x: - // ax == bx == cx == 0 => x(t) = dx - // x value is constant - // if x == 0 for all t, this does not limit the result, otherwise, there is no result, i.e - // the passed point is not on the curve - if (!ts3dutils.eq0(d[dim])) - return NaN; - } - else { - const newResults = ts3dutils.solveCubicReal2(a[dim], b[dim], c[dim], d[dim]); - if (0 == newResults.length) - return NaN; - if (1 == newResults.length) - return newResults[0]; - if (results) { - results = results.filter((t) => newResults.some((t2) => ts3dutils.eq(t, t2))); - if (0 == results.length) - return NaN; - if (1 == results.length) - return results[0]; - } - else { - results = newResults; - } - } - } - throw new Error("multiple intersection " + results + this.toString() + p.sce); - } - transform(m4) { - // perspective projection turn bezier curve into rational spline - ts3dutils.assert(m4.isNoProj(), m4.str); - return new BezierCurve(m4.transformPoint(this.p0), m4.transformPoint(this.p1), m4.transformPoint(this.p2), m4.transformPoint(this.p3), this.tMin, this.tMax); - } - transform4(m4) { - if (m4.isNoProj()) { - return this.transform(m4); - } - else { - return this.toNURBS().transform4(m4); - } - } - isClosed() { - return this.p0.like(this.p3); - } - isQuadratic() { - return this.p0.lerp(this.p1, 1.5).like(this.p3.lerp(this.p2, 1.5)); - } - debugInfo() { - return { - lines: [0, 1, 1, 2, 2, 3].map((i) => this.points[i]), - points: this.points, - }; - } - split(t) { - // do de Casteljau's algorithm at t, the resulting points are the points needed to create 2 new curves - const s = 1 - t; - const { p0, p1, p2, p3 } = this; - /* - p3 // n3 - b01 = s p0 + t p1 - b11 = s p1 + t p2 - b21 = s p2 + t p3 // n2 - b02 = s b01 + t b11 - b12 = s b11 + t b21 // n1 - b03 = s b02 + t b12 // n0 - - c01 = - */ - const b01 = p0.times(s).plus(p1.times(t)), b11 = p1.times(s).plus(p2.times(t)), b21 = p2.times(s).plus(p3.times(t)); - const b02 = b01.times(s).plus(b11.times(t)), b12 = b11.times(s).plus(b21.times(t)); - const b03 = b02.times(s).plus(b12.times(t)); - return [ - new BezierCurve(p0, b01, b02, b03), - new BezierCurve(b03, b12, b21, p3), - ]; - } - containsPoint(p) { - return isFinite(this.pointT(p)); - } - roots() { - /** - * := (3 (p3 - p2) - 6 (p2 - p1) + 3 (p1 - p0)) t²* - * + (-6 (p1 - p0) + 6 (p2 - p1)) t - * + 3 (p1 - p0) - * */ - const { p0, p1, p2, p3 } = this; - const p01 = p1.minus(p0), p12 = p2.minus(p1), p23 = p3.minus(p2); - const a = p01.plus(p23).times(3).minus(p12.times(6)); - const b = p12.minus(p01).times(6); - const c = p01.times(3); - return ts3dutils.arrayFromFunction(3, (dim) => ts3dutils.solveCubicReal2(0, a.e(dim), b.e(dim), c.e(dim))); - } - isInfosWithLine(anchorWC, dirWC, tMin, tMax, lineMin = -100000, lineMax = 100000) { - // const dirLength = dirWC.length() - // // TODO: no: - // let result = Curve.ispsRecursive(this, this.tMin, this.tMax, new L3(anchorWC, dirWC.unit()), lineMin, lineMax) - // result = fuzzyUniquesF(result, info => info.tOther) - // result.forEach(info => (info.tOther /= dirLength)) - // return result - // looking for this.at(t) == line.at(s) - // this.at(t).x == anchorWC.x + dirWC.x * s - // (this.at(t).x - anchorWC.x) / dirWC.x == s (analogue for y and z) (1x, 1y, 1z) - // (1x) - (1y): - // (this.at(t).x - anchorWC.x) / dirWC.x - (this.at(t).y - anchorWC.y) / dirWC.y == 0 - // (this.at(t).x - anchorWC.x) * dirWC.y - (this.at(t).y - anchorWC.y) * dirWC.x == 0 (2) - // cubic equation params (see #pointT): - const { p0, p1, p2, p3 } = this; - const a = p1.minus(p2).times(3).minus(p0).plus(p3); - const v1 = ts3dutils.V3.UNITS[a.minAbsDim()]; - const testPlane = P3.forAnchorAndPlaneVectors(anchorWC, dirWC, v1.isParallelTo(dirWC) ? a : v1); - return this.isTsWithPlane(testPlane) - .map((tThis) => { - const p = this.at(tThis); - return { tThis, tOther: L3.pointT(anchorWC, dirWC, p), p }; - }) - .filter((info) => L3.containsPoint(anchorWC, dirWC, info.p)); - } - closestPointToLine(line, tMin, tMax) { - // (this(t)-line(s)) * line.dir == 0 (1) - // (this(t)-line(s)) * this.tangentAt(t) == 0 (2) - // this(t) * line.dir - line(s) * line.dir == 0 - // this(t) * line.dir - line.anchor * line.dir - s line.dir * line.dir == 0 - // this(t) * line.dir - line.anchor * line.dir == s (3) - // insert (3) in (2) - // (this(t)-line(this(t) * line.dir - line.anchor * line.dir)) * this.tangentAt(t) == 0 (4) - // (4) is a 5th degree polynomial, solve numerically - tMin = isFinite(tMin) ? tMin : this.tMin; - tMax = isFinite(tMax) ? tMax : this.tMax; - const anchorDotDir1 = line.anchor.dot(line.dir1); - const f = (t) => { - const atT = this.at(t); - return atT - .minus(line.at(atT.dot(line.dir1) - anchorDotDir1)) - .dot(this.tangentAt(t)); - }; - const STEPS = 32; - const startT = ts3dutils.withMax(ts3dutils.arrayFromFunction(STEPS, (i) => tMin + ((tMax - tMin) * i) / STEPS), (t) => -f(t)); - return ts3dutils.newtonIterate1d(f, startT, 8); - } - /** - * - * @param bezier - * @param tMin - * @param tMax - * @param sMin - * @param {number=} sMax - * @returns - */ - isInfosWithBezier3(bezier, tMin, tMax, sMin, sMax) { - const handleStartTS = (startT, startS) => { - if (!result.some((info) => ts3dutils.eq(info.tThis, startT) && ts3dutils.eq(info.tOther, startS))) { - const f1 = (t, s) => this.tangentAt(t).dot(this.at(t).minus(bezier.at(s))); - const f2 = (t, s) => bezier.tangentAt(s).dot(this.at(t).minus(bezier.at(s))); - // f = (b1, b2, t1, t2) = b1.tangentAt(t1).dot(b1.at(t1).minus(b2.at(t2))) - const fdt1 = (b1, b2, t1, t2) => b1.ddt(t1).dot(b1.at(t1).minus(b2.at(t2))) + - b1.tangentAt(t1).squared(); - const fdt2 = (b1, b2, t1, t2) => -b1.tangentAt(t1).dot(b2.tangentAt(t2)); - const ni = ts3dutils.newtonIterate2dWithDerivatives(f1, f2, startT, startS, 16, fdt1.bind(undefined, this, bezier), fdt2.bind(undefined, this, bezier), (t, s) => -fdt2(bezier, this, s, t), (t, s) => -fdt1(bezier, this, s, t)); - result.push({ tThis: ni.x, tOther: ni.y, p: this.at(ni.x) }); - } - }; - tMin = undefined !== tMin ? tMin : this.tMin; - tMax = undefined !== tMax ? tMax : this.tMax; - sMin = undefined !== sMin ? sMin : bezier.tMin; - sMax = undefined !== sMax ? sMax : bezier.tMax; - // stack of indices: - const indices = [tMin, tMax, sMin, sMax]; - const result = []; - while (indices.length) { - const i = indices.length - 4; - const tMin = indices[i], tMax = indices[i + 1], sMin = indices[i + 2], sMax = indices[i + 3]; - indices.length -= 4; - const thisAABB = this.getAABB(tMin, tMax); - const otherAABB = bezier.getAABB(sMin, sMax); - // console.log(tMin, tMax, sMin, sMax, thisAABB.sce, otherAABB.sce) - if (thisAABB && otherAABB && thisAABB.intersectsAABB2d(otherAABB)) { - const tMid = (tMin + tMax) / 2; - const sMid = (sMin + sMax) / 2; - const EPS = 0.00001; - if (tMax - tMin < EPS || sMax - sMin < EPS) { - console.log(tMin, tMax, sMin, sMax); - console.log(thisAABB.sce); - console.log(otherAABB.sce); - console.log(tMid, sMid); - handleStartTS(tMid, sMid); - } - else { - indices.push(tMin, tMid, sMin, sMid, tMin, tMid, sMid, sMax, tMid, tMax, sMin, sMid, tMid, tMax, sMid, sMax); - } - } - } - return result; - } - isInfosWithBezier(bezier, tMin, tMax, sMin, sMax) { - tMin = undefined !== tMin ? tMin : this.tMin; - tMax = undefined !== tMax ? tMax : this.tMax; - sMin = undefined !== sMin ? sMin : bezier.tMin; - sMax = undefined !== sMax ? sMax : bezier.tMax; - ts3dutils.assertf(() => tMin < tMax); - ts3dutils.assertf(() => sMin < sMax); - const result = []; - const likeCurves = this.likeCurve(bezier), colinearCurves = this.isColinearTo(bezier); - if (likeCurves || colinearCurves) { - if (!likeCurves) { - // only colinear - // recalculate sMin and sMax so they are valid on this, from then on we can ignore bezier - sMin = this.pointT(bezier.at(sMin)); - sMax = this.pointT(bezier.at(sMax)); - } - tMin = Math.min(tMin, sMin); - tMax = Math.max(tMax, sMax); - const splits = ts3dutils.fuzzyUniques(ts3dutils.concatenated(this.roots()).filter(isFinite).concat([tMin, tMax])).sort(ts3dutils.MINUS); - //const aabbs = arrayFromFunction(splits.length - 1, i => this.getAABB(splits[i], splits[i + 1])) - Array.from(ts3dutils.combinations(splits.length - 1)).forEach(({ i, j }) => { - // adjacent curves can't intersect - if (Math.abs(i - j) > 2) { - // console.log(splits[i], splits[i + 1], splits[j], splits[j + 1], aabbs[i], aabbs[j]) - //findRecursive(splits[i], splits[i + 1], splits[j], splits[j + 1], aabbs[i], aabbs[j]) - result.push(...Curve.ispsRecursive(this, splits[i], splits[i + 1], bezier, splits[j], splits[j + 1])); - } - }); - } - else { - return Curve.ispsRecursive(this, tMin, tMax, bezier, sMin, sMax); - } - return result; - } - selfIntersectionsInfo() { - return this.isInfosWithBezier(this); - } - isInfosWithCurve(curve) { - if (curve instanceof L3) { - return this.isInfosWithLine(curve.anchor, curve.dir1, curve.tMin, curve.tMax); - } - if (curve instanceof BezierCurve) { - return this.isInfosWithBezier(curve); - } - return curve - .isInfosWithCurve(this) - .map(({ tThis, tOther, p }) => ({ tThis: tOther, tOther: tThis, p })); - } - /** - * Approximate this bezier curve with a number of circular segments. This curve is recursively split in half until - * segments are close enough (relative error < REL_ERR in two test points) to an arc which goes through the start, - * end and mid points of the segment. - * @returns each EllipseCurve is circular and their tMin and tMax respectively define their start and end points. - * @param t0 Start parameter of segment which should be approximated. - * @param t1 End parameter of segment which should be approximated. - * @param REL_ERROR max allowable relative error. - * @param result Resulting circle arcs are stored in this array. Mainly used by the recursion. - */ - circleApprox(t0 = this.tMin, t1 = this.tMax, REL_ERROR = 1 / 1024, result = []) { - const a = this.at(t0), b = this.at(t1), tMid = (t0 + t1) / 2, pMid = this.at(tMid), abLine = L3.throughPoints(a, b); - if (!abLine.containsPoint(pMid) && - ts3dutils.between(abLine.pointT(pMid), 0, abLine.pointT(b))) { - const arc = EllipseCurve.circleThroughPoints(a, pMid, b), arcRadius = arc.f1.length(), pTest1 = this.at(ts3dutils.lerp(t0, t1, 0.25)), pTest2 = this.at(ts3dutils.lerp(t0, t1, 0.75)); - if (abs(arc.center.distanceTo(pTest1) / arcRadius - 1) <= REL_ERROR && - abs(arc.center.distanceTo(pTest2) / arcRadius - 1) <= REL_ERROR) { - result.push(arc); - return result; - } - } - this.circleApprox(t0, tMid, REL_ERROR, result); - this.circleApprox(tMid, t1, REL_ERROR, result); - return result; - } - toNURBS() { - return NURBS.fromBezier(this); - } -} -/** - * https://en.wikipedia.org/wiki/Cubic_function#/media/File:Graph_of_cubic_polynomial.svg - */ -BezierCurve.EX2D = BezierCurve.graphXY(2, -3, -3, 2); -BezierCurve.EX3D = new BezierCurve(ts3dutils.V3.O, ts3dutils.V(-0.1, -1, 1), ts3dutils.V(1.1, 1, 1), ts3dutils.V3.X); -BezierCurve.QUARTER_CIRCLE = BezierCurve.approximateUnitArc(PI / 2); -BezierCurve.prototype.hlol = Curve.hlol++; -BezierCurve.prototype.tIncrement = 1 / 80; - -/** - * x² - y² = 1 - * C(t) = center + f1 * cosh(t) + f2 * sinh(t) - */ -class HyperbolaCurve extends XiEtaCurve { - constructor(center, f1, f2, tMin = -7, tMax = 7) { - super(center, f1, f2, tMin, tMax); - } - static XYLCValid(pLC) { - return pLC.x > 0 && ts3dutils.eq(1, pLC.x * pLC.x - pLC.y * pLC.y); - } - static XYLCPointT(pLC) { - return Math.asinh(pLC.y); - } - /** - * http://www.wolframalpha.com/input/?i=x%C2%BRep-y%C2%BRep%3D1,ax%2Bby%3Dc - * Minor empiric test shows asinh(eta) consistently gets more accurate results than atanh(eta/xi) - */ - static intersectionUnitLine(a, b, c) { - if (ts3dutils.eq0(b)) { - const sqrtVal = ts3dutils.snap0(Math.pow(c, 2) / Math.pow(a, 2) - 1); - if (sqrtVal < 0 || c * a < 0) { - return []; - } - else if (sqrtVal == 0) { - return [0]; - } - const eta1 = Math.sqrt(sqrtVal); - return [-Math.asinh(eta1), Math.asinh(eta1)]; - } - else if (ts3dutils.eq(abs(a), abs(b))) { - if (ts3dutils.le(c * a, 0)) { - return []; - } - const eta = (sign(a * b) * (Math.pow(c, 2) - Math.pow(a, 2))) / 2 / a / c; - return [Math.asinh(eta)]; - } - else { - const sqrtVal = ts3dutils.snap0(Math.pow(b, 2) * (-(Math.pow(a, 2)) + Math.pow(b, 2) + Math.pow(c, 2))); - if (sqrtVal < 0) { - return []; - } - const xi1 = (a * c - Math.sqrt(sqrtVal)) / (Math.pow(a, 2) - Math.pow(b, 2)); - const xi2 = (a * c + Math.sqrt(sqrtVal)) / (Math.pow(a, 2) - Math.pow(b, 2)); - const eta1 = (Math.pow(b, 2) * c - a * Math.sqrt(sqrtVal)) / (b * (Math.pow(b, 2) - Math.pow(a, 2))); - const eta2 = (Math.pow(b, 2) * c + a * Math.sqrt(sqrtVal)) / (b * (Math.pow(b, 2) - Math.pow(a, 2))); - return [xi1 > 0 && Math.asinh(eta1), xi2 > 0 && Math.asinh(eta2)].filter((x) => x !== false); - } - } - at(t) { - ts3dutils.assertNumbers(t); - // = center + f1 cosh t + f2 sinh t - return this.center - .plus(this.f1.times(Math.cosh(t))) - .plus(this.f2.times(Math.sinh(t))); - } - toString() { - return `${this.center} + ${this.f1} * cosh(t) + ${this.f2} * sinh(t)`; - } - tangentAt(t) { - ts3dutils.assertNumbers(t); - // = f1 sinh t + f2 cosh t - return this.f1.times(Math.sinh(t)).plus(this.f2.times(Math.cosh(t))); - } - tangentAt2(xi, eta) { - ts3dutils.assertNumbers(xi, eta); - // = f1 eta + f2 xi - return this.f1.times(eta).plus(this.f2.times(xi)); - } - ddt(t) { - ts3dutils.assertNumbers(t); - return this.f1.times(Math.cosh(t)).plus(this.f2.times(Math.sinh(t))); - } - isColinearTo(curve) { - if (!ts3dutils.hasConstructor(curve, HyperbolaCurve)) - return false; - if (!curve.center || !this.center.like(curve.center)) { - return false; - } - if (this === curve) { - return true; - } - const { f1: f1, f2: f2 } = this.rightAngled(), { f1: c1, f2: c2 } = curve.rightAngled(); - return (ts3dutils.eq(f1.squared(), Math.abs(f1.dot(c1))) && - ts3dutils.eq(f2.squared(), Math.abs(f2.dot(c2)))); - } - reversed() { - return new HyperbolaCurve(this.center, this.f1, this.f2.negated(), -this.tMax, -this.tMin); - } - rightAngled() { - const f1 = this.f1, f2 = this.f2, a = f1.dot(f2), b = f2.squared() + f1.squared(); - if (ts3dutils.eq0(a)) { - return this; - } - const g1 = 2 * a, g2 = b + Math.sqrt(b * b - 4 * a * a); - const { x1: xi, y1: eta } = intersectionUnitHyperbolaLine(g1, g2, 0); - return new HyperbolaCurve(this.center, f1.times(xi).plus(f2.times(eta)), f1.times(eta).plus(f2.times(xi))); - } - eccentricity() { - const mainAxes = this.rightAngled(); - const f1length = mainAxes.f1.length(), f2length = mainAxes.f1.length(); - const [a, b] = f1length > f2length ? [f1length, f2length] : [f2length, f1length]; - return Math.sqrt(1 + (b * b) / a / a); - } - roots() { - // tangent(t) = f1 sinh t + f2 cosh t = 0 - // tangentAt2(xi, eta) = f1 eta + f2 xi = V3.O - // xi² - eta² = 1 (by def for hyperbola) - return ts3dutils.arrayFromFunction(3, (dim) => { - const a = this.f2.e(dim), b = this.f1.e(dim); - return HyperbolaCurve.intersectionUnitLine(a, b, 0); - }); - } - transform4(m4) { - const tMap = (t) => sign(t) * min(10, sqrt(-(1 - cosh(t)) / (1 + cosh(t)))); - // prettier-ignore - const parabolaToUnitHyperbola = new ts3dutils.M4(0, 1, 0, 1, 2, 0, 0, 0, 0, 0, 1, 0, 0, -1, 0, 1); - return parabola4Projection(ts3dutils.M4.product(m4, this.matrix, parabolaToUnitHyperbola), tMap(this.tMin), tMap(this.tMax)); - } -} -HyperbolaCurve.XY = new HyperbolaCurve(ts3dutils.V3.O, ts3dutils.V3.X, ts3dutils.V3.Y); -HyperbolaCurve.prototype.tIncrement = PI / 16; - -/** - * A 3-dimensional line. Defined by an anchor and a normalized direction vector. - */ -class L3 extends Curve { - constructor(anchor, // line anchor - dir1, // normalized line dir - tMin = -4096, tMax = 4096) { - super(tMin, tMax); - this.anchor = anchor; - this.dir1 = dir1; - ts3dutils.assertVectors(anchor, dir1); - ts3dutils.assert(dir1.hasLength(1), "dir must be unit" + dir1); - ts3dutils.assertf(() => !Number.isNaN(anchor.x)); - } - isTsWithSurface(surface) { - return surface.isTsForLine(this); - } - static throughPoints(anchor, b, tMin = 0, tMax) { - const dir = b.minus(anchor); - return new L3(anchor, dir.unit(), tMin, undefined !== tMax ? tMax : dir.length()); - } - static anchorDirection(anchor, dir, min = 0, max = dir.length()) { - const dir1 = dir.unit(); - return new L3(anchor, dir1, "number" == typeof min ? min : min.minus(anchor).dot(dir1), "number" == typeof max ? max : max.minus(anchor).dot(dir1)); - } - static pointT(anchor, dir, x) { - ts3dutils.assertVectors(anchor, dir, x); - return x.minus(anchor).dot(dir) / dir.squared(); - } - static at(anchor, dir, t) { - return anchor.plus(dir.times(t)); - } - /** - * Create new line which is the intersection of two planes. Throws error if planes are parallel. - * @param plane1 - * @param plane2 - */ - static fromPlanes(plane1, plane2) { - ts3dutils.assertInst(P3, plane1, plane2); - const dir = plane1.normal1.cross(plane2.normal1); - const length = dir.length(); - if (length < 1e-10) { - throw new Error("Parallel planes"); - } - return plane1.intersectionWithPlane(plane2); - } - static containsPoint(anchor, dir, p) { - const closestT = L3.pointT(anchor, dir, p); - const distance = L3.at(anchor, dir, closestT).distanceTo(p); - return ts3dutils.eq0(distance); - } - roots() { - return [[], [], []]; - } - containsPoint(p) { - ts3dutils.assertVectors(p); - const dist = this.distanceToPoint(p); - ts3dutils.assertNumbers(dist); - return ts3dutils.eq0(dist); - } - likeCurve(curve) { - return (this == curve || - (ts3dutils.hasConstructor(curve, L3) && - this.anchor.like(curve.anchor) && - this.dir1.like(curve.dir1))); - } - equals(obj) { - return (this == obj || - (Object.getPrototypeOf(obj) == L3.prototype && - this.anchor.equals(obj.anchor) && - this.dir1.equals(obj.dir1))); - } - isColinearTo(obj) { - return (obj instanceof L3 && - this.containsPoint(obj.anchor) && - ts3dutils.eq(1, Math.abs(this.dir1.dot(obj.dir1)))); - } - distanceToLine(line) { - ts3dutils.assertInst(L3, line); - if (this.isParallelToLine(line)) { - return this.distanceToPoint(line.anchor); - } - const dirCross1 = this.dir1.cross(line.dir1).unit(); - const anchorDiff = this.anchor.minus(line.anchor); - return Math.abs(anchorDiff.dot(dirCross1)); - } - distanceToPoint(x) { - ts3dutils.assertVectors(x); - // See http://mathworld.wolfram.com/Point-LineDistance3-Dimensional.html - const t = x.minus(this.anchor).dot(this.dir1); - return this.at(t).distanceTo(x); - //return x.minus(this.anchor).cross(x.minus(this.anchor.plus(this.dir1))).length() - } - asSegmentDistanceToPoint(x, sStart, sEnd) { - let t = x.minus(this.anchor).dot(this.dir1); - t = ts3dutils.clamp(t, sStart, sEnd); - return this.at(t).minus(x).length(); - } - asSegmentDistanceToLine(line, sStart, sEnd) { - ts3dutils.assertInst(L3, line); - const dirCross = this.dir1.cross(line.dir1); - const div = dirCross.squared(); - if (ts3dutils.eq0(div)) { - return undefined; - } // lines parallel - const anchorDiff = line.anchor.minus(this.anchor); - // check if distance is zero (see also L3.distanceToLine) - if (!ts3dutils.eq0(anchorDiff.dot(dirCross.unit()))) { - return undefined; - } - let t = this.infoClosestToLine(line).t; - t = ts3dutils.clamp(t, sStart, sEnd); - return this.at(ts3dutils.clamp(t, sStart, sEnd)); - } - at(t) { - ts3dutils.assertNumbers(t); - return this.anchor.plus(this.dir1.times(t)); - } - /** - * This function returns lambda for a given point x - * - * Every point x on this line is described by the equation - * x = this.anchor + lambda * this.dir1 | - this.anchor - * x - this.anchor = lambda * this.dir1 | DOT this.dir1 - * (x - this.anchor) DOT this.dir1 = lambda (dir1² is 1 as |dir1| == 1) - * - * @param x - * @returns - */ - pointT(x) { - ts3dutils.assertVectors(x); - const t = x.minus(this.anchor).dot(this.dir1); - return t; - } - /** - * Returns true if the line is parallel (this.dir = line.dir || this.dir = -line.dir) to the argument. - */ - isParallelToLine(line) { - ts3dutils.assertInst(L3, line); - // we know that 1 == this.dir1.length() == line.dir1.length(), we can check for parallelity simpler than - // isParallelTo() - return ts3dutils.eq(1, Math.abs(this.dir1.dot(line.dir1))); - } - angleToLine(line) { - ts3dutils.assertInst(L3, line); - return this.dir1.angleTo(line.dir1); - } - /** - * - * @param line - * @returns {boolean} If the distance between the lines is zero - */ - intersectsLine(line) { - return ts3dutils.eq0(this.distanceToLine(line)); - } - isInfosWithCurve(curve) { - if (curve instanceof L3) { - return this.isInfosWithLine(curve.anchor, curve.dir1); - } - return super.isInfosWithCurve(curve); - } - isInfosWithLine(anchorWC, dirWC) { - const dirCross = this.dir1.cross(dirWC); - const div = dirCross.squared(); - if (ts3dutils.eq0(div)) { - // lines are parallel - return []; - } - const anchorDiff = anchorWC.minus(this.anchor); - if (ts3dutils.eq0(anchorDiff.dot(dirCross))) { - const tThis = anchorDiff.cross(dirWC).dot(dirCross) / div; - const tOther = anchorDiff.cross(this.dir1).dot(dirCross) / div; - const p = this.at(tThis); - return [{ tThis: tThis, tOther: tOther, p: p }]; - } - return []; - } - isInfoWithLine(line) { - // todo infos? - ts3dutils.assertInst(L3, line); - const dirCross = this.dir1.cross(line.dir1); - const div = dirCross.squared(); - if (ts3dutils.eq0(div)) { - return undefined; - } // lines parallel - const anchorDiff = line.anchor.minus(this.anchor); - // check if distance is zero (see also L3.distanceToLine) - if (!ts3dutils.eq0(anchorDiff.dot(dirCross.unit()))) { - return undefined; - } - const t = anchorDiff.cross(line.dir1).dot(dirCross) / div; - return this.at(t); - } - /** - * returns s and t with this.at(s) == line.at(t) - */ - intersectionLineST(line) { - // the two points on two lines the closest two each other are the ones whose - // connecting - // TODO Where does this come from? - // TODO: return value when no IS? - ts3dutils.assertInst(L3, line); - const dirCross = this.dir1.cross(line.dir1); - const div = dirCross.squared(); - const anchorDiff = line.anchor.minus(this.anchor); - const s = anchorDiff.cross(this.dir1).dot(dirCross) / div; - const t = anchorDiff.cross(line.dir1).dot(dirCross) / div; - return { s: s, t: t }; - // console.log(segmentIntersectsRay, a, b, "ab", ab, "p", p, "dir", dir, s > 0 && t / div >= 0 && t / div <= 1, - // "s", s, "t", t, "div", div) - } - ddt() { - return ts3dutils.V3.O; - } - getConstructorParameters() { - return [this.anchor, this.dir1]; - } - closestTToPoint(p) { - // similar logic as pointT; we project the vector (anchor -> p) onto dir1, then add anchor back to it - const nearestT = p.minus(this.anchor).dot(this.dir1); - return nearestT; - } - infoClosestToLine(line) { - /* - line = a + s*b - this = c + t*d - - (this - line) * b = 0 - (this - line) * d = 0 - - (a + s*b - c - t*d) * b = 0 - (a + s*b - c - t*d) * d = 0 - - (a - c + s*b - t*d) * b = 0 - (a - c + s*b - t*d) * d = 0 - - (a - c)*b + (s*b - t*d)*b = 0 - (a - c)*d + (s*b - t*d)*d = 0 - - (a - c)*b + s*(b*b) - t*(d*b) = 0 - (a - c)*d + s*(b*d) - t*(d*d) = 0 - - s = (t*(d*b) - (a - c)*b) / (b*b) - => - (a - c)*d + (t*(d*b) - (a - c)*b) / (b*b)*(b*d) - t*(d*d) = 0 | * (b*b) - (a - c)*d * (b*b) + (t*(d*b) - (a - c)*b)*(b*d) - t*(d*d) * (b*b) = 0 - (a - c)*d * (b*b) + t*(d*b)*(b*d) - (a - c)*b*(b*d) - t*(d*d) * (b*b) = 0 - t = ((a - c)*b*(b*d) - (a - c)*d * (b*b)) / ((d*b)*(b*d) - (d*d) * (b*b)) - */ - if (this.isParallelToLine(line)) { - return { t: NaN, s: NaN, distance: this.distanceToLine(line) }; - } - const a = line.anchor, b = line.dir1, c = this.anchor, d = this.dir1; - const bd = b.dot(d), bb = b.squared(), dd = d.squared(), ca = a.minus(c), divisor = bd * bd - dd * bb; - const t = (ca.dot(b) * bd - ca.dot(d) * bb) / divisor; - const s = (ca.dot(b) * dd - ca.dot(d) * bd) / divisor; - return { - t: t, - s: s, - closest: this.at(t), - closest2: line.at(s), - distance: this.at(t).distanceTo(line.at(s)), - }; - } - intersectionWithPlane(plane) { - // plane: plane.normal1 * p = plane.w - // line: p=line.point + lambda * line.dir1 - const lambda = (plane.w - plane.normal1.dot(this.anchor)) / plane.normal1.dot(this.dir1); - const point = this.anchor.plus(this.dir1.times(lambda)); - return point; - } - tangentAt() { - return this.dir1; - } - isTWithPlane(plane) { - // plane: plane.normal1 * p = plane.w - // line: p=line.point + lambda * line.dir1 - const div = plane.normal1.dot(this.dir1); - if (ts3dutils.eq0(div)) - return NaN; - const lambda = (plane.w - plane.normal1.dot(this.anchor)) / div; - return lambda; - } - reversed() { - return new L3(this.anchor, this.dir1.negated(), -this.tMax, -this.tMin); - } - isTsWithPlane(planeWC) { - const t = this.isTWithPlane(planeWC); - return isNaN(t) ? [] : [t]; - } - flipped() { - return new L3(this.anchor, this.dir1.negated()); - } - transform(m4) { - const newAnchor = m4.transformPoint(this.anchor); - const newDir = m4.transformVector(this.dir1); - return new L3(newAnchor, newDir.unit(), this.tMin * newDir.length(), this.tMax * newDir.length()); - } - transform4(m4) { - const vanishingPlane = P3.vanishingPlane(m4); - if (!vanishingPlane) - return this.transform(m4); - const pMin = this.at(this.tMin); - const pMax = this.at(this.tMax); - if (ts3dutils.le(vanishingPlane.distanceToPointSigned(pMin), 0) || - ts3dutils.le(vanishingPlane.distanceToPointSigned(pMax), 0)) { - throw new Error("line must be in front of vanishingPlane in [tMin, tMax]"); - } - const anchor = ts3dutils.lt(0, vanishingPlane.distanceToPointSigned(this.anchor)) - ? this.anchor - : this.at((this.tMin + this.tMax) / 2); - const transformedAnchor = m4.timesVector(ts3dutils.VV(anchor.x, anchor.y, anchor.z, 1)); - const transformedVector = m4.timesVector(ts3dutils.VV(this.dir1.x, this.dir1.y, this.dir1.z, 0)); - const newDir = transformedVector - .times(transformedAnchor.w) - .minus(transformedAnchor.times(transformedVector.w)) - .V3(); - const newAnchor = transformedAnchor.p3(); - return L3.anchorDirection(newAnchor, newDir, m4.transformPoint(pMin), m4.transformPoint(pMax)); - } - hashCode() { - return this.anchor.hashCode() * 31 + this.dir1.hashCode(); - } -} -L3.X = new L3(ts3dutils.V3.O, ts3dutils.V3.X); -L3.Y = new L3(ts3dutils.V3.O, ts3dutils.V3.Y); -L3.Z = new L3(ts3dutils.V3.O, ts3dutils.V3.Z); -L3.prototype.hlol = Curve.hlol++; -L3.prototype.tIncrement = 256; - -class PICurve extends ImplicitCurve { - constructor(points, tangents, parametricSurface, implicitSurface, pmPoints, pmTangents, stepSize, dir = 1, generator, tMin, tMax) { - super(points, tangents, dir, generator, tMin, tMax); - this.parametricSurface = parametricSurface; - this.implicitSurface = implicitSurface; - this.pmPoints = pmPoints; - this.pmTangents = pmTangents; - this.stepSize = stepSize; - ts3dutils.assert(Array.isArray(pmPoints)); - ts3dutils.assert(dir == 1); - ts3dutils.assert(stepSize <= 1); - const pf = parametricSurface.pUVFunc(); - const dpdu = parametricSurface.dpdu(); - const dpdv = parametricSurface.dpdv(); - const didp = implicitSurface.didp.bind(implicitSurface); - this.didu = (u, v) => didp(pf(u, v)).dot(dpdu(u, v)); - this.didv = (u, v) => didp(pf(u, v)).dot(dpdv(u, v)); - for (let i = 0; i < points.length - 1; i++) { - ts3dutils.assert(!points[i].equals(points[i + 1])); - //assert(parametricSurface.pUV(pmPoints[i].x, pmPoints[i].y).equals(points[i])) - } - { - const ps = this.parametricSurface; - const is = implicitSurface; - const pFunc = ps.pUVFunc(), iFunc = is.implicitFunction(); - const dpdu = ps.dpdu(); - const dpdv = ps.dpdv(); - const didp = is.didp.bind(is); - const mf = exports.MathFunctionR2R.forFFxFy((x, y) => iFunc(pFunc(x, y)), (u, v) => didp(pFunc(u, v)).dot(dpdu(u, v)), (u, v) => didp(pFunc(u, v)).dot(dpdv(u, v))); - const { points } = followAlgorithm2d(mf, this.pmPoints[0], stepSize, ps, (u, v) => is.containsPoint(pFunc(u, v)), ts3dutils.getLast(this.pmPoints), this.pmTangents[0]); - if (points.length !== this.points.length) { - followAlgorithm2d(mf, this.pmPoints[0], stepSize, ps, (u, v) => is.containsPoint(pFunc(u, v)), ts3dutils.getLast(this.pmPoints), this.pmTangents[0]); - } - ts3dutils.assert(points.length == this.points.length, points.length, this.points.length); - } - } - static forParametricStartEnd(ps, is, pmStart, pmEnd, stepSize = 0.02, startPMTangent, tMin, tMax) { - const pFunc = ps.pUVFunc(), iFunc = is.implicitFunction(); - const dpdu = ps.dpdu(); - const dpdv = ps.dpdv(); - const didp = is.didp.bind(is); - const mf = exports.MathFunctionR2R.forFFxFy((x, y) => iFunc(pFunc(x, y)), (u, v) => didp(pFunc(u, v)).dot(dpdu(u, v)), (u, v) => didp(pFunc(u, v)).dot(dpdv(u, v))); - const { points, tangents } = followAlgorithm2d(mf, pmStart, stepSize, ps, (u, v) => is.containsPoint(pFunc(u, v)), pmEnd, startPMTangent); - return PICurve.forParametricPointsTangents(ps, is, points, tangents, stepSize, 1, tMin, tMax); - } - static forStartEnd(ps, is, start, end, stepSize = 0.02, startTangent, min, max) { - const startPM = ps.uvP(start); - const dpdu = ps.dpdu()(startPM.x, startPM.y), dpdv = ps.dpdv()(startPM.x, startPM.y); - const startPMTangent = startTangent && - ts3dutils.M4.forSys(dpdu, dpdv).inversed().transformVector(startTangent); - // assert(dpdu.times(startPMTangent.x).plus(dpdv.times(startPMTangent.y)).like(startTangent)) - const curve = PICurve.forParametricStartEnd(ps, is, startPM, ps.uvP(end), stepSize, startPMTangent); - return curve.withBounds(min && curve.pointT(min), max && curve.pointT(max)); - } - static forParametricPointsTangents(ps, is, pmPoints, pmTangents, stepSize, dir = 1, tMin, tMax) { - const pFunc = ps.pUVFunc(), dpdu = ps.dpdu(); - const dpdv = ps.dpdv(); - const points = pmPoints.map(({ x, y }) => pFunc(x, y)); - const tangents = pmPoints.map(({ x: u, y: v }, i) => { - const ds = dpdu(u, v); - const dt = dpdv(u, v); - return ds.times(pmTangents[i].x).plus(dt.times(pmTangents[i].y)); - //const p = points[i] - //return cs.normalP(p).cross(ses.normalP(p)) - // .toLength(ds.times(pmTangents[i].x).plus(dt.times(pmTangents[i].y)).length()) - }); - return new PICurve(points, tangents, ps, is, pmPoints, pmTangents, stepSize, dir, undefined, tMin, tMax); - } - getConstructorParameters() { - return [ - this.points, - this.tangents, - this.parametricSurface, - this.implicitSurface, - this.pmPoints, - this.pmTangents, - this.stepSize, - this.dir, - this.generator, - ]; - } - implicitCurve() { - const pF = this.parametricSurface.pUVFunc(); - const iF = this.implicitSurface.implicitFunction(); - return (u, v) => iF(pF(u, v)); - } - isColinearTo(curve) { - if (curve instanceof PICurve) { - if (this.equals(curve)) { - return true; - } - if (this.parametricSurface.isCoplanarTo(curve.parametricSurface) && - this.implicitSurface.isCoplanarTo(curve.implicitSurface)) ; - return false; - } - else { - return false; - } - } - containsPoint(p) { - ts3dutils.assertVectors(p); - const t = this.pointT(p); - return !isNaN(t) && this.isValidT(t); - } - equals(obj) { - return (Object.getPrototypeOf(obj) == PICurve.prototype && - this.parametricSurface.equals(obj.parametricSurface) && - this.implicitSurface.equals(obj.implicitSurface) && - this.points[0].equals(obj.points[0]) && - this.tangents[0].equals(obj.tangents[0]) && - this.dir === obj.dir); - } - hashCode() { - let hashCode = 0; - hashCode = hashCode * 31 + this.parametricSurface.hashCode(); - hashCode = hashCode * 31 + this.implicitSurface.hashCode(); - hashCode = hashCode * 31 + this.points[0].hashCode(); - hashCode = hashCode * 31 + this.tangents[0].hashCode(); - return hashCode | 0; - } - tangentP(point) { - ts3dutils.assertVectors(point); - ts3dutils.assert(this.containsPoint(point), "this.containsPoint(point)"); - const t = this.pointT(point); - return this.tangentAt(t); - } - tangentAt(t) { - ts3dutils.assert(!isNaN(t)); - if (0 === t % 1) - return this.tangents[t]; - const uv = this.uvT(t); - const uvTangent = new ts3dutils.V3(-this.didv(uv.x, uv.y), this.didu(uv.x, uv.y), 0).toLength(this.stepSize); - const du = this.parametricSurface.dpdu()(uv.x, uv.y); - const dv = this.parametricSurface.dpdv()(uv.x, uv.y); - return du.times(uvTangent.x).plus(dv.times(uvTangent.y)); - } - at(t) { - ts3dutils.assert(!isNaN(t)); - if (0 === t % 1) - return this.points[t]; - const startParams = ts3dutils.V3.lerp(this.pmPoints[floor(t)], this.pmPoints[ceil(t)], t % 1); - return this.closestPointToParams(startParams); - } - uvT(t) { - ts3dutils.assert(!isNaN(t)); - //TODO: use elerp - if (0 === t % 1) - return this.pmPoints[t]; - const startParams = ts3dutils.V3.lerp(this.pmPoints[floor(t)], this.pmPoints[ceil(t)], t % 1); - return curvePoint(this.implicitCurve(), startParams, this.didu, this.didv); - } - closestTToPoint(p, tStart) { - // TODO - return 0; - } - closestPointToParams(startUV) { - const pointParams = curvePoint(this.implicitCurve(), startUV, this.didu, this.didv); - return this.parametricSurface.pUVFunc()(pointParams.x, pointParams.y); - } - isTsWithSurface(surface) { - if (surface instanceof EllipsoidSurface) { - const pS = this.parametricSurface, iS = this.implicitSurface; - if (pS instanceof ProjectedCurveSurface && - iS instanceof EllipsoidSurface) { - const iscs = iS.isCurvesWithSurface(surface); - const points = iscs.flatMap((isc) => isc.isTsWithSurface(pS).map((t) => isc.at(t))); - const ts = ts3dutils.fuzzyUniques(points.map((p) => this.pointT(p))); - return ts.filter((t) => !isNaN(t) && this.isValidT(t)); - } - } - else if (ImplicitSurface.is(surface)) { - const result = []; - const iF = surface.implicitFunction(); - let prevSignedDistance = iF(this.points[0]); - for (let i = 1; i < this.points.length; i++) { - const point = this.points[i]; - const signedDistance = iF(point); - if (prevSignedDistance * signedDistance <= 0) { - const pF = this.parametricSurface.pUVFunc(); - const dpdu = this.parametricSurface.dpdu(); - const dpdv = this.parametricSurface.dpdv(); - const startUV = this.pmPoints[abs(prevSignedDistance) < abs(signedDistance) ? i - 1 : i]; - const isUV = ts3dutils.newtonIterate2dWithDerivatives(this.implicitCurve(), (u, v) => iF(pF(u, v)), startUV.x, startUV.y, 4, this.didu, this.didv, (u, v) => dpdu(u, v).dot(surface.didp(pF(u, v))), (u, v) => dpdv(u, v).dot(surface.didp(pF(u, v)))); - result.push(this.pointT(this.parametricSurface.pUV(isUV.x, isUV.y))); - } - prevSignedDistance = signedDistance; - } - return result; - } - throw new Error(); - } - isTsWithPlane(planeWC) { - return this.isTsWithSurface(new PlaneSurface(planeWC)); - // version which intersects the plane with the defining surfaces of this PICurve, but this causes - // issues when they are PICurves too: - // assertInst(P3, planeWC) - // const ps = this.parametricSurface, - // is = this.implicitSurface - // const pscs = ps.isCurvesWithPlane(planeWC) - // const iscs = is.isCurvesWithPlane(planeWC) - // const infos = iscs.flatMap(isc => pscs.flatMap(psc => isc.isInfosWithCurve(psc))) - // const ts = fuzzyUniques(infos.map(info => this.pointT(info.p))) - // return ts.filter(t => !isNaN(t) && this.isValidT(t)) - } - pointT(p) { - ts3dutils.assertVectors(p); - if (!this.parametricSurface.containsPoint(p) || - !this.implicitSurface.containsPoint(p)) { - return NaN; - } - const pmPoint = this.parametricSurface.uvPFunc()(p); - const ps = this.points, pmps = this.pmPoints; - let t = 0, pmDistance = pmPoint.distanceTo(pmps[0]); - while (pmDistance > abs(this.stepSize) && t < ps.length - 1) { - // TODO -1? - //console.log(t, pmps[t].$, pmDistance) - t = min(pmps.length - 1, t + max(1, Math.round(pmDistance / abs(this.stepSize) / 2 / 2))); - pmDistance = pmPoint.distanceTo(pmps[t]); - } - // if (t < this.pmPoints.length - 1 && pmDistance > pmPoint.distanceTo(pmps[t + 1])) { - // t++ - // } - if (pmDistance > abs(this.stepSize) * 1.1) { - // p is not on this curve - return NaN; - } - if (t == ps.length - 1) { - t--; - } - if (ps[t].like(p)) - return t; - if (ps[t + 1].like(p)) - return t + 1; - const startT = ts3dutils.withMax(ts3dutils.arrayRange(floor(this.tMin), ceil(this.tMax), 1), (t) => -pmPoint.distanceTo(pmps[t])); - if (undefined === startT) - throw new Error(); - if (ps[startT].like(p)) - return startT; - //const [a, b] = 0 === startT - // ? [0, 1] - // : this.points.length - 1 === startT - // ? [startT - 1, startT] - // : pmPoint.distanceTo(pmps[startT - 1]) < pmPoint.distanceTo(pmps[startT + 1]) - // ? [startT - 1, startT] - // : [startT, startT + 1] - const a = max(0, startT - 1), b = min(this.points.length - 1, startT + 1); - const tangent = this.tangentAt(startT); - const f = (t) => this.at(ts3dutils.clamp(t, 0, this.points.length - 1)) - .to(p) - .dot(tangent); - // const df = (t: number) => -this.tangentAt(clamp(t, 0, this.points.length - 1)).dot(tangent) - //checkDerivate(f, df, 0, this.points.length - 2, 3) - // 8 steps necessary because df can currently be way off - t = ts3dutils.bisect(f, a, b, 32); - if (!isFinite(t) || this.at(t).distanceTo(p) > abs(this.stepSize)) { - return NaN; - } - return t; - } - transform(m4) { - const dirFactor = m4.isMirroring() ? -1 : 1; - return PICurve.forStartEnd(this.parametricSurface.transform(m4), this.implicitSurface.transform(m4), m4.transformPoint(this.points[0]), m4.transformPoint(ts3dutils.getLast(this.points)), this.stepSize * dirFactor, m4.transformVector(this.tangents[0]), m4.transformPoint(this.at(this.tMin)), m4.transformPoint(this.at(this.tMax))); - //return PICurve.forParametricStartEnd( - // this.parametricSurface.transform(m4), - // this.implicitSurface.transform(m4), - // this.pmPoints[0], - // getLast(this.pmPoints), - // this.stepSize, - // this.dir, - // this.tMin, - // this.tMax) - // TODO: pass transformed points? - //return new PICurve( - // m4.transformedPoints(this.points), - // m4.transformedVectors(this.tangents), - // this.parametricSurface.transform(m4), - // this.implicitSurface.transform(m4), - // this.pmPoints, - // this.pmTangents, - //this.stepSize, - // this.dir, - //this.generator, - //this.tMin, this.tMax) - } - roots() { - const allTs = ts3dutils.arrayRange(0, this.points.length); - return [allTs, allTs, allTs]; - } - isInfosWithLine(anchorWC, dirWC, tMin, tMax, lineMin, lineMax) { - return surfaceIsICurveIsInfosWithLine.call(this, this.implicitSurface, this.parametricSurface, anchorWC, dirWC, tMin, tMax, lineMin, lineMax); - } - toSource(rounder = (x) => x) { - const result = ts3dutils.callsce("PICurve.forParametricStartEnd", this.parametricSurface, this.implicitSurface, this.pmPoints[0], ts3dutils.getLast(this.pmPoints), this.stepSize, this.pmTangents[0], this.tMin, this.tMax); - return result; - } -} -PICurve.prototype.tIncrement = 1; - -class PPCurve extends ImplicitCurve { - constructor(points, tangents, parametricSurface1, parametricSurface2, st1s, pmTangents, stepSize, dir = 1, generator, tMin, tMax) { - super(points, tangents, dir, generator, tMin, tMax); - this.parametricSurface1 = parametricSurface1; - this.parametricSurface2 = parametricSurface2; - this.st1s = st1s; - this.pmTangents = pmTangents; - this.stepSize = stepSize; - ts3dutils.assert(ParametricSurface.is(parametricSurface1)); - ts3dutils.assert(ParametricSurface.is(parametricSurface2)); - ts3dutils.assert(Array.isArray(st1s)); - ts3dutils.assert(dir == 1); - ts3dutils.assert(stepSize <= 1); - } - at(t) { - ts3dutils.assert(!isNaN(t)); - if (0 === t % 1) - return this.points[t]; - const startPoint = ts3dutils.V3.lerp(this.points[floor(t)], this.points[ceil(t)], t % 1); - return curvePointPP(this.parametricSurface1, this.parametricSurface2, startPoint).p; - } - isColinearTo(curve) { - if (curve instanceof PPCurve) { - if (this.equals(curve)) { - return true; - } - if (this.parametricSurface1.isCoplanarTo(curve.parametricSurface1) && - this.parametricSurface1.isCoplanarTo(curve.parametricSurface2)) ; - return false; - } - else { - return false; - } - } - containsPoint(p) { - ts3dutils.assertVectors(p); - // TODO: wrong, as there could be another curve - return (this.parametricSurface1.containsPoint(p) && - this.parametricSurface2.containsPoint(p) && - !isNaN(this.pointT(p))); - } - rootPoints() { - const pF1 = this.parametricSurface1.pUVFunc(); - const pF2 = this.parametricSurface2.pUVFunc(); - const pN1 = this.parametricSurface1.normalUVFunc(); - const pN2 = this.parametricSurface2.normalUVFunc(); - const rootsApprox = this.rootsApprox(); - const results = [[], [], []]; - for (let dim = 0; dim < 3; dim++) { - for (let i = 0; i < rootsApprox[dim].length; i++) { - const lambda = rootsApprox[dim][i]; - const p = this.at(lambda); - ts3dutils.assert(this.parametricSurface1.containsPoint(p)); - const pp1 = this.parametricSurface1.uvP(p); - const { x: u, y: v } = this.parametricSurface2.uvP(p); - const startValues = [pp1.x, pp1.y, u, v]; - function f(vals) { - const [u1, v1, u2, v2] = vals; - const diff = pF1(u1, v1).minus(pF2(u2, v2)); - const n1 = pN1(u1, v1); - const n2 = pN2(u2, v2); - const tangent = n1.cross(n2); - return [diff.x, diff.y, diff.z, tangent.e(dim)]; - } - const pps = ts3dutils.newtonIterate(f, startValues, 8); - // assert(pF1(pps[0], pps[1]).like(pF2(pps[2], pps[3])), - // pF1(pps[0], pps[1]).sce + pF2(pps[2], pps[3]).sce) - const result = pF1(pps[0], pps[1]); - results[dim].push(result); - } - } - return results; - } - roots() { - return this.rootPoints().map((ps) => ps.map((p) => this.pointT(p))); - } - pointTangent(pWC) { - ts3dutils.assertVectors(pWC); - ts3dutils.assert(this.containsPoint(pWC), "this.containsPoint(pWC)"); - const n1 = this.parametricSurface1.normalP(pWC); - const n2 = this.parametricSurface2.normalP(pWC); - return n1.cross(n2); - } - transform(m4) { - return new PPCurve(m4.transformedPoints(this.points), m4.transformedVectors(this.tangents), this.parametricSurface1.transform(m4), this.parametricSurface2.transform(m4), this.st1s, undefined, this.stepSize, this.dir, undefined); - } - toSource() { - return ts3dutils.callsce("PPCurve.forStartEnd", this.parametricSurface1, this.parametricSurface2, this.points[0], ts3dutils.getLast(this.points), this.stepSize); - } - static forStartEnd(ps1, ps2, startPoint, end, stepSize = 0.02) { - const { points, tangents, st1s } = followAlgorithmPP(ps1, ps2, startPoint, stepSize); - return new PPCurve(points, tangents, ps1, ps2, st1s, undefined, stepSize, 1); - } - isInfosWithLine(anchorWC, dirWC, tMin, tMax, lineMin, lineMax) { - return surfaceIsICurveIsInfosWithLine.call(this, this.parametricSurface1, this.parametricSurface2, anchorWC, dirWC, tMin, tMax, lineMin, lineMax); - } - isTsWithSurface(surface) { - if (ImplicitSurface.is(surface)) { - const result = []; - const iF = surface.implicitFunction(); - const pUV1 = this.parametricSurface1.pUVFunc(); - const pUV2 = this.parametricSurface2.pUVFunc(); - let prevSignedDistance = iF(this.points[0]); - for (let i = 1; i < this.points.length; i++) { - const point = this.points[i]; - const signedDistance = iF(point); - if (prevSignedDistance * signedDistance <= 0) { - const startIndex = abs(prevSignedDistance) < abs(signedDistance) ? i - 1 : i; - const startPoint = this.points[startIndex]; - const startUV1 = this.st1s[startIndex]; - const startUV2 = this.parametricSurface2.uvP(startPoint); - const isSTUV = ts3dutils.newtonIterate(([u1, v1, u2, v2]) => { - const ps1p = pUV1(u1, v1); - const ps2p = pUV2(u2, v2); - return [...ps1p.to(ps2p), iF(ps1p)]; - }, [startUV1.x, startUV1.y, startUV2.x, startUV2.y]); - result.push(this.pointT(this.parametricSurface1.pUV(isSTUV[0], isSTUV[1]))); - } - prevSignedDistance = signedDistance; - } - return result; - } - throw new Error("Method not implemented."); - } - isTsWithPlane(planeWC) { - return this.isTsWithSurface(new PlaneSurface(planeWC)); - } -} - -/** - * eta = xi² - */ -class ParabolaCurve extends XiEtaCurve { - constructor(center, f1, f2, tMin = -10, tMax = 10) { - super(center, f1, f2, tMin, tMax); - } - static eccentricity() { - return 1; - } - static unitIsInfosWithLine(anchorLC, dirLC, anchorWC, dirWC) { - // para: x² = y - // line(t) = anchor + t dir - // (ax + t dx)² = ay + t dy - // ax² + t ax dx + t² dx² = ay + t dy - // t² dx² + t (ax dx + dy) + ay² + ay = 0 - const pqDiv = Math.pow(dirLC.x, 2); - const lineTs = ts3dutils.pqFormula((anchorLC.x * dirLC.x + dirLC.y) / pqDiv, (Math.pow(anchorLC.x, 2) + anchorLC.y) / pqDiv); - return lineTs - .filter((tOther) => ts3dutils.le(0, anchorLC.y + tOther * dirLC.y)) - .map((tOther) => ({ - tThis: dirLC.x * tOther + anchorLC.x, - tOther: tOther, - p: L3.at(anchorWC, dirWC, tOther), - })); - } - static intersectionUnitLine(a, b, c) { - /* - solve system (5)/(6) - g1 * xi + g2 * eta = g3 (6) - g1 * xi + g2 * xi * xi = g3 - xi² + xi * g1/g2 - g3/g2 = 0 - */ - return ts3dutils.pqFormula(a / b, -c / b); - } - static XYLCValid(pLC) { - return ts3dutils.eq(Math.pow(pLC.x, 2), pLC.y); - } - static XYLCPointT(pLC) { - return pLC.x; - } - static quadratic(a, b, c) { - // (1 - t)² a + 2 * t * (1 - t) b + t² c - // (1 -2t +t²)a + (2t -2t²) b + t² c - // = t²(a - 2b + c) + t (-2a + 2b) + a - // (2t - 2) a + (1 - 2t) b + 2t c = t(2a + 2b - 2c) - 2a + b - // 2 a + -2 b + 2 c - const f2 = a.plus(c).minus(b.times(2)); - const f1 = b.minus(a).times(2); - const center = a; - return new ParabolaCurve(center, f1, f2, 0, 1); - } - at(t) { - // center + f1 t + f2 t² - return this.center.plus(this.f1.times(t)).plus(this.f2.times(t * t)); - } - tangentAt(t) { - ts3dutils.assertNumbers(t); - // f1 + f2 2 t - return this.f1.plus(this.f2.times(2 * t)); - } - ddt(t) { - ts3dutils.assertNumbers(t); - return this.f2.times(2); - } - tangentAt2(xi, eta) { - ts3dutils.assertNumbers(xi, eta); - return this.f1.plus(this.f2.times(2 * eta)); - } - reversed() { - return new this.constructor(this.center, this.f1.negated(), this.f2, -this.tMax, -this.tMin); - } - /** - * tangent: f1 + 2 * t * f2 = 0 - * t = -f1 / 2 / f2 (for individual dimensions) - */ - roots() { - const dimRoots = (dim) => ts3dutils.eq0(this.f2.e(dim)) ? [] : [-this.f1.e(dim) / 2 / this.f2.e(dim)]; - return ts3dutils.arrayFromFunction(3, dimRoots); - } - isColinearTo(curve) { - if (!ts3dutils.hasConstructor(curve, ParabolaCurve)) - return false; - const thisRA = this.rightAngled(), curveRA = curve.rightAngled(); - return (thisRA.center.like(curveRA.center) && - thisRA.f2.like(curveRA.f2) && - thisRA.f1.likeOrReversed(curveRA.f1)); - } - rightAngled() { - // looking for vertex of parabola - // this is the point where the tangent is perpendicular to the main axis (f2) - // tangent = f1 + f2 * 2 * t0 - // f2 DOT (f1 + f2 * 2 * t0) == 0 - // f1 DOT f2 + f2 DOT f2 * 2 * t0 == 0 - // t0 == -(f1 DOT f2) / (f2 DOT f2 * 2) - const f1 = this.f1, f2 = this.f2; - const f1DOTf2 = f1.dot(f2); - if (ts3dutils.eq0(f1DOTf2) && f1.hasLength(1)) { - return this; - } - const t0 = -f1DOTf2 / f2.squared() / 2; - // we need to rearange tMin/tMax - // tMin' = pointT(at(tMin)) = - const raCenter = this.at(t0); - const raF1 = this.tangentAt(t0), raF1Length = raF1.length(), raF11 = raF1.unit(); - const repos = (t) => this.at(t).minus(raCenter).dot(raF11); - return new ParabolaCurve(raCenter, raF11, f2.div(Math.pow(raF1Length, 2)), repos(this.tMin), repos(this.tMax)); - } - arcLength(startT, endT) { - let f1 = this.f1; - const f2 = this.f2; - const f1DOTf2 = f1.dot(f2); - let t0 = 0; - if (!ts3dutils.eq0(f1DOTf2)) { - t0 = -f1DOTf2 / f2.squared() / 2; - f1 = f1.plus(f2.times(2 * t0)); - } - const f1Length = f1.length(); - const a = f2.length() / f1Length; - function F(x) { - return (Math.asinh(a * 2 * x) / 4 / a + - (x * Math.sqrt(1 + a * a * 4 * x * x)) / 2); - } - return f1Length * (F(endT - t0) - F(startT - t0)); - } - transform4(m4) { - return parabola4Projection(this.matrix.transform(m4), this.tMin, this.tMax); - } - asBezier() { - return BezierCurve.quadratic(this.at(-1), new L3(this.at(-1), this.tangentAt(-1).unit()).isInfoWithLine(new L3(this.at(1), this.tangentAt(1).unit())), this.at(1)); - } - /** - * Returns new ParabolaCurve that has its center point at this.at(t0) - * @param t0 - */ - recenter(t0) { - // this.at(t) = f2 t² + f1 t + center - // c2.at(t) = f2 (t + t0)² + f1 (t + t0) + center - // c2.at(t) = f2 (t² + 2 t0 t + t0²) + f1 (t + t0) + center - // c2.at(t) = f2 t² + (f1 + 2 f2 t0) t + center + f2 t0² + f1 t0 - return new ParabolaCurve(this.at(t0), this.f1.plus(this.f2.times(2 * t0)), this.f2); - } -} -ParabolaCurve.XY = new ParabolaCurve(ts3dutils.V3.O, ts3dutils.V3.X, ts3dutils.V3.Y); -ParabolaCurve.YZ = new ParabolaCurve(ts3dutils.V3.O, ts3dutils.V3.Y, ts3dutils.V3.Z); -ParabolaCurve.ZX = new ParabolaCurve(ts3dutils.V3.O, ts3dutils.V3.Z, ts3dutils.V3.X); -ParabolaCurve.prototype.tIncrement = 1 / 32; - -class EllipseCurve extends XiEtaCurve { - constructor(center, f1, f2, tMin = 0, tMax = PI) { - super(center, f1, f2, tMin, tMax); - ts3dutils.assert(-PI <= this.tMin && this.tMin < PI); - ts3dutils.assert(-PI < this.tMax && this.tMax <= PI); - } - static andFixTs(center, f1, f2, tMin = 0, tMax = PI) { - if (-PI <= tMin && tMax <= PI) { - return new EllipseCurve(center, f1, f2, tMin, tMax); - } - if (0 <= tMin && tMax <= ts3dutils.TAU) { - return new EllipseCurve(center, f1.negated(), f2.negated(), tMin - PI, tMax - PI); - } - if (-ts3dutils.TAU <= tMin && tMax <= 0) { - return new EllipseCurve(center, f1.negated(), f2.negated(), tMin + PI, tMax + PI); - } - throw new Error("Method not implemented."); - } - static XYLCValid(pLC) { - const { x, y } = pLC; - return ts3dutils.eq0(Math.pow(x, 2) + Math.pow(y, 2) - 1); - } - static XYLCPointT(pLC, tMin, tMax) { - ts3dutils.assertNumbers(tMin, tMax); - const t = atan2(pLC.y, pLC.x); - const lowSplitter = ts3dutils.lerp(tMin, tMax - ts3dutils.TAU, 0.5); - if (t < lowSplitter) { - return t + ts3dutils.TAU; - } - const highSplitter = ts3dutils.lerp(tMax, tMin + ts3dutils.TAU, 0.5); - if (t > highSplitter) { - return t - ts3dutils.TAU; - } - return t; - } - static intersectionUnitLine(a, b, c, tMin, tMax) { - const isLC = intersectionUnitCircleLine2(a, b, c); - const result = []; - for (const [xi, eta] of isLC) { - const t = EllipseCurve.XYLCPointT(new ts3dutils.V3(xi, eta, 0), tMin, tMax); - ts3dutils.fuzzyBetween(t, tMin, tMax) && result.push(t); - } - return result; - } - static unitIsInfosWithLine(anchorLC, dirLC, anchorWC, dirWC, tMin, tMax) { - // ell: x² + y² = 1 = p² - // line(t) = anchor + t dir - // anchor² - 1 + 2 t dir anchor + t² dir² = 0 - const pqDiv = dirLC.squared(); - const lineTs = ts3dutils.pqFormula((2 * dirLC.dot(anchorLC)) / pqDiv, (anchorLC.squared() - 1) / pqDiv); - return lineTs - .filter((tOther) => ts3dutils.le(0, anchorLC.y + tOther * dirLC.y)) - .map((tOther) => ({ - tThis: EllipseCurve.XYLCPointT(dirLC.times(tOther).plus(anchorLC), tMin, tMax), - tOther: tOther, - p: L3.at(anchorWC, dirWC, tOther), - })); - } - /** - * Returns a new EllipseCurve representing a circle parallel to the XY-plane.` - */ - static semicircle(radius, center = ts3dutils.V3.O, tMin, tMax) { - return new EllipseCurve(center, new ts3dutils.V3(radius, 0, 0), new ts3dutils.V3(0, radius, 0), tMin, tMax); - } - static circleForCenter2P(center, a, b, radius, tMin, tMax) { - const f1 = center.to(a); - const normal = f1.cross(center.to(b)); - const f2 = normal.cross(f1).toLength(f1.length()); - return new EllipseCurve(center, f1, f2, undefined !== tMin ? tMin : 0, undefined !== tMax ? tMax : f1.angleTo(center.to(b))); - } - split(tMin = this.tMin, tMax = this.tMax) { - const result = []; - tMin < 0 && - result.push(new EllipseCurve(this.center, this.f1.negated(), this.f2.negated(), tMin + PI, min(0, tMax) + PI)); - tMax > 0 && - result.push(new EllipseCurve(this.center, this.f1, this.f2, max(0, tMin), tMax)); - return result; - } - static forAB(a, b, center = ts3dutils.V3.O) { - return super.forAB(a, b, center); - } - /** - * Create a circle curve which has a, b and c on it. a, b, c can't be on a straight line. - * tMin defaults to 0, tMax defaults to the value for c - */ - static circleThroughPoints(a, b, c, tMin = 0, tMax) { - ts3dutils.assertf(() => !L3.throughPoints(a, c).containsPoint(b)); - const normal = a.to(b).cross(b.to(c)); - const center = new L3(a.lerp(b, 0.5), normal.cross(a.to(b)).unit()).isInfoWithLine(new L3(b.lerp(c, 0.5), normal.cross(b.to(c)).unit())); - const f1 = center.to(a).negated(); - return new EllipseCurve(center, f1, normal.unit().cross(f1), -PI, undefined === tMax - ? f1.angleRelativeNormal(center.to(c), normal.unit()) - : tMax); - } - getAreaInDir(right, up, tStart, tEnd) { - //assertf(() => tStart < tEnd) - ts3dutils.assertf(() => right.isPerpendicularTo(this.normal)); - ts3dutils.assertf(() => up.isPerpendicularTo(this.normal)); - //assertf(() => EllipseCurve.isValidT(tStart), tStart) - //assertf(() => EllipseCurve.isValidT(tEnd), tEnd) - const upLC = this.matrixInverse.transformVector(up); - const rightLC = upLC.cross(ts3dutils.V3.Z); - const normTStart = tStart - rightLC.angleXY(); - const normTEnd = tEnd - rightLC.angleXY(); - const transformedOriginY = this.matrixInverse - .getTranslation() - .dot(upLC.unit()); - // integral of sqrt(1 - x²) from 0 to cos(t) - // Basically, we want - // INTEGRAL[cos(t); PI/2] sqrt(1 - x²) dx - // INTEGRAL[PI/2: cos(t)] -sqrt(1 - x²) dx - // = INTEGRAL[cos(0); cos(t)] -sqrt(1 - x²) dx - // = INTEGRAL[0; t] -sqrt(1 - cos²(t)) * -sin(t) dt - // = INTEGRAL[0; t] -sin(t) * -sin(t) dt - // = INTEGRAL[0; t] sin²(t) dt (partial integration / wolfram alpha) - // = (1/2 * (t - sin(t) * cos(t)))[0; t] (this form has the distinct advantage of being defined everywhere) - function fArea(t) { - return (t - Math.sin(t) * Math.cos(t)) / 2; - } - // for the centroid, we want - // cx = 1 / area * INTEGRAL[cos(t); PI/2] x * f(x) dx - // cx = 1 / area * INTEGRAL[cos(t); PI/2] x * sqrt(1 - x²) dx - // cx = 1 / area * INTEGRAL[cos(0); cos(t)] x * -sqrt(1 - x²) dx - // ... - // cx = 1 / area * INTEGRAL[0; t] cos(t) * sin²(t) dt // WA - // cx = 1 / area * (sin^3(t) / 3)[0; t] - function cxTimesArea(t) { - return Math.pow(Math.sin(t), 3) / 3; - } - // cy = 1 / area * INTEGRAL[cos(t); PI/2] f²(x) / 2 dx - // cy = 1 / area * INTEGRAL[cos(0); cos(t)] -(1 - x²) / 2 dx - // cy = 1 / area * INTEGRAL[0; t] (cos²(t) - 1) * -sin(t) / 2 dt - // cy = 1 / area * (cos (3 * t) - 9 * cos(t)) / 24 )[0; t] - function cyTimesArea(t) { - return (Math.cos(3 * t) - 9 * Math.cos(t)) / 24; - } - const restArea = -transformedOriginY * (-Math.cos(normTEnd) + Math.cos(normTStart)); - const area = fArea(normTEnd) - fArea(normTStart) + restArea; - const cxt = (cxTimesArea(normTEnd) - - cxTimesArea(normTStart) + - ((-transformedOriginY * (-Math.cos(normTEnd) - Math.cos(normTStart))) / - 2) * - restArea) / - area; - const cyt = (cyTimesArea(normTEnd) - - cyTimesArea(normTStart) - - (-transformedOriginY / 2) * restArea) / - area; - const factor = this.matrix.xyAreaFactor(); // * upLC.length() - //console.log('fctor', factor, 'area', area, 'resultarea', area* factor) - ts3dutils.assert(!ts3dutils.eq0(factor)); - return { - area: area * factor, - centroid: this.matrix.transformPoint(ts3dutils.M4.rotateZ(rightLC.angleXY()).transformPoint(new ts3dutils.V3(cxt, cyt, 0))), - }; - } - at(t) { - ts3dutils.assertNumbers(t); - //assert(this.isValidT(t)) - // = center + f1 cos t + f2 sin t - return this.center - .plus(this.f1.times(Math.cos(t))) - .plus(this.f2.times(Math.sin(t))); - } - tangentAt(t) { - ts3dutils.assertNumbers(t); - //assert(this.isValidT(t)) - // ) f2 cos(t) - f1 sin(t) - return this.f2.times(Math.cos(t)).minus(this.f1.times(Math.sin(t))); - } - ddt(t) { - ts3dutils.assertNumbers(t); - ts3dutils.assert(this.isValidT(t)); - return this.f2.times(-Math.sin(t)).minus(this.f1.times(Math.cos(t))); - } - tangentAt2(xi, eta) { - return this.f2.times(xi).minus(this.f1.times(eta)); - } - isCircular() { - return (ts3dutils.eq(this.f1.length(), this.f2.length()) && - this.f1.isPerpendicularTo(this.f2)); - } - isColinearTo(curve) { - if (!ts3dutils.hasConstructor(curve, EllipseCurve)) - return false; - if (!this.center.like(curve.center)) { - return false; - } - if (this == curve) { - return true; - } - if (this.isCircular()) { - return (curve.isCircular() && - ts3dutils.eq(this.f1.length(), curve.f1.length()) && - this.normal.isParallelTo(curve.normal)); - } - else { - let { f1: f1, f2: f2 } = this.rightAngled(), { f1: c1, f2: c2 } = curve.rightAngled(); - if (f1.length() > f2.length()) { - [f1, f2] = [f2, f1]; - } - if (c1.length() > c2.length()) { - [c1, c2] = [c2, c1]; - } - return (ts3dutils.eq(f1.squared(), Math.abs(f1.dot(c1))) && - ts3dutils.eq(f2.squared(), Math.abs(f2.dot(c2)))); - } - } - pointT(pWC) { - ts3dutils.assertVectors(pWC); - ts3dutils.assert(this.containsPoint(pWC)); - const pLC = this.matrixInverse.transformPoint(pWC); - const t = EllipseCurve.XYLCPointT(pLC, this.tMin, this.tMax); - ts3dutils.assert(this.isValidT(t)); - return t; - } - reversed() { - return new EllipseCurve(this.center, this.f1.negated(), this.f2, PI - this.tMax, PI - this.tMin); - } - eccentricity() { - const mainAxes = this.rightAngled(); - const f1length = mainAxes.f1.length(), f2length = mainAxes.f1.length(); - const [a, b] = f1length > f2length ? [f1length, f2length] : [f2length, f1length]; - return Math.sqrt(1 - (b * b) / a / a); - } - circumference() { - return this.arcLength(-Math.PI, Math.PI); - } - arcLength(tStart = this.tMin, tEnd = this.tMax, steps = 2) { - ts3dutils.assert(tStart < tEnd, "startT < endT"); - const f1Length = this.f1.length(); - if (ts3dutils.eq(f1Length, this.f2.length())) { - return f1Length * (tEnd - tStart); - } - return super.arcLength(tStart, tEnd, steps); - } - circumferenceApproximate() { - // approximate circumference by Ramanujan - // https://en.wikipedia.org/wiki/Ellipse#Circumference - const { f1, f2 } = this.rightAngled(), a = f1.length(), b = f2.length(); - const h = Math.pow((a - b), 2) / Math.pow((a + b), 2); - return Math.PI * (a + b) * (1 + (3 * h) / (10 + Math.sqrt(4 - 3 * h))); - } - /** - * Radii of the ellipse are described by - * q(phi) = f1 * cos(phi) + f2 * sin(phi) - * or q(xi, eta) = f1 * xi + f2 * eta (1) with the added condition - * xi² + eta² = 1 (2) - * we want to find the radius where the corresponding tangent is perpendicular - * tangent: q'(phi) = f1 * -sin(phi) + f2 * cos(phi) - * tangent: q'(xi, eta) = f1 * -eta + f2 * xi - * perpendicular when: q'(xi, eta) DOT q(xi, eta) = 0 - * (f1 * -eta + f2 * xi) DOT (f1 * xi + f2 * eta) = 0 - * DOT is distributive: - * f1² * (-eta * xi) + f1 * f2 * (-eta² + xi²) + f2² * (xi * eta) = 0 - * (f2² - f1²) * (eta * xi) + f1 * f2 * (-eta² + xi²) = 0 - * a * (xi² - eta²) + b * xi * eta = 0 (2) - * with a = f1 * f2, b = f2² - f1² - * => (xi/eta)² + xi/eta * b/a + 1 = 0 (divide by a * eta²) - * xi/eta = b/a/2 +- sqrt(b²/a²/4 - 1) | * 2*a*eta - * 2 * a * xi = eta * (b +- sqrt(b² - 4 * a²)) - * g1 * xi - g2 * eta = 0 (3) - * with g1 = 2 * a, g2 = b +- sqrt(b² - 4 * a²) - * Solve (3), (2) with intersectionUnitCircleLine - */ - rightAngled() { - const f1 = this.f1, f2 = this.f2, a = f1.dot(f2), b = f2.squared() - f1.squared(); - if (ts3dutils.eq0(a)) { - return this; - } - const g1 = 2 * a, g2 = b + Math.sqrt(b * b + 4 * a * a); - const { x1: xi, y1: eta } = intersectionUnitCircleLine(g1, g2, 0); - const f1RA = f1.times(xi).plus(f2.times(eta)); - const f2RA = f1.times(-eta).plus(f2.times(xi)); - return new EllipseCurve(this.center, f1RA, f2RA, -PI, PI); - } - isInfosWithEllipse(ellipse) { - if (this.normal.isParallelTo(ellipse.normal) && - ts3dutils.eq0(this.center.minus(ellipse.center).dot(ellipse.normal))) { - // ellipses are coplanar - const ellipseLCRA = ellipse.transform(this.matrixInverse).rightAngled(); - const r1 = ellipseLCRA.f1.lengthXY(), r2 = ellipseLCRA.f2.lengthXY(), centerDist = ellipseLCRA.center.lengthXY(); - const rMin = min(r1, r2), rMax = max(r1, r2); - if (ts3dutils.lt(centerDist + rMax, 1) || // entirely inside unit circle - ts3dutils.lt(1, centerDist - rMax) || // entirely outside unit circle - ts3dutils.lt(1, rMin - centerDist) || // contains unit circle - (ts3dutils.eq(1, r1) && ts3dutils.eq(1, r2) && ts3dutils.eq0(centerDist)) // also unit circle, return no IS - ) { - return []; - } - const f = (t) => ellipseLCRA.at(t).lengthXY() - 1; - const df = (t) => ellipseLCRA.at(t).xy().dot(ellipseLCRA.tangentAt(t)) / - ellipseLCRA.at(t).lengthXY(); - ts3dutils.checkDerivate(f, df, -PI, PI, 1); - const ellipseLCRATs = []; - for (let startT = (-4 / 5) * PI; startT < PI; startT += PI / 4) { - let t = ts3dutils.newtonIterateSmart(f, startT, 16, df, 1e-4); - ts3dutils.le(t, -PI) && (t += ts3dutils.TAU); - ts3dutils.assert(!isNaN(t)); - if (ts3dutils.between(t, -PI, PI) && - ts3dutils.eq0(f(t)) && - !ellipseLCRATs.some((r) => ts3dutils.eq(t, r))) { - ellipseLCRATs.push(t); - } - } - const result = []; - for (const ellipseLCRAT of ellipseLCRATs) { - const p = this.matrix.transformPoint(ellipseLCRA.at(ellipseLCRAT)); - if (this.containsPoint(p) && ellipse.containsPoint(p)) { - result.push({ tThis: this.pointT(p), tOther: ellipse.pointT(p), p }); - } - } - return result; - //const angle = ellipseLCRA.f1.angleXY() - //const aSqr = ellipseLCRA.f1.squared(), bSqr = ellipseLCRA.f2.squared() - //const a = Math.sqrt(aSqr), b = Math.sqrt(bSqr) - //const {x: centerX, y: centerY} = ellipseLCRA.center - //const rotCenterX = centerX * Math.cos(-angle) + centerY * -Math.sin(-angle) - //const rotCenterY = centerX * Math.sin(-angle) + centerY * Math.cos(-angle) - //const rotCenter = V(rotCenterX, rotCenterY) - //const f = t => { - // const lex = Math.cos(t) - rotCenterX, ley = Math.sin(t) - rotCenterY - // return lex * lex / aSqr + ley * ley / bSqr - 1 - //} - //const f2 = (x, y) => (x * x + y * y - 1) - //const f3 = (x, y) => ((x - rotCenterX) * (x - rotCenterX) / aSqr + (y - rotCenterY) * (y - rotCenterY) / - // bSqr - 1) const results = [] const resetMatrix = this.matrix.times(M4.rotateZ(angle)) for (let startT = - // Math.PI / 4; startT < 2 * Math.PI; startT += Math.PI / 2) { const startP = EllipseCurve.XY.at(startT) - // const p = newtonIterate2d(f3, f2, startP.x, startP.y, 10) if (p && !results.some(r => r.like(p))) { - // results.push(p) } } const rotEl = new EllipseCurve(rotCenter, V(a, 0, 0), V(0, b, 0)) return - // results.map(pLC => { const p = resetMatrix.transformPoint(pLC) return {tThis: this.pointT(p, PI), - // tOther: ellipse.pointT(p, PI), p} }) - } - else { - return ts3dutils.mapFilter(this.isTsWithPlane(P3.normalOnAnchor(ellipse.normal.unit(), ellipse.center)), (t) => { - const p = this.at(t); - if (ellipse.containsPoint(p)) { - return { tThis: t, tOther: ellipse.pointT(p), p }; - } - return undefined; - }); - } - } - isInfosWithCurve(curve) { - if (curve instanceof EllipseCurve) { - return this.isInfosWithEllipse(curve); - } - return super.isInfosWithCurve(curve); - } - transform4(m4) { - const tMap = (t) => sign(t) * sqrt((1 - cos(t)) / (1 + cos(t))); - // prettier-ignore - const parabolaToUnitEllipse = new ts3dutils.M4(0, -1, 0, 1, 2, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 1); - return parabola4Projection(ts3dutils.M4.product(m4, this.matrix, parabolaToUnitEllipse), tMap(this.tMin), tMap(this.tMax)); - } - roots() { - // tangent(t) = f2 cos t - f1 sin t - // solve for each dimension separately - // tangent(eta, xi) = f2 eta - f1 xi - return ts3dutils.arrayFromFunction(3, (dim) => { - const a = this.f2.e(dim); - const b = -this.f1.e(dim); - return intersectionUnitCircleLine2(a, b, 0) - .map(([xi, eta]) => Math.atan2(eta, xi)) - .filter((t) => this.isValidT(t)); - }); - } - closestTToPoint(p, tStart) { - // (at(t) - p) * tangentAt(t) = 0 - // (xi f1 + eta f2 + q) * (xi f2 - eta f1) = 0 - // xi eta (f2^2-f1^2) + xi f2 q - eta² f1 f2 + xi² f1 f2 - eta f1 q = 0 - // (xi² - eta²) f1 f2 + xi eta (f2^2-f1^2) + xi f2 q - eta f1 q = 0 - // atan2 of p is a good first approximation for the searched t - tStart = tStart || this.matrixInverse.transformPoint(p).angleXY(); - const pRelCenter = p.minus(this.center); - const f = (t) => this.tangentAt(t).dot(this.f1 - .times(Math.cos(t)) - .plus(this.f2.times(Math.sin(t))) - .minus(pRelCenter)); - return ts3dutils.newtonIterate1d(f, tStart, 8); - } - area() { - // see - // https://upload.wikimedia.org/wikipedia/commons/thumb/4/4e/Cross_product_parallelogram.svg/220px-Cross_product_parallelogram.svg.png - return Math.PI * this.f1.cross(this.f2).length(); - } - angleToT(phi) { - // atan2(y, x) = phi - const phiDir = this.f1 - .unit() - .times(Math.cos(phi)) - .plus(this.f2.rejectedFrom(this.f1).unit().times(Math.sin(phi))); - const dirLC = this.matrixInverse.transformVector(phiDir); - return dirLC.angleXY(); - } -} -EllipseCurve.UNIT = new EllipseCurve(ts3dutils.V3.O, ts3dutils.V3.X, ts3dutils.V3.Y); -EllipseCurve.prototype.hlol = Curve.hlol++; -EllipseCurve.prototype.tIncrement = (2 * Math.PI) / (4 * 32); - -/** - * Non-Uniform Rational B-Spline implementation. - * - * See https://pages.mtu.edu/~shene/COURSES/cs3621/NOTES/ for a good reference. - * - * - */ -class NURBS extends Curve { - constructor( - /** - * The control points of the NURBS curve, as 4D homogeneous coordinates. - */ - points, - /** - * The degree of the NURBS curve. Must be at least 1 (linear). - */ - degree, knots = NURBS.openUniformKnots(points.length, degree), tMin = knots[degree], tMax = knots[knots.length - degree - 1]) { - super(tMin, tMax); - this.points = points; - this.degree = degree; - this.knots = knots; - const knotsLength = points.length + degree + 1; - ts3dutils.NLA_DEBUG && Object.freeze(points); - ts3dutils.NLA_DEBUG && Object.freeze(knots); - ts3dutils.assert(knots.length === knotsLength, "bad knot vector length: expected " + - knotsLength + - " (degree = " + - degree + - " pcount = " + - points.length + - "), but was " + - knots.length); - ts3dutils.assert(knots[degree] <= tMin); - ts3dutils.assert(tMax <= knots[knots.length - degree - 1]); - for (let i = 0; i < points.length; i++) { - ts3dutils.assert(points[i].dim() == 4); - } - ts3dutils.assert(degree >= 1, "degree must be at least 1 (linear)"); - ts3dutils.assert(degree % 1 == 0); - ts3dutils.assert(-1 == ts3dutils.firstUnsorted(knots, ts3dutils.MINUS), "knot values must be in ascending order"); - } - getConstructorParameters() { - return [this.points, this.degree, this.knots]; - } - at4(t) { - ts3dutils.NLA_DEBUG && - ts3dutils.assert(ts3dutils.between(t, this.tMin, this.tMax), t + " " + this.tMin + " " + this.tMax); - const { points, degree, knots } = this; - // find s (the spline segment) for the [t] value provided - const s = this.tInterval(t); - const v = ts3dutils.Vector.pack(points, new Float64Array((degree + 1) * 4), s - degree, 0, degree + 1); - for (let level = 0; level < degree; level++) { - // build level l of the pyramid - for (let i = degree; i > level; i--) { - const alpha = (t - knots[i + s - degree]) / - (knots[i + s - level] - knots[i + s - degree]); - // interpolate each component - for (let dim = 0; dim < 4; dim++) { - v[i * 4 + dim] = - (1 - alpha) * v[(i - 1) * 4 + dim] + alpha * v[i * 4 + dim]; - } - } - } - return new ts3dutils.Vector(v.slice(degree * 4, (degree + 1) * 4)); - } - at(t) { - return this.at4(t).p3(); - } - /** - d(k, i, t) = a(i, k, t) * d(k - 1, i, t) + (1 - a(i, k, t)) * d(k - 1, i - 1, t) - a(i, k, t) = (t - knots[i]) / (knots[i + 1 + n - k] - knots[i]) - a'(i, k, t) = 1 / (knots[i + 1 + n - k] - knots[i]) - - d/dt = a(i, k, t) * d'(k - 1, i, t) + a'(i, k, t) * d(k - 1, i, t) - + (1 - a(i, k, t)) * d'(k - 1, i - 1, t) + a'(i, k, t) * d(k - 1, i - 1, t) - */ - ptDtDdt4(t) { - const { points, degree, knots } = this; - // find s (the spline segment) for the [t] value provided - const s = this.tInterval(t); - const v = ts3dutils.Vector.pack(points, new Float64Array((degree + 1) * 4), s - degree, 0, degree + 1); - let ddt = ts3dutils.Vector.Zero(4); - let derivative; - for (let level = 0; level < degree; level++) { - if (level == degree - 2) { - // see https://www.globalspec.com/reference/61012/203279/10-8-derivatives - const a = new ts3dutils.Vector(v.slice(degree * 4, (degree + 1) * 4)); - const b = new ts3dutils.Vector(v.slice((degree - 1) * 4, degree * 4)); - const c = new ts3dutils.Vector(v.slice((degree - 2) * 4, (degree - 1) * 4)); - function step(k, i, dkMinus1iMinus1, dkMinus1i) { - return dkMinus1i - .minus(dkMinus1iMinus1) - .times(k / (knots[i + degree - k] - knots[i - 1])); - } - ddt = step(degree, s + 1, step(degree - 1, s + 1, a, b), step(degree - 1, s, b, c)); - } - if (level == degree - 1) { - const a = new ts3dutils.Vector(v.slice(degree * 4, (degree + 1) * 4)); - const b = new ts3dutils.Vector(v.slice((degree - 1) * 4, degree * 4)); - derivative = b.minus(a).times(degree / (knots[s] - knots[s + 1])); - } - for (let i = degree; i > level; i--) { - const alpha = (t - knots[i + s - degree]) / - (knots[i + s - level] - knots[i + s - degree]); - // interpolate each component - for (let dim = 0; dim < 4; dim++) { - v[i * 4 + dim] = - (1 - alpha) * v[(i - 1) * 4 + dim] + alpha * v[i * 4 + dim]; - } - } - } - const p = new ts3dutils.Vector(v.slice(degree * 4, degree * 4 + 4)); - return [p, derivative, ddt]; - } - tangentAt(t) { - // x(t) = xw(t) / w(t) - // quotient rule - const [p, derivative] = this.ptDtDdt4(t); - const expected = derivative - .times(p.w) - .minus(p.times(derivative.w)) - .div(Math.pow(p.w, 2)) - .V3(); - return expected; - } - ddt(t) { - const [p, dt, ddt] = this.ptDtDdt4(t); - // =(-w(t) x(t) w''(t) - 2 w(t) w'(t) x'(t) + 2 x(t) w'(t)^2 + w(t)^2 x''(t))/w(t)^3 - // =(x(t) ((-w(t)) w''(t) + 2 w'(t)^2) - x'(t) 2 w(t) w'(t) + x''(t) w(t)^2 )/w(t)^3 - // prettier-ignore - return ts3dutils.Vector.add(p.times(-p.w * ddt.w + 2 * Math.pow(dt.w, 2)), dt.times(-2 * p.w * dt.w), ddt.times(Math.pow(p.w, 2))).div(Math.pow(p.w, 3)).V3(); - } - ptDtDdt(t) { - const [pt, dt4, ddt4] = this.ptDtDdt4(t); - return [ - pt.p3(), - dt4 - .times(pt.w) - .minus(pt.times(dt4.w)) - .div(Math.pow(pt.w, 2)) - .V3(), - ts3dutils.Vector.add(pt.times(-pt.w * ddt4.w + 2 * Math.pow(dt4.w, 2)), // - dt4.times(-2 * pt.w * dt4.w), ddt4.times(Math.pow(pt.w, 2))) - .div(Math.pow(pt.w, 3)) - .V3(), - ]; - } - pointT(pWC) { - return this.closestTToPoint(pWC); - } - closestTToPoint(p, tStart, tMin = this.tMin, tMax = this.tMax) { - // this.at(t) has minimal distance to p when this.tangentAt(t) is perpendicular to - // the vector between this.at(t) and p. This is the case iff the dot product of the two is 0. - // f = (this.at(t) - p) . (this.tangentAt(t) - // df = this.tangentAt(t) . this.tangentAt(t) + (this.at(t) - p) . this.ddt(t) - // = this.tangentAt(t)² + (this.at(t) - p) . this.ddt(t) - const f = (t) => { - const [pt, dt, ddt] = this.ptDtDdt(t); - return [pt.minus(p).dot(dt), dt.squared() + pt.minus(p).dot(ddt)]; - }; - //checkDerivate(f, df, tMin, tMax) - const STEPS = 32; - if (undefined === tStart) { - tStart = ts3dutils.withMax(ts3dutils.arraySamples(tMin, tMax, STEPS), (t) => -this.at(t).distanceTo(p)); - } - const result = ts3dutils.newtonIterateWithDerivative2(f, tStart, 8, this.tMin, this.tMax); - //assert(undefined !== result) - return result; - } - containsPoint(pWC) { - const tGuess = this.closestTToPoint(pWC); - return undefined === tGuess ? false : this.at(tGuess).like(pWC); - } - derivate() { - const k = this.degree; - const ps = ts3dutils.arrayFromFunction(this.points.length - 1, (i) => this.points[i] - .to(this.points[i + 1]) - .times(k / (this.knots[i + k + 1] - this.knots[i + 1]))); - return new NURBS(ps, this.degree - 1, this.knots.slice(1, -1), this.tMin, this.tMax); - } - /** - * Create a new NURBS of equal degree with the added knot [newKnot]. New NURBS will have one additional control - * point. - */ - withKnot(newKnot) { - ts3dutils.assert(ts3dutils.between(newKnot, this.tMin, this.tMax)); - const k = this.tInterval(newKnot); - const { knots, points, degree } = this; - const insertPoints = ts3dutils.arrayFromFunction(this.degree, (j) => { - const i = k - degree + 1 + j; - const aiNumerator = newKnot - knots[i]; - // 0/0 defined as 0: - const ai = aiNumerator == 0 ? 0 : aiNumerator / (knots[i + degree] - knots[i]); - ts3dutils.assert(ts3dutils.between(ai, 0, 1)); - return ts3dutils.Vector.lerp(points[i - 1], points[i], ai); - }); - const newPoints = points.slice(); - newPoints.splice(k - degree + 1, degree - 1, ...insertPoints); - const newKnots = knots.slice(); - newKnots.splice(k + 1, 0, newKnot); - return new NURBS(newPoints, degree, newKnots, this.tMin, this.tMax); - } - removeKnot(t) { - const { knots, points, degree } = this; - let k = this.tInterval(t), s = 0; // s = multiplicity of the knot - while (knots[k + 1] == t) { - k++; - s++; - } - if (s == 0) - throw new Error("There is no knot " + t + "!"); - // the points which were relevant when inserting were (k - p - 1) to (k - 1). (- 1) because the current k has - // been increased by one due to the insertion. - // p - 1 points were replaced by p points, hence we need to generate the original p - 1 point, + 1 to check if - // this transformation is valid. - const insertPoints = [points[k - degree - 1]]; - const oldKnots = knots.slice(); - oldKnots.splice(k, 1); - for (let i = k - degree; i <= k - s; i++) { - const alphaInv = (oldKnots[i + degree] - oldKnots[i]) / (t - oldKnots[i]); - const oldPoint = ts3dutils.Vector.lerp(ts3dutils.getLast(insertPoints), points[i], alphaInv); - insertPoints.push(oldPoint); - } - if (ts3dutils.getLast(insertPoints).like(points[k + 1 - s])) { - const oldPoints = points.slice(); - oldPoints.splice(k - degree - 1, degree - s + 3, ...insertPoints); - return new NURBS(oldPoints, degree, oldKnots); - } - return undefined; - } - static openUniformKnots(pointCount, degree, tMin = 0, tMax = 1) { - const knotsLength = pointCount + degree + 1; - return ts3dutils.arrayFromFunction(knotsLength, (i) => { - if (i <= degree) { - return tMin; - } - else if (i >= knotsLength - degree - 1) { - return tMax; - } - else { - return ts3dutils.lerp(tMin, tMax, (i - degree) / (knotsLength - degree * 2 - 1)); - } - }); - } - static bezierKnots(degree, tMin = 0, tMax = 1) { - const result = new Array((degree + 1) * 2); - for (let i = 0; i < degree + 1; i++) { - result[i] = tMin; - result[degree + 1 + i] = tMax; - } - return result; - } - static fromBezier(bezier) { - const bezier01 = bezier.selectPart(bezier.tMin, bezier.tMax); - return NURBS.Bezier(bezier01.points); - } - static Bezier(points, tMin = 0, tMax = 1) { - return new NURBS(points.map((p) => p instanceof ts3dutils.V3 ? new ts3dutils.Vector(new Float64Array([p.x, p.y, p.z, 1])) : p), points.length - 1, ts3dutils.arrayFromFunction(points.length * 2, (i) => (i < points.length ? 0 : 1)), tMin, tMax); - } - static fromHyperbola(hyperbola, tMin = hyperbola.tMin, tMax = hyperbola.tMax) { - const p0 = HyperbolaCurve.XY.at(tMin); - const p2 = HyperbolaCurve.XY.at(tMax); - const p1 = new ts3dutils.V3((sinh(tMin) - sinh(tMax)) / sinh(tMin - tMax), (cosh(tMin) - cosh(tMax)) / sinh(tMin - tMax), 0); - // M: midpoint between p0 and p2 - // X: intersection of line through p1 and M and unit hyperbola - // result.at(1/2) = X - // result.at(1/2) = (1/4 p0 + 1/2 p1 w + 1/4 p2) / (1/4 + 1/ 2 w + 1/4) - // result.at(1/2) = (1/2 p0 + p1 w + 1/2 p2) / (1 + w) - // result.at(1/2) = (M + p1 w) / (1 + w) = X - // => w * (p1 - X) = (X - M) - // as p1, X and M are all on the same line, we can solve this equation with only the x - const M = p0.lerp(p2, 0.5); - const Xx = 1 / sqrt(1 - Math.pow((M.y / M.x), 2)); - const w = (Xx - M.x) / (p1.x - Xx); - return NURBS.fromV3s([p0, p1, p2], 2, undefined, [1, w, 1]).transform(hyperbola.matrix); - } - static fromParabola(parabola) { - return NURBS.fromBezier(parabola.asBezier()); - } - static fromEllipse(ellipse) { - const unitSemiEllipse = new NURBS([ - ts3dutils.VV(1, 0, 0, 1), - ts3dutils.VV(1, 1, 0, 1).times(SQRT1_2), - ts3dutils.VV(0, 1, 0, 1), - ts3dutils.VV(-1, 1, 0, 1).times(SQRT1_2), - ts3dutils.VV(-1, 0, 0, 1), - ts3dutils.VV(-1, -1, 0, 1).times(SQRT1_2), - ts3dutils.VV(0, -1, 0, 1), - ], 2, [0, 0, 0, PI / 2, PI / 2, PI, PI, (3 * PI) / 2, (3 * PI) / 2, 2 * PI]); - return unitSemiEllipse.transform(ellipse.matrix); - } - /** - * Create a new NURBS from V3s, with optional weights. - * @param points - * @param degree - * @param knots - * @param weights - */ - static fromV3s(points, degree, knots, weights = ts3dutils.arrayFromFunction(points.length, () => 1)) { - ts3dutils.assert(points.length == weights.length); - return new NURBS(points.map((p, i) => ts3dutils.Vector.fromV3AndWeight(p, weights[i])), degree, knots); - } - isUniform(precision = 0) { - const intervals = ts3dutils.arrayFromFunction(this.knots.length - 1, (i) => this.knots[i + 1] - this.knots[i]); - const [min, max] = minAndMax(intervals); - return ts3dutils.eq(min, max, precision); - } - /** - * NURBS is a B spline if control points all have the same weight. - */ - isBSpline(precision = 0) { - const [minWeight, maxWeight] = minAndMax(this.points.map((p) => p.w)); - return ts3dutils.eq(minWeight, maxWeight, precision); - } - /** - * Whether this is a (rational) bezier curve. - */ - isBezier(precision = 0) { - if (this.degree + 1 != this.points.length) - return false; - const [min0, max0] = minAndMax(this.knots, 0, this.degree + 1); - if (!ts3dutils.eq(min0, max0, precision)) - return false; - const [min1, max1] = minAndMax(this.knots, this.degree + 1); - if (!ts3dutils.eq(min1, max1, precision)) - return false; - return true; - } - /** - * Splits NURBS curve into rational bezier curves. - * See https://pages.mtu.edu/~shene/COURSES/cs3621/NOTES/spline/B-spline/subdivision.html - */ - getSegments() { - const { knots, points, degree } = this; - const result = []; - const v = ts3dutils.Vector.pack(points, new Float64Array(points.length * 4)); - const vectorFromV = (i) => new ts3dutils.Vector(v.slice(i * 4, (i + 1) * 4)); - let k = degree + 1; // k = knot index we are duplicating - while (k < knots.length - degree - 1) { - const t = knots[k]; - const prevKnot = knots[k - 1]; - let s = 1; // s = multiplicity of the knot - while (knots[k + 1] == t) { - k++; - s++; - } - const newNURBSPoints = new Array(degree + 1); - // the first s + 1 points are identical to the current curve - for (let i = 0; i < s + 1; i++) { - newNURBSPoints[i] = vectorFromV(k - degree - s + i); - } - // we need to have multiplicity degree, so insert (degree - s) times - for (let level = 1; level <= degree - s; level++) { - for (let i = k - degree; i <= k - s - level; i++) { - const alpha = (t - prevKnot) / (knots[i + degree + 1] - prevKnot); - for (let dim = 0; dim < 4; dim++) { - v[i * 4 + dim] = - (1 - alpha) * v[i * 4 + dim] + alpha * v[(i + 1) * 4 + dim]; - } - } - newNURBSPoints[s + level] = vectorFromV(k - degree); - } - const newNURBSKnots = ts3dutils.arrayFromFunction((degree + 1) * 2, (i) => i < degree + 1 ? knots[k - s] : t); - result.push(new NURBS(newNURBSPoints, degree, newNURBSKnots)); - k++; - } - // last curve - const newNURBSPoints = ts3dutils.arrayFromFunction(degree + 1, (i) => vectorFromV(points.length - degree - 1 + i)); - const newNURBSKnots = ts3dutils.arrayFromFunction((degree + 1) * 2, (i) => i < degree + 1 ? knots[k - 1] : knots[k]); - result.push(new NURBS(newNURBSPoints, degree, newNURBSKnots)); - return result; - } - split(t) { - const { knots, points, degree } = this; - ts3dutils.assert(ts3dutils.le(this.tMin, t) && ts3dutils.le(t, this.tMax)); - let k = this.tInterval(t), s = 0; // s = multiplicity of the knot - while (knots[k + 1] == t) { - k++; - s++; - } - const vectorFromV = (i) => new ts3dutils.Vector(v.slice(i * 4, (i + 1) * 4)); - const leftPoints = new Array(k + 1 - s); - // the first k + s + 1 points are identical to the current curve - for (let i = 0; i < k + s - degree + 1; i++) { - leftPoints[i] = this.points[i]; - } - const rightPointsLength = points.length - (k - degree); - const v = ts3dutils.Vector.pack(points, new Float64Array(rightPointsLength * 4), k - degree); - // we need to have multiplicity degree, so insert (degree - s) times - for (let level = 1; level <= degree - s; level++) { - for (let i = k - degree; i <= k - s - level; i++) { - const alpha = (t - knots[i + level]) / (knots[i + degree + 1] - knots[i + level]); - const j = i - (k - degree); - for (let dim = 0; dim < 4; dim++) { - v[j * 4 + dim] = - (1 - alpha) * v[j * 4 + dim] + alpha * v[(j + 1) * 4 + dim]; - } - } - leftPoints[k - degree + level] = vectorFromV(0); - } - const leftKnots = knots.slice(0, k + degree + 2 - s); - for (let i = 0; i < degree - s + 1; i++) { - leftKnots[k - s + 1 + i] = t; - } - const rightKnots = knots.slice(k - degree); - for (let i = 0; i < degree + 1; i++) { - rightKnots[i] = t; - } - const rightPoints = ts3dutils.arrayFromFunction(rightPointsLength, (i) => ts3dutils.vArrGet(v, 4, i)); - return [ - new NURBS(leftPoints, degree, leftKnots), - new NURBS(rightPoints, degree, rightKnots), - ]; - } - simplify() { - ts3dutils.assert(this.isBezier()); - if (3 == this.degree && this.isBSpline()) { - return new BezierCurve(this.points[0].p3(), this.points[1].p3(), this.points[2].p3(), this.points[3].p3(), this.tMin, this.tMax); - } - else if (2 == this.degree) { - const [P0, P1, P2] = this.points; - const [p0, p1, p2] = this.points.map((p) => p.p3()); - const c = NURBS.simplifyUnit2(P0.w, P1.w, P2.w).transform(ts3dutils.M4.forSys(p1.to(p0), p1.to(p2), undefined, p1)); - const [tMin, tMax] = [c.pointT(p0), c.pointT(p2)].sort(); - return c.withBounds(ts3dutils.snap(tMin, c.tMin), ts3dutils.snap(tMax, c.tMax)); - } - else if (1 == this.degree) { - return L3.throughPoints(this.points[0].p3(), this.points[1].p3()); - } - else { - return this; - } - } - static simplifyUnit2(w0, w1, w2) { - // see https://math.stackexchange.com/a/2794874/230980 - const delta = w0 * w2 - Math.pow(w1, 2); - const cxy = (w0 * w2) / 2 / delta; - const center = new ts3dutils.V3(cxy, cxy, 0); - const k = (Math.pow(w1, 2) + delta - 2 * w1 * sqrt(abs(delta))) / 2 / delta; - const p = ts3dutils.V3.X; - const q = new ts3dutils.V3(k, cxy, 0); - // const q = new V3(cxy, k, 0) - if (ts3dutils.eq0(delta)) { - return new ParabolaCurve(new ts3dutils.V3(1 / 4, 1 / 4, 0), new ts3dutils.V3(1, -1, 0), new ts3dutils.V3(1, 1, 0), -0.5, 0.5); - } - else if (delta < 0) { - // hyperbola - return new HyperbolaCurve(center, center.to(p), center.to(q)); - } - else { - // ellipse - return new EllipseCurve(center, center.to(p), center.to(q), 0); - } - } - elevateDegreeBezier() { - ts3dutils.assert(this.isBezier()); - const newPoints = new Array(this.points.length + 1); - newPoints[0] = this.points[0]; - newPoints[this.points.length] = this.points[this.points.length - 1]; - for (let i = 1; i < this.points.length; i++) { - newPoints[i] = ts3dutils.Vector.lerp(this.points[i], this.points[i - 1], i / (this.degree + 1)); - } - const newKnots = NURBS.bezierKnots(this.degree + 1, this.knots[0], this.knots[this.degree + 1]); - return new NURBS(newPoints, this.degree + 1, newKnots, this.tMin, this.tMax); - } - elevateDegree() { - const segmentsElevated = this.getSegments().map((b) => b.elevateDegreeBezier()); - // stitch together the segments - const newPoints = new Array(2 + segmentsElevated.length * this.degree); - newPoints[0] = segmentsElevated[0].points[0]; - ts3dutils.setLast(newPoints, ts3dutils.getLast(ts3dutils.getLast(segmentsElevated).points)); - for (let i = 0; i < segmentsElevated.length; i++) { - for (let pi = 1; pi < segmentsElevated[i].points.length - 1; pi++) { - newPoints[i * (segmentsElevated[0].points.length - 2) + pi] = - segmentsElevated[i].points[pi]; - } - } - const newKnots = new Array(newPoints.length + this.degree + 2); - for (let i = 0; i < this.degree + 2; i++) { - newKnots[i] = this.knots[0]; - } - for (let i = 0; i < segmentsElevated.length; i++) { - for (let pi = 1; pi < segmentsElevated[i].points.length - 1; pi++) { - newKnots[i * (segmentsElevated[0].points.length - 2) + pi + this.degree + 1] = ts3dutils.getLast(segmentsElevated[i].knots); - } - } - newKnots[newKnots.length - 1] = ts3dutils.getLast(this.knots); - newKnots[newKnots.length - 2] = ts3dutils.getLast(this.knots); - let result = new NURBS(newPoints, this.degree + 1, newKnots, this.tMin, this.tMax); - for (let i = 0; i < segmentsElevated.length - 1; i++) { - let optimization; - while ((optimization = result.removeKnot(ts3dutils.getLast(segmentsElevated[i].knots)))) { - result = optimization; - } - } - return result; - } - transform(m4) { - return this.transform4(m4); - } - transform4(m4) { - return new NURBS(this.points.map((p) => m4.timesVector(p)), this.degree, this.knots, this.tMin, this.tMax); - } - /** - * Returns the index of the interval which contains the value t. - */ - tInterval(t) { - const { degree, knots } = this; - for (let s = degree; s < knots.length - 1 - degree; s++) { - if (t >= knots[s] && t <= knots[s + 1]) { - return s; - } - } - throw new Error(t + " " + knots); - } - static UnitCircle(sections = 2, tMin = 0, tMax = PI) { - const dt = tMax - tMin; - const tStep = dt / sections; - const w = sin(PI / 2 - tStep / 2); - // cos - const r = 1 / cos(tStep / 2); - const points = ts3dutils.arrayFromFunction(sections * 2 + 1, (i) => { - const t = ts3dutils.lerp(tMin, tMax, i / 2 / sections); - if (i % 2 == 0) { - // control point on circle - return ts3dutils.VV(cos(t), sin(t), 0, 1); - } - else { - return ts3dutils.VV(r * w * cos(t), r * w * sin(t), 0, w); - } - }); - const knots = []; - knots.push(tMin, tMin, tMin); - for (let i = 0; i < sections - 1; i++) { - const knot = ts3dutils.lerp(tMin, tMax, (i + 1) / sections); - knots.push(knot, knot); - } - knots.push(tMax, tMax, tMax); - return new NURBS(points, 2, knots); - } - debugInfo() { - return { - points: [ - ...this.knots.slice(this.degree, -this.degree).map((t) => this.at(t)), - ...this.points.map((p) => p.p3()), - ], - lines: this.points.flatMap((p, i, ps) => ps[i + 1] ? [p.p3(), ps[i + 1].p3()] : []), - }; - } - isTsWithPlane(planeWC) { - const { knots, degree, points } = this; - const controlPointTs = [ - knots[degree], - ...points - .slice(1, -1) - .map((p, i) => this.closestTToPoint(p.p3(), undefined, knots[i + 3], knots[i + degree])), - knots[knots.length - degree - 1], - ]; - const result = []; - for (let i = 0; i < this.points.length - 1; i++) { - const findClosest = (startT) => { - console.log("startT", startT); - // try { - const f = (t) => { - const [p, dt] = this.ptDtDdt(t); - return [planeWC.distanceToPointSigned(p), planeWC.normal1.dot(dt)]; - }; - let t = ts3dutils.newtonIterateWithDerivative2(f, startT, 8, this.tMin, this.tMax); - let [distanceAtT, distanceDtAtT] = undefined === t ? [undefined, undefined] : f(t); - if (t === undefined || !ts3dutils.eq0(distanceAtT) || ts3dutils.eq0(distanceDtAtT)) { - t = ts3dutils.newtonIterateWithDerivative2((t) => { - const [, dt, ddt] = this.ptDtDdt(t); - return [planeWC.normal1.dot(dt), planeWC.normal1.dot(ddt)]; - }, startT, 8, this.tMin, this.tMax); - } - [distanceAtT, distanceDtAtT] = undefined === t ? [] : f(t); - if (undefined !== t && - ts3dutils.eq0(distanceAtT) && - !result.some((r) => ts3dutils.eq(r, t))) { - result.push(t); - } - }; - const a = this.points[i].p3(); - const b = this.points[i + 1].p3(); - const ad = ts3dutils.snap0(planeWC.distanceToPointSigned(a)); - const bd = ts3dutils.snap0(planeWC.distanceToPointSigned(b)); - if (ad * bd < 0) { - const startT = ts3dutils.lerp(controlPointTs[i], controlPointTs[i + 1], ad / (ad - bd)); - findClosest(startT); - } - else if (0 == bd) { - findClosest(this.closestTToPoint(b, controlPointTs[i + 1])); - } - } - return result; - } - isInfosWithCurve(curveWC) { - if (curveWC instanceof L3) { - return this.isInfosWithLine(curveWC.anchor, curveWC.dir1); - } - return super.isInfosWithCurve(curveWC); - } - isInfosWithLine(anchor, dir) { - const thisPlane = P3.fromPoints(this.points.map((p) => p.p3())); - const l = L3.anchorDirection(anchor, dir); - const maxDistanceToPlane = ts3dutils.max(this.points.map((p) => thisPlane.distanceToPoint(p.p3()))); - const thisIsPlanar = ts3dutils.eq0(maxDistanceToPlane); - if (thisIsPlanar && !thisPlane.containsLine(l)) { - const [t] = l.isTsWithPlane(thisPlane); - if (undefined === t) - return []; - const p = l.at(t); - return this.containsPoint(p) - ? [{ tThis: this.pointT(p), tOther: L3.pointT(anchor, dir, p), p }] - : []; - } - else { - const thisTs = this.isTsWithPlane(P3.normalOnAnchor(thisPlane.normal1.cross(dir), anchor)); - const infos = thisTs.map((tThis) => { - const p = this.at(tThis); - return { tThis, tOther: L3.pointT(anchor, dir, p), p }; - }); - return thisIsPlanar - ? infos - : infos.filter((info) => L3.containsPoint(anchor, dir, info.p)); - } - } - roots() { - console.log(this.tMin, this.tMax); - ts3dutils.arraySamples(this.tMin, this.tMax, 30).forEach((t) => { - console.log(t + "," + this.tangentAt(t).z); - }); - const result = [[], [], []]; - for (let i = 0; i < this.points.length - 1; i++) { - const findClosest = (startT, d) => { - console.log("d", d, "startT", startT); - // try { - const root = ts3dutils.newtonIterateWithDerivative2((t) => { - const [, dt, ddt] = this.ptDtDdt(t); - return [dt.e(d), ddt.e(d)]; - }, startT, 8, this.tMin, this.tMax); - if (undefined !== root) { - result[d].push(root); - } - console.log("d", d, "startT", startT, "root", root); - }; - const a = this.points[i].p3(); - const b = this.points[i + 1].p3(); - const ab = a.to(b); - for (let d = 0; d < 3; d++) { - if (0 !== i && ts3dutils.eq0(ab.e(d))) { - const startT = ts3dutils.lerp(this.knots[i], this.knots[i + this.degree + 2], 0.5); - findClosest(startT, d); - } - else if (i < this.points.length - 2) { - const bc = b.to(this.points[i + 2].p3()); - if (!ts3dutils.eq0(bc.e(d)) && ab.e(d) * bc.e(d) < 0) { - findClosest(this.closestTToPoint(b, this.guessTClosestToControlPoint(i + 1)), d); - } - } - } - } - console.log(result); - return result; - } - //getAABB() { - // return new AABB().addPoints(this.points.map(p => p.p3())) - //} - /** - * Rough approximation of t param for points closest to control point. - */ - guessTClosestToControlPoint(pointIndex) { - return ts3dutils.lerp(this.knots[pointIndex], this.knots[pointIndex + this.degree + 1], 0.5); - } - likeCurve(curve) { - return (this == curve || - (ts3dutils.hasConstructor(curve, NURBS) && - this.degree === curve.degree && - this.points.every((p, i) => p.like(curve.points[i])) && - this.knots.every((k, i) => ts3dutils.eq(k, curve.knots[i])))); - } - isColinearTo(curve) { - throw new Error("This doesn't even make sense."); - } -} -NURBS.EX2D = NURBS.fromV3s([ - ts3dutils.V(51, 141), - ts3dutils.V(11, 76), - ts3dutils.V(29, 32), - ts3dutils.V(46, 102), - ts3dutils.V(74, 148), - ts3dutils.V(189, 107), - ts3dutils.V(56, 10), - ts3dutils.V(206, 10), - ts3dutils.V(211, 98), - ts3dutils.V(195, 141), - ts3dutils.V(139, 148), -], 4); -NURBS.EX3D = new NURBS([ - ts3dutils.VV(94, 0, -34, 1), - ts3dutils.VV(69, 57, 45, 0.5), - ts3dutils.VV(-20, 44, 91, 1), - ts3dutils.VV(-89, -13, 47, 0.5), - ts3dutils.VV(-56, -97, -7, 1), - ts3dutils.VV(34, -83, -54, 0.5), - ts3dutils.VV(112, -53, 16, 1), - ts3dutils.VV(79, 30, 70, 0.5), - ts3dutils.VV(-2, -9, 141, 1), - ts3dutils.VV(-80, -40, 72, 0.5), - ts3dutils.VV(-38, -150, 43, 1), - ts3dutils.VV(43, -110, -29, 0.5), - ts3dutils.VV(130, -106, 65, 1), -], 2, [-12, -12, -12, -8, -8, -4, -4, 0, 0, 4, 4, 8, 8, 12, 12, 12]); -NURBS.prototype.tIncrement = 1 / 128; -function minAndMax(arr, start = 0, end = arr.length) { - let min = Infinity, max = -Infinity; - for (let i = start; i < end; i++) { - if (min > arr[i]) - min = arr[i]; - if (max < arr[i]) - max = arr[i]; - } - return [min, max]; -} - -/** - * Plane x DOT this.normal1 = this.w - */ -class P3 extends ts3dutils.Transformable { - /** - * Oriented plane, i.e. splits R^3 in half, with one half being "in front" of the plane. - * Leads to multiple comparisons: isCoplanarToPlane returns if the plane occupies the same space, - * like returns if the plane occupies the same space and has the same orientation - * - * Points x on the plane fulfill the equation: normal1 DOT x = w - * - * @param normal1 unit plane normal1 - * @param w signed (rel to normal1) distance from the origin - */ - constructor(normal1, w = 0) { - super(); - this.normal1 = normal1; - this.w = w; - ts3dutils.assertVectors(normal1); - ts3dutils.assertNumbers(w); - ts3dutils.assert(normal1.hasLength(1), "normal1.hasLength(1)" + normal1); - } - get anchor() { - return this.normal1.times(this.w); - } - static throughPoints(a, b, c) { - ts3dutils.assertVectors(a, b, c); - const n1 = b.minus(a).cross(c.minus(a)).unit(); - return new P3(n1, n1.dot(a)); - } - static normalOnAnchor(normal, anchor) { - ts3dutils.assertVectors(normal, anchor); - const n1 = normal.unit(); - return new this(n1, n1.dot(anchor)); - } - /** - * Create a plane which intersects the X, Y and Z axes at the specified offsets. - * x/x0 + y/y0 + y/y0 = 1 - */ - static forAxisIntercepts(x0, y0, z0) { - ts3dutils.assertNumbers(x0, y0, z0); - const normal = new ts3dutils.V3(1 / x0, 1 / y0, 1 / z0); - return new P3(normal.unit(), normal.length()); - } - /** - * Create a plane containing `anchor` and extending in directions `v0` and `v1`. - * `v0` and `v1` may not be parallel. - * @param anchor - * @param v0 - * @param v1 - */ - static forAnchorAndPlaneVectors(anchor, v0, v1) { - ts3dutils.assertVectors(anchor, v0, v1); - ts3dutils.assert(!v0.isParallelTo(v1)); - return this.normalOnAnchor(v0.cross(v1), anchor); - } - /** - * Create a plane which contains botha point and a line. The point may not lie on the line. - * @param p - * @param line - */ - static forPointAndLine(p, line) { - return this.forAnchorAndPlaneVectors(line.anchor, line.dir1, line.anchor.to(p)); - } - /** - * ax + by + cz + d = 0 - */ - static forABCD(a, b, c, d) { - const normalLength = Math.hypot(a, b, c); - if (ts3dutils.eq0(normalLength)) - return undefined; - return new P3(new ts3dutils.V3(a / normalLength, b / normalLength, c / normalLength), -d / normalLength); - } - static vanishingPlane(m4) { - return P3.forABCD(m4.m[12], m4.m[13], m4.m[14], m4.m[15]); - } - static forAABB(aabb, distance = 0) { - return [ - new P3(ts3dutils.V3.X, aabb.max.x + distance), - new P3(ts3dutils.V3.X.negated(), -aabb.min.x - distance), - new P3(ts3dutils.V3.Y, aabb.max.y + distance), - new P3(ts3dutils.V3.Y.negated(), -aabb.min.y - distance), - new P3(ts3dutils.V3.Z, aabb.max.z + distance), - new P3(ts3dutils.V3.Z.negated(), -aabb.min.z - distance), - ]; - } - // Fit a plane to a collection of points. - // Fast, and accurate to within a few degrees. - // Returns None if the points do not span a plane. - static fromPoints(points) { - const n = points.length; - if (n < 3) { - return undefined; - } - const centroid = ts3dutils.V3.add(...points).div(n); - // Calculate full 3x3 covariance matrix, excluding symmetries: - let xx = 0.0; - let xy = 0.0; - let xz = 0.0; - let yy = 0.0; - let yz = 0.0; - let zz = 0.0; - for (const p of points) { - const r = p.minus(centroid); - xx += r.x * r.x; - xy += r.x * r.y; - xz += r.x * r.z; - yy += r.y * r.y; - yz += r.y * r.z; - zz += r.z * r.z; - } - xx /= n; - xy /= n; - xz /= n; - yy /= n; - yz /= n; - zz /= n; - let weighted_dir = ts3dutils.V3.O; - { - const det_x = yy * zz - yz * yz; - const axis_dir = new ts3dutils.V3(det_x, xz * yz - xy * zz, xy * yz - xz * yy); - let weight = det_x * det_x; - if (weighted_dir.dot(axis_dir) < 0.0) { - weight = -weight; - } - weighted_dir = weighted_dir.plus(axis_dir.times(weight)); - } - { - const det_y = xx * zz - xz * xz; - const axis_dir = new ts3dutils.V3(xz * yz - xy * zz, det_y, xy * xz - yz * xx); - let weight = det_y * det_y; - if (weighted_dir.dot(axis_dir) < 0.0) { - weight = -weight; - } - weighted_dir = weighted_dir.plus(axis_dir.times(weight)); - } - { - const det_z = xx * yy - xy * xy; - const axis_dir = new ts3dutils.V3(xy * yz - xz * yy, xy * xz - yz * xx, det_z); - let weight = det_z * det_z; - if (weighted_dir.dot(axis_dir) < 0.0) { - weight = -weight; - } - weighted_dir = weighted_dir.plus(axis_dir.times(weight)); - } - const normal = weighted_dir.unit(); - return P3.normalOnAnchor(normal, centroid); - } - axisIntercepts() { - const w = this.w, n = this.normal1; - return new ts3dutils.V3(w / n.x, w / n.y, w / n.z); - } - isCoplanarToPlane(plane) { - ts3dutils.assertInst(P3, plane); - return this.like(plane) || this.likeFlipped(plane); - } - like(plane) { - ts3dutils.assertInst(P3, plane); - return ts3dutils.eq(this.w, plane.w) && this.normal1.like(plane.normal1); - } - likeFlipped(plane) { - ts3dutils.assertInst(P3, plane); - return ts3dutils.eq(this.w, -plane.w) && this.normal1.like(plane.normal1.negated()); - } - /** - * True iff plane.normal1 is equal to this.normal1 or it's negation. - * - */ - isParallelToPlane(plane) { - ts3dutils.assertInst(P3, plane); - return ts3dutils.eq(1, Math.abs(this.normal1.dot(plane.normal1))); - } - isParallelToLine(line) { - ts3dutils.assertInst(_.L3, line); - return ts3dutils.eq0(this.normal1.dot(line.dir1)); - } - isPerpendicularToLine(line) { - ts3dutils.assertInst(_.L3, line); - // this.normal1 || line.dir1 - return ts3dutils.eq(1, Math.abs(this.normal1.dot(line.dir1))); - } - isPerpendicularToPlane(plane) { - ts3dutils.assertInst(P3, plane); - return ts3dutils.eq0(this.normal1.dot(plane.normal1)); - } - toSource() { - return ts3dutils.callsce("new P3", this.normal1, this.w); - } - translated(offset) { - return new P3(this.normal1, this.w + offset.dot(this.normal1)); - } - transform(m4) { - // See https://stackoverflow.com/questions/7685495/transforming-a-3d-plane-using-a-4x4-matrix - // See http://www.songho.ca/opengl/gl_normaltransform.html - // with homogeneous coordinates, the hessian normal form of this plane is - // (p, 1) * (normal1, -w) = 0 - // transformation: (m4^-1 * (p, 1)) DOT (normal1, -w) = 0 - // => (p, 1) DOT ((m4^-T) * (normal1, -w)) = 0 - // (validity of the above transformation is easily seen by expanding the matrix multiplication and dot product) - // hence, (newNormal, newW) = (m4^-T) * (normal1, -w) - // we divide both newNormal and newW by newNormal.length() to normalize the normal vector - const m4InversedTransposed = ts3dutils.M4.transpose(ts3dutils.M4.inverse(m4, ts3dutils.M4.temp0), ts3dutils.M4.temp1); - const [nx, ny, nz] = this.normal1; - const newNormal = m4InversedTransposed.timesVector(ts3dutils.VV(nx, ny, nz, -this.w)); - return P3.forABCD(newNormal.x, newNormal.y, newNormal.z, newNormal.w); - } - distanceToLine(line) { - ts3dutils.assertInst(_.L3, line); - if (!this.isParallelToLine(line)) { - return this.distanceToPoint(line.anchor); - } - else { - return 0; - } - } - containsPoint(x) { - ts3dutils.assertVectors(x); - return ts3dutils.eq(this.w, this.normal1.dot(x)); - } - containsLine(line) { - ts3dutils.assertInst(_.L3, line); - return this.containsPoint(line.anchor) && this.isParallelToLine(line); - } - distanceToPointSigned(point) { - ts3dutils.assertInst(ts3dutils.V3, point); - return this.normal1.dot(point) - this.w; - } - distanceToPoint(point) { - ts3dutils.assertInst(ts3dutils.V3, point); - return Math.abs(this.normal1.dot(point) - this.w); - } - intersectionWithLine(line) { - return line.intersectionWithPlane(this); - } - intersectionWithPlane(plane) { - ts3dutils.assertInst(P3, plane); - /* - - this: n0 * x = w0 - plane: n1 * x = w1 - plane perpendicular to both which goes through origin: - n2 := n0 X x1 - n2 * x = 0 - */ - if (this.isParallelToPlane(plane)) { - return undefined; - } - /* - var n0 = this.normal1, n1 = plane.normal1, n2 = n0.cross(n1).unit(), m = M4.forSys(n0, n1, n2) - var x0 = this.anchor, x1 = plane.anchor, x2 = V3.O - var p = n2.times(x2.dot(n2)) - .plus(n1.cross(n2).times(x0.dot(n0))) - .plus(n2.cross(n0).times(x1.dot(n1))) - .div(m.determinant()) - */ - const n0 = this.normal1, n1 = plane.normal1, n2 = n0.cross(n1).unit(); - const p = ts3dutils.M4.forRows(n0, n1, n2) - .inversed() - .transformVector(new ts3dutils.V3(this.w, plane.w, 0)); - return new _.L3(p, n2); - } - /** - * Returns the point in the plane closest to the given point - * - */ - projectedPoint(x) { - // See http://math.stackexchange.com/questions/444968/project-a-point-in-3d-on-a-given-plane - // p = x - ((x - planeAnchor) * normal1) * normal1 - return x.minus(this.normal1.times(x.minus(this.anchor).dot(this.normal1))); - } - projectedVector(x) { - // See V3.rejectedFrom. Simplified, as this.normal1.length() == 1 - return x.minus(this.normal1.times(x.dot(this.normal1))); - } - flipped() { - return new P3(this.normal1.negated(), -this.w); - } - containsCurve(curve) { - if (curve instanceof _.L3) { - return this.containsLine(curve); - } - else if (curve instanceof _.EllipseCurve || - curve instanceof _.HyperbolaCurve || - curve instanceof _.ParabolaCurve) { - return (this.containsPoint(curve.center) && - this.normal1.isParallelTo(curve.normal)); - } - else if (curve instanceof _.BezierCurve) { - return curve.points.every((p) => this.containsPoint(p)); - } - else { - throw new Error("" + curve); - } - } - equals(obj) { - return (ts3dutils.hasConstructor(obj, P3) && - this.normal1.equals(obj.normal1) && - this.w == obj.w); - } - hashCode() { - return (this.normal1.hashCode() * 31) | (0 + ts3dutils.floatHashCode(this.w)); - } -} -P3.YZ = new P3(ts3dutils.V3.X, 0); -P3.ZX = new P3(ts3dutils.V3.Y, 0); -P3.XY = new P3(ts3dutils.V3.Z, 0); - -class Surface extends ts3dutils.Transformable { - static loopContainsPointGeneral(loop, pWC, testLine, lineOut) { - const testPlane = __.P3.normalOnAnchor(lineOut, pWC); - // edges colinear to the testing line; these will always be counted as "inside" relative to the testing line - const colinearEdges = loop.map((edge) => edge.colinearToLine(testLine)); - let inside = false; - function logIS(isP) { - const isT = testLine.pointT(isP); - if (ts3dutils.eq0(isT)) { - return true; - } - else if (isT > 0) { - inside = !inside; - } - return false; - } - for (let edgeIndex = 0; edgeIndex < loop.length; edgeIndex++) { - const edge = loop[edgeIndex]; - const nextEdgeIndex = (edgeIndex + 1) % loop.length, nextEdge = loop[nextEdgeIndex]; - //console.log(edge.toSource()) {p:V(2, -2.102, 0), - if (colinearEdges[edgeIndex]) { - const lineAT = testLine.pointT(edge.a), lineBT = testLine.pointT(edge.b); - if (Math.min(lineAT, lineBT) <= ts3dutils.NLA_PRECISION && - -ts3dutils.NLA_PRECISION <= Math.max(lineAT, lineBT)) { - return exports.PointVsFace.ON_EDGE; - } - // edge colinear to intersection - const nextInside = colinearEdges[nextEdgeIndex] || - __.dotCurve2(nextEdge.curve, nextEdge.aT, lineOut, sign(nextEdge.deltaT())) < 0; - if (!nextInside) { - if (logIS(edge.b)) - return exports.PointVsFace.ON_EDGE; - } - } - else { - for (const edgeT of edge.edgeISTsWithPlane(testPlane)) { - if (edgeT == edge.bT) { - if (!testLine.containsPoint(edge.b)) - continue; - // endpoint lies on intersection line - if (edge.b.like(pWC)) { - // TODO: refactor, dont check for different sides, just logIs everything - return exports.PointVsFace.ON_EDGE; - } - const edgeInside = __.dotCurve2(edge.curve, edge.bT, lineOut, -sign(edge.deltaT())) < 0; - const nextInside = colinearEdges[nextEdgeIndex] || - __.dotCurve2(nextEdge.curve, nextEdge.aT, lineOut, sign(nextEdge.deltaT())) < 0; - if (edgeInside != nextInside) { - if (logIS(edge.b)) - return exports.PointVsFace.ON_EDGE; - } - } - else if (edgeT != edge.aT) { - const p = edge.curve.at(edgeT); - if (!testLine.containsPoint(p)) - continue; - // edge crosses line, neither starts nor ends on it - if (logIS(p)) - return exports.PointVsFace.ON_EDGE; - // TODO: tangents? - } - } - } - } - return inside ? exports.PointVsFace.INSIDE : exports.PointVsFace.OUTSIDE; - } - static loopContainsPointEllipse(loop, pWC, testLine, pWCT) { - const lineOut = testLine.normal; - const testPlane = __.P3.normalOnAnchor(testLine.normal, pWC); - const colinearEdges = loop.map((edge) => testLine.isColinearTo(edge.curve)); - let inside = false; - if (undefined === pWCT) { - pWCT = testLine.pointT(pWC); - } - const pT = pWCT; - function logIS(isP) { - const isT = testLine.pointT(isP); - if (ts3dutils.eq(pT, isT)) { - return true; - } - else if (pT < isT && ts3dutils.le(isT, PI)) { - inside = !inside; - } - return false; - } - for (let edgeIndex = 0; edgeIndex < loop.length; edgeIndex++) { - const edge = loop[edgeIndex]; - const nextEdgeIndex = (edgeIndex + 1) % loop.length, nextEdge = loop[nextEdgeIndex]; - //console.log(edge.toSource()) {p:V(2, -2.102, 0), - if (colinearEdges[edgeIndex]) { - let edgeT; - if (edge.curve.containsPoint(pWC) && - ts3dutils.le(edge.minT, (edgeT = edge.curve.pointT(pWC))) && - ts3dutils.le(edgeT, edge.maxT)) { - return exports.PointVsFace.ON_EDGE; - } - // edge colinear to intersection - const nextInside = colinearEdges[nextEdgeIndex] || - __.dotCurve2(nextEdge.curve, nextEdge.aT, lineOut, sign(nextEdge.deltaT())) < 0; - if (!nextInside && testLine.containsPoint(edge.b)) { - if (logIS(edge.b)) - return exports.PointVsFace.ON_EDGE; - } - } - else { - for (const edgeT of edge.edgeISTsWithPlane(testPlane)) { - if (edgeT == edge.bT) { - if (!testLine.containsPoint(edge.b)) - continue; - // endpoint lies on intersection testLine - const edgeInside = __.dotCurve2(edge.curve, edge.bT, lineOut, -sign(edge.deltaT())) < 0; - const nextInside = colinearEdges[nextEdgeIndex] || - __.dotCurve2(nextEdge.curve, nextEdge.aT, lineOut, sign(nextEdge.deltaT())) < 0; - if (edgeInside != nextInside) { - if (logIS(edge.b)) - return exports.PointVsFace.ON_EDGE; - } - } - else if (edgeT != edge.aT) { - const p = edge.curve.at(edgeT); - if (!testLine.containsPoint(p)) - continue; - // edge crosses testLine, neither starts nor ends on it - if (logIS(p)) - return exports.PointVsFace.ON_EDGE; - // TODO: tangents? - } - } - } - } - return inside ? exports.PointVsFace.INSIDE : exports.PointVsFace.OUTSIDE; - } - toString() { - return this.toSource(); - } - toSource(rounder = (x) => x) { - return ts3dutils.callsce.call(undefined, "new " + this.constructor.name, ...this.getConstructorParameters()); - } - /** - * Return points which would touch AABB. Doesnt include borders due to parametric bounds, for example. - */ - getExtremePoints() { - return []; - } - isCurvesWithSurface(surface) { - return surface.isCurvesWithSurface(this); //.map(curve => curve.reversed()) - } - containsCurve(curve) { - if (curve instanceof __.PPCurve) { - if (this.equals(curve.parametricSurface1) || - this.equals(curve.parametricSurface2)) { - return true; - } - } - if (curve instanceof __.ImplicitCurve) { - for (let i = ceil(curve.tMin) + 1; i <= floor(curve.tMax) - 1; i++) { - if (!this.containsPoint(curve.points[i])) { - return false; - } - } - return true; - } - return false; - } - flipped2(doFlip) { - return doFlip ? this.flipped() : this; - } - clipCurves(curves) { - return curves; - } - equals(obj) { - return (this === obj || - (this.constructor === obj.constructor && - ts3dutils.arrayEquals(this.getConstructorParameters(), obj.getConstructorParameters()))); - } - hashCode() { - return ts3dutils.arrayHashCode(this.getConstructorParameters()); - } - zDirVolume(allEdges) { - return this.visit(__.ZDirVolumeVisitor, allEdges); - } - calculateArea(allEdges) { - return this.visit(__.CalculateAreaVisitor, allEdges); - } -} -(function (PointVsFace) { - PointVsFace[PointVsFace["INSIDE"] = 0] = "INSIDE"; - PointVsFace[PointVsFace["OUTSIDE"] = 1] = "OUTSIDE"; - PointVsFace[PointVsFace["ON_EDGE"] = 2] = "ON_EDGE"; -})(exports.PointVsFace || (exports.PointVsFace = {})); - -class ParametricSurface extends __.Surface { - constructor(uMin, uMax, vMin, vMax) { - super(); - this.uMin = uMin; - this.uMax = uMax; - this.vMin = vMin; - this.vMax = vMax; - ts3dutils.assertNumbers(uMin, uMax, vMin, vMax); - ts3dutils.assert(uMin < uMax); - ts3dutils.assert(vMin < vMax); - ts3dutils.assert(ts3dutils.emod(this.getConstructorParameters(), -4) == this.uMin, this.getConstructorParameters(), this.uMin); - } - static isCurvesParametricImplicitSurface(ps, is, uStep, vStep = uStep, curveStepSize) { - const pf = ps.pUVFunc(), icc = is.implicitFunction(); - const dpdu = ps.dpdu(); - const dpdv = ps.dpdv(); - const didp = is.didp.bind(is); - const ist = (x, y) => icc(pf(x, y)); - const didu = (u, v) => didp(pf(u, v)).dot(dpdu(u, v)); - const didv = (u, v) => didp(pf(u, v)).dot(dpdv(u, v)); - const mf = __.MathFunctionR2R.forFFxFy(ist, didu, didv); - const curves = __.Curve.breakDownIC(mf, ps, uStep, vStep, curveStepSize, (u, v) => is.containsPoint(pf(u, v))).map(({ points, tangents }, _i) => __.PICurve.forParametricPointsTangents(ps, is, points, tangents, curveStepSize)); - return curves; - } - static isCurvesParametricParametricSurface(ps1, ps2, s1Step, t1Step = s1Step, curveStepSize) { - return __.breakDownPPCurves(ps1, ps2, s1Step, t1Step, curveStepSize); - } - static is(obj) { - return obj.pUVFunc; - } - pUV(u, v) { - return this.pUVFunc()(u, v); - } - pUVFunc() { - return this.pUV.bind(this); - } - uvP(pWC) { - return this.uvPFunc()(pWC); - } - uvPFunc() { - return this.uvP.bind(this); - } - bounds(u, v) { - return this.uMin <= u && u <= this.uMax && this.vMin <= v && v <= this.vMax; - } - /** - * Positive values are inside bounds. - */ - boundsSigned(u, v) { - return min(u - this.uMin, this.uMax - u, v - this.vMin, this.vMax - v); - } - normalP(p) { - const pmPoint = this.uvPFunc()(p); - return this.normalUV(pmPoint.x, pmPoint.y); - } - normalUVFunc() { - return this.normalUV.bind(this); - } - normalUV(u, v) { - return this.normalUVFunc()(u, v); - } - parametersValid(u, v) { - return ts3dutils.between(u, this.uMin, this.uMax) && ts3dutils.between(v, this.vMin, this.vMax); - } - toMesh(uStep = this.uStep, vStep = this.vStep) { - ts3dutils.assert(isFinite(this.vMin) && - isFinite(this.vMax) && - isFinite(this.uMin) && - isFinite(this.uMax)); - ts3dutils.assert(isFinite(uStep) && isFinite(vStep)); - return tsgl.Mesh.parametric(this.pUVFunc(), this.normalUVFunc(), this.uMin, this.uMax, this.vMin, this.vMax, ceil((this.uMax - this.uMin) / uStep), ceil((this.vMax - this.vMin) / vStep)); - } - isCurvesWithImplicitSurface(is, uStep, vStep, stepSize) { - return ParametricSurface.isCurvesParametricImplicitSurface(this, is, uStep, vStep, stepSize); - } - edgeLoopCCW(contour) { - const ptpF = this.uvPFunc(); - return ts3dutils.isCCW(contour.flatMap((e) => e.getVerticesNo0()).map((v) => ptpF(v)), ts3dutils.V3.Z); - } - like(object) { - if (!this.isCoplanarTo(object)) - return false; - // normals need to point in the same direction (outwards or inwards) for both - const pSMinTMin = this.pUVFunc()(this.uMin, this.vMin); - const thisNormal = this.normalUVFunc()(this.uMin, this.vMin); - const otherNormal = object.normalP(pSMinTMin); - return 0 < thisNormal.dot(otherNormal); - } - getApproxAABB() { - const result = new ts3dutils.AABB(); - result.addPoints(this.getExtremePoints()); - const ps = [ts3dutils.V(0, 0), ts3dutils.V(0, 1), ts3dutils.V(1, 0), ts3dutils.V(1, 1), ts3dutils.V(0.5, 0.5)].map((p) => this.pUV(ts3dutils.lerp(this.uMin, this.uMax, p.x), ts3dutils.lerp(this.vMin, this.vMax, p.y))); - result.addPoints(ps); - return result; - } -} - -class ConicSurface extends __.ParametricSurface { - /** - * returns new cone C = {apex + f1 * v * cos(u) + f2 * v * sin(u) + f3 * v | - * -PI <= u <= PI, 0 <= v} - * - * If the coordinate system [f1 f2 dir] is right-handed, the normals will - * point outwards, otherwise inwards. - * - * @param f1 - * @param f2 - * @param dir Direction in which the cone opens. The ellipse spanned by f1, - * f2 is contained at (apex + dir). - */ - constructor(center, f1, f2, dir, uMin = 0, uMax = PI, vMin = 0, vMax = 16) { - super(uMin, uMax, vMin, vMax); - this.center = center; - this.f1 = f1; - this.f2 = f2; - this.dir = dir; - ts3dutils.assertVectors(center, f1, f2, dir); - ts3dutils.assert(-PI <= uMin && uMax <= PI); - ts3dutils.assert(0 <= vMin, vMin); - this.matrix = ts3dutils.M4.forSys(f1, f2, dir, center); - this.matrixInverse = this.matrix.inversed(); - this.normalDir = sign(this.f1.cross(this.f2).dot(this.dir)); - this.pLCNormalWCMatrix = this.matrix - .as3x3() - .inversed() - .transposed() - .scale(this.normalDir); - } - getConstructorParameters() { - return [ - this.center, - this.f1, - this.f2, - this.dir, - this.uMin, - this.uMax, - this.vMin, - this.vMax, - ]; - } - pointFoot(pWC, startU, startV) { - if (undefined === startU || undefined === startV) { - // similar to uvP - const pLC = this.matrixInverse.transformPoint(pWC); - const angle = pLC.angleXY(); - if (undefined === startU) { - startU = angle < -PI / 2 ? angle + ts3dutils.TAU : angle; - } - if (undefined === startV) { - startV = pLC.z + (pLC.lengthXY() - pLC.z) * SQRT1_2; - } - } - const f = ([u, v]) => { - const pUVToPWC = this.pUV(u, v).to(pWC); - return [this.dpdu()(u, v).dot(pUVToPWC), this.dpdv()(u).dot(pUVToPWC)]; - }; - const { 0: x, 1: y } = ts3dutils.newtonIterate(f, [startU, startV]); - return new ts3dutils.V3(x, y, 0); - } - get apex() { - return this.center; - } - static atApexThroughEllipse(apex, ellipse, uMin, uMax, vMin, vMax) { - ts3dutils.assertVectors(apex); - ts3dutils.assertInst(__.EllipseCurve, ellipse); - return new ConicSurface(apex, ellipse.f1, ellipse.f2, apex.to(ellipse.center), uMin, uMax, vMin, vMax); - } - static unitISLineTs(anchor, dir) { - const { x: ax, y: ay, z: az } = anchor; - const { x: dx, y: dy, z: dz } = dir; - // this cone: x² + y² = z² - // line: p = anchor + t * dir1 - // split line equation into 3 component equations, insert into cone equation - // transform to form (a t² + b t + c = 0) and solve with pqFormula - const a = dx * dx + dy * dy - dz * dz; - const b = 2 * (ax * dx + ay * dy - az * dz); - const c = ax * ax + ay * ay - az * az; - // cone only defined for 0 <= z, so filter invalid values - return ts3dutils.pqFormula(b / a, c / a).filter((t) => 0 < az + t * dz); - } - // calculate intersection of plane ax + cz = d and cone x² + y² = z² - static unitISPlane(a, c, d) { - if (ts3dutils.eq0(c)) { - // plane is "vertical", i.e. parallel to Y and Z axes - ts3dutils.assert(!ts3dutils.eq0(a)); // normal would be zero, which is invalid - // z² - y² = d²/a² - if (ts3dutils.eq0(d)) { - // d = 0 => z² - y² = 0 => z² = y² => z = y - // plane goes through origin/V3.O - return [ - new __.L3(ts3dutils.V3.O, new ts3dutils.V3(0, -SQRT1_2, -SQRT1_2), undefined, 0), - new __.L3(ts3dutils.V3.O, new ts3dutils.V3(0, -SQRT1_2, SQRT1_2), 0), - ]; - } - else { - // hyperbola - const center = new ts3dutils.V3(d / a, 0, 0); - const f1 = new ts3dutils.V3(0, 0, abs(d / a)); // abs, because we always want the - // hyperbola to be pointing up - const f2 = new ts3dutils.V3(0, d / a, 0); - return [new __.HyperbolaCurve(center, f1, f2)]; - } - } - else { - // c != 0 - const aa = a * a, cc = c * c; - if (ts3dutils.eq0(d)) { - // ax + cz = d => x = d - cz / a => x² = d² - 2cdz/a + c²z²/a² - // x² + y² = z² - // => d² - 2cdz/a + c²z²/a² + y² = z² - if (ts3dutils.eq(aa, cc)) { - return [new __.L3(ts3dutils.V3.O, new ts3dutils.V3(c, 0, -a).unit())]; - } - else if (aa < cc) { - throw new Error("intersection is single point V3.O"); - } - else if (aa > cc) { - return [ - new __.L3(ts3dutils.V3.O, new ts3dutils.V3(c, sqrt(aa - cc), -a).unit()), - new __.L3(ts3dutils.V3.O, new ts3dutils.V3(c, -sqrt(aa - cc), -a).unit()), - ]; - } - } - else { - if (ts3dutils.eq(aa, cc)) { - // parabola - const parabolaVertex = new ts3dutils.V3(d / 2 / a, 0, d / 2 / c); - const parabolaVertexTangentPoint = new ts3dutils.V3(d / 2 / a, d / c, d / 2 / c); - const p2 = new ts3dutils.V3(0, 0, d / c); - const f2 = p2.minus(parabolaVertex); - return [ - new __.ParabolaCurve(parabolaVertex, parabolaVertexTangentPoint.minus(parabolaVertex), f2.z < 0 ? f2.negated() : f2), - ]; - } - else if (aa < cc) { - // ellipse - const center = new ts3dutils.V3((-a * d) / (cc - aa), 0, (d * c) / (cc - aa)); - if (center.z < 0) { - return []; - } - const p1 = new ts3dutils.V3(d / (a - c), 0, -d / (a - c)); - const p2 = new ts3dutils.V3((-a * d) / (cc - aa), d / sqrt(cc - aa), (d * c) / (cc - aa)); - return [ - new __.EllipseCurve(center, center.to(p1), center.to(p2), -PI, PI), - ]; - } - else if (aa > cc) { - // hyperbola - const center = new ts3dutils.V3((-a * d) / (cc - aa), 0, (d * c) / (cc - aa)); - // const p1 = new V3(d / (a - c), 0, -d / (a - c)) - // const p2 = new V3(-a * d / (cc - aa), d / sqrt(aa - cc), d * c / - // (cc - aa)) const f1 = center.to(p1) - const f1 = new ts3dutils.V3((d * c) / (aa - cc), 0, (-d * a) / (aa - cc)); - const f2 = new ts3dutils.V3(0, d / sqrt(aa - cc), 0); - return [new __.HyperbolaCurve(center, f1.z > 0 ? f1 : f1.negated(), f2)]; - } - } - } - throw new Error("???"); - } - equals(obj) { - return (this == obj || - (Object.getPrototypeOf(this) == Object.getPrototypeOf(obj) && - this.center.equals(obj.center) && - this.f1.equals(obj.f1) && - this.f2.equals(obj.f2) && - this.dir.equals(obj.dir))); - } - like(object) { - if (!this.isCoplanarTo(object)) - return false; - // normals need to point in the same direction (outwards or inwards) for - // both - return this.normalDir == object.normalDir; - } - getVectors() { - return [ - { anchor: this.center, dir1: this.dir }, - { anchor: this.center.plus(this.dir), dir1: this.f1 }, - { anchor: this.center.plus(this.dir), dir1: this.f2 }, - ]; - } - getSeamPlane() { - return __.P3.forAnchorAndPlaneVectors(this.center, this.f1, this.dir); - } - loopContainsPoint(contour, p) { - ts3dutils.assertVectors(p); - const line = this.center.like(p) - ? new __.L3(p, this.matrix.transformVector(new ts3dutils.V3(0, 1, 1)).unit()) - : __.L3.throughPoints(p, this.apex); - const lineOut = line.dir1.cross(this.dir); - return __.Surface.loopContainsPointGeneral(contour, p, line, lineOut); - } - isTsForLine(line) { - // transforming line manually has advantage that dir1 will not be - // renormalized, meaning that calculated values t for lineLC are directly - // transferable to line - const anchorLC = this.matrixInverse.transformPoint(line.anchor); - const dirLC = this.matrixInverse.transformVector(line.dir1); - return ConicSurface.unitISLineTs(anchorLC, dirLC); - } - /** - * Interestingly, two cones don't need to have parallel dirs to be coplanar. - */ - isCoplanarTo(surface) { - if (this === surface) - return true; - if (!(surface instanceof ConicSurface) || !this.apex.like(surface.apex)) - return false; - // at this point apexes are equal - return this.containsEllipse(new __.EllipseCurve(surface.center.plus(surface.dir), surface.f1, surface.f2)); - } - containsEllipse(ellipse) { - const ellipseLC = ellipse.transform(this.matrixInverse); - if (ellipseLC.center.z < 0) { - return false; - } - const { f1, f2 } = ellipseLC.rightAngled(); - const p1 = ellipseLC.center.plus(f1), p2 = ellipseLC.center.plus(f2); - // check if both endpoints are on the cone's surface - // and that one main axis is perpendicular to the Z-axis - return (ts3dutils.eq(Math.pow(p1.x, 2) + Math.pow(p1.y, 2), Math.pow(p1.z, 2)) && - ts3dutils.eq(Math.pow(p2.x, 2) + Math.pow(p2.y, 2), Math.pow(p2.z, 2)) && - (ts3dutils.eq0(f1.z) || ts3dutils.eq0(f2.z))); - } - containsLine(line) { - const lineLC = line.transform(this.matrixInverse); - const d = lineLC.dir1; - return lineLC.containsPoint(ts3dutils.V3.O) && ts3dutils.eq(d.x * d.x + d.y * d.y, d.z * d.z); - } - containsParabola(curve) { - ts3dutils.assertInst(__.ParabolaCurve, curve); - const curveLC = curve.transform(this.matrixInverse); - if (curveLC.center.z < 0 || curveLC.f2.z < 0) { - return false; - } - const { center, f1, f2 } = curveLC.rightAngled(); - // check if center is on the surface, - // that tangent is perpendicular to the Z-axis - // and that "y" axis is parallel to surface - return (ts3dutils.eq(center.x * center.x + center.y * center.y, center.z * center.z) && - ts3dutils.eq0(f1.z) && - ts3dutils.eq(f2.x * f2.x + f2.y * f2.y, f2.z * f2.z)); - } - containsHyperbola(curve) { - // calculate intersection of plane ax + cz = 1 and cone x² + y² = z² - // const center = new V3(-a / (cc - aa), 0, 1 / (cc - aa)) - // const p1 = new V3(1 / (a - c), 0, -1 / (a - c)) - // const p2 = new V3(-a / (cc - aa), 1 / sqrt(aa - cc), 1 / (cc - aa)) - // const f1 = new V3(1 * c / (aa - cc), 0, -a / (aa - cc) ) - // const f2 = new V3(0, 1 / sqrt(aa - cc), 0) - ts3dutils.assertInst(__.HyperbolaCurve, curve); - const curveLC = curve.transform(this.matrixInverse).rightAngled(); - const centerXY = curveLC.center.xy(); - if (centerXY.likeO()) { - return false; - } - const rot = centerXY.angleXY(); - const { center, f1, f2 } = curveLC.rotateZ(-rot); - // s = a / (aa - cc) - // t = -c / (aa - cc) - // s + t = 1 / (a + c) - // s - t = 1 / (a - c) - // (s + t)(s - t) = (ss - tt) = 1 / (aa - cc) - // u = 1 / sqrt(aa - cc) = sqrt(ss - tt) - // check if center is on the surface, - // that tangent is perpendicular to the Z-axis - return (f1.z > 0 && - ts3dutils.eq(center.x, f1.z) && - ts3dutils.eq(center.z, f1.x) && - ts3dutils.eq0(center.y) && - ts3dutils.eq0(f1.y) && - ts3dutils.eq(sqrt(abs(Math.pow(center.x, 2) - Math.pow(center.z, 2))), abs(f2.y)) && - ts3dutils.eq0(f2.x) && - ts3dutils.eq0(f2.z)); - } - containsCurve(curve) { - if (curve instanceof __.EllipseCurve) { - return this.containsEllipse(curve); - } - else if (curve instanceof __.L3) { - return this.containsLine(curve); - } - else if (curve instanceof __.HyperbolaCurve) { - return this.containsHyperbola(curve); - } - else if (curve instanceof __.ParabolaCurve) { - return this.containsParabola(curve); - } - else { - return super.containsCurve(curve); - } - } - transform(m4) { - return new ConicSurface(m4.transformPoint(this.center), m4.transformVector(this.f1).times(m4.isMirroring() ? -1 : 1), m4.transformVector(this.f2), m4.transformVector(this.dir), this.uMin, this.uMax, this.vMin, this.vMax); - } - transform4(m4) { - const transformedApex = m4.timesVector(ts3dutils.Vector.fromV3AndWeight(this.center, 1)); - const isometricV = (z) => new __.EllipseCurve(new ts3dutils.V3(0, 0, z), new ts3dutils.V3(z, 0, 0), new ts3dutils.V3(0, z, 0)); - if (!ts3dutils.eq0(transformedApex.w)) { - // sMin doesn't change, but tMin does... - const c = m4.transformPoint(this.center), f1 = m4 - .transformVector2(this.f1, this.center) - .times(m4.isMirroring() ? -1 : 1), f2 = m4.transformVector2(this.f2, this.center), dir = m4.transformVector2(this.dir, this.center); - const matrixInv = ts3dutils.M4.forSys(f1, f2, dir, c).inversed(); - const x = isometricV(this.vMin).transform4(matrixInv.times(m4).times(this.matrix)); - const y = isometricV(this.vMax).transform4(matrixInv.times(m4).times(this.matrix)); - const aabb = ts3dutils.AABB.forAABBs([x.getAABB(), y.getAABB()]); - console.log("aabb", aabb); - console.log(matrixInv.str); - console.log(x.str, y.str); - return new ConicSurface(c, f1, f2, dir, this.uMin, this.uMax, aabb.min.z, aabb.max.z); - } - else { - const dir = transformedApex.V3(); - const baseCurve = isometricV(this.vMin).transform4(m4.times(this.matrix)); - const matrixInv = ts3dutils.M4.forSys(baseCurve.f1, baseCurve.f2, dir.unit(), baseCurve.center).inversed(); - const aabb = isometricV(this.vMax) - .transform4(matrixInv.times(m4.times(this.matrix))) - .getAABB(); - return new __.CylinderSurface(baseCurve, dir.unit(), this.uMin, this.uMax, min(0, aabb.min.z, aabb.max.z), max(0, aabb.min.z, aabb.max.z)); - } - } - flipped() { - return new ConicSurface(this.center, this.f1.negated(), this.f2, this.dir); - } - normalUVFunc() { - const { f1, f2 } = this, f3 = this.dir; - return (d, _z) => { - return f2 - .cross(f1) - .plus(f2.cross(f3.times(Math.cos(d)))) - .plus(f3.cross(f1.times(Math.sin(d)))) - .unit(); - }; - } - normalP(p) { - //TODO assert(!p.like(this.center)) - const pLC = this.matrixInverse.transformPoint(p); - return this.normalUVFunc()(pLC.angleXY(), pLC.z); - } - pUVFunc() { - return (u, v) => { - // center + f1 v cos u + f2 v sin u + v dir - const resultLC = new ts3dutils.V3(v * cos(u), v * sin(u), v); - return this.matrix.transformPoint(resultLC); - }; - } - dpdu() { - return (u, v) => { - const resultLC = new ts3dutils.V3(v * -sin(u), v * cos(u), 0); - return this.matrix.transformVector(resultLC); - }; - } - dpdv() { - return (s) => { - const resultLC = new ts3dutils.V3(cos(s), sin(s), 1); - return this.matrix.transformVector(resultLC); - }; - } - implicitFunction() { - return (pWC) => { - const pLC = this.matrixInverse.transformPoint(pWC); - const radiusLC = pLC.lengthXY(); - return this.normalDir * (radiusLC - pLC.z); - }; - } - didp(pWC) { - const pLC = this.matrixInverse.transformPoint(pWC); - return this.pLCNormalWCMatrix.transformVector(pLC.xy().unit().withElement("z", -1).times(this.normalDir)); - } - containsPoint(p) { - return ts3dutils.eq0(this.implicitFunction()(p)); - } - uvP(pWC) { - const pLC = this.matrixInverse.transformPoint(pWC); - const angle = pLC.angleXY(); - return new ts3dutils.V3(angle < -PI / 2 ? angle + ts3dutils.TAU : angle, pLC.z, 0); - } - isCurvesWithSurface(surface) { - if (surface instanceof __.PlaneSurface) { - return this.isCurvesWithPlane(surface.plane); - } - else if (__.ImplicitSurface.is(surface)) { - return __.ParametricSurface.isCurvesParametricImplicitSurface(this, surface, 0.1, 0.1 / this.dir.length(), 0.02); - } - return super.isCurvesWithSurface(surface); - } - getCenterLine() { - return new __.L3(this.center, this.dir); - } - isCurvesWithPlane(plane) { - ts3dutils.assertInst(__.P3, plane); - const planeLC = plane.transform(this.matrixInverse); - const planeNormal = planeLC.normal1; - const c = planeNormal.z; - /** "rotate" plane normal1 when passing to {@link ConicSurface.unitISPlane} so that - * y-component of normal1 is 0 */ - const a = planeNormal.lengthXY(); - const d = planeLC.w; - // generated curves need to be rotated back before transforming to world - // coordinates - const rotationMatrix = ts3dutils.M4.rotateZ(planeNormal.angleXY()); - const wcMatrix = ts3dutils.eq0(planeNormal.lengthXY()) - ? this.matrix - : this.matrix.times(rotationMatrix); - return ConicSurface.unitISPlane(a, c, d).flatMap((curve) => { - const curveWC = curve.transform(wcMatrix); - if (curve instanceof __.EllipseCurve) { - const curveLC = curve.transform(rotationMatrix); - const ts = curveLC.isTsWithPlane(__.P3.ZX); - const intervals = ts3dutils.getIntervals(ts, -PI, PI).filter(([a, b]) => curveLC.at((a + b) / 2).y > 0); - return intervals.flatMap(([a, b]) => curveWC.split(a, b)); - } - const p = curveWC.at(0.2); - return this.normalP(p).cross(plane.normal1).dot(curveWC.tangentAt(0.2)) > - 0 - ? curveWC - : curveWC.reversed(); - }); - } - debugInfo() { - return { - ps: [this.center], - lines: [ - this.center, - this.center.plus(this.f1), - this.center.plus(this.f2), - this.center.plus(this.dir), - ], - }; - } -} -/** - * Unit cone. x² + y² = z², 0 <= z - */ -ConicSurface.UNIT = new ConicSurface(ts3dutils.V3.O, ts3dutils.V3.X, ts3dutils.V3.Y, ts3dutils.V3.Z); -ConicSurface.prototype.uStep = PI / 16; -ConicSurface.prototype.vStep = 256; - -/** - * Surface normal1 is (t, z) => this.baseCurve.tangentAt(t) X this.dir - * Choose dir appropriately to select surface orientation. - */ -class ProjectedCurveSurface extends ParametricSurface { - constructor(baseCurve, dir, uMin = baseCurve.tMin, uMax = baseCurve.tMax, vMin = -100, vMax = 100) { - super(uMin, uMax, vMin, vMax); - this.baseCurve = baseCurve; - this.dir = dir; - ts3dutils.assertInst(Curve, baseCurve); - ts3dutils.assertInst(ts3dutils.V3, dir); - ts3dutils.assert(uMin < uMax); - ts3dutils.assert(vMin < vMax); - } - getConstructorParameters() { - return [ - this.baseCurve, - this.dir, - this.uMin, - this.uMax, - this.vMin, - this.vMax, - ]; - } - equals(obj) { - return (this == obj || - (Object.getPrototypeOf(this) == Object.getPrototypeOf(obj) && - this.dir.equals(obj.dir) && - this.baseCurve.equals(obj.baseCurve))); - } - hashCode() { - return ts3dutils.arrayHashCode([this.dir, this.baseCurve]); - } - containsLine(line) { - return this.dir.isParallelTo(line.dir1) && this.containsPoint(line.anchor); - } - dpdu() { - return (u, v) => this.baseCurve.tangentAt(u); - } - dpdv() { - return (u, v) => this.dir; - } - normalUV(u, v) { - return this.baseCurve.tangentAt(u).cross(this.dir).unit(); - } - pUV(u, v) { - return this.baseCurve.at(u).plus(this.dir.times(v)); - } - pointFoot(pWC, ss) { - const basePlane = new P3(this.dir.unit(), 0); - const projCurve = this.baseCurve.project(basePlane); - const projPoint = basePlane.projectedPoint(pWC); - const t = projCurve.closestTToPoint(projPoint, ss, this.uMin, this.uMax); - const z = L3.pointT(this.baseCurve.at(t), this.dir, pWC); - return new ts3dutils.V3(t, z, 0); - } - uvPFunc() { - const projPlane = new P3(this.dir.unit(), 0); - const projBaseCurve = this.baseCurve.project(projPlane); - return (pWC) => { - const projPoint = projPlane.projectedPoint(pWC); - ts3dutils.assertNumbers(this.uMin); - const t = projBaseCurve.pointT(projPoint, this.uMin, this.uMax); - const z = L3.pointT(this.baseCurve.at(t), this.dir, pWC); - return new ts3dutils.V3(t, z, 0); - }; - } - isCurvesWithPlane(plane) { - ts3dutils.assertInst(P3, plane); - if (this.dir.isPerpendicularTo(plane.normal1)) { - const ts = this.baseCurve.isTsWithPlane(plane); - return ts.map((t) => { - const l3dir = 0 < this.baseCurve.tangentAt(t).dot(plane.normal1) - ? this.dir - : this.dir.negated(); - return new L3(this.baseCurve.at(t), l3dir.unit()); - }); - } - else { - let projCurve = this.baseCurve.transform(ts3dutils.M4.project(plane, this.dir)); - if (this.dir.dot(plane.normal1) > 0) { - // we need to flip the ellipse so the tangent is correct - projCurve = projCurve.reversed(); - } - return [projCurve]; - } - } - isCurvesWithSurface(surface) { - if (surface instanceof PlaneSurface) { - return this.isCurvesWithPlane(surface.plane); - } - if (surface instanceof ProjectedCurveSurface) { - const dir1 = surface.dir; - if (this.dir.isParallelTo(dir1)) { - const ts = surface.baseCurve.isTsWithSurface(this); - return ts.map((t) => { - const p = surface.baseCurve.at(t); - const correctDir = this.normalP(p).cross(surface.normalP(p)); - return new L3(p, dir1.times(sign(correctDir.dot(dir1)))); - }); - } - else if (ImplicitSurface.is(surface)) { - let curves2 = ParametricSurface.isCurvesParametricImplicitSurface(this, surface, 0.1, 0.1 / surface.dir.length(), 0.05); - curves2 = surface.clipCurves(curves2); - return curves2; - } - else { - let curves2 = ParametricSurface.isCurvesParametricParametricSurface(this, surface, 0.05, 0.1 / surface.dir.length(), 0.05); - curves2 = this.clipCurves(curves2); - curves2 = surface.clipCurves(curves2); - return curves2; - } - } - if (surface instanceof EllipsoidSurface) { - return surface.isCurvesWithSurface(this); - } - return super.isCurvesWithSurface(surface); - } - containsPoint(pWC) { - const uv = this.uvPFunc()(pWC); - return this.pUVFunc()(uv.x, uv.y).like(pWC); - } - containsCurve(curve) { - if (curve instanceof L3) { - return (this.dir.isParallelTo(curve.dir1) && this.containsPoint(curve.anchor)); - } - if (curve instanceof ImplicitCurve) { - return super.containsCurve(curve); - } - // project baseCurve and test curve onto a common plane and check if the curves are alike - const projPlane = new P3(this.dir.unit(), 0); - const projBaseCurve = this.baseCurve.project(projPlane); - const projCurve = curve.project(projPlane); - return projBaseCurve.isColinearTo(projCurve); - } - isCoplanarTo(surface) { - return (this == surface || - (ts3dutils.hasConstructor(surface, ProjectedCurveSurface) && - this.dir.isParallelTo(surface.dir) && - this.containsCurve(surface.baseCurve))); - } - like(object) { - if (!this.isCoplanarTo(object)) - return false; - // normals need to point in the same direction (outwards or inwards) for both - const p00 = this.pUVFunc()(0, 0); - const thisNormal = this.normalUVFunc()(0, 0); - const otherNormal = object.normalP(p00); - return 0 < thisNormal.dot(otherNormal); - } - loopContainsPoint(loop, p) { - ts3dutils.assertVectors(p); - ts3dutils.assert(isFinite(p.x), p.y, p.z); - const line = new L3(p, this.dir.unit()); - const ptpf = this.uvPFunc(); - const pp = ptpf(p); - if (isNaN(pp.x)) { - console.log(this.sce, p.sce); - ts3dutils.assert(false); - } - const lineOut = this.baseCurve.tangentAt(pp.x).rejectedFrom(this.dir); - return Surface.loopContainsPointGeneral(loop, p, line, lineOut); - } - transform(m4) { - const f = m4.isMirroring() ? -1 : 1; - return new this.constructor(this.baseCurve.transform(m4), m4.transformVector(this.dir).times(f), this.uMin, this.uMax, 1 == f ? this.vMin : -this.vMax, 1 == f ? this.vMax : -this.vMin); - } - transform4(m4) { - const vp = m4.vanishingPoint(this.dir); - if (!vp) { - const f = m4.isMirroring() ? -1 : 1; - return new this.constructor(this.baseCurve.transform4(m4), m4.normalized().transformVector(this.dir).times(f), undefined, undefined, 1 == f ? this.vMin : -this.vMax, 1 == f ? this.vMax : -this.vMin); - } - const curveT = this.baseCurve.transform4(m4); - if (curveT instanceof EllipseCurve) { - console.log(vp.sce, curveT.sce); - return ConicSurface.atApexThroughEllipse(vp, m4.isMirroring() ? curveT : curveT.reversed(), this.uMin, this.uMax, 1, 2); - } - return new PointProjectedSurface(curveT, vp, P3.throughPoints(curveT.at(curveT.tMin), curveT.at((curveT.tMin + curveT.tMax) / 2), curveT.at(curveT.tMax)), 1, this.uMin, this.uMax, 1, 2); - } - isTsForLine(line) { - ts3dutils.assertInst(L3, line); - const projPlane = new P3(this.dir.unit(), 0); - const projDir = projPlane.projectedVector(line.dir1); - if (projDir.likeO()) { - // line is parallel to this.dir - return []; - } - const projAnchor = projPlane.projectedPoint(line.anchor); - const projBaseCurve = this.baseCurve.project(projPlane); - return projBaseCurve - .isInfosWithLine(projAnchor, projDir, this.uMin, this.uMax, line.tMin, line.tMax) - .map((info) => info.tOther); - } - flipped() { - return new this.constructor(this.baseCurve, this.dir.negated(), this.uMin, this.uMax, -this.vMax, -this.vMin); - } -} -ProjectedCurveSurface.prototype.uStep = 1 / 128; -ProjectedCurveSurface.prototype.vStep = 256; - -/** - * Rotation surface with r = f(z) - */ -class RotatedCurveSurface extends __.ParametricSurface { - constructor(curve, matrix = ts3dutils.M4.IDENTITY, uMin = 0, uMax = PI, vMin = curve.tMin, vMax = curve.tMax) { - // d/dz (r(z)) - super(uMin, uMax, vMin, vMax); - this.curve = curve; - this.matrix = matrix; - ts3dutils.assertInst(ts3dutils.M4, matrix); - ts3dutils.assert(matrix.isNoProj()); - ts3dutils.assert(ts3dutils.eq0(curve.at(vMin).y)); - this.matrixInverse = matrix.inversed(); - this.vStep = this.curve.tIncrement; - } - getConstructorParameters() { - return [this.curve, this.matrix, this.uMin, this.uMax, this.vMin, this.vMax]; - } - flipped() { - return new RotatedCurveSurface(this.curve, this.matrix.times(ts3dutils.M4.mirror(__.P3.YZ)), this.uMin, this.uMax, this.vMin, this.vMax); - } - transform(m4) { - return new RotatedCurveSurface(this.curve, m4.isMirroring() - ? m4.times(this.matrix).times(ts3dutils.M4.mirror(__.P3.YZ)) - : m4.times(this.matrix), this.uMin, this.uMax, this.vMin, this.vMax); - } - containsPoint(pWC) { - const pLC = this.matrixInverse.transformPoint(pWC); - const radius = pLC.lengthXY(); - return this.curve.containsPoint(new ts3dutils.V3(radius, 0, pLC.z)); - } - pUVFunc() { - return (u, v) => { - const { x: radius, z: z } = this.curve.at(v); - return this.matrix.transformPoint(ts3dutils.V3.polar(radius, u, z)); - }; - } - dpdu() { - return (u, v) => { - const radius = this.curve.at(v).x; - const resultLC = new ts3dutils.V3(radius * -sin(u), radius * cos(u), 0); - return this.matrix.transformVector(resultLC); - }; - } - dpdv() { - return (u, v) => { - const { x: drdt, z: dzdt } = this.curve.tangentAt(v); - return this.matrix.transformVector(ts3dutils.V3.polar(drdt, u, dzdt)); - }; - } - normalUVFunc() { - const matrix = this.matrix.inversed().transposed().as3x3(); - const normalLength = this.matrix.isMirroring() ? -1 : 1; - return (u, v) => { - const { x: drdt, z: dzdt } = this.curve.tangentAt(v); - return matrix - .transformVector(ts3dutils.V3.polar(dzdt, u, -drdt)) - .toLength(normalLength); - }; - } - uvPFunc() { - return (pWC) => { - const pLC = this.matrixInverse.transformPoint(pWC); - const angle = __.EllipseCurve.XYLCPointT(pLC, this.uMin, this.uMax); - const radius = pLC.lengthXY(); - return new ts3dutils.V3(angle, this.curve.pointT(new ts3dutils.V3(radius, 0, pLC.z)), 0); - }; - } - pointFoot(pWC, startS, startT) { - const pLC = this.matrixInverse.transformPoint(pWC); - const angle = abs(pLC.angleXY()); - const radius = pLC.lengthXY(); - return new ts3dutils.V3(angle, this.curve.closestTToPoint(new ts3dutils.V3(radius, 0, pLC.z)), 0); - } - isTsForLine(line) { - const anchorLC = this.matrixInverse.transformPoint(line.anchor); - const dirLC = this.matrixInverse.transformVector(line.dir1); - if (dirLC.isParallelTo(ts3dutils.V3.Z)) { - if (!ts3dutils.fuzzyBetween(anchorLC.angleXY(), this.uMin, this.uMax)) - return []; - return this.curve - .isInfosWithLine(new ts3dutils.V3(anchorLC.lengthXY(), 0, anchorLC.z), dirLC) - .map((info) => info.tOther); - } - else if (__.L3.containsPoint(anchorLC.xy(), dirLC.xy(), ts3dutils.V3.O)) { - // line goes through Z axis - const dotter = dirLC.xy().unit(); - return [ - ...this.curve.isInfosWithLine(new ts3dutils.V3(dotter.dot(anchorLC), 0, anchorLC.z), new ts3dutils.V3(dotter.dot(dirLC), 0, dirLC.z)), - ...this.curve.isInfosWithLine(new ts3dutils.V3(-dotter.dot(anchorLC), 0, anchorLC.z), new ts3dutils.V3(-dotter.dot(dirLC), 0, dirLC.z)), - ] - .map((info) => info.tOther) - .filter((t) => ts3dutils.fuzzyBetween(__.L3.at(anchorLC, dirLC, t).angleXY(), this.uMin, this.uMax)); - } - else if (dirLC.isPerpendicularTo(ts3dutils.V3.Z)) { - const secs = this.isCurvesWithPlaneLC(new __.P3(ts3dutils.V3.Z, anchorLC.z)); - if (!secs) - return []; - return secs.flatMap((sec) => sec.isInfosWithLine(anchorLC, dirLC).map((info) => info.tOther)); - } - else { - // transform into hyperbola - // f(t) = V(((ax + t dx)² + (ay + t dy)²) ** 1/2, 0, az + t dz) - // f(t) = V((ax² + 2 ax t dx + t² dx² + ay² + 2 ay t dy + t² dy²) ** 1/2, 0, az + t dz) - // f(t) = V((t² (dx² + dy²) + 2 t (ax dx + ay dy) + ax² + ay²) ** 1/2, 0, az + t * dz) - // (anchorLC.xy + t * dirLC.xy) * dir.xy = 0 - // t * dirLC.xy² = -anchorLC.xy * dirLC.xy - const closestTToZ = -anchorLC.xy().dot(dirLC.xy()) / dirLC.xy().squared(); - const closestPointToZ = __.L3.at(anchorLC, dirLC, closestTToZ); - const scaleX = closestPointToZ.lengthXY(); - const lineGradientWC = dirLC.z / dirLC.lengthXY(); - const scaleZ = scaleX * lineGradientWC; - const hc = __.HyperbolaCurve.XY.transform(ts3dutils.M4.rotateX(90 * ts3dutils.DEG) - .scale(scaleX, 0, scaleZ) - .translate(0, 0, closestPointToZ.z)); - const infos = hc.isInfosWithCurve(this.curve); - return infos - .map((info) => (info.p.z - anchorLC.z) / dirLC.z) - .filter((t) => ts3dutils.fuzzyBetween(__.L3.at(anchorLC, dirLC, t).angleXY(), this.uMin, this.uMax)); - } - } - isCurvesWithPlaneLC(planeLC) { - if (planeLC.normal1.isParallelTo(ts3dutils.V3.Z)) { - return this.curve.isTsWithPlane(planeLC).map((t) => { - const { x: radius } = this.curve.at(t); - return new __.EllipseCurve(new ts3dutils.V3(0, 0, planeLC.w), new ts3dutils.V3(radius, 0, 0), new ts3dutils.V3(0, radius, 0), this.uMin, this.uMax).transform(this.matrix); - }); - } - else if (planeLC.normal1.isPerpendicularTo(ts3dutils.V3.Z) && - planeLC.containsPoint(ts3dutils.V3.O)) { - return [ - this.curve - .rotateZ(ts3dutils.V3.Y.angleRelativeNormal(planeLC.normal1, ts3dutils.V3.Z)) - .transform(this.matrix), - ]; - } - return undefined; - } - isCurvesWithPlane(plane) { - const planeLC = plane.transform(this.matrixInverse); - const planeLCCurves = this.isCurvesWithPlaneLC(planeLC); - if (planeLCCurves) { - return planeLCCurves.map((curve) => curve.transform(this.matrix)); - } - else { - return __.ParametricSurface.isCurvesParametricImplicitSurface(this, new __.PlaneSurface(plane), 0.05, 0.05, 0.02); - } - } - loopContainsPoint(loop, pWC) { - const pLC = this.matrixInverse.transformPoint(pWC); - const angle = __.EllipseCurve.XYLCPointT(pLC, this.uMin, this.uMax); - const testCurveLC = __.EllipseCurve.semicircle(pLC.lengthXY(), new ts3dutils.V3(0, 0, pLC.z)); - const testCurveWC = testCurveLC.transform(this.matrix); - return __.Surface.loopContainsPointEllipse(loop, pWC, testCurveWC, angle); - } - isCoplanarTo(surface) { - if (this === surface) - return true; - if (!ts3dutils.hasConstructor(surface, RotatedCurveSurface)) - return false; - const surfaceLCToThisLC = this.matrixInverse.times(surface.matrix); - ts3dutils.assert(!surfaceLCToThisLC.X.xy().likeO()); - const zRotation = surfaceLCToThisLC.X.angleXY(); - return surface.curve - .transform(ts3dutils.M4.rotateZ(-zRotation).times(surfaceLCToThisLC)) - .isColinearTo(this.curve); - } - isCurvesWithSurface(surface) { - if (surface instanceof __.PlaneSurface) { - return this.isCurvesWithPlane(surface.plane); - } - return super.isCurvesWithSurface(surface); - } - containsCurve(curve) { - if (curve.constructor == this.curve.constructor) { - const curveLC = curve.transform(this.matrixInverse); - // find a point on curveLC which isn't on the Z-axis - const t = ts3dutils.withMax([0, 0.5, 1].map((x) => ts3dutils.lerp(curveLC.tMin, curveLC.tMax, x)), (t) => curveLC.at(t).lengthXY()); - const angle = curveLC.at(t).angleXY(); - const curveLCRotated = curveLC.rotateZ(-angle); - if (this.curve.isColinearTo(curveLCRotated)) { - return true; - } - } - if (curve instanceof __.EllipseCurve) { - const curveLC = curve.transform(this.matrixInverse); - if (curveLC.normal.isParallelTo(ts3dutils.V3.Z)) { - return (curveLC.isCircular() && - this.curve.containsPoint(new ts3dutils.V3(curveLC.f1.length(), 0, curveLC.center.z))); - } - return false; - } - return super.containsCurve(curve); - } - getExtremePoints() { - return getExtremePointsHelper.call(this, this.curve); - } - asNURBSSurface() { - // y = 0 for baseNURBS - const baseNURBS = __.NURBS.fromEllipse(this.curve); - const rotationNURBS = __.NURBS.UnitCircle(2, this.vMin, this.vMax); - return new __.NURBSSurface(rotationNURBS.points.flatMap((rv) => baseNURBS.points.map((b) => this.matrix.timesVector(ts3dutils.VV(rv.x * b.x, rv.y * b.x, b.z * rv.w, rv.w * b.w)))), baseNURBS.knots, rotationNURBS.knots, baseNURBS.degree, rotationNURBS.degree, baseNURBS.tMin, baseNURBS.tMax, rotationNURBS.tMin, rotationNURBS.tMax); - } -} -RotatedCurveSurface.prototype.uStep = __.EllipseCurve.prototype.tIncrement; -function getExtremePointsHelper(curve) { - // this logic comes from EllipseCurve.roots - const f1 = this.matrix.X; - const f2 = this.matrix.Y; - return [0, 1, 2].flatMap((dim) => { - const a = f2.e(dim); - const b = -f1.e(dim); - const xiEtas = ts3dutils.eq0(a) && ts3dutils.eq0(b) ? [[1, 0]] : __.intersectionUnitCircleLine2(a, b, 0); - return xiEtas.flatMap(([xi, eta]) => { - const u = Math.atan2(eta, xi); - if (!(ts3dutils.lt(this.uMin, u) && ts3dutils.lt(u, this.uMax))) - return []; - const testCurve = curve.transform(this.matrix.times(ts3dutils.M4.rotateZ(u))); - return testCurve.roots()[dim].map((v) => this.pUV(u, v)); - }); - }); -} - -class CylinderSurface extends __.ProjectedCurveSurface { - // @ts-ignore - // readonly baseCurve: EllipseCurve - constructor(baseCurve, dir1, uMin = baseCurve.tMin, uMax = baseCurve.tMax, zMin = -Infinity, zMax = Infinity) { - super(baseCurve, dir1, uMin, uMax, zMin, zMax); - this.baseCurve = baseCurve; - ts3dutils.assertInst(__.EllipseCurve, baseCurve); - //assert(!baseCurve.normal1.isPerpendicularTo(dir1), !baseCurve.normal1.isPerpendicularTo(dir1)) - this.matrix = ts3dutils.M4.forSys(baseCurve.f1, baseCurve.f2, dir1, baseCurve.center); - this.matrixInverse = this.matrix.inversed(); - this.normalDir = sign(this.baseCurve.normal.dot(this.dir)); - this.pLCNormalWCMatrix = this.matrix - .as3x3() - .inversed() - .transposed() - .scale(this.normalDir); - this.pWCNormalWCMatrix = this.pLCNormalWCMatrix.times(this.matrixInverse); - } - static semicylinder(radius, sMin, sMax, tMin, tMax) { - return new CylinderSurface(new __.EllipseCurve(ts3dutils.V3.O, new ts3dutils.V3(radius, 0, 0), new ts3dutils.V3(0, radius, 0)), ts3dutils.V3.Z, sMin, sMax, tMin, tMax); - } - /** - * - * @param anchorLC - * @param dirLC not necessarily unit - */ - static unitISLineTs(anchorLC, dirLC) { - const { x: ax, y: ay } = anchorLC; - const { x: dx, y: dy } = dirLC; - // this cylinder: x² + y² = 1 - // line: p = anchorLC + t * dirLC - // split line equation into 3 component equations, insert into cylinder equation - // x = ax + t * dx - // y = ay + t * dy - // (ax² + 2 ax t dx + t²dx²) + (ay² + 2 ay t dy + t²dy²) = 1 - // transform to form (a t² + b t + c = 0) and solve with pqFormula - const a = Math.pow(dx, 2) + Math.pow(dy, 2); - const b = 2 * (ax * dx + ay * dy); - const c = Math.pow(ax, 2) + Math.pow(ay, 2) - 1; - return ts3dutils.pqFormula(b / a, c / a).filter((t) => __.EllipseCurve.XYLCValid(new ts3dutils.V3(ax + dx * t, ay + dy * t, 0))); - } - normalP(p) { - return this.pLCNormalWCMatrix - .transformVector(this.matrixInverse.transformPoint(p).xy()) - .unit(); - } - loopContainsPoint(loop, p) { - ts3dutils.assertVectors(p); - if (!this.containsPoint(p)) - return __.OUTSIDE; - const line = new __.L3(p, this.dir.unit()); - const lineOut = this.dir.cross(this.normalP(p)); - return __.Surface.loopContainsPointGeneral(loop, p, line, lineOut); - } - isTsForLine(line) { - ts3dutils.assertInst(__.L3, line); - // transforming line manually has advantage that dir1 will not be renormalized, - // meaning that calculated values t for localLine are directly transferable to line - const dirLC = this.matrixInverse.transformVector(line.dir1); - if (dirLC.isParallelTo(ts3dutils.V3.Z)) { - // line is parallel to this.dir - return []; - } - const anchorLC = this.matrixInverse.transformPoint(line.anchor); - ts3dutils.assert(!CylinderSurface.unitISLineTs(anchorLC, dirLC).length || - !isNaN(CylinderSurface.unitISLineTs(anchorLC, dirLC)[0]), "sad " + dirLC); - return CylinderSurface.unitISLineTs(anchorLC, dirLC); - } - isCoplanarTo(surface) { - return (this == surface || - (ts3dutils.hasConstructor(surface, CylinderSurface) && - this.dir.isParallelTo(surface.dir) && - this.containsEllipse(surface.baseCurve, false))); - } - like(surface) { - if (!this.isCoplanarTo(surface)) - return false; - // normals need to point in the same direction (outwards or inwards) for both - const thisFacesOut = 0 < this.baseCurve.normal.dot(this.dir); - const objectFacesOut = 0 < surface.baseCurve.normal.dot(surface.dir); - return thisFacesOut == objectFacesOut; - } - containsEllipse(ellipse, checkAABB = true) { - const projEllipse = ellipse.transform(ts3dutils.M4.project(this.baseCurve.getPlane(), this.dir)); - return this.baseCurve == ellipse || this.baseCurve.isColinearTo(projEllipse); - } - containsCurve(curve) { - if (curve instanceof __.L3) { - return this.containsLine(curve); - } - else if (curve instanceof __.EllipseCurve) { - return this.containsEllipse(curve); - } - else if (curve instanceof __.BezierCurve) { - return false; - } - else { - return super.containsCurve(curve); - } - } - implicitFunction() { - return (pWC) => { - const pLC = this.matrixInverse.transformPoint(pWC); - return (pLC.lengthXY() - 1) * this.normalDir; - }; - } - didp(pWC) { - const pLC = this.matrixInverse.transformPoint(pWC); - const pLCLengthXY = pLC.lengthXY(); - const didpLC = new ts3dutils.V3(pLC.x / pLCLengthXY, pLC.y / pLCLengthXY, 0); - return this.pLCNormalWCMatrix.transformVector(didpLC); - } - containsPoint(pWC) { - const pLC = this.matrixInverse.transformPoint(pWC); - return this.baseCurve.isValidT(__.EllipseCurve.XYLCPointT(pLC, this.uMin, this.uMax)); - } - uvP(pWC) { - ts3dutils.assert(arguments.length == 1); - const pLC = this.matrixInverse.transformPoint(pWC); - const u = __.EllipseCurve.XYLCPointT(pLC, this.vMin, this.vMax); - return new ts3dutils.V3(u, pLC.z, 0); - } - isCurvesWithSurface(surface2) { - if (surface2 instanceof __.ProjectedCurveSurface) { - if (surface2.dir.isParallelTo(this.dir)) { - const projectedCurve = surface2.baseCurve.transform(ts3dutils.M4.project(this.baseCurve.getPlane(), this.dir)); - return this.baseCurve.isInfosWithCurve(projectedCurve).map((info) => { - const lineDir = sign(this.normalP(info.p) - .cross(surface2.normalP(info.p)) - .dot(this.dir)) || 1; - return new __.L3(info.p, this.dir.times(lineDir)); - }); - } - } - if (surface2 instanceof CylinderSurface) { - if (ts3dutils.eq0(this.getCenterLine().distanceToLine(surface2.getCenterLine()))) { - throw new Error(); - } - } - return super.isCurvesWithSurface(surface2); - } - getCenterLine() { - return new __.L3(this.baseCurve.center, this.dir); - } - facesOutwards() { - return this.baseCurve.normal.dot(this.dir) > 0; - } - getSeamPlane() { - let normal = this.baseCurve.f1.cross(this.dir); - normal = normal.times(-sign(normal.dot(this.baseCurve.f2))); - return __.P3.normalOnAnchor(normal, this.baseCurve.center); - } - clipCurves(curves) { - return curves.flatMap((curve) => curve.clipPlane(this.getSeamPlane())); - } -} -CylinderSurface.UNIT = new CylinderSurface(__.EllipseCurve.UNIT, ts3dutils.V3.Z, undefined, undefined, 0, 1); -CylinderSurface.prototype.uStep = ts3dutils.TAU / 32; -CylinderSurface.prototype.vStep = 256; - -class EllipsoidSurface extends __.ParametricSurface { - constructor(center, f1, f2, f3, uMin = 0, uMax = PI, vMin = -PI / 2, vMax = PI / 2) { - super(uMin, uMax, vMin, vMax); - this.center = center; - this.f1 = f1; - this.f2 = f2; - this.f3 = f3; - ts3dutils.assert(0 <= uMin && uMin <= PI, uMin); - ts3dutils.assert(0 <= uMax && uMax <= PI, uMax); - ts3dutils.assert(-PI / 2 <= vMin && vMin <= PI / 2); - ts3dutils.assert(-PI / 2 <= vMax && vMax <= PI / 2); - ts3dutils.assertVectors(center, f1, f2, f3); - this.matrix = ts3dutils.M4.forSys(f1, f2, f3, center); - this.matrixInverse = this.matrix.inversed(); - this.normalDir = sign(this.f1.cross(this.f2).dot(this.f3)); - this.pLCNormalWCMatrix = this.matrix - .as3x3() - .inversed() - .transposed() - .scale(this.normalDir); - this.pWCNormalWCMatrix = this.pLCNormalWCMatrix.times(this.matrixInverse); - } - static unitArea(contour) { - const totalArea = ts3dutils.sum(contour.map((edge) => { - if (edge.curve instanceof __.PICurve) { - const points = edge.curve.calcSegmentPoints(edge.aT, edge.bT, edge.a, edge.b, edge.aT > edge.bT, true); - let sum = 0; - for (let i = 0; i < points.length - 1; i++) { - const p = points[i], ppp = points[i + 1]; - sum += ((abs(p.angleXY()) + abs(ppp.angleXY())) / 2) * (ppp.z - p.z); - } - return sum; - } - else if (edge.curve instanceof __.EllipseCurve) { - const f = (t) => { - const at = edge.curve.at(t), tangent = edge.curve.tangentAt(t); - const angleXY = abs(at.angleXY()); - //const arcLength = angleXY * Math.sqrt(1 - at.z ** 2) ( == at.lengthXY()) - //const scaling = tangent.z / at.lengthXY() - return angleXY * tangent.z; - }; - const val = ts3dutils.glqInSteps(f, edge.aT, edge.bT, 1); - return val; - } - else { - throw new Error(); - } - })); - return totalArea; - } - /** - * unit sphere: x² + y² + z² = 1 - * line: p = anchor + t * dir |^2 - * p² = (anchor + t * dir)^2 - * 1 == (anchor + t * dir)^2 - * 1 == anchor DOT anchor + 2 * anchor * t * dir + t² * dir DOT dir - */ - static unitISTsWithLine(anchor, dir) { - // for 0 = a t² + b t + c - const a = dir.dot(dir); - const b = 2 * anchor.dot(dir); - const c = anchor.dot(anchor) - 1; - return ts3dutils.pqFormula(b / a, c / a).filter((t) => ts3dutils.le(0, anchor.y + t * dir.y)); - } - /** - * unit sphere: x² + y² + z² = 1 - * plane: normal1 DOT p = w - */ - static unitISCurvesWithPlane(plane) { - const distPlaneCenter = Math.abs(plane.w); - if (ts3dutils.lt(distPlaneCenter, 1)) { - // result is a circle - // radius of circle: imagine right angled triangle (origin -> center of intersection circle -> point on - // intersection circle) pythagoras: 1² == distPlaneCenter² + isCircleRadius² => isCircleRadius == sqrt(1 - - // distPlaneCenter²) - const isCircleRadius = Math.sqrt(1 - Math.pow(distPlaneCenter, 2)); - const anchorY = plane.normal1.y * plane.w; - const d = abs(distPlaneCenter * isCircleRadius); - if (ts3dutils.le(anchorY, -d) && !ts3dutils.eq0(distPlaneCenter)) { - return []; - } - else if (ts3dutils.le(anchorY, 0) && !plane.normal1.isParallelTo(ts3dutils.V3.Y)) { - const f1 = plane.normal1.isParallelTo(ts3dutils.V3.Y) - ? ts3dutils.V3.Z - : plane.normal1.cross(ts3dutils.V3.Y).toLength(isCircleRadius); - const f2 = f1.cross(plane.normal1); - const minEta = -anchorY / f2.y, minT = max(0, Math.asin(minEta)); - return [new __.EllipseCurve(plane.anchor, f1, f2, minT, PI - minT)]; - } - else { - const f2 = (plane.normal1.isParallelTo(ts3dutils.V3.Y) - ? ts3dutils.V3.X - : plane.normal1.cross(ts3dutils.V3.Y)).toLength(isCircleRadius); - const f1 = f2.cross(plane.normal1); - const minXi = ts3dutils.eq0(f1.y) ? -1 : -anchorY / f1.y, maxT = Math.acos(max(-1, minXi - ts3dutils.NLA_PRECISION)); - return [ - new __.EllipseCurve(plane.anchor, f1.negated(), f2, PI - maxT, PI), - new __.EllipseCurve(plane.anchor, f1, f2.negated(), 0, maxT), - ]; - } - } - else { - return []; - } - } - static unitISCurvesWithEllipsoidSurface(surface) { - if (surface.isSphere()) { - const surfaceRadius = surface.f1.length(); - const surfaceCenterDist = surface.center.length(); - if (ts3dutils.le(1, surfaceCenterDist - surfaceRadius) || - ts3dutils.le(surfaceCenterDist + surfaceRadius, 1) || - ts3dutils.le(surfaceCenterDist - surfaceRadius, -1)) { - return []; - } - else { - // origin, surface.center and points on the intersection curves form a triangle. - // the height on the segment origin - surface.center is the radius of the is curves - // the distance from the origin to the lot point is the distance to the intersection plane - function heron(a, b, c) { - const p = (a + b + c) / 2; - return sqrt(p * (p - a) * (p - b) * (p - c)); - } - const triangleArea = heron(1, surfaceRadius, surfaceCenterDist); - const radius = (triangleArea * 2) / surfaceCenterDist; - const isCurvesCenterDist = sign(1 + Math.pow(surfaceCenterDist, 2) - Math.pow(surfaceRadius, 2)) * - sqrt(1 - Math.pow(radius, 2)); - const plane = new __.P3(surface.center.unit(), isCurvesCenterDist); - return EllipsoidSurface.unitISCurvesWithPlane(plane.flipped()); - } - } - throw new Error(); - } - static unitISCurvesWithCylinderSurface(surface) { - if (new __.L3(surface.baseCurve.center, surface.dir).containsPoint(ts3dutils.V3.O)) { - const projEllipse = surface.baseCurve.transform(ts3dutils.M4.project(new __.P3(surface.dir, 0))); - const f1Length = projEllipse.f1.length(), f2Length = projEllipse.f2.length(); - if (ts3dutils.lt(1, min(f1Length, f2Length))) - return []; - if (projEllipse.isCircular()) { - const distISCurveCenter = Math.sqrt(1 - Math.pow(min(1, f1Length), 2)); - const isCurveCenter = (surface.dir.y < 0 - ? surface.dir.negated() - : surface.dir).times(distISCurveCenter); - // isCurve.at(t).y = isCurveCenter.y + projEllipse.f1.y * cos(t) + projEllipse.f2.y * sin(t) = 0 - return [new __.EllipseCurve(isCurveCenter, projEllipse.f1, projEllipse.f2)]; - } - } - throw new Error(); - } - static sphere(radius, center = ts3dutils.V3.O) { - ts3dutils.assertNumbers(radius); - return new EllipsoidSurface(center, new ts3dutils.V3(radius, 0, 0), new ts3dutils.V3(0, radius, 0), new ts3dutils.V3(0, 0, radius)); - } - /** - * x²/a² + y²/b² + z²/c² = 1 - */ - static forABC(a, b, c, center = ts3dutils.V3.O) { - return new EllipsoidSurface(center, new ts3dutils.V3(a, 0, 0), new ts3dutils.V3(0, b, 0), new ts3dutils.V3(0, 0, c)); - } - static calculateAreaSpheroid(a, b, c, edges) { - ts3dutils.assertf(() => a.isPerpendicularTo(b)); - ts3dutils.assertf(() => b.isPerpendicularTo(c)); - ts3dutils.assertf(() => c.isPerpendicularTo(a)); - // handling discontinuities: - // option 1: check for intersections with baseline, if there are any integrate parts separetely - // "rotate" the edge so that there are no overlaps - const matrix = ts3dutils.M4.forSys(a, b, c), matrixInverse = matrix.inversed(); - const circleRadius = a.length(); - const c1 = c.unit(); - const totalArea = ts3dutils.sum(edges.map((edge) => { - if (edge.curve instanceof __.EllipseCurve) { - const f = (t) => { - const at = edge.curve.at(t), tangent = edge.tangentAt(t); - const localAt = matrixInverse.transformPoint(at); - const angleXY = localAt.angleXY(); - const arcLength = angleXY * circleRadius * Math.sqrt(1 + Math.pow(localAt.z, 2)); - const scaling = Math.sqrt(1 + Math.pow(c1.dot(tangent), 2)); - return arcLength * scaling; - }; - const val = ts3dutils.glqInSteps(f, edge.aT, edge.bT, 1); - return val; - } - else { - throw new Error(); - } - })); - return totalArea; - } - getConstructorParameters() { - return [ - this.center, - this.f1, - this.f2, - this.f3, - this.uMin, - this.uMax, - this.vMin, - this.vMax, - ]; - } - equals(obj) { - return (this == obj || - (Object.getPrototypeOf(obj) == this.constructor.prototype && - this.matrix.equals(obj.matrix))); - } - edgeLoopCCW(loop) { - return (EllipsoidSurface.unitArea(loop.map((edge) => edge.transform(this.matrixInverse))) > 0); - //let totalAngle = 0 - //for (let i = 0; i < contour.length; i++) { - // const ipp = (i + 1) % contour.length - // const edge = contour[i], nextEdge = contour[ipp] - // totalAngle += edge.bDir.angleRelativeNormal(nextEdge.aDir, this.normalP(edge.b)) - //} - //return le(0, totalAngle) - } - like(object) { - if (!this.isCoplanarTo(object)) - return false; - // normals need to point in the same direction (outwards or inwards) for both - return this.matrix.determinant3() * object.matrix.determinant3() > 0; - } - rootPoints() { } - toMesh() { - return __.ParametricSurface.prototype.toMesh.call(this); - } - clipCurves(curves) { - return curves.flatMap((curve) => curve.clipPlane(this.getSeamPlane())); - } - dpdu() { - // dp(u, v) = new V3(cos(t) * cos(s), cos(t) * sin(s), sin(t) - return (u, v) => this.matrix.transformVector(new ts3dutils.V3(cos(v) * -sin(u), cos(v) * cos(u), 0)); - } - dpdv() { - return (u, v) => this.matrix.transformVector(new ts3dutils.V3(-sin(v) * cos(u), -sin(v) * sin(u), cos(v))); - } - isCurvesWithPCS(surface) { - let curves2 = __.ParametricSurface.isCurvesParametricImplicitSurface(surface, this, 0.1, 0.1 / surface.dir.length(), 0.05); - curves2 = this.clipCurves(curves2); - return curves2; - } - isCurvesWithPCSSmart(surface) { - const surfaceLC = surface.transform(this.matrixInverse); - //const lcMinZ0RelO = - const baseCurveLC = surfaceLC.baseCurve.project(new __.P3(surfaceLC.dir, 0)); - const ists = baseCurveLC.isTsWithSurface(EllipsoidSurface.UNIT); - const insideIntervals = ts3dutils.getIntervals(ists, baseCurveLC.tMin, baseCurveLC.tMax).filter(([a, b]) => baseCurveLC.at((a + b) / 2).length() < 1); - const projectedCurves = [0, 1].map((id) => { - return (t) => { - const atSqr = ts3dutils.snap(baseCurveLC.at(t).squared(), 1); - const lineISTs = /* +- */ sqrt(1 - atSqr); - //assert(!isNaN(lineISTs)) - return ts3dutils.eq0(lineISTs) - ? baseCurveLC.at(t) - : baseCurveLC - .at(t) - .plus(surfaceLC.dir.times(sign(id - 0.5) * lineISTs)); - }; - }); - const dProjectedCurves = [0, 1].map((id) => { - return (t) => { - // d/dt sqrt(1 - baseCurveLC.at(t).squared()) - // = -1/2 * 1/sqrt(1 - baseCurveLC.at(t).squared()) * -2*baseCurveLC.at(t) * baseCurveLC.tangentAt(t) - const atSqr = ts3dutils.snap(baseCurveLC.at(t).squared(), 1); - const lineISTs = /* +- */ baseCurveLC - .at(t) - .times(-1 / sqrt(1 - atSqr)) - .dot(baseCurveLC.tangentAt(t)); - //assert(!isNaN(lineISTs)) - return baseCurveLC - .tangentAt(t) - .plus(surfaceLC.dir.times(sign(id - 0.5) * lineISTs)); - }; - }); - //const f2 = t => sqrt(1 - baseCurveLC.at(t).squared()) - //const df2 = t => baseCurveLC.at(t).times(-1 / sqrt(1 - - // baseCurveLC.at(t).squared())).dot(baseCurveLC.tangentAt(t)) checkDerivate(f2, df2, 0.31, 0.60) - const curves = []; - for (const [aT, bT] of insideIntervals) { - //const aLine = new L3(baseCurveLC.at(aT), surfaceLC.dir1) - //const a = EllipsoidSurface.UNIT.isTsForLine(aLine).map(t => aLine.at(t)) - //const bLine = new L3(baseCurveLC.at(bT), surfaceLC.dir1) - //const b = EllipsoidSurface.UNIT.isTsForLine(bLine).map(t => bLine.at(t)) - for (const i of [0, 1]) { - const f = (t) => projectedCurves[i](t).y; - const df = (t) => dProjectedCurves[i](t).y; - ts3dutils.checkDerivate(f, df, aT + 0.1, bT - 0.1); - const tsAtY0 = ts3dutils.getRoots(f, aT + ts3dutils.NLA_PRECISION, bT - ts3dutils.NLA_PRECISION, 1 / (1 << 11), df); - const ii2 = ts3dutils.getIntervals(tsAtY0, aT, bT).filter(([a, b]) => f((a + b) / 2) > 0); - for (const [aT2, bT2] of ii2) { - let aP = projectedCurves[i](aT2), bP = projectedCurves[i](bT2); - 0 === i && ([aP, bP] = [bP, aP]); - ts3dutils.assert(EllipsoidSurface.UNIT.containsPoint(aP)); - ts3dutils.assert(EllipsoidSurface.UNIT.containsPoint(bP)); - curves.push(__.PICurve.forStartEnd(surface, this, this.matrix.transformPoint(bP), this.matrix.transformPoint(aP), undefined)); - } - } - } - return surface.clipCurves(curves); - } - isCurvesWithSurface(surface) { - if (surface instanceof __.PlaneSurface) { - return this.isCurvesWithPlane(surface.plane); - } - else if (surface instanceof __.CylinderSurface) { - return this.isCurvesWithCylinderSurface(surface); - } - else if (surface instanceof EllipsoidSurface) { - const surfaceLC = surface.transform(this.matrixInverse); - const curves = EllipsoidSurface.unitISCurvesWithEllipsoidSurface(surfaceLC).map((c) => c.transform(this.matrix)); - return surface.clipCurves(curves); - } - else if (surface instanceof __.ProjectedCurveSurface) { - return this.isCurvesWithPCS(surface); - } - else if (surface instanceof __.ParametricSurface) { - let curves2 = __.ParametricSurface.isCurvesParametricImplicitSurface(surface, this, 0.1, 0.1, 0.05); - curves2 = this.clipCurves(curves2); - curves2 = surface.clipCurves(curves2); - return curves2; - } - else { - throw new Error(); - } - } - isCurvesWithPlane(plane) { - const planeLC = plane.transform(this.matrixInverse); - return EllipsoidSurface.unitISCurvesWithPlane(planeLC).map((c) => c.transform(this.matrix)); - } - isCurvesWithCylinderSurface(surface) { - if (__.L3.containsPoint(surface.baseCurve.center, surface.dir, this.center)) { - ts3dutils.assert(this.isSphere()); - const ellipseProjected = surface.baseCurve.transform(ts3dutils.M4.project(surface.baseCurve.getPlane(), surface.dir)); - if (ellipseProjected.isCircular()) { - const thisRadius = this.f1.length(); - const surfaceRadius = ellipseProjected.f1.length(); - // sphereRadius² = distanceISFromCenter² + isRadius² - if (ts3dutils.eq(thisRadius, surfaceRadius)) ; - ts3dutils.assert(false); - } - } - return this.isCurvesWithPCS(surface); - } - isTsForLine(line) { - ts3dutils.assertInst(__.L3, line); - // transforming line manually has advantage that dir1 will not be renormalized, - // meaning that calculated values t for localLine are directly transferable to line - const anchorLC = this.matrixInverse.transformPoint(line.anchor); - const dirLC = this.matrixInverse.transformVector(line.dir1); - return EllipsoidSurface.unitISTsWithLine(anchorLC, dirLC); - } - isCoplanarTo(surface) { - if (this === surface) - return true; - if (!ts3dutils.hasConstructor(surface, EllipsoidSurface)) - return false; - if (!this.center.like(surface.center)) - return false; - if (this.isSphere()) - return surface.isSphere() && ts3dutils.eq(this.f1.length(), this.f2.length()); - const otherMatrixLC = this.matrixInverse.times(surface.matrix); - // Ellipsoid with matrix otherMatrixLC is unit sphere iff otherMatrixLC is orthogonal - return otherMatrixLC.like3x3() && otherMatrixLC.isOrthogonal(); - } - containsEllipse(ellipse) { - const ellipseLC = ellipse.transform(this.matrixInverse); - const distEllipseLCCenter = ellipseLC.center.length(); - const correctRadius = Math.sqrt(1 - Math.pow(distEllipseLCCenter, 2)); - return (ts3dutils.lt(distEllipseLCCenter, 1) && - ellipseLC.isCircular() && - ellipseLC.f1.hasLength(correctRadius)); - //&& le(0, ellipseLC.getAABB().min.y) - } - containsCurve(curve) { - if (curve instanceof __.EllipseCurve) { - return this.containsEllipse(curve); - } - else { - return super.containsCurve(curve); - } - } - transform(m4) { - ts3dutils.assert(m4.isNoProj(), () => m4.sce); - return new EllipsoidSurface(m4.transformPoint(this.center), m4.transformVector(this.f1), m4.transformVector(this.f2), m4.transformVector(this.f3).times(m4.isMirroring() ? -1 : 1)); - } - transform4(m4) { - console.log("transform4"); - const resultMatrix = m4.times(this.matrix); - console.log(resultMatrix.toString()); - const scaleDir = ts3dutils.V(resultMatrix.m[12], resultMatrix.m[13], resultMatrix.m[14]); - // need to find parameters where scaleDir is parallel to the normal - const pLC = this.pLCNormalWCMatrix.inversed().transformPoint(scaleDir); - const s = pLC.angleXY(); - const t = Math.asin(ts3dutils.clamp(pLC.z, -1, 1)); - const fa = resultMatrix.transformPoint(scaleDir.unit()); - const fb = resultMatrix.transformPoint(scaleDir.unit().negated()); - const newCenter = ts3dutils.V3.lerp(fa, fb, 0.5); - console.log(scaleDir.sce, s, t, fa, fb, "newCenter", newCenter.sce); - return new EllipsoidSurface(newCenter, m4.transformVector2(this.f1, this.center), m4.transformVector2(this.f2, this.center), m4 - .transformVector2(this.f3, this.center) - .times(m4.isMirroring() ? -1 : 1)); - } - isInsideOut() { - return this.f1.cross(this.f2).dot(this.f3) < 0; - } - flipped() { - return new EllipsoidSurface(this.center, this.f1, this.f2, this.f3.negated(), this.uMin, this.uMax, -this.vMax, -this.vMin); - } - normalUVFunc() { - // ugh - // paramtric ellipsoid point q(a, b) - // normal1 == (dq(a, b) / da) X (dq(a, b) / db) (cross product of partial derivatives) - // normal1 == cos b * (f2 X f3 * cos b * cos a + f3 X f1 * cos b * sin a + f1 X f2 * sin b) - return (a, b) => { - const { f1, f2, f3 } = this; - const normal = f2 - .cross(f3) - .times(Math.cos(b) * Math.cos(a)) - .plus(f3.cross(f1).times(Math.cos(b) * Math.sin(a))) - .plus(f1.cross(f2).times(Math.sin(b))) - //.times(Math.cos(b)) - .unit(); - return normal; - }; - } - normalP(p) { - return this.pLCNormalWCMatrix - .transformVector(this.matrixInverse.transformPoint(p)) - .unit(); - } - normalUV(u, v) { - return this.pLCNormalWCMatrix.transformVector(ts3dutils.V3.sphere(u, v)).unit(); - } - uvPFunc() { - return (pWC) => { - const pLC = this.matrixInverse.transformPoint(pWC); - const alpha = abs(pLC.angleXY()); - const beta = Math.asin(ts3dutils.clamp(pLC.z, -1, 1)); - ts3dutils.assert(isFinite(alpha)); - ts3dutils.assert(isFinite(beta)); - return new ts3dutils.V3(alpha, beta, 0); - }; - } - pUVFunc() { - // this(a, b) = f1 cos a cos b + f2 sin a cos b + f2 sin b - return (alpha, beta) => { - return this.matrix.transformPoint(ts3dutils.V3.sphere(alpha, beta)); - }; - } - isSphere() { - return (ts3dutils.eq(this.f1.length(), this.f2.length()) && - ts3dutils.eq(this.f2.length(), this.f3.length()) && - ts3dutils.eq(this.f3.length(), this.f1.length()) && - this.f1.isPerpendicularTo(this.f2) && - this.f2.isPerpendicularTo(this.f3) && - this.f3.isPerpendicularTo(this.f1)); - } - isVerticalSpheroid() { - return (ts3dutils.eq(this.f1.length(), this.f2.length()) && - this.f1.isPerpendicularTo(this.f2) && - this.f2.isPerpendicularTo(this.f3) && - this.f3.isPerpendicularTo(this.f1)); - } - mainAxes() { - // q(a, b) = f1 cos a cos b + f2 sin a cos b + f3 sin b - // q(s, t, u) = s * f1 + t * f2 + u * f3 with s² + t² + u² = 1 - // (del q(a, b) / del a) = f1 (-sin a) cos b + f2 cos a cos b - // (del q(a, b) / del b) = f1 cos a (-sin b) + f2 sin a (-sin b) + f2 cos b - // del q(s, t, u) / del a = -t f1 + s f2 - // (del q(a, b) / del a) DOT q(a, b) == 0 - // (f1 (-sin a) cos b + f2 cos a cos b) DOT (f1 cos a cos b + f2 sin a cos b + f2 sin b) == 0 - // (del q(a, b) / del b) DOT q(a, b) == 0 - // (f1 cos a (-sin b) + f2 sin a (-sin b) + f2 cos b) DOT (f1 cos a cos b + f2 sin a cos b + f2 sin b) == 0 - // Solve[ - // (f1 (-sin a) cos b + f2 cos a cos b) * (f1 cos a cos b + f2 sin a cos b + f2 sin b) = 0, - // (f1 cos a (-sin b) + f2 sin a (-sin b) + f2 cos b) * (f1 cos a cos b + f2 sin a cos b + f2 sin b) = 0}, a, b] - const { f1, f2, f3 } = this; - if (ts3dutils.eq0(f1.dot(f2)) && ts3dutils.eq0(f2.dot(f3)) && ts3dutils.eq0(f3.dot(f1))) { - return this; - } - //const f = ([a, b], x?) => { - // const sinA = Math.sin(a), cosA = Math.cos(a), sinB = Math.sin(b), cosB = Math.cos(b) - // const centerToP = V3.add(f1.times(cosA * cosB), f2.times(sinA * cosB), f3.times(sinB)) - // const centerToPdelA = f1.times(-sinA * cosB).plus(f2.times(cosA * cosB)) - // const centerToPdelB = V3.add(f1.times(cosA * -sinB), f2.times(sinA * -sinB), f3.times(cosB)) - // x && console.log(centerToP.sce, centerToPdelA.sce, centerToPdelB.sce) - // return [centerToP.dot(centerToPdelA), centerToP.dot(centerToPdelB)] - //} - //const mainF1Params = newtonIterate(f, [0, 0], 8), mainF1 = this.pUVFunc()(mainF1Params[0], mainF1Params[1]) - //console.log(f(mainF1Params, 1).sce) - //const mainF2Params = newtonIterate(f, this.uvPFunc()(f2.rejectedFrom(mainF1)).toArray(2), 8), - // mainF2 = this.pUVFunc()(mainF2Params[0], mainF2Params[1]) - //console.log(this.normalUVFunc()(mainF2Params[0], mainF2Params[1]).sce) - //assert(mainF1.isPerpendicularTo(mainF2), mainF1, mainF2, mainF1.dot(mainF2), mainF1Params) - //const mainF3Params = this.uvPFunc()(mainF1.cross(mainF2)), mainF3 = this.pUVFunc()(mainF3Params[0], - // mainF3Params[1]) return new EllipsoidSurface(this.center, mainF1, mainF2, mainF3) - const { U, SIGMA } = this.matrix.svd3(); - ts3dutils.assert(SIGMA.isDiagonal()); - ts3dutils.assert(U.isOrthogonal()); - const U_SIGMA = U.times(SIGMA); - // column vectors of U_SIGMA - const [mainF1, mainF2, mainF3] = ts3dutils.arrayFromFunction(3, (i) => new ts3dutils.V3(U_SIGMA.m[i], U_SIGMA.m[i + 4], U_SIGMA.m[i + 8])); - return new EllipsoidSurface(this.center, mainF1, mainF2, mainF3); - } - containsPoint(p) { - return ts3dutils.eq0(this.implicitFunction()(p)); - } - boundsFunction() { - return (a, b) => ts3dutils.between(a, 0, PI) && ts3dutils.between(b, -PI, PI); - } - volume() { - return (4 / 3) * Math.PI * this.f1.dot(this.f2.cross(this.f3)); - } - loopContainsPoint(loop, pWC) { - if (!this.containsPoint(pWC)) - return __.PointVsFace.OUTSIDE; - ts3dutils.assertVectors(pWC); - ts3dutils.assert(__.Edge.isLoop(loop)); - const pLCXY = this.matrixInverse.transformPoint(pWC).xy(); - const testLine = new __.EllipseCurve(this.center, this.f3, pLCXY.likeO() ? this.f2 : this.matrix.transformVector(pLCXY.unit())); - if (__.P3.normalOnAnchor(this.f2.unit(), this.center).containsPoint(pWC)) { - return loop.some((edge) => edge.curve.containsPoint(pWC) && - ts3dutils.fuzzyBetween(edge.curve.pointT(pWC), edge.minT, edge.maxT)) - ? __.PointVsFace.ON_EDGE - : __.PointVsFace.OUTSIDE; - } - return __.Surface.loopContainsPointEllipse(loop, pWC, testLine); - } - surfaceAreaApprox() { - // See https://en.wikipedia.org/wiki/Ellipsoid#Surface_area - const mainAxes = this.mainAxes(), a = mainAxes.f1.length(), b = mainAxes.f2.length(), c = mainAxes.f3.length(); - const p = 1.6075; - return (4 * - PI * - Math.pow((Math.pow(a * b, p) + Math.pow(b * c, p) + Math.pow(c * a, p)) / 3, 1 / p)); - } - surfaceArea() { - // See https://en.wikipedia.org/wiki/Ellipsoid#Surface_area - const mainAxes = this.mainAxes(), f1l = mainAxes.f1.length(), f2l = mainAxes.f2.length(), f3l = mainAxes.f3.length(), [c, b, a] = [f1l, f2l, f3l].sort(ts3dutils.MINUS); - // https://en.wikipedia.org/w/index.php?title=Spheroid&oldid=761246800#Area - function spheroidArea(a, c) { - if (c < a) { - const eccentricity2 = 1 - Math.pow(c, 2) / Math.pow(a, 2); - const eccentricity = Math.sqrt(eccentricity2); - return (2 * - PI * - Math.pow(a, 2) * - (1 + - ((1 - eccentricity2) / Math.sqrt(eccentricity)) * - Math.atanh(eccentricity))); - } - else { - const eccentricity = Math.sqrt(1 - Math.pow(a, 2) / Math.pow(c, 2)); - return (2 * - PI * - Math.pow(a, 2) * - (1 + (c / a / eccentricity) * Math.asin(eccentricity))); - } - } - if (ts3dutils.eq(a, b)) { - return spheroidArea(a, c); - } - else if (ts3dutils.eq(b, c)) { - return spheroidArea(b, a); - } - else if (ts3dutils.eq(c, a)) { - return spheroidArea(c, b); - } - const phi = Math.acos(c / a); - const kk = (Math.pow(a, 2) * (Math.pow(b, 2) - Math.pow(c, 2))) / (Math.pow(b, 2) * (Math.pow(a, 2) - Math.pow(c, 2))); - const incompleteEllipticInt1 = ts3dutils.gaussLegendreQuadrature24((phi) => Math.pow(1 - kk * Math.pow(Math.sin(phi), 2), -0.5), 0, phi); - const incompleteEllipticInt2 = ts3dutils.gaussLegendreQuadrature24((phi) => Math.pow(1 - kk * Math.pow(Math.sin(phi), 2), 0.5), 0, phi); - return ((2 * PI * Math.pow(c, 2) + (2 * PI * a * b) / Math.sin(phi)) * - (incompleteEllipticInt2 * Math.pow(Math.sin(phi), 2) + - incompleteEllipticInt1 * Math.pow(Math.cos(phi), 2))); - } - getSeamPlane() { - const plane = __.P3.forAnchorAndPlaneVectors(this.center, this.f1, this.f3); - return plane.normal1.dot(this.f2) < 0 ? plane : plane.flipped(); - } - getExtremePoints() { - return __.getExtremePointsHelper.call(this, new __.EllipseCurve(ts3dutils.V3.O, ts3dutils.V3.X, ts3dutils.V3.Z, -PI / 2, PI / 2)); - } - pointFoot(pWC, startS, startT) { - console.log(pWC.sce); - if (undefined === startS || undefined === startT) { - let pLC1 = this.matrixInverse.transformPoint(pWC).unit(); - if (pLC1.y < 0) - pLC1 = pLC1.negated(); - ({ x: startS, y: startT } = EllipsoidSurface.UNIT.uvP(pLC1)); - } - const dpdu = this.dpdu(); - const dpdv = this.dpdv(); - const [u, v] = ts3dutils.newtonIterate(([u, v]) => { - const p = this.pUV(u, v); - console.log([p, p.plus(dpdu(u, v)), p, p.plus(dpdv(u, v))].map(ts3dutils.toSource).join() + - ","); - const pUVToPWC = this.pUV(u, v).to(pWC); - return [pUVToPWC.dot(dpdu(u, v)), pUVToPWC.dot(dpdv(u, v))]; - }, [startS, startT], 8, undefined, 0.1); - return new ts3dutils.V3(u, v, 0); - } - implicitFunction() { - return (pWC) => { - const pLC = this.matrixInverse.transformPoint(pWC); - return (pLC.length() - 1) * this.normalDir; - }; - } - // = this.inverseMatrix.transformPoint(this.inverseMatrix.transformPoint(pWC).unit()) - didp(pWC) { - // i(pWC) = this.inverseMatrix.transformPoint(pWC).length() - 1 - // chain diff rule - const pLC = this.matrixInverse.transformPoint(pWC); - return this.pLCNormalWCMatrix.transformVector(pLC.unit()); //.times(this.normalDir) - } - /*+ - * An ellipsoid remains an ellipsoid after a perspective transform (as long as it does not intersect the vanishing - * plane. This transforms a matrix with a perspective component into one which would return an identical ellipsoid, - * but with no perspective component. - */ - static unitTransform4(m) { - m.m[15] !== 1 && (m = m.divScalar(m.m[15])); - // X * P = m => X = m * P^-1 - // prettier-ignore - const Pinv = new ts3dutils.M4(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -m.m[12], -m.m[13], -m.m[14], 1); - const pn = new ts3dutils.V3(m.m[12], m.m[13], m.m[14]), pw = m.m[15]; - const pwSqrMinusPnSqr = Math.pow(pw, 2) - pn.squared(); - if (ts3dutils.lt(pwSqrMinusPnSqr, 0)) { - throw new Error("vanishing plane intersects unit sphere"); - } - const c = pn.div(-pwSqrMinusPnSqr); - const scale = pn.times((pw * pn.length()) / (pn.squared() * -pwSqrMinusPnSqr)); - const scale1 = pw / -pwSqrMinusPnSqr; - const scale2 = 1 / sqrt(pwSqrMinusPnSqr); - const rotNX = ts3dutils.M4.forSys(pn.unit(), pn.getPerpendicular().unit()); - return ts3dutils.M4.product(m, Pinv, ts3dutils.M4.translate(c), rotNX, ts3dutils.M4.scale(scale1, scale2, scale2), rotNX.transposed()); - } -} -EllipsoidSurface.UNIT = new EllipsoidSurface(ts3dutils.V3.O, ts3dutils.V3.X, ts3dutils.V3.Y, ts3dutils.V3.Z); -EllipsoidSurface.prototype.uStep = PI / 32; -EllipsoidSurface.prototype.vStep = PI / 32; - -class PlaneSurface extends __.ParametricSurface { - constructor(plane, right = plane.normal1.getPerpendicular().unit(), up = plane.normal1.cross(right).unit(), uMin = -100, uMax = 100, vMin = -100, vMax = 100) { - super(uMin, uMax, vMin, vMax); - this.plane = plane; - this.right = right; - this.up = up; - ts3dutils.assertInst(__.P3, plane); - ts3dutils.assert(this.right.cross(this.up).like(this.plane.normal1)); - this.matrix = ts3dutils.M4.forSys(right, up, plane.normal1, plane.anchor); - } - toSource(rounder = (x) => x) { - return ts3dutils.callsce.call(undefined, "new PlaneSurface", ...this.getConstructorParameters()); - } - static throughPoints(a, b, c) { - return new PlaneSurface(__.P3.throughPoints(a, b, c)); - } - static forAnchorAndPlaneVectors(anchor, v0, v1, uMin, uMax, vMin, vMax) { - return new PlaneSurface(__.P3.forAnchorAndPlaneVectors(anchor, v0, v1), v0, v1, uMin, uMax, vMin, vMax); - } - isCoplanarTo(surface) { - return (ts3dutils.hasConstructor(surface, PlaneSurface) && - this.plane.isCoplanarToPlane(surface.plane)); - } - isTsForLine(line) { - return line.isTsWithPlane(this.plane); - } - like(surface) { - return (ts3dutils.hasConstructor(surface, PlaneSurface) && this.plane.like(surface.plane)); - } - pUV(u, v) { - return this.matrix.transformPoint(new ts3dutils.V3(u, v, 0)); - } - implicitFunction() { - return (p) => this.plane.distanceToPointSigned(p); - } - isCurvesWithSurface(surface2) { - if (surface2 instanceof PlaneSurface) { - return this.isCurvesWithPlane(surface2.plane); - } - return super.isCurvesWithSurface(surface2); - } - isCurvesWithPlane(plane) { - const result = this.plane.intersectionWithPlane(plane); - return result ? [result] : []; - } - edgeLoopCCW(contour) { - ts3dutils.assert(__.Edge.isLoop(contour), "isLoop"); - return ts3dutils.isCCW(contour.flatMap((edge) => edge.points()), this.plane.normal1); - } - loopContainsPoint(loop, p) { - const dir = this.right.plus(this.up.times(0.123)).unit(); - const line = new __.L3(p, dir); - const lineOut = dir.cross(this.plane.normal1); - return __.Surface.loopContainsPointGeneral(loop, p, line, lineOut); - } - uvPFunc() { - const matrixInverse = this.matrix.inversed(); - return function (pWC) { - return matrixInverse.transformPoint(pWC); - }; - } - pointFoot(pWC) { - return this.uvP(pWC); - } - normalP(pWC) { - return this.plane.normal1; - } - containsPoint(p) { - return this.plane.containsPoint(p); - } - containsCurve(curve) { - return curve instanceof __.ImplicitCurve - ? super.containsCurve(curve) - : this.plane.containsCurve(curve); - } - transform(m4) { - return new PlaneSurface(this.plane.transform(m4)); - } - transform4(m4) { - return new PlaneSurface(this.plane.transform(m4)); - } - flipped() { - return new PlaneSurface(this.plane.flipped(), this.right, this.up.negated()); - } - getConstructorParameters() { - return [ - this.plane, - this.right, - this.up, - this.uMin, - this.uMax, - this.vMin, - this.vMax, - ]; - } - dpdu() { - return () => this.right; - } - dpdv() { - return () => this.up; - } - didp(pWC) { - return this.plane.normal1; - } - normalUV() { - return this.plane.normal1; - } -} -PlaneSurface.prototype.uStep = 1e6; -PlaneSurface.prototype.vStep = 1e6; - -class PointProjectedSurface extends __.ParametricSurface { - constructor(curve, apex, curvePlane, normalDir = 1, uMin = curve.tMin, uMax = curve.tMax, vMin = 0, vMax = 16) { - super(uMin, uMax, vMin, vMax); - this.curve = curve; - this.apex = apex; - this.curvePlane = curvePlane; - this.normalDir = normalDir; - ts3dutils.assertInst(__.Curve, curve); - ts3dutils.assert(!(curve instanceof __.L3), "use PlaneSurface instead"); - ts3dutils.assert(!(curve instanceof __.EllipseCurve), "use ConicSurface instead"); - ts3dutils.assert(!(curve instanceof __.ImplicitCurve), "this just seems like a terrible idea"); - ts3dutils.assert(new __.PlaneSurface(curvePlane).containsCurve(curve)); - ts3dutils.assertVectors(apex); - ts3dutils.assert(0 <= vMin); - this.planeProjectionMatrix = ts3dutils.M4.projectPlanePoint(apex, curvePlane); - this.uStep = curve.tIncrement; - } - pointFoot(pWC, startU, startV) { - if (undefined === startU || undefined === startV) { - // similar to stP - if (undefined === startU) { - startU = pWC.like(this.apex) - ? 0 - : this.curve.closestTToPoint(this.planeProjectionMatrix.transformPoint(pWC)) * this.normalDir; - } - if (undefined === startV) { - startV = ts3dutils.V3.inverseLerp(this.apex, this.curve.at(startU), pWC); - } - } - const f = ([u, v]) => { - const pUVToPWC = this.pUV(u, v).to(pWC); - return [this.dpdu()(u, v).dot(pUVToPWC), this.dpdv()(u).dot(pUVToPWC)]; - }; - const { 0: x, 1: y } = ts3dutils.newtonIterate(f, [startU, startV]); - return new ts3dutils.V3(x, y, 0); - } - getConstructorParameters() { - return [ - this.curve, - this.apex, - this.curvePlane, - this.normalDir, - this.uMin, - this.uMax, - this.vMin, - this.vMax, - ]; - } - static unitISLineTs(anchor, dir) { - const { x: ax, y: ay, z: az } = anchor; - const { x: dx, y: dy, z: dz } = dir; - // this cone: x² + y² = z² - // line: p = anchor + t * dir1 - // split line equation into 3 component equations, insert into cone equation - // transform to form (a t² + b t + c = 0) and solve with pqFormula - const a = dx * dx + dy * dy - dz * dz; - const b = 2 * (ax * dx + ay * dy - az * dz); - const c = ax * ax + ay * ay - az * az; - // cone only defined for 0 <= z, so filter invalid values - return ts3dutils.pqFormula(b / a, c / a).filter((t) => 0 < az + t * dz); - } - equals(obj) { - return (this == obj || - (ts3dutils.hasConstructor(obj, PointProjectedSurface) && - this.curve.equals(obj.curve) && - this.apex.equals(this.apex))); - } - like(object) { - if (!this.isCoplanarTo(object)) - return false; - // normals need to point in the same direction (outwards or inwards) for both - return this.normalDir == object.normalDir; - } - loopContainsPoint(contour, p) { - ts3dutils.assertVectors(p); - const line = this.apex.like(p) - ? new __.L3(p, this.apex.to(this.curve.at(this.curve.tMin)).unit()) - : __.L3.throughPoints(p, this.apex); - const lineOut = line.dir1.cross(this.curvePlane.normal1); - return __.Surface.loopContainsPointGeneral(contour, p, line, lineOut); - } - isTsForLine(line) { - // transforming line manually has advantage that dir1 will not be renormalized, - // meaning that calculated values t for lineLC are directly transferable to line - const anchorPlane = this.planeProjectionMatrix.transformPoint(line.anchor); - const anchor2Plane = this.planeProjectionMatrix.transformPoint(line.anchor.plus(line.dir1)); - if (anchorPlane.like(anchor2Plane)) { - // line projects onto a point in plane. - // there are either no or infinite intersection points - return []; - } - return this.curve - .isInfosWithLine(anchorPlane, anchorPlane.to(anchor2Plane), undefined, undefined, line.tMin, line.tMax) - .map((info) => info.tOther); - } - /** - * Interestingly, two cones don't need to have parallel dirs to be coplanar. - */ - isCoplanarTo(surface) { - if (this === surface) - return true; - if (!(surface instanceof PointProjectedSurface) || - !this.apex.like(surface.apex)) - return false; - // at this point apexes are equal - return this.containsCurve(surface.curve); - } - containsLine(line) { - if (this.curvePlane.isParallelToLine(line)) { - return false; - } - if (!line.containsPoint(this.apex)) { - return false; - } - const p = this.curvePlane.intersectionWithLine(line); - return this.curve.containsPoint(p); - } - containsCurve(curve) { - if (curve instanceof __.L3) { - return this.containsLine(curve); - } - else if (!(curve instanceof __.ImplicitCurve)) { - const otherCurveOnThisPlane = curve.transform(this.planeProjectionMatrix); - return this.curve.isColinearTo(otherCurveOnThisPlane); - } - else { - return super.containsCurve(curve); - } - } - transform(m4) { - return new PointProjectedSurface(this.curve.transform(m4), m4.transformPoint(this.apex), this.curvePlane.transform(m4), (m4.isMirroring() ? -1 : 1) * this.normalDir, this.uMin, this.uMax, this.vMin, this.vMax); - } - flipped() { - return new PointProjectedSurface(this.curve, this.apex, this.curvePlane, -this.normalDir, -this.uMax, -this.uMin, this.vMin, this.vMax); - } - normalUVFunc() { - const dpdv = this.dpdv(); - return (u) => this.curve - .tangentAt(u * this.normalDir) - .times(this.normalDir) - .cross(dpdv(u)) - .unit(); - } - pUVFunc() { - return (u, v) => { - return this.apex.lerp(this.curve.at(u * this.normalDir), v); - }; - } - dpdu() { - return (u, v) => { - return this.curve.tangentAt(u * this.normalDir).times(v * this.normalDir); - }; - } - dpdv() { - return (u) => { - return this.apex.to(this.curve.at(u * this.normalDir)); - }; - } - containsPoint(pWC) { - return (this.apex.like(pWC) || - this.curve.containsPoint(this.planeProjectionMatrix.transformPoint(pWC))); - } - uvP(pWC) { - const u = pWC.like(this.apex) - ? 0 - : this.curve.pointT(this.planeProjectionMatrix.transformPoint(pWC)); - const v = ts3dutils.V3.inverseLerp(this.apex, this.curve.at(u), pWC); - return new ts3dutils.V3(u * this.normalDir, v, 0); - } - isCurvesWithSurface(surface) { - if (surface instanceof __.PlaneSurface) { - return this.isCurvesWithPlane(surface.plane); - } - else if (__.ImplicitSurface.is(surface)) { - return __.ParametricSurface.isCurvesParametricImplicitSurface(this, surface, 0.1, 0.1 / this.curvePlane.distanceToPoint(this.apex), 0.02); - } - return super.isCurvesWithSurface(surface); - } - isCurvesWithPlane(plane) { - if (plane.containsPoint(this.apex)) { - if (plane.isParallelToPlane(this.curvePlane)) { - return []; - } - return this.curve - .isTsWithPlane(plane) - .map((t) => __.L3.throughPoints(this.apex, this.curve.at(t))); - } - return [this.curve.transform(ts3dutils.M4.projectPlanePoint(this.apex, plane))]; - } -} -PointProjectedSurface.prototype.vStep = 256; - -class NURBSSurface extends __.ParametricSurface { - constructor( - /** - * Control points in u-major order. I.e. the first pointCountU points are a NURBS. - */ - points, knotsU, knotsV, degreeU, degreeV, uMin = knotsU[degreeU], uMax = knotsU[knotsU.length - degreeU - 1], vMin = knotsV[degreeV], vMax = knotsV[knotsV.length - degreeV - 1]) { - super(uMin, uMax, vMin, vMax); - this.points = points; - this.knotsU = knotsU; - this.knotsV = knotsV; - this.degreeU = degreeU; - this.degreeV = degreeV; - const pointCountU = knotsU.length - 1 - degreeU; - const pointCountV = knotsV.length - 1 - degreeV; - ts3dutils.assert(pointCountU * pointCountV == points.length); - ts3dutils.assert(degreeU <= degreeV, "degreeU <= degreeV"); - ts3dutils.assert(-1 === ts3dutils.firstUnsorted(knotsU, ts3dutils.MINUS), "knot values must be in ascending order"); - ts3dutils.assert(-1 === ts3dutils.firstUnsorted(knotsV, ts3dutils.MINUS), "knot values must be in ascending order"); - } - getConstructorParameters() { - return [ - this.points, - this.knotsU, - this.knotsV, - this.degreeU, - this.degreeV, - this.uMin, - this.uMax, - this.vMin, - this.vMax, - ]; - } - transform(m4) { - return this.transform4(m4); - } - transform4(m4) { - return new NURBSSurface(this.points.map((p) => m4.timesVector(p)), this.knotsU, this.knotsV, this.degreeU, this.degreeV, this.uMin, this.uMax, this.vMin, this.vMax); - } - pUV(u, v) { - return this.isoparametricU(u).at(v); - } - dpdu() { - return (u, v) => this.isoparametricV(v).tangentAt(u); - } - dpdv() { - return (u, v) => this.isoparametricU(u).tangentAt(v); - } - normalUV(u, v) { - const normal = this.dpdu()(u, v).cross(this.dpdv()(u, v)); - return normal.likeO() ? ts3dutils.V3.X : normal.unit(); - } - isoparametricU(u) { - const pointCountU = this.knotsU.length - 1 - this.degreeU; - const pointCountV = this.knotsV.length - 1 - this.degreeV; - return new __.NURBS(ts3dutils.arrayFromFunction(pointCountV, (i) => { - return deBoor(this.points.slice(i * pointCountU, (i + 1) * pointCountU), this.degreeU, this.knotsU, u); - }), this.degreeV, this.knotsV, this.vMin, this.vMax); - } - isoparametricV(v) { - const pointCountU = this.knotsU.length - 1 - this.degreeU; - return new __.NURBS(ts3dutils.arrayFromFunction(pointCountU, (i) => { - return deBoor(ts3dutils.sliceStep(this.points, i, this.points.length, pointCountU, 1), this.degreeV, this.knotsV, v); - }), this.degreeU, this.knotsU, this.uMin, this.uMax); - } - debugInfo() { - const pointCountU = this.knotsU.length - 1 - this.degreeU; - const pointCountV = this.knotsV.length - 1 - this.degreeV; - const grid = []; - for (let u = 0; u < pointCountU; u++) { - for (let v = 0; v < pointCountV; v++) { - const i = v * pointCountU + u; - if (u < pointCountU - 1) { - const j = v * pointCountU + u + 1; - grid.push(this.points[i].p3(), this.points[j].p3()); - } - if (v < pointCountV - 1) { - const j = (v + 1) * pointCountU + u; - grid.push(this.points[i].p3(), this.points[j].p3()); - } - } - } - return { points: this.points.map((p) => p.p3()), lines: grid }; - } - flipped() { - const pointCountU = this.knotsU.length - 1 - this.degreeU; - return new NURBSSurface(ts3dutils.arrayFromFunction(this.points.length, (i) => { - const u = i % pointCountU; - return this.points[i - u + (pointCountU - u - 1)]; - }), this.knotsU.map((x) => -x).reverse(), this.knotsV, this.degreeU, this.degreeV, -this.uMax, -this.uMin, this.vMin, this.vMax); - } - isCoplanarTo(surface) { - throw new Error("not implemented"); - } - isTsForLine(line) { - // intersect line with - const startT = 4; - // Once we have a starting t param, there are two options: - // 1. 1-D Newton iterate on (t) -> (distanceFromSurface) - // 2. 3-D Newton iterate on (u, v, t) -> this.pUV(u, v).to(line.at(t)) - // Let's go with 2, because 1 will require doing a nested newton iteration. - const [startU, startV] = this.pointFoot(line.at(startT)); - const [, , t] = ts3dutils.newtonIterate(([u, v, t]) => { - console.log("uvt", u, v, t); - const lineP = line.at(t); - return ts3dutils.ilog(this.pUV(u, v).to(lineP).toArray()); - }, [startU, startV, startT], 8); - return [t]; - } - pointFoot(pWC, startU, startV) { - const closestPointIndex = ts3dutils.indexWithMax(this.points, (p) => -p.p3().distanceTo(pWC)); - const pointCountU = this.knotsU.length - this.degreeU - 1; - const closestPointPos = ts3dutils.V(closestPointIndex % pointCountU, (closestPointIndex / pointCountU) | 0); - const start = this.guessUVForMeshPos(closestPointPos.x, closestPointPos.y); - const dpdu = this.dpdu(); - const dpdv = this.dpdv(); - try { - const [u, v] = ts3dutils.newtonIterate(([u, v]) => { - // console.log("u,v", u, v) - const pUV = this.pUV(u, v); - const pUVToPWC = pUV.to(pWC); - return [pUVToPWC.dot(dpdu(u, v)), pUVToPWC.dot(dpdv(u, v))]; - }, [start.x, start.y], 16); - return new ts3dutils.V3(u, v, 0); - } - catch (e) { - return undefined; - } - } - isCurvesWithPlane(plane) { - throw new Error("Method not implemented."); - } - containsPoint(pWC) { - const foot = this.pointFoot(pWC); - return foot && this.pUV(foot.x, foot.y).like(pWC); - } - loopContainsPoint(contour, point) { - throw new Error("Method not implemented."); - } - guessUVForMeshPos(x, y) { - function eLerp(arr, t, lerp) { - if (0 === t % 1) - return arr[t]; - return lerp(arr[floor(t)], arr[ceil(t)], t % 1); - } - return new ts3dutils.V3(ts3dutils.clamp(eLerp(this.knotsU, x + (this.degreeU + 1) / 2, ts3dutils.lerp), this.uMin, this.uMax), ts3dutils.clamp(eLerp(this.knotsV, y + (this.degreeV + 1) / 2, ts3dutils.lerp), this.vMin, this.vMax), 0); - } -} -NURBSSurface.prototype.uStep = 1 / 8; -NURBSSurface.prototype.vStep = 1 / 8; -function getInterval(degree, knots, t) { - for (let s = degree; s < knots.length - 1 - degree; s++) { - if (t >= knots[s] && t <= knots[s + 1]) { - return s; - } - } - throw new Error(t + " " + knots); -} -function deBoor(points, degree, knots, t) { - // find s (the spline segment) for the [t] value provided - const s = getInterval(degree, knots, t); - const v = ts3dutils.Vector.pack(points, new Float64Array(points.length * 4)); - // l (level) goes from 1 to the curve degree + 1 - for (let l = 1; l <= degree; l++) { - // build level l of the pyramid - for (let i = s; i > s - degree - 1 + l; i--) { - const alpha = (t - knots[i]) / (knots[i + degree + 1 - l] - knots[i]); - // interpolate each component - for (let d = 0; d < 4; d++) { - v[i * 4 + d] = (1 - alpha) * v[(i - 1) * 4 + d] + alpha * v[i * 4 + d]; - } - } - } - return new ts3dutils.Vector(v.slice(s * 4, s * 4 + 4)); -} - -/** - * In general: the z-dir shadow volume of a face is the integral: SURFACE_INTEGRAL[p in face] (normal(p).z * p.z) dp - * In general: the centroid of the z-dir shadow volume of a face is the integral: - * SURFACE_INTEGRAL[p in face] ((p schur (1, 1, 0.5)) * normal(p).z * p.z) dp - * dividing the z component by 2 is usually done at the very end - */ -const ZDirVolumeVisitor = { - [ConicSurface.name](edges) { - console.log(this); - const dpdu = this.dpdu(); - const dpdv = this.dpdv(); - // INT[edge.at; edge.bT] (at(t) DOT dir) * (at(t) - at(t).projectedOn(dir) / 2).z dt - const totalVolume = ts3dutils.sum(edges.map((edgeWC) => { - const curveWC = edgeWC.curve; - if (curveWC instanceof EllipseCurve || - curveWC instanceof HyperbolaCurve || - curveWC instanceof ParabolaCurve) { - const f = (curveT) => { - const at = curveWC.at(curveT), tangentWC = curveWC.tangentAt(curveT); - const uvOfPWC = this.uvP(at); - // INTEGRATE [0; atUV.y] (dpdu(atUV.x, t) X dpdv(atUV.x)).z * pUV(atUV.x, t).z dt - // dpdu(u, v) === t * dpdu(s, 1) - // => INTEGRATE [0; atUV.y] (t * dpdu(atUV.x, 1) X dpdv(atUV.x)).z * pUV(atUV.x, t).z dt - // => (dpdu(atUV.x, 1) X dpdv(atUV.x)).z * INTEGRATE [0; atUV.y] t * pUV(atUV.x, t).z dt - // pUV(u, v) === t * (pUV(s, 1) - center) + center - // => (dpdu(atUV.x, 1) X dpdv(atUV.x)).z - // * INTEGRATE [0; atUV.y] t² * (pUV(atUV.x, t) - center).z + t * center.z dt - // => (dpdu(atUV.x, 1) X dpdv(atUV.x)).z - // * INTEGRATE [0; atUV.y] t² * (pUV(atUV.x, t) - center).z + t * center.z dt - // => (dpdu(atUV.x, 1) X dpdv(atUV.x)).z - // * (1/3 t³ pUV(atUV.x, 1).z + 1/2 t² center.z)[0; atUV.y] - const du = -ts3dutils.M4.forSys(dpdu(uvOfPWC.x, uvOfPWC.y), dpdv(uvOfPWC.x)) - .inversed() - .transformVector(tangentWC).x; - const factor = (Math.pow(uvOfPWC.y, 3) / 3) * - (this.pUV(uvOfPWC.x, 1).z - this.center.z) + - (Math.pow(uvOfPWC.y, 2) / 2) * this.center.z; - const actual = dpdu(uvOfPWC.x, factor).cross(dpdv(uvOfPWC.x)).z; - return actual * du; - }; - const val = ts3dutils.glqInSteps(f, edgeWC.aT, edgeWC.bT, 1); - return val; - } - else if (curveWC instanceof L3) { - return 0; - } - else { - throw new Error(); - } - })); - const centroidZX2Parts = edges.map((edgeWC) => { - const curveWC = edgeWC.curve; - if (curveWC instanceof EllipseCurve || - curveWC instanceof HyperbolaCurve || - curveWC instanceof ParabolaCurve) { - const f = (curveT) => { - const at = curveWC.at(curveT), tangentWC = curveWC.tangentAt(curveT); - const uvOfPWC = this.uvP(at); - // INTEGRATE [0; atUV.y] dpdu(atUV.x, t) X dpdv(atUV.x, t) * pUV(atUV.x, t).z dt - // dpdv is constant with respect to t - // => (dpdu(atUV.x, t) X dpdv(atUV.x, t)).z - // * (INTEGRATE [0; atUV.y] t * pUV(atUV.x, t) * pUV(atUV.x, t).z dt) - // dpdu(u, v) === t * dpdu(s, 1) - // pUV(u, v) === t * (pUV(s, 1) - center) + center - // INTEGRATE [0; atUV.y] t * pUV(atUV.x, t) * pUV(atUV.x, t).z dt - // = INTEGRATE [0; atUV.y] t * - // (t * (pUV(s, 1) - center) + center) * - // (t (pUV(s, 1) - center).z + center.z) dt - // = INTEGRATE [0; atUV.y] t³ (pUV(s, 1) - center) * (pUV(s, 1) - center).z - // + t² ((pUV(s, 1) - center) * center.z + (pUV(s, 1) - center).z * center) - // + t center center.z dt - // = (1/4 t^4 (pUV(s, 1) - center) * (pUV(s, 1) - center).z - // (1/3 t³ ((pUV(s, 1) - center) * center.z + (pUV(s, 1) - center).z * center) - // (1/2 t² center center.z dt)[0; atUV.y] - const pUVS1V = this.pUV(uvOfPWC.x, 1).minus(this.center); - const factor = ts3dutils.V3.add(pUVS1V.times((1 / 4) * Math.pow(uvOfPWC.y, 4) * pUVS1V.z + - (1 / 3) * Math.pow(uvOfPWC.y, 3) * this.center.z), this.center.times((1 / 3) * Math.pow(uvOfPWC.y, 3) * pUVS1V.z + - (1 / 2) * Math.pow(uvOfPWC.y, 2) * this.center.z)); - const partialCentroid = factor.times(dpdu(uvOfPWC.x, 1).cross(dpdv(uvOfPWC.x)).z); - const ds = -ts3dutils.M4.forSys(dpdu(uvOfPWC.x, uvOfPWC.y), dpdv(uvOfPWC.x)) - .inversed() - .transformVector(tangentWC).x; - return partialCentroid.times(ds); - }; - return glqV3(f, edgeWC.aT, edgeWC.bT); - } - else if (curveWC instanceof L3) { - return ts3dutils.V3.O; - } - else { - throw new Error(); - } - }); - const centroid = ts3dutils.V3.add(...centroidZX2Parts) - .schur(new ts3dutils.V3(1, 1, 0.5)) - .div(totalVolume); - return { volume: totalVolume, centroid: centroid }; - }, - [PlaneSurface.name](edges) { - const r1 = this.right; - const u1 = this.up; - const c = this.plane.anchor; - ts3dutils.assert(r1.hasLength(1)); - ts3dutils.assert(u1.hasLength(1)); - ts3dutils.assert(r1.isPerpendicularTo(u1)); - const volumeAndCentroidZX2Parts = edges.map((edgeWC) => { - const curveWC = edgeWC.curve; - if (curveWC instanceof L3) { - // split shadow volume into two triangle shadow volumes and use the same logic as for mesh triangles: - function triangleShadowVolumeAndCentroid(a, b, c) { - const ab = b.minus(a), ac = c.minus(a); - const normal = ab.cross(ac); - const faceCentroid = ts3dutils.V3.add(a, b, c).div(3); - return [ - (faceCentroid.z * normal.z) / 2, - ts3dutils.V3.add(a.times(2 * a.z + b.z + c.z), b.times(a.z + 2 * b.z + c.z), c.times(a.z + b.z + 2 * c.z)).times(normal.z), - ]; - } - const a = edgeWC.a, b = edgeWC.b; - const as = a.dot(r1); - const bs = b.dot(r1); - const aBase = this.pUV(as, 0); - const bBase = this.pUV(bs, 0); - const [v1, c1] = triangleShadowVolumeAndCentroid(a, b, aBase); - const [v2, c2] = triangleShadowVolumeAndCentroid(bBase, aBase, b); - return [v1 + v2, c1.plus(c2).div(24)]; - } - else if (curveWC instanceof ImplicitCurve) { - throw new Error(); - } - else { - const sliceAreaAndCentroidZX2TimesDs = (curveT) => { - const p = curveWC.at(curveT); - const s = p.dot(r1); - const t = p.dot(u1); - const area = t * c.z + s * t * r1.z + (1 / 2) * Math.pow(t, 2) * u1.z; - const ds = -curveWC.tangentAt(curveT).dot(r1); - return [ - area * ds, - ...ts3dutils.V3.add(c.times(area), r1.times(c.z * s * t + r1.z * Math.pow(s, 2) * t + (1 / 2) * s * Math.pow(t, 2) * u1.z), u1.times((1 / 2) * c.z * Math.pow(t, 2) + - (1 / 2) * r1.z * s * Math.pow(t, 2) + - (1 / 3) * Math.pow(t, 3) * u1.z)).times(ds), - ]; - }; - const [vol, cx, cy, cz] = glqArray(sliceAreaAndCentroidZX2TimesDs, edgeWC.aT, edgeWC.bT, 4); - return [ - vol * this.plane.normal1.z, - new ts3dutils.V3(cx, cy, cz).times(this.plane.normal1.z), - ]; - } - }); - return mergeVolumeAndCentroidZX2Parts(volumeAndCentroidZX2Parts); - }, - /** - * Generic implementation. - */ - [ParametricSurface.name](edges) { - const dpdu = this.dpdu(); - const dpdv = this.dpdv(); - const volume = edges.map((edgeWC) => { - const curveWC = edgeWC.curve; - if (curveWC instanceof ImplicitCurve) { - throw new Error(); - } - else { - const sliceAreaAndCentroidZX2TimesDs = (curveT) => { - // use curve.tangent not edge.tangent, reverse edges are handled by the integration boundaries - const pWC = curveWC.at(curveT), tangentWC = curveWC.tangentAt(curveT); - const uvOfPWC = this.uvP(pWC); - const slice = (t) => { - const p = this.pUV(uvOfPWC.x, t); - const normal = dpdu(uvOfPWC.x, t).cross(dpdv(uvOfPWC.x, t)); - return p.z * normal.z; - }; - const sliceIntegral0ToPWCT = ts3dutils.glqInSteps(slice, 0, uvOfPWC.y, 1); - // const dt = tangentWC.dot(scalingVector) - const dt = -ts3dutils.M4.forSys(dpdu(uvOfPWC.x, uvOfPWC.y), dpdv(uvOfPWC.x, uvOfPWC.y)) - .inversed() - .transformVector(tangentWC).x; - const sliceAreaTimesDs = sliceIntegral0ToPWCT * dt; - const slice2 = (t) => { - const p = this.pUV(uvOfPWC.x, t); - const normal = dpdu(uvOfPWC.x, t).cross(dpdv(uvOfPWC.x, t)); - return p.times(p.z * normal.z); - }; - const sliceIntegral0ToPWCT2 = glqV3(slice2, 0, uvOfPWC.y); - // const dt = tangentWC.dot(scalingVector) - const sliceCentroidZX2TimesDs = sliceIntegral0ToPWCT2.times(dt); - return [sliceAreaTimesDs, ...sliceCentroidZX2TimesDs.toArray()]; - }; - const [vol, cx, cy, cz] = glqArray(sliceAreaAndCentroidZX2TimesDs, edgeWC.aT, edgeWC.bT, 4); - return [vol, new ts3dutils.V3(cx, cy, cz)]; - } - }); - return mergeVolumeAndCentroidZX2Parts(volume); - }, - /** - * at(t) - * |\ ^ - * | \ at(t).projectedOn(dir1) \ dir1 - * | \ \ - * | \ at(t).rejectedFrom(dir1) = b - * | | - * |___| - * z = 0 - * - * - * A = ((at(t) + at(t).rejectedFrom(dir1)) / 2).z * at(t).projectedOn(dir1).lengthXY() - * scaling = tangentAt(t) DOT dir1.cross(V3.Z).unit() - */ - [ProjectedCurveSurface.name](edges) { - if (ts3dutils.V3.Z.cross(this.dir).likeO()) - return { volume: 0, centroid: ts3dutils.V3.O }; - // normalize this.dir so it always points up - const upDir1 = this.dir.toLength(Math.sign(this.dir.z) || 1); - const scalingVector = ts3dutils.V3.Z.cross(upDir1).unit(); - // the length of the base of the trapezoid is calculated by dotting with the baseVector - const baseVector = upDir1.rejectedFrom(ts3dutils.V3.Z).unit(); - // INT[edge.at; edge.bT] (at(t) DOT dir1) * (at(t) - at(t).projectedOn(dir) / 2).z - const volume = edges.map((edgeWC) => { - if (edgeWC.curve instanceof L3) { - return [0, ts3dutils.V3.O]; - } - else if (edgeWC.curve instanceof ImplicitCurve) { - return [0, ts3dutils.V3.O]; - // const { points, tangents } = edgeWC.curve - // const minT = edgeWC.minT, - // maxT = edgeWC.maxT - // let sum = 0 - // const start = Math.ceil(minT + NLA_PRECISION) - // const end = Math.floor(maxT - NLA_PRECISION) - // for (let i = start; i <= end; i++) { - // const at = points[i], - // tangent = tangents[i] - // const area = (at.z + at.rejectedFrom1(upDir1).z) / 2 * at.projectedOn(upDir1).dot(baseVector) - // const scale = tangent.dot(scalingVector) - // sum += area * scale - // } - // const f = (t: number) => { - // const at = edgeWC.curve.at(t), - // tangent = edgeWC.curve.tangentAt(t) - // const area = (at.z + at.rejectedFrom1(upDir1).z) / 2 * at.projectedOn(upDir1).dot(baseVector) - // const scale = tangent.dot(scalingVector) - // return area * scale - // } - // sum += f(minT) * (start - minT - 0.5) - // sum += f(maxT) * (maxT - end - 0.5) - // return sum * Math.sign(edgeWC.deltaT()) - } - else { - const f = (curveT) => { - // use curve.tangent not edge.tangent, reverse edges are handled by the integration boundaries - const at = edgeWC.curve.at(curveT), tangent = edgeWC.curve.tangentAt(curveT); - const b = at.rejectedFrom1(upDir1); - const area = (at.z * b.to(at).dot(baseVector)) / 2 + - (b.z * b.to(at).dot(baseVector)) / 2; - const areaCentroidA = ts3dutils.V3.add(at.xy(), b, at).times((at.z * b.to(at).dot(baseVector)) / 2 / 3); - const areaCentroidB = ts3dutils.V3.add(at.xy(), b, b.xy()).times((b.z * b.to(at).dot(baseVector)) / 2 / 3); - const scale = tangent.dot(scalingVector); - return [ - area * scale, - ...areaCentroidA.plus(areaCentroidB).times(scale).schur(ts3dutils.V(1, 1, 2)), - ]; - }; - const [vol, cx, cy, cz] = glqArray(f, edgeWC.aT, edgeWC.bT, 4); - return [vol, new ts3dutils.V3(cx, cy, cz)]; - } - }); - return mergeVolumeAndCentroidZX2Parts(volume); - }, - // volume does scale linearly, so this could be done in the local coordinate system - // however, shear matrices lead to point-to-plane distances having to be calculated along a vector other than - // the plane normal - [RotatedCurveSurface.name](edges) { - const dpdu = this.dpdu(); - const dpdv = this.dpdv(); - const totalVolume = ts3dutils.sum(edges.map((edgeWC) => { - const curveWC = edgeWC.curve; - const f = (curveT) => { - const pWC = curveWC.at(curveT), tangentWC = curveWC.tangentAt(curveT); - const uvOfPWC = this.uvP(pWC); - const pLC = this.matrixInverse.transformPoint(pWC); - const dpdvAtS0 = this instanceof RotatedCurveSurface - ? this.curve.tangentAt(uvOfPWC.y) - : ts3dutils.V(-pLC.z, 0, pLC.lengthXY()); - // const slice = (phi: number) => { - // const p = this.pUV(phi, uvOfPWC.y) - // const normal = dpdu(phi, uvOfPWC.y).cross(dpdv(phi, uvOfPWC.y)) - // return p.z * normal.z - // } - // const z = this.curve.at(uvOfPWC.y).z - // const r = this.curve.at(uvOfPWC.y).lengthXY() - // const pz = - // this.f1.z * r * cos(s) + - // this.f2.z * r * sin(s) + - // this.f3.z * z + - // this.center.z - // const dpdux = this.f1.x * r * -sin(s) + this.f2.x * r * cos(s) - // const dpduy = this.f1.y * r * -sin(s) + this.f2.y * r * cos(s) - // const dpdvx = this.f1.x * dr * cos(s) + this.f2.x * dr * sin(s) + this.f3.x * dz - // const dpdvy = this.f1.y * dr * cos(s) + this.f2.y * dr * sin(s) + this.f3.y * dz - // const normalz = dpdux * dpdvy - dpduy * dpdvx - // result = pz * normalz - const r = pLC.lengthXY(), z = pLC.z; - const dr = dpdvAtS0.x; - const dz = dpdvAtS0.z; - const a = this.matrix.X.z * r, b = this.matrix.Y.z * r, c = this.matrix.Z.z * z + this.matrix.O.z; - const t0 = (this.matrix.X.x * this.matrix.Y.y - - this.matrix.X.y * this.matrix.Y.x) * - r * - dr; - const t1 = (this.matrix.Y.x * this.matrix.X.y - - this.matrix.Y.y * this.matrix.X.x) * - r * - dr; - const t2 = (this.matrix.X.x * this.matrix.X.y - - this.matrix.X.y * this.matrix.X.x) * - r * - dr; - const t3 = (this.matrix.Y.x * this.matrix.Y.y - - this.matrix.Y.y * this.matrix.Y.x) * - r * - dr; - const t4 = (this.matrix.Y.x * this.matrix.Z.y - - this.matrix.Y.y * this.matrix.Z.x) * - r * - dz; - const t5 = (this.matrix.X.x * this.matrix.Z.y - - this.matrix.X.y * this.matrix.Z.x) * - r * - dz; - const sliceIntegral = (p) => { - return ((6 * (c * (-t0 + t1) + a * t4 - b * t5) * p + - 3 * - (3 * b * t0 - b * t1 + a * (t2 - t3) + 4 * c * t5) * - cos(p) + - 3 * - (3 * a * t1 - a * t0 - b * (t2 - t3) + 4 * c * t4) * - sin(p) + - 3 * (a * t5 - b * t4 + c * (t2 - t3)) * cos(2 * p) + - 3 * (a * t4 + b * t5 + c * (t0 + t1)) * sin(2 * p) + - (a * (t2 - t3) - b * (t0 + t1)) * cos(3 * p) + - (a * (t0 + t1) + b * (t2 - t3)) * sin(3 * p)) / - 12); - }; - const dt = ts3dutils.M4.forSys(dpdu(uvOfPWC.x, uvOfPWC.y), dpdv(uvOfPWC.x, uvOfPWC.y)) - .inversed() - .transformVector(tangentWC).y; - const sliceIntegral0ToPWCS = sliceIntegral(uvOfPWC.x); //- sliceIntegral(0) //(always 0) - const result = sliceIntegral0ToPWCS * dt; - return result; - }; - return ts3dutils.gaussLegendreQuadrature24(f, edgeWC.aT, edgeWC.bT); - })); - // calc centroid: - const centroidZX2Parts = edges.map((edgeWC) => { - const f = (curveT) => { - const curveWC = edgeWC.curve; - const pWC = curveWC.at(curveT), tangentWC = curveWC.tangentAt(curveT); - const uvOfPWC = this.uvP(pWC); - const slice = (phi) => { - const p = this.pUV(phi, uvOfPWC.y); - const normal = dpdu(phi, uvOfPWC.y).cross(dpdv(phi, uvOfPWC.y)); - return p.times(p.z * normal.z); - }; - const sliceIntegral0ToPWCS = glqV3(slice, 0, uvOfPWC.x); - const dt = ts3dutils.M4.forSys(dpdu(uvOfPWC.x, uvOfPWC.y), dpdv(uvOfPWC.x, uvOfPWC.y)) - .inversed() - .transformVector(tangentWC).y; - const result = sliceIntegral0ToPWCS.times(dt); - return result; - }; - return glqV3(f, edgeWC.aT, edgeWC.bT); - }); - const centroid = ts3dutils.V3.add(...centroidZX2Parts) - .schur(new ts3dutils.V3(1, 1, 0.5)) - .div(totalVolume); - return { volume: totalVolume, centroid: centroid }; - }, -}; -ZDirVolumeVisitor[EllipsoidSurface.name] = - ZDirVolumeVisitor[RotatedCurveSurface.name]; -function glqV3(f, startT, endT) { - return ts3dutils.gaussLegendre24Xs - .reduce((val, currVal, index) => { - const x = startT + ((currVal + 1) / 2) * (endT - startT); - return val.plus(f(x).times(ts3dutils.gaussLegendre24Weights[index])); - }, ts3dutils.V3.O) - .times((endT - startT) / 2); -} -function glqArray(f, startT, endT, numEls = 3) { - const result = new Array(numEls).fill(0); - for (let i = 0; i < 24; i++) { - const x = startT + ((ts3dutils.gaussLegendre24Xs[i] + 1) / 2) * (endT - startT); - const fx = f(x); - for (let j = 0; j < numEls; j++) { - result[j] += fx[j] * ts3dutils.gaussLegendre24Weights[i]; - } - } - for (let j = 0; j < numEls; j++) { - result[j] *= (endT - startT) / 2; - } - return result; -} -function mergeVolumeAndCentroidZX2Parts(volumeAndCentroidZX2Parts) { - const volume = volumeAndCentroidZX2Parts.reduce((result, [volume]) => result + volume, 0); - const weightedCentroid = ts3dutils.V3.add(...volumeAndCentroidZX2Parts.map(([, centroidZX2]) => centroidZX2)).schur(new ts3dutils.V3(1, 1, 0.5)); - return { volume, centroid: weightedCentroid.div(volume) }; -} - -const CalculateAreaVisitor = { - [ConicSurface.name](edges) { - const dpdu = this.dpdu(); - const dpdv = this.dpdv(); - // calculation cannot be done in local coordinate system, as the area doesnt scale proportionally - const totalArea = ts3dutils.sum(edges.map((edge) => { - if (edge.curve instanceof EllipseCurve || - edge.curve instanceof HyperbolaCurve || - edge.curve instanceof ParabolaCurve) { - const f = (t) => { - const at = edge.curve.at(t), tangentWC = edge.tangentAt(t); - const uvOfPWC = this.uvP(at); - // INTEGRATE [0; atUV.y] - // dpdu(atUV.x, t) X dpdv(atUV.x, t) - // dt - // dpdv is constant with respect to t - // => dpdv(atUV.x, 0) X (INTEGRATE [0; atUV.y] dpdu(atUV.x, t) dt) - // dpdu(u, v) === v * dpdu(u, 1) - // => dpdv(atUV.x, 0) X (1/2 t² dpdu(atUV.x, 1))[0; atUV.y] - // => dpdv(atUV.x, 0) X dpdu(atUV.x, atUV.y² / 2) - const du = -ts3dutils.M4.forSys(dpdu(uvOfPWC.x, uvOfPWC.y), dpdv(uvOfPWC.x)) - .inversed() - .transformVector(tangentWC).x; - return (dpdu(uvOfPWC.x, Math.pow(uvOfPWC.y, 2) / 2) - .cross(dpdv(uvOfPWC.x)) - .length() * du); - }; - return ts3dutils.glqInSteps(f, edge.aT, edge.bT, 1); - } - else if (edge.curve instanceof L3) { - return 0; - } - else { - throw new Error(); - } - })); - return totalArea * this.normalDir; - }, - [PlaneSurface.name](edges) { - let totalArea = 0; - const r1 = this.right, u1 = this.up; - for (const edge of edges) { - let edgeArea; - const curve = edge.curve; - if (curve instanceof L3) { - edgeArea = - ((edge.a.dot(u1) + edge.b.dot(u1)) / 2) * edge.b.to(edge.a).dot(r1); - } - else if (curve instanceof EllipseCurve) { - // INTEGRATE[aT; bT] (curve.at(t) * u1) * (tangent(t) * r1) dt - // INTEGRATE[aT; bT] (u1 f1 cos t + u1 f2 sin t + u1 c) * (r1 f1 (-sin t) + r1 f2 cos t) dt - const { f1, f2, center } = curve; - const a = u1.dot(f1), b = u1.dot(f2), c = u1.dot(center), d = r1.dot(f1), e = r1.dot(f2); - function fArea(t) { - return (0.25 * - (2 * (-b * d + a * e) * t + - 4 * c * d * cos(t) + - 4 * c * e * sin(t) + - (a * d - b * e) * cos(2 * t) + - (b * d + a * e) * sin(2 * t))); - } - edgeArea = -(fArea(edge.bT) - fArea(edge.aT)); - } - else if (curve instanceof ImplicitCurve) { - throw new Error("implement for implicitCurve"); - } - else { - const dir1 = u1; - ts3dutils.assertf(() => dir1.hasLength(1)); - // INT[aT; bT] at(t) * dir1 * tangentAt(t).rejectedFrom(dir1) dt - const f = (curveT) => { - const at = curve.at(curveT); - const tangent = curve.tangentAt(curveT); - const ds = r1.dot(tangent); - const t = u1.dot(at); - return ds * t; - }; - edgeArea = ts3dutils.glqInSteps(f, edge.aT, edge.bT, 3); - } - totalArea += edgeArea; - } - ts3dutils.assert(isFinite(totalArea)); - return totalArea; - }, - [RotatedCurveSurface.name](edges, canApproximate = true) { - const f1 = this.matrix.X, f2 = this.matrix.Y, f3 = this.matrix.Z; - const likeVerticalSpheroid = ts3dutils.eq(f1.length(), f2.length()) && - f1.isPerpendicularTo(f2) && - f2.isPerpendicularTo(f3) && - f3.isPerpendicularTo(f1); - const areaParts = edges.map((edgeWC, ei) => { - console.log("edge", ei, edgeWC.sce); - const curveWC = edgeWC.curve; - if (edgeWC.curve instanceof ImplicitCurve) { - throw new Error(); - } - else { - if (likeVerticalSpheroid) { - const f = (curveT) => { - const pWC = curveWC.at(curveT), tangent = curveWC.tangentAt(curveT); - const pLC = this.matrixInverse.transformPoint(pWC); - const { x: angleXY, y: t } = this.uvP(pWC); - const arcRadius = this.matrix.transformVector(pLC.xy()).length(); - const arcLength = angleXY * arcRadius; - const dpdv = this.dpdv()(angleXY, t).unit(); - const scaling = dpdv.dot(tangent); - return arcLength * scaling; - }; - return ts3dutils.glqInSteps(f, edgeWC.aT, edgeWC.bT, 1); - } - else { - const dpdu = this.dpdu(), dpdv = this.dpdv(); - const f2 = (curveT) => { - const pWC = curveWC.at(curveT), tangentWC = curveWC.tangentAt(curveT); - const uvPWC = this.uvP(pWC); - const slice = (phi) => { - //return this.dpdu()(phi, st.y).length() * this.dpdv()(phi, st.y).length() - return dpdu(phi, uvPWC.y).cross(dpdv(phi, uvPWC.y)).length(); - }; - // we need to do a coordinate transform from curveT to dt, as that is what we are integrating - const dt = ts3dutils.M4.forSys(dpdu(uvPWC.x, uvPWC.y), dpdv(uvPWC.x, uvPWC.y)) - .inversed() - .transformVector(tangentWC).y; - return ts3dutils.glqInSteps(slice, 0, uvPWC.x, 1) * dt; - }; - return ts3dutils.glqInSteps(f2, edgeWC.aT, edgeWC.bT, 1); - } - } - }); - return ts3dutils.sum(areaParts); - }, - [ProjectedCurveSurface.name](edges) { - // calculation cannot be done in local coordinate system, as the area doesn't scale proportionally - const thisDir1 = this.dir.unit(); - const totalArea = ts3dutils.sum(edges.map((edge) => { - if (edge.curve instanceof L3) { - return 0; - } - else if (edge.curve instanceof ImplicitCurve) { - const { points, tangents } = edge.curve; - const minT = edge.minT, maxT = edge.maxT; - let sum = 0; - const start = ceil(minT + ts3dutils.NLA_PRECISION); - const end = floor(maxT - ts3dutils.NLA_PRECISION); - for (let i = start; i <= end; i++) { - const at = points[i], tangent = tangents[i]; //.toLength(edge.curve.stepSize) - const scaling = this.normalP(at).cross(thisDir1).unit().dot(tangent); - sum += at.dot(thisDir1) * scaling; - } - const f = (t) => { - const at = edge.curve.at(t), tangent = edge.curve.tangentAt(t); - const scaling = this.normalP(at).cross(thisDir1).unit().dot(tangent); - return at.dot(thisDir1) * scaling; - }; - sum += f(minT) * (start - minT - 0.5); - sum += f(maxT) * (maxT - end - 0.5); - return sum * sign(edge.deltaT()); - } - else { - const f = (t) => { - const at = edge.curve.at(t); - const tangent = edge.tangentAt(t); - const scaling = tangent.rejected1Length(thisDir1); - return at.dot(thisDir1) * scaling; - }; - const val = ts3dutils.glqInSteps(f, edge.aT, edge.bT, 1); - const sign = Math.sign(this.normalP(edge.a) - .cross(this.dir) - .dot(edge.curve.tangentAt(edge.aT))); - ts3dutils.assert(0 !== sign); - return val * sign; - } - })); - console.log("totalArea", totalArea); - return totalArea; - }, -}; -CalculateAreaVisitor[EllipsoidSurface.name] = - CalculateAreaVisitor[RotatedCurveSurface.name]; - -/** - * Create a surface by projecting a curve in a direction. - * - * @param curve The curve to project. - * @param offset The direction and distance to project curve. - * @param flipped Whether the surface's default orientation (normal = curve tangent cross offset) should be flipped. - */ -function projectCurve(curve, offset, flipped) { - if (curve instanceof _.L3) { - const surfaceNormal = offset.cross(curve.dir1).toLength(flipped ? -1 : 1); - return new _.PlaneSurface(_.P3.normalOnAnchor(surfaceNormal, curve.anchor)); - } - if (curve instanceof _.EllipseCurve) { - const curveDir = flipped ? offset : offset.negated(); - return new _.CylinderSurface(curve, curveDir.unit(), undefined, undefined); - } - if (curve instanceof _.BezierCurve || curve instanceof _.XiEtaCurve) { - const curveDir = offset.times(flipped ? 1 : -1); - return new _.ProjectedCurveSurface(curve, curveDir, undefined, undefined, flipped ? 0 : -1, flipped ? 1 : 0); - } - throw new Error(); -} -/** - * Create a surface by projecting a curve onto a point. - */ -function projectPointCurve(curve, tMin = curve.tMin, tMax = curve.tMax, p, flipped) { - if (curve instanceof _.L3) { - const up = curve.anchor.to(p).rejectedFrom(curve.dir1); - return _.PlaneSurface.forAnchorAndPlaneVectors(curve.anchor, curve.dir1, up.unit(), tMin, tMax, 0, up.length()); - } - else if (curve instanceof _.EllipseCurve) { - // flip f2 by default - const factor = -1 * (flipped ? -1 : 1); - return new _.ConicSurface(p, curve.f1.times(factor), curve.f2, p.to(curve.center), tMin, tMax, 0, 1); - } - else { - throw new Error("projectPointCurve not implemented for " + curve.constructor.name); - } -} -/** - * Create a surface by rotating a curve in the XZ-plane, with X > 0, around the Z-axis according to the right-hand rule. - * @param curve The curve to rotate. - * @param tMin The minimum value for t for which the surface should be defined. - * @param tMax The maximum value for t for which the surface should be defined. - * @param angle How much the curve should be rotated. sMin/sMax will be be 0/angle. - * @param flipped Whether the surface's default orientation (normal = curve tangent cross rotation tangent) should be - * flipped. - */ -function rotateCurve(curve, tMin = curve.tMin, tMax = curve.tMax, angle, flipped) { - ts3dutils.assertf(() => new _.PlaneSurface(_.P3.ZX).containsCurve(curve)); - if (curve instanceof _.L3) { - if (curve.dir1.isParallelTo(ts3dutils.V3.Z)) { - if (ts3dutils.eq0(curve.anchor.x)) { - return undefined; - //throw new Error('Cannot rotate curve colinear to Z axis.') - } - const baseEllipse = new _.EllipseCurve(ts3dutils.V3.O, curve.anchor.xy(), curve.anchor.xy().getPerpendicular(), 0, angle); - // if curve.dir1 is going up (+Z), it the cylinder surface should face inwards - const factor = (curve.dir1.z > 0 ? -1 : 1) * (flipped ? -1 : 1); - const [zMin, zMax] = [ - curve.at(tMin).z * factor, - curve.at(tMax).z * factor, - ].sort(ts3dutils.MINUS); - return new _.CylinderSurface(baseEllipse, ts3dutils.V3.Z.times(factor), 0, angle, zMin, zMax); - } - if (curve.at(tMin).xy().dot(curve.dir1) * - curve.at(tMax).xy().dot(curve.dir1) < - 0) { - throw new Error("line cannot cross the Z axis in the [tMin, tMax] interval, as conic surfaces cannot have an hourglass shape."); - } - if (curve.dir1.isPerpendicularTo(ts3dutils.V3.Z)) { - // if line.dir1 is pointing aways from V3.Z, then the surface should face up - const factor = (curve.at(ts3dutils.lerp(tMin, tMax, 0.5)).dot(curve.dir1) > 0 ? 1 : -1) * - (flipped ? -1 : 1); - return new _.PlaneSurface(new _.P3(ts3dutils.V3.Z.times(factor), curve.anchor.z * factor)); - } - else { - // apex is intersection of segment with Z-axis - const a = curve.at(tMin), b = curve.at(tMax); - const apexZ = a.z - (a.x * (b.z - a.z)) / (b.x - a.x); - const apex = new ts3dutils.V3(0, 0, apexZ); - const factor = -(a.x > b.x ? -1 : 1) * (flipped ? -1 : 1); - const s = new _.ConicSurface(apex, new ts3dutils.V3(curve.dir1.lengthXY(), 0, 0), new ts3dutils.V3(0, curve.dir1.lengthXY(), 0), new ts3dutils.V3(0, 0, (a.x > b.x ? -1 : 1) * curve.dir1.z), 0, angle, 0, 1); - return factor > 0 ? s : s.flipped(); - } - } - if (curve instanceof _.EllipseCurve) { - const a = curve.at(tMin), b = curve.at(tMax); - const ell = curve.rightAngled(); - const f1Perp = ell.f1.isPerpendicularTo(ts3dutils.V3.Z), f2Perp = ell.f2.isPerpendicularTo(ts3dutils.V3.Z); - if (_.L3.Z.containsPoint(ell.center) && (f1Perp || f2Perp)) { - flipped = flipped == a.z > b.z; - let width = ell.f1.length(), height = ell.f2.length(); - if (ell.f1.isParallelTo(ts3dutils.V3.Z)) { - [width, height] = [height, width]; - } - return _.EllipsoidSurface.forABC(width, (!flipped ? 1 : -1) * width, height, ell.center); - } - else { - const s = new _.RotatedCurveSurface(curve, ts3dutils.M4.IDENTITY, tMin, tMax); - return s; - } - } - throw new Error(); -} -(function (B2T) { - /** - * Create a [BRep] of an axis-aligned box width starting at the origin and extending into +XYZ space. - * @param width x-direction size. - * @param height y-direction size. - * @param depth z-direction size. - * @param name - */ - function box(width = 1, height = 1, depth = 1, name = "box" + _.getGlobalId()) { - ts3dutils.assertNumbers(width, height, depth); - ts3dutils.assert("string" === typeof name); - const baseVertices = [ - new ts3dutils.V3(0, 0, 0), - new ts3dutils.V3(0, height, 0), - new ts3dutils.V3(width, height, 0), - new ts3dutils.V3(width, 0, 0), - ]; - const generator = ts3dutils.callsce("B2T.box", width, height, depth, name); - return B2T.extrudeVertices(baseVertices, _.P3.XY.flipped(), new ts3dutils.V3(0, 0, depth), name, generator); - } - B2T.box = box; - function puckman(radius, rads, height, name = "puckman" + _.getGlobalId()) { - ts3dutils.assertf(() => ts3dutils.lt(0, radius)); - ts3dutils.assertf(() => ts3dutils.lt(0, rads) && ts3dutils.le(rads, ts3dutils.TAU)); - ts3dutils.assertf(() => ts3dutils.lt(0, height)); - const edges = _.StraightEdge.chain([ - ts3dutils.V3.O, - new ts3dutils.V3(radius, 0, 0), - new ts3dutils.V3(radius, 0, height), - new ts3dutils.V3(0, 0, height), - ], true); - return B2T.rotateEdges(edges, rads, name); - } - B2T.puckman = puckman; - function registerVertexName(map, name, p) { - // TODO - if (!Array.from(map.keys()).some((p2) => p2.like(p))) { - map.set(p, name); - } - } - B2T.registerVertexName = registerVertexName; - /** - * Create a [BRep] by projecting a number of edges in a direction. - * @param baseFaceEdges - * @param baseFacePlane - * @param offset - * @param name - * @param gen - * @param infoFactory - */ - function extrudeEdges(baseFaceEdges, baseFacePlane = _.P3.XY, offset = ts3dutils.V3.Z, name = "extrude" + _.getGlobalId(), gen, infoFactory) { - baseFaceEdges = fixEdges(baseFaceEdges); - //Array.from(combinations(baseFaceEdges.length)).forEach(({i, j}) => { - // assertf(() => !Edge.edgesIntersect(baseFaceEdges[i], baseFaceEdges[j]), baseFaceEdges[i].sce + - // baseFaceEdges[j].sce) }) - ts3dutils.assertf(() => _.Edge.isLoop(baseFaceEdges)); - // TODO checks.. - //if (offset.dot(baseFacePlane.normal1) > 0) { - // baseFacePlane = baseFacePlane.flipped() - //} - const vertexNames = new Map(); - const basePlaneSurface = new _.PlaneSurface(baseFacePlane); - //assert(basePlaneSurface.edgeLoopCCW(baseFaceEdges), 'edges not CCW on baseFacePlane') - const translationMatrix = ts3dutils.M4.translate(offset); - const topEdges = baseFaceEdges.map((edge) => edge.transform(translationMatrix, "top")); - const edgeCount = baseFaceEdges.length; - const bottomInfo = infoFactory && infoFactory.extrudeBottom(basePlaneSurface, baseFaceEdges); - const bottomFace = new _.PlaneFace(basePlaneSurface, baseFaceEdges, [], name + "Bottom", bottomInfo); - const topFaceEdges = topEdges.map((edge) => edge.flipped()).reverse(); - const topSurface = new _.PlaneSurface(baseFacePlane.flipped().translated(offset)); - const topInfo = infoFactory && infoFactory.extrudeBottom(topSurface, topFaceEdges); - const topFace = new _.PlaneFace(topSurface, topFaceEdges, [], name + "Top", topInfo); - baseFaceEdges.forEach((edge) => B2T.registerVertexName(vertexNames, edge.name + "A", edge.a)); - topFaceEdges.forEach((edge) => B2T.registerVertexName(vertexNames, edge.name + "A", edge.a)); - const ribs = ts3dutils.arrayFromFunction(edgeCount, (i) => _.StraightEdge.throughPoints(baseFaceEdges[i].a, topEdges[i].a, name + "Rib" + i)); - const faces = baseFaceEdges.map((edge, i) => { - const faceName = name + "Wall" + i; - const j = (i + 1) % edgeCount; - const faceEdges = [ - baseFaceEdges[i].flipped(), - ribs[i], - topEdges[i], - ribs[j].flipped(), - ]; - const surface = projectCurve(edge.curve, offset, edge.reversed); - const info = infoFactory && infoFactory.extrudeWall(i, surface, faceEdges); - return _.Face.create(surface, faceEdges, undefined, faceName, info); - }); - faces.push(bottomFace, topFace); - gen = - gen || - ts3dutils.callsce("B2T.extrudeEdges", baseFaceEdges, baseFacePlane, offset, name); - return new _.BRep(faces, baseFacePlane.normal1.dot(offset) > 0, gen, vertexNames); - } - B2T.extrudeEdges = extrudeEdges; - function cylinder(radius = 1, height = 1, rads = ts3dutils.TAU, name = "cylinder" + _.getGlobalId()) { - const vertices = [ - new ts3dutils.V3(0, 0, 0), - new ts3dutils.V3(radius, 0, 0), - new ts3dutils.V3(radius, 0, height), - new ts3dutils.V3(0, 0, height), - ]; - return rotateEdges(_.StraightEdge.chain(vertices, true), rads, name); - } - B2T.cylinder = cylinder; - function cone(radius = 1, height = 1, rads = ts3dutils.TAU, name = "cone" + _.getGlobalId()) { - const vertices = [ - new ts3dutils.V3(0, 0, 0), - new ts3dutils.V3(radius, 0, height), - new ts3dutils.V3(0, 0, height), - ]; - return rotateEdges(_.StraightEdge.chain(vertices, true), rads, name); - } - B2T.cone = cone; - function sphere(radius = 1, name = "sphere" + _.getGlobalId(), rot = ts3dutils.TAU) { - const ee = new _.PCurveEdge(new _.EllipseCurve(ts3dutils.V3.O, new ts3dutils.V3(0, 0, -radius), new ts3dutils.V3(radius, 0, 0)), new ts3dutils.V3(0, 0, -radius), new ts3dutils.V3(0, 0, radius), 0, PI, undefined, new ts3dutils.V3(radius, 0, 0), new ts3dutils.V3(-radius, 0, 0)); - const generator = ts3dutils.callsce("B2T.sphere", radius, name, rot); - return rotateEdges([_.StraightEdge.throughPoints(ee.b, ee.a), ee], rot, name, generator); - } - B2T.sphere = sphere; - /** - * Create a [[BRep]] of a menger sponge. - * @param res 0: just a cube, 1: every cube face has one hole, 2: 9 holes, etc - * @param name - */ - function menger(res = 2, name = "menger" + _.getGlobalId()) { - let result = B2T.box(1, 1, 1); - if (0 == res) - return result; - const punch = B2T.box(1 / 3, 1 / 3, 2) - .translate(1 / 3, 1 / 3, -1 / 2) - .flipped(); - function recurse(steps, m4) { - result = result.and(punch.transform(m4)); - if (steps > 1) { - const scaled = m4.times(ts3dutils.M4.scale(1 / 3, 1 / 3, 1)); - for (let i = 0; i < 9; i++) { - if (4 == i) - continue; - recurse(steps - 1, scaled.times(ts3dutils.M4.translate(i % 3, (i / 3) | 0, 0))); - } - } - } - recurse(res, ts3dutils.M4.IDENTITY); - recurse(res, ts3dutils.M4.YZX); - recurse(res, ts3dutils.M4.ZXY); - return result; - } - B2T.menger = menger; - function menger2(res = 2, name = "menger" + _.getGlobalId()) { - if (0 == res) - return B2T.box(1, 1, 1); - const punch = B2T.box(1 / 3, 1 / 3, 2) - .translate(1 / 3, 1 / 3, -1 / 2) - .flipped(); - const stencilFaces = []; - function recurse(steps, m4) { - stencilFaces.push(...punch.transform(m4).faces); - if (steps > 1) { - const scaled = m4.times(ts3dutils.M4.scale(1 / 3, 1 / 3, 1)); - for (let i = 0; i < 9; i++) { - if (4 == i) - continue; - recurse(steps - 1, scaled.times(ts3dutils.M4.translate(i % 3, (i / 3) | 0, 0))); - } - } - } - recurse(res, ts3dutils.M4.IDENTITY); - const stencil = new _.BRep(stencilFaces, true); - return B2T.box(1, 1, 1, name) - .and(stencil) - .and(stencil.transform(ts3dutils.M4.YZX)) - .and(stencil.transform(ts3dutils.M4.ZXY)); - } - B2T.menger2 = menger2; - /** - * Create a [BRep] of a torus. - * @param rSmall The radius to the surface of the torus. - * @param rLarge The radius from the origin to the inside of the torus. - * @param rads - * @param name - */ - function torus(rSmall, rLarge, rads = ts3dutils.TAU, name = "torus" + _.getGlobalId()) { - ts3dutils.assertNumbers(rSmall, rLarge, rads); - ts3dutils.assertf(() => rLarge > rSmall); - const curves = [ - _.EllipseCurve.semicircle(rSmall, new ts3dutils.V3(rLarge, 0, 0)), - _.EllipseCurve.semicircle(-rSmall, new ts3dutils.V3(rLarge, 0, 0)), - ]; - const baseEdges = curves.map((c) => _.PCurveEdge.forCurveAndTs(c, 0, Math.PI).rotateX(PI / 2)); - return B2T.rotateEdges(baseEdges, rads, name); - } - B2T.torus = torus; - /** - * Create a [BRep] by smoothly rotating edges around Z. - * baseLoop should be CCW on XZ plane for a bounded BRep - */ - function rotateEdges(baseLoop, totalRads, name = "rotateEdges" + _.getGlobalId(), generator, infoFactory) { - ts3dutils.assert(baseLoop.every((e) => new _.PlaneSurface(_.P3.ZX).containsCurve(e.curve))); - ts3dutils.assert(!ts3dutils.eq(PI, totalRads) || PI == totalRads); // URHGJ - ts3dutils.assertf(() => ts3dutils.lt(0, totalRads) && ts3dutils.le(totalRads, ts3dutils.TAU)); - totalRads = ts3dutils.snap(totalRads, ts3dutils.TAU); - ts3dutils.assertf(() => _.Edge.isLoop(baseLoop)); - const basePlane = new _.PlaneSurface(_.P3.ZX.flipped()).edgeLoopCCW(baseLoop) - ? new _.PlaneSurface(_.P3.ZX.flipped()) - : new _.PlaneSurface(_.P3.ZX); - // const rotationSteps = ceil((totalRads - NLA_PRECISION) / PI) - // const angles = rotationSteps == 1 ? [-PI, -PI + totalRads] : [-PI, 0, totalRads - PI] - const open = !ts3dutils.eq(totalRads, 2 * PI); - const baseRibCurves = baseLoop.map((edge) => { - const a = edge.a, radius = a.lengthXY(); - if (!ts3dutils.eq0(radius)) { - return new _.EllipseCurve(ts3dutils.V(0, 0, a.z), ts3dutils.V(radius, 0, 0), ts3dutils.V(0, radius, 0)); - } - return undefined; - }); - const baseSurfaces = baseLoop.map((edge) => { - const s = rotateCurve(edge.curve, edge.minT, edge.maxT, PI, edge.deltaT() > 0); - const t = ts3dutils.lerp(edge.aT, edge.bT, 0.5); - s && - ts3dutils.assert(edge - .tangentAt(t) - .cross(ts3dutils.V3.Y) - .dot(s.normalP(edge.curve.at(t))) < 0); - return s; - }); - let stepStartEdges = baseLoop, stepEndEdges; - const faces = []; - for (let rot = 0; rot < totalRads; rot += PI) { - const aT = 0, bT = min(totalRads - rot, PI); - const rotation = ts3dutils.M4.rotateZ(rot + bT); - stepEndEdges = - rot + bT == ts3dutils.TAU - ? baseLoop - : baseLoop.map((edge) => edge.transform(rotation)); - const ribs = ts3dutils.arrayFromFunction(baseLoop.length, (i) => { - const a = stepStartEdges[i].a, radius = a.lengthXY(); - const b = stepEndEdges[i].a; - if (!ts3dutils.eq0(radius)) { - const curve = 0 === rot ? baseRibCurves[i] : baseRibCurves[i].rotateZ(rot); - return new _.PCurveEdge(curve, a, b, aT, bT, undefined, curve.tangentAt(aT), curve.tangentAt(bT), name + "rib" + i); - } - return undefined; - }); - for (let edgeIndex = 0; edgeIndex < baseLoop.length; edgeIndex++) { - if (baseSurfaces[edgeIndex]) { - const edge = stepStartEdges[edgeIndex]; - const ipp = (edgeIndex + 1) % baseLoop.length; - const faceEdges = [ - stepStartEdges[edgeIndex].flipped(), - !ts3dutils.eq0(edge.a.x) && ribs[edgeIndex], - stepEndEdges[edgeIndex], - !ts3dutils.eq0(edge.b.x) && ribs[ipp].flipped(), - ].filter((x) => x); - const surface = 0 === rot - ? baseSurfaces[edgeIndex] - : baseSurfaces[edgeIndex].rotateZ(rot); - const info = infoFactory && - infoFactory.extrudeWall(edgeIndex, surface, faceEdges, undefined); - faces.push(_.Face.create(surface, faceEdges, undefined, name + "Wall" + edgeIndex, info)); - } - } - stepStartEdges = stepEndEdges; - } - if (open) { - const endFaceEdges = _.Edge.reversePath(stepEndEdges); - const infoStart = infoFactory && infoFactory.rotationStart(basePlane, baseLoop, undefined); - const infoEnd = infoFactory && - infoFactory.rotationEnd(basePlane.flipped().rotateZ(totalRads), endFaceEdges, undefined); - faces.push(new _.PlaneFace(basePlane, baseLoop, undefined, name + "start", infoStart), new _.PlaneFace(basePlane.flipped().rotateZ(totalRads), endFaceEdges, undefined, name + "end", infoEnd)); - } - const infiniteVolume = new _.PlaneSurface(_.P3.ZX).edgeLoopCCW(baseLoop); - return new _.BRep(faces, infiniteVolume, generator); - } - B2T.rotateEdges = rotateEdges; - /** - * loop should be CCW on XZ plane for a bounded BRep - */ - //export function rotateEdgesUnsplit(loop: Edge[], rads: raddd, name: string): BRep { - // assert(Edge.isLoop(loop)) - // const rotationMatrix = M4.rotateZ(rads) - // const open = !eq(rads, 2 * PI) - // const endEdges = open ? loop.map(edge => edge.transform(rotationMatrix)) : loop - // const edgeCount = loop.length - // const ribs = arrayFromFunction(edgeCount, i => { - // const a = loop[i].a, radius = a.lengthXY() - // const b = endEdges[i].a - // if (!eq0(radius)) { - // const curve = new EllipseCurve(V(0, 0, a.z), V(-radius, 0, 0), V(0, -radius, 0)) - // const aT = -PI, bT = -PI + rads - // return new PCurveEdge(curve, a, b, aT, bT, undefined, curve.tangentAt(aT), curve.tangentAt(bT), name - // + 'rib' + i) } }) const faces = loop.map((edge, i) => { const ipp = (i + 1) % edgeCount console.log('ljl', i, - // ipp, ribs) const faceEdges = [ edge.flipped(), !eq0(edge.a.x) && ribs[i], endEdges[i], !eq0(edge.b.x) && - // ribs[ipp].flipped()].filter(x => x) if (edge instanceof StraightEdge) { const line = edge.curve let surface if - // (line.dir1.isParallelTo(V3.Z)) { if (eq0(edge.a.x)) { return } let flipped = edge.a.z > edge.b.z surface = new - // CylinderSurface(ribs[i].curve, !flipped ? V3.Z : V3.Z.negated()) } else if - // (line.dir1.isPerpendicularTo(V3.Z)) { let flipped = edge.a.x > edge.b.x let surface = new PlaneSurface(new - // P3(V3.Z, edge.a.z)) if (!flipped) surface = surface.flipped() if (!open) { const hole = flipped ? !eq0(edge.b.x) - // && ribs[ipp].flipped() : !eq0(edge.a.x) && ribs[i] return new PlaneFace(surface, [flipped ? ribs[i] : - // ribs[ipp].flipped()], hole && [[hole]]) } return new PlaneFace(surface, faceEdges) } else { // apex is - // intersection of segment with Z-axis let a = edge.a, b = edge.b let apexZ = a.z - a.x * (b.z - a.z) / (b.x - a.x) - // let apex = new V3(0, 0, apexZ) let flipped = edge.a.z > edge.b.z surface = - // ConicSurface.atApexThroughEllipse(apex, ribs[a.x > b.x ? i : ipp].curve as EllipseCurve, !flipped ? 1 : -1) - // } return Face.create(surface, faceEdges) } if (edge.curve instanceof EllipseCurve) { let flipped = undefined - // let ell = edge.curve.rightAngled() let f1Perp = ell.f1.isPerpendicularTo(V3.Z), f2Perp = - // ell.f2.isPerpendicularTo(V3.Z) if (L3.Z.containsPoint(ell.center) && (f1Perp || f2Perp)) { let f3length = f1Perp - // ? ell.f1.length() : ell.f2.length() if (flipped) { f3length *= -1 } let surface = new - // EllipsoidSurface(ell.center, ell.f1, ell.f2, ell.f1.cross(ell.f2).toLength(f3length)) return new - // RotationFace(surface, faceEdges) } } else { assert(false, edge) } }).filter(x => x) if (open) { const - // endFaceEdges = endEdges.map(edge => edge.flipped()).reverse() faces.push( new PlaneFace(new - // PlaneSurface(P3.ZX.flipped()), loop), new PlaneFace(new PlaneSurface(P3.ZX.rotateZ(rads)), endFaceEdges)) } - // return new BRep(faces, undefined) } - function quaffle() { - const baseK = B2T.sphere(1).translate(0, 1.7).flipped(); - //const baseK = B2T.box().scale(0.2).translate(0, 0.95).flipped() - // const vs = B2T.DODECAHEDRON_VERTICES.concat( - // B2T.DODECAHEDRON_FACE_VERTICES.map(fis => fis - // .map(vi => B2T.DODECAHEDRON_VERTICES[vi]) - // .reduce((a,b) => a.plus(b), V3.O) - // .unit())) - const ss = new _.BRep(B2T.TETRAHEDRON_VERTICES.flatMap((v) => baseK.rotateAB(ts3dutils.V3.Y, v).faces), false); - //return ss - return B2T.sphere().and(ss); - } - B2T.quaffle = quaffle; - function extrudeFace(face, dir) { - return new _.BRep(extrudeEdges(face.contour, face.surface.plane, dir) - .faces.slice(0, -2) - .concat(face, face.translate(dir.x, dir.y, dir.z).flipped(), face.holes.flatMap((hole) => extrudeEdges(hole, face.surface.plane.flipped(), dir).faces.slice(0, -2))), false); - } - B2T.extrudeFace = extrudeFace; - function loadFonts() { - return loadFont("fonts/FiraSansMedium.woff").then((font) => (B2T.defaultFont = font)); - } - B2T.loadFonts = loadFonts; - const loadedFonts = new Map(); - function loadFont(fontPath) { - return new Promise(function (resolve, reject) { - const font = loadedFonts.get(fontPath); - if (font) { - resolve(font); - } - else { - opentype.load(fontPath, function (err, f) { - if (err) { - reject(err); - } - else { - loadedFonts.set(fontPath, f); - resolve(f); - } - }); - } - }); - } - B2T.loadFont = loadFont; - function loadFontsAsync(callback) { - if (B2T.defaultFont) { - callback(); - } - else { - opentype.load("fonts/FiraSansMedium.woff", function (err, font) { - if (err) { - throw new Error("Could not load font: " + err); - } - else { - B2T.defaultFont = font; - callback(); - } - }); - } - } - B2T.loadFontsAsync = loadFontsAsync; - /** - * Create the [BRep] of a string rendered in a font. - * @param text - * @param size - * @param depth - * @param font An opentype.js font. - */ - function text(text, size, depth = 1, font = B2T.defaultFont) { - const path = font.getPath(text, 0, 0, size); - const subpaths = []; - path.commands.forEach((c) => { - if (c.type == "M") { - subpaths.push([]); - } - ts3dutils.getLast(subpaths).push(c); - }); - const loops = subpaths.map((sp) => { - const path = new opentype.Path(); - path.commands = sp; - const loop = _.Edge.reversePath(_.edgePathFromSVG(path.toPathData(13))).map((e) => e.mirrorY()); - ts3dutils.assert(_.Edge.isLoop(loop)); - return loop; - }); - const faces = _.Face.assembleFacesFromLoops(loops, new _.PlaneSurface(_.P3.XY), _.PlaneFace); - const generator = ts3dutils.callsce("B2T.text", text, size, depth); - return _.BRep.join(faces.map((face) => B2T.extrudeFace(face, ts3dutils.V(0, 0, -depth))), generator); - } - B2T.text = text; - function minorityReport() { - const a = B2T.sphere(); - const b = B2T.text("LEO CROW", 64, 128) - .scale(0.1 / 32) - .translate(-0.5, -0.05, 1.2) - .flipped(); - const c = B2T.sphere(0.98); - return a.and(b).plus(c); - } - B2T.minorityReport = minorityReport; - function whatever() { - const iso = icosahedron(); - const numbersBRep = _.BRep.join(iso.faces.map((face, i) => { - const numberBRep = text("" + (i + 1), 0.4, -2); - const centroid = face.contour - .map((edge) => edge.a) - .reduce((a, b) => a.plus(b), ts3dutils.V3.O) - .div(3); - const sys = ts3dutils.M4.forSys(face.contour[0].aDir, centroid.cross(face.contour[0].aDir), centroid.unit(), centroid); - return numberBRep.transform(sys.times(ts3dutils.M4.translate(-numberBRep.getAABB().size().x / 2, -0.1, -0.04))); - })); - const s = sphere(0.9); - //return iso.and(numbersBRep) - return iso.and(s).and(numbersBRep); - //return numbersBRep - } - B2T.whatever = whatever; - function whatever3() { - const t = B2T.torus(1, 2); - return B2T.box(5, 5, 2).translate(-2.5, -2.5).minus(t); - } - B2T.whatever3 = whatever3; - function d20() { - const iso = icosahedron(); - const numbersBRep = _.BRep.join(iso.faces.map((face, i) => { - const numberBRep = text("" + (i + 1), 0.4, -2); - const centroid = face.contour - .map((edge) => edge.a) - .reduce((a, b) => a.plus(b), ts3dutils.V3.O) - .div(3); - const sys = ts3dutils.M4.forSys(face.contour[0].aDir, centroid.cross(face.contour[0].aDir), centroid.unit(), centroid); - return numberBRep.transform(sys.times(ts3dutils.M4.translate(-numberBRep.getAABB().size().x / 2, -0.1, -0.04))); - })); - const s = sphere(0.9); - //return iso.and(numbersBRep) - return iso.and(s).and(numbersBRep); - //return numbersBRep - } - B2T.d20 = d20; - function rotStep(edges, totalRadsOrAngles, countO) { - const angles = "number" === typeof totalRadsOrAngles - ? ts3dutils.arrayFromFunction(countO, (i) => ((i + 1) / countO) * totalRadsOrAngles) - : totalRadsOrAngles; - const count = angles.length; - const open = !ts3dutils.eq(ts3dutils.TAU, ts3dutils.getLast(angles)); - const ribs = [ - edges, - ...angles.map((phi) => { - if (ts3dutils.eq(ts3dutils.TAU, phi)) { - return edges; - } - const matrix = ts3dutils.M4.rotateZ(phi); - return edges.map((edge) => edge.transform(matrix)); - }), - ]; - const horizontalEdges = ts3dutils.arrayFromFunction(count, (i) => { - const ipp = (i + 1) % (count + 1); - return ts3dutils.arrayFromFunction(edges.length, (j) => { - if (!ts3dutils.eq0(edges[j].a.lengthXY())) { - return _.StraightEdge.throughPoints(ribs[i][j].a, ribs[ipp][j].a); - } - return undefined; - }); - }); - const faces = []; - let face; - edges.forEach((edge, i) => { - const ipp = (i + 1) % edges.length; - // for straight edges perpendicular to the Z-axis, we only create one face. - if (edge instanceof _.StraightEdge && - edge.curve.dir1.isPerpendicularTo(ts3dutils.V3.Z)) { - const flipped = edge.a.x > edge.b.x; - const surface = new _.PlaneSurface(flipped ? new _.P3(ts3dutils.V3.Z, edge.a.z) : new _.P3(ts3dutils.V3.Z.negated(), -edge.a.z)); - if (open) { - const faceEdges = []; - if (!ts3dutils.eq0(edge.a.x)) { - faceEdges.push(...ts3dutils.arrayFromFunction(count, (j) => horizontalEdges[j][i])); - } - faceEdges.push(ribs[count][i]); - if (!ts3dutils.eq0(edge.b.x)) { - faceEdges.push(...ts3dutils.arrayFromFunction(count, (j) => horizontalEdges[count - j - 1][ipp].flipped())); - } - faceEdges.push(edge.flipped()); - face = new _.PlaneFace(surface, faceEdges); - } - else { - const contour = flipped - ? ts3dutils.arrayFromFunction(count, (j) => horizontalEdges[j][i]) - : ts3dutils.arrayFromFunction(count, (j) => horizontalEdges[count - j - 1][ipp].flipped()); - let hole; - if (flipped && !ts3dutils.eq0(edge.b.x)) { - hole = ts3dutils.arrayFromFunction(count, (j) => horizontalEdges[count - j - 1][ipp].flipped()); - } - else if (!flipped && !ts3dutils.eq0(edge.a.x)) { - hole = ts3dutils.arrayFromFunction(count, (j) => horizontalEdges[j][i]); - } - face = new _.PlaneFace(surface, contour, hole ? [hole] : []); - } - faces.push(face); - return; - } - else if (edge instanceof _.StraightEdge) { - if (ts3dutils.eq0(edge.a.lengthXY()) && ts3dutils.eq0(edge.b.lengthXY())) { - return; - } - } - for (let r = 0; r < count; r++) { - const rpp = (r + 1) % (count + 1); - const faceEdges = [ - ribs[r][i].flipped(), - horizontalEdges[r][i], - ribs[rpp][i], - horizontalEdges[r][ipp] && horizontalEdges[r][ipp].flipped(), - ].filter((x) => x); - let surface; - if (edge instanceof _.StraightEdge) { - surface = new _.PlaneSurface(_.P3.throughPoints(faceEdges[0].a, faceEdges[1].a, faceEdges[2].a)); - } - else { - const maxX = edges[i].getAABB().max.x; - const phi = angles[r], prevPhi = 0 == r ? 0 : angles[r - 1]; - const offset = ts3dutils.V3.polar(maxX, prevPhi).to(ts3dutils.V3.polar(maxX, phi)); - surface = projectCurve(ribs[r][i].curve, offset, false); - } - faces.push(_.Face.create(surface, faceEdges)); - } - }); - if (open) { - const endFaceEdges = ribs[count].map((edge) => edge.flipped()).reverse(); - const endFace = new _.PlaneFace(new _.PlaneSurface(_.P3.ZX.rotateZ(ts3dutils.getLast(angles))), endFaceEdges); - faces.push(new _.PlaneFace(new _.PlaneSurface(_.P3.ZX.flipped()), edges), endFace); - } - return new _.BRep(faces, new _.PlaneSurface(_.P3.ZX).edgeLoopCCW(edges)); - } - B2T.rotStep = rotStep; - function fixEdges(edges) { - return edges.flatMap((edge) => { - const c = edge.curve; - if (c instanceof _.EllipseCurve && c.tMin === -PI && c.tMax === PI) { - const splitEdges = edge.minT < 0 && edge.maxT > 0 ? edge.split(0) : [edge]; - return splitEdges.map((edge) => { - if (edge.minT >= 0) { - return _.createEdge(new _.EllipseCurve(c.center, c.f1, c.f2, max(0, c.tMin), c.tMax), edge.a, edge.b, edge.aT, edge.bT, undefined, edge.aDir, edge.bDir, edge.name); - } - else { - // "rotate" the curve - return _.createEdge(new _.EllipseCurve(c.center, c.f1.negated(), c.f2.negated(), c.tMin + PI, min(PI, c.tMax + PI)), edge.a, edge.b, edge.aT + PI, edge.bT + PI, undefined, edge.aDir, edge.bDir, edge.name); - } - }); - } - if (c instanceof _.BezierCurve) { - if (edge.a.like(edge.b)) { - return edge.split(ts3dutils.lerp(edge.aT, edge.bT, 0.5)); - } - } - return edge; - }); - } - B2T.fixEdges = fixEdges; - /** - * Create a [BRep] by projecting edges created by joining vertices with straight edges. - * @param baseVertices - * @param baseFacePlane - * @param offset - * @param name - * @param generator - */ - function extrudeVertices(baseVertices, baseFacePlane, offset, name, generator) { - ts3dutils.assert(baseVertices.every((v) => v instanceof ts3dutils.V3), "baseVertices.every(v => v instanceof V3)"); - ts3dutils.assertInst(_.P3, baseFacePlane); - ts3dutils.assertVectors(offset); - if (baseFacePlane.normal1.dot(offset) > 0) - baseFacePlane = baseFacePlane.flipped(); - const edges = _.StraightEdge.chain(baseVertices, true); - generator = - generator || - ts3dutils.callsce("B2T.extrudeVertices", baseVertices, baseFacePlane, offset, name); - return B2T.extrudeEdges(edges, baseFacePlane, offset, name, generator); - } - B2T.extrudeVertices = extrudeVertices; - /** - * Create a tetrahedron (3 sided pyramid) [BRep]. - * `a`, `b`, `c` and `d` can be in any order. The only constraint is that they cannot be on a common plane. - * The resulting tetrahedron will always have outwards facing faces. - * @param a - * @param b - * @param c - * @param d - * @param name - */ - function tetrahedron(a, b, c, d, name = "tetra" + _.getGlobalId()) { - ts3dutils.assertVectors(a, b, c, d); - const dDistance = _.P3.throughPoints(a, b, c).distanceToPointSigned(d); - if (ts3dutils.eq0(dDistance)) { - throw new Error("four points are coplanar"); - } - if (dDistance > 0) { - [c, d] = [d, c]; - } - const ab = _.StraightEdge.throughPoints(a, b); - const ac = _.StraightEdge.throughPoints(a, c); - const ad = _.StraightEdge.throughPoints(a, d); - const bc = _.StraightEdge.throughPoints(b, c); - const bd = _.StraightEdge.throughPoints(b, d); - const cd = _.StraightEdge.throughPoints(c, d); - const faces = [ - new _.PlaneFace(_.PlaneSurface.throughPoints(a, b, c), [ab, bc, ac.flipped()], [], name + "abc"), - new _.PlaneFace(_.PlaneSurface.throughPoints(a, d, b), [ad, bd.flipped(), ab.flipped()], [], name + "adb"), - new _.PlaneFace(_.PlaneSurface.throughPoints(b, d, c), [bd, cd.flipped(), bc.flipped()], [], name + "bdc"), - new _.PlaneFace(_.PlaneSurface.throughPoints(c, d, a), [cd, ad.flipped(), ac], [], name + "cda"), - ]; - const gen = ts3dutils.callsce("B2T.tetrahedron", a, b, c, d); - return new _.BRep(faces, false, gen); - } - B2T.tetrahedron = tetrahedron; - const b = 1 / ts3dutils.GOLDEN_RATIO, c = 2 - ts3dutils.GOLDEN_RATIO; - B2T.TETRAHEDRON_VERTICES = [ - new ts3dutils.V3(1, 0, -SQRT1_2), - new ts3dutils.V3(-1, 0, -SQRT1_2), - new ts3dutils.V3(0, -1, SQRT1_2), - new ts3dutils.V3(0, 1, SQRT1_2), - ].map((v) => v.unit()); - B2T.DODECAHEDRON_VERTICES = [ - new ts3dutils.V3(c, 0, 1), - new ts3dutils.V3(-c, 0, 1), - new ts3dutils.V3(-b, b, b), - new ts3dutils.V3(0, 1, c), - new ts3dutils.V3(b, b, b), - new ts3dutils.V3(b, -b, b), - new ts3dutils.V3(0, -1, c), - new ts3dutils.V3(-b, -b, b), - new ts3dutils.V3(c, 0, -1), - new ts3dutils.V3(-c, 0, -1), - new ts3dutils.V3(-b, -b, -b), - new ts3dutils.V3(0, -1, -c), - new ts3dutils.V3(b, -b, -b), - new ts3dutils.V3(b, b, -b), - new ts3dutils.V3(0, 1, -c), - new ts3dutils.V3(-b, b, -b), - new ts3dutils.V3(1, c, 0), - new ts3dutils.V3(-1, c, 0), - new ts3dutils.V3(-1, -c, 0), - new ts3dutils.V3(1, -c, 0), - ].map((v) => v.unit()); - B2T.DODECAHEDRON_FACE_VERTICES = [ - [4, 3, 2, 1, 0], - [7, 6, 5, 0, 1], - [12, 11, 10, 9, 8], - [15, 14, 13, 8, 9], - [14, 3, 4, 16, 13], - [3, 14, 15, 17, 2], - [11, 6, 7, 18, 10], - [6, 11, 12, 19, 5], - [4, 0, 5, 19, 16], - [12, 8, 13, 16, 19], - [15, 9, 10, 18, 17], - [7, 1, 2, 17, 18], - ]; - B2T.OCTAHEDRON_VERTICES = [ - new ts3dutils.V3(1, 0, 0), - new ts3dutils.V3(-1, 0, 0), - new ts3dutils.V3(0, 1, 0), - new ts3dutils.V3(0, -1, 0), - new ts3dutils.V3(0, 0, 1), - new ts3dutils.V3(0, 0, -1), - ]; - B2T.OCTAHEDRON_FACE_VERTICES = [ - [0, 2, 4], - [2, 1, 4], - [1, 3, 4], - [3, 0, 4], - [2, 0, 5], - [1, 2, 5], - [3, 1, 5], - [0, 3, 5], - ]; - const { x: s, y: t } = new ts3dutils.V3(1, ts3dutils.GOLDEN_RATIO, 0).unit(); - B2T.ICOSAHEDRON_VERTICES = [ - new ts3dutils.V3(-s, t, 0), - new ts3dutils.V3(s, t, 0), - new ts3dutils.V3(-s, -t, 0), - new ts3dutils.V3(s, -t, 0), - new ts3dutils.V3(0, -s, t), - new ts3dutils.V3(0, s, t), - new ts3dutils.V3(0, -s, -t), - new ts3dutils.V3(0, s, -t), - new ts3dutils.V3(t, 0, -s), - new ts3dutils.V3(t, 0, s), - new ts3dutils.V3(-t, 0, -s), - new ts3dutils.V3(-t, 0, s), - ]; - B2T.ICOSAHEDRON_FACE_VERTICES = [ - // 5 faces around point 0 - [0, 11, 5], - [0, 5, 1], - [0, 1, 7], - [0, 7, 10], - [0, 10, 11], - // 5 adjacent faces - [1, 5, 9], - [5, 11, 4], - [11, 10, 2], - [10, 7, 6], - [7, 1, 8], - // 5 faces around point 3 - [3, 9, 4], - [3, 4, 2], - [3, 2, 6], - [3, 6, 8], - [3, 8, 9], - // 5 adjacent faces - [4, 9, 5], - [2, 4, 11], - [6, 2, 10], - [8, 6, 7], - [9, 8, 1], - ]; - /** - * Create a dodecahedron [BRep]. The vertices are on the unit sphere. - */ - function dodecahedron() { - return makePlatonic(B2T.DODECAHEDRON_VERTICES, B2T.DODECAHEDRON_FACE_VERTICES, "B2T.dodecahedron()"); - } - B2T.dodecahedron = dodecahedron; - /** - * Create an octahedron [BRep]. The vertices are on the unit sphere. - */ - function octahedron() { - return makePlatonic(B2T.OCTAHEDRON_VERTICES, B2T.OCTAHEDRON_FACE_VERTICES, "B2T.octahedron()"); - } - B2T.octahedron = octahedron; - /** - * Create an icosahedron [BRep]. The vertices are on the unit sphere. - */ - function icosahedron() { - return makePlatonic(B2T.ICOSAHEDRON_VERTICES, B2T.ICOSAHEDRON_FACE_VERTICES, "B2T.icosahedron()"); - } - B2T.icosahedron = icosahedron; - function makePlatonic(VS, FVIS, generator) { - const edgeMap = new Map(); - const faces = FVIS.map((faceIndexes) => { - const surface = _.PlaneSurface.throughPoints(VS[faceIndexes[0]], VS[faceIndexes[1]], VS[faceIndexes[2]]); - const contour = ts3dutils.arrayFromFunction(faceIndexes.length, (i) => { - const ipp = (i + 1) % faceIndexes.length; - const iA = faceIndexes[i], iB = faceIndexes[ipp]; - const iMin = min(iA, iB), iMax = max(iA, iB), edgeID = iMin * VS.length + iMax; - let edge = edgeMap.get(edgeID); - !edge && - edgeMap.set(edgeID, (edge = _.StraightEdge.throughPoints(VS[iMin], VS[iMax]))); - return iA < iB ? edge : edge.flipped(); - }); - return new _.PlaneFace(surface, contour); - }); - return new _.BRep(faces, false, generator); - } - /** - * Create a [BRep] by projecting a number of edges onto a point. - * @param baseEdges The edges forming the base of the pyramid. - * @param apex The tip of the pyramid. - * @param name - */ - function pyramidEdges(baseEdges, apex, name = "pyramid" + _.getGlobalId()) { - ts3dutils.assertInst(_.Edge, ...baseEdges); - ts3dutils.assertVectors(apex); - const ribs = baseEdges.map((baseEdge) => _.StraightEdge.throughPoints(apex, baseEdge.a)); - const faces = baseEdges.map((baseEdge, i) => { - const faceName = name + "Wall" + i; - const ipp = (i + 1) % baseEdges.length; - const faceEdges = [ribs[i], baseEdge, ribs[ipp].flipped()]; - const surface = projectPointCurve(baseEdge.curve, baseEdge.minT, baseEdge.maxT, apex, baseEdge.deltaT() < 0); - return _.Face.create(surface, faceEdges, undefined, faceName); - }); - const baseSurface = new _.PlaneSurface(_.P3.XY).flipped(); - const bottomFace = _.Face.create(baseSurface, _.Edge.reversePath(baseEdges)); - faces.push(bottomFace); - const generator = ts3dutils.callsce("B2T.pyramidEdges", baseEdges, apex, name); - return new _.BRep(faces, false, generator); - } - B2T.pyramidEdges = pyramidEdges; - function fromBPT(bpt) { - const lineRegex = /.+/g; - const readLine = () => lineRegex.exec(bpt)[0]; - const readLineNumbers = () => readLine() - .trim() - .split(/\s+/) - .map((s) => parseFloat(s)); - const numOfPatches = parseInt(readLine()); - const faces = ts3dutils.arrayFromFunction(numOfPatches, () => { - const [pointsUCount, pointsVCount] = readLineNumbers(); - const points = Array.from({ length: (pointsUCount + 1) * (pointsVCount + 1) }, () => ts3dutils.VV(...readLineNumbers(), 1)); - const surface = new NURBSSurface(points, _.NURBS.bezierKnots(pointsUCount), _.NURBS.bezierKnots(pointsVCount), pointsUCount, pointsVCount, 0, 1, 0, 1); - const edges = [ - _.edgeForCurveAndTs(surface.isoparametricV(0)), - _.edgeForCurveAndTs(surface.isoparametricU(1)), - _.edgeForCurveAndTs(surface.isoparametricV(1)).flipped(), - _.edgeForCurveAndTs(surface.isoparametricU(0)).flipped(), - ]; - return _.Face.create(surface, edges); - }); - return new _.BRep(faces, false); - } - B2T.fromBPT = fromBPT; -})(exports.B2T || (exports.B2T = {})); - -class CustomPlane extends _.P3 { - constructor(anchor, right, up, name = "CustomPlane" + _.getGlobalId(), color = chroma.random().gl(), uMin = -500, uMax = 500, vMin = -500, vMax = 500) { - const { normal1, w } = _.P3.forAnchorAndPlaneVectors(anchor, right, up); - super(normal1, w); - this.up = up; - this.right = right; - this.uMin = uMin; - this.uMax = uMax; - this.vMin = vMin; - this.vMax = vMax; - this.name = name; - this.color = color; - } - get plane() { - return this; - } - toPlaneSurface() { - return new _.PlaneSurface(this, this.right, this.up); - } - toSource() { - return ts3dutils.callsce("new CustomPlane", this.anchor, this.right, this.up, this.name, this.color, this.uMin, this.uMax, this.vMin, this.vMax); - } - static forPlane(plane, color = tsgl.GL_COLOR_BLACK, name) { - //assert(!name) - const up = plane.normal1.getPerpendicular().unit(), right = up.cross(plane.normal1); - return new CustomPlane(plane.anchor, right, up, name, color); - } - static fromPlaneSurface(surface) { - return new CustomPlane(surface.plane.anchor, surface.right, surface.up, "genCustomPlane" + _.getGlobalId()); - } - distanceTo(line, mindist) { - return ts3dutils.min([ - new _.L3(this.anchor.plus(this.right.times(this.uMin)), this.up), - new _.L3(this.anchor.plus(this.right.times(this.uMax)), this.up), - new _.L3(this.anchor.plus(this.up.times(this.vMin)), this.right), - new _.L3(this.anchor.plus(this.up.times(this.vMax)), this.right), - ].map((line2, line2Index) => { - const info = line2.infoClosestToLine(line); - if ((isNaN(info.t) || // parallel LINES - (line2Index < 2 && this.vMin <= info.t && info.t <= this.vMax) || - (line2Index >= 2 && this.uMin <= info.t && info.t <= this.uMax)) && - info.distance <= mindist) { - return info.s; - } - else { - return Infinity; - } - })); - } - distanceTo2(line, mindist) { - return ts3dutils.min([ - new _.L3(this.anchor.plus(this.right.times(this.uMin)), this.up), - new _.L3(this.anchor.plus(this.right.times(this.uMax)), this.up), - new _.L3(this.anchor.plus(this.up.times(this.vMin)), this.right), - new _.L3(this.anchor.plus(this.up.times(this.vMax)), this.right), - ].map((line2, line2Index) => { - const info = line2.infoClosestToLine(line); - if ((isNaN(info.t) || // parallel LINES - (line2Index < 2 && this.vMin <= info.t && info.t <= this.vMax) || - (line2Index >= 2 && this.uMin <= info.t && info.t <= this.uMax)) && - info.distance <= mindist) { - return info.distance; - } - else { - return Infinity; - } - })); - } -} - -class Edge extends ts3dutils.Transformable { - constructor(curve, a, b, aT, bT, flippedOf, name) { - super(); - this.curve = curve; - this.a = a; - this.b = b; - this.aT = aT; - this.bT = bT; - this.flippedOf = flippedOf; - this.name = name; - ts3dutils.assertNumbers(aT, bT); - ts3dutils.assert(!ts3dutils.eq(aT, bT)); - ts3dutils.assertVectors(a, b); - ts3dutils.assertf(() => curve instanceof _.Curve, curve); - ts3dutils.assertf(() => !curve.isValidT || (curve.isValidT(aT) && curve.isValidT(bT)), aT, bT, curve); - //if (curve instanceof PICurve) { - // assertf(() => curve.at(aT).to(a).length() < 0.1, ''+curve.at(aT)+a) - // assertf(() => curve.at(bT).to(b).length() < 0.1, '' + curve.at(bT) + b) - //} else { - ts3dutils.assertf(() => curve.at(aT).like(a), () => "" + curve.at(aT) + a + " aT should have been " + curve.pointT(a)); - ts3dutils.assertf(() => curve.at(bT).like(b), () => "" + curve.at(bT) + b + " bT should have been " + curve.pointT(b)); - //} - ts3dutils.assertf(() => ts3dutils.fuzzyBetween(aT, curve.tMin, curve.tMax), aT, curve.tMin, curve.tMax); - ts3dutils.assertf(() => ts3dutils.fuzzyBetween(bT, curve.tMin, curve.tMax), bT, curve.tMin, curve.tMax); - ts3dutils.assert(!a.like(b), "!a.like(b)" + a + b); - this.aT = ts3dutils.clamp(aT, curve.tMin, curve.tMax); - this.bT = ts3dutils.clamp(bT, curve.tMin, curve.tMax); - this.reversed = this.aT > this.bT; - } - get minT() { - return Math.min(this.aT, this.bT); - } - get maxT() { - return Math.max(this.aT, this.bT); - } - static isLoop(loop) { - return loop.every((edge, i) => edge.b.like(loop[(i + 1) % loop.length].a)); - } - static edgesIntersect(e1, e2) { - // TODO: still getting some NaNs here.. - ts3dutils.assertNumbers(e1.curve.hlol, e2.curve.hlol); - ts3dutils.assertInst(Edge, e1, e2); - if (e1.curve.hlol < e2.curve.hlol) { - [e2, e1] = [e1, e2]; - } - const sts = e1.curve.isInfosWithCurve(e2.curve); - if (sts.some((info) => isNaN(info.tThis) || isNaN(info.tOther))) { - console.log(e1.sce); - console.log(e2.sce); - ts3dutils.assert(false); - } - return sts.some( - /// ( e1.aT < tThis < e1.bT ) && ( e2.aT < tOther < e2.bT ) - ({ tThis, tOther }) => { - return e1.tValueInside(tThis) && e2.tValueInside(tOther); - }); - } - static assertLoop(edges) { - edges.forEach((edge, i) => { - const j = (i + 1) % edges.length; - ts3dutils.assert(edge.b.like(edges[j].a), `edges[${i}].b != edges[${j}].a (${edges[i].b.sce} != ${edges[j].a.sce})`); - }); - } - static reversePath(path, doReverse = true) { - return doReverse - ? ts3dutils.arrayFromFunction(path.length, (i) => path[path.length - 1 - i].flipped()) - : path; - } - toString() { - return ts3dutils.callsce("new " + this.constructor.name, this.curve, this.a, this.b, this.aT, this.bT, undefined, this.aDir, this.bDir); - } - colinearToLine(line) { - return this.curve instanceof _.L3 && this.curve.isColinearTo(line); - } - tValueInside(t) { - return this.aT < this.bT - ? ts3dutils.lt(this.aT, t) && ts3dutils.lt(t, this.bT) - : ts3dutils.lt(this.bT, t) && ts3dutils.lt(t, this.aT); - } - isValidT(t) { - return this.aT < this.bT - ? ts3dutils.le(this.aT, t) && ts3dutils.le(t, this.bT) - : ts3dutils.le(this.bT, t) && ts3dutils.le(t, this.aT); - } - clampedT(t) { - return this.aT < this.bT - ? ts3dutils.clamp(t, this.aT, this.bT) - : ts3dutils.clamp(t, this.bT, this.aT); - } - /** - * this is equals-equals. "isColinearTo" might make more sense but can't be used, because you can't get a - * consistent hashCode for colinear curves - * @param obj - * @returns - */ - equals(obj) { - return (this === obj || - (this.constructor == obj.constructor && - this.a.equals(obj.a) && - this.b.equals(obj.b) && - this.curve.equals(obj.curve))); - } - hashCode() { - let hashCode = 0; - hashCode = hashCode * 31 + this.a.hashCode(); - hashCode = hashCode * 31 + this.b.hashCode(); - hashCode = hashCode * 31 + this.curve.hashCode(); - return hashCode | 0; - } - like(edge) { - // TODO this breaks on colinear edges, - // TODO: what, where? - return (this === edge || - (this.curve.isColinearTo(edge.curve) && - this.a.like(edge.a) && - this.b.like(edge.b) && - this.aDir.isParallelTo(edge.aDir) && - this.aDir.dot(edge.aDir) > 0)); - } - isCanon() { - return !this.reversed; - } - getCanon() { - return this.reversed ? this.flipped() : this; - } - overlaps(edge, noback) { - ts3dutils.assert(this.curve.isColinearTo(edge.curve)); - const edgeAT = this.curve.containsPoint(edge.a) && this.curve.pointT(edge.a); - const edgeBT = this.curve.containsPoint(edge.b) && this.curve.pointT(edge.b); - if (false === edgeAT && false === edgeBT) { - return noback ? false : edge.overlaps(this, true); - } - return !(ts3dutils.le(edge.maxT, this.minT) || ts3dutils.le(this.maxT, edge.minT)); - } - getAABB() { - const min = [Infinity, Infinity, Infinity], max = [-Infinity, -Infinity, -Infinity]; - this.curve.roots().forEach((ts, dim) => { - ts.forEach((t) => { - if (ts3dutils.lt(this.minT, t) && ts3dutils.lt(t, this.maxT)) { - min[dim] = Math.min(min[dim], this.curve.at(t).e(dim)); - max[dim] = Math.max(max[dim], this.curve.at(t).e(dim)); - } - }); - }); - const aabb = new ts3dutils.AABB(ts3dutils.V(min), ts3dutils.V(max)); - aabb.addPoint(this.a); - aabb.addPoint(this.b); - return aabb; - } - length(steps = 1) { - return this.curve.arcLength(this.minT, this.maxT, steps); - } - deltaT() { - return this.bT - this.aT; - } - deltaTSign() { - return sign(this.bT - this.aT); - } - atAvgT() { - return this.curve.at((this.minT + this.maxT) / 2); - } - /** - * Whether two edge loops are equal. Takes into account that two loops need not start with the same edge. - * @param loop1 - * @param loop2 - */ - static loopsEqual(loop1, loop2) { - return (loop1.length == loop2.length && - ts3dutils.arrayRange(0, loop1.length, 1).some((offset) => loop1.every((edge, i) => edge.equals(loop2[(offset + i) % loop1.length])))); - } -} - -class StraightEdge extends _.Edge { - constructor(line, a, b, aT, bT, flippedOf, name) { - super(line, a, b, aT, bT, flippedOf, name); - this.flippedOf = flippedOf; - ts3dutils.assertInst(_.L3, line); - !flippedOf || ts3dutils.assertInst(StraightEdge, flippedOf); - !name || ts3dutils.assertf(() => "string" === typeof name, name); - this.tangent = - this.aT < this.bT ? this.curve.dir1 : this.curve.dir1.negated(); - } - get aDir() { - return this.tangent; - } - get bDir() { - return this.tangent; - } - static throughPoints(a, b, name) { - return new StraightEdge(_.L3.throughPoints(a, b, 0, a.to(b).length()), a, b, 0, a.to(b).length(), undefined, name); - } - /** - * Create a list of StraightEdges from a list of vertices. - * @param vertices - * @param closed Whether to connect the first and last vertices. Defaults to true. - * @returns - */ - static chain(vertices, closed = true) { - const vc = vertices.length; - return ts3dutils.arrayFromFunction(closed ? vc : vc - 1, (i) => StraightEdge.throughPoints(vertices[i], vertices[(i + 1) % vc])); - } - toSource() { - return ts3dutils.callsce("new StraightEdge", this.curve, this.a, this.b, this.aT, this.bT); - } - getVerticesNo0() { - return [this.b]; - } - pointsCount() { - return 2; - } - points() { - return [this.a, this.b]; - } - edgeISTsWithPlane(plane) { - const edgeT = ts3dutils.snap2(this.curve.isTWithPlane(plane), this.aT, this.bT); - return this.minT <= edgeT && edgeT <= this.maxT ? [edgeT] : []; - } - edgeISTsWithSurface(surface) { - if (surface instanceof _.PlaneSurface) { - return this.edgeISTsWithPlane(surface.plane); - } - else { - return surface - .isTsForLine(this.curve) - .map((edgeT) => ts3dutils.snap2(edgeT, this.aT, this.bT)) - .filter((edgeT) => this.minT <= edgeT && edgeT <= this.maxT); - } - } - tangentAt() { - return this.tangent; - } - flipped() { - return (this.flippedOf || - (this.flippedOf = new StraightEdge(this.curve, this.b, this.a, this.bT, this.aT, this, this.name))); - } - transform(m4, desc) { - const lineDir1TransLength = m4 - .transformVector2(this.curve.dir1, this.curve.anchor) - .length(); - const curve = this.curve.transform(m4); - const a = m4.transformPoint(this.a); - const b = m4.transformPoint(this.b); - return new StraightEdge(curve, a, b, m4.isNoProj() ? this.aT * lineDir1TransLength : curve.pointT(a), m4.isNoProj() ? this.bT * lineDir1TransLength : curve.pointT(b), undefined, "" + this.name + desc); - } - transform4(m4, desc) { - const lineDir1TransLength = m4 - .transformVector2(this.curve.dir1, this.curve.anchor) - .length(); - const curve = this.curve.transform4(m4); - const a = m4.transformPoint(this.a); - const b = m4.transformPoint(this.b); - return new StraightEdge(curve, a, b, m4.isNoProj() ? this.aT * lineDir1TransLength : curve.pointT(a), m4.isNoProj() ? this.bT * lineDir1TransLength : curve.pointT(b), undefined, "" + this.name + desc); - } - isCoEdge(edge) { - return (this === edge || - this === edge.flippedOf || - (edge.constructor instanceof StraightEdge && - ((this.a.like(edge.a) && this.b.like(edge.b)) || - (this.a.like(edge.b) && this.b.like(edge.a))))); - } - getEdgeT(p) { - ts3dutils.assertVectors(p); - let edgeT = p.minus(this.curve.anchor).dot(this.curve.dir1); - if (!ts3dutils.eq0(this.curve.at(edgeT).distanceTo(p))) { - return; - } - edgeT = ts3dutils.snap2(edgeT, this.aT, this.bT); - return this.minT <= edgeT && edgeT <= this.maxT ? edgeT : undefined; - } - split(t) { - const p = this.curve.at(t); - return [ - new StraightEdge(this.curve, this.a, p, this.aT, t, undefined, this.name + "left"), - new StraightEdge(this.curve, p, this.b, t, this.bT, undefined, this.name + "right"), - ]; - } -} - -class PCurveEdge extends _.Edge { - constructor(curve, a, b, aT, bT, flippedOf, aDir, bDir, name) { - super(curve, a, b, aT, bT, flippedOf, name); - this.flippedOf = flippedOf; - this.aDir = aDir; - this.bDir = bDir; - ts3dutils.assertVectors(aDir, bDir); - ts3dutils.assertf(() => !aDir.likeO(), curve); - ts3dutils.assertf(() => !bDir.likeO(), curve); - if (!(curve instanceof _.PICurve)) { - // TODO - ts3dutils.assertf(() => curve.tangentAt(aT).likeOrReversed(aDir), "" + aT + curve.tangentAt(aT).sce + " " + aDir.sce); - ts3dutils.assertf(() => curve.tangentAt(bT).likeOrReversed(bDir), "" + bT + curve.tangentAt(bT).sce + " " + bDir.sce); - } - ts3dutils.assert(this.reversed === this.aDir.dot(curve.tangentAt(aT)) < 0, aT + - " " + - bT + - " " + - curve.constructor.name + - " " + - this.aDir.sce + - " " + - this.bDir.sce + - " " + - curve.tangentAt(aT)); - ts3dutils.assert(this.reversed === this.bDir.dot(curve.tangentAt(bT)) < 0, aT + - " " + - bT + - " " + - curve.constructor.name + - " " + - this.aDir.sce + - " " + - this.bDir.sce + - " " + - curve.tangentAt(aT)); - } - static forCurveAndTs(curve, aT, bT, name) { - return new PCurveEdge(curve, curve.at(aT), curve.at(bT), aT, bT, undefined, aT < bT ? curve.tangentAt(aT) : curve.tangentAt(aT).negated(), aT < bT ? curve.tangentAt(bT) : curve.tangentAt(bT).negated(), name); - } - toSource() { - return ts3dutils.callsce("new PCurveEdge", this.curve, this.a, this.b, this.aT, this.bT, undefined, this.aDir, this.bDir, this.name); - } - getVerticesNo0() { - return this.curve.calcSegmentPoints(this.aT, this.bT, this.a, this.b, this.reversed, false); - } - pointsCount() { - return this.points().length; - } - points() { - return this.curve.calcSegmentPoints(this.aT, this.bT, this.a, this.b, this.reversed, true); - } - edgeISTsWithSurface(surface) { - return this.curve - .isTsWithSurface(surface) - .map((edgeT) => ts3dutils.snap2(edgeT, this.aT, this.bT)) - .filter((edgeT) => this.minT <= edgeT && edgeT <= this.maxT); - } - edgeISTsWithPlane(surface) { - return this.curve - .isTsWithPlane(surface) - .map((edgeT) => ts3dutils.snap2(edgeT, this.aT, this.bT)) - .filter((edgeT) => this.minT <= edgeT && edgeT <= this.maxT); - } - tangentAt(t) { - return !this.reversed - ? this.curve.tangentAt(t) - : this.curve.tangentAt(t).negated(); - } - flipped() { - return (this.flippedOf || - (this.flippedOf = new PCurveEdge(this.curve, this.b, this.a, this.bT, this.aT, this, this.bDir.negated(), this.aDir.negated(), this.name))); - } - transform(m4, desc) { - return new PCurveEdge(this.curve.transform(m4), m4.transformPoint(this.a), m4.transformPoint(this.b), this.aT, this.bT, undefined, m4.transformVector(this.aDir), m4.transformVector(this.bDir), "" + this.name + desc); - } - transform4(m4, desc) { - const a_ = m4.transformPoint(this.a); - const b_ = m4.transformPoint(this.b); - const curve_ = this.curve.transform4(m4); - return new PCurveEdge(curve_, a_, b_, ts3dutils.snap(curve_.pointT(a_), this.aT), ts3dutils.snap(curve_.pointT(b_), this.bT), undefined, m4.transformVector(this.aDir), m4.transformVector(this.bDir), "" + this.name + desc); - } - isCoEdge(edge) { - return (this === edge || - this === edge.flippedOf || - (this.curve.isColinearTo(edge.curve) && - ((this.a.like(edge.a) && this.b.like(edge.b)) || - (this.a.like(edge.b) && this.b.like(edge.a))))); - } - split(t) { - const p = this.curve.at(t); - const dir = this.tangentAt(t); - return [ - new PCurveEdge(this.curve, this.a, p, this.aT, t, undefined, this.aDir, dir, this.name + "left"), - new PCurveEdge(this.curve, p, this.b, t, this.bT, undefined, this.aDir, dir, this.name + "right"), - ]; - } -} - -function edgePathFromSVG(pathString) { - let currentPos = undefined; - const parsed = new svgPathdata.SVGPathData(pathString) - .toAbs() - .normalizeHVZ() - .sanitize(ts3dutils.NLA_PRECISION) - .annotateArcs().commands; - const path = []; - for (const c of parsed) { - ts3dutils.assert("x" in c && "y" in c); - const endPos = new ts3dutils.V3(c.x, c.y, 0); - switch (c.type) { - case svgPathdata.SVGPathData.LINE_TO: - path.push(_.StraightEdge.throughPoints(currentPos, endPos)); - break; - case svgPathdata.SVGPathData.CURVE_TO: { - const c1 = new ts3dutils.V3(c.x1, c.y1, 0); - const c2 = new ts3dutils.V3(c.x2, c.y2, 0); - const curve = new _.BezierCurve(currentPos, c1, c2, endPos, 0, 1); - const edge = new _.PCurveEdge(curve, currentPos, endPos, 0, 1, undefined, curve.tangentAt(0), curve.tangentAt(1)); - path.push(edge); - break; - } - case svgPathdata.SVGPathData.QUAD_TO: { - const c1 = new ts3dutils.V3(c.x1, c.y1, 0); - const curve = _.ParabolaCurve.quadratic(currentPos, c1, endPos).rightAngled(); - const edge = new _.PCurveEdge(curve, currentPos, endPos, curve.tMin, curve.tMax, undefined, curve.tangentAt(curve.tMin), curve.tangentAt(curve.tMax)); - path.push(edge); - break; - } - case svgPathdata.SVGPathData.ARC: { - const phi1 = c.phi1 * ts3dutils.DEG, phi2 = c.phi2 * ts3dutils.DEG, [phiMin, phiMax] = [phi1, phi2].sort(ts3dutils.MINUS); - const stops = ts3dutils.arrayRange(-3, 4, 1) - .map((n) => n * ts3dutils.PI) - .filter((stop) => phiMin <= stop && stop <= phiMax); - const center = ts3dutils.V(c.cX, c.cY); - const f1 = ts3dutils.V3.polar(c.rX, c.xRot * ts3dutils.DEG); - const f2 = ts3dutils.V3.polar(c.rY, c.xRot * ts3dutils.DEG + Math.PI / 2); - const edges = ts3dutils.getIntervals(stops, phiMin, phiMax).map(([t1, t2]) => { - const deltaT = t2 - t1; - const t1_ = ts3dutils.mod(t1, ts3dutils.TAU); - const t2_ = t1_ + deltaT; - ts3dutils.assert(t1_ >= 0 == t2_ >= 0); - const gtPI = t1_ > ts3dutils.PI || t2_ > ts3dutils.PI; - const aT = gtPI ? t1_ - ts3dutils.PI : t1_; - const bT = gtPI ? t2_ - ts3dutils.PI : t2_; - const curve = new _.EllipseCurve(center, gtPI ? f1.negated() : f1, gtPI ? f2.negated() : f2); - const a = phi1 == t1 ? currentPos : phi2 == t1 ? endPos : curve.at(aT); - const b = phi1 == t2 ? currentPos : phi2 == t2 ? endPos : curve.at(bT); - return new _.PCurveEdge(curve, a, b, aT, bT, undefined, curve.tangentAt(aT), curve.tangentAt(bT)); - }); - path.push(...(c.phiDelta > 0 ? edges : _.Edge.reversePath(edges))); - break; - } - } - currentPos = endPos; - } - return path; -} -/** - * Create an axis-aligned rectangle of edges on the XY-plane with the bottom-left corner on the origin. - * @param width - * @param height - */ -function edgeRect(width = 1, height = width) { - const vertices = [ - new ts3dutils.V3(0, 0, 0), - new ts3dutils.V3(width, 0, 0), - new ts3dutils.V3(width, height, 0), - new ts3dutils.V3(0, height, 0), - ]; - return _.StraightEdge.chain(vertices); -} -function edgeNgon(n = 3, radius = 1) { - return _.StraightEdge.chain(ts3dutils.arrayFromFunction(n, (i) => ts3dutils.V3.polar(radius, (ts3dutils.TAU * i) / n))); -} -function edgeStar(pointCount = 5, r0 = 1, r1 = 0.5) { - const vertices = ts3dutils.arrayFromFunction(pointCount * 2, (i) => ts3dutils.V3.polar(0 == i % 2 ? r0 : r1, (ts3dutils.TAU * i) / pointCount / 2)); - return _.StraightEdge.chain(vertices); -} -function createEdge(curve, a, b, aT, bT, flippedOf, aDir, bDir, name) { - if (curve instanceof _.L3) { - return new _.StraightEdge(curve, a, b, aT, bT, flippedOf, name); - } - else { - return new _.PCurveEdge(curve, a, b, aT, bT, flippedOf, aDir, bDir, name); - } -} -function edgeForCurveAndTs(curve, aT = curve.tMin, bT = curve.tMax) { - return createEdge(curve, curve.at(aT), curve.at(bT), aT, bT, undefined, aT < bT ? curve.tangentAt(aT) : curve.tangentAt(aT).negated(), aT < bT ? curve.tangentAt(bT) : curve.tangentAt(bT).negated()); -} -function reuleaux(n = 3, radius = 1) { - ts3dutils.assert(3 <= n); - ts3dutils.assert(1 == n % 2); - const corners = ts3dutils.arrayFromFunction(n, (i) => ts3dutils.V3.polar(radius, (ts3dutils.TAU * i) / n)); - return ts3dutils.arrayFromFunction(n, (i) => { - const aI = (i + floor(n / 2)) % n, bI = (i + ceil(n / 2)) % n; - const a = corners[aI], b = corners[bI]; - const center = corners[i]; - const f1 = center.to(a), curve = new _.EllipseCurve(center, f1, ts3dutils.V3.Z.cross(f1)); - return createEdge(curve, a, b, 0, curve.pointT(b), undefined, ts3dutils.V3.Z.cross(f1), ts3dutils.V3.Z.cross(center.to(b))); - }); -} -function round$1(edges, radius) { - if (ts3dutils.eq0(radius)) { - return edges; - } - const corners = edges.map((edge, i) => { - const j = (i + 1) % edges.length, nextEdge = edges[j]; - if (!edge.b.like(nextEdge.a)) - return undefined; - const angleToNext = edge.bDir.angleTo(nextEdge.aDir); - const c1 = edge.curve, c2 = nextEdge.curve; - if (c1 instanceof _.L3 && c2 instanceof _.L3) { - const normal = c1.dir1.cross(c2.dir1); - if (ts3dutils.eq0(angleToNext)) - return undefined; - const l1inside = normal.cross(c1.dir1), l2inside = normal.cross(c2.dir1); - const l1offset = c1.transform(ts3dutils.M4.translate(l1inside.toLength(radius))); - const l2offset = c2.transform(ts3dutils.M4.translate(l2inside.toLength(radius))); - const center = l1offset.isInfoWithLine(l2offset); - if (!center) - throw new Error("tangential curves"); - const cornerA = center.plus(l1inside.toLength(-radius)); - const cornerB = center.plus(l2inside.toLength(-radius)); - const f1 = l1inside.toLength(-radius); - const curve = new _.EllipseCurve(center, f1, normal.cross(f1).toLength(radius)); - const cornerEdge = createEdge(curve, cornerA, cornerB, 0, curve.pointT(cornerB), undefined, c1.dir1, c2.dir1); - return cornerEdge; - } - else { - return arbitraryCorner(edge, nextEdge, radius); - } - }); - const result = edges.flatMap((edge, i) => { - const h = (i + edges.length - 1) % edges.length; - const prevCorner = corners[h], nextCorner = corners[i]; - if (!prevCorner && !nextCorner) { - return edge; - } - const [aT, a, aDir] = !prevCorner - ? [edge.aT, edge.a, edge.aDir] - : [edge.curve.pointT(prevCorner.b), prevCorner.b, prevCorner.bDir]; - const [bT, b, bDir] = !nextCorner - ? [edge.bT, edge.b, edge.bDir] - : [edge.curve.pointT(nextCorner.a), nextCorner.a, nextCorner.aDir]; - const newEdge = createEdge(edge.curve, a, b, aT, bT, undefined, aDir, bDir); - return !nextCorner ? newEdge : [newEdge, nextCorner]; - }); - return result; -} -function arbitraryCorner(e1, e2, radius) { - const c1 = e1.curve, c2 = e2.curve; - function f([t1, t2]) { - const p1 = c1.at(t1), p2 = c2.at(t2); - const dp1 = c1.tangentAt(t1), dp2 = c2.tangentAt(t2); - const virtualPlaneNormal = dp1.cross(dp2); - const normal1 = virtualPlaneNormal.cross(dp1).unit(), normal2 = virtualPlaneNormal.cross(dp2).unit(); - const dirCross = normal1.cross(normal2); - if (virtualPlaneNormal.likeO()) { - ts3dutils.assert(false); - } // lines parallel - const p1p2 = p1.to(p2); - // check if distance is zero (see also L3.distanceToLine) - if (!ts3dutils.eq0(p1p2.dot(virtualPlaneNormal))) { - ts3dutils.assert(false); - } - const dist1 = p1p2.cross(normal2).dot(dirCross) / dirCross.squared(); - const dist2 = p1p2.cross(normal1).dot(dirCross) / dirCross.squared(); - const g1 = p1.plus(normal1.times(dist1)); - const g2 = p2.plus(normal2.times(dist2)); - ts3dutils.assert(g1.like(g2)); - return [abs(dist1) - radius, abs(dist2) - radius]; - } - const startT1 = e1.bT - (radius * sign(e1.deltaT())) / e1.bDir.length(); - const startT2 = e2.aT + (radius * sign(e2.deltaT())) / e2.aDir.length(); - const [t1, t2] = ts3dutils.newtonIterate(f, [startT1, startT2]); - const cornerA = e1.curve.at(t1); - const cornerB = e2.curve.at(t2); - const dp1 = c1.tangentAt(t1), dp2 = c2.tangentAt(t2); - const virtualPlaneNormal = dp1.cross(dp2); - const normal1 = virtualPlaneNormal.cross(dp1).unit(); - const f1 = normal1.toLength(-radius); - const center = cornerA.minus(f1); - const curve = new _.EllipseCurve(center, f1, virtualPlaneNormal.cross(f1).toLength(radius)); - const cornerEdge = createEdge(curve, cornerA, cornerB, 0, curve.pointT(cornerB), undefined, c1.tangentAt(t1), c2.tangentAt(t2)); - return cornerEdge; -} - -/** - * Created by aval on 19.04.2017. - */ -class FaceInfoFactory { - static makeStatic(staticInfo) { - return new (class extends FaceInfoFactory { - constructor() { - super(); - } - info(surface, contour, holes) { - return staticInfo; - } - })(); - } - info(surface, contour, holes) { - throw new Error("no default implementation"); - } - extrudeBottom(surface, contour, holes = []) { - return this.info(surface, contour, holes); - } - extrudeTop(surface, contour, holes = []) { - return this.info(surface, contour, holes); - } - extrudeWall(index, surface, contour, holes = []) { - return this.info(surface, contour, holes); - } - rotationWall(index, surface, contour, holes = []) { - return this.info(surface, contour, holes); - } - rotationStart(surface, contour, holes = []) { - return this.info(surface, contour, holes); - } - rotationEnd(surface, contour, holes = []) { - return this.info(surface, contour, holes); - } - newSubFace(original, surface, contour, holes = []) { - return original.info; - } - transform(original, m4, desc, surface, contour, holes = []) { - return original.info; - } -} - -class Face extends ts3dutils.Transformable { - constructor(surface, contour, holes = [], name, info) { - super(); - this.surface = surface; - this.contour = contour; - this.holes = holes; - this.name = name; - this.info = info; - this.aabb = undefined; - //assert(name) - _.Edge.assertLoop(contour); - ts3dutils.assert(contour.every((f) => f instanceof _.Edge), () => "contour.every(f => f instanceof Edge)" + contour); - // contour.forEach(e => !surface.containsCurve(e.curve) && - // console.log('FAIL:'+surface.distanceToPoint(e.curve.anchor))) - //contour.forEach(e => { - // assert(surface.containsCurve(e.curve), 'edge not in surface ' + e + surface) - //}) - //assert(surface.edgeLoopCCW(contour), surface.toString() + contour.join('\n')) - holes && holes.forEach((hole) => _.Edge.assertLoop(hole)); - holes && holes.forEach((hole) => ts3dutils.assert(!surface.edgeLoopCCW(hole))); - ts3dutils.assert(!holes || holes.constructor == Array, holes && holes.toString()); - this.allEdges = Array.prototype.concat.apply(this.contour, this.holes); - } - static assembleFacesFromLoops(loops, surface, faceConstructor) { - function placeRecursively(newLoopInfo, loopInfos) { - if (loopInfos.length == 0) { - loopInfos.push(newLoopInfo); - } - else { - const subLoopInfo = loopInfos.find((loopInfo) => _.BRep.loop1ContainsLoop2(loopInfo.loop, loopInfo.ccw, newLoopInfo.loop, newLoopInfo.ccw, surface)); - if (subLoopInfo) { - placeRecursively(newLoopInfo, subLoopInfo.subloops); - } - else { - // newLoopInfo isnt contained by any other subLoopInfo - for (let i = loopInfos.length; --i >= 0;) { - const subLoopInfo = loopInfos[i]; - //console.log('cheving subLoopInfo', surface.loopContainsPoint(newLoopInfo.edges, - // subLoopInfo.edges[0].a)) - if (_.BRep.loop1ContainsLoop2(newLoopInfo.loop, newLoopInfo.ccw, subLoopInfo.loop, subLoopInfo.ccw, surface)) { - newLoopInfo.subloops.push(subLoopInfo); - loopInfos.splice(i, 1); // remove it - } - } - loopInfos.push(newLoopInfo); - } - } - } - function newFacesRecursive(loopInfo) { - newFaces.push(new faceConstructor(surface, loopInfo.ccw ? loopInfo.loop : _.Edge.reversePath(loopInfo.loop), loopInfo.subloops.map((sl) => sl.ccw ? _.Edge.reversePath(sl.loop) : sl.loop))); - loopInfo.subloops.forEach((sl) => sl.subloops.forEach((sl2) => newFacesRecursive(sl2))); - } - const newFaces = []; - const topLevelLoops = []; - loops.forEach((loop) => placeRecursively({ - loop: loop, - ccw: surface.edgeLoopCCW(loop), - subloops: [], - }, topLevelLoops)); - topLevelLoops.forEach((tll) => newFacesRecursive(tll)); - return newFaces; - } - //fromLoops(loops: Edge[][], surface: Surface) { - // type LoopInfo = {loop: Edge[], ccw: boolean, subloops: LoopInfo[]} - // function placeRecursively(newLoopInfo: LoopInfo, loopInfos: LoopInfo[]) { - // if (loopInfos.length == 0) { - // loopInfos.push(newLoopInfo) - // } else { - // const subLoopInfo = loopInfos.find(loopInfo => BRep.loop1ContainsLoop2(loopInfo.loop, loopInfo.ccw, - // newLoopInfo.loop, newLoopInfo.ccw, surface)) if (subLoopInfo) { placeRecursively(newLoopInfo, - // subLoopInfo.subloops) } else { // newLoopInfo isnt contained by any other subLoopInfo for (let i = - // loopInfos.length; --i >= 0;) { const subLoopInfo = loopInfos[i] //console.log('cheving subLoopInfo', - // surface.loopContainsPoint(newLoopInfo.edges, subLoopInfo.edges[0].a)) if - // (BRep.loop1ContainsLoop2(newLoopInfo.loop, subLoopInfo.loop, surface)) { newLoopInfo.subloops.push(subLoopInfo) - // loopInfos.splice(i, 1) // remove it } } loopInfos.push(newLoopInfo) } } } function newFacesRecursive(loopInfo: - // LoopInfo): void { // CW loops can be top level, if they are holes in the original face not contained in the new - // face if (loopInfo.ccw) { if (loopInfo.subloops.every(sl => !sl.ccw)) { const newFace = new - // faceConstructor(surface, loopInfo.loop, loopInfo.subloops.map(sl => sl.loop)) newFaces.push(newFace) - // loopInfo.subloops.forEach(sl => sl.subloops.forEach(slsl => slsl.ccw && newFacesRecursive(slsl))) } else { - // loopInfo.subloops.forEach(sl => sl.ccw && newFacesRecursive(sl)) } } } const newFaces: Face[] = [] const - // topLevelLoops:LoopInfo[] = [] loops.forEach(loop => placeRecursively({loop: loop, ccw: - // surface.edgeLoopCCW(loop), subloops: []}, topLevelLoops)) topLevelLoops.forEach(tll => newFacesRecursive(tll)) - // return newFaces } - static create(surface, faceEdges, holes, faceName, info) { - return surface instanceof _.PlaneSurface - ? new PlaneFace(surface, faceEdges, holes, faceName, info) - : new RotationFace(surface, faceEdges, holes, faceName, info); - } - intersectFace(face2, thisBrep, face2Brep, faceMap, thisEdgePoints, otherEdgePoints, checkedPairs) { - //thisEdgePoints = { - // get(key) { - // return _thisEdgePoints.get(key) - // }, - // set(key, value) { - // assert(thisBrep.edgeFaces.get(key)) - // _thisEdgePoints.set(key, value) - // } - //} - function hasPair(a, b) { - return checkedPairs.has(new javasetmap_ts.Pair(a, b)); - } - function addPair(a, b) { - return checkedPairs.add(new javasetmap_ts.Pair(a, b)); - } - /** - * @param newEdge generated segment - * @param col1 if newEdge is colinear to an edge of this, the edge in question - * @param col2 same for face2 - * @return whether new edge was added. - */ - function handleNewEdge(newEdge, col1, col2) { - if (!col1 && !col2) { - let correctDir = face.surface - .normalP(newEdge.a) - .cross(face2.surface.normalP(newEdge.a)); - if (correctDir.likeO()) { - const t = ts3dutils.lerp(newEdge.aT, newEdge.bT, 1 / ts3dutils.GOLDEN_RATIO), p = newEdge.curve.at(t); - correctDir = face.surface.normalP(p).cross(face2.surface.normalP(p)); - } - if (!correctDir.likeO()) { - if (correctDir.dot(newEdge.aDir) < 0) { - newEdge = newEdge.flipped(); - } - ts3dutils.mapPush(faceMap, face, newEdge); - ts3dutils.mapPush(faceMap, face2, newEdge.flipped()); - } - else { - const p = newEdge.a; - const plane = _.P3.normalOnAnchor(newEdge.aDir, p); - const up = face.surface.normalP(p); - const sameDir = up.dot(face2.surface.normalP(p)) > 0; - const canonDir = plane.normal1.cross(up); - const curve = face.surface.isCurvesWithPlane(plane)[0], curveT = curve.pointT(p), curveDir = sign(canonDir.dot(curve.tangentAt(curveT))); - const curve2 = face2.surface.isCurvesWithPlane(plane)[0], curve2T = curve2.pointT(p), curve2Dir = sign(canonDir.dot(curve.tangentAt(curve2T))); - const foo = curve.diff(curveT, _.EPS * curveDir).dot(up); - const foo2 = curve2.diff(curve2T, _.EPS * curve2Dir).dot(up); - if (foo2 < foo) { - ts3dutils.mapPush(faceMap, face2, sameDir ? newEdge.flipped() : newEdge); - } - if (up.dot(face2.surface.normalP(p)) < 0 == foo2 < foo) { - ts3dutils.mapPush(faceMap, face, newEdge.flipped()); - } - const bar = curve.diff(curveT, _.EPS * curveDir).dot(up); - const bar2 = curve2.diff(curve2T, _.EPS * curve2Dir).dot(up); - if (bar2 < bar) { - ts3dutils.mapPush(faceMap, face2, sameDir ? newEdge : newEdge.flipped()); - } - if (sameDir != bar2 < bar) { - ts3dutils.mapPush(faceMap, face, newEdge); - } - } - return true; - } - function handleEdgeInFace(col1, col2, face, face2, thisBrep, face2Brep, coplanarSameIsInside, has, add) { - if (col1 && !col2) { - if (hasPair(col1.getCanon(), face2)) - return false; - //add(col1.getCanon(), face2) - const surface2 = face2.surface; - // NB: a new edge is inserted even though it may be the same as an old one - // however it indicates that it intersects the other volume here, i.e. the old edge cannot - // be counted as 'inside' for purposes of reconstitution - thisBrep.edgeFaces.get(col1.getCanon()).forEach((faceInfo) => { - //const dot = snap0(surface2.normal1.dot(faceInfo.inside)) - //if (dot == 0 ? !coplanarSameIsInside : dot < 0) { - const pointsInsideFace = _.fff(faceInfo, face2.surface); - const edgeInside = pointsInsideFace == _.INSIDE || - (!coplanarSameIsInside && pointsInsideFace == _.COPLANAR_SAME); - const pushEdge = faceInfo.edge - .tangentAt(faceInfo.edge.curve.pointT(newEdge.a)) - .like(newEdge.aDir) - ? newEdge - : newEdge.flipped(); - ts3dutils.assert(faceInfo.edge - .tangentAt(faceInfo.edge.curve.pointT(pushEdge.a)) - .like(pushEdge.aDir)); - edgeInside && ts3dutils.mapPush(faceMap, faceInfo.face, pushEdge); - }); - const surface2NormalAtNewEdgeA = surface2.normalP(newEdge.a); - const newEdgeInside = surface2NormalAtNewEdgeA.cross(newEdge.aDir); - const sVEF1 = _.splitsVolumeEnclosingFacesP(thisBrep, col1.getCanon(), newEdge.a, newEdgeInside, surface2NormalAtNewEdgeA); - let addNewEdge, addNewEdgeFlipped; - if ((addNewEdge = - sVEF1 == _.INSIDE || - (coplanarSameIsInside && sVEF1 == _.COPLANAR_SAME))) { - ts3dutils.mapPush(faceMap, face2, newEdge); - } - const sVEF2 = _.splitsVolumeEnclosingFacesP(thisBrep, col1.getCanon(), newEdge.a, newEdgeInside.negated(), surface2NormalAtNewEdgeA); - if ((addNewEdgeFlipped = - sVEF2 == _.INSIDE || - (coplanarSameIsInside && sVEF2 == _.COPLANAR_SAME))) { - ts3dutils.mapPush(faceMap, face2, newEdge.flipped()); - } - if (addNewEdge || - addNewEdgeFlipped || - (sVEF1 == _.COPLANAR_SAME && sVEF2 == _.INSIDE) || - (sVEF2 == _.COPLANAR_SAME && sVEF1 == _.INSIDE)) { - return true; - } - } - return false; - } - const c1 = handleEdgeInFace(col1, col2, face, face2, thisBrep, face2Brep, false); - const c2 = handleEdgeInFace(col2, col1, face2, face, face2Brep, thisBrep, true); - if (c1 || c2) - return true; - if (col1 && col2) { - if (hasPair(col1.getCanon(), col2.getCanon())) - return false; - addPair(col1.getCanon(), col2.getCanon()); - function handleColinearEdgeFaces(col1, col2, thisBrep, face2Brep, coplanarSameIsInside, thisEdgePoints, has, add) { - // not entirely sure for what i had the dirInsides in? - //const aDirNegatedInside = (newEdge.a.like(col2.a) || newEdge.a.like(col2.b)) && - // splitsVolumeEnclosingCone(face2Brep, newEdge.a, newEdge.aDir.negated()) == INSIDE const - // bDirInside = (newEdge.b.like(col2.a) || newEdge.b.like(col2.b)) && - // splitsVolumeEnclosingCone(face2Brep, newEdge.b, newEdge.bDir) == INSIDE - for (const faceInfo of thisBrep.edgeFaces.get(col1.getCanon())) { - const sVEF = _.splitsVolumeEnclosingFaces(face2Brep, col2.getCanon(), faceInfo.inside, faceInfo.normalAtCanonA); - const edgeInside = sVEF == _.INSIDE || (coplanarSameIsInside && sVEF == _.COPLANAR_SAME); - const pushEdge = faceInfo.edge.aDir.like(newEdge.aDir) - ? newEdge - : newEdge.flipped(); - if (edgeInside) { - ts3dutils.mapPush(faceMap, faceInfo.face, pushEdge); - const aT = col1.getCanon().curve.pointT(newEdge.a); - if (!ts3dutils.eq(aT, col1.aT) && !ts3dutils.eq(aT, col1.bT)) { - // newEdge.a is in center of col1 - if (_.splitsVolumeEnclosingCone2(face2Brep, newEdge.a, newEdge.curve, newEdge.aT, -Math.sign(newEdge.deltaT())) == _.INSIDE) { - ts3dutils.mapPush(thisEdgePoints, col1.getCanon(), { - p: newEdge.a, - edgeT: aT, - }); - } - } - const bT = col1.getCanon().curve.pointT(newEdge.b); - if (!ts3dutils.eq(bT, col1.aT) && !ts3dutils.eq(bT, col1.bT)) { - if (_.splitsVolumeEnclosingCone2(face2Brep, newEdge.b, newEdge.curve, newEdge.bT, Math.sign(newEdge.deltaT())) == _.INSIDE) { - ts3dutils.mapPush(thisEdgePoints, col1.getCanon(), { - p: newEdge.b, - edgeT: bT, - }); - } - } - } - } - } - handleColinearEdgeFaces(col1, col2, thisBrep, face2Brep, true, thisEdgePoints); - handleColinearEdgeFaces(col2, col1, face2Brep, thisBrep, false, otherEdgePoints); - return false; - } - return false; - } - // what needs to be generated: new edges on face - // points on edges where they are cut by faces so that sub edges will be generated for loops - // points on ends of edges where the edge will be an edge in the new volume where it goes from A to B - // you don't want those to be marked as 'inside', otherwise invalid faces will be added - // if a face cuts a corner, nothing needs to be done, as that alone does not limit what adjacent faces will be - function handleEndPoint(a, b, newEdge) { - // ends in the middle of b's face - if (a && !b) { - if (!a.colinear && a.edgeT != a.edge.aT && a.edgeT != a.edge.bT) { - ts3dutils.mapPush(thisEdgePoints, a.edge.getCanon(), a); - ts3dutils.assert(a.edge.isValidT(a.edgeT)); - } - // else colinear segment ends in middle of other face, do nothing - } - // ends in the middle of a's face - if (b && !a) { - if (!b.colinear && b.edgeT != b.edge.aT && b.edgeT != b.edge.bT) { - ts3dutils.mapPush(otherEdgePoints, b.edge.getCanon(), b); - ts3dutils.assert(b.edge.isValidT(b.edgeT)); - } - // else colinear segment ends in middle of other face, do nothing - } - if (a && b) { - ts3dutils.assert(a.colinear || b.colinear || ts3dutils.eq(a.t, b.t)); - // if a or b is colinear the correct points will already have been added to the edge by handleNewEdge - // segment starts/ends on edge/edge intersection - function handleAB(a, b, face, face2, thisPlane, face2Plane, thisBrep, face2Brep, first, thisEdgePoints) { - if (!a.colinear && a.edgeT != a.edge.aT && a.edgeT != a.edge.bT) { - //if (!hasPair(a.edge.getCanon(), b.edge.getCanon())) { - addPair(a.edge.getCanon(), b.edge.getCanon()); - // ends on a, on colinear segment b bT != a.edge.bT && - // b can be colinear, so edgeT == aT is possible - if (a.p.like(b.edge.a) || a.p.like(b.edge.b)) { - const corner = a.p.like(b.edge.a) ? b.edge.a : b.edge.b; - // face2brep corner on edge - const sVEC1 = _.splitsVolumeEnclosingCone2(face2Brep, corner, a.edge.curve, a.edgeT, 1); - const sVEC2 = _.splitsVolumeEnclosingCone2(face2Brep, corner, a.edge.curve, a.edgeT, -1); - // if either of these return ALONG_EDGE_OR_PLANE, then the breps share a colinear edge - if (_.INSIDE == sVEC1 || _.INSIDE == sVEC2) { - ts3dutils.mapPush(thisEdgePoints, a.edge.getCanon(), a); - ts3dutils.assert(a.edge.isValidT(a.edgeT)); - } - } - else { - // edge / edge center intersection - // todo: is this even necessary considering we add edges anyway? i think so... - // const testVector = - // a.edge.tangentAt(a.edgeT).rejectedFrom(b.edge.tangentAt(b.edge.curve.pointT(a.p))) - // assert(!testVector.likeO()) - const sVEF1 = _.splitsVolumeEnclosingFacesP2(face2Brep, b.edge.getCanon(), a.p, a.edge.curve, a.edgeT, 1, thisPlane.normalP(a.p)); - const sVEF2 = _.splitsVolumeEnclosingFacesP2(face2Brep, b.edge.getCanon(), a.p, a.edge.curve, a.edgeT, -1, thisPlane.normalP(a.p)); - if (_.INSIDE == sVEF1 || - (first && _.COPLANAR_SAME == sVEF1) || - _.INSIDE == sVEF2 || - (first && _.COPLANAR_SAME == sVEF2)) { - ts3dutils.mapPush(thisEdgePoints, a.edge.getCanon(), a); - ts3dutils.assert(a.edge.isValidT(a.edgeT)); - } - } - //} - } - } - handleAB(a, b, face, face2, surface, surface2, thisBrep, face2Brep, true, thisEdgePoints); - handleAB(b, a, face2, face, surface2, surface, face2Brep, thisBrep, false, otherEdgePoints); - } - } - ts3dutils.assertInst(Face, face2); - const face = this; - const surface = face.surface, surface2 = face2.surface; - if (!this.getAABB().touchesAABBfuzzy(face2.getAABB())) { - return; - } - if (surface.isCoplanarTo(surface2)) { - return; - } - const isCurves = surface.isCurvesWithSurface(surface2); - if (0 == isCurves.length) { - return; - } - for (const isCurve of isCurves) { - ts3dutils.assert(surface.containsCurve(isCurve)); - ts3dutils.assert(surface2.containsCurve(isCurve)); - } - for (let isCurveIndex = 0; isCurveIndex < isCurves.length; isCurveIndex++) { - // get intersections of newCurve with other edges of face and face2 - const isCurve = isCurves[isCurveIndex]; - const ps1 = face.edgeISPsWithSurface(isCurve, face2.surface); - const ps2 = face2.edgeISPsWithSurface(isCurve, face.surface); - // for non-endless curves, e.g. ellipses, the intersections of the faces can be non-zero, even if one of - // the faces doesn't register any points on the curve. For example, if a cylinder is cut entirely by a - // plane face (all its edges around the cylinder), then the face will contain the entire curve and - // 'ps' for the plane face will be empty - // TODO: behavior when curves touch face? - // !! start in does depend on insideDir... TODO - ts3dutils.assertf(() => 0 == ps1.length || - !ts3dutils.eq0(ps1[0].insideDir.dot(isCurve.tangentAt(ps1[0].t))), () => ps1[0].insideDir.dot(isCurve.tangentAt(ps1[0].t))); - ts3dutils.assertf(() => 0 == ps2.length || - !ts3dutils.eq0(ps2[0].insideDir.dot(isCurve.tangentAt(ps2[0].t))), () => ps2[0].insideDir.dot(isCurve.tangentAt(ps2[0].t))); - function startsInside(ps, face) { - if (0 == ps.length) { - return (isFinite(isCurve.tMin) && - face.containsPoint2(isCurve.at(isCurve.tMin)) == _.PointVsFace.INSIDE); - } - else { - return ps[0].insideDir.dot(isCurve.tangentAt(ps[0].t)) < 0; - } - } - // they can't both be empty currently - // they can't both start 'inside' - let in1 = startsInside(ps1, face); - let in2 = startsInside(ps2, face2); - if ((0 == ps1.length && !in1) || (0 == ps2.length && !in2)) { - continue; - } - //assert(!in1 || !in2) - let col1, col2; - let i = 0, j = 0, last; - let startP = in1 && in2 ? isCurve.at(isCurve.tMin) : undefined, startDir, startT = isCurve.tMin, startA, startB; - while (i < ps1.length || j < ps2.length) { - ts3dutils.assert(i <= ps1.length); - ts3dutils.assert(j <= ps2.length); - const a = ps1[i], b = ps2[j]; - ts3dutils.assert(a || b); - if (j == ps2.length || (i < ps1.length && ts3dutils.lt(a.t, b.t))) { - last = a; - in1 = !in1; - a.used = true; - col1 = a.colinear ? a : undefined; - i++; - } - else if (i == ps1.length || ts3dutils.gt(a.t, b.t)) { - last = b; - b.used = true; - in2 = !in2; - col2 = b.colinear ? b : undefined; - j++; - } - else { - last = a; - a.used = true; - b.used = true; - in1 = !in1; - in2 = !in2; - //if (in1 == in2) { - col1 = a.colinear ? a : undefined; - col2 = b.colinear ? b : undefined; - //} - i++; - j++; - } - if (startP && !(in1 && in2)) { - // segment end - startDir = isCurve.tangentAt(startT); - if (ts3dutils.eq(startT, last.t)) { - startP = undefined; - continue; - } - ts3dutils.assert(ts3dutils.lt(startT, last.t)); - startT > last.t && (startDir = startDir.negated()); - let endDir = isCurve.tangentAt(last.t); - startT > last.t && (endDir = endDir.negated()); - const newEdge = _.createEdge(isCurve, startP, last.p, startT, last.t, undefined, startDir, endDir, "genseg" + _.getGlobalId()); - startP = undefined; - if (handleNewEdge(newEdge, col1 && col1.edge, col2 && col2.edge)) { - handleEndPoint(startA || col1, startB || col2); - handleEndPoint((a && a.used && a) || col1, (b && b.used && b) || col2); - } - } - else if (in1 && in2) { - // new segment just started - startP = last.p; - startDir = last.insideDir; - startT = last.t; - startA = a && a.used ? a : undefined; - startB = b && b.used ? b : undefined; - } - } - if (in1 && in2 && startT !== isCurve.tMax) { - const endT = isCurve.tMax; - startDir = isCurve.tangentAt(startT); - startT > endT && (startDir = startDir.negated()); - let endDir = isCurve.tangentAt(endT); - startT > endT && (endDir = endDir.negated()); - const newEdge = _.createEdge(isCurve, startP, isCurve.at(endT), startT, endT, undefined, startDir, endDir, "genseg" + _.getGlobalId()); - if (handleNewEdge(newEdge, col1 && col1.edge, col2 && col2.edge)) { - handleEndPoint(startA || col1, startB || col2); - } - } - } - face.getAllEdges().forEach((edge) => { - checkedPairs.add(new javasetmap_ts.Pair(edge.getCanon(), face2)); - }); - face2.getAllEdges().forEach((edge) => { - checkedPairs.add(new javasetmap_ts.Pair(edge.getCanon(), face)); - }); - } - edgeISPsWithSurface(isCurve, surface2) { - const face = this; - const surface = face.surface; - const loops = face.holes.concat([face.contour]); - const ps = []; - for (const loop of loops) { - const colinearEdges = loop.map((edge) => edge.curve.isColinearTo(isCurve)); - //const colinearSides = loop.map((edge, edgeIndex) => -1 != colinearEdges[edgeIndex] - // && -sign(isCurves[colinearEdges[edgeIndex]].tangentAt(edge.aT).dot(edge.aDir))) - for (let edgeIndex = 0; edgeIndex < loop.length; edgeIndex++) { - const edge = loop[edgeIndex]; - const nextEdgeIndex = (edgeIndex + 1) % loop.length, nextEdge = loop[nextEdgeIndex]; - //console.log(edge.toSource()) {p:V3(2, -2.102, 0), - if (colinearEdges[edgeIndex]) { - if (isCurve.containsPoint(edge.a)) { - const prevEdgeIndex = (edgeIndex - 1 + loop.length) % loop.length, prevEdge = loop[prevEdgeIndex]; - const curveAT = isCurve.pointT(edge.a); - const colinearOutA = edge.aDir.cross(surface.normalP(edge.a)); - if (!colinearEdges[prevEdgeIndex] && - _.dotCurve2(prevEdge.curve, prevEdge.bT, colinearOutA, -sign(prevEdge.deltaT())) > 0) { - ps.push({ - p: prevEdge.b, - insideDir: edge.aDir.negated(), - t: curveAT, - edge: prevEdge, - edgeT: prevEdge.bT, - colinear: false, - }); - } - ps.push({ - p: edge.a, - insideDir: edge.aDir, - t: curveAT, - edge: edge, - edgeT: edge.aT, - colinear: true, - }); - } - if (isCurve.containsPoint(edge.b)) { - const curveBT = isCurve.pointT(edge.b); - const colinearOutB = edge.bDir.cross(surface.normalP(edge.b)); - if (!colinearEdges[nextEdgeIndex] && - _.dotCurve2(nextEdge.curve, nextEdge.aT, colinearOutB, sign(nextEdge.deltaT())) > 0) { - ps.push({ - p: edge.b, - insideDir: edge.bDir, - t: curveBT, - edge: nextEdge, - edgeT: nextEdge.aT, - colinear: false, - }); - } - ps.push({ - p: edge.b, - insideDir: edge.bDir.negated(), - t: curveBT, - edge: edge, - edgeT: edge.bT, - colinear: true, - }); - } - } - else { - const edgeTs = edge.edgeISTsWithSurface(surface2); - for (const edgeT of edgeTs) { - const p = edge.curve.at(edgeT); - if (!isCurve.containsPoint(p)) - continue; - const curveT = isCurve.pointT(p); - ts3dutils.assert(!isNaN(curveT)); - const insideDir = edge - .tangentAt(edgeT) - .cross(surface.normalP(p)) - .negated(); - const isTangent = isCurve.tangentAt(curveT); - //if(!eq0(insideDir.dot(isTangent))) { - // Edge.edgeISTsWithSurface returns snapped values, so comparison with == is ok: - if (edgeT == edge.bT) { - // endpoint lies on intersection line - if (!colinearEdges[nextEdgeIndex]) { - if (!ts3dutils.eq(curveT, isCurve.tMax)) { - const pointsToInside = this.pointsToInside3(edge.b, isCurve, curveT, 1); - ts3dutils.assert(pointsToInside != _.PointVsFace.ON_EDGE); - if (_.PointVsFace.INSIDE == pointsToInside) { - ps.push({ - p: edge.b, - insideDir: isTangent, - t: curveT, - edge: edge, - edgeT: edge.bT, - colinear: false, - }); - } - } - if (!ts3dutils.eq(curveT, isCurve.tMin)) { - const pointsToInside = this.pointsToInside3(edge.b, isCurve, curveT, -1); - ts3dutils.assert(pointsToInside != _.PointVsFace.ON_EDGE); - if (_.PointVsFace.INSIDE == pointsToInside) { - ps.push({ - p: edge.b, - insideDir: isTangent.negated(), - t: curveT, - edge: edge, - edgeT: edge.bT, - colinear: false, - }); - } - } - //let thisSide = -normVector.dot(edge.bDir) - //if (eq0(thisSide)) { - // // advanced test - // const dir = -sign(edge.deltaT()) - // const iscd = isCurve.at(curveT).to(isCurve.at(curveT + dir * dirFactor * - // eps)).dot(normVector) const ecd = edge.curve.at(edgeT).to(edge.curve.at(edgeT + dir - // * eps)).dot(normVector) thisSide = sign(ecd - iscd) } let nextSide = - // normVector.dot(nextEdge.aDir) if (eq0(nextSide)) { // advanced test const dirFactor - // = sign(snap0(isTangent.dot(nextEdge.curve.tangentAt(nextEdge.aT)))) assert(dirFactor - // !== 0) const dir = sign(nextEdge.deltaT()) const iscd = - // isCurve.at(curveT).to(isCurve.at(curveT + dir * dirFactor * eps)).dot(normVector) - // const ecd = nextEdge.curve.at(nextEdge.aT).to(nextEdge.curve.at(nextEdge.aT + dir * - // eps)).dot(normVector) nextSide = sign(ecd - iscd) } if (nextSide < 0 || thisSide < - // 0) { assert(!eq0(insideDir.dot(isTangent))) // next segment is not colinear and ends - // on different side ps.push({ p: edge.b, insideDir: insideDir, t: curveT, edge: edge, - // edgeT: edge.bT, colinear: false}) } - } - } - else if (edgeT != edge.aT) { - // edge crosses/touches an intersection curve, neither starts nor ends on it - if (ts3dutils.eq0(insideDir.dot(isTangent))) { - const dirFactor = sign(isTangent.dot(edge.curve.tangentAt(edgeT))); - const eps = 1e-4; - for (const dir of [-1, 1]) { - if ((-1 == dir * dirFactor && edgeT == edge.minT) || - (1 == dir * dirFactor && edgeT == edge.maxT) || - (-1 == dir && curveT == isCurve.tMin) || - (1 == dir && curveT == isCurve.tMax)) - continue; - const iscd = isCurve - .at(curveT) - .to(isCurve.at(curveT + dir * eps)) - .dot(insideDir); - const ecd = edge.curve - .at(edgeT) - .to(edge.curve.at(edgeT + dir * dirFactor * eps)) - .dot(insideDir); - if (iscd - ecd > 0) { - ps.push({ - p, - insideDir: isTangent.times(dir), - t: curveT, - edge: edge, - edgeT: edgeT, - colinear: false, - }); - } - } - } - else { - ps.push({ - p: p, - insideDir: insideDir, - t: curveT, - edge: edge, - edgeT: edgeT, - colinear: false, - }); - } - } - //} else { - // - // const dirFactor = sign(isTangent.dot(edge.curve.tangentAt(edgeT))) - // const eps = 1e-4 - // const normVector = surface2.normalP(p) - // for (const dir of [-1, 1]) { - // if (-1 == dir * dirFactor && edgeT == edge.minT || - // 1 == dir * dirFactor && edgeT == edge.maxT || - // -1 == dir && curveT == isCurve.tMin || - // 1 == dir && curveT == isCurve.tMax) continue - // const iscd = isCurve.at(curveT).to(isCurve.at(curveT + dir * eps)).dot(normVector) - // const ecd = edge.curve.at(edgeT).to(edge.curve.at(edgeT + dir * dirFactor * - // eps)).dot(normVector) if (iscd > ecd) { ps.push({p, insideDir: isTangent.times(dir * - // dirFactor), t: curveT, edge: edge, edgeT: edgeT, colinear: false}) } } - // curveVsSurface(isCurve, curveT, p, surface2) } - } - } - } - } - // duplicate 't's are ok, as sometimes a segment needs to stop and start again - // should be sorted so that back facing ones are first - ps.sort((a, b) => a.t - b.t || a.insideDir.dot(isCurve.tangentAt(a.t))); - return ps; - } - transform(m4) { - const mirroring = m4.isMirroring(); - const newEdges = _.Edge.reversePath(this.contour.map((e) => e.transform(m4)), mirroring); - const newHoles = this.holes.map((hole) => _.Edge.reversePath(hole.map((e) => e.transform(m4)), mirroring)); - return new this.constructor(this.surface.transform(m4), newEdges, newHoles, this.name, this.info); - } - transform4(m4) { - const mirroring = m4.isMirroring(); - const newEdges = _.Edge.reversePath(this.contour.map((e) => e.transform4(m4)), mirroring); - const newHoles = this.holes.map((hole) => _.Edge.reversePath(hole.map((e) => e.transform4(m4)), mirroring)); - return new this.constructor(this.surface.transform4(m4), newEdges, newHoles, this.name, this.info); - } - flipped() { - const newEdges = this.contour.map((e) => e.flipped()).reverse(); - const newHoles = this.holes.map((hole) => hole.map((e) => e.flipped()).reverse()); - return new this.constructor(this.surface.flipped(), newEdges, newHoles, this.name, this.info); - } - toString() { - return ("new " + - this.constructor.name + - "(" + - this.surface + - ", [" + - this.contour.map((e) => "\n\t" + e).join() + - "]" + - this.holes.map((hole) => "\n\t\thole: " + hole.join()) + - ")"); - } - toSource() { - return ("new " + - this.constructor.name + - "(" + - this.surface.toSource() + - ", [" + - this.contour.map((e) => "\n\t" + e.toSource() + ",").join("") + - "], [" + - this.holes - .map((hole) => "[" + hole.map((e) => "\n\t" + e.toSource() + ",").join("") + "]") - .join(",") + - "])"); - } - equals(obj) { - return (this == obj || - (Object.getPrototypeOf(this) == Object.getPrototypeOf(obj) && - this.holes.length == obj.holes.length && - _.Edge.loopsEqual(this.contour, obj.contour) && - this.holes.every((hole) => obj.holes.some((hole2) => _.Edge.loopsEqual(hole, hole2))))); - } - hashCode() { - function arrayHashCode(array) { - let hashCode = 0; - for (const val of array) { - hashCode = (hashCode * 31 + val) | 0; - } - return hashCode; - } - function loopHashCode(loop) { - return arrayHashCode(loop.map((edge) => edge.hashCode()).sort(ts3dutils.MINUS)); - } - let hashCode = 0; - hashCode = - (hashCode * 31 + - arrayHashCode(this.holes.map((loop) => loopHashCode(loop)).sort(ts3dutils.MINUS))) | - 0; - hashCode = (hashCode * 31 + loopHashCode(this.contour)) | 0; - hashCode = (hashCode * 31 + this.surface.hashCode()) | 0; - return hashCode; - } - likeFace(face2) { - function loopsLike(a, b) { - return (a.length == b.length && - ts3dutils.arrayRange(0, a.length, 1).some((offset) => a.every((edge, i) => edge.like(b[(offset + i) % a.length])))); - } - ts3dutils.assertInst(Face, face2); - return (this.surface.like(face2.surface) && - this.holes.length == face2.holes.length && - loopsLike(this.contour, face2.contour) && - this.holes.every((hole) => face2.holes.some((hole2) => loopsLike(hole, hole2)))); - } - getAllEdges() { - return this.allEdges; - } - addEdgeLines(mesh) { - ts3dutils.assert(false, "buggy, fix"); - const vertices = this.contour.flatMap((edge) => edge.getVerticesNo0()), mvl = mesh.vertices.length; - for (let i = 0; i < vertices.length; i++) { - mesh.vertices.push(vertices[i]); - mesh.LINES.push(mvl + i, mvl + ((i + 1) % vertices.length)); - } - } - containsPoint(p) { - ts3dutils.assertVectors(p); - return (this.surface.loopContainsPoint(this.contour, p) != _.PointVsFace.OUTSIDE && - !this.holes.some((hole) => this.surface.loopContainsPoint(hole, p) != _.PointVsFace.OUTSIDE)); - } - containsPoint2(p) { - ts3dutils.assertVectors(p); - const contourContainsPoint = this.surface.loopContainsPoint(this.contour, p); - if (contourContainsPoint != _.PointVsFace.INSIDE) - return contourContainsPoint; - for (const hole of this.holes) { - const loopContainsPoint = this.surface.loopContainsPoint(hole, p); - if (loopContainsPoint != _.PointVsFace.OUTSIDE) { - return loopContainsPoint == _.PointVsFace.ON_EDGE - ? _.PointVsFace.ON_EDGE - : _.PointVsFace.OUTSIDE; - } - } - return _.PointVsFace.INSIDE; - } - /** - * - * @param line - * @returns t param of the line if there is an intersection, NaN otherwise - */ - intersectsLine(line) { - ts3dutils.assertInst(_.L3, line); - if (!this.getAABB().intersectsLine(line)) - return NaN; - const containedIntersectionsTs = this.surface - .isTsForLine(line) - .filter((t) => this.containsPoint(line.at(t))); - const nearestPointT = ts3dutils.min(containedIntersectionsTs); - return undefined != nearestPointT ? nearestPointT : NaN; - } - toMesh() { - const mesh = new tsgl.Mesh() - .addIndexBuffer("TRIANGLES") - .addIndexBuffer("LINES") - .addVertexBuffer("normals", "ts_Normal"); - this.addToMesh(mesh); - //mesh.compile() - return mesh; - } - zDirVolume() { - return this.surface.zDirVolume(this.getAllEdges()); - } - calcArea() { - return this.surface.calculateArea(this.getAllEdges()); - } - getLoops() { - return [this.contour, ...this.holes]; - } - getAABB() { - return (this.aabb || - (this.aabb = ts3dutils.AABB.forAABBs(this.contour.map((e) => e.getAABB())))); - } - pointsToInside3(p, curve, curveT, dir) { - const eps = 1e-6; - const normal = this.surface.normalP(p); - const curveTangent = curve.tangentAt(curveT).times(dir); - const up = normal.cross(curveTangent); - const ecd = curve - .at(curveT) - .to(curve.at(curveT + dir * eps)) - .dot(up); - let minValue = Infinity, result, advanced = false; - for (const edge of this.getAllEdges()) { - const aEqP = edge.a.like(p), bEqP = edge.b.like(p); - ts3dutils.assert(aEqP == edge.a.like(p)); - ts3dutils.assert(bEqP == edge.b.like(p)); - if (!aEqP && !bEqP) - continue; - const edgeTangent = aEqP ? edge.aDir : edge.bDir.negated(); - const angle = curveTangent.angleRelativeNormal(edgeTangent, normal); - if (ts3dutils.eq0(angle)) { - if (curve.isColinearTo(edge.curve)) { - return _.PointVsFace.ON_EDGE; - } - const edgeT = aEqP ? edge.aT : edge.bT; - const edgeDir = (aEqP ? 1 : -1) * sign(edge.deltaT()); - const iscd = edge.curve.diff(edgeT, edgeDir * eps).dot(up); - //const iscd = edge.curve.at(edgeT).to(curve.at(edgeT + edgeDir * eps)).dot(up) - const diff = iscd - ecd; - if (diff > 0 && (!advanced || diff < minValue)) { - advanced = true; - minValue = diff; - result = aEqP ? _.PointVsFace.OUTSIDE : _.PointVsFace.INSIDE; - } - } - else if (!advanced) { - const angle2 = (angle + ts3dutils.TAU) % ts3dutils.TAU; - if (angle2 < minValue) { - minValue = angle2; - result = aEqP ? _.PointVsFace.OUTSIDE : _.PointVsFace.INSIDE; - } - } - } - if (result == undefined) - throw new Error(); - return result; - } - pointsToInside2(p, dir) { - return this.pointsToInside3(p, _.L3.anchorDirection(p, dir), 0, 1); - //const normal = this.surface.normalP(p) - //let minAngle = Infinity, inOut = false - //function test(v, b) { - // const angle = (dir.angleRelativeNormal(v, normal) + TAU + NLA_PRECISION / 2) % TAU - // if (angle <= 2 * NLA_PRECISION) { - // return true - // } - // if (angle < minAngle) { - // minAngle = angle - // inOut = b - // } - //} - //for (const edge of this.getAllEdges()) { - // assert(edge.a.equals(p) || !edge.a.like(p)) - // assert(edge.b.equals(p) || !edge.b.like(p)) - // if (edge.a.equals(p) && test(edge.aDir, false)) return PointVsFace.ON_EDGE - // if (edge.b.equals(p) && test(edge.bDir.negated(), true)) return PointVsFace.ON_EDGE - //} - //return inOut ? PointVsFace.INSIDE : PointVsFace.OUTSIDE - } -} -class PlaneFace extends Face { - constructor(p, contour, holes, name, info) { - ts3dutils.assert(p instanceof _.P3 || p instanceof _.PlaneSurface); - super(p instanceof _.P3 ? new _.PlaneSurface(p) : p, contour, holes, name, info); - } - static forVertices(planeSurface, vs, ...holeVss) { - const _planeSurface = planeSurface instanceof _.P3 ? new _.PlaneSurface(planeSurface) : planeSurface; - ts3dutils.assert(ts3dutils.isCCW(vs, _planeSurface.plane.normal1), "isCCW(vs, planeSurface.plane.normal1)"); - const edges = _.StraightEdge.chain(vs); - holeVss.forEach((vs) => ts3dutils.assert(ts3dutils.doubleSignedArea(vs, _planeSurface.plane.normal1) >= 0, "doubleSignedArea(vs, planeSurface.plane.normal1) >= 0")); - const holes = holeVss.map((hvs) => _.StraightEdge.chain(hvs)); - return new PlaneFace(planeSurface, edges, holes); - } - addToMesh(mesh) { - const mvl = mesh.vertices.length; - const normal = this.surface.plane.normal1; - const vertices = this.contour.flatMap((edge) => edge.getVerticesNo0()); - for (let i = 0; i < vertices.length; i++) { - mesh.LINES.push(mvl + i, mvl + ((i + 1) % vertices.length)); - } - const holeStarts = []; - this.holes.forEach((hole) => { - holeStarts.push(vertices.length); - vertices.push(...hole.flatMap((edge) => edge.getVerticesNo0())); - }); - const triangles = _.triangulateVertices(normal, vertices, holeStarts).map((index) => index + mvl); - Array.prototype.push.apply(mesh.vertices, vertices); - Array.prototype.push.apply(mesh.TRIANGLES, triangles); - Array.prototype.push.apply(mesh.normals, ts3dutils.arrayFromFunction(vertices.length, () => normal)); - } - intersectsLine(line) { - ts3dutils.assertInst(_.L3, line); - const lambda = line.isTWithPlane(this.surface.plane); - if (!Number.isFinite(lambda)) { - return NaN; - } - const inside = this.containsPoint(line.at(lambda)); - return inside ? lambda : NaN; - } - //intersectPlaneFace(face2: PlaneFace, - // thisBrep: BRep, - // face2Brep: BRep, - // faceMap: Map, - // thisEdgePoints: CustomMap, - // otherEdgePoints: CustomMap, - // checkedPairs: CustomSet>) { - // assertInst(CustomMap, thisEdgePoints, otherEdgePoints) - // - // function hasPair(a: Equalable, b: Equalable) { - // return checkedPairs.has(new Pair(a, b)) - // } - // function addPair(a: Equalable, b: Equalable) { - // return checkedPairs.add(new Pair(a, b)) - // } - // - // /** - // * @param newEdge generated segment - // * @param col1 if newEdge is colinear to an edge of this, the edge in question - // * @param col2 same for face2 - // */ - // function handleNewEdge(newEdge: StraightEdge, col1: Edge, col2: Edge) { - // if (!col1 && !col2) { - // mapPush(faceMap, face, newEdge) - // mapPush(faceMap, face2, newEdge.flipped()) - // return true - // } - // function handleEdgeInFace(col1, col2, face, face2, thisBrep, face2Brep, coplanarSameIsInside: boolean, - // has, add) { if (col1 && !col2) { if (hasPair(col1.getCanon(), face2)) return //add(col1.getCanon(), face2) - // const face2Plane = face2.surface.plane // NB: a new edge is inserted even though it may be the same as an old - // one // however it indicates that it intersects the other volume here, i.e. the old edge cannot // be counted as - // 'inside' for purposes of reconstitution thisBrep.edgeFaces.get(col1.getCanon()).forEach(faceInfo => { //const - // dot = snap0(face2Plane.normal1.dot(faceInfo.inside)) //if (dot == 0 ? !coplanarSameIsInside : dot < 0) { const - // pointsInsideFace = fff(faceInfo, face2.surface) const edgeInside = pointsInsideFace == INSIDE || - // !coplanarSameIsInside && pointsInsideFace == COPLANAR_SAME const pushEdge = - // (faceInfo.edge.aDir.like(newEdge.aDir)) ? newEdge : newEdge.flipped() - // assert(faceInfo.edge.aDir.like(pushEdge.aDir)) edgeInside && mapPush(faceMap, faceInfo.face, pushEdge) }) const - // newEdgeInside = face2Plane.normal1.cross(newEdge.aDir) const sVEF1 = splitsVolumeEnclosingFaces(thisBrep, - // col1.getCanon(), newEdgeInside, face2Plane.normal1) let addNewEdge, addNewEdgeFlipped if (addNewEdge = sVEF1 == - // INSIDE || coplanarSameIsInside && sVEF1 == COPLANAR_SAME) { mapPush(faceMap, face2, newEdge) } const sVEF2 = - // splitsVolumeEnclosingFaces(thisBrep, col1.getCanon(), newEdgeInside.negated(), face2Plane.normal1) if - // (addNewEdgeFlipped = sVEF2 == INSIDE || coplanarSameIsInside && sVEF2 == COPLANAR_SAME) { mapPush(faceMap, - // face2, newEdge.flipped()) } if (addNewEdge || addNewEdgeFlipped || sVEF1 == COPLANAR_SAME && sVEF2 == INSIDE || - // sVEF2 == COPLANAR_SAME && sVEF1 == INSIDE) { return true } } } const c1 = handleEdgeInFace(col1, col2, face, - // face2, thisBrep, face2Brep, false, hasPair, addPair) const c2 = handleEdgeInFace(col2, col1, face2, face, - // face2Brep, thisBrep, true, (a, b) => hasPair(b, a), (a, b) => addPair(b, a)) if (c1 || c2) return true if (col1 - // && col2) { if (hasPair(col1.getCanon(), col2.getCanon())) return addPair(col1.getCanon(), col2.getCanon()) - // function handleColinearEdgeFaces(col1, col2, thisBrep, face2Brep, coplanarSameIsInside: boolean, thisEdgePoints, - // has, add) { // not entirely sure for what i had the dirInsides in? //const aDirNegatedInside = - // (newEdge.a.like(col2.a) || newEdge.a.like(col2.b)) && splitsVolumeEnclosingCone(face2Brep, newEdge.a, - // newEdge.aDir.negated()) == INSIDE //const bDirInside = (newEdge.b.like(col2.a) || newEdge.b.like(col2.b)) && - // splitsVolumeEnclosingCone(face2Brep, newEdge.b, newEdge.bDir) == INSIDE - // thisBrep.edgeFaces.get(col1.getCanon()).forEach(faceInfo => { const sVEF = splitsVolumeEnclosingFaces(face2Brep, - // col2.getCanon(), faceInfo.inside, faceInfo.normalAtCanonA) const edgeInside = sVEF == INSIDE || - // coplanarSameIsInside && sVEF == COPLANAR_SAME const pushEdge = (faceInfo.edge.aDir.like(newEdge.aDir)) ? newEdge - // : newEdge.flipped() edgeInside && mapPush(faceMap, faceInfo.face, pushEdge) }) } handleColinearEdgeFaces(col1, - // col2, thisBrep, face2Brep, true, thisEdgePoints, hasPair, addPair) handleColinearEdgeFaces(col2, col1, - // face2Brep, thisBrep, false, otherEdgePoints, (a, b) => hasPair(b, a), (a, b) => addPair(b, a)) } } // what - // needs to be generated: new edges on face // points on edges where they are cut by faces so that sub edges will - // be generated for loops // points on ends of edges where the edge will be an edge in the new volume where it goes - // from A to B // you don't want thos to be marked as 'inside', otherwise invalid faces will be added // if - // a face cuts a corner, nothings needs to be done, as that alone does not limit what adjacent faces will be - // function handleEndPoint(a: IntersectionPointInfo, b: IntersectionPointInfo, newEdge: Edge) { // ends in the - // middle of b's face if (a && !b) { if (!a.colinear && a.edgeT != a.edge.aT && a.edgeT != a.edge.bT) { - // mapPush(thisEdgePoints, a.edge.getCanon(), a) assert(a.edge.isValidT(a.edgeT)) } // else colinear segment ends - // in middle of other face, do nothing } // ends in the middle of a's face if (b && !a) { if (!b.colinear && - // b.edgeT != b.edge.aT && b.edgeT != b.edge.bT) { mapPush(otherEdgePoints, b.edge.getCanon(), b) - // assert(b.edge.isValidT(b.edgeT)) } // else colinear segment ends in middle of other face, do nothing } if (a && - // b) { // if a or b is colinear the correct points will already have been added to the edge by handleNewEdge // - // segment starts/ends on edge/edge intersection function foo(a, b, face, face2, thisPlane, face2Plane, thisBrep, - // face2Brep, first, thisEdgePoints) { if (!a.colinear && a.edgeT != a.edge.aT && a.edgeT != a.edge.bT) { if - // (!hasPair(a.edge.getCanon(), b.edge.getCanon())) { addPair(a.edge.getCanon(), b.edge.getCanon()) // ends on a, - // on colinear segment b bT != a.edge.bT && // b can be colinear, so edgeT == aT is possible if (a.p.like(b.edge.a) - // || a.p.like(b.edge.b)) { const corner = a.p.like(b.edge.a) ? b.edge.a : b.edge.b // face2brep corner on edge - // const sVEC1 = splitsVolumeEnclosingCone(face2Brep, corner, a.edge.aDir) const sVEC2 = - // splitsVolumeEnclosingCone(face2Brep, corner, a.edge.aDir.negated()) // if either of these return - // ALONG_EDGE_OR_PLANE, then the breps share a colinear edge if (INSIDE == sVEC1 || INSIDE == sVEC2) { - // mapPush(thisEdgePoints, a.edge.getCanon(), a) assert(a.edge.isValidT(a.edgeT)) } } else { // edge / edge center - // intersection const aEdgeDir = a.edge.tangentAt(a.edgeT) const bEdgeDir = b.edge.tangentAt(b.edgeT) const - // testVector = aEdgeDir.rejectedFrom(bEdgeDir) assert(!testVector.likeO()) const sVEF1 = - // splitsVolumeEnclosingFaces(face2Brep, b.edge.getCanon()Vector, thisPlane.normal1) const sVEF2 = - // splitsVolumeEnclosingFaces(face2Brep, b.edge.getCanon()Vector.negated(), thisPlane.normal1) if (INSIDE == - // sVEF1 || INSIDE == sVEF2) { mapPush(thisEdgePoints, a.edge.getCanon(), a) assert(a.edge.isValidT(a.edgeT)) } } } - // } } foo(a, b, face, face2, thisPlane, face2Plane, thisBrep, face2Brep, true, thisEdgePoints) foo(b, a, face2, - // face, face2Plane, thisPlane, face2Brep, thisBrep, false, otherEdgePoints) } } assertInst(PlaneFace, face2) - // const face: PlaneFace = this // get intersection const thisPlane = this.surface.plane, face2Plane = - // face2.surface.plane if (thisPlane.isParallelToPlane(face2Plane)) { if (thisPlane.like(face2Plane)) { // normal1 - // same and same location in space // addLikeSurfaceFaces(likeSurfaceFaces, this, face2) } return } const isLine = - // L3.fromPlanes(thisPlane, face2Plane) // get intersections of newCurve with other edges of face and face2 const - // ps1 = planeFaceEdgeISPsWithPlane(face, isLine, face2Plane) const ps2 = planeFaceEdgeISPsWithPlane(face2, isLine, - // thisPlane) if (ps1.length == 0 || ps2.length == 0) { // faces to not intersect return } let col1: - // IntersectionPointInfo, col2: IntersectionPointInfo let in1 = false, in2 = false let i = 0, j = 0, last let - // startP, startDir, startT, startA, startB while (i < ps1.length || j < ps2.length) { assert(i <= ps1.length) - // assert(j <= ps2.length) const a = ps1[i], b = ps2[j] assert(a || b) if (j == ps2.length || i < ps1.length && - // lt(a.t, b.t)) { last = a in1 = !in1 a.used = true in1 && (col1 = a.colinear && a) i++ } else if (i == ps1.length - // || gt(a.t, b.t)) { last = b in2 = !in2 b.used = true in2 && (col2 = b.colinear && b) j++ } else { // TODO: this - // will break if 3 points on the same t last = a in1 = !in1 in2 = !in2 //if (in1 == in2) { a.used = true b.used = - // true in1 && (col1 = a.colinear && a) in2 && (col2 = b.colinear && b) //} i++ j++ } if (startP && !(in1 && in2)) - // { // segment end const newEdge = new StraightEdge(isLine, startP, last.p, startT, last.t, undefined, 'genseg' + - // getGlobalId()) startP = undefined last.used = true if (handleNewEdge(newEdge, col1 && col1.edge, col2 && - // col2.edge)) { handleEndPoint(startA || col1, startB || col2, newEdge) handleEndPoint(a && a.used && a || col1, b - // && b.used && b || col2, newEdge) } } else if (in1 && in2) { // new segment just started startP = last.p startDir - // = last.insideDir startT = last.t startA = a && a.used && a startB = b && b.used && b } if (!in1 && a && last == - // a && a.colinear) { checkedPairs.add(new Pair(a.edge.getCanon(), face2)) } if (!in2 && b && (last == b || b.used) - // && b.colinear) { checkedPairs.add(new Pair(b.edge.getCanon(), face)) } } } - withHole(holeEdges) { - return new PlaneFace(this.surface, this.contour, [holeEdges]); - } - pointsToInside(p, dir) { - return this.containsPoint2(p.plus(dir.times(ts3dutils.NLA_PRECISION * 8))); - } - edgeISPsWithPlane(isLine, plane2) { - const face = this; - ts3dutils.assert(face.surface.plane.containsLine(isLine)); - ts3dutils.assert(plane2.containsLine(isLine)); - const plane = face.surface.plane; - const ps = []; - const loops = [face.contour].concat(face.holes); - loops.forEach((loop) => { - const colinearEdges = loop.map((edge) => edge.colinearToLine(isLine) && -sign(edge.aDir.dot(isLine.dir1))); - const isLineOut = isLine.dir1.cross(plane.normal1); - loop.forEach((edge, edgeIndex, edges) => { - const nextEdgeIndex = (edgeIndex + 1) % edges.length, nextEdge = edges[nextEdgeIndex], colinearEdge = colinearEdges[edgeIndex]; - //console.log(edge.toSource()) {p:V3(2, -2.102, 0), - if (colinearEdge) { - // edge colinear to intersection line - const curveAT = isLine.pointT(edge.a), curveBT = isLine.pointT(edge.b); - // add interval for colinear segment - ps.push({ - p: edge.a, - insideDir: edge.aDir, - t: curveAT, - edge: edge, - edgeT: edge.aT, - colinear: true, - }, { - p: edge.b, - insideDir: edge.bDir.negated(), - t: curveBT, - edge: edge, - edgeT: edge.bT, - colinear: true, - }); - // open next interval if necessary - const nextSide = colinearEdges[nextEdgeIndex] || - _.dotCurve2(nextEdge.curve, nextEdge.aT, isLineOut, nextEdge.deltaTSign()); - if (colinearEdge * nextSide < 0) { - // side changes - ps.push({ - p: nextEdge.a, - insideDir: edge.bDir, - t: curveBT, - edge: nextEdge, - edgeT: nextEdge.aT, - colinear: false, - }); - } - } - else { - // not necessarily a straight edge, so multiple intersections are possible - const edgeTs = edge.edgeISTsWithPlane(plane2); - ts3dutils.assert(edgeTs.every((t) => plane2.containsPoint(edge.curve.at(t))), edgeTs); - for (const edgeT of edgeTs) { - if (edgeT == edge.bT) { - // endpoint lies on intersection line - const side = _.dotCurve2(edge.curve, edge.bT, isLineOut, -edge.deltaTSign()); - const nextSide = colinearEdges[nextEdgeIndex] || - _.dotCurve2(nextEdge.curve, nextEdge.aT, isLineOut, nextEdge.deltaTSign()); - if (side * nextSide < 0) { - // next segment is not colinear and ends on different side - ps.push({ - p: edge.b, - insideDir: plane2.normal1.negated(), - t: isLine.pointT(edge.b), - edge: edge, - edgeT: edge.bT, - colinear: false, - }); - } - } - else if (edgeT != edge.aT) { - // edge crosses intersection line, neither starts nor ends on it - const p = edge.curve.at(edgeT); - ts3dutils.assert(plane2.containsPoint(p), edge.toString(), p, edgeT, plane2.distanceToPoint(p)); - ts3dutils.assert(isLine.containsPoint(p), edge.toString(), p, edgeT, isLine.distanceToPoint(p)); - const insideDir = plane2.normal1.negated(); - ps.push({ - p: p, - insideDir: insideDir, - t: isLine.pointT(p), - edge: edge, - edgeT: edgeT, - colinear: false, - }); - } - } - } - }); - }); - // duplicate 't's are ok, as sometimes a segment needs to stop and start again - // should be sorted so that back facing ones are first - ps.sort((a, b) => a.t - b.t || a.insideDir.dot(isLine.dir1)); - return ps; - } -} -class RotationFace extends Face { - constructor(rot, contour, holes, name, info) { - super(rot, contour, holes, name, info); - } - static loopDoesNotCrossPlane(loop, seamPlane) { - let side = 0; - // returns true if d is on the other side as previous calls - function checkSide(d) { - if (side == 0) { - side = d; - } - else { - return !side || side * d < 0; - } - return false; - } - for (const edge of loop) { - const ts = edge.edgeISTsWithPlane(seamPlane); - if (ts.length == 0) { - if (!(edge.curve instanceof _.L3) && - checkSide(seamPlane.distanceToPointSigned(edge.a))) - return false; - } - else { - for (const t of ts) { - // TODO: this part probably should be in a separate function - // check 'backwards' only if if aT != t - if (edge.aT != t) { - if (checkSide(_.dotCurve2(edge.curve, t, seamPlane.normal1, -edge.deltaTSign()))) - return false; - } - if (edge.bT != t) { - if (checkSide(_.dotCurve2(edge.curve, t, seamPlane.normal1, edge.deltaTSign()))) - return false; - } - } - } - } - return true; - } - getAABB() { - if (this.aabb) - return this.aabb; - this.aabb = ts3dutils.AABB.forAABBs(this.contour.map((e) => e.getAABB())); - this.aabb.addPoints(this.surface.getExtremePoints().filter((p) => this.containsPoint(p))); - return this.aabb; - } - unrollLoop(edgeLoop) { - const vs = []; - const uvP = this.surface.uvPFunc(); - const verticesNo0s = edgeLoop.map((edge) => edge.getVerticesNo0()); - const startEdgeIndex = verticesNo0s.findIndex((edgeVertices) => !ts3dutils.eq(uvP(edgeVertices[0]).x, Math.PI)); - ts3dutils.assert(-1 != startEdgeIndex); - // console.log(startEdgeIndex) - for (let i = 0; i < edgeLoop.length; i++) { - const edgeIndex = (i + startEdgeIndex) % edgeLoop.length; - for (let j = 0; j < verticesNo0s[edgeIndex].length; j++) { - const p = verticesNo0s[edgeIndex][j]; - const localP = uvP(p); - // console.log(hint, p.sce, localP.sce) - vs.push(localP); - } - } - edgeLoop.forEach((edge) => { - edge.getVerticesNo0().forEach((p) => { - vs.push(uvP(p)); - }); - }); - console.log("vs\n", vs.join("\n"), vs.length); - return vs; - } - /** - * f1 cos t + f2 sin t - * tan(phi) = sin / cos - * = (f1x cos t + f2x sin t) / (f1y cos t + f2y sin t) - * - * = (-f1x sin t + f2x cos t) / (-f1y sin t + f2y cos t) - */ - unrollEllipsoidLoops(edgeLoops) { - const verticesUV = [], vertices = [], loopStarts = []; - const ellipsoid = this.surface; - const ptpf = ellipsoid.uvPFunc(); - const testDegeneratePoint = ellipsoid instanceof _.EllipsoidSurface - ? (nextStart) => nextStart.like(ellipsoid.center.plus(ellipsoid.f3)) || - nextStart.like(ellipsoid.center.minus(ellipsoid.f3)) - : (nextStart) => nextStart.like(this.surface.center); - for (const edgeLoop of edgeLoops) { - loopStarts.push(verticesUV.length); - // console.log(startEdgeIndex) - for (let i = 0; i < edgeLoop.length; i++) { - const ipp = (i + 1) % edgeLoop.length; - const verticesNo0 = edgeLoop[i].getVerticesNo0(); - vertices.push(...verticesNo0); - verticesUV.push(...verticesNo0.map((v) => ptpf(v))); - const nextStart = edgeLoop[ipp].a; - //console.log('BLAH', nextStart.str, ellipsoid.center.plus(ellipsoid.f3).str) - if (testDegeneratePoint(nextStart)) { - const bDirLC = ellipsoid.matrixInverse.transformVector(edgeLoop[i].bDir), aDirLC = ellipsoid.matrixInverse.transformVector(edgeLoop[ipp].aDir); - const inAngle = Math.atan2(-bDirLC.y, -bDirLC.x); - const outAngle = Math.atan2(aDirLC.y, aDirLC.x); - const stLast = verticesUV.pop(); - verticesUV.push(new ts3dutils.V3(inAngle, stLast.y, 0), new ts3dutils.V3(outAngle, stLast.y, 0)); - vertices.push(ts3dutils.getLast(vertices)); - } - verticesUV.forEach(({ u, v }) => { - ts3dutils.assert(isFinite(u)); - ts3dutils.assert(isFinite(v)); - }); - } - } - let normals; - if (this.surface instanceof _.EllipsoidSurface) { - normals = vertices.map((v) => ellipsoid.normalP(v)); - } - else { - const normalUV = ellipsoid.normalUVFunc(); - normals = verticesUV.map(({ u, v }) => normalUV(u, v)); - } - ts3dutils.assert(vertices.length == vertices.length); - //console.log(verticesUV.map(v => v.str).join('\n')) - return { - verticesUV: verticesUV, - vertices: vertices, - normals: normals, - loopStarts: loopStarts, - }; - } - unrollCylinderLoops(loops) { - const vertexLoops = loops.map((loop) => loop.flatMap((edge) => edge.getVerticesNo0())); - const surface = this.surface; - const vertices = ts3dutils.concatenated(vertexLoops); - // this.unrollLoop(loop).map(v => new V3(v.x / uStep, v.y / vStep, 0))) - const loopStarts = vertexLoops.reduce((arr, loop) => (arr.push(ts3dutils.getLast(arr) + loop.length), arr), [0]); - const uvPFunc = surface.uvPFunc(); - const verticesUV = vertices.map((v) => uvPFunc(v)); - const uvN = surface.normalUVFunc(); - const normals = verticesUV.map(({ u, v }) => uvN(u, v)); - return { - verticesUV: verticesUV, - vertices: vertices, - normals: normals, - loopStarts: loopStarts, - }; - } - /** - * at(s, t) = new V3(s cos t, s sin t, t + ) - * - * x = 0 - * - * s cos t = 0 - * ==> s = 0 || cos t = 0 - * ==> L3.Z || V3(0, +-s, k * 2 pi) - * - * x = c - * s cos t = c - * ==> V3(c, c sin t / cos t = c tan t, t) - * ==> V3(c, c t, arctan t) - * - * - * x . n = w - * s cos t nx + s sin t ny + t nz = w - * s = (w - t nz) / (cos t nx + sub t ny) - * ==> V3( - * cos t (w - t nz) / (cos t nx + sin t ny) - * sin t (w - t nz) / (cos t nx + sin t ny) - * t) - * - * ==> V3( - * (w - z arctan t) / (x + t y) - * (w - z arctan t) / (y + x / t) - * arctan t) - * - * - * - */ - addToMesh(mesh, uStep = this.surface.uStep, vStep = this.surface.vStep) { - ts3dutils.assertf(() => uStep > 0 && vStep > 0, uStep, vStep, "Surface: " + this.surface); - const triangles = []; - const pMN = (m, n) => this.surface.pUVFunc()(m * uStep, n * vStep); - const normalMN = (m, n) => this.surface.normalUVFunc()(m * uStep, n * vStep); - const loops = this.getLoops(); - const { vertices, verticesUV, normals, loopStarts } = this.surface instanceof _.EllipsoidSurface || - this.surface instanceof _.ConicSurface - ? this.unrollEllipsoidLoops(loops) - : this.unrollCylinderLoops(loops); - loopStarts.push(vertices.length); - const verticesMN = verticesUV.map(({ u, v }) => new ts3dutils.V3(u / uStep, v / vStep, 0)); - for (let vertexLoopIndex = 0; vertexLoopIndex < loops.length; vertexLoopIndex++) { - const vertexLoopStart = loopStarts[vertexLoopIndex]; - const vertexLoopLength = loopStarts[vertexLoopIndex + 1] - vertexLoopStart; - const base = mesh.vertices.length + loopStarts[vertexLoopIndex]; - for (let i = 0; i < vertexLoopLength; i++) { - mesh.LINES.push(base + i, base + ((i + 1) % vertexLoopLength)); - } - } - ts3dutils.disableConsole(); - let minM = Infinity, maxM = -Infinity, minN = Infinity, maxN = -Infinity; - //console.log('surface', this.surface.str) - //console.log(verticesMN) - //drPs.push(...verticesMN.map((v, i) => ({p: vertices[i], text: `${i} uv: ${v.toString(x => round10(x, - // -4))}`}))) - verticesMN.forEach(([m, n]) => { - ts3dutils.assert(isFinite(m)); - ts3dutils.assert(isFinite(n)); - minM = min(minM, m); - maxM = max(maxM, m); - minN = min(minN, n); - maxN = max(maxN, n); - }); - if (_.ParametricSurface.is(this.surface)) ; - const mOffset = floor(minM + ts3dutils.NLA_PRECISION), nOffset = floor(minN + ts3dutils.NLA_PRECISION); - const mRes = ceil(maxM - ts3dutils.NLA_PRECISION) - mOffset, nRes = ceil(maxN - ts3dutils.NLA_PRECISION) - nOffset; - console.log(uStep, vStep, mRes, nRes); - if (mRes == 1 && nRes == 1) { - // triangulate this face as if it were a plane - const polyTriangles = _.triangulateVertices(ts3dutils.V3.Z, verticesMN, loopStarts.slice(1, 1 + this.holes.length)); - triangles.push(...polyTriangles); - } - else { - const partss = new Array(mRes * nRes); - function fixUpPart(part, baseM, baseN) { - ts3dutils.assert(baseM < mRes && baseN < nRes, `${baseM}, ${baseN}, ${mRes}, ${nRes}`); - console.log("complete part", part, baseM, baseN); - //console.trace() - ts3dutils.assert(part.length); - const cellM = baseM + mOffset, cellN = baseN + nOffset; - for (const index of part) { - ts3dutils.assert(ts3dutils.le(cellM, verticesMN[index].x) && - ts3dutils.le(verticesMN[index].x, cellM + 1), `${index} ${verticesMN[index].str} ${cellM} ${cellM}`); - ts3dutils.assert(ts3dutils.le(cellN, verticesMN[index].y) && - ts3dutils.le(verticesMN[index].y, cellN + 1)); - } - const pos = baseN * mRes + baseM; - (partss[pos] || (partss[pos] = [])).push(part); - //const outline = partss[pos] || (partss[pos] = [minM + baseM * uStep, minN + baseN * vStep, minM + - // (baseM + 1) * uStep, minN + (baseN + 1) * vStep]) - } - // 'some' instead of forEach so we can return out of the entire function if this.edges crosses no borders - // and - for (let vertexLoopIndex = 0; vertexLoopIndex < loops.length; vertexLoopIndex++) { - let part = undefined; - let firstPart = undefined; - let firstPartBaseM = -1; - let firstPartBaseN = -1; - let lastBaseM = -1, lastBaseN = -1; - let partCount = 0; - const vertexLoopStart = loopStarts[vertexLoopIndex]; - const vertexLoopLength = loopStarts[vertexLoopIndex + 1] - vertexLoopStart; - for (let vlvi = 0; vlvi < vertexLoopLength; vlvi++) { - const vx0index = vertexLoopStart + vlvi, vx0 = verticesMN[vx0index]; - const vx1index = vertexLoopStart + ((vlvi + 1) % vertexLoopLength), vx1 = verticesMN[vx1index]; - //console.log('dask', vx0index, vx1index) - const vx01 = vx0.to(vx1); - ts3dutils.assert(vx0); - const di = vx01.x, dj = vx01.y; - let vxIndex = vx0index, vx = vx0, currentT = 0; - let whileLimit = 400; - while (--whileLimit) { - // points which are on a grid line are assigned to the cell into which they are going (+ - // NLA_PRECISION * sign(di)) if they are parallel to the gridline (eq0(di)), they belong the - // the cell for which they are a CCW boundary - const baseM = floor(vx.u + (!ts3dutils.eq0(di) ? sign(di) : -sign(dj)) * ts3dutils.NLA_PRECISION) - - mOffset; - const baseN = floor(vx.v + (!ts3dutils.eq0(dj) ? sign(dj) : sign(di)) * ts3dutils.NLA_PRECISION) - - nOffset; - ts3dutils.assert(baseM < mRes && baseN < nRes, `${baseM}, ${baseN}, ${mRes}, ${nRes}`); - // figure out the next intersection with a gridline: - // iNext is the positive horizontal distance to the next vertical gridline - const iNext = ceil(sign(di) * vx.u + ts3dutils.NLA_PRECISION) - sign(di) * vx.u; - const jNext = ceil(sign(dj) * vx.v + ts3dutils.NLA_PRECISION) - sign(dj) * vx.v; - const iNextT = currentT + iNext / abs(di); - const jNextT = currentT + jNext / abs(dj); - //console.log(vxIndex, vx.str, 'vij', vx.u, vx.v, 'd', di, dj, 'ijNext', iNext, jNext, 'nextT', - // iNextT, jNextT) - if (lastBaseM != baseM || lastBaseN != baseN) { - if (part) { - if (!firstPart) { - firstPart = part; - firstPartBaseM = lastBaseM; - firstPartBaseN = lastBaseN; - } - else { - partCount++; - fixUpPart(part, lastBaseM, lastBaseN); - } - } - part = [vxIndex]; - } - lastBaseM = baseM; - lastBaseN = baseN; - currentT = min(iNextT, jNextT); - if (ts3dutils.ge(currentT, 1)) { - //console.log('breaking ', vx1index) - part.push(vx1index); - break; - } - else { - const nextPoint = vx0.lerp(vx1, currentT); - const nextPointIndex = addVertex(nextPoint.x, nextPoint.y); - //console.log('pushing ', nextPointIndex) - part.push(nextPointIndex); - vx = nextPoint; - vxIndex = nextPointIndex; - } - } - ts3dutils.assert(whileLimit, "whileLimit"); - } - if (0 == partCount) { - // complete loop - ts3dutils.assert(false, "found a hole, try increasing resolution"); - } - // at this point, the firstPart hasn't been added, and the last part also hasn't been added - // either they belong to the same cell, or not - if (firstPartBaseM == lastBaseM && firstPartBaseN == lastBaseN) { - part.pop(); - fixUpPart(part.concat(firstPart), lastBaseM, lastBaseN); - } - else { - fixUpPart(firstPart, firstPartBaseM, firstPartBaseN); - fixUpPart(part, lastBaseM, lastBaseN); - } - console.log("firstPart", firstPart); - } - console.log("calculated parts", partss); - const fieldVertexIndices = new Array((mRes + 1) * (nRes + 1)); - function addVertex(m, n) { - verticesMN.push(new ts3dutils.V3(m, n, 0)); - normals.push(normalMN(m, n)); - return vertices.push(pMN(m, n)) - 1; - } - function getGridVertexIndex(i, j) { - const index = j * (mRes + 1) + i; - return (fieldVertexIndices[index] || - (fieldVertexIndices[index] = addVertex(i + mOffset, j + nOffset))); - } - for (let col = 0; col < mRes; col++) { - let inside = false; - for (let row = 0; row < nRes; row++) { - const pos = row * mRes + col; - const fieldU = mOffset + col, fieldV = nOffset + row; - const parts = partss[pos]; - if (!parts) { - if (inside) { - tsgl.pushQuad(triangles, false, getGridVertexIndex(col, row), getGridVertexIndex(col + 1, row), getGridVertexIndex(col, row + 1), getGridVertexIndex(col + 1, row + 1)); - } - } - else { - // assemble the field with segments in in - function opos(index) { - const p = verticesMN[index], u1 = p.x - fieldU, v1 = p.y - fieldV; - ts3dutils.assert(-ts3dutils.NLA_PRECISION < u1 && - u1 < 1 + ts3dutils.NLA_PRECISION && - -ts3dutils.NLA_PRECISION < v1 && - v1 < 1 + ts3dutils.NLA_PRECISION, "oob u1 v1 " + - u1 + - " " + - v1 + - " " + - index + - " " + - p.str + - "IF THIS FAILS check canonSeamU is correct"); - return v1 < u1 ? u1 + v1 : 4 - u1 - v1; - } - while (parts.length) { - const outline = []; - const startPart = parts[0]; - ts3dutils.assert(startPart.length > 0); - let currentPart = startPart; - do { - outline.push(...currentPart); - const currentPartEndOpos = opos(ts3dutils.getLast(currentPart)); - const nextPartIndex = ts3dutils.indexWithMax(parts, (part) => -ts3dutils.mod(opos(part[0]) - currentPartEndOpos, 4)); - const nextPart = ts3dutils.bagRemoveIndex(parts, nextPartIndex); - let currentOpos = currentPartEndOpos; - const nextPartStartOpos = opos(nextPart[0]) > currentOpos - ? opos(nextPart[0]) - : opos(nextPart[0]) + 4; - let nextOpos = ceil(currentOpos + ts3dutils.NLA_PRECISION); - let flipping = ts3dutils.eq0(((currentOpos + ts3dutils.NLA_PRECISION) % 1) - ts3dutils.NLA_PRECISION); - //inside = inside != (!eq0(currentOpos % 1) && currentOpos % 2 < 1) - while (ts3dutils.lt(nextOpos, nextPartStartOpos)) { - switch (nextOpos % 4) { - case 0: - outline.push(getGridVertexIndex(col, row)); - break; - case 1: - inside = inside != flipping; - outline.push(getGridVertexIndex(col + 1, row)); - break; - case 2: - outline.push(getGridVertexIndex(col + 1, row + 1)); - break; - case 3: - inside = inside != flipping; - outline.push(getGridVertexIndex(col, row + 1)); - break; - } - flipping = true; - nextOpos++; - } - // if the next loop would have completed a top or bottom segment - inside = - inside != - (flipping && - nextOpos % 2 == 1 && - ts3dutils.eq(nextOpos, nextPartStartOpos)); - currentOpos = nextOpos; - currentPart = nextPart; - } while (currentPart != startPart); - // triangulate outline - if (outline.length == 3) { - // its just a triangle - triangles.push(...outline); - } - else { - const polyTriangles = _.triangulateVertices(ts3dutils.V3.Z, outline.map((i) => verticesMN[i]), []).map((i) => outline[i]); - triangles.push(...polyTriangles); - } - //console.log('outline', col, row, outline) - } - } - } - } - } - //console.log('trinagle', triangles.max(), vertices.length, triangles.length, triangles.toSource(), - // triangles.map(col => vertices[col].$).toSource() ) assert(normals.every(n => n.hasLength(1)), normals.find(n - // => !n.hasLength(1)).length() +' '+normals.findIndex(n => !n.hasLength(1))) - Array.prototype.push.apply(mesh.TRIANGLES, triangles.map((index) => index + mesh.vertices.length)); - Array.prototype.push.apply(mesh.vertices, vertices); - Array.prototype.push.apply(mesh.normals, normals); - //this.addEdgeLines(mesh) - ts3dutils.enableConsole(); - } - addToMesh2(mesh) { - const zSplit = 8; - const ribs = []; - let minZ = Infinity, maxZ = -Infinity; - //let cmp = (a, b) => a.value - b.value - const f = this.surface.pUVFunc(); - const normalF = this.surface.normalUVFunc(); - const vertexLoops = this.holes - .concat([this.contour]) - .map((loop) => this.unrollLoop(loop)); - vertexLoops.forEach((vertexLoop) => { - vertexLoop.forEach(({ x: d, y: z }) => { - const index0 = ts3dutils.binaryIndexOf(ribs, d, (a, b) => ts3dutils.snap(a.value - b, 0)); - if (index0 < 0) { - ribs.splice(-index0 - 1, 0, { value: d, left: [], right: [] }); - } - minZ = min(minZ, z); - maxZ = max(maxZ, z); - }); - }); - console.log("zzzs", minZ, maxZ, vertexLoops[0].toSource().replace(/\), /g, ",\n")); - const correction = 1; - vertexLoops.forEach((vertexLoop) => { - vertexLoop.forEach((v0, i, vs) => { - let v1 = vs[(i + 1) % vs.length], dDiff = v1.x - v0.x; - //console.log(v0.sce, v1.sce) - if (ts3dutils.eq0(dDiff)) { - return; - } - if (dDiff < 0) { - [v0, v1] = [v1, v0]; - dDiff = -dDiff; - } - const index0 = ts3dutils.binaryIndexOf(ribs, v0.x, (a, b) => ts3dutils.snap(a.value - b, 0)); - const index1 = ts3dutils.binaryIndexOf(ribs, v1.x, (a, b) => ts3dutils.snap(a.value - b, 0)); - ts3dutils.binaryInsert(ribs[index0].right, v0.y); - for (let j = (index0 + correction) % ribs.length; j != index1; j = (j + correction) % ribs.length) { - const x = ribs[j].value; - const part = (x - v0.x) / dDiff; - const interpolated = v1.y * part + v0.y * (1 - part); - ts3dutils.binaryInsert(ribs[j].left, interpolated); - ts3dutils.binaryInsert(ribs[j].right, interpolated); - } - ts3dutils.binaryInsert(ribs[index1].left, v1.y); - // console.log(ribs.map(r=>r.toSource()).join('\n')) - }); - }); - const vertices = [], triangles0 = [], normals = []; - for (let i = 0; i < ribs.length; i++) { - const ribLeft = ribs[i], ribRight = ribs[(i + 1) % ribs.length]; - ts3dutils.assert(ribLeft.right.length == ribRight.left.length); - for (let j = 0; j < ribLeft.right.length; j++) { - vertices.push(f(ribLeft.value, ribLeft.right[j]), f(ribRight.value, ribRight.left[j])); - normals.push(normalF(ribLeft.value, ribLeft.right[j]), normalF(ribRight.value, ribRight.left[j])); - } - } - //console.log(ribs.map(r=>r.toSource()).join('\n')) - const vss = vertices.length, detailVerticesStart = vss; - const zInterval = maxZ - minZ, zStep = zInterval / zSplit; - const detailZs = ts3dutils.arrayFromFunction(zSplit - 1, (i) => minZ + (1 + i) * zStep); - console.log("detailsZs", detailZs); - for (let i = 0; i < ribs.length; i++) { - const d = ribs[i].value; - for (let j = 0; j < detailZs.length; j++) { - vertices.push(f(d, detailZs[j])); - normals.push(normalF(d, detailZs[j])); - } - } - // console.log('detailVerticesStart', detailVerticesStart, 'vl', vertices.length, vertices.length - - // detailVerticesStart, ribs.length) finally, fill in the ribs - let vsStart = 0; - const flipped2 = true; - //for (var i = 0; i < 1; i++) { - const end = ribs.length - 1; - for (let i = 0; i < end; i++) { - const ipp = (i + 1) % ribs.length; - let inside = false, colPos = 0; - const ribLeft = ribs[i], ribRight = ribs[(i + 1) % ribs.length]; - for (let j = 0; j < detailZs.length + 1; j++) { - const detailZ = detailZs[j] || 100000; - if (!inside) { - if (ribLeft.right[colPos] < detailZ && - ribRight.left[colPos] < detailZ) { - if (ribLeft.right[colPos + 1] < detailZ || - ribRight.left[colPos + 1] < detailZ) { - tsgl.pushQuad(triangles0, flipped2, vsStart + colPos * 2, vsStart + (colPos + 1) * 2, vsStart + colPos * 2 + 1, vsStart + (colPos + 1) * 2 + 1); - colPos += 2; - if (ribLeft.right[colPos] < detailZ || - ribRight.left[colPos] < detailZ) { - j--; - } - } - else { - tsgl.pushQuad(triangles0, flipped2, vsStart + colPos * 2, vsStart + colPos * 2 + 1, detailVerticesStart + i * detailZs.length + j, detailVerticesStart + ipp * detailZs.length + j); - inside = true; - colPos++; - } - } - } - else { - if (ribLeft.right[colPos] < detailZ || - ribRight.left[colPos] < detailZ) { - tsgl.pushQuad(triangles0, flipped2, detailVerticesStart + i * detailZs.length + j - 1, detailVerticesStart + ipp * detailZs.length + j - 1, vsStart + colPos * 2, vsStart + colPos * 2 + 1); - inside = false; - colPos++; - if (ribLeft.right[colPos] < detailZ || - ribRight.left[colPos] < detailZ) { - j--; - } - } - else { - tsgl.pushQuad(triangles0, flipped2, detailVerticesStart + i * detailZs.length + j, detailVerticesStart + i * detailZs.length + j - 1, detailVerticesStart + ipp * detailZs.length + j, detailVerticesStart + ipp * detailZs.length + j - 1); - } - } - } - vsStart += ribLeft.right.length * 2; - } - //console.log('trinagle', triangles0.max(), vertices.length, triangles0.length, triangles0.toSource(), - // triangles0.map(i => vertices[i].$).toSource() ) - const triangles = triangles0.map((index) => index + mesh.vertices.length); - //assert(normals.every(n => n.hasLength(1)), normals.find(n => !n.hasLength(1)).length() +' - // '+normals.findIndex(n => !n.hasLength(1))) - Array.prototype.push.apply(mesh.vertices, vertices); - Array.prototype.push.apply(mesh.TRIANGLES, triangles); - Array.prototype.push.apply(mesh.normals, normals); - //this.addEdgeLines(mesh) - } -} - -const EPS = 1e-5; -let globalId = 0; -function getGlobalId() { - return globalId++; -} -function addLikeSurfaceFaces(likeSurfaceFaces, face1, face2) { - // There cannot be two subgroups which will later be connected, as the "graph" of like surface faces is fully - // connected - for (let i = 0; i < likeSurfaceFaces.length; i++) { - const faceGroup = likeSurfaceFaces[i]; - let foundFace1 = false, foundFace2 = false; - for (let j = 0; j < faceGroup.length; j++) { - const face = faceGroup[j]; - if (face == face1) { - foundFace1 = true; - } - if (face == face2) { - foundFace2 = true; - } - } - if (foundFace1 != foundFace2) { - faceGroup.push(foundFace1 ? face2 : face1); - return; - } - else if (foundFace1) { - // found both - return; - } - } - // nothing found, add a new group - likeSurfaceFaces.push([face1, face2]); -} -function assembleFaceFromLooseEdges(edges, surface, originalFace) { - const visited = new Set(); - function nextStart() { - return edges.find((edge) => !visited.has(edge)); - } - const loops = []; - let startEdge, currentEdge = undefined; - while ((startEdge = nextStart())) { - currentEdge = startEdge; - const loop = []; - let total = 0; - do { - visited.add(currentEdge); - loop.push(currentEdge); - const possibleEdges = edges.filter((edge) => currentEdge.b.like(edge.a)); - const normalAtCurrentB = surface.normalP(currentEdge.b); - const nextEdgeIndex = ts3dutils.indexWithMax(possibleEdges, (edge) => currentEdge.bDir.angleRelativeNormal(edge.aDir, normalAtCurrentB)); - currentEdge = possibleEdges[nextEdgeIndex]; - } while (startEdge != currentEdge && total++ < 200); - ts3dutils.assert(total != 201); - loops.push(loop); - } - const assembledFaces = BRep.assembleFacesFromLoops(loops, surface, originalFace); - ts3dutils.assertf(() => 1 == assembledFaces.length); - return assembledFaces[0]; -} -/** - * ## Markdown header - * ![foo](screenshots/Capture.PNG) - * {@link ../screenshots/Capture.PNG} - * find the next edge with the MAXIMUM angle - */ -function calcNextEdgeIndex(currentEdge, possibleEdges, faceNormalAtCurrentB) { - let maxValue = -20, advanced = false, result = Number.MAX_SAFE_INTEGER; - const normVector = currentEdge.bDir.cross(faceNormalAtCurrentB); - const eps = 1e-4; - const dir = sign(currentEdge.deltaT()); - const ecd = currentEdge.curve.diff(currentEdge.bT, -dir * eps).dot(normVector); - for (let i = possibleEdges.length; i--;) { - const edge = possibleEdges[i]; - const angle1 = currentEdge.bDir - .negated() - .angleRelativeNormal(edge.aDir, faceNormalAtCurrentB); - const angle = ((angle1 + ts3dutils.TAU + ts3dutils.NLA_PRECISION) % ts3dutils.TAU) - ts3dutils.NLA_PRECISION; - if (ts3dutils.eq0(angle)) { - // do advanced analysis - if (currentEdge.curve.isColinearTo(edge.curve)) { - continue; - } - const edgeDir = sign(edge.deltaT()); - const iscd = edge.curve.diff(edge.aT, edgeDir * eps).dot(normVector); - const diff = iscd - ecd; - // if diff > 0, the angle is actually ~= 0 - if (diff < 0 && (!advanced || diff > maxValue)) { - advanced = true; - maxValue = diff; - result = i; - } - } - else if (!advanced) { - if (ts3dutils.gt(angle, maxValue)) { - maxValue = angle; - result = i; - } - } - } - return result == Number.MAX_SAFE_INTEGER ? 0 : result; -} -class BRep extends ts3dutils.Transformable { - constructor(faces, infiniteVolume, generator, vertexNames) { - super(); - this.faces = faces; - ts3dutils.assertInst(_.Face, ...faces); - this.infiniteVolume = infiniteVolume; - ts3dutils.assert(!this.infiniteVolume || true === this.infiniteVolume); - this.generator = generator; - this.vertexNames = vertexNames; - this.edgeFaces = undefined; - //this.assertSanity() - } - static loop1ContainsLoop2(loop1, ccw1, loop2, ccw2, surface) { - for (const edge of loop2) { - const loop1ContainsPoint = surface.loopContainsPoint(loop1, edge.a); - if (_.PointVsFace.ON_EDGE != loop1ContainsPoint) - return _.PointVsFace.INSIDE == loop1ContainsPoint; - } - for (const edge of loop2) { - const edgePoint = edge.curve.at(edge.aT * 0.2 + edge.bT * 0.8); - const loop1ContainsPoint = surface.loopContainsPoint(loop1, edgePoint); - if (_.PointVsFace.ON_EDGE != loop1ContainsPoint) - return _.PointVsFace.INSIDE == loop1ContainsPoint; - } - if (ccw1 != ccw2) { - return ccw2; - } - throw new Error(loop1.sce + loop2.sce); - } - static assembleFacesFromLoops(loops, surface, originalFace, infoFactory) { - function placeRecursively(newLoopInfo, loopInfos) { - if (loopInfos.length == 0) { - loopInfos.push(newLoopInfo); - } - else { - const subLoopInfo = loopInfos.find((loopInfo) => BRep.loop1ContainsLoop2(loopInfo.loop, loopInfo.ccw, newLoopInfo.loop, newLoopInfo.ccw, surface)); - if (subLoopInfo) { - placeRecursively(newLoopInfo, subLoopInfo.subloops); - } - else { - // newLoopInfo isnt contained by any other subLoopInfo - for (let i = loopInfos.length; --i >= 0;) { - const subLoopInfo = loopInfos[i]; - //console.log("cheving subLoopInfo", surface.loopContainsPoint(newLoopInfo.edges, - // subLoopInfo.edges[0].a)) - if (BRep.loop1ContainsLoop2(newLoopInfo.loop, newLoopInfo.ccw, subLoopInfo.loop, subLoopInfo.ccw, surface)) { - newLoopInfo.subloops.push(subLoopInfo); - loopInfos.splice(i, 1); // remove it - } - } - loopInfos.push(newLoopInfo); - } - } - } - function newFacesRecursive(loopInfo) { - // CW loops can be top level, if they are holes in the original face not contained in the new face - if (loopInfo.ccw) { - if (loopInfo.subloops.every((sl) => !sl.ccw)) { - const holes = loopInfo.subloops.map((sl) => sl.loop); - const info = infoFactory && - infoFactory.newSubFace(originalFace, surface, loopInfo.loop, holes); - const newFace = new originalFace.constructor(surface, loopInfo.loop, holes, "genface" + getGlobalId(), info); - newFaces.push(newFace); - loopInfo.subloops.forEach((sl) => sl.subloops.forEach((slsl) => slsl.ccw && newFacesRecursive(slsl))); - } - else { - loopInfo.subloops.forEach((sl) => sl.ccw && newFacesRecursive(sl)); - } - } - } - const newFaces = []; - const topLevelLoops = []; - loops.forEach((loop) => placeRecursively({ - loop: loop, - ccw: surface.edgeLoopCCW(loop), - subloops: [], - }, topLevelLoops)); - topLevelLoops.forEach((tll) => newFacesRecursive(tll)); - return newFaces; - } - /** - * Create a [BRep] by concatenating the faces of other BReps. Only use this if certain that the faces of the BReps do not intersect. - * Otherwise, use [BRep.plus]. - * @param bReps - * @param generator - */ - static join(bReps, generator) { - return new BRep(bReps.flatMap((b2) => b2.faces), false, generator); - } - containsPoint(p, forceInsideOutside = false) { - const dirs = [ - ts3dutils.V(-0.3920414696448526, -0.12936136783391444, -0.9108068525164064), - ts3dutils.V(0.6520650903544943, -0.07151288645511984, -0.7547827667692488), - ts3dutils.V(0.9433494201061395, -0.2402757256238473, -0.22882186797013926), - ts3dutils.V(0.13678704228501923, -0.04480387361087783, 0.9895867410047372), - ts3dutils.V(0.0662057922721913, -0.5865836917435423, 0.8071780259955845), - ts3dutils.V(-0.7322576567870621, -0.12953393611526787, 0.6685953061989045), - ts3dutils.V(0.6579719127258273, -0.012300218400456116, 0.7529420075219719), - ts3dutils.V(-0.5576497966736425, 0.8006695748324647, 0.2189861552871446), - ]; - dirLoop: for (const dir of dirs) { - const testLine = new _.L3(p, dir); - let inside = this.infiniteVolume; - for (const face of this.faces) { - ts3dutils.assert(!face.surface.containsCurve(testLine)); - const ists = face.surface.isTsForLine(testLine); - for (const t of ists) { - const p = testLine.at(t); - const pvf = face.containsPoint2(p); - //assert(pvf != PointVsFace.ON_EDGE) - !forceInsideOutside && ts3dutils.assert(!ts3dutils.eq0(t)); - if (t > 0) { - if (pvf == _.PointVsFace.ON_EDGE) { - continue dirLoop; - } - if (pvf == _.PointVsFace.INSIDE) { - inside = !inside; - } - } - } - } - return inside; - } - return false; - } - withMergedFaces() { - const likeSurfaceFaces = []; - for (let i = 0; i < this.faces.length; i++) { - let addedToGroup = false; - for (let j = 0; j < i; j++) { - if (this.faces[i].surface.isCoplanarTo(this.faces[j].surface)) { - const faceGroup = likeSurfaceFaces.find((faceGroup) => faceGroup.includes(this.faces[j])); - if (faceGroup) { - faceGroup.push(this.faces[i]); - addedToGroup = true; - } - } - } - !addedToGroup && likeSurfaceFaces.push([this.faces[i]]); - } - console.log("likeSurfaceFaces", likeSurfaceFaces); - if (likeSurfaceFaces.every((group) => group.length == 1)) - return this; - const newFaces = []; - let total = 0; - for (const faceGroup of likeSurfaceFaces) { - console.log(faceGroup); - if (faceGroup.length == 1) { - newFaces.push(faceGroup[0]); - } - else { - const allEdges = faceGroup.flatMap((face) => face.getAllEdges()); - for (let i = allEdges.length; i-- > 0;) { - for (let j = 0; j < i; j++) { - console.log("blugh", total); - ts3dutils.assert(i >= 0 && j >= 0 && total++ < 500, i + " " + j + " " + total); - if (allEdges[i].isCoEdge(allEdges[j])) { - // remove both - allEdges.splice(i, 1); - allEdges.splice(j, 1); - i--; - break; - } - } - } - const newFace = assembleFaceFromLooseEdges(allEdges, faceGroup[0].surface, faceGroup[0]); - newFaces.push(newFace); - } - } - return new BRep(newFaces, this.infiniteVolume, this.generator && this.generator + ".withMergedFaces()", this.vertexNames); - } - calculateVolume() { - return ts3dutils.sum(this.faces.map((face) => face.zDirVolume().volume)); - } - toMesh() { - const mesh = new tsgl.Mesh() - .addVertexBuffer("normals", "ts_Normal") - .addIndexBuffer("TRIANGLES") - .addIndexBuffer("LINES"); - mesh.faceIndexes = new Map(); - for (const face of this.faces) { - const triangleStart = mesh.TRIANGLES.length; - face.addToMesh(mesh); - mesh.faceIndexes.set(face, { - start: triangleStart, - count: mesh.TRIANGLES.length - triangleStart, - }); - } - //this.buildAdjacencies() - //for (const edge of this.edgeFaces.keys()) { - // - //} - return mesh; - } - minus(other, infoFactory) { - const generator = this.generator && - other.generator && - this.generator + ".minus(" + other.generator + ")"; - return this.intersection(other.flipped(), true, true, generator, infoFactory); - } - plus(other, infoFactory) { - const generator = this.generator && - other.generator && - this.generator + ".plus(" + other.generator + ")"; - return this.flipped() - .intersection(other.flipped(), true, true, generator, infoFactory) - .flipped(); - } - and(other, infoFactory) { - const generator = this.generator && - other.generator && - this.generator + ".and(" + other.generator + ")"; - return this.intersection(other, true, true, generator, infoFactory); - } - xor(other, infoFactory) { - const generator = this.generator && - other.generator && - this.generator + ".xor(" + other.generator + ")"; - return new BRep(this.minus(other, infoFactory).faces.concat(other.minus(this, infoFactory).faces), this.infiniteVolume != other.infiniteVolume, generator); - } - equals(obj) { - return (this.faces.length == obj.faces.length && - this.faces.every((face) => obj.faces.some((face2) => face.equals(face2)))); - } - like(brep) { - return (this.faces.length == brep.faces.length && - this.faces.every((face) => brep.faces.some((face2) => face.likeFace(face2)))); - } - //reconstituteCoplanarFaces(likeSurfacePlanes, edgeLooseSegments, faceMap, newFaces) { - // likeSurfacePlanes.forEach(faceGroup => { - // // calculate total contours - // let surface = faceGroup[0].surface, bag = [] - // faceGroup.forEach(face => { - // Array.prototype.push.apply(bag, faceMap(face)) - // face.getAllEdges().forEach(edge => { - // let edgeSubSegments - // if (edgeSubSegments = edgeLooseSegments.get(edge)) { - // Array.prototype.push.apply(bag, edgeSubSegments) - // } else { - // bag.push(edge) - // } - // }) - // }) - // let currentEdge, loops = [] - // while (currentEdge = bag.find(edge => !edge.visited)) { - // let path = [] - // do { - // currentEdge.visited = true - // path.push(currentEdge) - // let possibleNextEdges = bag.filter(edge => currentEdge.b.like(edge.a)) - // // lowest angle, i.e. the right-most next edge - // let nextEdgeIndex = possibleNextEdges.indexWithMax((edge, index) => - // -currentEdge.bDir.angleRelativeNormal(edge.aDir, surface.normalP(currentEdge.b))) currentEdge = - // possibleNextEdges[nextEdgeIndex] } while (!currentEdge.visited) let startIndex = path.find(currentEdge) if (-1 - // != startIndex) { loops.push(path.slice(startIndex)) } } }) } - toString() { - return `new BRep([\n${this.faces.join(",\n").replace(/^/gm, "\t")}], ${this.infiniteVolume})`; - } - getConstructorParameters() { - return [this.faces, this.infiniteVolume]; - } - toSource(useGenerator = true) { - return ((useGenerator && this.generator) || - `new BRep([\n${this.faces.map(ts3dutils.SCE).join(",\n").replace(/^/gm, "\t")}], ${this.infiniteVolume})`); - } - /** - * Rightmost next segment doesn't work, as the correct next segment isn't obvious from the current corner - * alone. - * (at least, not without extensive pre-analysis on the face edges, which shouldn't be necessary, as the - * correct new faces are defined by the new edges already.) Leftmost edge should work. Holes which touch the - * edge of the face will be added to the face contour. - * - * New segments will always be part left-er than existing ones, so no special check is required. - * - */ - reconstituteFaces(oldFaces, edgeSubEdges, faceMap, newFaces, infoFactory) { - const oldFaceStatuses = new Map(); - // reconstitute faces - const insideEdges = []; - for (const face of oldFaces) { - const usableOldEdges = face - .getAllEdges() - .filter((edge) => !edgeSubEdges.get(edge)); - const subEdges = ts3dutils.concatenated(ts3dutils.mapFilter(face.getAllEdges(), (edge) => edgeSubEdges.get(edge))); - const newEdges = faceMap.get(face) || []; - if (newEdges.length || subEdges.length) { - oldFaceStatuses.set(face, "partial"); - const loops = []; - // new edges are definitely part of a resulting loop - // old edges (both contour and holes) can either be part of a new loop, in which case they will already - // have been visited when starting a loop search with a new edge, OR they can be stranded, OR they can - // remain in their old loop - function getNextStart() { - return (newEdges.find((edge) => !visitedEdges.has(edge)) || - subEdges.find((edge) => !visitedEdges.has(edge)) || - usableOldEdges.find((edge) => !visitedEdges.has(edge))); - } - const visitedEdges = new Set(); - // search for a loop: - let currentEdge; - while ((currentEdge = getNextStart())) { - const startEdge = currentEdge, edges = []; - let i = 0; - // wether only new edges are used (can include looseSegments) - do { - visitedEdges.add(currentEdge); - edges.push(currentEdge); - // find next edge - const possibleOldEdges = usableOldEdges.filter((edge) => currentEdge.b.like(edge.a)); - const possibleSubEdges = subEdges.filter((edge) => currentEdge.b.like(edge.a)); - const possibleNewEdges = newEdges.filter((edge) => currentEdge.b.like(edge.a)); - const possibleEdges = possibleOldEdges.concat(possibleSubEdges, possibleNewEdges); - if (0 == possibleEdges.length) - break; - ts3dutils.assert(0 < possibleEdges.length, () => face.sce); - const faceNormalAtCurrentB = face.surface.normalP(currentEdge.b); - const nextEdgeIndex = calcNextEdgeIndex(currentEdge, possibleEdges, faceNormalAtCurrentB); - currentEdge = possibleEdges[nextEdgeIndex]; - if (visitedEdges.has(currentEdge)) { - break; - } - ts3dutils.assert(currentEdge); - ts3dutils.assert(currentEdge != startEdge); - } while (++i < 400); - if (400 == i) { - ts3dutils.assert(false, "too many"); - } - // check if we found a loop - if (edges.length > 1 && currentEdge == startEdge) { - loops.push(edges); - } - } - const faceNewFaces = BRep.assembleFacesFromLoops(loops, face.surface, face, infoFactory); - newFaces.push(...faceNewFaces); - const faceNewFacesEdges = faceNewFaces.flatMap((face) => face.getAllEdges()); - insideEdges.push(...usableOldEdges.filter((edge) => faceNewFacesEdges.includes(edge))); - } - } - while (insideEdges.length != 0) { - const insideEdge = insideEdges.pop(); - const adjacentFaces = this.edgeFaces.get(insideEdge.getCanon()); - adjacentFaces.forEach((info) => { - if (!oldFaceStatuses.has(info.face)) { - oldFaceStatuses.set(info.face, "inside"); - insideEdges.push.apply(insideEdges, info.face.getAllEdges()); - } - }); - } - newFaces.push(...oldFaces.filter((face) => oldFaceStatuses.get(face) == "inside")); - } - static getLooseEdgeSegments(edgePointInfoss, edgeFaces) { - const result = new javasetmap_ts.JavaMap(); - // if there are no point info, the original edge will be kept, so we should return nothing - // otherwise, something will be returned, even if it a new edge identical to the base edge - for (const [canonEdge, pointInfos] of edgePointInfoss) { - if (0 == pointInfos.length) - continue; - const allFaces = edgeFaces.get(canonEdge); - pointInfos.sort((a, b) => ts3dutils.snap0(a.edgeT - b.edgeT) || +!!undefined); - let startP = canonEdge.a, startDir = canonEdge.aDir, startT = canonEdge.aT, startInfo; - function addNewEdge(startInfo, endInfo, newEdge) { - for (let i = 0; i < allFaces.length; i++) { - const faceInfo = allFaces[i]; - ts3dutils.mapPush(result, !faceInfo.reversed ? canonEdge : canonEdge.flipped(), !faceInfo.reversed ? newEdge : newEdge.flipped()); - } - } - for (let i = 0; i < pointInfos.length; i++) { - const info = pointInfos[i]; - const pDir = canonEdge.tangentAt(info.edgeT); - if (!ts3dutils.eq(info.edgeT, startT)) { - const newEdge = _.createEdge(canonEdge.curve, startP, info.p, startT, info.edgeT, undefined, startDir, pDir, "looseSegment" + getGlobalId()); - addNewEdge(startInfo, info, newEdge); - } - startP = info.p; - startT = info.edgeT; - startInfo = info; - startDir = pDir; - } - if (startInfo && !ts3dutils.eq(startT, canonEdge.bT)) { - const newEdge = _.createEdge(canonEdge.curve, startP, canonEdge.b, startT, canonEdge.bT, undefined, startDir, canonEdge.bDir, "looseSegment" + getGlobalId()); - addNewEdge(startInfo, undefined, newEdge); - } - } - return result; - } - getIntersectionEdges(brep2) { - const faceMap = new Map(), thisEdgePoints = new javasetmap_ts.JavaMap(), otherEdgePoints = new javasetmap_ts.JavaMap(); - const checkedPairs = new javasetmap_ts.JavaSet(); - this.faces.forEach((face) => { - //console.log('face', face.toString()) - brep2.faces.forEach((face2) => { - //console.log('face2', face2.toString()) - face.intersectFace(face2, this, brep2, faceMap, thisEdgePoints, otherEdgePoints, checkedPairs); - }); - }); - return ts3dutils.concatenated(Array.from(faceMap.values())); - } - shellCount() { - const foundFaces = new Set(); - let face, result = 0; - while ((face = this.faces.find((face) => !foundFaces.has(face)))) { - result++; - const stack = [face]; - while ((face = stack.pop())) { - // @ts-ignore - for (const edge of face.getAllEdges()) { - // @ts-ignore - for (const { face: face2 } of this.edgeFaces.get(edge.getCanon())) { - if (face !== face2 && !foundFaces.has(face2)) { - foundFaces.add(face2); - stack.push(face2); - } - } - } - } - } - return result; - } - getAABB() { - return ts3dutils.AABB.forAABBs(this.faces.map((face) => face.getAABB())); - } - assertSanity() { - if (!ts3dutils.NLA_DEBUG) - return; - // const allFaceEdges = this.faces.flatMap(face => face.getAllEdges()) - // for (const { i, j } of combinations(allFaceEdges.length)) { - // const a = allFaceEdges[i], - // b = allFaceEdges[j] - // assert(i == j || !a.isCoEdge(b) || a == b || a.flippedOf == b, 'coedges not linked properly', a, b) - // assert( - // i == j || - // !a.curve.isColinearTo(b.curve) || - // (a.curve.equals(b.curve) && a.isCoEdge(b)) || - // !a.overlaps(b), - // 'colinear edges overlap', - // a, - // b, - // ) - // } - this.buildAdjacencies(); - for (const [canonEdge, edgeFaceInfos] of this.edgeFaces) { - // TODO handle curved faces - ts3dutils.assert(edgeFaceInfos.length % 2 == 0, () => canonEdge + edgeFaceInfos.sce); - } - } - //intersection3(other: BRep, buildThis: boolean, buildOther: boolean, name?: string): BRep { - // this.assertSanity() - // other.assertSanity() - // this.buildAdjacencies() - // other.buildAdjacencies() - // - // // edge / edge - // for (const [edge1, edge1Faces] of this.edgeFaces) { - // for (const [edge2, edge2Faces] of other.edgeFaces) { - // const curve1 = edge1.curve, curve2 = edge2.curve - // if (curve1.isColinearTo(curve2)) { - // if (edge1.overlaps(edge2)) { - // // faces have a common edge - // const aT = curve1.pointT(edge2.a), bT = curve1.pointT(edge2.a) - // const minT = min(aT, bT), maxT = max(aT, bT) - // const commonEdge = createEdge(curve1, min(edge1.minT, minT), min(edge1.maxT, maxT), ) - // } - // } else if (x = curve1.isInfosWithCurve(edge2.curve)) { - // // edges intersect in a point - // } - // } - // } - // - // // point / edge - // function pointEdge(b1, b2, has, add) { - // for (const v1 of this.vertFaces.keys()) { - // for (const edge2 of other.edgeFaces.keys()) { - // if (edge2.curve.containsPoint(v1)) { - // const edge2T = edge2.curve.pointT(v1) - // if (eq(edge2.aT, edge2T) || eq(edge2.bT, edge2T)) { - // add(v1, eq(edge2.aT, edge2T) ? edge2.a : edge2.b) - // } - // } - // } - // } - // } - // const pairs: CustomSet<[Equalable, Equalable]> = new CustomSet<[Equalable, Equalable]>() - // pointEdge(this, other, (a, b) => pairs.has([a, b]), (a, b) => pairs.add([a, b])) - // pointEdge(other, this, (b, a) => pairs.has([a, b]), (b, a) => pairs.add([a, b])) - // - // - // // point / point - // for (const v1 of this.vertFaces.keys()) { - // for (const v2 of other.vertFaces.keys()) { - // if (v1.like(v2)) { - // - // } - // } - // } - // - // for (const face1 of this.faces) { - // for (const face2 of other.faces) { - // face1.intersectFace(face2) - // } - // } - // - //} - buildAdjacencies() { - if (this.edgeFaces) - return this; - this.edgeFaces = new javasetmap_ts.JavaMap(); - for (const face of this.faces) { - for (const edge of face.getAllEdges()) { - const canon = edge.getCanon(); - const normalAtCanonA = face.surface.normalP(canon.a); - const inside = normalAtCanonA.cross(canon == edge ? edge.aDir : edge.bDir); - ts3dutils.mapPush(this.edgeFaces, canon, { - face: face, - edge: edge, - normalAtCanonA: normalAtCanonA, - reversed: canon != edge, - inside: inside, - angle: 0, - }); - } - } - for (const [canonEdge, edgeFaceInfos] of this.edgeFaces) { - // TODO handle curved faces - //assert(edgeFaceInfos.length % 2 == 0, () => canonEdge + edgeFaceInfos.sce) - const faceInfo0 = edgeFaceInfos.find((faceInfo) => faceInfo.reversed); - if (!faceInfo0) { - console.warn("invalid brep"); - continue; - } - edgeFaceInfos.forEach((faceInfo) => { - if (faceInfo != faceInfo0) { - faceInfo.angle = faceInfo0.inside.angleRelativeNormal(faceInfo.inside, canonEdge.aDir.unit()); - if (faceInfo.angle < 0) - faceInfo.angle += 2 * Math.PI; - } - }); - edgeFaceInfos.sort((a, b) => ts3dutils.snap(a.angle - b.angle, 0)); // TODO || assertNever() - } - return this; - } - /** - * Cases for volumes A and B - * - * 1. Volumes do not touch. - * 2. face/face Face surfaces intersect each other. - * implies edges going through faces. - * e.g. box(5, 5, 5) - box(5, 5, 5).translate(1, 1, 1) - * 3. face/edge Edge of A lies in a face of B - * implies vertices of A lying in face of B - * e.g. box(5, 5, 5) - box(3, 3, 3).rotateZ([0, 1, 2] * PI / 2).translate(0, 1, 1) - * 4. edge/edge Two edges are colinear. - * implies vertex of A lying in edge of B - * 5. vertex/edge Vertex of A lies on edge of B (but no edge/edge) - * 6. vertex/vertex with/without edge/edge, edge/face and face/face intersections - * 7. vertex lies in face - * - * - * - */ - intersection(other, buildThis, buildOther, generator, infoFactory) { - this.assertSanity(); - other.assertSanity(); - this.buildAdjacencies(); - other.buildAdjacencies(); - const faceMap = new Map(); - const thisEdgePoints = new javasetmap_ts.JavaMap(), otherEdgePoints = new javasetmap_ts.JavaMap(); - const checkedPairs = new javasetmap_ts.JavaSet(); - for (const thisFace of this.faces) { - for (const otherFace of other.faces) { - thisFace.intersectFace(otherFace, this, other, faceMap, thisEdgePoints, otherEdgePoints, checkedPairs); - } - } - for (const edge of thisEdgePoints.keys()) { - ts3dutils.assert(this.edgeFaces.get(edge)); - } - for (const edge of otherEdgePoints.keys()) { - ts3dutils.assert(other.edgeFaces.get(edge)); - } - const newFaces = []; - if (0 == faceMap.size && - 0 == thisEdgePoints.size && - 0 == otherEdgePoints.size) { - const thisInOther = other.containsPoint(this.faces[0].contour[0].a, true) !== - other.infiniteVolume; - const otherInThis = !thisInOther && - this.containsPoint(other.faces[0].contour[0].a) !== this.infiniteVolume; - if (thisInOther || otherInThis) { - const [inside, outside] = thisInOther ? [this, other] : [other, this]; - if (inside.infiniteVolume) { - if (outside.infiniteVolume) { - return outside; - } - else { - return BRep.join([inside, outside]); - } - } - else { - if (outside.infiniteVolume) { - return BRep.EMPTY; - } - else { - return inside; - } - } - } - else { - if (this.infiniteVolume) { - if (other.infiniteVolume) { - return BRep.join([this, other]); - } - } - else { - if (other.infiniteVolume) { - return this; - } - else { - return BRep.EMPTY; - } - } - } - return BRep.EMPTY; - } - else { - if (buildThis) { - const edgeLooseSegments = BRep.getLooseEdgeSegments(thisEdgePoints, this.edgeFaces); - // @ts-ignore - const els = this.faces.map((face) => [ - face, - Array.from(edgeLooseSegments.entries()).flatMap(([edge, subs]) => face.getAllEdges().some((e) => e.equals(edge)) ? subs : []), - ]); - this.reconstituteFaces(this.faces, edgeLooseSegments, faceMap, newFaces, infoFactory); - } - if (buildOther) { - const edgeLooseSegments = BRep.getLooseEdgeSegments(otherEdgePoints, other.edgeFaces); - // @ts-ignore - const els = other.faces.map((face) => [ - face, - Array.from(edgeLooseSegments.entries()).flatMap(([edge, subs]) => face.getAllEdges().some((e) => e.equals(edge)) ? subs : []), - ]); - other.reconstituteFaces(other.faces, edgeLooseSegments, faceMap, newFaces, infoFactory); - } - } - //buildCoplanar && this.reconstituteCoplanarFaces(likeSurfaceFaces, edgeLooseSegments, faceMap, newFaces, - // this.infiniteVolume, other.infiniteVolume) - const result = new BRep(newFaces, this.infiniteVolume && other.infiniteVolume, generator); - //result.buildAdjacencies() - return result; - } - transform(m4, desc) { - let vertexNames; - if (this.vertexNames) { - vertexNames = new Map(); - this.vertexNames.forEach((name, vertex) => vertexNames.set(m4.transformPoint(vertex), name + desc)); - } - return new BRep(this.faces.map((f) => f.transform(m4)), this.infiniteVolume, this.generator && desc && this.generator + desc, // if desc isn't set, the generator will be invalid - vertexNames); - } - transform4(m4, desc) { - let vertexNames; - if (this.vertexNames) { - vertexNames = new Map(); - this.vertexNames.forEach((name, vertex) => vertexNames.set(m4.transformPoint(vertex), name + desc)); - } - return new BRep(this.faces.map((f) => f.transform4(m4)), this.infiniteVolume, this.generator && desc && this.generator + desc, // if desc isn't set, the generator will be invalid - vertexNames); - } - flipped() { - return new BRep(this.faces.map((f) => f.flipped()), !this.infiniteVolume, this.generator && this.generator + ".flipped()", this.vertexNames); - } -} -BRep.EMPTY = new BRep([], false, "BRep.EMPTY", new Map()).buildAdjacencies(); -BRep.R3 = new BRep([], true, "BRep.R3", new Map()).buildAdjacencies(); -function dotCurve(v, cDir, cDDT) { - let dot = v.dot(cDir); - if (ts3dutils.eq0(dot)) { - dot = v.dot(cDDT); - } - ts3dutils.assert(!ts3dutils.eq0(dot)); - return dot; -} -function dotCurve2(curve, t, normal, sign) { - ts3dutils.assert(sign == 1 || sign == -1, sign); - const tangentDot = curve.tangentAt(t).dot(normal); - // if tangentDot != 0 the curve simply crosses the plane - if (!ts3dutils.eq0(tangentDot)) { - return sign * tangentDot; - } - if (curve.ddt) { - const ddtDot = curve.ddt(t).dot(normal); - // tangentDot == 0 ==> critical point at t, if ddtDot != 0, then it is a turning point, otherwise we can't be sure - // and must do a numeric test - if (!ts3dutils.eq0(ddtDot)) { - return ddtDot; - } - } - const numericDot = curve - .at(t) - .to(curve.at(t + sign * 4 * ts3dutils.NLA_PRECISION)) - .dot(normal); - ts3dutils.assert(!(curve instanceof _.L3)); - return numericDot; -} -const INSIDE = 0, OUTSIDE = 1, COPLANAR_SAME = 2, COPLANAR_OPPOSITE = 3, ALONG_EDGE_OR_PLANE = 4; -/** - * - * @param brep BREP to check - * @param edge edge to check - * @param dirAtEdgeA the direction vector to check - * @param faceNormal If dirAtEdgeA doesn't split a volume, but is along a face, the returned value depends on - * wether that faces normal1 points in the same direction as faceNormal - * @returns INSIDE, OUTSIDE, COPLANAR_SAME or COPLANAR_OPPOSITE - */ -//function splitsVolumeEnclosingFaces(brep: BRep, edge: Edge, dirAtEdgeA: V3, faceNormal: V3): int { -// assert(arguments.length == 4) -// //assert(p.equals(edge.a)) -// const ab1 = edge.aDir.unit() -// const relFaces = facesWithEdge(edge, brep.faces) as any[] -// relFaces.forEach(faceInfo => { -// faceInfo.normalAtEdgeA = faceInfo.face.surface.normalP(edge.a) -// faceInfo.edgeDirAtEdgeA = !faceInfo.reversed -// ? faceInfo.edge.aDir -// : faceInfo.edge.bDir -// faceInfo.outsideVector = faceInfo.edgeDirAtEdgeA.cross(faceInfo.normalAtEdgeA) -// faceInfo.angle = (dirAtEdgeA.angleRelativeNormal(faceInfo.outsideVector.negated(), ab1) + 2 * Math.PI + -// NLA_PRECISION / 2) % (2 * Math.PI) }) assert(relFaces.length != 0, edge.toSource()) relFaces.sort((a, b) => a.angle -// - b.angle) // assert(relFaces.length % 2 == 0, edge.toSource()) // even number of touching faces if -// (eq0(relFaces[0].angle)) { //assert(false) todo const coplanarSame = relFaces[0].normalAtEdgeA.dot(faceNormal) > 0; -// return coplanarSame ? COPLANAR_SAME : COPLANAR_OPPOSITE } else { return !relFaces[0].reversed ? INSIDE : OUTSIDE } } -function splitsVolumeEnclosingFaces(brep, canonEdge, dirAtEdgeA, faceNormal) { - ts3dutils.assert(arguments.length == 4); - ts3dutils.assert(canonEdge == canonEdge.getCanon()); - //assert(p.equals(canonEdge.a)) - const edgeFaceInfos = brep.edgeFaces.get(canonEdge); - ts3dutils.assertf(() => edgeFaceInfos.length % 2 == 0); - ts3dutils.assertf(() => brep.edgeFaces); - const faceInfo0 = edgeFaceInfos[0]; - const aDir1 = canonEdge.aDir.unit(); - const angleToCanon = ((faceInfo0.inside.angleRelativeNormal(dirAtEdgeA, aDir1) + - 2 * Math.PI + - ts3dutils.NLA_PRECISION) % - (2 * Math.PI)) - - ts3dutils.NLA_PRECISION; - const nearestFaceInfoIndex = edgeFaceInfos.findIndex((faceInfo) => ts3dutils.lt(angleToCanon, faceInfo.angle)); - const nearestFaceInfo = edgeFaceInfos[nearestFaceInfoIndex == -1 - ? edgeFaceInfos.length - 1 - : nearestFaceInfoIndex - 1]; - if (ts3dutils.eq(nearestFaceInfo.angle, angleToCanon)) { - //assert(false) todo - const coplanarSame = nearestFaceInfo.normalAtCanonA.dot(faceNormal) > 0; - return coplanarSame ? COPLANAR_SAME : COPLANAR_OPPOSITE; - } - else { - return nearestFaceInfo.reversed ? INSIDE : OUTSIDE; - } -} -function splitsVolumeEnclosingFacesP(brep, canonEdge, p, pInside, pFaceNormal) { - ts3dutils.assert(arguments.length == 5); - ts3dutils.assert(canonEdge == canonEdge.getCanon()); - //assert(p.equals(canonEdge.a)) - ts3dutils.assertf(() => brep.edgeFaces); - const edgeFaceInfos = brep.edgeFaces.get(canonEdge); - ts3dutils.assertf(() => edgeFaceInfos.length % 2 == 0); - const pDir1 = canonEdge.tangentAt(canonEdge.curve.pointT(p)).unit(); - const faceInfoAngleFromPInsideNeg = (faceInfo) => { - const faceInfoPDir = faceInfo.edge.getCanon() == faceInfo.edge ? pDir1 : pDir1.negated(); - const faceInfoInsideAtP = faceInfo.face.surface - .normalP(p) - .cross(faceInfoPDir); - const faceInfoAngleAtP = pInside.angleRelativeNormal(faceInfoInsideAtP, pDir1); - return -(((faceInfoAngleAtP + ts3dutils.TAU + ts3dutils.NLA_PRECISION) % ts3dutils.TAU) - ts3dutils.NLA_PRECISION); - }; - const nearestFaceInfo = ts3dutils.withMax(edgeFaceInfos, faceInfoAngleFromPInsideNeg); - if (ts3dutils.eq0(faceInfoAngleFromPInsideNeg(nearestFaceInfo))) { - //assert(false) todo - const coplanarSame = nearestFaceInfo.face.surface.normalP(p).dot(pFaceNormal) > 0; - return coplanarSame ? COPLANAR_SAME : COPLANAR_OPPOSITE; - } - else { - return nearestFaceInfo.reversed ? OUTSIDE : INSIDE; - } -} -function splitsVolumeEnclosingFacesP2(brep, canonEdge, p, testCurve, curveT, dir, faceNormal) { - ts3dutils.assert(canonEdge == canonEdge.getCanon()); - //assert(p.equals(canonEdge.a)) - ts3dutils.assertf(() => brep.edgeFaces); - const edgeFaceInfos = brep.edgeFaces.get(canonEdge); - ts3dutils.assertf(() => edgeFaceInfos.length % 2 == 0); - const pDir1 = canonEdge.tangentAt(canonEdge.curve.pointT(p)).unit(); - let pInside = testCurve.tangentAt(curveT).times(dir); - if (pInside.isParallelTo(pDir1)) { - pInside = testCurve - .diff(curveT, (1e-4 * dir) / testCurve.tangentAt(curveT).length()) - .rejectedFrom(pDir1); - pInside = pInside.div(pInside.length()); - } - let minValue = 20, advanced = false, result = OUTSIDE; - for (const faceInfo of edgeFaceInfos) { - const faceInfoPDir = faceInfo.edge.getCanon() == faceInfo.edge ? pDir1 : pDir1.negated(); - const faceInfoInsideAtP = faceInfo.face.surface - .normalP(p) - .cross(faceInfoPDir); - const faceInfoAngleAtP = pInside.angleRelativeNormal(faceInfoInsideAtP, pDir1); - const angle = ((faceInfoAngleAtP + ts3dutils.TAU + ts3dutils.NLA_PRECISION) % ts3dutils.TAU) - ts3dutils.NLA_PRECISION; - if (ts3dutils.eq0(angle)) { - // do advanced analysis - const normVector = faceInfo.face.surface.normalP(p); - if (faceInfo.face.surface.containsCurve(testCurve)) { - const coplanarSame = normVector.dot(faceNormal) > 0; - return coplanarSame ? COPLANAR_SAME : COPLANAR_OPPOSITE; - } - const testPlane = _.P3.normalOnAnchor(pDir1, p); - const isCurve = faceInfo.face.surface.isCurvesWithPlane(testPlane)[0]; - const isCurvePT = isCurve.pointT(p); - const dirFactor = sign(isCurve.tangentAt(isCurvePT).dot(pInside)); - const eps = 1e-4; - const iscd = isCurve - .at(isCurvePT) - .to(isCurve.at(isCurvePT + dir * dirFactor * eps)) - .dot(normVector); - const ecd = testCurve - .at(curveT) - .to(testCurve.at(curveT + dir * eps)) - .dot(normVector); - const diff = (iscd - ecd) * (faceInfo.reversed ? -1 : 1); - if (diff > 0 && (!advanced || diff < minValue)) { - advanced = true; - minValue = diff; - result = faceInfo.reversed ? OUTSIDE : INSIDE; - } - } - else if (!advanced) { - if (angle < minValue) { - minValue = angle; - result = faceInfo.reversed ? OUTSIDE : INSIDE; - } - } - } - return result; -} -function splitsVolumeEnclosingCone(brep, p, dir) { - const testPlane = _.P3.forAnchorAndPlaneVectors(p, dir, dir.getPerpendicular()); - const rays = []; - for (let k = 0; k < brep.faces.length; k++) { - const planeFace = brep.faces[k]; - ts3dutils.assertf(() => planeFace instanceof _.PlaneFace); - if (planeFace.getAllEdges().some((edge) => edge.a.like(p))) { - if (testPlane.isParallelToPlane(planeFace.surface.plane)) { - if (planeFace.pointsToInside(p, dir) != _.PointVsFace.OUTSIDE) { - return ALONG_EDGE_OR_PLANE; - } - } - else { - const isLine = _.L3.fromPlanes(testPlane, planeFace.surface.plane); - const ps = planeFace.edgeISPsWithPlane(isLine, testPlane); - let i = 0; - while (i < ps.length) { - const a = ps[i++], b = ps[i++]; - const out = a.p.like(p); - if (out || b.p.like(p)) { - const dir2 = out ? isLine.dir1 : isLine.dir1.negated(); - const angle = (dir.angleRelativeNormal(dir2, testPlane.normal1) + - 2 * Math.PI + - ts3dutils.NLA_PRECISION / 2) % - (2 * Math.PI); - rays.push({ angle: angle, out: out }); - } - } - } - } - } - rays.sort((a, b) => a.angle - b.angle); - //console.log("testPlane"Plane.toSource(), "rays", rays.toSource()) - if (ts3dutils.eq0(rays[0].angle)) { - return ALONG_EDGE_OR_PLANE; - } - else { - return rays[0].out ? OUTSIDE : INSIDE; - } -} -function splitsVolumeEnclosingCone2(brep, p, curve, curveT, fb) { - ts3dutils.assert(curve.containsPoint(p)); - const pFaces = brep.faces.filter((face) => face.getAllEdges().some((edge) => edge.a.like(p))); - for (let k = 0; k < pFaces.length; k++) { - const face = pFaces[k]; - if (face.surface.containsCurve(curve)) { - //assert(false) - if (face.pointsToInside3(p, curve, curveT, fb) != _.PointVsFace.OUTSIDE) { - return ALONG_EDGE_OR_PLANE; - } - } - } - const EPS = 1e-6; - return brep.containsPoint(curve.at(curveT + fb * EPS), true) - ? INSIDE - : OUTSIDE; -} -function fff(info, surface) { - const canonA = info.edge.reversed ? info.edge.b : info.edge.a; - const surfaceNormalAtCanonA = surface.normalP(canonA); - const dot = ts3dutils.snap0(info.inside.dot(surfaceNormalAtCanonA)); - if (0 !== dot) { - return 0 < dot ? OUTSIDE : INSIDE; - } - if (surface.isCoplanarTo(info.face.surface)) { - return 0 < info.normalAtCanonA.dot(surfaceNormalAtCanonA) - ? COPLANAR_SAME - : COPLANAR_OPPOSITE; - } - throw new Error(); -} -function triangulateVertices(normal, vertices, holeStarts) { - const absMaxDim = normal.maxAbsDim(), factor = sign(normal.e(absMaxDim)); - const contour = new Float64Array(vertices.length * 2); - let i = vertices.length; - /* - var [coord0, coord1] = [['y', 'z'], ['z', 'x'], ['x', 'y']][maxAbsDim] - while (i--) { - contour[i * 2 ] = vertices[i][coord0] * factor - contour[i * 2 + 1] = vertices[i][coord1] - } - */ - while (i--) { - // unroll disambiguation instead of accessing elements by string name ([coord0] etc) - // as it confuses google closure - switch (absMaxDim) { - case 0: - contour[i * 2] = vertices[i].y * factor; - contour[i * 2 + 1] = vertices[i].z; - break; - case 1: - contour[i * 2] = vertices[i].z * factor; - contour[i * 2 + 1] = vertices[i].x; - break; - case 2: - contour[i * 2] = vertices[i].x * factor; - contour[i * 2 + 1] = vertices[i].y; - break; - } - } - return earcut__default['default'](contour, holeStarts); -} -/** - * Solves a quadratic system of equations of the form - * a * x + b * y = c - * x² + y² = 1 - * This can be understood as the intersection of the unit circle with a line. - * => y = (c - a x) / b - * => x² + (c - a x)² / b² = 1 - * => x² b² + c² - 2 c a x + a² x² = b² - * => (a² + b²) x² - 2 a c x + (c² - b²) = 0 - * - * a * b + (b -c) * (b + c) - */ -function intersectionUnitCircleLine(a, b, c) { - ts3dutils.assertNumbers(a, b, c); - // TODO: disambiguate on a < b - const term = sqrt(a * a + b * b - c * c); - return { - x1: (a * c + b * term) / (a * a + b * b), - x2: (a * c - b * term) / (a * a + b * b), - y1: (b * c - a * term) / (a * a + b * b), - y2: (b * c + a * term) / (a * a + b * b), - }; -} -function intersectionUnitCircleLine2(a, b, c) { - ts3dutils.assertNumbers(a, b, c); - // TODO: disambiguate on a < b - // cf. pqFormula - const termSqr = ts3dutils.snap0(a * a + b * b - c * c); - if (termSqr < 0) { - return []; - } - else if (termSqr == 0) { - return [[(a * c) / (a * a + b * b), (b * c) / (a * a + b * b)]]; - } - else { - const term = sqrt(termSqr); - return [ - [ - (a * c + b * term) / (a * a + b * b), - (b * c - a * term) / (a * a + b * b), - ], - [ - (a * c - b * term) / (a * a + b * b), - (b * c + a * term) / (a * a + b * b), - ], - ]; - } -} -function intersectionCircleLine(a, b, c, r) { - ts3dutils.assertNumbers(a, b, c, r); - const term = sqrt(r * r * (a * a + b * b) - c * c); - return { - x1: (a * c + b * term) / (a * a + b * b), - x2: (a * c - b * term) / (a * a + b * b), - y1: (b * c - a * term) / (a * a + b * b), - y2: (b * c + a * term) / (a * a + b * b), - }; -} -/** - * Solves a quadratic system of equations of the form - * a * x + b * y = c - * x^2 - y^2 = 1 - * This can be understood as the intersection of the unit hyperbola with a line. - * - * @returns with x1 >= x2 and y1 <= y2 - * a * b + (b -c) * (b + c) - */ -function intersectionUnitHyperbolaLine(a, b, c) { - ts3dutils.assertNumbers(a, b, c); - const aa = a * a, bb = b * b, cc = c * c; - // TODO: disambiguate on a < b - //var xTerm = sqrt(4*cc*aa-4*(bb-aa)*(-cc-bb)) - const xTerm = 2 * sqrt(bb * cc + bb * bb - aa * bb); - const yTerm = sqrt(4 * cc * bb - 4 * (bb - aa) * (cc - aa)); - return { - x1: (-2 * a * c + xTerm) / 2 / (bb - aa), - x2: (-2 * a * c - xTerm) / 2 / (bb - aa), - y1: (2 * b * c - yTerm) / 2 / (bb - aa), - y2: (2 * b * c + yTerm) / 2 / (bb - aa), - }; -} -function curvePointPP(ps1, ps2, startPoint, dontCheck) { - const EPS = ts3dutils.NLA_PRECISION / 4; - //if (!dontCheck) { - // const p = curvePointPP(ps1, ps2, startPoint, true).p - // if (!ps1.containsPoint(p)) { - // console.log("foo, startPoint was " + startPoint.sce) - // ps1.containsPoint(p) - // } - //} - let Q = startPoint; - let st1 = ps1.pointFoot(Q); - let st2 = ps2.pointFoot(Q); - let a, b, aNormal, bNormal, abNormalsCross; - //console.log("curvePointPP, startPoint was " + startPoint.sce) - //console.log(Q.sce+ ',') - let i = 16; - do { - a = ps1.pUV(st1.x, st1.y); - b = ps2.pUV(st2.x, st2.y); - if (ts3dutils.eq0(a.distanceTo(b), EPS)) - break; - // drPs.push({p:a,text:'a'+j+' '+i}) - // drPs.push({p:b,text:'b'+j+' '+i}) - aNormal = ps1.normalUV(st1.x, st1.y); - bNormal = ps2.normalUV(st2.x, st2.y); - // next Q is the intersection of the planes - // (x - a) * aNormal, - // (x - b) * bNormal and - // (x - Q) * (aNormal X bNormal) - abNormalsCross = aNormal.cross(bNormal); - // drVs.push({anchor: Q, dir: aNormal}) - // drVs.push({anchor: Q, dir: bNormal}) - Q = ts3dutils.V3.add(bNormal.cross(abNormalsCross).times(a.dot(aNormal)), abNormalsCross.cross(aNormal).times(b.dot(bNormal)), abNormalsCross.times(abNormalsCross.dot(Q))).div(abNormalsCross.squared()); - //console.log(Q.sce+ ',') - // feet of Q on ps1 and ps2 (closest points) - st1 = ps1.pointFoot(Q, st1.x, st1.y); - st2 = ps2.pointFoot(Q, st2.x, st2.y); - } while (--i); - //assert(ps1.containsPoint(Q), Q, ps1) - //assert(ps2.containsPoint(Q)) - if (!ts3dutils.eq0(a.distanceTo(b), EPS)) { - return undefined; - } - return { p: Q, st1: st1, st2: st2 }; -} -/** - * Follow the intersection curve of two parametric surfaces starting from a given point. - * @param {ParametricSurface} ps1 - * @param {ParametricSurface} ps2 - * @param {number} s1Step - * @param {number} t1Step - * @param {number} s2Step - * @param {number} t2Step - * @param {number} curveStepSize - * @return {Curve[]} - */ -function followAlgorithmPP(ps1, ps2, startPoint, curveStepSize, bounds1 = _.uvInAABB2.bind(undefined, ps1), bounds2 = _.uvInAABB2.bind(undefined, ps2)) { - const points = []; - const tangents = []; - const st1s = []; - const st2s = []; - let Q = startPoint; - let st1 = ps1.uvP(Q); - let st2 = ps2.uvP(Q); - ts3dutils.assert(ps1.pUV(st1.x, st1.y).like(Q)); - ts3dutils.assert(st1.like(ps1.pointFoot(Q, st1.x, st1.y))); - ts3dutils.assert(ps2.pUV(st2.x, st2.y).like(Q)); - ts3dutils.assert(st2.like(ps2.pointFoot(Q, st2.x, st2.y))); - for (let i = 0; i < 1000; i++) { - ({ p: Q, st1, st2 } = curvePointPP(ps1, ps2, Q)); - ts3dutils.assert(ps1.containsPoint(Q), Q, ps1); - ts3dutils.assert(ps2.containsPoint(Q)); - const aNormal = ps1.normalUV(st1.x, st1.y); - const bNormal = ps2.normalUV(st2.x, st2.y); - const tangent = aNormal.cross(bNormal).toLength(curveStepSize); - tangents.push(tangent); - points.push(Q); - st1s.push(st1); - st2s.push(st2); - if (i > 4) { - if (!bounds1(st1.x, st1.y) || !bounds2(st2.x, st2.y)) { - break; - } - } - Q = Q.plus(tangent); - } - return { points, tangents, st1s, st2s }; -} -/** - * Iteratively calculate points on an implicit 2D curve. - * @param ic The curve in question. - * @param startP The point at which to start. - * @param stepLength The step the algorithm takes. Will be the approximate distance between points. - * @param bounds Bounds function. - * @param endP End point. If undefined, algorithm will continue until out of bounds or back at start point. - * @param startTangent TODO Ignore this. - * @returns Calculated points and tangents. points[0] and tangents[0] will be startP and startTangent. - */ -function followAlgorithm2d(ic, startP, stepLength = 0.5, bounds, validUV, endP, startTangent) { - ts3dutils.assertNumbers(stepLength, ic(0, 0)); - ts3dutils.assertVectors(startP); - if (!startTangent) { - startTangent = new ts3dutils.V3(-ic.y(startP.x, startP.y), ic.x(startP.x, startP.y), 0).toLength(stepLength); - } - ts3dutils.assertVectors(startTangent); - const points = []; - const tangents = []; - ts3dutils.assert(ts3dutils.eq0(ic(startP.x, startP.y), 0.01), "isZero(implicitCurve(startPoint.x, startPoint.y))", ic(startP.x, startP.y)); - let i = 0, p = startP, tangent = startTangent, fullLoop = false; - do { - points.push(p); - tangents.push(tangent); - const searchStart = p.plus(tangent); - ts3dutils.assert(searchStart); - const newP = _.curvePointMF(ic, searchStart); - const dfpdx = ic.x(newP.x, newP.y), dfpdy = ic.y(newP.x, newP.y); - const newTangent = new ts3dutils.V3(-dfpdy, dfpdx, 0).toLength(stepLength); - //const reversedDir = p.minus(prevp).dot(tangent) < 0 - ts3dutils.assert(!p.equals(newP)); - // check if we passed a singularity - if (tangent.dot(newTangent) < 0) { - const singularity = ts3dutils.newtonIterate2d(ic.x, ic.y, p.x, p.y); - if (ts3dutils.eq0(ic(singularity.x, singularity.y)) && - singularity.distanceTo(p) < abs(stepLength)) { - // end on this point - points.push(singularity); - tangents.push(p.to(singularity)); - break; - } - else { - throw new Error(); - } - } - // check for endP - if (endP && p.equals(endP)) { - break; - } - // check if loop - if (fullLoop) { - if (p.distanceTo(startP) > abs(stepLength)) { - points.pop(); - tangents.pop(); - ts3dutils.assert(ts3dutils.getLast(points).distanceTo(startP) <= abs(stepLength)); - break; - } - } - else { - if (i > 4 && p.distanceTo(startP) <= abs(stepLength)) { - fullLoop = true; - } - } - // check if out of bounds - if (i > 1 && !_.uvInAABB2(bounds, p.x, p.y)) { - const endP = figureOutBorderPoint(bounds, p, ic); - points.pop(); - tangents.pop(); - if (ts3dutils.getLast(points).distanceTo(endP) < abs(stepLength) / 2) { - points.pop(); - tangents.pop(); - } - const endTangent = new ts3dutils.V3(-ic.y(endP.x, endP.y), ic.x(endP.x, endP.y), 0).toLength(stepLength); - points.push(endP); - tangents.push(endTangent); - break; - } - if (i > 4 && !validUV(p.x, p.y)) { - break; - } - ts3dutils.assert(ts3dutils.eq0(ic(newP.x, newP.y), ts3dutils.NLA_PRECISION * 2), p, newP, searchStart, ic(newP.x, newP.y)); - tangent = newTangent; - p = newP; - } while (++i < 1000); - ts3dutils.assert(i < 1000); - //assert(points.length > 6) - return { points, tangents }; -} -/** - * Given a point p just outside the bounds, figure out the nearby intersection of the bounds with the ic. - * @param bounds - * @param p - * @param ic - */ -function figureOutBorderPoint(bounds, p, ic) { - if (p.x < bounds.uMin || bounds.uMax < p.x) { - const u = bounds.uMax < p.x ? bounds.uMax : bounds.uMin; - const v = ts3dutils.newtonIterateWithDerivative((t) => ic(u, t), p.y, 4, (t) => ic.y(u, t)); - if (_.uvInAABB2(bounds, u, v)) { - return new ts3dutils.V3(u, v, 0); - } - } - if (p.y < bounds.vMin || bounds.vMax < p.y) { - const v = bounds.vMax < p.y ? bounds.vMax : bounds.vMin; - const u = ts3dutils.newtonIterateWithDerivative((s) => ic(s, v), p.x, 4, (s) => ic.x(s, v)); - ts3dutils.assert(_.uvInAABB2(bounds, u, v)); - return new ts3dutils.V3(u, v, 0); - } - throw new Error(p + " " + bounds); -} -function followAlgorithm2dAdjustable(ic, start, stepLength = 0.5, bounds, endp = start) { - ts3dutils.assertNumbers(stepLength, ic(0, 0)); - ts3dutils.assertVectors(start); - //assert (!startDir || startDir instanceof V3) - const points = []; - const tangents = []; - ts3dutils.assert(ts3dutils.eq0(ic(start.x, start.y), 0.01), "isZero(implicitCurve(startPoint.x, startPoint.y))"); - let p = start, prevp = p; - let i = 0; - do { - const dfpdx = ic.x(p.x, p.y), dfpdy = ic.y(p.x, p.y); - const dfpdxx = ic.xx(p.x, p.y), dfpdyy = ic.yy(p.x, p.y), dfpdxy = ic.xy(p.x, p.y); - const c2factor = abs((Math.pow(dfpdy, 2) * dfpdxx - 2 * dfpdx * dfpdy * dfpdxy + Math.pow(dfpdx, 2) * dfpdyy) / - Math.pow((Math.pow(dfpdx, 2) + Math.pow(dfpdy, 2)), 2)); - const c2 = new ts3dutils.V3(dfpdx, dfpdy, 0).times(c2factor); - const s = 1 / 16 / c2.length(); - const tangent = new ts3dutils.V3(-dfpdy, dfpdx, 0).unit(); - const newPStart = p.plus(tangent.times(s).plus(c2.times(Math.pow(s, 2) / 2))); - points.push(p); - tangents.push(tangent); - prevp = p; - const newP = _.curvePointMF(ic, newPStart); - if (newP.equals(p)) { - ts3dutils.assertNever(); - } - console.log(p.to(newP).length()); - p = newP; - ts3dutils.assert(ts3dutils.eq0(ic(p.x, p.y))); - } while (i++ < 1000 && - (i < 4 || prevp.distanceTo(endp) > stepLength) && - bounds(p.x, p.y)); - ts3dutils.assert(i != 1000); - //assert(bounds(p.x, p.y)) - const end = i < 4 || prevp.distanceTo(endp) > stepLength ? p : endp; - const endTangent = new ts3dutils.V3(-ic.y(end.x, end.y), ic.x(end.x, end.y), 0).toLength(stepLength); - points.push(end); - tangents.push(endTangent); - //assert(points.length > 6) - // TODO gleichmäßige Verteilung der Punkte - return { points, tangents }; -} -// both curves must be in the same s-t coordinates for this to make sense -function intersectionICurveICurve(iCurve1, startParams1, endParams1, startDir, stepLength, iCurve2) { - ts3dutils.assertNumbers(stepLength, iCurve1(0, 0), iCurve2(0, 0)); - ts3dutils.assertVectors(startParams1, endParams1); - ts3dutils.assert(!startDir || startDir instanceof ts3dutils.V3); - const vertices = []; - ts3dutils.assert(ts3dutils.eq0(iCurve1(startParams1.x, startParams1.y))); - stepLength = stepLength || 0.5; - const eps = 1e-5; - let p = startParams1, prevp = p; // startDir ? p.minus(startDir) : p - let i = 0; - while (i++ < 1000 && (i < 4 || p.distanceTo(endParams1) > 1.1 * stepLength)) { - const fp = iCurve1(p.x, p.y); - const dfpdx = (iCurve1(p.x + eps, p.y) - fp) / eps, dfpdy = (iCurve1(p.x, p.y + eps) - fp) / eps; - let tangent = new ts3dutils.V3(-dfpdy, dfpdx, 0).toLength(stepLength); - if (p.minus(prevp).dot(tangent) < 0) - tangent = tangent.negated(); - prevp = p; - p = _.curvePointMF(iCurve1, p.plus(tangent)); - vertices.push(p); - } - // TODO gleichmäßige Verteilung der Punkte - return vertices; -} -function intersectionICurveICurve2(iCurve1, loopPoints1, iCurve2) { - let p = loopPoints1[0], val = iCurve2(p.x, p.y), lastVal; - const iss = []; - for (let i = 0; i < loopPoints1.length; i++) { - lastVal = val; - p = loopPoints1[i]; - val = iCurve2(p.x, p.y); - if (val * lastVal <= 0) { - // TODO < ? - iss.push(ts3dutils.newtonIterate2d(iCurve1, iCurve2, p.x, p.y)); - } - } - return iss; -} -// export function intersectionPCurveISurface( -// parametricCurve: Curve, -// searchStart: number, -// searchEnd: number, -// searchStep: number, -// implicitSurface: ImplicitSurface, -// ) { -// assertNumbers(searchStart, searchEnd, searchStep) -// const iss = [] -// let val = implicitSurface(parametricCurve(searchStart)), -// lastVal -// for (let t = searchStart + searchStep; t <= searchEnd; t += searchStep) { -// lastVal = val -// val = implicitSurface(parametricCurve(t)) -// if (val * lastVal <= 0) { -// iss.push(newtonIterate1d(t => implicitSurface(parametricCurve(t)), t)) -// } -// } -// return iss -// } -function cassini(a, c) { - return (x, y) => (x * x + y * y) * (x * x + y * y) - - 2 * c * c * (x * x - y * y) - - (Math.pow(a, 4) - Math.pow(c, 4)); -} -(function (MathFunctionR2R) { - function forNerdamer(expression, args = ["x", "y"]) { - const ndf = nerdamer__default['default'](expression); - const ndfs = nerdamer__default['default'].diff(ndf, args[0]); - const ndft = nerdamer__default['default'].diff(ndf, args[1]); - const f = ndf.buildFunction(args); - f.x = ndfs.buildFunction(args); - f.y = ndft.buildFunction(args); - f.xx = nerdamer__default['default'].diff(ndfs, args[0]).buildFunction(args); - f.xy = nerdamer__default['default'].diff(ndfs, args[1]).buildFunction(args); - f.yy = nerdamer__default['default'].diff(ndft, args[1]).buildFunction(args); - return f; - } - MathFunctionR2R.forNerdamer = forNerdamer; - function nerdamerToR2_R(expression, args = ["x", "y"]) { - return expression.buildFunction(args); - } - MathFunctionR2R.nerdamerToR2_R = nerdamerToR2_R; - function forFFxFy(f, fx, fy) { - f.x = fx; - f.y = fy; - return f; - } - MathFunctionR2R.forFFxFy = forFFxFy; -})(exports.MathFunctionR2R || (exports.MathFunctionR2R = {})); -const cas2 = cassini(0.9, 1.02); -function arrayLerp(lerp, arr, t) { - if (0 === t % 1) - return arr[t]; - return lerp(arr[Math.floor(t)], arr[Math.ceil(t)], t % 1); -} - -function doNotSerialize(target, key) { - const map = target.__SERIALIZATION_BLACKLIST || (target.__SERIALIZATION_BLACKLIST = {}); - map[key] = "no"; -} -class ClassSerializer { - constructor() { - this.CLASS_NAMES = new Map(); - this.NAME_CLASSES = new Map(); - this.addClass("Object", Object); - } - addClass(name, clazz) { - if (this.NAME_CLASSES.has(name)) { - throw new Error(name); - } - this.NAME_CLASSES.set(name, clazz); - this.CLASS_NAMES.set(clazz, name); - return this; - } - addNamespace(namespace, namespaceName) { - Object.keys(namespace).forEach((symbol) => { - const o = namespace[symbol]; - if ("function" == typeof o && o.name) { - this.addClass((namespaceName ? namespaceName + "." : "") + symbol, o); - } - }); - return this; - } - setUpdater(f) { - this.updater = f; - return this; - } - serialize(v) { - return JSON.stringify(this.serializeObj(v)); - } - serializeObj(v) { - const gatherList = (v) => { - //console.log(path.toString()) - if (undefined !== v && - v.hasOwnProperty("constructor") && - this.CLASS_NAMES.has(v.constructor)) ; - else if (Array.isArray(v)) { - if (visited.has(v)) { - if (!listMap.has(v)) { - listMap.set(v, resultList.length); - resultList.push(v); - } - } - else { - visited.add(v); - for (let i = 0; i < v.length; i++) { - gatherList(v[i]); - } - } - } - else if (undefined !== v && "object" == typeof v) { - if (visited.has(v)) { - if (!listMap.has(v)) { - listMap.set(v, resultList.length); - resultList.push(v); - } - } - else { - ts3dutils.assert(!v.__noxTarget || !visited.has(v.__noxTarget)); - ts3dutils.assert(!v.__noxProxy || !visited.has(v.__noxProxy)); - visited.add(v); - if (!v.getConstructorParameters) { - for (const key of Object.keys(v).sort()) { - if (key == "__noxProxy" || key == "__noxTarget") - continue; - if (!v.__SERIALIZATION_BLACKLIST || - !v.__SERIALIZATION_BLACKLIST[key]) { - gatherList(v[key]); - } - } - } - gatherList(Object.getPrototypeOf(v)); - } - } - }; - const transform = (v, allowLinks, first) => { - if ("string" == typeof v || - "number" == typeof v || - "boolean" == typeof v || - null === v) { - return v; - } - if ("undefined" == typeof v) { - return { "#REF": -1 }; - } - if (v.hasOwnProperty("constructor") && - this.CLASS_NAMES.has(v.constructor)) { - return { "#REF": this.CLASS_NAMES.get(v.constructor) }; - } - let index; - if (allowLinks && !first && undefined !== (index = listMap.get(v))) { - return { "#REF": index }; - } - if (Array.isArray(v)) { - return v.map((x) => transform(x, allowLinks)); - } - //if (mobx && mobx.isObservableArray(v)) { - // const result = {'#PROTO': 'ObservableArray'} as any - // v.forEach((val, i) => result[i] = transform(val)) - // return result - //} - if ("object" == typeof v) { - if (v.getConstructorParameters) { - return { - "#CONSTRUCTOR": this.CLASS_NAMES.get(v.constructor), - "#ARGS": transform(v.getConstructorParameters(), false), - }; - } - const result = {}; - if (Object.prototype !== Object.getPrototypeOf(v)) { - result["#PROTO"] = transform(Object.getPrototypeOf(v), allowLinks); - } - for (const key of Object.keys(v)) { - if (key == "__noxProxy" || key == "__noxTarget") - continue; - if (!v.__SERIALIZATION_BLACKLIST || - !v.__SERIALIZATION_BLACKLIST[key]) { - result[key] = transform(v[key], allowLinks); - } - } - return result; - } - throw new Error("?" + typeof v + v.toString()); - }; - const visited = new Set(); - const listMap = new Map(); - let resultList = []; - listMap.set(v, 0); - resultList.push(v); - gatherList(v); - resultList = resultList.map((v) => transform(v, true, true)); - return resultList; - } - unserialize(string) { - let depth = 0; - const fixObject = (v, onReady) => { - depth++; - if (depth > 100) - throw new Error(); - if (v && v.constructor === Array) { - onReady(v); - for (let i = 0; i < v.length; i++) { - fixObject(v[i], (x) => (v[i] = x)); - } - } - else if ("object" == typeof v && undefined != v) { - if ("#CONSTRUCTOR" in v) { - const protoName = v["#CONSTRUCTOR"]; - const proto = this.NAME_CLASSES.get(protoName); - ts3dutils.assert(proto, protoName + " Missing "); - let args = undefined; - fixObject(v["#ARGS"], (x) => (args = x)); - onReady(new proto(...args)); - } - else if ("#REF" in v) { - const ref = v["#REF"]; - if ("string" == typeof ref) { - onReady(this.NAME_CLASSES.get(ref).prototype); - } - else if ("number" == typeof ref) { - if (-1 == ref) { - onReady(undefined); - } - else if (fixedObjects[ref]) { - onReady(fixedObjects[ref]); - } - else { - fixObject(tree[ref], (x) => onReady((fixedObjects[ref] = x))); - } - } - } - else { - let result; - if ("#PROTO" in v) { - fixObject(v["#PROTO"], (x) => { - result = Object.create(x); - onReady(result); - }); - } - else { - onReady((result = v)); - } - const keys = Object.keys(v); - for (let i = 0; i < keys.length; i++) { - //if ('name' == keys[i]) console.log(result) - if ("#PROTO" != keys[i]) { - fixObject(v[keys[i]], (x) => (result[keys[i]] = x)); - //Object.defineProperty(result, keys[i], { - // value: fixObjects(v[keys[i]]), - // enumerable: true, - // writable: true, - // configurable: true - //}) - } - } - Object.defineProperty(result, "loadID", { - value: _.getGlobalId(), - enumerable: false, - writable: false, - }); - this.updater && this.updater(result); - } - } - else { - onReady(v); - } - depth--; - }; - // const linkReferences = (v: any) => { - // if (v && v.constructor === Array) { - // for (let i = 0; i < v.length; i++) { - // v[i] = linkReferences(v[i]) - // } - // return v - // } else if ('object' == typeof v && undefined != v) { - // if ('#REF' in v) { - // return tree[v['#REF']] - // } else { - // const keys = Object.keys(v) - // for (let i = 0; i < keys.length; i++) { - // v[keys[i]] = linkReferences(v[keys[i]]) - // } - // return v - // } - // } else { - // return v - // } - // } - const tree = JSON.parse(string); - // console.log(tree) - const fixedObjects = new Array(tree.length); - fixObject({ "#REF": 0 }, () => { }); - // console.log(tree) - // linkReferences(tree) - // console.log(tree) - return fixedObjects[0]; - } -} - -const fragmentShaderLighting = ` - precision highp float; - uniform vec4 color; - uniform vec3 camPos; - varying vec3 normal; - varying vec4 vPosition; - void main() { - vec3 normal1 = normalize(normal); - vec3 lightPos = vec3(1000, 2000, 4000); - vec3 lightDir = normalize(vPosition.xyz - lightPos); - vec3 reflectionDirection = reflect(lightDir, normal1); - vec3 eyeDirection = normalize(camPos.xyz-vPosition.xyz); - float uMaterialShininess = 256.0; - float specularLightWeighting = pow(max(dot(reflectionDirection, eyeDirection), 0.0), uMaterialShininess); - float lightIntensity = 0.6 + 0.2 * max(0.0, -dot(lightDir, normal1)) + 0.2*specularLightWeighting; - gl_FragColor = vec4(vec3(color) * lightIntensity, 1); - } -`; -const vertexShaderLighting = ` - uniform mat4 ts_ModelViewProjectionMatrix; - uniform mat4 ts_ModelViewMatrix; - attribute vec4 ts_Vertex; - uniform mat3 ts_NormalMatrix; - attribute vec3 ts_Normal; - uniform vec4 color; - varying vec3 normal; - varying vec4 vPosition; - void main() { - gl_Position = ts_ModelViewProjectionMatrix * ts_Vertex; - vPosition = ts_ModelViewMatrix * ts_Vertex; - normal = normalize(ts_NormalMatrix * ts_Normal); - } -`; -const vertexShaderWaves = ` - uniform mat4 ts_ModelViewProjectionMatrix; - uniform mat4 ts_ModelViewMatrix; - attribute vec4 ts_Vertex; - uniform mat3 ts_NormalMatrix; - attribute vec3 ts_Normal; - uniform vec4 color; - varying vec3 normal; - varying vec4 vPosition; - void main() { - normal = normalize(ts_NormalMatrix * ts_Normal); - float offset = mod (((ts_Vertex.x + ts_Vertex.y + ts_Vertex.z) * 31.0), 20.0) - 10.0; - vec4 modPos = ts_Vertex + vec4(normal * offset, 0); - gl_Position = ts_ModelViewProjectionMatrix * modPos; - vPosition = ts_ModelViewMatrix * modPos; - } -`; -const vertexShaderBasic = ` - uniform mat4 ts_ModelViewProjectionMatrix; - attribute vec4 ts_Vertex; - void main() { - gl_Position = ts_ModelViewProjectionMatrix * ts_Vertex; - } -`; -const vertexShaderColor = ` - uniform mat4 ts_ModelViewProjectionMatrix; - attribute vec4 ts_Vertex; - attribute vec4 ts_Color; - varying vec4 fragColor; - void main() { - gl_Position = ts_ModelViewProjectionMatrix * ts_Vertex; - fragColor = ts_Color; - } -`; -const vertexShaderArc = ` - uniform mat4 ts_ModelViewProjectionMatrix; - attribute vec4 ts_Vertex; - uniform float step, offset; - uniform float radius, width; - void main() { - float r = radius; - float t = offset + ts_Vertex.x * step; - float pRadius = r - ts_Vertex.y * width; - vec4 p = vec4(pRadius * cos(t), pRadius * sin(t), 0, 1); - gl_Position = ts_ModelViewProjectionMatrix * p; -} -`; -const vertexShaderConic3d = ` - uniform mat4 ts_ModelViewProjectionMatrix; - attribute vec4 ts_Vertex; - uniform float startT, endT, scale; - uniform vec3 center, f1, f2; - uniform int mode; - float sinh(float x) { return (exp(x) - exp(-x)) / 2.0; } - float cosh(float x) { return (exp(x) + exp(-x)) / 2.0; } - void main() { - float t = startT + ts_Vertex.x * (endT - startT); - - vec3 normal = normalize(cross(f1, f2)); - - vec3 p, tangent; - if (0 == mode) { // ellipse - p = center + f1 * cos(t) + f2 * sin(t); - tangent = f1 * -sin(t) + f2 * cos(t); - } - if (1 == mode) { // parabola - p = center + f1 * t + f2 * t * t; - tangent = f1 + 2.0 * f2 * t; - } - if (2 == mode) { // hyperbola - p = center + f1 * cosh(t) + f2 * sinh(t); - tangent = f1 * sinh(t) + f2 * cosh(t); - } - vec3 outDir = normalize(cross(normal, tangent)); - vec3 p2 = p + scale * (outDir * ts_Vertex.y + normal * ts_Vertex.z); - gl_Position = ts_ModelViewProjectionMatrix * vec4(p2, 1); - } -`; -const vertexShaderNURBS = `#version 300 es - uniform mat4 ts_ModelViewProjectionMatrix; - in vec4 ts_Vertex; - uniform float startT, endT, scale; - uniform vec4 points[32]; - uniform int pointCount, degree; - uniform float knots[40]; - uniform vec3 normal; - const int MIN_DEGREE = 1; - const int MAX_DEGREE = 6; - - int tInterval(float t) { - for (int s = degree; s < 40 - 1 - degree; s++) { - if (t >= knots[s] && t <= knots[s + 1]) { - return s; - } - } - } - - vec4 stepp(int k, int i, vec4 dkMinus1iMinus1, vec4 dkMinus1i) { - return dkMinus1i - dkMinus1iMinus1 * float(k) / (knots[i + degree - k] - knots[i - 1]); - } - - void main() { - // ts_Vertex.x is in [0, 1] - float t = startT + ts_Vertex.x * (endT - startT); - - int s = tInterval(t); - - vec4 v[MAX_DEGREE + 1]; - for (int i = 0; i < degree + 1; i++) { - v[i] = points[s - degree + i]; - } - - vec4 pTangent4, ddt4 = vec4(0, 0, 1, 0); - for (int level = 0; level < degree; level++) { - if (level == degree - 2) { - // see https://www.globalspec.com/reference/61012/203279/10-8-derivatives - vec4 a = v[degree]; - vec4 b = v[degree - 1]; - vec4 c = v[degree - 2]; - ddt4 = stepp(degree, s + 1, stepp(degree - 1, s + 1, a, b), stepp(degree - 1, s, b, c)); - } - if (level == degree - 1) { - vec4 a = v[degree]; - vec4 b = v[degree - 1]; - pTangent4 = (b - a) * (float(degree) / (knots[s] - knots[s + 1])); - } - for (int i = degree; i > level; i--) { - float alpha = (t - knots[i + s - degree]) / (knots[i + s - level] - knots[i + s - degree]); - - // interpolate each component - v[i] = (1.0 - alpha) * v[i - 1] + alpha * v[i]; - } - } - - vec4 p4 = v[degree]; - - vec3 p = p4.xyz / p4.w; - vec3 pTangent = ((pTangent4.xyz * p4.w) - (p4.xyz * pTangent4.w)) / (p4.w * p4.w); - vec3 ddt = ( - p4.xyz * (-p4.w * ddt4.w + 2.0 * pow(pTangent4.w, 2.0)) - + pTangent4.xyz * (-2.0 * p4.w * pTangent4.w) - + ddt4.xyz * pow(p4.w, 2.0) - ) / pow(p4.w, 3.0); - - vec3 outDir = normalize(cross(ddt, pTangent)); - vec3 correctNormal = normalize(cross(pTangent, outDir)); - vec3 p2 = p + scale * (outDir * ts_Vertex.y + correctNormal * ts_Vertex.z); - gl_Position = ts_ModelViewProjectionMatrix * vec4(p2, 1); - } -`; -const vertexShaderBezier = ` - // calculates a bezier curve using ts_Vertex.x as the (t) parameter of the curve - uniform mat4 ts_ModelViewProjectionMatrix; - attribute vec4 ts_Vertex; - uniform float width, startT, endT; - uniform vec3 p0, p1, p2, p3; - void main() { - // ts_Vertex.x is in [0, 1] - float t = startT + ts_Vertex.x * (endT - startT), s = 1.0 - t; - float c0 = s * s * s, c1 = 3.0 * s * s * t, c2 = 3.0 * s * t * t, c3 = t * t * t; - vec3 pPos = p0 * c0 + p1 * c1 + p2 * c2 + p3 * c3; - float c01 = 3.0 * s * s, c12 = 6.0 * s * t, c23 = 3.0 * t * t; - vec3 pTangent = (p1 - p0) * c01 + (p2 - p1) * c12 + (p3 - p2) * c23; - vec3 pNormal = normalize(vec3(pTangent.y, -pTangent.x, 0)); - vec4 p = vec4(pPos - ts_Vertex.y * width * pNormal, 1); - gl_Position = ts_ModelViewProjectionMatrix * p; - } -`; -const vertexShaderBezier3d = ` - precision highp float; - // calculates a bezier curve using ts_Vertex.x as the (t) parameter of the curve - uniform float scale, startT, endT; - uniform vec3 ps[4]; - uniform vec3 p0, p1, p2, p3, normal; - uniform mat4 ts_ModelViewProjectionMatrix; - attribute vec4 ts_Vertex; - void main() { - // ts_Vertex.y is in [0, 1] - vec3 p5 = ps[0]; - float t = startT * (1.0 - ts_Vertex.x) + endT * ts_Vertex.x, s = 1.0 - t; - float c0 = s * s * s, - c1 = 3.0 * s * s * t, - c2 = 3.0 * s * t * t, c3 = t * t * t; - vec3 p = (p0 * c0 + p1 * c1) + (p2 * c2 + p3 * c3); - float c01 = 3.0 * s * s, - c12 = 6.0 * s * t, - c23 = 3.0 * t * t; - vec3 pTangent = (p1 - p0) * c01 + (p2 - p1) * c12 + (p3 - p2) * c23; - vec3 outDir = normalize(cross(normal, pTangent)); - vec3 correctNormal = normalize(cross(pTangent, outDir)); - vec3 p2 = p + scale * (outDir * ts_Vertex.y + correctNormal * ts_Vertex.z); - gl_Position = ts_ModelViewProjectionMatrix * vec4(p2, 1); - } -`; -const vertexShaderGeneric = ` - uniform float scale; - uniform mat4 ts_ModelViewProjectionMatrix; - attribute vec4 ts_Vertex; - uniform mat3 ts_NormalMatrix; - attribute vec3 ts_Normal; - void main() { - vec3 normal = normalize(ts_NormalMatrix * ts_Normal); - vec4 vertexPos = ts_Vertex + vec4(normal * scale, 0); - gl_Position = ts_ModelViewProjectionMatrix * vertexPos; - } -`; -const vertexShaderRing = ` - #define M_PI 3.1415926535897932384626433832795 - uniform float step; - uniform float innerRadius, outerRadius; - attribute float index; - uniform mat4 ts_ModelViewProjectionMatrix; - attribute vec4 ts_Vertex; - void main() { - gl_Position = ts_ModelViewProjectionMatrix * vec4(index, index, index, 1); - float id = atan(ts_Vertex.x, ts_Vertex.y) / M_PI * 32.0; - float radius = mod(id, 2.0) < 1.0 ? outerRadius : innerRadius; - gl_Position = ts_ModelViewProjectionMatrix * vec4(radius * cos(index * step), radius * sin(index * step), 0, 1); - } -`; -const fragmentShaderColor = ` - precision highp float; - uniform vec4 color; - void main() { - gl_FragColor = color; - } -`; -const fragmentShaderColor3 = `#version 300 es - precision highp float; - uniform vec4 color; - out vec4 fragColor; - void main() { - fragColor = color; - } -`; -const fragmentShaderVaryingColor = ` - precision highp float; - varying vec4 fragColor; - void main() { - gl_FragColor = fragColor; - } -`; -const fragmentShaderColorHighlight = ` - precision highp float; - uniform vec4 color; - void main() { - float diagonal = (gl_FragCoord.x + 2.0 * gl_FragCoord.y); - if (mod(diagonal, 50.0) > 40.0) { // mod(diagonal, 2.0) > 1.0 - discard; - //gl_FragColor = color + vec4(0.2,0.2,0.2,0); - } else { - gl_FragColor = color - vec4(0.2,0.2,0.2,0); - } - } -`; -const vertexShaderTexture = ` - varying vec2 texturePos; - attribute vec4 ts_Vertex; - uniform mat4 ts_ModelViewProjectionMatrix; - void main() { - texturePos = ts_Vertex.xy; - gl_Position = ts_ModelViewProjectionMatrix * ts_Vertex; - } -`; -const fragmentShaderTextureColor = ` - precision highp float; - varying vec2 texturePos; - uniform vec4 color; - uniform sampler2D texture; - void main() { - gl_FragColor = texture2D(texture, texturePos) * color; - } -`; - -function parseGetParams(str) { - const result = {}; - str.split("&").forEach(function (item) { - const splitIndex = item.indexOf("="); - if (-1 == splitIndex) { - result[item] = item; - } - else { - result[item.substr(0, splitIndex)] = decodeURI(item.substr(splitIndex + 1)); - } - }); - return result; -} -const COLORS = { - RD_FILL: chroma.color("#9EDBF9"), - RD_STROKE: chroma.color("#77B0E0"), - TS_FILL: chroma.color("#D19FE3"), - TS_STROKE: chroma.color("#A76BC2"), - PP_FILL: chroma.color("#F3B6CF"), - PP_STROKE: chroma.color("#EB81B4"), -}; -class BREPGLContext { - constructor(gl) { - this.cachedMeshes = new WeakMap(); - this.shaders = initShaders(gl); - initMeshes((this.meshes = {}), gl); - } - static create(gl) { - ts3dutils.addOwnProperties(gl, BREPGLContext.prototype); - ts3dutils.addOwnProperties(gl, new BREPGLContext(gl)); - return gl; - } - drawPoint(p, color = tsgl.GL_COLOR_BLACK, size = 5) { - this.pushMatrix(); - this.translate(p); - this.scale(size / 2, size / 2, size / 2); - this.shaders.singleColor - .uniforms({ color: color }) - .draw(this.meshes.sphere1); - this.popMatrix(); - } - drawEdge(edge, color = tsgl.GL_COLOR_BLACK, width = 2) { - CURVE_PAINTERS[edge.curve.constructor.name](this, edge.curve, color, edge.minT, edge.maxT, width); - } - drawCurve(curve, color = tsgl.GL_COLOR_BLACK, width = 2, tStart, tEnd) { - CURVE_PAINTERS[curve.constructor.name](this, curve, color, tStart, tEnd, width); - } - drawVector(vector, anchor, color = tsgl.GL_COLOR_BLACK, size = 1) { - if (vector.likeO()) - return; - this.pushMatrix(); - const headLength = size * 4; - if (headLength > vector.length()) - return; - const vT = vector.getPerpendicular().unit(); - this.multMatrix(ts3dutils.M4.forSys(vector.unit(), vT, vector.cross(vT).unit(), anchor)); - this.scale(vector.length() - headLength, size / 2, size / 2); - this.shaders.singleColor - .uniforms({ - color: color, - }) - .draw(this.meshes.vectorShaft); - this.scale(1 / (vector.length() - headLength), 1, 1); - this.translate(vector.length() - headLength, 0, 0); - this.scale(headLength / 2, 1, 1); - this.shaders.singleColor.draw(this.meshes.vectorHead); - this.popMatrix(); - } - drawVectors(drVs, size = undefined) { - this.drawVector(ts3dutils.V3.X, ts3dutils.V3.O, chroma.color("red").gl(), size); - this.drawVector(ts3dutils.V3.Y, ts3dutils.V3.O, chroma.color("green").gl(), size); - this.drawVector(ts3dutils.V3.Z, ts3dutils.V3.O, chroma.color("blue").gl(), size); - drVs.forEach((vi) => this.drawVector(vi.v, vi.anchor, vi.color, size)); - } - drawPlane(customPlane, color, dotted = false) { - this.pushMatrix(); - this.multMatrix(ts3dutils.M4.forSys(customPlane.right, customPlane.up, customPlane.normal1, customPlane.anchor)); - this.translate(customPlane.uMin, customPlane.vMin, 0); - this.scale(customPlane.uMax - customPlane.uMin, customPlane.vMax - customPlane.vMin, 1); - const mesh = dotted - ? this.meshes.xyDottedLinePlane - : this.meshes.xyLinePlane; - this.shaders.singleColor.uniforms({ color: color }).draw(mesh, this.LINES); - this.popMatrix(); - } - drawBox(m4, color) { - this.pushMatrix(); - this.multMatrix(m4.m[15] >= 0 ? m4 : m4.mulScalar(-1)); - if (color) { - this.shaders.singleColor - .uniforms({ color: color }) - .draw(this.meshes.cube, this.LINES); - } - else { - this.shaders.multiColor.draw(this.meshes.cube, this.LINES); - } - this.popMatrix(); - } -} -function conicPainter(mode, gl, ellipse, color, startT, endT, width = 2) { - gl.shaders.ellipse3d - .uniforms({ - f1: ellipse.f1, - f2: ellipse.f2, - center: ellipse.center, - color: color, - startT: startT, - endT: endT, - scale: width, - mode: mode, - }) - .draw(gl.meshes.pipe); -} -const CURVE_PAINTERS = { - [_.EllipseCurve.name]: conicPainter.bind(undefined, 0), - [_.ParabolaCurve.name]: conicPainter.bind(undefined, 1), - [_.HyperbolaCurve.name]: conicPainter.bind(undefined, 2), - [_.ImplicitCurve.name](gl, curve, color, startT, endT, width = 2) { - let mesh = gl.cachedMeshes.get(curve); - const RES = 4; - if (!mesh) { - mesh = new tsgl.Mesh() - .addIndexBuffer("TRIANGLES") - .addVertexBuffer("normals", "ts_Normal"); - curve.addToMesh(mesh, RES); - mesh.compile(); - gl.cachedMeshes.set(curve, mesh); - } - const startIndex = ceil(startT); - const endIndex = floor(endT); - if (startIndex <= endIndex) { - const indexFactor = 2 * // no of triangles per face - RES * // no of faces - 3; // no of indexes per triangle - gl.shaders.generic3d - .uniforms({ - color: color, - scale: width, - }) - .draw(mesh, gl.TRIANGLES, startIndex * indexFactor, (floor(endT) - startIndex) * indexFactor); - if (startT % 1 !== 0) { - const p = curve.at(startT); - gl.pushMatrix(); - const m = ts3dutils.M4.forSys(p.to(curve.points[startIndex]), mesh.normals[startIndex * RES].toLength(width), mesh.normals[startIndex * RES + 1].toLength(width), p); - gl.multMatrix(m); - gl.shaders.singleColor - .uniforms({ color: color }) - .draw(gl.meshes.pipeSegmentForICurve); - console.log(gl.meshes.pipeSegmentForICurve); - gl.popMatrix(); - } - if (endT % 1 !== 0) { - const p = curve.at(endT); - gl.pushMatrix(); - const m = ts3dutils.M4.forSys(curve.points[endIndex].to(p), mesh.normals[endIndex * RES].toLength(width), mesh.normals[endIndex * RES + 1].toLength(width), curve.points[endIndex]); - gl.multMatrix(m); - gl.shaders.singleColor - .uniforms({ color: color }) - .draw(gl.meshes.pipeSegmentForICurve); - gl.popMatrix(); - } - } - else { - const p1 = curve.at(startT); - const p2 = curve.at(endT); - gl.pushMatrix(); - const v0 = p1.to(p2), v1 = v0.getPerpendicular().toLength(width), v2 = v0.cross(v1).toLength(width); - const m = ts3dutils.M4.forSys(v0, v1, v2, p1); - gl.multMatrix(m); - gl.shaders.singleColor - .uniforms({ color: color }) - .draw(gl.meshes.pipeSegmentForICurve); - gl.popMatrix(); - } - }, - [_.BezierCurve.name](gl, curve, color, startT, endT, width = 2, normal = ts3dutils.V3.Z) { - gl.shaders.bezier3d - .uniforms({ - p0: curve.p0, - p1: curve.p1, - p2: curve.p2, - p3: curve.p3, - color: color, - startT: startT, - endT: endT, - scale: width, - normal: normal, - }) - .draw(gl.meshes.pipe); - }, - [_.NURBS.name](gl, curve, color, startT, endT, width = 2, normal = ts3dutils.V3.Z) { - gl.shaders.nurbs - .uniforms({ - "points[0]": ts3dutils.Vector.pack(curve.points), - degree: curve.degree, - "knots[0]": curve.knots, - color: color, - startT: startT, - endT: endT, - scale: width, - normal: normal, - }) - .draw(gl.meshes.pipe); - }, - [_.L3.name](gl, curve, color, startT, endT, width = 2, normal = ts3dutils.V3.Z) { - gl.pushMatrix(); - const a = curve.at(startT), b = curve.at(endT); - const ab = b.minus(a), abT = ab.getPerpendicular().unit(); - const m = ts3dutils.M4.forSys(ab, abT, ab.cross(abT).unit(), a); - gl.multMatrix(m); - gl.scale(1, width, width); - gl.shaders.singleColor - .uniforms({ - color: color, - }) - .draw(gl.meshes.pipe); - gl.popMatrix(); - }, -}; -CURVE_PAINTERS[_.PICurve.name] = CURVE_PAINTERS[_.ImplicitCurve.name]; -CURVE_PAINTERS[_.PPCurve.name] = CURVE_PAINTERS[_.ImplicitCurve.name]; -function initMeshes(_meshes, _gl) { - _gl.makeCurrent(); - _meshes.cube = (() => { - const cube = _.B2T.box().toMesh().addVertexBuffer("colors", "ts_Color"); - cube.colors = cube.vertices.map((p) => [p.x, p.y, p.z, 1].map((x) => x * 0.9)); - cube.compile(); - return cube; - })(); - _meshes.sphere1 = tsgl.Mesh.sphere(2); - _meshes.segment = tsgl.Mesh.plane({ startY: -0.5, height: 1, detailX: 128 }); - _meshes.text = tsgl.Mesh.plane(); - _meshes.vector = tsgl.Mesh.rotation([ts3dutils.V3.O, ts3dutils.V(0, 0.05, 0), ts3dutils.V(0.8, 0.05), ts3dutils.V(0.8, 0.1), ts3dutils.V(1, 0)], _.L3.X, ts3dutils.TAU, 16, true); - _meshes.vectorShaft = tsgl.Mesh.rotation([ts3dutils.V3.O, ts3dutils.V3.Y, ts3dutils.V3.XY], _.L3.X, ts3dutils.TAU, 8, true); - _meshes.vectorHead = tsgl.Mesh.rotation([ts3dutils.V3.Y, ts3dutils.V(0, 2, 0), ts3dutils.V(2, 0, 0)], _.L3.X, ts3dutils.TAU, 8, true); - _meshes.pipe = tsgl.Mesh.rotation(ts3dutils.arrayFromFunction(512, (i, l) => new ts3dutils.V3(i / (l - 1), -0.5, 0)), _.L3.X, ts3dutils.TAU, 8, true); - _meshes.xyLinePlane = tsgl.Mesh.plane(); - _meshes.xyDottedLinePlane = makeDottedLinePlane(); - _meshes.pipeSegmentForICurve = tsgl.Mesh.offsetVertices(ts3dutils.M4.rotateY(90 * ts3dutils.DEG).transformedPoints(ts3dutils.arrayFromFunction(4, (i) => ts3dutils.V3.polar(1, (ts3dutils.TAU * i) / 4))), ts3dutils.V3.X, true); -} -function initShaders(_gl) { - _gl.makeCurrent(); - return { - singleColor: tsgl.Shader.create(vertexShaderBasic, fragmentShaderColor), - multiColor: tsgl.Shader.create(vertexShaderColor, fragmentShaderVaryingColor), - singleColorHighlight: tsgl.Shader.create(vertexShaderBasic, fragmentShaderColorHighlight), - textureColor: tsgl.Shader.create(vertexShaderTexture, fragmentShaderTextureColor), - arc: tsgl.Shader.create(vertexShaderRing, fragmentShaderColor), - arc2: tsgl.Shader.create(vertexShaderArc, fragmentShaderColor), - ellipse3d: tsgl.Shader.create(vertexShaderConic3d, fragmentShaderColor), - generic3d: tsgl.Shader.create(vertexShaderGeneric, fragmentShaderColor), - bezier3d: tsgl.Shader.create(vertexShaderBezier3d, fragmentShaderColor), - nurbs: tsgl.Shader.create(vertexShaderNURBS, fragmentShaderColor3), - bezier: tsgl.Shader.create(vertexShaderBezier, fragmentShaderColor), - lighting: tsgl.Shader.create(vertexShaderLighting, fragmentShaderLighting), - waves: tsgl.Shader.create(vertexShaderWaves, fragmentShaderLighting), - }; -} -function makeDottedLinePlane(count = 128) { - const mesh = new tsgl.Mesh().addIndexBuffer("LINES"); - const OXvertices = ts3dutils.arrayFromFunction(count, (i) => new ts3dutils.V3(i / count, 0, 0)); - mesh.vertices.push(...OXvertices); - mesh.vertices.push(...ts3dutils.M4.forSys(ts3dutils.V3.Y, ts3dutils.V3.O, ts3dutils.V3.O, ts3dutils.V3.X).transformedPoints(OXvertices)); - mesh.vertices.push(...ts3dutils.M4.forSys(ts3dutils.V3.X.negated(), ts3dutils.V3.O, ts3dutils.V3.O, new ts3dutils.V3(1, 1, 0)).transformedPoints(OXvertices)); - mesh.vertices.push(...ts3dutils.M4.forSys(ts3dutils.V3.Y.negated(), ts3dutils.V3.O, ts3dutils.V3.O, ts3dutils.V3.Y).transformedPoints(OXvertices)); - mesh.LINES = ts3dutils.arrayFromFunction(count * 4, (i) => i - (i >= count * 2 ? 1 : 0)); - mesh.compile(); - return mesh; -} -function initNavigationEvents(_gl, eye, paintScreen) { - const canvas = _gl.canvas; - let lastPos = ts3dutils.V3.O; - //_gl.onmousedown.push((e) => { - // e.preventDefault() - // e.stopPropagation() - //}) - //_gl.onmouseup.push((e) => { - // e.preventDefault() - // e.stopPropagation() - //}) - canvas.addEventListener("mousemove", (e) => { - const pagePos = ts3dutils.V(e.pageX, e.pageY); - const delta = lastPos.to(pagePos); - //noinspection JSBitwiseOperatorUsage - if (e.buttons & 4) { - // pan - const moveCamera = ts3dutils.V((-delta.x * 2) / _gl.canvas.width, (delta.y * 2) / _gl.canvas.height); - const inverseProjectionMatrix = _gl.projectionMatrix.inversed(); - const worldMoveCamera = inverseProjectionMatrix.transformVector(moveCamera); - eye.pos = eye.pos.plus(worldMoveCamera); - eye.focus = eye.focus.plus(worldMoveCamera); - setupCamera(eye, _gl); - paintScreen(); - } - // scene rotation - //noinspection JSBitwiseOperatorUsage - if (e.buttons & 2) { - const rotateLR = (-delta.x / 6.0) * ts3dutils.DEG; - const rotateUD = (-delta.y / 6.0) * ts3dutils.DEG; - // rotate - let matrix = ts3dutils.M4.rotateLine(eye.focus, eye.up, rotateLR); - //let horizontalRotationAxis = focus.minus(pos).cross(up) - const horizontalRotationAxis = eye.up.cross(eye.pos.minus(eye.focus)); - matrix = matrix.times(ts3dutils.M4.rotateLine(eye.focus, horizontalRotationAxis, rotateUD)); - eye.pos = matrix.transformPoint(eye.pos); - eye.up = matrix.transformVector(eye.up); - setupCamera(eye, _gl); - paintScreen(); - } - lastPos = pagePos; - }); - canvas.addEventListener("wheel", (e) => { - // zoom - const wheelY = -sign(e.deltaY) * 2; - // console.log(e.deltaY, e.deltaX) - eye.zoomFactor *= pow(0.9, -wheelY); - const mouseCoordsOnCanvas = getPosOnTarget(e); - const mousePosFrustrum = ts3dutils.V((mouseCoordsOnCanvas.x * 2) / _gl.canvas.offsetWidth - 1, (-mouseCoordsOnCanvas.y * 2) / _gl.canvas.offsetHeight + 1, 0); - const moveCamera = mousePosFrustrum.times(1 - 1 / pow(0.9, -wheelY)); - const inverseProjectionMatrix = _gl.projectionMatrix.inversed(); - const worldMoveCamera = inverseProjectionMatrix.transformVector(moveCamera); - //console.log("moveCamera", moveCamera) - //console.log("worldMoveCamera", worldMoveCamera) - eye.pos = eye.pos.plus(worldMoveCamera); - eye.focus = eye.focus.plus(worldMoveCamera); - // tilt - const mousePosWC = inverseProjectionMatrix.transformPoint(mousePosFrustrum); - const tiltMatrix = ts3dutils.M4.rotateLine(mousePosWC, eye.pos.to(eye.focus), -sign(e.deltaX) * 10 * ts3dutils.DEG); - eye.up = tiltMatrix.transformVector(eye.up); - eye.pos = tiltMatrix.transformPoint(eye.pos); - eye.focus = tiltMatrix.transformPoint(eye.focus); - setupCamera(eye, _gl); - paintScreen(); - e.preventDefault(); - }); -} -/** - * Transforms position on the screen into a line in world coordinates. - */ -function getMouseLine(pos, _gl) { - const ndc1 = ts3dutils.V((pos.x * 2) / _gl.canvas.width - 1, (-pos.y * 2) / _gl.canvas.height + 1, 0); - const ndc2 = ts3dutils.V((pos.x * 2) / _gl.canvas.width - 1, (-pos.y * 2) / _gl.canvas.height + 1, 1); - //console.log(ndc) - const inverseProjectionMatrix = _gl.projectionMatrix.inversed(); - const s = inverseProjectionMatrix.transformPoint(ndc1); - const dir = inverseProjectionMatrix.transformPoint(ndc2).minus(s); - return _.L3.anchorDirection(s, dir); -} -function getPosOnTarget(e) { - const target = e.target; - const targetRect = target.getBoundingClientRect(); - const mouseCoordsOnElement = { - x: e.clientX - targetRect.left, - y: e.clientY - targetRect.top, - }; - return mouseCoordsOnElement; -} -function setupCamera(_eye, _gl, suppressEvents = false) { - const { pos, focus, up, zoomFactor } = _eye; - //console.log("pos", pos.$, "focus", focus.$, "up", up.$) - _gl.matrixMode(_gl.PROJECTION); - _gl.loadIdentity(); - //_gl.perspective(70, _gl.canvas.width / _gl.canvas.height, 0.1, 1000); - const lr = _gl.canvas.width / 2 / zoomFactor; - const bt = _gl.canvas.height / 2 / zoomFactor; - _gl.ortho(-lr, lr, -bt, bt, -1e4, 1e4); - _gl.lookAt(pos, focus, up); - _gl.matrixMode(_gl.MODELVIEW); - !suppressEvents && cameraChangeListeners.forEach((l) => l(_eye)); -} -const cameraChangeListeners = []; -const SHADERS_TYPE_VAR = false ; -// let shaders: typeof SHADERS_TYPE_VAR -// declare let a: BRep, b: BRep, c: BRep, d: BRep, edges: Edge[] = [], hovering: any, -// , normallines: boolean = false, b2s: BRep[] = [] -// const - -class Quaternion { - constructor(s, x, y, z) { - this.s = s; - this.x = x; - this.y = y; - this.z = z; - } - static axis(axis, rotation) { - ts3dutils.assertf(() => axis.hasLength(1)); - return new Quaternion(cos(rotation / 2), sin(rotation / 2) * axis.x, sin(rotation / 2) * axis.y, sin(rotation / 2) * axis.z); - } - static of(s, x, y, z) { - return new Quaternion(s, x, y, z); - } - plus(q) { - return new Quaternion(this.s + q.s, this.x + q.x, this.y + q.y, this.z + q.z); - } - times(q) { - return "number" == typeof q - ? new Quaternion(q * this.s, q * this.x, q * this.y, q * this.z) - : new Quaternion(this.s * q.s - (this.x * q.x + this.y * q.y + this.z * q.z), this.y * q.z - this.z * q.y + this.s * q.x + q.s * this.x, this.z * q.x - this.x * q.z + this.s * q.y + q.s * this.y, this.x * q.y - this.y * q.x + this.s * q.z + q.s * this.z); - } - conjugated() { - return new Quaternion(this.s, -this.x, -this.y, -this.z); - } - length() { - return Math.hypot(this.s, this.x, this.y, this.z); - } - norm() { - return Math.pow(this.s, 2) + Math.pow(this.x, 2) + (Math.pow(this.y, 2) + Math.pow(this.z, 2)); - } - unit() { - const l = this.length(); - return new Quaternion(this.s / l, this.x / l, this.y / l, this.z / l); - } - inverse() { - return this.conjugated().times(1 / this.norm()); - } - toM4() { - ts3dutils.assertf(() => ts3dutils.eq(1, this.length())); - const { s, x, y, z } = this; - // prettier-ignore - return new ts3dutils.M4([ - 1 - 2 * (y * y + z * z), 2 * (x * y - z * s), 2 * (x * z + y * s), 0, - 2 * (x * y + z * s), 1 - 2 * (x * x + z * z), 2 * (y * z - x * s), 0, - 2 * (x * z - y * s), 2 * (y * z + x * s), 1 - 2 * (x * x + y * y), 0, - 0, 0, 0, 1, - ]); - } - static fromRotation(m4) { - const sqrtTracePlus1 = Math.sqrt(m4.trace() + 1); - const f = 1 / (2 * sqrtTracePlus1); - return new Quaternion(sqrtTracePlus1 / 2, f * (m4.e(2, 1) - m4.e(1, 2)), f * (m4.e(0, 2) - m4.e(2, 0)), f * (m4.e(1, 0) - m4.e(0, 1))); - } - rotatePoint(p) { - const v = this.times(Quaternion.of(1, p.x, p.y, p.z)).times(this.conjugated()); - return new ts3dutils.V3(v.x, v.y, v.z); - } - like(q, precision) { - return (ts3dutils.eq(this.s, q.s, precision) && - ts3dutils.eq(this.x, q.x, precision) && - ts3dutils.eq(this.y, q.y, precision) && - ts3dutils.eq(this.z, q.z, precision)); - } - equals(q) { - return (this == q || - (q instanceof Quaternion && - this.s == q.s && - this.x == q.x && - this.y == q.y && - this.z == q.z)); - } - hashCode() { - let hashCode = 0; - hashCode = (hashCode * 31 + ts3dutils.floatHashCode(this.s)) | 0; - hashCode = (hashCode * 31 + ts3dutils.floatHashCode(this.x)) | 0; - hashCode = (hashCode * 31 + ts3dutils.floatHashCode(this.y)) | 0; - hashCode = (hashCode * 31 + ts3dutils.floatHashCode(this.z)) | 0; - return hashCode; - } - slerp(b, f) { - ts3dutils.assertf(() => ts3dutils.eq(1, this.length())); - ts3dutils.assertf(() => ts3dutils.eq(1, b.length())); - const a = this; - let dot = a.s * b.s + a.x * b.x + a.y * b.y + a.z * b.z; - if (dot < 0) { - dot = -dot; - b = b.times(-1); - console.log("dot < 0"); - } - const DOT_THRESHOLD = 0.9995; - if (dot > DOT_THRESHOLD) { - // If the inputs are too close for comfort, linearly interpolate - // and normalize the result. - return a - .times(1 - f) - .plus(b.times(f)) - .unit(); - } - // Since dot is in range [0, DOT_THRESHOLD], acos is safe - const theta0 = acos(dot); // theta_0 = angle between input vectors - const theta = theta0 * f; // theta = angle between v0 and result - const s0 = cos(theta) - (dot * sin(theta)) / sin(theta0); // == sin(theta_0 - theta) / sin(theta_0) - const s1 = sin(theta) / sin(theta0); - console.log(s0, s1, a.times(s0), b.times(s1)); - return a.times(s0).plus(b.times(s1)); - } - toArray() { - return [this.s, this.x, this.y, this.z]; - } -} -Quaternion.O = new Quaternion(1, 0, 0, 0); - -class ImplicitSurface extends __.Surface { - static is(obj) { - return obj.implicitFunction && obj.didp; - } -} - -exports.AABB2 = AABB2; -exports.ALONG_EDGE_OR_PLANE = ALONG_EDGE_OR_PLANE; -exports.BREPGLContext = BREPGLContext; -exports.BRep = BRep; -exports.BezierCurve = BezierCurve; -exports.COLORS = COLORS; -exports.COPLANAR_OPPOSITE = COPLANAR_OPPOSITE; -exports.COPLANAR_SAME = COPLANAR_SAME; -exports.CURVE_PAINTERS = CURVE_PAINTERS; -exports.CalculateAreaVisitor = CalculateAreaVisitor; -exports.ClassSerializer = ClassSerializer; -exports.ConicSurface = ConicSurface; -exports.Curve = Curve; -exports.CustomPlane = CustomPlane; -exports.CylinderSurface = CylinderSurface; -exports.EPS = EPS; -exports.Edge = Edge; -exports.EllipseCurve = EllipseCurve; -exports.EllipsoidSurface = EllipsoidSurface; -exports.Face = Face; -exports.FaceInfoFactory = FaceInfoFactory; -exports.HyperbolaCurve = HyperbolaCurve; -exports.INSIDE = INSIDE; -exports.ImplicitCurve = ImplicitCurve; -exports.ImplicitSurface = ImplicitSurface; -exports.L3 = L3; -exports.NURBS = NURBS; -exports.NURBSSurface = NURBSSurface; -exports.OUTSIDE = OUTSIDE; -exports.P3 = P3; -exports.PCurveEdge = PCurveEdge; -exports.PICurve = PICurve; -exports.PPCurve = PPCurve; -exports.ParabolaCurve = ParabolaCurve; -exports.ParametricSurface = ParametricSurface; -exports.PlaneFace = PlaneFace; -exports.PlaneSurface = PlaneSurface; -exports.PointProjectedSurface = PointProjectedSurface; -exports.ProjectedCurveSurface = ProjectedCurveSurface; -exports.Quaternion = Quaternion; -exports.RotatedCurveSurface = RotatedCurveSurface; -exports.RotationFace = RotationFace; -exports.SHADERS_TYPE_VAR = SHADERS_TYPE_VAR; -exports.StraightEdge = StraightEdge; -exports.Surface = Surface; -exports.XiEtaCurve = XiEtaCurve; -exports.ZDirVolumeVisitor = ZDirVolumeVisitor; -exports.addLikeSurfaceFaces = addLikeSurfaceFaces; -exports.arbitraryCorner = arbitraryCorner; -exports.arrayLerp = arrayLerp; -exports.assembleFaceFromLooseEdges = assembleFaceFromLooseEdges; -exports.breakDownPPCurves = breakDownPPCurves; -exports.calcNextEdgeIndex = calcNextEdgeIndex; -exports.cameraChangeListeners = cameraChangeListeners; -exports.cas2 = cas2; -exports.cassini = cassini; -exports.createEdge = createEdge; -exports.curvePoint = curvePoint; -exports.curvePointMF = curvePointMF; -exports.curvePointPP = curvePointPP; -exports.doNotSerialize = doNotSerialize; -exports.dotCurve = dotCurve; -exports.dotCurve2 = dotCurve2; -exports.edgeForCurveAndTs = edgeForCurveAndTs; -exports.edgeNgon = edgeNgon; -exports.edgePathFromSVG = edgePathFromSVG; -exports.edgeRect = edgeRect; -exports.edgeStar = edgeStar; -exports.fff = fff; -exports.followAlgorithm2d = followAlgorithm2d; -exports.followAlgorithm2dAdjustable = followAlgorithm2dAdjustable; -exports.followAlgorithmPP = followAlgorithmPP; -exports.getExtremePointsHelper = getExtremePointsHelper; -exports.getGlobalId = getGlobalId; -exports.getMouseLine = getMouseLine; -exports.getPosOnTarget = getPosOnTarget; -exports.glqArray = glqArray; -exports.glqV3 = glqV3; -exports.initMeshes = initMeshes; -exports.initNavigationEvents = initNavigationEvents; -exports.initShaders = initShaders; -exports.intersectionCircleLine = intersectionCircleLine; -exports.intersectionICurveICurve = intersectionICurveICurve; -exports.intersectionICurveICurve2 = intersectionICurveICurve2; -exports.intersectionUnitCircleLine = intersectionUnitCircleLine; -exports.intersectionUnitCircleLine2 = intersectionUnitCircleLine2; -exports.intersectionUnitHyperbolaLine = intersectionUnitHyperbolaLine; -exports.parabola4Projection = parabola4Projection; -exports.parseGetParams = parseGetParams; -exports.projectCurve = projectCurve; -exports.projectPointCurve = projectPointCurve; -exports.reuleaux = reuleaux; -exports.rotateCurve = rotateCurve; -exports.round = round$1; -exports.setupCamera = setupCamera; -exports.splitsVolumeEnclosingCone = splitsVolumeEnclosingCone; -exports.splitsVolumeEnclosingCone2 = splitsVolumeEnclosingCone2; -exports.splitsVolumeEnclosingFaces = splitsVolumeEnclosingFaces; -exports.splitsVolumeEnclosingFacesP = splitsVolumeEnclosingFacesP; -exports.splitsVolumeEnclosingFacesP2 = splitsVolumeEnclosingFacesP2; -exports.surfaceIsICurveIsInfosWithLine = surfaceIsICurveIsInfosWithLine; -exports.triangulateVertices = triangulateVertices; -exports.uvInAABB2 = uvInAABB2; -//# sourceMappingURL=bundle.js.map diff --git a/dist/bundle.js.map b/dist/bundle.js.map deleted file mode 100644 index 58e7274..0000000 --- a/dist/bundle.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"bundle.js","sources":["../out/math.js","../out/curve/Curve.js","../out/curve/XiEtaCurve.js","../out/curve/ImplicitCurve.js","../out/curve/BezierCurve.js","../out/curve/HyperbolaCurve.js","../out/curve/L3.js","../out/curve/PICurve.js","../out/curve/PPCurve.js","../out/curve/ParabolaCurve.js","../out/curve/EllipseCurve.js","../out/curve/NURBS.js","../out/P3.js","../out/surface/Surface.js","../out/surface/ParametricSurface.js","../out/surface/ConicSurface.js","../out/surface/ProjectedCurveSurface.js","../out/surface/RotatedCurveSurface.js","../out/surface/CylinderSurface.js","../out/surface/EllipsoidSurface.js","../out/surface/PlaneSurface.js","../out/surface/PointProjectedSurface.js","../out/surface/NURBSSurface.js","../out/surface/ZDirVolumeVisitor.js","../out/surface/CalculateAreaVisitor.js","../out/BRepGenerators.js","../out/CustomPlane.js","../out/Edge.js","../out/StraightEdge.js","../out/PCurveEdge.js","../out/edgeUtil.js","../out/FaceInfo.js","../out/Face.js","../out/BRep.js","../out/ClassSerializer.js","../out/shaders.js","../out/BREPGLContext.js","../out/Quaternion.js","../out/surface/ImplicitSurface.js"],"sourcesContent":["export const { abs, acos, acosh, asin, asinh, atan, atanh, atan2, ceil, cbrt, expm1, clz32, cos, cosh, exp, floor, fround, hypot, imul, log, log1p, log2, log10, max, min, pow, random, round, sign, sin, sinh, sqrt, tan, tanh, trunc, E, LN10, LN2, LOG10E, LOG2E, PI, SQRT1_2, SQRT2, } = Math;\r\n//# sourceMappingURL=math.js.map","import { AABB, arrayEquals, arrayFromFunction, arrayHashCode, assert, assertNumbers, callsce, clamp, eq, eq0, fuzzyUniquesF, getIntervals, getLast, glqInSteps, hasConstructor, le, mapFilter, newtonIterate1d, newtonIterate2dWithDerivatives, newtonIterateWithDerivative, NLA_PRECISION, Transformable, V, V3, withMax, } from \"ts3dutils\";\r\nimport { curvePointPP, EllipsoidSurface, followAlgorithm2d, followAlgorithmPP, P3, PlaneSurface, PPCurve, ProjectedCurveSurface, } from \"../index\";\r\nimport { abs, ceil, floor } from \"../math\";\r\nlet insideIsInfosWithCurve = false;\r\nexport class Curve extends Transformable {\r\n constructor(tMin, tMax) {\r\n super();\r\n this.tMin = tMin;\r\n this.tMax = tMax;\r\n assertNumbers(tMin, tMax);\r\n assert(\"number\" === typeof tMin && !isNaN(tMin));\r\n assert(\"number\" === typeof tMax && !isNaN(tMax));\r\n assert(tMin < tMax, \"tMin < tMax \" + tMin + \" < \" + tMax);\r\n }\r\n static integrate(curve, startT, endT, steps) {\r\n const step = (endT - startT) / steps;\r\n let length = 0;\r\n let p = curve.at(startT);\r\n let i = 0, t = startT + step;\r\n for (; i < steps; i++, t += step) {\r\n const next = curve.at(t);\r\n length += p.distanceTo(next);\r\n p = next;\r\n }\r\n return length;\r\n }\r\n static ispsRecursive(curve1, tMin, tMax, curve2, sMin, sMax) {\r\n // the recursive function finds good approximates for the intersection points\r\n // curve1 function uses newton iteration to improve the result as much as possible\r\n function handleStartTS(startT, startS) {\r\n if (!result.some((info) => eq(info.tThis, startT) && eq(info.tOther, startS))) {\r\n const f1 = (t, s) => curve1.tangentAt(t).dot(curve1.at(t).minus(curve2.at(s)));\r\n const f2 = (t, s) => curve2.tangentAt(s).dot(curve1.at(t).minus(curve2.at(s)));\r\n // f = (b1, b2, t1, t2) = b1.tangentAt(t1).dot(b1.at(t1).minus(b2.at(t2)))\r\n const dfdt1 = (b1, b2, t1, t2) => b1.ddt(t1).dot(b1.at(t1).minus(b2.at(t2))) +\r\n b1.tangentAt(t1).squared();\r\n const dfdt2 = (b1, b2, t1, t2) => -b1.tangentAt(t1).dot(b2.tangentAt(t2));\r\n const ni = newtonIterate2dWithDerivatives(f1, f2, startT, startS, 16, dfdt1.bind(undefined, curve1, curve2), dfdt2.bind(undefined, curve1, curve2), (t, s) => -dfdt2(curve2, curve1, s, t), (t, s) => -dfdt1(curve2, curve1, s, t));\r\n assert(isFinite(ni.x));\r\n assert(isFinite(ni.y));\r\n if (ni == undefined)\r\n console.log(startT, startS, curve1.sce, curve2.sce);\r\n result.push({ tThis: ni.x, tOther: ni.y, p: curve1.at(ni.x) });\r\n }\r\n }\r\n // returns whether an intersection was immediately found (i.e. without further recursion)\r\n function findRecursive(tMin, tMax, sMin, sMax, curve1AABB, curve2AABB, depth = 0) {\r\n const EPS = NLA_PRECISION;\r\n if (curve1AABB.touchesAABBfuzzy(curve2AABB)) {\r\n const tMid = (tMin + tMax) / 2;\r\n const sMid = (sMin + sMax) / 2;\r\n if (Math.abs(tMax - tMin) < EPS || Math.abs(sMax - sMin) < EPS) {\r\n handleStartTS(tMid, sMid);\r\n return true;\r\n }\r\n else {\r\n const curve1AABBleft = curve1.getAABB(tMin, tMid);\r\n const curve2AABBleft = curve2.getAABB(sMin, sMid);\r\n let curve1AABBright, curve2AABBright;\r\n // if one of the following calls immediately finds an intersection, we don't want to call the others\r\n // as that will lead to the same intersection being output multiple times\r\n findRecursive(tMin, tMid, sMin, sMid, curve1AABBleft, curve2AABBleft, depth + 1) ||\r\n findRecursive(tMin, tMid, sMid, sMax, curve1AABBleft, (curve2AABBright = curve2.getAABB(sMid, sMax)), depth + 1) ||\r\n findRecursive(tMid, tMax, sMin, sMid, (curve1AABBright = curve1.getAABB(tMid, tMax)), curve2AABBleft, depth + 1) ||\r\n findRecursive(tMid, tMax, sMid, sMax, curve1AABBright, curve2AABBright, depth + 1);\r\n }\r\n }\r\n return false;\r\n }\r\n const result = [];\r\n findRecursive(tMin, tMax, sMin, sMax, curve1.getAABB(tMin, tMax), curve2.getAABB(sMin, sMax));\r\n return fuzzyUniquesF(result, (info) => info.tThis);\r\n }\r\n /**\r\n * Searches a 2d area for (an) implicit curve(s).\r\n * @param implicitCurve\r\n * @param bounds Defines area to search.\r\n * @param uStep Granularity of search in s-direction.\r\n * @param vStep Granularity of search in t-direction.\r\n * @param stepSize step size to take along the curve\r\n * @return\r\n */\r\n static breakDownIC(implicitCurve, bounds, uStep, vStep, stepSize, validUV) {\r\n //undefined == didu && (didu = (u, v) => (implicitCurve(u + EPS, v) - implicitCurve(u, v)) / EPS)\r\n //undefined == didv && (didv = (u, v) => (implicitCurve(u, v + EPS) - implicitCurve(u, v)) / EPS)\r\n const { uMin, uMax, vMin, vMax } = bounds;\r\n const deltaS = uMax - uMin, deltaT = vMax - vMin;\r\n const sRes = ceil(deltaS / uStep), tRes = ceil(deltaT / vStep);\r\n const grid = new Array(sRes * tRes).fill(0);\r\n // const printGrid = () =>\r\n // \tconsole.log(\r\n // \t\tarrayFromFunction(tRes, i =>\r\n // \t\t\tgrid\r\n // \t\t\t\t.slice(sRes * i, sRes * (i + 1))\r\n // \t\t\t\t.map(v => (v ? 'X' : '_'))\r\n // \t\t\t\t.join(''),\r\n // \t\t).join('\\n'),\r\n // \t)\r\n const get = (i, j) => grid[j * sRes + i];\r\n const set = (i, j) => 0 <= i && i < sRes && 0 <= j && j < tRes && (grid[j * sRes + i] = 1);\r\n const result = [];\r\n const logTable = [];\r\n for (let i = 0; i < sRes; i++) {\r\n search: for (let j = 0; j < tRes; j++) {\r\n if (get(i, j))\r\n continue;\r\n set(i, j);\r\n let u = uMin + (i + 0.5) * uStep, v = vMin + (j + 0.5) * vStep;\r\n const startS = u, startT = v;\r\n // basically curvePoint\r\n for (let k = 0; k < 8; k++) {\r\n const fp = implicitCurve(u, v);\r\n const dfpdx = implicitCurve.x(u, v), dfpdy = implicitCurve.y(u, v);\r\n if (0 === Math.pow(dfpdx, 2) + Math.pow(dfpdy, 2)) {\r\n // top of a hill, keep looking\r\n continue search;\r\n }\r\n const scale = fp / (Math.pow(dfpdx, 2) + Math.pow(dfpdy, 2));\r\n u -= scale * dfpdx;\r\n v -= scale * dfpdy;\r\n }\r\n const li = floor((u - uMin) / uStep), lj = floor((v - vMin) / vStep);\r\n logTable.push({\r\n i,\r\n j,\r\n li,\r\n lj,\r\n startS,\r\n startT,\r\n u,\r\n v,\r\n \"bounds(u, v)\": uvInAABB2(bounds, u, v),\r\n \"ic(s,t)\": implicitCurve(u, v),\r\n });\r\n if (!(i == li && j == lj) && get(li, lj)) {\r\n continue search;\r\n }\r\n set(li, lj);\r\n // u, v are now good starting coordinates to use follow algorithm\r\n if (uvInAABB2(bounds, u, v) &&\r\n validUV(u, v) &&\r\n eq0(implicitCurve(u, v))) {\r\n const subResult = mkcurves(implicitCurve, u, v, stepSize, bounds, validUV);\r\n for (const curveData of subResult) {\r\n assert(curveData.points.length > 2);\r\n for (const { x, y } of curveData.points) {\r\n const lif = (x - uMin) / uStep, ljf = (y - vMin) / vStep;\r\n set((lif - 0.5) | 0, (ljf - 0.5) | 0);\r\n set((lif - 0.5) | 0, (ljf + 0.5) | 0);\r\n set((lif + 0.5) | 0, (ljf - 0.5) | 0);\r\n set((lif + 0.5) | 0, (ljf + 0.5) | 0);\r\n }\r\n }\r\n //printGrid()\r\n result.push(...subResult);\r\n }\r\n }\r\n }\r\n // console.table(logTable)\r\n for (const { points } of result) {\r\n for (let i = 0; i < points.length - 1; i++) {\r\n assert(!points[i].equals(points[i + 1]));\r\n }\r\n }\r\n return result;\r\n }\r\n toString() {\r\n return this.toSource();\r\n }\r\n toSource(rounder = (x) => x) {\r\n return callsce.call(undefined, \"new \" + this.constructor.name, ...this.getConstructorParameters(), this.tMin, this.tMax);\r\n }\r\n withBounds(tMin = this.tMin, tMax = this.tMax) {\r\n //assert(this.tMin <= tMin && tMin <= this.tMax)\r\n //assert(this.tMin <= tMax && tMax <= this.tMax)\r\n return new this.constructor(...this.getConstructorParameters(), tMin, tMax);\r\n }\r\n /**\r\n * The point on the line that is closest to the given point.\r\n */\r\n closestPointToPoint(p) {\r\n return this.at(this.closestTToPoint(p));\r\n }\r\n isValidT(t) {\r\n return le(this.tMin, t) && le(t, this.tMax);\r\n }\r\n diff(t, eps) {\r\n return this.at(t).to(this.at(t + eps));\r\n }\r\n // TODO: tmin/tmax first\r\n closestTToPoint(p, tStart, tMin = this.tMin, tMax = this.tMax) {\r\n // this.at(t) has minimal distance to p when this.tangentAt(t) is perpendicular to\r\n // the vector between this.at(t) and p. This is the case iff the dot product of the two is 0.\r\n // f = (this.at(t) - p) . (this.tangentAt(t)\r\n // df = this.tangentAt(t) . this.tangentAt(t) + (this.at(t) - p) . this.ddt(t)\r\n // = this.tangentAt(t)² + (this.at(t) - p) . this.ddt(t)\r\n const f = (t) => this.at(t).minus(p).dot(this.tangentAt(t)); // 5th degree polynomial\r\n const df = (t) => this.tangentAt(t).squared() + this.at(t).minus(p).dot(this.ddt(t));\r\n //checkDerivate(f, df, tMin, tMax)\r\n const STEPS = 32;\r\n if (undefined === tStart) {\r\n tStart = withMax(arrayFromFunction(STEPS, (i) => tMin + ((tMax - tMin) * i) / (STEPS - 1)), (t) => -this.at(t).distanceTo(p));\r\n }\r\n return newtonIterateWithDerivative(f, tStart, 16, df);\r\n }\r\n /**\r\n * So different edges on the same curve do not have different vertices, they are always generated\r\n * on fixed points this.at(k * this.tIncrement), with k taking integer values\r\n *\r\n */\r\n calcSegmentPoints(aT, bT, a, b, reversed, includeFirst) {\r\n assert(this.tIncrement, \"tIncrement not defined on \" + this);\r\n const inc = this.tIncrement;\r\n const result = [];\r\n if (includeFirst)\r\n result.push(a);\r\n assert(reversed != aT < bT);\r\n if (aT < bT) {\r\n const start = Math.ceil((aT + NLA_PRECISION) / inc);\r\n const end = Math.floor((bT - NLA_PRECISION) / inc);\r\n for (let i = start; i <= end; i++) {\r\n result.push(this.at(i * inc));\r\n }\r\n }\r\n else {\r\n const start = Math.floor((aT - NLA_PRECISION) / inc);\r\n const end = Math.ceil((bT + NLA_PRECISION) / inc);\r\n for (let i = start; i >= end; i--) {\r\n result.push(this.at(i * inc));\r\n }\r\n }\r\n result.push(b);\r\n return result;\r\n }\r\n calcSegmentTs(aT, bT, reversed, includeFirst) {\r\n assert(this.tIncrement, \"tIncrement not defined on \" + this);\r\n const inc = this.tIncrement;\r\n const result = [];\r\n if (includeFirst)\r\n result.push(aT);\r\n assert(reversed != aT < bT);\r\n if (aT < bT) {\r\n const start = Math.ceil((aT + NLA_PRECISION) / inc);\r\n const end = Math.floor((bT - NLA_PRECISION) / inc);\r\n for (let i = start; i <= end; i++) {\r\n result.push(i * inc);\r\n }\r\n }\r\n else {\r\n const start = Math.floor((aT - NLA_PRECISION) / inc);\r\n const end = Math.ceil((bT + NLA_PRECISION) / inc);\r\n for (let i = start; i >= end; i--) {\r\n result.push(i * inc);\r\n }\r\n }\r\n result.push(bT);\r\n return result;\r\n }\r\n /**\r\n *\r\n * @param p\r\n * @param tStart Defines interval with tEnd in which a start value for t will be searched.\r\n * Result is not necessarily in this interval.\r\n * @param tEnd\r\n */\r\n distanceToPoint(p, tStart, tEnd) {\r\n const closestT = this.closestTToPoint(p, tStart, tEnd);\r\n return this.at(closestT).distanceTo(p);\r\n }\r\n asSegmentDistanceToPoint(p, tStart, tEnd) {\r\n let t = this.closestTToPoint(p, tStart, tEnd);\r\n t = clamp(t, tStart, tEnd);\r\n return this.at(t).distanceTo(p);\r\n }\r\n /**\r\n * Behavior when curves are colinear: self intersections\r\n */\r\n isInfosWithCurve(curve) {\r\n if (insideIsInfosWithCurve) {\r\n return Curve.ispsRecursive(this, this.tMin, this.tMax, curve, curve.tMin, curve.tMax);\r\n }\r\n else {\r\n try {\r\n insideIsInfosWithCurve = true;\r\n const infos = curve.isInfosWithCurve(this);\r\n return infos.map((info) => {\r\n assert(info);\r\n const { tThis, tOther, p } = info;\r\n return { tOther: tThis, tThis: tOther, p };\r\n });\r\n }\r\n finally {\r\n insideIsInfosWithCurve = false;\r\n }\r\n }\r\n }\r\n isTsWithSurface(surface) {\r\n if (surface instanceof PlaneSurface) {\r\n return this.isTsWithPlane(surface.plane);\r\n }\r\n if (surface instanceof ProjectedCurveSurface) {\r\n const projPlane = new P3(surface.dir.unit(), 0);\r\n const projThis = this.project(projPlane);\r\n const projEllipse = surface.baseCurve.project(projPlane);\r\n return projEllipse.isInfosWithCurve(projThis).map((info) => info.tOther);\r\n }\r\n if (surface instanceof EllipsoidSurface) {\r\n const thisOC = this.transform(surface.matrixInverse);\r\n if (!thisOC.getAABB().touchesAABBfuzzy(new AABB(V3.XYZ.negated(), V3.XYZ))) {\r\n return [];\r\n }\r\n const f = (t) => thisOC.at(t).length() - 1;\r\n const df = (t) => thisOC.at(t).unit().dot(thisOC.tangentAt(t));\r\n const stepSize = 1 / (1 << 11);\r\n const result = [];\r\n for (let startT = this.tMin; startT <= this.tMax; startT += stepSize) {\r\n const dt = stepSize * thisOC.tangentAt(startT).length();\r\n if (abs(f(startT)) <= dt) {\r\n //const t = newtonIterate1d(f, startT, 16)\r\n let t = newtonIterateWithDerivative(f, startT, 16, df);\r\n if (!eq0(f(t)) || eq0(df(t))) {\r\n t = newtonIterate1d(df, startT, 16);\r\n //if (f(a) * f(b) < 0) {\r\n // t = bisect(f, a, b, 16)\r\n //} else if (df(a) * df(b) < 0) {\r\n // t = bisect(df, a, b, 16)\r\n //}\r\n }\r\n if (eq0(f(t)) && !result.some((r) => eq(r, t))) {\r\n result.push(t);\r\n }\r\n }\r\n }\r\n return result.filter((t) => surface.containsPoint(this.at(t)));\r\n }\r\n throw new Error();\r\n }\r\n arcLength(startT, endT, steps = 1) {\r\n assert(startT < endT, \"startT < endT\");\r\n return glqInSteps((t) => this.tangentAt(t).length(), startT, endT, steps);\r\n }\r\n equals(obj) {\r\n if (this === obj)\r\n return true;\r\n return (hasConstructor(obj, this.constructor) &&\r\n arrayEquals(this.getConstructorParameters(), obj.getConstructorParameters()));\r\n }\r\n hashCode() {\r\n return arrayHashCode(this.getConstructorParameters());\r\n }\r\n getAABB(tMin = this.tMin, tMax = this.tMax) {\r\n tMin = isFinite(tMin) ? tMin : this.tMin;\r\n tMax = isFinite(tMax) ? tMax : this.tMax;\r\n const tMinAt = this.at(tMin), tMaxAt = this.at(tMax);\r\n const roots = this.roots();\r\n const mins = [0, 0, 0];\r\n const maxs = [0, 0, 0];\r\n for (let dim = 0; dim < 3; dim++) {\r\n const tRoots = roots[dim];\r\n mins[dim] = Math.min(tMinAt.e(dim), tMaxAt.e(dim));\r\n maxs[dim] = Math.max(tMinAt.e(dim), tMaxAt.e(dim));\r\n for (const tRoot of tRoots) {\r\n if (tMin < tRoot && tRoot < tMax) {\r\n mins[dim] = Math.min(mins[dim], this.at(tRoot).e(dim));\r\n maxs[dim] = Math.max(maxs[dim], this.at(tRoot).e(dim));\r\n }\r\n }\r\n }\r\n return new AABB(V3.fromArray(mins), V3.fromArray(maxs));\r\n }\r\n reversed() {\r\n throw new Error();\r\n }\r\n clipPlane(plane) {\r\n const ists = this.isTsWithPlane(plane).filter((ist) => this.tMin <= ist && ist <= this.tMax);\r\n return mapFilter(getIntervals(ists, this.tMin, this.tMax), ([a, b]) => {\r\n const midT = (a + b) / 2;\r\n return (!eq(a, b) &&\r\n plane.distanceToPointSigned(this.at(midT)) < 0 &&\r\n this.withBounds(a, b));\r\n });\r\n }\r\n}\r\nCurve.hlol = 0;\r\nfunction mkcurves(implicitCurve, sStart, tStart, stepSize, bounds, validUV) {\r\n const start = V(sStart, tStart);\r\n assert(stepSize > 0);\r\n // checkDerivate(s => implicitCurve(s, 0), s => didu(s, 0), -1, 1, 0)\r\n // checkDerivate(t => implicitCurve(0, t), t => didv(0, t), -1, 1, 0)\r\n const { points, tangents } = followAlgorithm2d(implicitCurve, start, stepSize, bounds, validUV);\r\n if (points.length > 4 &&\r\n points[0].distanceTo(getLast(points)) <= abs(stepSize)) {\r\n // this is a loop: split it\r\n for (let i = 0; i < points.length - 1; i++) {\r\n assert(!points[i].equals(points[i + 1]));\r\n }\r\n const half = floor(points.length / 2);\r\n const points1 = points.slice(0, half), points2 = points.slice(half - 1, points.length);\r\n const tangents1 = tangents.slice(0, half), tangents2 = tangents.slice(half - 1, tangents.length);\r\n //tangents2[tangents2.length - 1] = tangents1[0]\r\n //points2[tangents2.length - 1] = points1[0]\r\n for (let i = 0; i < points1.length - 1; i++) {\r\n assert(!points1[i].equals(points1[i + 1]));\r\n }\r\n for (let i = 0; i < points2.length - 1; i++) {\r\n assert(!points2[i].equals(points2[i + 1]));\r\n }\r\n return [\r\n { points: points1, tangents: tangents1 },\r\n { points: points2, tangents: tangents2 },\r\n ];\r\n }\r\n else {\r\n // not a loop: check in the other direction\r\n const { points: reversePoints, tangents: reverseTangents, } = followAlgorithm2d(implicitCurve, start, -stepSize, bounds, validUV);\r\n const result = followAlgorithm2d(implicitCurve, getLast(reversePoints), stepSize, bounds, validUV, undefined, getLast(reverseTangents).negated());\r\n assert(result.points.length > 2);\r\n return [result];\r\n }\r\n}\r\nexport function breakDownPPCurves(ps1, ps2, uStep, vStep, stepSize) {\r\n const { uMin, uMax, vMin, vMax } = ps1;\r\n const bounds = uvInAABB2.bind(undefined, ps1);\r\n const bounds2 = uvInAABB2.bind(undefined, ps2);\r\n const deltaU = uMax - uMin, deltaV = vMax - vMin;\r\n const sRes = ceil(deltaU / uStep), tRes = ceil(deltaV / vStep);\r\n const grid = new Array(sRes * tRes).fill(0);\r\n //const printGrid = () => console.log(arrayFromFunction(tRes, i => grid.slice(sRes * i, sRes * (i + 1)).map(v => v ? 'X' : '_').join('')).join('\\n'))\r\n const at = (i, j) => grid[j * sRes + i];\r\n const set = (i, j) => 0 <= i && i < sRes && 0 <= j && j < tRes && (grid[j * sRes + i] = 1);\r\n const result = [];\r\n const logTable = [];\r\n for (let i = 0; i < sRes; i++) {\r\n search: for (let j = 0; j < tRes; j++) {\r\n if (at(i, j))\r\n continue;\r\n set(i, j);\r\n const startU = uMin + (i + 0.5) * uStep, startV = vMin + (j + 0.5) * vStep;\r\n // assume point is valid, currently (TODO)\r\n const curvePointPPResult = curvePointPP(ps1, ps2, ps1.pUV(startU, startV));\r\n if (undefined === curvePointPPResult) {\r\n continue search;\r\n }\r\n const { p: startP, st1: { x: u, y: v }, st2: { x: u2, y: v2 }, } = curvePointPPResult;\r\n const li = floor((u - uMin) / uStep), lj = floor((v - vMin) / vStep);\r\n logTable.push({\r\n i,\r\n j,\r\n li,\r\n lj,\r\n startU,\r\n startV,\r\n u,\r\n v,\r\n \"bounds(u, v)\": bounds(u, v),\r\n });\r\n if (!(i == li && j == lj) && at(li, lj)) {\r\n continue search;\r\n }\r\n set(li, lj);\r\n // u, v are now good starting coordinates to use follow algorithm\r\n if (bounds(u, v) && bounds2(u2, v2)) {\r\n console.log(V(u, v).sce);\r\n const subResult = mkPPCurves(ps1, ps2, startP, stepSize, bounds, bounds2);\r\n for (const curveData of subResult) {\r\n assert(curveData.st1s.length > 2);\r\n for (const { x, y } of curveData.st1s) {\r\n const lif = (x - uMin) / uStep, ljf = (y - vMin) / vStep;\r\n set((lif - 0.5) | 0, (ljf - 0.5) | 0);\r\n set((lif - 0.5) | 0, (ljf + 0.5) | 0);\r\n set((lif + 0.5) | 0, (ljf - 0.5) | 0);\r\n set((lif + 0.5) | 0, (ljf + 0.5) | 0);\r\n }\r\n }\r\n //printGrid()\r\n result.push(...subResult);\r\n }\r\n }\r\n }\r\n console.table(logTable);\r\n for (const { points } of result) {\r\n for (let i = 0; i < points.length - 1; i++) {\r\n assert(!points[i].equals(points[i + 1]));\r\n }\r\n }\r\n return result.map(({ points, tangents, st1s }) => {\r\n return new PPCurve(points, tangents, ps1, ps2, st1s, undefined, stepSize, 1);\r\n });\r\n}\r\nfunction mkPPCurves(ps1, ps2, startPoint, stepSize, bounds1, bounds2) {\r\n // checkDerivate(s => implicitCurve(s, 0), s => didu(s, 0), -1, 1, 0)\r\n // checkDerivate(t => implicitCurve(0, t), t => didv(0, t), -1, 1, 0)\r\n const { points, tangents, st1s } = followAlgorithmPP(ps1, ps2, startPoint, stepSize, bounds1, bounds2);\r\n if (points[0].distanceTo(getLast(points)) < stepSize && points.length > 2) {\r\n // this is a loop: split it\r\n for (let i = 0; i < points.length - 1; i++) {\r\n assert(!points[i].equals(points[i + 1]));\r\n }\r\n const half = floor(points.length / 2);\r\n const points1 = points.slice(0, half), points2 = points.slice(half - 1, points.length);\r\n const tangents1 = tangents.slice(0, half), tangents2 = tangents.slice(half - 1, tangents.length);\r\n const st1s1 = st1s.slice(0, half), st1s2 = st1s.slice(half - 1, tangents.length);\r\n tangents2[tangents2.length - 1] = tangents1[0];\r\n points2[tangents2.length - 1] = points1[0];\r\n st1s2[tangents2.length - 1] = st1s1[0];\r\n for (let i = 0; i < points1.length - 1; i++) {\r\n assert(!points1[i].equals(points1[i + 1]));\r\n }\r\n for (let i = 0; i < points2.length - 1; i++) {\r\n assert(!points2[i].equals(points2[i + 1]));\r\n }\r\n return [\r\n { points: points1, tangents: tangents1, st1s: st1s1 },\r\n { points: points2, tangents: tangents2, st1s: st1s2 },\r\n ];\r\n }\r\n else {\r\n // not a loop: check in the other direction\r\n const { points: reversePoints } = followAlgorithmPP(ps1, ps2, startPoint, -stepSize, bounds1, bounds2);\r\n const result = followAlgorithmPP(ps1, ps2, getLast(reversePoints), stepSize, bounds1, bounds2);\r\n assert(result.points.length > 2);\r\n return [result];\r\n }\r\n}\r\nexport function AABB2(uMin, uMax, vMin, vMax) {\r\n return { uMin, uMax, vMin, vMax };\r\n}\r\nexport function uvInAABB2(aabb2, u, v) {\r\n return (aabb2.uMin <= u && u <= aabb2.uMax && aabb2.vMin <= v && v <= aabb2.vMax);\r\n}\r\n/**\r\n * Finds a point on a 2D implicit curve.\r\n *\r\n * @param implicitCurve The curve follows the path where implicitCurve(u, v) is zero.\r\n * @param startPoint The point from which to start looking (only .x = u and .y = v will be read).\r\n * @param didu Derivative of implicitCurve in the first parameter.\r\n * @param didv Derivative of implicitCurve in the second parameter.\r\n */\r\nexport function curvePoint(implicitCurve, startPoint, didu, didv) {\r\n let p = startPoint;\r\n for (let i = 0; i < 8; i++) {\r\n const fp = implicitCurve(p.x, p.y);\r\n const dfpdx = didu(p.x, p.y);\r\n const dfpdy = didv(p.x, p.y);\r\n const scale = fp / (dfpdx * dfpdx + dfpdy * dfpdy);\r\n p = p.minus(new V3(scale * dfpdx, scale * dfpdy, 0));\r\n }\r\n return p;\r\n}\r\nexport function curvePointMF(mf, startPoint, steps = 8, eps = 1 / (1 << 30)) {\r\n let p = startPoint;\r\n for (let i = 0; i < steps; i++) {\r\n const fp = mf(p.x, p.y);\r\n const dfpdx = mf.x(p.x, p.y);\r\n const dfpdy = mf.y(p.x, p.y);\r\n const scale = fp / (dfpdx * dfpdx + dfpdy * dfpdy);\r\n p = p.minus(new V3(scale * dfpdx, scale * dfpdy, 0));\r\n if (abs(fp) <= eps)\r\n break;\r\n }\r\n return p;\r\n}\r\n//# sourceMappingURL=Curve.js.map","import { arrayFromFunction, assertInst, assertNumbers, assertVectors, eq0, hasConstructor, M4, mapFilter, NLA_PRECISION, snap0, solveCubicReal2, TAU, toSource, V, V3, } from \"ts3dutils\";\r\nimport { pushQuad } from \"tsgl\";\r\nimport { BezierCurve, ConicSurface, Curve, EllipseCurve, EllipsoidSurface, HyperbolaCurve, L3, P3, ParabolaCurve, PlaneSurface, ProjectedCurveSurface, } from \"../index\";\r\nimport { abs, acos, acosh, sign, sqrt } from \"../math\";\r\nexport class XiEtaCurve extends Curve {\r\n constructor(center, f1, f2, tMin, tMax) {\r\n super(tMin, tMax);\r\n this.center = center;\r\n this.f1 = f1;\r\n this.f2 = f2;\r\n this.tMin = tMin;\r\n this.tMax = tMax;\r\n assertVectors(center, f1, f2);\r\n this.normal = f1.cross(f2);\r\n if (!this.normal.likeO()) {\r\n this.normal = this.normal.unit();\r\n this.matrix = M4.forSys(f1, f2, this.normal, center);\r\n this.matrixInverse = this.matrix.inversed();\r\n }\r\n else {\r\n this.matrix = M4.forSys(f1, f2, f1.unit(), center);\r\n const f1p = f1.getPerpendicular();\r\n // prettier-ignore\r\n this.matrixInverse = new M4(1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1).times(M4.forSys(f1, f1p, f1.cross(f1p), center).inversed());\r\n }\r\n }\r\n /**\r\n * Intersection of the unit curve with the line ax + by = c.\r\n */\r\n static intersectionUnitLine(a, b, c, tMin, tMax) {\r\n throw new Error(\"abstract\");\r\n }\r\n /**\r\n * Returns a new EllipseCurve representing an ellipse parallel to the XY-plane\r\n * with semi-major/minor axes parallel t the X and Y axes.\r\n *\r\n * @param a length of the axis parallel to X axis.\r\n * @param b length of the axis parallel to Y axis.\r\n * @param center center of the ellipse.\r\n */\r\n static forAB(a, b, center = V3.O) {\r\n return new this(center, V(a, 0, 0), V(0, b, 0));\r\n }\r\n static XYLCValid(pLC) {\r\n throw new Error(\"abstract\");\r\n }\r\n static XYLCPointT(pLC, tMin, tMax) {\r\n throw new Error(\"abstract\");\r\n }\r\n static unitIsInfosWithLine(anchorLC, dirLC, anchorWC, dirWC, tMin, tMax) {\r\n throw new Error(\"abstract\");\r\n }\r\n addToMesh(mesh, res = 4, radius = 0, pointStep = 1) {\r\n const baseNormals = arrayFromFunction(res, (i) => V3.polar(1, (TAU * i) / res));\r\n const baseVertices = arrayFromFunction(res, (i) => V3.polar(radius, (TAU * i) / res));\r\n const inc = this.tIncrement;\r\n const start = Math.ceil((this.tMin + NLA_PRECISION) / inc);\r\n const end = Math.floor((this.tMax - NLA_PRECISION) / inc);\r\n for (let i = start; i <= end; i += pointStep) {\r\n const t = i * inc;\r\n const start = mesh.vertices.length;\r\n if (0 !== i) {\r\n for (let j = 0; j < res; j++) {\r\n pushQuad(mesh.TRIANGLES, true, start - res + j, start + j, start - res + ((j + 1) % res), start + ((j + 1) % res));\r\n }\r\n }\r\n const point = this.at(t), tangent = this.tangentAt(t);\r\n const matrix = M4.forSys(this.normal, tangent.cross(this.normal), tangent, point);\r\n mesh.normals.push(...matrix.transformedVectors(baseNormals));\r\n mesh.vertices.push(...matrix.transformedPoints(baseVertices));\r\n }\r\n }\r\n getConstructorParameters() {\r\n return [this.center, this.f1, this.f2];\r\n }\r\n isInfosWithCurve(curve) {\r\n if (curve instanceof L3) {\r\n return this.isInfosWithLine(curve.anchor, curve.dir1, this.tMin, this.tMax, curve.tMin, curve.tMax);\r\n }\r\n if (curve instanceof BezierCurve) {\r\n return this.isInfosWithBezier(curve);\r\n }\r\n if (curve instanceof XiEtaCurve) {\r\n if (!this.normal.isParallelTo(curve.normal)) {\r\n return mapFilter(this.isTsWithPlane(curve.getPlane()), (tThis) => {\r\n const p = this.at(tThis);\r\n if (curve.containsPoint(p)) {\r\n return { tThis, tOther: curve.pointT(p), p };\r\n }\r\n return undefined;\r\n });\r\n }\r\n }\r\n return super.isInfosWithCurve(curve);\r\n }\r\n transform(m4) {\r\n return new this.constructor(m4.transformPoint(this.center), m4.transformVector(this.f1), m4.transformVector(this.f2), this.tMin, this.tMax);\r\n }\r\n equals(obj) {\r\n return (this == obj ||\r\n (undefined != obj &&\r\n this.constructor == obj.constructor &&\r\n this.center.equals(obj.center) &&\r\n this.f1.equals(obj.f1) &&\r\n this.f2.equals(obj.f2)));\r\n }\r\n hashCode() {\r\n let hashCode = 0;\r\n hashCode = hashCode * 31 + this.center.hashCode();\r\n hashCode = hashCode * 31 + this.f1.hashCode();\r\n hashCode = hashCode * 31 + this.f2.hashCode();\r\n return hashCode | 0;\r\n }\r\n likeCurve(curve) {\r\n return (hasConstructor(curve, this.constructor) &&\r\n this.center.like(curve.center) &&\r\n this.f1.like(curve.f1) &&\r\n this.f2.like(curve.f2));\r\n }\r\n normalP(t) {\r\n return this.tangentAt(t).cross(this.normal);\r\n }\r\n getPlane() {\r\n return P3.normalOnAnchor(this.normal, this.center);\r\n }\r\n isTsWithPlane(planeWC) {\r\n assertInst(P3, planeWC);\r\n /*\r\n this: x = center + f1 * cos t + f2 * sin t (1)\r\n plane:\r\n n := plane.normal1\r\n n DOT x == plane.w (2)\r\n plane defined by f1/f2\r\n x = center + f1 * xi + f2 * eta (3)\r\n intersection plane and planef1/f2:\r\n insert (3) into (2):\r\n n DOT center + n DOT f1 * xi + n DOT f2 * eta = plane.w | -n DOT center\r\n n DOT f1 * xi + n DOT f2 * eta = plane.w - n DOT center (4)\r\n points on ellipse have additional condition\r\n eta * eta + xi * xi = 1 (5)\r\n g1 := n DOT f1\r\n g2 := n DOT f2\r\n g3 := w - n DOT center\r\n solve system (5)/(6)\r\n g1 * xi + g2 * eta = g3 (6)\r\n */\r\n if (planeWC.normal1.isParallelTo(this.normal)) {\r\n return [];\r\n }\r\n const n = planeWC.normal1, w = planeWC.w, center = this.center, f1 = this.f1, f2 = this.f2, g1 = n.dot(f1), g2 = n.dot(f2), g3 = w - n.dot(center);\r\n return this.constructor.intersectionUnitLine(g1, g2, g3, this.tMin, this.tMax);\r\n }\r\n pointT(p) {\r\n assertVectors(p);\r\n const pLC = this.matrixInverse.transformPoint(p);\r\n return this.constructor.XYLCPointT(pLC);\r\n }\r\n containsPoint(p) {\r\n const pLC = this.matrixInverse.transformPoint(p);\r\n return (eq0(pLC.z) &&\r\n this.isValidT(this.constructor.XYLCPointT(pLC, this.tMin, this.tMax)));\r\n }\r\n isInfosWithLine(anchorWC, dirWC, tMin = this.tMin, tMax = this.tMax, lineMin = -100000, lineMax = 100000) {\r\n const anchorLC = this.matrixInverse.transformPoint(anchorWC);\r\n const dirLC = this.matrixInverse.transformVector(dirWC);\r\n if (eq0(dirLC.z)) {\r\n // local line parallel to XY-plane\r\n if (eq0(anchorLC.z)) {\r\n // local line lies in XY-plane\r\n return this.constructor.unitIsInfosWithLine(anchorLC, dirLC, anchorWC, dirWC, tMin, tMax);\r\n }\r\n }\r\n else {\r\n // if the line intersects the XY-plane in a single point, there can be an intersection there\r\n // find point, then check if distance from circle = 1\r\n const otherTAtZ0 = anchorLC.z / dirLC.z;\r\n const isp = dirLC.times(otherTAtZ0).plus(anchorLC);\r\n if (this.constructor.XYLCValid(isp)) {\r\n // point lies on unit circle\r\n return [\r\n {\r\n tThis: this.constructor.XYLCPointT(isp),\r\n tOther: otherTAtZ0,\r\n p: anchorWC.plus(dirWC.times(otherTAtZ0)),\r\n },\r\n ];\r\n }\r\n }\r\n return [];\r\n }\r\n isTsWithSurface(surface) {\r\n if (surface instanceof PlaneSurface) {\r\n return this.isTsWithPlane(surface.plane);\r\n }\r\n else if (surface instanceof EllipsoidSurface) {\r\n const isEllipses = surface.isCurvesWithPlane(this.getPlane());\r\n return isEllipses\r\n .flatMap((isEllipse) => this.isInfosWithCurve(isEllipse))\r\n .filter((info) => surface.containsPoint(info.p))\r\n .map((info) => info.tThis);\r\n }\r\n else if (surface instanceof ProjectedCurveSurface ||\r\n surface instanceof ConicSurface) {\r\n return surface\r\n .isCurvesWithPlane(this.getPlane())\r\n .flatMap((curve) => this.isInfosWithCurve(curve))\r\n .map((info) => info.tThis);\r\n }\r\n else {\r\n throw new Error();\r\n }\r\n }\r\n isInfosWithBezier(bezierWC) {\r\n const bezierLC = bezierWC.transform(this.matrixInverse);\r\n if (new PlaneSurface(P3.XY).containsCurve(bezierLC)) {\r\n return this.isInfosWithBezier2D(bezierWC);\r\n }\r\n else {\r\n const infos = mapFilter(bezierLC.isTsWithPlane(P3.XY), (tOther) => {\r\n const pLC = bezierLC.at(tOther);\r\n if (this.constructor.XYLCValid(pLC)) {\r\n return {\r\n tOther: tOther,\r\n p: bezierWC.at(tOther),\r\n tThis: this.constructor.XYLCPointT(pLC),\r\n };\r\n }\r\n return undefined;\r\n });\r\n return infos;\r\n }\r\n }\r\n isInfosWithBezier2D(bezierWC, sMin = bezierWC.tMin, sMax = bezierWC.tMax) {\r\n return Curve.ispsRecursive(this, this.tMin, this.tMax, bezierWC, sMin, sMax);\r\n }\r\n isOrthogonal() {\r\n return this.f1.isPerpendicularTo(this.f2);\r\n }\r\n at2(xi, eta) {\r\n assertNumbers(xi, eta);\r\n // center + f1 xi + f2 eta\r\n return this.center.plus(this.f1.times(xi)).plus(this.f2.times(eta));\r\n }\r\n debugInfo() {\r\n return {\r\n points: [\r\n this.center,\r\n this.at2(0.5, 0),\r\n this.at2(0, 1 / 3),\r\n this.at2(0, 2 / 3),\r\n ],\r\n lines: [this.center, this.at2(0, 1), this.center, this.at2(1, 0)],\r\n };\r\n }\r\n}\r\n/**\r\n * Transforms the unit 4d parabola\r\n * P(t) = t² (0, 1, 0, 0) + t (1, 0, 0, 0) + (0, 0, 0, 1) using m and projects\r\n * the result into 3d. This is used for the transform4 implementation of conics.\r\n * The parabola may not cross the vanishing plane of m in the interval\r\n * [tMin, tMax], as that would result in discontinuities.\r\n */\r\nexport function parabola4Projection(m, tMin, tMax) {\r\n const w1 = m.m[12];\r\n const w2 = m.m[13];\r\n const wc = m.m[15];\r\n // if the 4d parabola crosses the vanishing plane, it will lead to multiple/infinite hyperbolas, both of which we\r\n // want to avoid. Hence, we must check that the entire interval [tMin, tMax] is on one side of the vanishing plane.\r\n // Checking tMax, tMin and the extremas is enough.\r\n const extremas = solveCubicReal2(0, w2, w1, wc);\r\n const wx0 = (x) => Number.isFinite(x) ? snap0(Math.pow(x, 2) * w2 + x * w1 + wc) : sign(w2) * Infinity;\r\n if (wx0(tMin) * wx0(tMax) < 0 ||\r\n extremas.some((x) => wx0(x) * (wx0(tMin) + wx0(tMax)) < 0)) {\r\n console.log(m.str);\r\n throw new Error(\"The entire interval must be on one side of the vanishing plane. P=\" +\r\n toSource(P3.vanishingPlane(m)));\r\n }\r\n if (eq0(wc)) {\r\n // the following matrix maps a curve C onto itself, with the parameter being inverted:\r\n // C2(t) = C(-1/t). This makes C(0) a real value, which is necessary for the projection calculation.\r\n // the sign inversion is so the tangent direction does not change.\r\n // prettier-ignore\r\n const mm = new M4(-1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0);\r\n if (!eq0(w2)) {\r\n return parabola4Projection(m.times(mm), -1 / tMin, -1 / tMax);\r\n }\r\n // wc == w2 == 0 => degenerates to a line:\r\n // C(t) = (t² f2 + t f1 + c) / (t w1)\r\n // C(t) = (t f2 + f1 + c) / (t w2 + w1)\r\n // substitute t = (1/s - w1) / w2\r\n // C(s) = f2 / w2 + s (f1 - f2 w1 / w2), which is a line\r\n // we can multiply the direction vector by w2 to avoid divisions:\r\n // C(t) = f2 / w2 + s (f1 w2 - f2 w1)\r\n const f1 = m.col(0);\r\n const f2 = m.col(1);\r\n return L3.anchorDirection(f2.p3(), f1.V3().times(f2.w).minus(f2.V3().times(f1.w)));\r\n }\r\n {\r\n // ensure that the bottom-right value = 1. this does not change the 3d result.\r\n m.m[15] !== 1 && (m = m.divScalar(m.m[15]));\r\n const w2 = m.m[13];\r\n const w1 = m.m[12];\r\n const wc = m.m[15];\r\n // we want to split m into X * P, such that X is a transformation with no projective component (first three\r\n // values of the bottom row = 0), which can be handled by the usual .transform() method, and P which has only a\r\n // projective component (only the last row differs from the identity matrix). This simplifies the following\r\n // calculation. X * P = m => X * P * P^-1 = m * P^-1 => X = m * P^-1\r\n // prettier-ignore\r\n const Pinv = new M4(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -m.m[12], -m.m[13], -m.m[14], 1);\r\n const X = m.times(Pinv);\r\n // P'(t) = 0 is true for t = 0 and t1. The center is in between P(0) and P(t1), or P(t1) / 2, as P(0) = O\r\n const delta = 4 * w2 * wc - Math.pow(w1, 2);\r\n const center = new V3((-w1 * wc) / delta, (2 * Math.pow(wc, 2)) / delta, 0);\r\n // f2 is parallel to P'(0), i.e. horizontal. Solve Py(t2) = Cy = Py(t1) / 2 for t2 and simplify\r\n // f2x = Px(t2) - Cx = Px(t2) - Px(t1) / 2 to get the x-component of f2:\r\n const f2x = 1 / sqrt(abs(delta)) / wc;\r\n const f2 = new V3(f2x, 0, 0);\r\n let result;\r\n if (eq0(delta)) {\r\n result = new ParabolaCurve(V3.O, V3.X, V3.Y, tMin, tMax);\r\n }\r\n else if (0 < delta) {\r\n const tMapInv = (t) => {\r\n const wt = Math.pow(t, 2) * w2 + t * w1 + wc;\r\n const xi = 1 -\r\n (delta / 2 / Math.pow(wc, 2)) * (Number.isFinite(t) ? Math.pow(t, 2) / wt : 1 / w2);\r\n const eta = (t * 2 * Math.pow(wc, 2) - Math.pow(t, 2) * delta) / wt / 2 / Math.pow(wc, 2) -\r\n (2 * w1 * wc) / delta;\r\n const xx = acos(xi);\r\n const p = Number.isFinite(t)\r\n ? new V3(t, Math.pow(t, 2), 0).div(wt)\r\n : new V3(0, 1 / w2, 0);\r\n const pLC = M4.forSys(center.negated(), f2, V3.Z, center)\r\n .inversed()\r\n .transformPoint(p);\r\n const angle = pLC.angleXY();\r\n if (t > 0 && pLC.y < 0) {\r\n return angle + TAU;\r\n }\r\n else if (t < 0 && pLC.y > 0) {\r\n return angle - TAU;\r\n }\r\n return angle;\r\n };\r\n result = EllipseCurve.andFixTs(center, center.negated(), f2, tMapInv(tMin), tMapInv(tMax));\r\n }\r\n else {\r\n const tMapInv = (t) => sign(t) *\r\n acosh(1 -\r\n (delta / 2 / Math.pow(wc, 2)) *\r\n (Number.isFinite(t)\r\n ? Math.pow(t, 2) / (Math.pow(t, 2) * w2 + t * w1 + wc)\r\n : 1 / w2));\r\n result = new HyperbolaCurve(center, center.negated(), f2, tMapInv(tMin), tMapInv(tMax));\r\n }\r\n return result.transform(X);\r\n }\r\n}\r\n//# sourceMappingURL=XiEtaCurve.js.map","import { arrayFromFunction, arrayHashCode, arrayRange, assert, assertVectors, bisect, clamp, eq, eq0, M4, TAU, V3, withMax, } from \"ts3dutils\";\r\nimport { pushQuad } from \"tsgl\";\r\nimport { Curve, L3, PICurve } from \"../index\";\r\nimport { ceil, floor, max, min } from \"../math\";\r\nexport class ImplicitCurve extends Curve {\r\n constructor(points, tangents, dir = 1, generator, tMin = 1 == dir ? 0 : -(points.length - 1), tMax = 1 == dir ? points.length - 1 : 0) {\r\n super(tMin, tMax);\r\n this.points = points;\r\n this.tangents = tangents;\r\n this.dir = dir;\r\n this.generator = generator;\r\n assert(points.length > 2);\r\n assert(0 <= tMin && tMin <= points.length - 1, tMin, points.length);\r\n assert(0 <= tMax && tMax <= points.length - 1, tMax, points.length);\r\n }\r\n likeCurve(curve) {\r\n throw new Error(\"Method not implemented.\");\r\n }\r\n toSource(rounder = (x) => x) {\r\n return this.generator || super.toSource(rounder);\r\n }\r\n containsPoint(p) {\r\n assertVectors(p);\r\n return !isNaN(this.pointT(p));\r\n }\r\n equals(obj) {\r\n return (this == obj ||\r\n (Object.getPrototypeOf(obj) == PICurve.prototype &&\r\n this.points[0].equals(obj.points[0]) &&\r\n this.tangents[0].equals(obj.tangents[0])));\r\n }\r\n hashCode() {\r\n return arrayHashCode([this.points[0], this.tangents[0]]);\r\n }\r\n tangentP(pWC) {\r\n assertVectors(pWC);\r\n assert(this.containsPoint(pWC), \"this.containsPoint(pWC)\" + this.containsPoint(pWC));\r\n const t = this.pointT(pWC);\r\n return this.tangentAt(t);\r\n }\r\n tangentAt(t) {\r\n t = clamp(t, this.tMin, this.tMax);\r\n return V3.lerp(this.tangents[floor(t)], this.tangents[ceil(t)], t % 1);\r\n }\r\n at(t) {\r\n assert(isFinite(t));\r\n return V3.lerp(this.points[floor(t)], this.points[ceil(t)], t % 1);\r\n }\r\n getConstructorParameters() {\r\n throw new Error();\r\n }\r\n roots() {\r\n const allTs = arrayRange(0, this.points.length);\r\n return [allTs, allTs, allTs];\r\n }\r\n /**\r\n * @param mesh\r\n * @param res\r\n * @param radius default to 0. Use the shader to achieve dynamic scaling.\r\n * @param pointStep\r\n */\r\n addToMesh(mesh, res = 4, radius = 0, pointStep = 1) {\r\n const baseNormals = arrayFromFunction(res, (i) => V3.polar(1, (TAU * i) / res));\r\n const baseVertices = arrayFromFunction(res, (i) => V3.polar(radius, (TAU * i) / res));\r\n let prevTangent = V3.Z, prevMatrix = M4.IDENTITY;\r\n for (let i = 0; i < this.points.length; i += pointStep) {\r\n const start = mesh.vertices.length;\r\n if (0 !== i) {\r\n for (let j = 0; j < res; j++) {\r\n pushQuad(mesh.TRIANGLES, true, start - res + j, start + j, start - res + ((j + 1) % res), start + ((j + 1) % res));\r\n }\r\n }\r\n const point = this.points[i], tangent = this.tangents[i];\r\n const tangentMatrix = M4.rotateAB(prevTangent, tangent).times(prevMatrix);\r\n mesh.normals.push(...tangentMatrix.transformedVectors(baseNormals));\r\n const baseMatrix = M4.translate(point).times(tangentMatrix);\r\n mesh.vertices.push(...baseMatrix.transformedPoints(baseVertices));\r\n prevTangent = tangent;\r\n prevMatrix = tangentMatrix;\r\n }\r\n }\r\n rootsApprox() {\r\n const roots = [[], [], []];\r\n const points = this.points;\r\n let lastDiff = points[1].minus(points[0]);\r\n for (let i = 2; i < points.length; i++) {\r\n const diff = points[i].minus(points[i - 1]);\r\n for (let dim = 0; dim < 3; dim++) {\r\n if (Math.sign(lastDiff.e(dim)) != Math.sign(diff.e(dim))) {\r\n roots[dim].push(i);\r\n }\r\n }\r\n lastDiff = diff;\r\n }\r\n return roots;\r\n }\r\n pointT(pWC) {\r\n const startT = withMax(arrayRange(floor(this.tMin), ceil(this.tMax), 1), (t) => -pWC.distanceTo(this.points[t]));\r\n if (undefined === startT)\r\n throw new Error();\r\n if (this.points[startT].like(pWC))\r\n return startT;\r\n const a = max(0, startT - 1), b = min(this.points.length - 1, startT + 1);\r\n const tangent = this.tangentAt(startT);\r\n const f = (t) => this.at(t).to(pWC).dot(tangent);\r\n // const df = (t: number) => -this.tangentAt(clamp(t, 0, this.points.length - 1)).dot(tangent)\r\n //checkDerivate(f, df, 0, this.points.length - 2, 3)\r\n const t = bisect(f, a, b, 32);\r\n if (!isFinite(t) || !eq0(this.at(t).distanceTo(pWC))) {\r\n return NaN;\r\n }\r\n return t;\r\n }\r\n}\r\nImplicitCurve.prototype.tIncrement = 1;\r\n/**\r\n * isInfosWithLine for an ImplicitCurve defined as the intersection of two surfaces.\r\n */\r\nexport function surfaceIsICurveIsInfosWithLine(surface1, surface2, anchorWC, dirWC, tMin, tMax, lineMin, lineMax) {\r\n const line = new L3(anchorWC, dirWC.unit());\r\n const psTs = surface1.isTsForLine(line);\r\n const isTs = surface2.isTsForLine(line);\r\n const commonTs = psTs.filter((psT) => isTs.some((isT) => eq(psT, isT)));\r\n const commonTInfos = commonTs.map((t) => ({\r\n tThis: 0,\r\n tOther: t / dirWC.length(),\r\n p: line.at(t),\r\n }));\r\n const result = commonTInfos.filter((info) => this.containsPoint(info.p));\r\n result.forEach((info) => (info.tThis = this.pointT(info.p)));\r\n return result;\r\n}\r\n//# sourceMappingURL=ImplicitCurve.js.map","import { arrayFromFunction, assert, assertf, assertInst, assertNever, assertNumbers, assertVectors, between, combinations, concatenated, eq, eq0, fuzzyUniques, hasConstructor, lerp, MINUS, newtonIterate1d, newtonIterate2dWithDerivatives, NLA_PRECISION, solveCubicReal2, V, V3, withMax, } from \"ts3dutils\";\r\nimport { Curve, CylinderSurface, EllipseCurve, L3, NURBS, P3, } from \"../index\";\r\nimport { abs, cos, PI, sin } from \"../math\";\r\n/**\r\n * Bezier curve with degree 3.\r\n */\r\nexport class BezierCurve extends Curve {\r\n constructor(p0, p1, p2, p3, tMin = -0.1, tMax = 1.1) {\r\n super(tMin, tMax);\r\n assertVectors(p0, p1, p2, p3);\r\n assert(isFinite(tMin) && isFinite(tMax));\r\n //assert(!L3.throughPoints(p0, p3).containsPoint(p1) || !L3.throughPoints(p0, p3).containsPoint(p2))\r\n this.p0 = p0;\r\n this.p1 = p1;\r\n this.p2 = p2;\r\n this.p3 = p3;\r\n }\r\n get points() {\r\n return [this.p0, this.p1, this.p2, this.p3];\r\n }\r\n /**\r\n * Returns a new BezierCurve with curve.at(x) == V(x, ax³ + bx² + cx + d, 0).\r\n */\r\n static graphXY(a, b, c, d, tMin, tMax) {\r\n // d = p0y\r\n // c = -3 p0y + 3 p1y => p1y = c/3 + p0y\r\n // b = 3 p0y - 6 p1y + 3 p2y => p2y = b/3 - p0y + 2 p1y\r\n // a = -p0y + 3 p1y -3 p2y + p3y => p3y = a + p0y - 3 p1y + 3 p2y\r\n const p0y = d;\r\n const p1y = c / 3 + p0y;\r\n const p2y = b / 3 - p0y + 2 * p1y;\r\n const p3y = a + p0y - 3 * p1y + 3 * p2y;\r\n return new BezierCurve(V(0, p0y), V(1 / 3, p1y), V(2 / 3, p2y), V(1, p3y), tMin, tMax);\r\n }\r\n static quadratic(a, b, c, tMin = 0, tMax = 1) {\r\n const line = L3.throughPoints(a, c);\r\n if (line.containsPoint(b)) {\r\n return line;\r\n }\r\n else {\r\n // p1 = 1/3 a + 2/3 b\r\n // p2 = 1/3 c + 2/3 b\r\n return new BezierCurve(a, b.times(2).plus(a).div(3), b.times(2).plus(c).div(3), c, tMin, tMax);\r\n }\r\n }\r\n /**\r\n * Returns a bezier curve which approximates a CCW unit circle arc starting at V3.X of angle phi\r\n * phi <= PI / 2 is recommended\r\n *\r\n * Formula from here: https://pomax.github.io/bezierinfo/#circles_cubic\r\n */\r\n static approximateUnitArc(phi) {\r\n const f = (4 / 3) * Math.tan(phi / 4);\r\n return new BezierCurve(V3.X, new V3(1, f, 0), new V3(cos(phi) + f * sin(phi), sin(phi) - f * cos(phi), 0), V3.sphere(phi, 0), 0, 1);\r\n }\r\n getConstructorParameters() {\r\n return [this.p0, this.p1, this.p2, this.p3];\r\n }\r\n at(t) {\r\n // = s^3 p0 + 3 s^2 t p1 + 3 s t^2 p2 + t^3 p3\r\n assertNumbers(t);\r\n const p0 = this.p0, p1 = this.p1, p2 = this.p2, p3 = this.p3;\r\n const s = 1 - t, c0 = s * s * s, c1 = 3 * s * s * t, c2 = 3 * s * t * t, c3 = t * t * t;\r\n return new V3(p0.x * c0 + p1.x * c1 + p2.x * c2 + p3.x * c3, p0.y * c0 + p1.y * c1 + p2.y * c2 + p3.y * c3, p0.z * c0 + p1.z * c1 + p2.z * c2 + p3.z * c3);\r\n }\r\n /**\r\n * s := (1 - t)\r\n * at(t) := s³ p0 + 3 s² t p1 + 3 s t² p2 + t³ p3\r\n * tangent(t) := 3 s² (p1 - p0) + 6 s t (p2 - p1) + 3 t² (p3 - p2)\r\n * := 3 (1 - t)² (p1 - p0) + 6 (1 - t) t (p2 - p1) + 3 t² (p3 - p2)\r\n * := 3 (1 - 2 t + t²) (p1 - p0) + 6 (t - t²) (p2 - p1) + 3 t² (p3 - p2)\r\n * := (3 (p3 - p2) - 6 (p2 - p1) + 3 (p1 - p0)) t²*\r\n * + (-6 (p1 - p0) + (p2 - p1)) t\r\n * + 3 (p1 - p0)\r\n */\r\n tangentAt(t) {\r\n assertNumbers(t);\r\n const p0 = this.p0, p1 = this.p1, p2 = this.p2, p3 = this.p3;\r\n const s = 1 - t, c01 = 3 * s * s, c12 = 6 * s * t, c23 = 3 * t * t;\r\n return new V3((p1.x - p0.x) * c01 + (p2.x - p1.x) * c12 + (p3.x - p2.x) * c23, (p1.y - p0.y) * c01 + (p2.y - p1.y) * c12 + (p3.y - p2.y) * c23, (p1.z - p0.z) * c01 + (p2.z - p1.z) * c12 + (p3.z - p2.z) * c23);\r\n }\r\n ddt(t) {\r\n assertNumbers(t);\r\n const p0 = this.p0, p1 = this.p1, p2 = this.p2, p3 = this.p3;\r\n const c012 = 6 * (1 - t), c123 = 6 * t;\r\n return new V3((p2.x - 2 * p1.x + p0.x) * c012 + (p3.x - 2 * p2.x + p1.x) * c123, (p2.y - 2 * p1.y + p0.y) * c012 + (p3.y - 2 * p2.y + p1.y) * c123, (p2.z - 2 * p1.z + p0.z) * c012 + (p3.z - 2 * p2.z + p1.z) * c123);\r\n }\r\n normalP(t) {\r\n const tangent = this.tangentAt(t);\r\n const rot = tangent.cross(this.ddt(t));\r\n return rot.cross(tangent);\r\n }\r\n isTsWithPlane(planeWC) {\r\n assertInst(P3, planeWC);\r\n /*\r\n We are solving for t:\r\n n := plane.normal1\r\n this.at(t) DOT n == plane.w // according to plane definition\r\n (a t³ + b t² + c t + d) DOT n == plane.w // bezier curve as cubic equation\r\n (a DOT n) t³ + (b DOT n) t³ + (c DOT n) t + d DOT n - plane.w == 0 // multiply out DOT n, minus plane.w\r\n */\r\n const { p0, p1, p2, p3 } = this;\r\n const n = planeWC.normal1;\r\n const a = p1.minus(p2).times(3).minus(p0).plus(p3);\r\n const b = p0.plus(p2).times(3).minus(p1.times(6));\r\n const c = p1.minus(p0).times(3);\r\n const d = p0;\r\n return solveCubicReal2(a.dot(n), b.dot(n), c.dot(n), d.dot(n) - planeWC.w).filter((t) => between(t, this.tMin, this.tMax));\r\n }\r\n isTsWithSurface(surfaceWC) {\r\n if (surfaceWC instanceof CylinderSurface) {\r\n const projPlane = new P3(surfaceWC.dir.unit(), 0);\r\n const projThis = this.project(projPlane);\r\n const projEllipse = surfaceWC.baseCurve.project(projPlane);\r\n return projEllipse\r\n .isInfosWithBezier2D(projThis)\r\n .map((info) => info.tOther);\r\n }\r\n return super.isTsWithSurface(surfaceWC);\r\n }\r\n likeCurve(curve) {\r\n return (this == curve ||\r\n (hasConstructor(curve, BezierCurve) &&\r\n this.p0.like(curve.p0) &&\r\n this.p1.like(curve.p1) &&\r\n this.p2.like(curve.p2) &&\r\n this.p3.like(curve.p3)));\r\n }\r\n equals(obj) {\r\n return (this == obj ||\r\n (hasConstructor(obj, BezierCurve) &&\r\n this.p0.equals(obj.p0) &&\r\n this.p1.equals(obj.p1) &&\r\n this.p2.equals(obj.p2) &&\r\n this.p3.equals(obj.p3)));\r\n }\r\n hashCode() {\r\n let hashCode = 0;\r\n hashCode = hashCode * 31 + this.p0.hashCode();\r\n hashCode = hashCode * 31 + this.p1.hashCode();\r\n hashCode = hashCode * 31 + this.p2.hashCode();\r\n hashCode = hashCode * 31 + this.p3.hashCode();\r\n return hashCode | 0;\r\n }\r\n /**\r\n * Checks if this curve is colinear to the passed curve, i.e.\r\n * for every t:number there exists a s:number with this.at(t) = curve.at(s)\r\n */\r\n isColinearTo(curve) {\r\n if (this === curve || this.likeCurve(curve))\r\n return true;\r\n if (!(curve instanceof BezierCurve))\r\n return false;\r\n // first, find out where/if curve.p0 and curve.p3 are on this\r\n // then split this at curve.p0 --> curve.p3 to compare points p1 and p2\r\n let curveP0T, curveP3T;\r\n // assign in if condition to exploit short-circuit\r\n if (isNaN((curveP0T = this.pointT(curve.p0))) ||\r\n isNaN((curveP3T = this.pointT(curve.p3)))) {\r\n return false;\r\n }\r\n let thisSplit;\r\n if (eq(1, curveP0T)) {\r\n // this.split(curveP0T).right is degenerate in this case, so we need to handle it separately\r\n // this.split(curveP3T): 0 --> curveP3T --> 1\r\n // .right: curveP3T --> 1\r\n // .reversed(): 1 --> curveP3T\r\n thisSplit = this.split(curveP3T)[1].reversed();\r\n }\r\n else {\r\n // curveP3T describes the point on this\r\n // adjust it so it describes the same point on this.split(curveP0T).right\r\n // this: 0 p0t p3t 1\r\n // | | | |\r\n // this.split(curveP0T).right: 0 p3tad 1\r\n const curveP3Tadjusted = (curveP3T - curveP0T) / (1 - curveP0T);\r\n thisSplit = this.split(curveP0T)[1].split(curveP3Tadjusted)[0];\r\n }\r\n return curve.likeCurve(thisSplit);\r\n }\r\n selectPart(t0, t1) {\r\n const t1Adjusted = (t1 - t0) / (1 - t0);\r\n return this.split(t0)[1].split(t1Adjusted)[0];\r\n }\r\n reversed() {\r\n return new BezierCurve(this.p3, this.p2, this.p1, this.p0, 1 - this.tMax, 1 - this.tMin);\r\n }\r\n getCoefficients() {\r\n const { p0, p1, p2, p3 } = this;\r\n // calculate cubic equation coefficients\r\n // a t³ + b t² + c t + d = 0\r\n // multiplying out the cubic Bézier curve equation gives:\r\n // a = -p0 + 3 p1 - 3 p2 + p3\r\n // b = 3 p0 - 6 p1 + 3 p2\r\n // c = -3 p0 + 3 p1\r\n // d = p0 - p\r\n const a = p1.minus(p2).times(3).minus(p0).plus(p3);\r\n const b = p0.plus(p2).times(3).minus(p1.times(6));\r\n const c = p1.minus(p0).times(3);\r\n const d = p0;\r\n return [a, b, c, d];\r\n }\r\n tangentCoefficients() {\r\n const { p0, p1, p2, p3 } = this;\r\n const p01 = p1.minus(p0), p12 = p2.minus(p1), p23 = p3.minus(p2);\r\n const a = p01.plus(p23).times(3).minus(p12.times(6));\r\n const b = p12.minus(p01).times(6);\r\n const c = p01.times(3);\r\n return [V3.O, a, b, c];\r\n }\r\n pointT2(p, tMin = this.tMin, tMax = this.tMax) {\r\n const t = this.closestTToPoint(p, undefined, tMin, tMax);\r\n assert(this.at(t).like(p));\r\n return t;\r\n }\r\n pointT(p) {\r\n const { p0, p1, p2, p3 } = this;\r\n // calculate cubic equation coefficients\r\n // a t³ + b t² + c t + d = 0\r\n // multiplying out the cubic Bézier curve equation gives:\r\n // a = -p0 + 3 p1 - 3 p2 + p3\r\n // b = 3 p0 - 6 p1 + 3 p2\r\n // c = -3 p0 + 3 p1\r\n // d = p0 - p\r\n const a = p1.minus(p2).times(3).minus(p0).plus(p3);\r\n const b = p0.plus(p2).times(3).minus(p1.times(6));\r\n const c = p1.minus(p0).times(3);\r\n const d = p0.minus(p);\r\n // a t³ + b t² + c t + d = 0 is 3 cubic equations, some of which can be degenerate\r\n const maxDim = NLA_PRECISION < a.maxAbsElement()\r\n ? a.maxAbsDim()\r\n : NLA_PRECISION < b.maxAbsElement()\r\n ? b.maxAbsDim()\r\n : NLA_PRECISION < c.maxAbsElement()\r\n ? c.maxAbsDim()\r\n : assertNever();\r\n const results = solveCubicReal2(a.e(maxDim), b.e(maxDim), c.e(maxDim), d.e(maxDim)).filter((t) => this.at(t).like(p));\r\n if (0 == results.length)\r\n return NaN;\r\n if (1 == results.length)\r\n return results[0];\r\n throw new Error(\"multiple intersection \" + this.toString() + p.sce);\r\n }\r\n pointT3(p) {\r\n const { p0, p1, p2, p3 } = this;\r\n // calculate cubic equation coefficients\r\n // a t³ + b t² + c t + d = 0\r\n // multiplying out the cubic Bézier curve equation gives:\r\n // a = -p0 + 3 p1 - 3 p2 + p3\r\n // b = 3 p0 - 6 p1 + 3 p2\r\n // c = -3 p0 + 3 p1\r\n // d = p0 - p\r\n const a = p1.minus(p2).times(3).minus(p0).plus(p3).els();\r\n const b = p0.plus(p2).times(3).minus(p1.times(6)).els();\r\n const c = p1.minus(p0).times(3).els();\r\n const d = p0.minus(p).els();\r\n let results = undefined;\r\n // assume passed point is on curve and that curve does not self-intersect,\r\n // i.e. there is exactly one correct result for t\r\n // try to find a single result in the x-dimension, if multiple are found,\r\n // filter them by checking the other dimensions\r\n for (let dim = 0; dim < 3; dim++) {\r\n if (eq0(a[dim]) && eq0(b[dim]) && eq0(c[dim])) {\r\n // for case x:\r\n // ax == bx == cx == 0 => x(t) = dx\r\n // x value is constant\r\n // if x == 0 for all t, this does not limit the result, otherwise, there is no result, i.e\r\n // the passed point is not on the curve\r\n if (!eq0(d[dim]))\r\n return NaN;\r\n }\r\n else {\r\n const newResults = solveCubicReal2(a[dim], b[dim], c[dim], d[dim]);\r\n if (0 == newResults.length)\r\n return NaN;\r\n if (1 == newResults.length)\r\n return newResults[0];\r\n if (results) {\r\n results = results.filter((t) => newResults.some((t2) => eq(t, t2)));\r\n if (0 == results.length)\r\n return NaN;\r\n if (1 == results.length)\r\n return results[0];\r\n }\r\n else {\r\n results = newResults;\r\n }\r\n }\r\n }\r\n throw new Error(\"multiple intersection \" + results + this.toString() + p.sce);\r\n }\r\n transform(m4) {\r\n // perspective projection turn bezier curve into rational spline\r\n assert(m4.isNoProj(), m4.str);\r\n return new BezierCurve(m4.transformPoint(this.p0), m4.transformPoint(this.p1), m4.transformPoint(this.p2), m4.transformPoint(this.p3), this.tMin, this.tMax);\r\n }\r\n transform4(m4) {\r\n if (m4.isNoProj()) {\r\n return this.transform(m4);\r\n }\r\n else {\r\n return this.toNURBS().transform4(m4);\r\n }\r\n }\r\n isClosed() {\r\n return this.p0.like(this.p3);\r\n }\r\n isQuadratic() {\r\n return this.p0.lerp(this.p1, 1.5).like(this.p3.lerp(this.p2, 1.5));\r\n }\r\n debugInfo() {\r\n return {\r\n lines: [0, 1, 1, 2, 2, 3].map((i) => this.points[i]),\r\n points: this.points,\r\n };\r\n }\r\n split(t) {\r\n // do de Casteljau's algorithm at t, the resulting points are the points needed to create 2 new curves\r\n const s = 1 - t;\r\n const { p0, p1, p2, p3 } = this;\r\n /*\r\n p3 // n3\r\n b01 = s p0 + t p1\r\n b11 = s p1 + t p2\r\n b21 = s p2 + t p3 // n2\r\n b02 = s b01 + t b11\r\n b12 = s b11 + t b21 // n1\r\n b03 = s b02 + t b12 // n0\r\n \r\n c01 =\r\n */\r\n const b01 = p0.times(s).plus(p1.times(t)), b11 = p1.times(s).plus(p2.times(t)), b21 = p2.times(s).plus(p3.times(t));\r\n const b02 = b01.times(s).plus(b11.times(t)), b12 = b11.times(s).plus(b21.times(t));\r\n const b03 = b02.times(s).plus(b12.times(t));\r\n return [\r\n new BezierCurve(p0, b01, b02, b03),\r\n new BezierCurve(b03, b12, b21, p3),\r\n ];\r\n }\r\n containsPoint(p) {\r\n return isFinite(this.pointT(p));\r\n }\r\n roots() {\r\n /**\r\n * := (3 (p3 - p2) - 6 (p2 - p1) + 3 (p1 - p0)) t²*\r\n * + (-6 (p1 - p0) + 6 (p2 - p1)) t\r\n * + 3 (p1 - p0)\r\n * */\r\n const { p0, p1, p2, p3 } = this;\r\n const p01 = p1.minus(p0), p12 = p2.minus(p1), p23 = p3.minus(p2);\r\n const a = p01.plus(p23).times(3).minus(p12.times(6));\r\n const b = p12.minus(p01).times(6);\r\n const c = p01.times(3);\r\n return arrayFromFunction(3, (dim) => solveCubicReal2(0, a.e(dim), b.e(dim), c.e(dim)));\r\n }\r\n isInfosWithLine(anchorWC, dirWC, tMin, tMax, lineMin = -100000, lineMax = 100000) {\r\n // const dirLength = dirWC.length()\r\n // // TODO: no:\r\n // let result = Curve.ispsRecursive(this, this.tMin, this.tMax, new L3(anchorWC, dirWC.unit()), lineMin, lineMax)\r\n // result = fuzzyUniquesF(result, info => info.tOther)\r\n // result.forEach(info => (info.tOther /= dirLength))\r\n // return result\r\n // looking for this.at(t) == line.at(s)\r\n // this.at(t).x == anchorWC.x + dirWC.x * s\r\n // (this.at(t).x - anchorWC.x) / dirWC.x == s (analogue for y and z) (1x, 1y, 1z)\r\n // (1x) - (1y):\r\n // (this.at(t).x - anchorWC.x) / dirWC.x - (this.at(t).y - anchorWC.y) / dirWC.y == 0\r\n // (this.at(t).x - anchorWC.x) * dirWC.y - (this.at(t).y - anchorWC.y) * dirWC.x == 0 (2)\r\n // cubic equation params (see #pointT):\r\n const { p0, p1, p2, p3 } = this;\r\n const a = p1.minus(p2).times(3).minus(p0).plus(p3);\r\n const v1 = V3.UNITS[a.minAbsDim()];\r\n const testPlane = P3.forAnchorAndPlaneVectors(anchorWC, dirWC, v1.isParallelTo(dirWC) ? a : v1);\r\n return this.isTsWithPlane(testPlane)\r\n .map((tThis) => {\r\n const p = this.at(tThis);\r\n return { tThis, tOther: L3.pointT(anchorWC, dirWC, p), p };\r\n })\r\n .filter((info) => L3.containsPoint(anchorWC, dirWC, info.p));\r\n }\r\n closestPointToLine(line, tMin, tMax) {\r\n // (this(t)-line(s)) * line.dir == 0 (1)\r\n // (this(t)-line(s)) * this.tangentAt(t) == 0 (2)\r\n // this(t) * line.dir - line(s) * line.dir == 0\r\n // this(t) * line.dir - line.anchor * line.dir - s line.dir * line.dir == 0\r\n // this(t) * line.dir - line.anchor * line.dir == s (3)\r\n // insert (3) in (2)\r\n // (this(t)-line(this(t) * line.dir - line.anchor * line.dir)) * this.tangentAt(t) == 0 (4)\r\n // (4) is a 5th degree polynomial, solve numerically\r\n tMin = isFinite(tMin) ? tMin : this.tMin;\r\n tMax = isFinite(tMax) ? tMax : this.tMax;\r\n const anchorDotDir1 = line.anchor.dot(line.dir1);\r\n const f = (t) => {\r\n const atT = this.at(t);\r\n return atT\r\n .minus(line.at(atT.dot(line.dir1) - anchorDotDir1))\r\n .dot(this.tangentAt(t));\r\n };\r\n const STEPS = 32;\r\n const startT = withMax(arrayFromFunction(STEPS, (i) => tMin + ((tMax - tMin) * i) / STEPS), (t) => -f(t));\r\n return newtonIterate1d(f, startT, 8);\r\n }\r\n /**\r\n *\r\n * @param bezier\r\n * @param tMin\r\n * @param tMax\r\n * @param sMin\r\n * @param {number=} sMax\r\n * @returns\r\n */\r\n isInfosWithBezier3(bezier, tMin, tMax, sMin, sMax) {\r\n const handleStartTS = (startT, startS) => {\r\n if (!result.some((info) => eq(info.tThis, startT) && eq(info.tOther, startS))) {\r\n const f1 = (t, s) => this.tangentAt(t).dot(this.at(t).minus(bezier.at(s)));\r\n const f2 = (t, s) => bezier.tangentAt(s).dot(this.at(t).minus(bezier.at(s)));\r\n // f = (b1, b2, t1, t2) = b1.tangentAt(t1).dot(b1.at(t1).minus(b2.at(t2)))\r\n const fdt1 = (b1, b2, t1, t2) => b1.ddt(t1).dot(b1.at(t1).minus(b2.at(t2))) +\r\n b1.tangentAt(t1).squared();\r\n const fdt2 = (b1, b2, t1, t2) => -b1.tangentAt(t1).dot(b2.tangentAt(t2));\r\n const ni = newtonIterate2dWithDerivatives(f1, f2, startT, startS, 16, fdt1.bind(undefined, this, bezier), fdt2.bind(undefined, this, bezier), (t, s) => -fdt2(bezier, this, s, t), (t, s) => -fdt1(bezier, this, s, t));\r\n result.push({ tThis: ni.x, tOther: ni.y, p: this.at(ni.x) });\r\n }\r\n };\r\n tMin = undefined !== tMin ? tMin : this.tMin;\r\n tMax = undefined !== tMax ? tMax : this.tMax;\r\n sMin = undefined !== sMin ? sMin : bezier.tMin;\r\n sMax = undefined !== sMax ? sMax : bezier.tMax;\r\n // stack of indices:\r\n const indices = [tMin, tMax, sMin, sMax];\r\n const result = [];\r\n while (indices.length) {\r\n const i = indices.length - 4;\r\n const tMin = indices[i], tMax = indices[i + 1], sMin = indices[i + 2], sMax = indices[i + 3];\r\n indices.length -= 4;\r\n const thisAABB = this.getAABB(tMin, tMax);\r\n const otherAABB = bezier.getAABB(sMin, sMax);\r\n // console.log(tMin, tMax, sMin, sMax, thisAABB.sce, otherAABB.sce)\r\n if (thisAABB && otherAABB && thisAABB.intersectsAABB2d(otherAABB)) {\r\n const tMid = (tMin + tMax) / 2;\r\n const sMid = (sMin + sMax) / 2;\r\n const EPS = 0.00001;\r\n if (tMax - tMin < EPS || sMax - sMin < EPS) {\r\n console.log(tMin, tMax, sMin, sMax);\r\n console.log(thisAABB.sce);\r\n console.log(otherAABB.sce);\r\n console.log(tMid, sMid);\r\n handleStartTS(tMid, sMid);\r\n }\r\n else {\r\n indices.push(tMin, tMid, sMin, sMid, tMin, tMid, sMid, sMax, tMid, tMax, sMin, sMid, tMid, tMax, sMid, sMax);\r\n }\r\n }\r\n }\r\n return result;\r\n }\r\n isInfosWithBezier(bezier, tMin, tMax, sMin, sMax) {\r\n tMin = undefined !== tMin ? tMin : this.tMin;\r\n tMax = undefined !== tMax ? tMax : this.tMax;\r\n sMin = undefined !== sMin ? sMin : bezier.tMin;\r\n sMax = undefined !== sMax ? sMax : bezier.tMax;\r\n assertf(() => tMin < tMax);\r\n assertf(() => sMin < sMax);\r\n const result = [];\r\n const likeCurves = this.likeCurve(bezier), colinearCurves = this.isColinearTo(bezier);\r\n if (likeCurves || colinearCurves) {\r\n if (!likeCurves) {\r\n // only colinear\r\n // recalculate sMin and sMax so they are valid on this, from then on we can ignore bezier\r\n sMin = this.pointT(bezier.at(sMin));\r\n sMax = this.pointT(bezier.at(sMax));\r\n }\r\n tMin = Math.min(tMin, sMin);\r\n tMax = Math.max(tMax, sMax);\r\n const splits = fuzzyUniques(concatenated(this.roots()).filter(isFinite).concat([tMin, tMax])).sort(MINUS);\r\n //const aabbs = arrayFromFunction(splits.length - 1, i => this.getAABB(splits[i], splits[i + 1]))\r\n Array.from(combinations(splits.length - 1)).forEach(({ i, j }) => {\r\n // adjacent curves can't intersect\r\n if (Math.abs(i - j) > 2) {\r\n // console.log(splits[i], splits[i + 1], splits[j], splits[j + 1], aabbs[i], aabbs[j])\r\n //findRecursive(splits[i], splits[i + 1], splits[j], splits[j + 1], aabbs[i], aabbs[j])\r\n result.push(...Curve.ispsRecursive(this, splits[i], splits[i + 1], bezier, splits[j], splits[j + 1]));\r\n }\r\n });\r\n }\r\n else {\r\n return Curve.ispsRecursive(this, tMin, tMax, bezier, sMin, sMax);\r\n }\r\n return result;\r\n }\r\n selfIntersectionsInfo() {\r\n return this.isInfosWithBezier(this);\r\n }\r\n isInfosWithCurve(curve) {\r\n if (curve instanceof L3) {\r\n return this.isInfosWithLine(curve.anchor, curve.dir1, curve.tMin, curve.tMax);\r\n }\r\n if (curve instanceof BezierCurve) {\r\n return this.isInfosWithBezier(curve);\r\n }\r\n return curve\r\n .isInfosWithCurve(this)\r\n .map(({ tThis, tOther, p }) => ({ tThis: tOther, tOther: tThis, p }));\r\n }\r\n /**\r\n * Approximate this bezier curve with a number of circular segments. This curve is recursively split in half until\r\n * segments are close enough (relative error < REL_ERR in two test points) to an arc which goes through the start,\r\n * end and mid points of the segment.\r\n * @returns each EllipseCurve is circular and their tMin and tMax respectively define their start and end points.\r\n * @param t0 Start parameter of segment which should be approximated.\r\n * @param t1 End parameter of segment which should be approximated.\r\n * @param REL_ERROR max allowable relative error.\r\n * @param result Resulting circle arcs are stored in this array. Mainly used by the recursion.\r\n */\r\n circleApprox(t0 = this.tMin, t1 = this.tMax, REL_ERROR = 1 / 1024, result = []) {\r\n const a = this.at(t0), b = this.at(t1), tMid = (t0 + t1) / 2, pMid = this.at(tMid), abLine = L3.throughPoints(a, b);\r\n if (!abLine.containsPoint(pMid) &&\r\n between(abLine.pointT(pMid), 0, abLine.pointT(b))) {\r\n const arc = EllipseCurve.circleThroughPoints(a, pMid, b), arcRadius = arc.f1.length(), pTest1 = this.at(lerp(t0, t1, 0.25)), pTest2 = this.at(lerp(t0, t1, 0.75));\r\n if (abs(arc.center.distanceTo(pTest1) / arcRadius - 1) <= REL_ERROR &&\r\n abs(arc.center.distanceTo(pTest2) / arcRadius - 1) <= REL_ERROR) {\r\n result.push(arc);\r\n return result;\r\n }\r\n }\r\n this.circleApprox(t0, tMid, REL_ERROR, result);\r\n this.circleApprox(tMid, t1, REL_ERROR, result);\r\n return result;\r\n }\r\n toNURBS() {\r\n return NURBS.fromBezier(this);\r\n }\r\n}\r\n/**\r\n * https://en.wikipedia.org/wiki/Cubic_function#/media/File:Graph_of_cubic_polynomial.svg\r\n */\r\nBezierCurve.EX2D = BezierCurve.graphXY(2, -3, -3, 2);\r\nBezierCurve.EX3D = new BezierCurve(V3.O, V(-0.1, -1, 1), V(1.1, 1, 1), V3.X);\r\nBezierCurve.QUARTER_CIRCLE = BezierCurve.approximateUnitArc(PI / 2);\r\nBezierCurve.prototype.hlol = Curve.hlol++;\r\nBezierCurve.prototype.tIncrement = 1 / 80;\r\n//# sourceMappingURL=BezierCurve.js.map","import { arrayFromFunction, assertNumbers, eq, eq0, hasConstructor, le, M4, snap0, V3, } from \"ts3dutils\";\r\nimport { intersectionUnitHyperbolaLine, parabola4Projection, XiEtaCurve, } from \"../index\";\r\nimport { abs, cosh, min, PI, sign, sqrt } from \"../math\";\r\n/**\r\n * x² - y² = 1\r\n * C(t) = center + f1 * cosh(t) + f2 * sinh(t)\r\n */\r\nexport class HyperbolaCurve extends XiEtaCurve {\r\n constructor(center, f1, f2, tMin = -7, tMax = 7) {\r\n super(center, f1, f2, tMin, tMax);\r\n }\r\n static XYLCValid(pLC) {\r\n return pLC.x > 0 && eq(1, pLC.x * pLC.x - pLC.y * pLC.y);\r\n }\r\n static XYLCPointT(pLC) {\r\n return Math.asinh(pLC.y);\r\n }\r\n /**\r\n * http://www.wolframalpha.com/input/?i=x%C2%BRep-y%C2%BRep%3D1,ax%2Bby%3Dc\r\n * Minor empiric test shows asinh(eta) consistently gets more accurate results than atanh(eta/xi)\r\n */\r\n static intersectionUnitLine(a, b, c) {\r\n if (eq0(b)) {\r\n const sqrtVal = snap0(Math.pow(c, 2) / Math.pow(a, 2) - 1);\r\n if (sqrtVal < 0 || c * a < 0) {\r\n return [];\r\n }\r\n else if (sqrtVal == 0) {\r\n return [0];\r\n }\r\n const eta1 = Math.sqrt(sqrtVal);\r\n return [-Math.asinh(eta1), Math.asinh(eta1)];\r\n }\r\n else if (eq(abs(a), abs(b))) {\r\n if (le(c * a, 0)) {\r\n return [];\r\n }\r\n const eta = (sign(a * b) * (Math.pow(c, 2) - Math.pow(a, 2))) / 2 / a / c;\r\n return [Math.asinh(eta)];\r\n }\r\n else {\r\n const sqrtVal = snap0(Math.pow(b, 2) * (-(Math.pow(a, 2)) + Math.pow(b, 2) + Math.pow(c, 2)));\r\n if (sqrtVal < 0) {\r\n return [];\r\n }\r\n const xi1 = (a * c - Math.sqrt(sqrtVal)) / (Math.pow(a, 2) - Math.pow(b, 2));\r\n const xi2 = (a * c + Math.sqrt(sqrtVal)) / (Math.pow(a, 2) - Math.pow(b, 2));\r\n const eta1 = (Math.pow(b, 2) * c - a * Math.sqrt(sqrtVal)) / (b * (Math.pow(b, 2) - Math.pow(a, 2)));\r\n const eta2 = (Math.pow(b, 2) * c + a * Math.sqrt(sqrtVal)) / (b * (Math.pow(b, 2) - Math.pow(a, 2)));\r\n return [xi1 > 0 && Math.asinh(eta1), xi2 > 0 && Math.asinh(eta2)].filter((x) => x !== false);\r\n }\r\n }\r\n at(t) {\r\n assertNumbers(t);\r\n // = center + f1 cosh t + f2 sinh t\r\n return this.center\r\n .plus(this.f1.times(Math.cosh(t)))\r\n .plus(this.f2.times(Math.sinh(t)));\r\n }\r\n toString() {\r\n return `${this.center} + ${this.f1} * cosh(t) + ${this.f2} * sinh(t)`;\r\n }\r\n tangentAt(t) {\r\n assertNumbers(t);\r\n // = f1 sinh t + f2 cosh t\r\n return this.f1.times(Math.sinh(t)).plus(this.f2.times(Math.cosh(t)));\r\n }\r\n tangentAt2(xi, eta) {\r\n assertNumbers(xi, eta);\r\n // = f1 eta + f2 xi\r\n return this.f1.times(eta).plus(this.f2.times(xi));\r\n }\r\n ddt(t) {\r\n assertNumbers(t);\r\n return this.f1.times(Math.cosh(t)).plus(this.f2.times(Math.sinh(t)));\r\n }\r\n isColinearTo(curve) {\r\n if (!hasConstructor(curve, HyperbolaCurve))\r\n return false;\r\n if (!curve.center || !this.center.like(curve.center)) {\r\n return false;\r\n }\r\n if (this === curve) {\r\n return true;\r\n }\r\n const { f1: f1, f2: f2 } = this.rightAngled(), { f1: c1, f2: c2 } = curve.rightAngled();\r\n return (eq(f1.squared(), Math.abs(f1.dot(c1))) &&\r\n eq(f2.squared(), Math.abs(f2.dot(c2))));\r\n }\r\n reversed() {\r\n return new HyperbolaCurve(this.center, this.f1, this.f2.negated(), -this.tMax, -this.tMin);\r\n }\r\n rightAngled() {\r\n const f1 = this.f1, f2 = this.f2, a = f1.dot(f2), b = f2.squared() + f1.squared();\r\n if (eq0(a)) {\r\n return this;\r\n }\r\n const g1 = 2 * a, g2 = b + Math.sqrt(b * b - 4 * a * a);\r\n const { x1: xi, y1: eta } = intersectionUnitHyperbolaLine(g1, g2, 0);\r\n return new HyperbolaCurve(this.center, f1.times(xi).plus(f2.times(eta)), f1.times(eta).plus(f2.times(xi)));\r\n }\r\n eccentricity() {\r\n const mainAxes = this.rightAngled();\r\n const f1length = mainAxes.f1.length(), f2length = mainAxes.f1.length();\r\n const [a, b] = f1length > f2length ? [f1length, f2length] : [f2length, f1length];\r\n return Math.sqrt(1 + (b * b) / a / a);\r\n }\r\n roots() {\r\n // tangent(t) = f1 sinh t + f2 cosh t = 0\r\n // tangentAt2(xi, eta) = f1 eta + f2 xi = V3.O\r\n // xi² - eta² = 1 (by def for hyperbola)\r\n return arrayFromFunction(3, (dim) => {\r\n const a = this.f2.e(dim), b = this.f1.e(dim);\r\n return HyperbolaCurve.intersectionUnitLine(a, b, 0);\r\n });\r\n }\r\n transform4(m4) {\r\n const tMap = (t) => sign(t) * min(10, sqrt(-(1 - cosh(t)) / (1 + cosh(t))));\r\n // prettier-ignore\r\n const parabolaToUnitHyperbola = new M4(0, 1, 0, 1, 2, 0, 0, 0, 0, 0, 1, 0, 0, -1, 0, 1);\r\n return parabola4Projection(M4.product(m4, this.matrix, parabolaToUnitHyperbola), tMap(this.tMin), tMap(this.tMax));\r\n }\r\n}\r\nHyperbolaCurve.XY = new HyperbolaCurve(V3.O, V3.X, V3.Y);\r\nHyperbolaCurve.prototype.tIncrement = PI / 16;\r\n//# sourceMappingURL=HyperbolaCurve.js.map","import { assert, assertf, assertInst, assertNumbers, assertVectors, clamp, eq, eq0, hasConstructor, le, lt, V3, VV, } from \"ts3dutils\";\r\nimport { Curve, P3 } from \"../index\";\r\n/**\r\n * A 3-dimensional line. Defined by an anchor and a normalized direction vector.\r\n */\r\nexport class L3 extends Curve {\r\n constructor(anchor, // line anchor\r\n dir1, // normalized line dir\r\n tMin = -4096, tMax = 4096) {\r\n super(tMin, tMax);\r\n this.anchor = anchor;\r\n this.dir1 = dir1;\r\n assertVectors(anchor, dir1);\r\n assert(dir1.hasLength(1), \"dir must be unit\" + dir1);\r\n assertf(() => !Number.isNaN(anchor.x));\r\n }\r\n isTsWithSurface(surface) {\r\n return surface.isTsForLine(this);\r\n }\r\n static throughPoints(anchor, b, tMin = 0, tMax) {\r\n const dir = b.minus(anchor);\r\n return new L3(anchor, dir.unit(), tMin, undefined !== tMax ? tMax : dir.length());\r\n }\r\n static anchorDirection(anchor, dir, min = 0, max = dir.length()) {\r\n const dir1 = dir.unit();\r\n return new L3(anchor, dir1, \"number\" == typeof min ? min : min.minus(anchor).dot(dir1), \"number\" == typeof max ? max : max.minus(anchor).dot(dir1));\r\n }\r\n static pointT(anchor, dir, x) {\r\n assertVectors(anchor, dir, x);\r\n return x.minus(anchor).dot(dir) / dir.squared();\r\n }\r\n static at(anchor, dir, t) {\r\n return anchor.plus(dir.times(t));\r\n }\r\n /**\r\n * Create new line which is the intersection of two planes. Throws error if planes are parallel.\r\n * @param plane1\r\n * @param plane2\r\n */\r\n static fromPlanes(plane1, plane2) {\r\n assertInst(P3, plane1, plane2);\r\n const dir = plane1.normal1.cross(plane2.normal1);\r\n const length = dir.length();\r\n if (length < 1e-10) {\r\n throw new Error(\"Parallel planes\");\r\n }\r\n return plane1.intersectionWithPlane(plane2);\r\n }\r\n static containsPoint(anchor, dir, p) {\r\n const closestT = L3.pointT(anchor, dir, p);\r\n const distance = L3.at(anchor, dir, closestT).distanceTo(p);\r\n return eq0(distance);\r\n }\r\n roots() {\r\n return [[], [], []];\r\n }\r\n containsPoint(p) {\r\n assertVectors(p);\r\n const dist = this.distanceToPoint(p);\r\n assertNumbers(dist);\r\n return eq0(dist);\r\n }\r\n likeCurve(curve) {\r\n return (this == curve ||\r\n (hasConstructor(curve, L3) &&\r\n this.anchor.like(curve.anchor) &&\r\n this.dir1.like(curve.dir1)));\r\n }\r\n equals(obj) {\r\n return (this == obj ||\r\n (Object.getPrototypeOf(obj) == L3.prototype &&\r\n this.anchor.equals(obj.anchor) &&\r\n this.dir1.equals(obj.dir1)));\r\n }\r\n isColinearTo(obj) {\r\n return (obj instanceof L3 &&\r\n this.containsPoint(obj.anchor) &&\r\n eq(1, Math.abs(this.dir1.dot(obj.dir1))));\r\n }\r\n distanceToLine(line) {\r\n assertInst(L3, line);\r\n if (this.isParallelToLine(line)) {\r\n return this.distanceToPoint(line.anchor);\r\n }\r\n const dirCross1 = this.dir1.cross(line.dir1).unit();\r\n const anchorDiff = this.anchor.minus(line.anchor);\r\n return Math.abs(anchorDiff.dot(dirCross1));\r\n }\r\n distanceToPoint(x) {\r\n assertVectors(x);\r\n // See http://mathworld.wolfram.com/Point-LineDistance3-Dimensional.html\r\n const t = x.minus(this.anchor).dot(this.dir1);\r\n return this.at(t).distanceTo(x);\r\n //return x.minus(this.anchor).cross(x.minus(this.anchor.plus(this.dir1))).length()\r\n }\r\n asSegmentDistanceToPoint(x, sStart, sEnd) {\r\n let t = x.minus(this.anchor).dot(this.dir1);\r\n t = clamp(t, sStart, sEnd);\r\n return this.at(t).minus(x).length();\r\n }\r\n asSegmentDistanceToLine(line, sStart, sEnd) {\r\n assertInst(L3, line);\r\n const dirCross = this.dir1.cross(line.dir1);\r\n const div = dirCross.squared();\r\n if (eq0(div)) {\r\n return undefined;\r\n } // lines parallel\r\n const anchorDiff = line.anchor.minus(this.anchor);\r\n // check if distance is zero (see also L3.distanceToLine)\r\n if (!eq0(anchorDiff.dot(dirCross.unit()))) {\r\n return undefined;\r\n }\r\n let t = this.infoClosestToLine(line).t;\r\n t = clamp(t, sStart, sEnd);\r\n return this.at(clamp(t, sStart, sEnd));\r\n }\r\n at(t) {\r\n assertNumbers(t);\r\n return this.anchor.plus(this.dir1.times(t));\r\n }\r\n /**\r\n * This function returns lambda for a given point x\r\n *\r\n * Every point x on this line is described by the equation\r\n * x = this.anchor + lambda * this.dir1 | - this.anchor\r\n * x - this.anchor = lambda * this.dir1 | DOT this.dir1\r\n * (x - this.anchor) DOT this.dir1 = lambda (dir1² is 1 as |dir1| == 1)\r\n *\r\n * @param x\r\n * @returns\r\n */\r\n pointT(x) {\r\n assertVectors(x);\r\n const t = x.minus(this.anchor).dot(this.dir1);\r\n return t;\r\n }\r\n /**\r\n * Returns true if the line is parallel (this.dir = line.dir || this.dir = -line.dir) to the argument.\r\n */\r\n isParallelToLine(line) {\r\n assertInst(L3, line);\r\n // we know that 1 == this.dir1.length() == line.dir1.length(), we can check for parallelity simpler than\r\n // isParallelTo()\r\n return eq(1, Math.abs(this.dir1.dot(line.dir1)));\r\n }\r\n angleToLine(line) {\r\n assertInst(L3, line);\r\n return this.dir1.angleTo(line.dir1);\r\n }\r\n /**\r\n *\r\n * @param line\r\n * @returns {boolean} If the distance between the lines is zero\r\n */\r\n intersectsLine(line) {\r\n return eq0(this.distanceToLine(line));\r\n }\r\n isInfosWithCurve(curve) {\r\n if (curve instanceof L3) {\r\n return this.isInfosWithLine(curve.anchor, curve.dir1);\r\n }\r\n return super.isInfosWithCurve(curve);\r\n }\r\n isInfosWithLine(anchorWC, dirWC) {\r\n const dirCross = this.dir1.cross(dirWC);\r\n const div = dirCross.squared();\r\n if (eq0(div)) {\r\n // lines are parallel\r\n return [];\r\n }\r\n const anchorDiff = anchorWC.minus(this.anchor);\r\n if (eq0(anchorDiff.dot(dirCross))) {\r\n const tThis = anchorDiff.cross(dirWC).dot(dirCross) / div;\r\n const tOther = anchorDiff.cross(this.dir1).dot(dirCross) / div;\r\n const p = this.at(tThis);\r\n return [{ tThis: tThis, tOther: tOther, p: p }];\r\n }\r\n return [];\r\n }\r\n isInfoWithLine(line) {\r\n // todo infos?\r\n assertInst(L3, line);\r\n const dirCross = this.dir1.cross(line.dir1);\r\n const div = dirCross.squared();\r\n if (eq0(div)) {\r\n return undefined;\r\n } // lines parallel\r\n const anchorDiff = line.anchor.minus(this.anchor);\r\n // check if distance is zero (see also L3.distanceToLine)\r\n if (!eq0(anchorDiff.dot(dirCross.unit()))) {\r\n return undefined;\r\n }\r\n const t = anchorDiff.cross(line.dir1).dot(dirCross) / div;\r\n return this.at(t);\r\n }\r\n /**\r\n * returns s and t with this.at(s) == line.at(t)\r\n */\r\n intersectionLineST(line) {\r\n // the two points on two lines the closest two each other are the ones whose\r\n // connecting\r\n // TODO Where does this come from?\r\n // TODO: return value when no IS?\r\n assertInst(L3, line);\r\n const dirCross = this.dir1.cross(line.dir1);\r\n const div = dirCross.squared();\r\n const anchorDiff = line.anchor.minus(this.anchor);\r\n const s = anchorDiff.cross(this.dir1).dot(dirCross) / div;\r\n const t = anchorDiff.cross(line.dir1).dot(dirCross) / div;\r\n return { s: s, t: t };\r\n // console.log(segmentIntersectsRay, a, b, \"ab\", ab, \"p\", p, \"dir\", dir, s > 0 && t / div >= 0 && t / div <= 1,\r\n // \"s\", s, \"t\", t, \"div\", div)\r\n }\r\n ddt() {\r\n return V3.O;\r\n }\r\n getConstructorParameters() {\r\n return [this.anchor, this.dir1];\r\n }\r\n closestTToPoint(p) {\r\n // similar logic as pointT; we project the vector (anchor -> p) onto dir1, then add anchor back to it\r\n const nearestT = p.minus(this.anchor).dot(this.dir1);\r\n return nearestT;\r\n }\r\n infoClosestToLine(line) {\r\n /*\r\n line = a + s*b\r\n this = c + t*d\r\n \r\n (this - line) * b = 0\r\n (this - line) * d = 0\r\n \r\n (a + s*b - c - t*d) * b = 0\r\n (a + s*b - c - t*d) * d = 0\r\n \r\n (a - c + s*b - t*d) * b = 0\r\n (a - c + s*b - t*d) * d = 0\r\n \r\n (a - c)*b + (s*b - t*d)*b = 0\r\n (a - c)*d + (s*b - t*d)*d = 0\r\n \r\n (a - c)*b + s*(b*b) - t*(d*b) = 0\r\n (a - c)*d + s*(b*d) - t*(d*d) = 0\r\n \r\n s = (t*(d*b) - (a - c)*b) / (b*b)\r\n =>\r\n (a - c)*d + (t*(d*b) - (a - c)*b) / (b*b)*(b*d) - t*(d*d) = 0 | * (b*b)\r\n (a - c)*d * (b*b) + (t*(d*b) - (a - c)*b)*(b*d) - t*(d*d) * (b*b) = 0\r\n (a - c)*d * (b*b) + t*(d*b)*(b*d) - (a - c)*b*(b*d) - t*(d*d) * (b*b) = 0\r\n t = ((a - c)*b*(b*d) - (a - c)*d * (b*b)) / ((d*b)*(b*d) - (d*d) * (b*b))\r\n */\r\n if (this.isParallelToLine(line)) {\r\n return { t: NaN, s: NaN, distance: this.distanceToLine(line) };\r\n }\r\n const a = line.anchor, b = line.dir1, c = this.anchor, d = this.dir1;\r\n const bd = b.dot(d), bb = b.squared(), dd = d.squared(), ca = a.minus(c), divisor = bd * bd - dd * bb;\r\n const t = (ca.dot(b) * bd - ca.dot(d) * bb) / divisor;\r\n const s = (ca.dot(b) * dd - ca.dot(d) * bd) / divisor;\r\n return {\r\n t: t,\r\n s: s,\r\n closest: this.at(t),\r\n closest2: line.at(s),\r\n distance: this.at(t).distanceTo(line.at(s)),\r\n };\r\n }\r\n intersectionWithPlane(plane) {\r\n // plane: plane.normal1 * p = plane.w\r\n // line: p=line.point + lambda * line.dir1\r\n const lambda = (plane.w - plane.normal1.dot(this.anchor)) / plane.normal1.dot(this.dir1);\r\n const point = this.anchor.plus(this.dir1.times(lambda));\r\n return point;\r\n }\r\n tangentAt() {\r\n return this.dir1;\r\n }\r\n isTWithPlane(plane) {\r\n // plane: plane.normal1 * p = plane.w\r\n // line: p=line.point + lambda * line.dir1\r\n const div = plane.normal1.dot(this.dir1);\r\n if (eq0(div))\r\n return NaN;\r\n const lambda = (plane.w - plane.normal1.dot(this.anchor)) / div;\r\n return lambda;\r\n }\r\n reversed() {\r\n return new L3(this.anchor, this.dir1.negated(), -this.tMax, -this.tMin);\r\n }\r\n isTsWithPlane(planeWC) {\r\n const t = this.isTWithPlane(planeWC);\r\n return isNaN(t) ? [] : [t];\r\n }\r\n flipped() {\r\n return new L3(this.anchor, this.dir1.negated());\r\n }\r\n transform(m4) {\r\n const newAnchor = m4.transformPoint(this.anchor);\r\n const newDir = m4.transformVector(this.dir1);\r\n return new L3(newAnchor, newDir.unit(), this.tMin * newDir.length(), this.tMax * newDir.length());\r\n }\r\n transform4(m4) {\r\n const vanishingPlane = P3.vanishingPlane(m4);\r\n if (!vanishingPlane)\r\n return this.transform(m4);\r\n const pMin = this.at(this.tMin);\r\n const pMax = this.at(this.tMax);\r\n if (le(vanishingPlane.distanceToPointSigned(pMin), 0) ||\r\n le(vanishingPlane.distanceToPointSigned(pMax), 0)) {\r\n throw new Error(\"line must be in front of vanishingPlane in [tMin, tMax]\");\r\n }\r\n const anchor = lt(0, vanishingPlane.distanceToPointSigned(this.anchor))\r\n ? this.anchor\r\n : this.at((this.tMin + this.tMax) / 2);\r\n const transformedAnchor = m4.timesVector(VV(anchor.x, anchor.y, anchor.z, 1));\r\n const transformedVector = m4.timesVector(VV(this.dir1.x, this.dir1.y, this.dir1.z, 0));\r\n const newDir = transformedVector\r\n .times(transformedAnchor.w)\r\n .minus(transformedAnchor.times(transformedVector.w))\r\n .V3();\r\n const newAnchor = transformedAnchor.p3();\r\n return L3.anchorDirection(newAnchor, newDir, m4.transformPoint(pMin), m4.transformPoint(pMax));\r\n }\r\n hashCode() {\r\n return this.anchor.hashCode() * 31 + this.dir1.hashCode();\r\n }\r\n}\r\nL3.X = new L3(V3.O, V3.X);\r\nL3.Y = new L3(V3.O, V3.Y);\r\nL3.Z = new L3(V3.O, V3.Z);\r\nL3.prototype.hlol = Curve.hlol++;\r\nL3.prototype.tIncrement = 256;\r\n//# sourceMappingURL=L3.js.map","import { arrayRange, assert, assertVectors, bisect, callsce, clamp, fuzzyUniques, getLast, M4, newtonIterate2dWithDerivatives, V3, withMax, } from \"ts3dutils\";\r\nimport { curvePoint, EllipsoidSurface, followAlgorithm2d, ImplicitCurve, ImplicitSurface, MathFunctionR2R, PlaneSurface, ProjectedCurveSurface, surfaceIsICurveIsInfosWithLine, } from \"../index\";\r\nimport { abs, ceil, floor, max, min } from \"../math\";\r\nexport class PICurve extends ImplicitCurve {\r\n constructor(points, tangents, parametricSurface, implicitSurface, pmPoints, pmTangents, stepSize, dir = 1, generator, tMin, tMax) {\r\n super(points, tangents, dir, generator, tMin, tMax);\r\n this.parametricSurface = parametricSurface;\r\n this.implicitSurface = implicitSurface;\r\n this.pmPoints = pmPoints;\r\n this.pmTangents = pmTangents;\r\n this.stepSize = stepSize;\r\n assert(Array.isArray(pmPoints));\r\n assert(dir == 1);\r\n assert(stepSize <= 1);\r\n const pf = parametricSurface.pUVFunc();\r\n const dpdu = parametricSurface.dpdu();\r\n const dpdv = parametricSurface.dpdv();\r\n const didp = implicitSurface.didp.bind(implicitSurface);\r\n this.didu = (u, v) => didp(pf(u, v)).dot(dpdu(u, v));\r\n this.didv = (u, v) => didp(pf(u, v)).dot(dpdv(u, v));\r\n for (let i = 0; i < points.length - 1; i++) {\r\n assert(!points[i].equals(points[i + 1]));\r\n //assert(parametricSurface.pUV(pmPoints[i].x, pmPoints[i].y).equals(points[i]))\r\n }\r\n {\r\n const ps = this.parametricSurface;\r\n const is = implicitSurface;\r\n const pFunc = ps.pUVFunc(), iFunc = is.implicitFunction();\r\n const dpdu = ps.dpdu();\r\n const dpdv = ps.dpdv();\r\n const didp = is.didp.bind(is);\r\n const mf = MathFunctionR2R.forFFxFy((x, y) => iFunc(pFunc(x, y)), (u, v) => didp(pFunc(u, v)).dot(dpdu(u, v)), (u, v) => didp(pFunc(u, v)).dot(dpdv(u, v)));\r\n const { points } = followAlgorithm2d(mf, this.pmPoints[0], stepSize, ps, (u, v) => is.containsPoint(pFunc(u, v)), getLast(this.pmPoints), this.pmTangents[0]);\r\n if (points.length !== this.points.length) {\r\n followAlgorithm2d(mf, this.pmPoints[0], stepSize, ps, (u, v) => is.containsPoint(pFunc(u, v)), getLast(this.pmPoints), this.pmTangents[0]);\r\n }\r\n assert(points.length == this.points.length, points.length, this.points.length);\r\n }\r\n }\r\n static forParametricStartEnd(ps, is, pmStart, pmEnd, stepSize = 0.02, startPMTangent, tMin, tMax) {\r\n const pFunc = ps.pUVFunc(), iFunc = is.implicitFunction();\r\n const dpdu = ps.dpdu();\r\n const dpdv = ps.dpdv();\r\n const didp = is.didp.bind(is);\r\n const mf = MathFunctionR2R.forFFxFy((x, y) => iFunc(pFunc(x, y)), (u, v) => didp(pFunc(u, v)).dot(dpdu(u, v)), (u, v) => didp(pFunc(u, v)).dot(dpdv(u, v)));\r\n const { points, tangents } = followAlgorithm2d(mf, pmStart, stepSize, ps, (u, v) => is.containsPoint(pFunc(u, v)), pmEnd, startPMTangent);\r\n return PICurve.forParametricPointsTangents(ps, is, points, tangents, stepSize, 1, tMin, tMax);\r\n }\r\n static forStartEnd(ps, is, start, end, stepSize = 0.02, startTangent, min, max) {\r\n const startPM = ps.uvP(start);\r\n const dpdu = ps.dpdu()(startPM.x, startPM.y), dpdv = ps.dpdv()(startPM.x, startPM.y);\r\n const startPMTangent = startTangent &&\r\n M4.forSys(dpdu, dpdv).inversed().transformVector(startTangent);\r\n // assert(dpdu.times(startPMTangent.x).plus(dpdv.times(startPMTangent.y)).like(startTangent))\r\n const curve = PICurve.forParametricStartEnd(ps, is, startPM, ps.uvP(end), stepSize, startPMTangent);\r\n return curve.withBounds(min && curve.pointT(min), max && curve.pointT(max));\r\n }\r\n static forParametricPointsTangents(ps, is, pmPoints, pmTangents, stepSize, dir = 1, tMin, tMax) {\r\n const pFunc = ps.pUVFunc(), dpdu = ps.dpdu();\r\n const dpdv = ps.dpdv();\r\n const points = pmPoints.map(({ x, y }) => pFunc(x, y));\r\n const tangents = pmPoints.map(({ x: u, y: v }, i) => {\r\n const ds = dpdu(u, v);\r\n const dt = dpdv(u, v);\r\n return ds.times(pmTangents[i].x).plus(dt.times(pmTangents[i].y));\r\n //const p = points[i]\r\n //return cs.normalP(p).cross(ses.normalP(p))\r\n //\t.toLength(ds.times(pmTangents[i].x).plus(dt.times(pmTangents[i].y)).length())\r\n });\r\n return new PICurve(points, tangents, ps, is, pmPoints, pmTangents, stepSize, dir, undefined, tMin, tMax);\r\n }\r\n getConstructorParameters() {\r\n return [\r\n this.points,\r\n this.tangents,\r\n this.parametricSurface,\r\n this.implicitSurface,\r\n this.pmPoints,\r\n this.pmTangents,\r\n this.stepSize,\r\n this.dir,\r\n this.generator,\r\n ];\r\n }\r\n implicitCurve() {\r\n const pF = this.parametricSurface.pUVFunc();\r\n const iF = this.implicitSurface.implicitFunction();\r\n return (u, v) => iF(pF(u, v));\r\n }\r\n isColinearTo(curve) {\r\n if (curve instanceof PICurve) {\r\n if (this.equals(curve)) {\r\n return true;\r\n }\r\n if (this.parametricSurface.isCoplanarTo(curve.parametricSurface) &&\r\n this.implicitSurface.isCoplanarTo(curve.implicitSurface)) {\r\n // TODO\r\n }\r\n return false;\r\n }\r\n else {\r\n return false;\r\n }\r\n }\r\n containsPoint(p) {\r\n assertVectors(p);\r\n const t = this.pointT(p);\r\n return !isNaN(t) && this.isValidT(t);\r\n }\r\n equals(obj) {\r\n return (Object.getPrototypeOf(obj) == PICurve.prototype &&\r\n this.parametricSurface.equals(obj.parametricSurface) &&\r\n this.implicitSurface.equals(obj.implicitSurface) &&\r\n this.points[0].equals(obj.points[0]) &&\r\n this.tangents[0].equals(obj.tangents[0]) &&\r\n this.dir === obj.dir);\r\n }\r\n hashCode() {\r\n let hashCode = 0;\r\n hashCode = hashCode * 31 + this.parametricSurface.hashCode();\r\n hashCode = hashCode * 31 + this.implicitSurface.hashCode();\r\n hashCode = hashCode * 31 + this.points[0].hashCode();\r\n hashCode = hashCode * 31 + this.tangents[0].hashCode();\r\n return hashCode | 0;\r\n }\r\n tangentP(point) {\r\n assertVectors(point);\r\n assert(this.containsPoint(point), \"this.containsPoint(point)\");\r\n const t = this.pointT(point);\r\n return this.tangentAt(t);\r\n }\r\n tangentAt(t) {\r\n assert(!isNaN(t));\r\n if (0 === t % 1)\r\n return this.tangents[t];\r\n const uv = this.uvT(t);\r\n const uvTangent = new V3(-this.didv(uv.x, uv.y), this.didu(uv.x, uv.y), 0).toLength(this.stepSize);\r\n const du = this.parametricSurface.dpdu()(uv.x, uv.y);\r\n const dv = this.parametricSurface.dpdv()(uv.x, uv.y);\r\n return du.times(uvTangent.x).plus(dv.times(uvTangent.y));\r\n }\r\n at(t) {\r\n assert(!isNaN(t));\r\n if (0 === t % 1)\r\n return this.points[t];\r\n const startParams = V3.lerp(this.pmPoints[floor(t)], this.pmPoints[ceil(t)], t % 1);\r\n return this.closestPointToParams(startParams);\r\n }\r\n uvT(t) {\r\n assert(!isNaN(t));\r\n //TODO: use elerp\r\n if (0 === t % 1)\r\n return this.pmPoints[t];\r\n const startParams = V3.lerp(this.pmPoints[floor(t)], this.pmPoints[ceil(t)], t % 1);\r\n return curvePoint(this.implicitCurve(), startParams, this.didu, this.didv);\r\n }\r\n closestTToPoint(p, tStart) {\r\n // TODO\r\n return 0;\r\n }\r\n closestPointToParams(startUV) {\r\n const pointParams = curvePoint(this.implicitCurve(), startUV, this.didu, this.didv);\r\n return this.parametricSurface.pUVFunc()(pointParams.x, pointParams.y);\r\n }\r\n isTsWithSurface(surface) {\r\n if (surface instanceof EllipsoidSurface) {\r\n const pS = this.parametricSurface, iS = this.implicitSurface;\r\n if (pS instanceof ProjectedCurveSurface &&\r\n iS instanceof EllipsoidSurface) {\r\n const iscs = iS.isCurvesWithSurface(surface);\r\n const points = iscs.flatMap((isc) => isc.isTsWithSurface(pS).map((t) => isc.at(t)));\r\n const ts = fuzzyUniques(points.map((p) => this.pointT(p)));\r\n return ts.filter((t) => !isNaN(t) && this.isValidT(t));\r\n }\r\n }\r\n else if (ImplicitSurface.is(surface)) {\r\n const result = [];\r\n const iF = surface.implicitFunction();\r\n let prevSignedDistance = iF(this.points[0]);\r\n for (let i = 1; i < this.points.length; i++) {\r\n const point = this.points[i];\r\n const signedDistance = iF(point);\r\n if (prevSignedDistance * signedDistance <= 0) {\r\n const pF = this.parametricSurface.pUVFunc();\r\n const dpdu = this.parametricSurface.dpdu();\r\n const dpdv = this.parametricSurface.dpdv();\r\n const startUV = this.pmPoints[abs(prevSignedDistance) < abs(signedDistance) ? i - 1 : i];\r\n const isUV = newtonIterate2dWithDerivatives(this.implicitCurve(), (u, v) => iF(pF(u, v)), startUV.x, startUV.y, 4, this.didu, this.didv, (u, v) => dpdu(u, v).dot(surface.didp(pF(u, v))), (u, v) => dpdv(u, v).dot(surface.didp(pF(u, v))));\r\n result.push(this.pointT(this.parametricSurface.pUV(isUV.x, isUV.y)));\r\n }\r\n prevSignedDistance = signedDistance;\r\n }\r\n return result;\r\n }\r\n throw new Error();\r\n }\r\n isTsWithPlane(planeWC) {\r\n return this.isTsWithSurface(new PlaneSurface(planeWC));\r\n // version which intersects the plane with the defining surfaces of this PICurve, but this causes\r\n // issues when they are PICurves too:\r\n // assertInst(P3, planeWC)\r\n // const ps = this.parametricSurface,\r\n // \tis = this.implicitSurface\r\n // const pscs = ps.isCurvesWithPlane(planeWC)\r\n // const iscs = is.isCurvesWithPlane(planeWC)\r\n // const infos = iscs.flatMap(isc => pscs.flatMap(psc => isc.isInfosWithCurve(psc)))\r\n // const ts = fuzzyUniques(infos.map(info => this.pointT(info.p)))\r\n // return ts.filter(t => !isNaN(t) && this.isValidT(t))\r\n }\r\n pointT(p) {\r\n assertVectors(p);\r\n if (!this.parametricSurface.containsPoint(p) ||\r\n !this.implicitSurface.containsPoint(p)) {\r\n return NaN;\r\n }\r\n const pmPoint = this.parametricSurface.uvPFunc()(p);\r\n const ps = this.points, pmps = this.pmPoints;\r\n let t = 0, pmDistance = pmPoint.distanceTo(pmps[0]);\r\n while (pmDistance > abs(this.stepSize) && t < ps.length - 1) {\r\n // TODO -1?\r\n //console.log(t, pmps[t].$, pmDistance)\r\n t = min(pmps.length - 1, t + max(1, Math.round(pmDistance / abs(this.stepSize) / 2 / 2)));\r\n pmDistance = pmPoint.distanceTo(pmps[t]);\r\n }\r\n // if (t < this.pmPoints.length - 1 && pmDistance > pmPoint.distanceTo(pmps[t + 1])) {\r\n // t++\r\n // }\r\n if (pmDistance > abs(this.stepSize) * 1.1) {\r\n // p is not on this curve\r\n return NaN;\r\n }\r\n if (t == ps.length - 1) {\r\n t--;\r\n }\r\n if (ps[t].like(p))\r\n return t;\r\n if (ps[t + 1].like(p))\r\n return t + 1;\r\n const startT = withMax(arrayRange(floor(this.tMin), ceil(this.tMax), 1), (t) => -pmPoint.distanceTo(pmps[t]));\r\n if (undefined === startT)\r\n throw new Error();\r\n if (ps[startT].like(p))\r\n return startT;\r\n //const [a, b] = 0 === startT\r\n // ? [0, 1]\r\n // : this.points.length - 1 === startT\r\n // ? [startT - 1, startT]\r\n // : pmPoint.distanceTo(pmps[startT - 1]) < pmPoint.distanceTo(pmps[startT + 1])\r\n // ? [startT - 1, startT]\r\n // : [startT, startT + 1]\r\n const a = max(0, startT - 1), b = min(this.points.length - 1, startT + 1);\r\n const tangent = this.tangentAt(startT);\r\n const f = (t) => this.at(clamp(t, 0, this.points.length - 1))\r\n .to(p)\r\n .dot(tangent);\r\n // const df = (t: number) => -this.tangentAt(clamp(t, 0, this.points.length - 1)).dot(tangent)\r\n //checkDerivate(f, df, 0, this.points.length - 2, 3)\r\n // 8 steps necessary because df can currently be way off\r\n t = bisect(f, a, b, 32);\r\n if (!isFinite(t) || this.at(t).distanceTo(p) > abs(this.stepSize)) {\r\n return NaN;\r\n }\r\n return t;\r\n }\r\n transform(m4) {\r\n const dirFactor = m4.isMirroring() ? -1 : 1;\r\n return PICurve.forStartEnd(this.parametricSurface.transform(m4), this.implicitSurface.transform(m4), m4.transformPoint(this.points[0]), m4.transformPoint(getLast(this.points)), this.stepSize * dirFactor, m4.transformVector(this.tangents[0]), m4.transformPoint(this.at(this.tMin)), m4.transformPoint(this.at(this.tMax)));\r\n //return PICurve.forParametricStartEnd(\r\n //\tthis.parametricSurface.transform(m4),\r\n //\tthis.implicitSurface.transform(m4),\r\n //\tthis.pmPoints[0],\r\n //\tgetLast(this.pmPoints),\r\n //\tthis.stepSize,\r\n //\tthis.dir,\r\n //\tthis.tMin,\r\n //\tthis.tMax)\r\n // TODO: pass transformed points?\r\n //return new PICurve(\r\n //\tm4.transformedPoints(this.points),\r\n //\tm4.transformedVectors(this.tangents),\r\n // this.parametricSurface.transform(m4),\r\n // this.implicitSurface.transform(m4),\r\n // this.pmPoints,\r\n // this.pmTangents,\r\n //this.stepSize,\r\n // this.dir,\r\n //this.generator,\r\n //this.tMin, this.tMax)\r\n }\r\n roots() {\r\n const allTs = arrayRange(0, this.points.length);\r\n return [allTs, allTs, allTs];\r\n }\r\n isInfosWithLine(anchorWC, dirWC, tMin, tMax, lineMin, lineMax) {\r\n return surfaceIsICurveIsInfosWithLine.call(this, this.implicitSurface, this.parametricSurface, anchorWC, dirWC, tMin, tMax, lineMin, lineMax);\r\n }\r\n toSource(rounder = (x) => x) {\r\n const result = callsce(\"PICurve.forParametricStartEnd\", this.parametricSurface, this.implicitSurface, this.pmPoints[0], getLast(this.pmPoints), this.stepSize, this.pmTangents[0], this.tMin, this.tMax);\r\n return result;\r\n }\r\n}\r\nPICurve.prototype.tIncrement = 1;\r\n//# sourceMappingURL=PICurve.js.map","import { assert, assertVectors, callsce, getLast, newtonIterate, V3, } from \"ts3dutils\";\r\nimport { curvePointPP, followAlgorithmPP, ImplicitCurve, ImplicitSurface, ParametricSurface, PlaneSurface, surfaceIsICurveIsInfosWithLine, } from \"../index\";\r\nimport { abs, ceil, floor } from \"../math\";\r\nexport class PPCurve extends ImplicitCurve {\r\n constructor(points, tangents, parametricSurface1, parametricSurface2, st1s, pmTangents, stepSize, dir = 1, generator, tMin, tMax) {\r\n super(points, tangents, dir, generator, tMin, tMax);\r\n this.parametricSurface1 = parametricSurface1;\r\n this.parametricSurface2 = parametricSurface2;\r\n this.st1s = st1s;\r\n this.pmTangents = pmTangents;\r\n this.stepSize = stepSize;\r\n assert(ParametricSurface.is(parametricSurface1));\r\n assert(ParametricSurface.is(parametricSurface2));\r\n assert(Array.isArray(st1s));\r\n assert(dir == 1);\r\n assert(stepSize <= 1);\r\n }\r\n at(t) {\r\n assert(!isNaN(t));\r\n if (0 === t % 1)\r\n return this.points[t];\r\n const startPoint = V3.lerp(this.points[floor(t)], this.points[ceil(t)], t % 1);\r\n return curvePointPP(this.parametricSurface1, this.parametricSurface2, startPoint).p;\r\n }\r\n isColinearTo(curve) {\r\n if (curve instanceof PPCurve) {\r\n if (this.equals(curve)) {\r\n return true;\r\n }\r\n if (this.parametricSurface1.isCoplanarTo(curve.parametricSurface1) &&\r\n this.parametricSurface1.isCoplanarTo(curve.parametricSurface2)) {\r\n // TODO\r\n }\r\n return false;\r\n }\r\n else {\r\n return false;\r\n }\r\n }\r\n containsPoint(p) {\r\n assertVectors(p);\r\n // TODO: wrong, as there could be another curve\r\n return (this.parametricSurface1.containsPoint(p) &&\r\n this.parametricSurface2.containsPoint(p) &&\r\n !isNaN(this.pointT(p)));\r\n }\r\n rootPoints() {\r\n const pF1 = this.parametricSurface1.pUVFunc();\r\n const pF2 = this.parametricSurface2.pUVFunc();\r\n const pN1 = this.parametricSurface1.normalUVFunc();\r\n const pN2 = this.parametricSurface2.normalUVFunc();\r\n const rootsApprox = this.rootsApprox();\r\n const results = [[], [], []];\r\n for (let dim = 0; dim < 3; dim++) {\r\n for (let i = 0; i < rootsApprox[dim].length; i++) {\r\n const lambda = rootsApprox[dim][i];\r\n const p = this.at(lambda);\r\n assert(this.parametricSurface1.containsPoint(p));\r\n const pp1 = this.parametricSurface1.uvP(p);\r\n const { x: u, y: v } = this.parametricSurface2.uvP(p);\r\n const startValues = [pp1.x, pp1.y, u, v];\r\n function f(vals) {\r\n const [u1, v1, u2, v2] = vals;\r\n const diff = pF1(u1, v1).minus(pF2(u2, v2));\r\n const n1 = pN1(u1, v1);\r\n const n2 = pN2(u2, v2);\r\n const tangent = n1.cross(n2);\r\n return [diff.x, diff.y, diff.z, tangent.e(dim)];\r\n }\r\n const pps = newtonIterate(f, startValues, 8);\r\n // assert(pF1(pps[0], pps[1]).like(pF2(pps[2], pps[3])),\r\n // \tpF1(pps[0], pps[1]).sce + pF2(pps[2], pps[3]).sce)\r\n const result = pF1(pps[0], pps[1]);\r\n results[dim].push(result);\r\n }\r\n }\r\n return results;\r\n }\r\n roots() {\r\n return this.rootPoints().map((ps) => ps.map((p) => this.pointT(p)));\r\n }\r\n pointTangent(pWC) {\r\n assertVectors(pWC);\r\n assert(this.containsPoint(pWC), \"this.containsPoint(pWC)\");\r\n const n1 = this.parametricSurface1.normalP(pWC);\r\n const n2 = this.parametricSurface2.normalP(pWC);\r\n return n1.cross(n2);\r\n }\r\n transform(m4) {\r\n return new PPCurve(m4.transformedPoints(this.points), m4.transformedVectors(this.tangents), this.parametricSurface1.transform(m4), this.parametricSurface2.transform(m4), this.st1s, undefined, this.stepSize, this.dir, undefined);\r\n }\r\n toSource() {\r\n return callsce(\"PPCurve.forStartEnd\", this.parametricSurface1, this.parametricSurface2, this.points[0], getLast(this.points), this.stepSize);\r\n }\r\n static forStartEnd(ps1, ps2, startPoint, end, stepSize = 0.02) {\r\n const { points, tangents, st1s } = followAlgorithmPP(ps1, ps2, startPoint, stepSize);\r\n return new PPCurve(points, tangents, ps1, ps2, st1s, undefined, stepSize, 1);\r\n }\r\n isInfosWithLine(anchorWC, dirWC, tMin, tMax, lineMin, lineMax) {\r\n return surfaceIsICurveIsInfosWithLine.call(this, this.parametricSurface1, this.parametricSurface2, anchorWC, dirWC, tMin, tMax, lineMin, lineMax);\r\n }\r\n isTsWithSurface(surface) {\r\n if (ImplicitSurface.is(surface)) {\r\n const result = [];\r\n const iF = surface.implicitFunction();\r\n const pUV1 = this.parametricSurface1.pUVFunc();\r\n const pUV2 = this.parametricSurface2.pUVFunc();\r\n let prevSignedDistance = iF(this.points[0]);\r\n for (let i = 1; i < this.points.length; i++) {\r\n const point = this.points[i];\r\n const signedDistance = iF(point);\r\n if (prevSignedDistance * signedDistance <= 0) {\r\n const startIndex = abs(prevSignedDistance) < abs(signedDistance) ? i - 1 : i;\r\n const startPoint = this.points[startIndex];\r\n const startUV1 = this.st1s[startIndex];\r\n const startUV2 = this.parametricSurface2.uvP(startPoint);\r\n const isSTUV = newtonIterate(([u1, v1, u2, v2]) => {\r\n const ps1p = pUV1(u1, v1);\r\n const ps2p = pUV2(u2, v2);\r\n return [...ps1p.to(ps2p), iF(ps1p)];\r\n }, [startUV1.x, startUV1.y, startUV2.x, startUV2.y]);\r\n result.push(this.pointT(this.parametricSurface1.pUV(isSTUV[0], isSTUV[1])));\r\n }\r\n prevSignedDistance = signedDistance;\r\n }\r\n return result;\r\n }\r\n throw new Error(\"Method not implemented.\");\r\n }\r\n isTsWithPlane(planeWC) {\r\n return this.isTsWithSurface(new PlaneSurface(planeWC));\r\n }\r\n}\r\n//# sourceMappingURL=PPCurve.js.map","import { arrayFromFunction, assertNumbers, eq, eq0, hasConstructor, le, pqFormula, V3, } from \"ts3dutils\";\r\nimport { BezierCurve, L3, XiEtaCurve, } from \"../index\";\r\nimport { parabola4Projection } from \"./XiEtaCurve\";\r\n/**\r\n * eta = xi²\r\n */\r\nexport class ParabolaCurve extends XiEtaCurve {\r\n constructor(center, f1, f2, tMin = -10, tMax = 10) {\r\n super(center, f1, f2, tMin, tMax);\r\n }\r\n static eccentricity() {\r\n return 1;\r\n }\r\n static unitIsInfosWithLine(anchorLC, dirLC, anchorWC, dirWC) {\r\n // para: x² = y\r\n // line(t) = anchor + t dir\r\n // (ax + t dx)² = ay + t dy\r\n // ax² + t ax dx + t² dx² = ay + t dy\r\n // t² dx² + t (ax dx + dy) + ay² + ay = 0\r\n const pqDiv = Math.pow(dirLC.x, 2);\r\n const lineTs = pqFormula((anchorLC.x * dirLC.x + dirLC.y) / pqDiv, (Math.pow(anchorLC.x, 2) + anchorLC.y) / pqDiv);\r\n return lineTs\r\n .filter((tOther) => le(0, anchorLC.y + tOther * dirLC.y))\r\n .map((tOther) => ({\r\n tThis: dirLC.x * tOther + anchorLC.x,\r\n tOther: tOther,\r\n p: L3.at(anchorWC, dirWC, tOther),\r\n }));\r\n }\r\n static intersectionUnitLine(a, b, c) {\r\n /*\r\n solve system (5)/(6)\r\n g1 * xi + g2 * eta = g3 (6)\r\n g1 * xi + g2 * xi * xi = g3\r\n xi² + xi * g1/g2 - g3/g2 = 0\r\n */\r\n return pqFormula(a / b, -c / b);\r\n }\r\n static XYLCValid(pLC) {\r\n return eq(Math.pow(pLC.x, 2), pLC.y);\r\n }\r\n static XYLCPointT(pLC) {\r\n return pLC.x;\r\n }\r\n static quadratic(a, b, c) {\r\n // (1 - t)² a + 2 * t * (1 - t) b + t² c\r\n // (1 -2t +t²)a + (2t -2t²) b + t² c\r\n // = t²(a - 2b + c) + t (-2a + 2b) + a\r\n // (2t - 2) a + (1 - 2t) b + 2t c = t(2a + 2b - 2c) - 2a + b\r\n // 2 a + -2 b + 2 c\r\n const f2 = a.plus(c).minus(b.times(2));\r\n const f1 = b.minus(a).times(2);\r\n const center = a;\r\n return new ParabolaCurve(center, f1, f2, 0, 1);\r\n }\r\n at(t) {\r\n // center + f1 t + f2 t²\r\n return this.center.plus(this.f1.times(t)).plus(this.f2.times(t * t));\r\n }\r\n tangentAt(t) {\r\n assertNumbers(t);\r\n // f1 + f2 2 t\r\n return this.f1.plus(this.f2.times(2 * t));\r\n }\r\n ddt(t) {\r\n assertNumbers(t);\r\n return this.f2.times(2);\r\n }\r\n tangentAt2(xi, eta) {\r\n assertNumbers(xi, eta);\r\n return this.f1.plus(this.f2.times(2 * eta));\r\n }\r\n reversed() {\r\n return new this.constructor(this.center, this.f1.negated(), this.f2, -this.tMax, -this.tMin);\r\n }\r\n /**\r\n * tangent: f1 + 2 * t * f2 = 0\r\n * t = -f1 / 2 / f2 (for individual dimensions)\r\n */\r\n roots() {\r\n const dimRoots = (dim) => eq0(this.f2.e(dim)) ? [] : [-this.f1.e(dim) / 2 / this.f2.e(dim)];\r\n return arrayFromFunction(3, dimRoots);\r\n }\r\n isColinearTo(curve) {\r\n if (!hasConstructor(curve, ParabolaCurve))\r\n return false;\r\n const thisRA = this.rightAngled(), curveRA = curve.rightAngled();\r\n return (thisRA.center.like(curveRA.center) &&\r\n thisRA.f2.like(curveRA.f2) &&\r\n thisRA.f1.likeOrReversed(curveRA.f1));\r\n }\r\n rightAngled() {\r\n // looking for vertex of parabola\r\n // this is the point where the tangent is perpendicular to the main axis (f2)\r\n // tangent = f1 + f2 * 2 * t0\r\n // f2 DOT (f1 + f2 * 2 * t0) == 0\r\n // f1 DOT f2 + f2 DOT f2 * 2 * t0 == 0\r\n // t0 == -(f1 DOT f2) / (f2 DOT f2 * 2)\r\n const f1 = this.f1, f2 = this.f2;\r\n const f1DOTf2 = f1.dot(f2);\r\n if (eq0(f1DOTf2) && f1.hasLength(1)) {\r\n return this;\r\n }\r\n const t0 = -f1DOTf2 / f2.squared() / 2;\r\n // we need to rearange tMin/tMax\r\n // tMin' = pointT(at(tMin)) =\r\n const raCenter = this.at(t0);\r\n const raF1 = this.tangentAt(t0), raF1Length = raF1.length(), raF11 = raF1.unit();\r\n const repos = (t) => this.at(t).minus(raCenter).dot(raF11);\r\n return new ParabolaCurve(raCenter, raF11, f2.div(Math.pow(raF1Length, 2)), repos(this.tMin), repos(this.tMax));\r\n }\r\n arcLength(startT, endT) {\r\n let f1 = this.f1;\r\n const f2 = this.f2;\r\n const f1DOTf2 = f1.dot(f2);\r\n let t0 = 0;\r\n if (!eq0(f1DOTf2)) {\r\n t0 = -f1DOTf2 / f2.squared() / 2;\r\n f1 = f1.plus(f2.times(2 * t0));\r\n }\r\n const f1Length = f1.length();\r\n const a = f2.length() / f1Length;\r\n function F(x) {\r\n return (Math.asinh(a * 2 * x) / 4 / a +\r\n (x * Math.sqrt(1 + a * a * 4 * x * x)) / 2);\r\n }\r\n return f1Length * (F(endT - t0) - F(startT - t0));\r\n }\r\n transform4(m4) {\r\n return parabola4Projection(this.matrix.transform(m4), this.tMin, this.tMax);\r\n }\r\n asBezier() {\r\n return BezierCurve.quadratic(this.at(-1), new L3(this.at(-1), this.tangentAt(-1).unit()).isInfoWithLine(new L3(this.at(1), this.tangentAt(1).unit())), this.at(1));\r\n }\r\n /**\r\n * Returns new ParabolaCurve that has its center point at this.at(t0)\r\n * @param t0\r\n */\r\n recenter(t0) {\r\n // this.at(t) = f2 t² + f1 t + center\r\n // c2.at(t) = f2 (t + t0)² + f1 (t + t0) + center\r\n // c2.at(t) = f2 (t² + 2 t0 t + t0²) + f1 (t + t0) + center\r\n // c2.at(t) = f2 t² + (f1 + 2 f2 t0) t + center + f2 t0² + f1 t0\r\n return new ParabolaCurve(this.at(t0), this.f1.plus(this.f2.times(2 * t0)), this.f2);\r\n }\r\n}\r\nParabolaCurve.XY = new ParabolaCurve(V3.O, V3.X, V3.Y);\r\nParabolaCurve.YZ = new ParabolaCurve(V3.O, V3.Y, V3.Z);\r\nParabolaCurve.ZX = new ParabolaCurve(V3.O, V3.Z, V3.X);\r\nParabolaCurve.prototype.tIncrement = 1 / 32;\r\n//# sourceMappingURL=ParabolaCurve.js.map","import { arrayFromFunction, assert, assertf, assertNumbers, assertVectors, between, checkDerivate, eq, eq0, fuzzyBetween, hasConstructor, le, lerp, lt, M4, mapFilter, newtonIterate1d, newtonIterateSmart, pqFormula, TAU, V3, } from \"ts3dutils\";\r\nimport { Curve, intersectionUnitCircleLine, intersectionUnitCircleLine2, L3, P3, XiEtaCurve, } from \"../index\";\r\nimport { atan2, cos, max, min, PI, sign, sqrt } from \"../math\";\r\nimport { parabola4Projection } from \"./XiEtaCurve\";\r\nexport class EllipseCurve extends XiEtaCurve {\r\n constructor(center, f1, f2, tMin = 0, tMax = PI) {\r\n super(center, f1, f2, tMin, tMax);\r\n assert(-PI <= this.tMin && this.tMin < PI);\r\n assert(-PI < this.tMax && this.tMax <= PI);\r\n }\r\n static andFixTs(center, f1, f2, tMin = 0, tMax = PI) {\r\n if (-PI <= tMin && tMax <= PI) {\r\n return new EllipseCurve(center, f1, f2, tMin, tMax);\r\n }\r\n if (0 <= tMin && tMax <= TAU) {\r\n return new EllipseCurve(center, f1.negated(), f2.negated(), tMin - PI, tMax - PI);\r\n }\r\n if (-TAU <= tMin && tMax <= 0) {\r\n return new EllipseCurve(center, f1.negated(), f2.negated(), tMin + PI, tMax + PI);\r\n }\r\n throw new Error(\"Method not implemented.\");\r\n }\r\n static XYLCValid(pLC) {\r\n const { x, y } = pLC;\r\n return eq0(Math.pow(x, 2) + Math.pow(y, 2) - 1);\r\n }\r\n static XYLCPointT(pLC, tMin, tMax) {\r\n assertNumbers(tMin, tMax);\r\n const t = atan2(pLC.y, pLC.x);\r\n const lowSplitter = lerp(tMin, tMax - TAU, 0.5);\r\n if (t < lowSplitter) {\r\n return t + TAU;\r\n }\r\n const highSplitter = lerp(tMax, tMin + TAU, 0.5);\r\n if (t > highSplitter) {\r\n return t - TAU;\r\n }\r\n return t;\r\n }\r\n static intersectionUnitLine(a, b, c, tMin, tMax) {\r\n const isLC = intersectionUnitCircleLine2(a, b, c);\r\n const result = [];\r\n for (const [xi, eta] of isLC) {\r\n const t = EllipseCurve.XYLCPointT(new V3(xi, eta, 0), tMin, tMax);\r\n fuzzyBetween(t, tMin, tMax) && result.push(t);\r\n }\r\n return result;\r\n }\r\n static unitIsInfosWithLine(anchorLC, dirLC, anchorWC, dirWC, tMin, tMax) {\r\n // ell: x² + y² = 1 = p²\r\n // line(t) = anchor + t dir\r\n // anchor² - 1 + 2 t dir anchor + t² dir² = 0\r\n const pqDiv = dirLC.squared();\r\n const lineTs = pqFormula((2 * dirLC.dot(anchorLC)) / pqDiv, (anchorLC.squared() - 1) / pqDiv);\r\n return lineTs\r\n .filter((tOther) => le(0, anchorLC.y + tOther * dirLC.y))\r\n .map((tOther) => ({\r\n tThis: EllipseCurve.XYLCPointT(dirLC.times(tOther).plus(anchorLC), tMin, tMax),\r\n tOther: tOther,\r\n p: L3.at(anchorWC, dirWC, tOther),\r\n }));\r\n }\r\n /**\r\n * Returns a new EllipseCurve representing a circle parallel to the XY-plane.`\r\n */\r\n static semicircle(radius, center = V3.O, tMin, tMax) {\r\n return new EllipseCurve(center, new V3(radius, 0, 0), new V3(0, radius, 0), tMin, tMax);\r\n }\r\n static circleForCenter2P(center, a, b, radius, tMin, tMax) {\r\n const f1 = center.to(a);\r\n const normal = f1.cross(center.to(b));\r\n const f2 = normal.cross(f1).toLength(f1.length());\r\n return new EllipseCurve(center, f1, f2, undefined !== tMin ? tMin : 0, undefined !== tMax ? tMax : f1.angleTo(center.to(b)));\r\n }\r\n split(tMin = this.tMin, tMax = this.tMax) {\r\n const result = [];\r\n tMin < 0 &&\r\n result.push(new EllipseCurve(this.center, this.f1.negated(), this.f2.negated(), tMin + PI, min(0, tMax) + PI));\r\n tMax > 0 &&\r\n result.push(new EllipseCurve(this.center, this.f1, this.f2, max(0, tMin), tMax));\r\n return result;\r\n }\r\n static forAB(a, b, center = V3.O) {\r\n return super.forAB(a, b, center);\r\n }\r\n /**\r\n * Create a circle curve which has a, b and c on it. a, b, c can't be on a straight line.\r\n * tMin defaults to 0, tMax defaults to the value for c\r\n */\r\n static circleThroughPoints(a, b, c, tMin = 0, tMax) {\r\n assertf(() => !L3.throughPoints(a, c).containsPoint(b));\r\n const normal = a.to(b).cross(b.to(c));\r\n const center = new L3(a.lerp(b, 0.5), normal.cross(a.to(b)).unit()).isInfoWithLine(new L3(b.lerp(c, 0.5), normal.cross(b.to(c)).unit()));\r\n const f1 = center.to(a).negated();\r\n return new EllipseCurve(center, f1, normal.unit().cross(f1), -PI, undefined === tMax\r\n ? f1.angleRelativeNormal(center.to(c), normal.unit())\r\n : tMax);\r\n }\r\n getAreaInDir(right, up, tStart, tEnd) {\r\n //assertf(() => tStart < tEnd)\r\n assertf(() => right.isPerpendicularTo(this.normal));\r\n assertf(() => up.isPerpendicularTo(this.normal));\r\n //assertf(() => EllipseCurve.isValidT(tStart), tStart)\r\n //assertf(() => EllipseCurve.isValidT(tEnd), tEnd)\r\n const upLC = this.matrixInverse.transformVector(up);\r\n const rightLC = upLC.cross(V3.Z);\r\n const normTStart = tStart - rightLC.angleXY();\r\n const normTEnd = tEnd - rightLC.angleXY();\r\n const transformedOriginY = this.matrixInverse\r\n .getTranslation()\r\n .dot(upLC.unit());\r\n // integral of sqrt(1 - x²) from 0 to cos(t)\r\n // Basically, we want\r\n // INTEGRAL[cos(t); PI/2] sqrt(1 - x²) dx\r\n // INTEGRAL[PI/2: cos(t)] -sqrt(1 - x²) dx\r\n // = INTEGRAL[cos(0); cos(t)] -sqrt(1 - x²) dx\r\n // = INTEGRAL[0; t] -sqrt(1 - cos²(t)) * -sin(t) dt\r\n // = INTEGRAL[0; t] -sin(t) * -sin(t) dt\r\n // = INTEGRAL[0; t] sin²(t) dt (partial integration / wolfram alpha)\r\n // = (1/2 * (t - sin(t) * cos(t)))[0; t] (this form has the distinct advantage of being defined everywhere)\r\n function fArea(t) {\r\n return (t - Math.sin(t) * Math.cos(t)) / 2;\r\n }\r\n // for the centroid, we want\r\n // cx = 1 / area * INTEGRAL[cos(t); PI/2] x * f(x) dx\r\n // cx = 1 / area * INTEGRAL[cos(t); PI/2] x * sqrt(1 - x²) dx\r\n // cx = 1 / area * INTEGRAL[cos(0); cos(t)] x * -sqrt(1 - x²) dx\r\n // ...\r\n // cx = 1 / area * INTEGRAL[0; t] cos(t) * sin²(t) dt // WA\r\n // cx = 1 / area * (sin^3(t) / 3)[0; t]\r\n function cxTimesArea(t) {\r\n return Math.pow(Math.sin(t), 3) / 3;\r\n }\r\n // cy = 1 / area * INTEGRAL[cos(t); PI/2] f²(x) / 2 dx\r\n // cy = 1 / area * INTEGRAL[cos(0); cos(t)] -(1 - x²) / 2 dx\r\n // cy = 1 / area * INTEGRAL[0; t] (cos²(t) - 1) * -sin(t) / 2 dt\r\n // cy = 1 / area * (cos (3 * t) - 9 * cos(t)) / 24 )[0; t]\r\n function cyTimesArea(t) {\r\n return (Math.cos(3 * t) - 9 * Math.cos(t)) / 24;\r\n }\r\n const restArea = -transformedOriginY * (-Math.cos(normTEnd) + Math.cos(normTStart));\r\n const area = fArea(normTEnd) - fArea(normTStart) + restArea;\r\n const cxt = (cxTimesArea(normTEnd) -\r\n cxTimesArea(normTStart) +\r\n ((-transformedOriginY * (-Math.cos(normTEnd) - Math.cos(normTStart))) /\r\n 2) *\r\n restArea) /\r\n area;\r\n const cyt = (cyTimesArea(normTEnd) -\r\n cyTimesArea(normTStart) -\r\n (-transformedOriginY / 2) * restArea) /\r\n area;\r\n const factor = this.matrix.xyAreaFactor(); // * upLC.length()\r\n //console.log('fctor', factor, 'area', area, 'resultarea', area* factor)\r\n assert(!eq0(factor));\r\n return {\r\n area: area * factor,\r\n centroid: this.matrix.transformPoint(M4.rotateZ(rightLC.angleXY()).transformPoint(new V3(cxt, cyt, 0))),\r\n };\r\n }\r\n at(t) {\r\n assertNumbers(t);\r\n //assert(this.isValidT(t))\r\n // = center + f1 cos t + f2 sin t\r\n return this.center\r\n .plus(this.f1.times(Math.cos(t)))\r\n .plus(this.f2.times(Math.sin(t)));\r\n }\r\n tangentAt(t) {\r\n assertNumbers(t);\r\n //assert(this.isValidT(t))\r\n // ) f2 cos(t) - f1 sin(t)\r\n return this.f2.times(Math.cos(t)).minus(this.f1.times(Math.sin(t)));\r\n }\r\n ddt(t) {\r\n assertNumbers(t);\r\n assert(this.isValidT(t));\r\n return this.f2.times(-Math.sin(t)).minus(this.f1.times(Math.cos(t)));\r\n }\r\n tangentAt2(xi, eta) {\r\n return this.f2.times(xi).minus(this.f1.times(eta));\r\n }\r\n isCircular() {\r\n return (eq(this.f1.length(), this.f2.length()) &&\r\n this.f1.isPerpendicularTo(this.f2));\r\n }\r\n isColinearTo(curve) {\r\n if (!hasConstructor(curve, EllipseCurve))\r\n return false;\r\n if (!this.center.like(curve.center)) {\r\n return false;\r\n }\r\n if (this == curve) {\r\n return true;\r\n }\r\n if (this.isCircular()) {\r\n return (curve.isCircular() &&\r\n eq(this.f1.length(), curve.f1.length()) &&\r\n this.normal.isParallelTo(curve.normal));\r\n }\r\n else {\r\n let { f1: f1, f2: f2 } = this.rightAngled(), { f1: c1, f2: c2 } = curve.rightAngled();\r\n if (f1.length() > f2.length()) {\r\n ;\r\n [f1, f2] = [f2, f1];\r\n }\r\n if (c1.length() > c2.length()) {\r\n ;\r\n [c1, c2] = [c2, c1];\r\n }\r\n return (eq(f1.squared(), Math.abs(f1.dot(c1))) &&\r\n eq(f2.squared(), Math.abs(f2.dot(c2))));\r\n }\r\n }\r\n pointT(pWC) {\r\n assertVectors(pWC);\r\n assert(this.containsPoint(pWC));\r\n const pLC = this.matrixInverse.transformPoint(pWC);\r\n const t = EllipseCurve.XYLCPointT(pLC, this.tMin, this.tMax);\r\n assert(this.isValidT(t));\r\n return t;\r\n }\r\n reversed() {\r\n return new EllipseCurve(this.center, this.f1.negated(), this.f2, PI - this.tMax, PI - this.tMin);\r\n }\r\n eccentricity() {\r\n const mainAxes = this.rightAngled();\r\n const f1length = mainAxes.f1.length(), f2length = mainAxes.f1.length();\r\n const [a, b] = f1length > f2length ? [f1length, f2length] : [f2length, f1length];\r\n return Math.sqrt(1 - (b * b) / a / a);\r\n }\r\n circumference() {\r\n return this.arcLength(-Math.PI, Math.PI);\r\n }\r\n arcLength(tStart = this.tMin, tEnd = this.tMax, steps = 2) {\r\n assert(tStart < tEnd, \"startT < endT\");\r\n const f1Length = this.f1.length();\r\n if (eq(f1Length, this.f2.length())) {\r\n return f1Length * (tEnd - tStart);\r\n }\r\n return super.arcLength(tStart, tEnd, steps);\r\n }\r\n circumferenceApproximate() {\r\n // approximate circumference by Ramanujan\r\n // https://en.wikipedia.org/wiki/Ellipse#Circumference\r\n const { f1, f2 } = this.rightAngled(), a = f1.length(), b = f2.length();\r\n const h = Math.pow((a - b), 2) / Math.pow((a + b), 2);\r\n return Math.PI * (a + b) * (1 + (3 * h) / (10 + Math.sqrt(4 - 3 * h)));\r\n }\r\n /**\r\n * Radii of the ellipse are described by\r\n * q(phi) = f1 * cos(phi) + f2 * sin(phi)\r\n * or q(xi, eta) = f1 * xi + f2 * eta (1) with the added condition\r\n * xi² + eta² = 1 (2)\r\n * we want to find the radius where the corresponding tangent is perpendicular\r\n * tangent: q'(phi) = f1 * -sin(phi) + f2 * cos(phi)\r\n * tangent: q'(xi, eta) = f1 * -eta + f2 * xi\r\n * perpendicular when: q'(xi, eta) DOT q(xi, eta) = 0\r\n * (f1 * -eta + f2 * xi) DOT (f1 * xi + f2 * eta) = 0\r\n * DOT is distributive:\r\n * f1² * (-eta * xi) + f1 * f2 * (-eta² + xi²) + f2² * (xi * eta) = 0\r\n * (f2² - f1²) * (eta * xi) + f1 * f2 * (-eta² + xi²) = 0\r\n * a * (xi² - eta²) + b * xi * eta = 0 (2)\r\n * with a = f1 * f2, b = f2² - f1²\r\n * => (xi/eta)² + xi/eta * b/a + 1 = 0 (divide by a * eta²)\r\n * xi/eta = b/a/2 +- sqrt(b²/a²/4 - 1) | * 2*a*eta\r\n * 2 * a * xi = eta * (b +- sqrt(b² - 4 * a²))\r\n * g1 * xi - g2 * eta = 0 (3)\r\n * with g1 = 2 * a, g2 = b +- sqrt(b² - 4 * a²)\r\n * Solve (3), (2) with intersectionUnitCircleLine\r\n */\r\n rightAngled() {\r\n const f1 = this.f1, f2 = this.f2, a = f1.dot(f2), b = f2.squared() - f1.squared();\r\n if (eq0(a)) {\r\n return this;\r\n }\r\n const g1 = 2 * a, g2 = b + Math.sqrt(b * b + 4 * a * a);\r\n const { x1: xi, y1: eta } = intersectionUnitCircleLine(g1, g2, 0);\r\n const f1RA = f1.times(xi).plus(f2.times(eta));\r\n const f2RA = f1.times(-eta).plus(f2.times(xi));\r\n return new EllipseCurve(this.center, f1RA, f2RA, -PI, PI);\r\n }\r\n isInfosWithEllipse(ellipse) {\r\n if (this.normal.isParallelTo(ellipse.normal) &&\r\n eq0(this.center.minus(ellipse.center).dot(ellipse.normal))) {\r\n // ellipses are coplanar\r\n const ellipseLCRA = ellipse.transform(this.matrixInverse).rightAngled();\r\n const r1 = ellipseLCRA.f1.lengthXY(), r2 = ellipseLCRA.f2.lengthXY(), centerDist = ellipseLCRA.center.lengthXY();\r\n const rMin = min(r1, r2), rMax = max(r1, r2);\r\n if (lt(centerDist + rMax, 1) || // entirely inside unit circle\r\n lt(1, centerDist - rMax) || // entirely outside unit circle\r\n lt(1, rMin - centerDist) || // contains unit circle\r\n (eq(1, r1) && eq(1, r2) && eq0(centerDist)) // also unit circle, return no IS\r\n ) {\r\n return [];\r\n }\r\n const f = (t) => ellipseLCRA.at(t).lengthXY() - 1;\r\n const df = (t) => ellipseLCRA.at(t).xy().dot(ellipseLCRA.tangentAt(t)) /\r\n ellipseLCRA.at(t).lengthXY();\r\n checkDerivate(f, df, -PI, PI, 1);\r\n const ellipseLCRATs = [];\r\n for (let startT = (-4 / 5) * PI; startT < PI; startT += PI / 4) {\r\n let t = newtonIterateSmart(f, startT, 16, df, 1e-4);\r\n le(t, -PI) && (t += TAU);\r\n assert(!isNaN(t));\r\n if (between(t, -PI, PI) &&\r\n eq0(f(t)) &&\r\n !ellipseLCRATs.some((r) => eq(t, r))) {\r\n ellipseLCRATs.push(t);\r\n }\r\n }\r\n const result = [];\r\n for (const ellipseLCRAT of ellipseLCRATs) {\r\n const p = this.matrix.transformPoint(ellipseLCRA.at(ellipseLCRAT));\r\n if (this.containsPoint(p) && ellipse.containsPoint(p)) {\r\n result.push({ tThis: this.pointT(p), tOther: ellipse.pointT(p), p });\r\n }\r\n }\r\n return result;\r\n //const angle = ellipseLCRA.f1.angleXY()\r\n //const aSqr = ellipseLCRA.f1.squared(), bSqr = ellipseLCRA.f2.squared()\r\n //const a = Math.sqrt(aSqr), b = Math.sqrt(bSqr)\r\n //const {x: centerX, y: centerY} = ellipseLCRA.center\r\n //const rotCenterX = centerX * Math.cos(-angle) + centerY * -Math.sin(-angle)\r\n //const rotCenterY = centerX * Math.sin(-angle) + centerY * Math.cos(-angle)\r\n //const rotCenter = V(rotCenterX, rotCenterY)\r\n //const f = t => {\r\n //\tconst lex = Math.cos(t) - rotCenterX, ley = Math.sin(t) - rotCenterY\r\n //\treturn lex * lex / aSqr + ley * ley / bSqr - 1\r\n //}\r\n //const f2 = (x, y) => (x * x + y * y - 1)\r\n //const f3 = (x, y) => ((x - rotCenterX) * (x - rotCenterX) / aSqr + (y - rotCenterY) * (y - rotCenterY) /\r\n // bSqr - 1) const results = [] const resetMatrix = this.matrix.times(M4.rotateZ(angle)) for (let startT =\r\n // Math.PI / 4; startT < 2 * Math.PI; startT += Math.PI / 2) { const startP = EllipseCurve.XY.at(startT)\r\n // const p = newtonIterate2d(f3, f2, startP.x, startP.y, 10) if (p && !results.some(r => r.like(p))) {\r\n // results.push(p) } } const rotEl = new EllipseCurve(rotCenter, V(a, 0, 0), V(0, b, 0)) return\r\n // results.map(pLC => { const p = resetMatrix.transformPoint(pLC) return {tThis: this.pointT(p, PI),\r\n // tOther: ellipse.pointT(p, PI), p} })\r\n }\r\n else {\r\n return mapFilter(this.isTsWithPlane(P3.normalOnAnchor(ellipse.normal.unit(), ellipse.center)), (t) => {\r\n const p = this.at(t);\r\n if (ellipse.containsPoint(p)) {\r\n return { tThis: t, tOther: ellipse.pointT(p), p };\r\n }\r\n return undefined;\r\n });\r\n }\r\n }\r\n isInfosWithCurve(curve) {\r\n if (curve instanceof EllipseCurve) {\r\n return this.isInfosWithEllipse(curve);\r\n }\r\n return super.isInfosWithCurve(curve);\r\n }\r\n transform4(m4) {\r\n const tMap = (t) => sign(t) * sqrt((1 - cos(t)) / (1 + cos(t)));\r\n // prettier-ignore\r\n const parabolaToUnitEllipse = new M4(0, -1, 0, 1, 2, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 1);\r\n return parabola4Projection(M4.product(m4, this.matrix, parabolaToUnitEllipse), tMap(this.tMin), tMap(this.tMax));\r\n }\r\n roots() {\r\n // tangent(t) = f2 cos t - f1 sin t\r\n // solve for each dimension separately\r\n // tangent(eta, xi) = f2 eta - f1 xi\r\n return arrayFromFunction(3, (dim) => {\r\n const a = this.f2.e(dim);\r\n const b = -this.f1.e(dim);\r\n return intersectionUnitCircleLine2(a, b, 0)\r\n .map(([xi, eta]) => Math.atan2(eta, xi))\r\n .filter((t) => this.isValidT(t));\r\n });\r\n }\r\n closestTToPoint(p, tStart) {\r\n // (at(t) - p) * tangentAt(t) = 0\r\n // (xi f1 + eta f2 + q) * (xi f2 - eta f1) = 0\r\n // xi eta (f2^2-f1^2) + xi f2 q - eta² f1 f2 + xi² f1 f2 - eta f1 q = 0\r\n // (xi² - eta²) f1 f2 + xi eta (f2^2-f1^2) + xi f2 q - eta f1 q = 0\r\n // atan2 of p is a good first approximation for the searched t\r\n tStart = tStart || this.matrixInverse.transformPoint(p).angleXY();\r\n const pRelCenter = p.minus(this.center);\r\n const f = (t) => this.tangentAt(t).dot(this.f1\r\n .times(Math.cos(t))\r\n .plus(this.f2.times(Math.sin(t)))\r\n .minus(pRelCenter));\r\n return newtonIterate1d(f, tStart, 8);\r\n }\r\n area() {\r\n // see\r\n // https://upload.wikimedia.org/wikipedia/commons/thumb/4/4e/Cross_product_parallelogram.svg/220px-Cross_product_parallelogram.svg.png\r\n return Math.PI * this.f1.cross(this.f2).length();\r\n }\r\n angleToT(phi) {\r\n // atan2(y, x) = phi\r\n const phiDir = this.f1\r\n .unit()\r\n .times(Math.cos(phi))\r\n .plus(this.f2.rejectedFrom(this.f1).unit().times(Math.sin(phi)));\r\n const dirLC = this.matrixInverse.transformVector(phiDir);\r\n return dirLC.angleXY();\r\n }\r\n}\r\nEllipseCurve.UNIT = new EllipseCurve(V3.O, V3.X, V3.Y);\r\nEllipseCurve.prototype.hlol = Curve.hlol++;\r\nEllipseCurve.prototype.tIncrement = (2 * Math.PI) / (4 * 32);\r\n//# sourceMappingURL=EllipseCurve.js.map","import { arrayFromFunction, arraySamples, assert, between, eq, eq0, firstUnsorted, getLast, hasConstructor, le, lerp, M4, max, MINUS, newtonIterateWithDerivative2, NLA_DEBUG, setLast, snap, snap0, V, V3, vArrGet, Vector, VV, withMax, } from \"ts3dutils\";\r\nimport { BezierCurve, Curve, EllipseCurve, HyperbolaCurve, L3, P3, ParabolaCurve, } from \"../index\";\r\nimport { abs, cos, cosh, PI, sin, sinh, sqrt, SQRT1_2 } from \"../math\";\r\n/**\r\n * Non-Uniform Rational B-Spline implementation.\r\n *\r\n * See https://pages.mtu.edu/~shene/COURSES/cs3621/NOTES/ for a good reference.\r\n *\r\n *\r\n */\r\nexport class NURBS extends Curve {\r\n constructor(\r\n /**\r\n * The control points of the NURBS curve, as 4D homogeneous coordinates.\r\n */\r\n points, \r\n /**\r\n * The degree of the NURBS curve. Must be at least 1 (linear).\r\n */\r\n degree, knots = NURBS.openUniformKnots(points.length, degree), tMin = knots[degree], tMax = knots[knots.length - degree - 1]) {\r\n super(tMin, tMax);\r\n this.points = points;\r\n this.degree = degree;\r\n this.knots = knots;\r\n const knotsLength = points.length + degree + 1;\r\n NLA_DEBUG && Object.freeze(points);\r\n NLA_DEBUG && Object.freeze(knots);\r\n assert(knots.length === knotsLength, \"bad knot vector length: expected \" +\r\n knotsLength +\r\n \" (degree = \" +\r\n degree +\r\n \" pcount = \" +\r\n points.length +\r\n \"), but was \" +\r\n knots.length);\r\n assert(knots[degree] <= tMin);\r\n assert(tMax <= knots[knots.length - degree - 1]);\r\n for (let i = 0; i < points.length; i++) {\r\n assert(points[i].dim() == 4);\r\n }\r\n assert(degree >= 1, \"degree must be at least 1 (linear)\");\r\n assert(degree % 1 == 0);\r\n assert(-1 == firstUnsorted(knots, MINUS), \"knot values must be in ascending order\");\r\n }\r\n getConstructorParameters() {\r\n return [this.points, this.degree, this.knots];\r\n }\r\n at4(t) {\r\n NLA_DEBUG &&\r\n assert(between(t, this.tMin, this.tMax), t + \" \" + this.tMin + \" \" + this.tMax);\r\n const { points, degree, knots } = this;\r\n // find s (the spline segment) for the [t] value provided\r\n const s = this.tInterval(t);\r\n const v = Vector.pack(points, new Float64Array((degree + 1) * 4), s - degree, 0, degree + 1);\r\n for (let level = 0; level < degree; level++) {\r\n // build level l of the pyramid\r\n for (let i = degree; i > level; i--) {\r\n const alpha = (t - knots[i + s - degree]) /\r\n (knots[i + s - level] - knots[i + s - degree]);\r\n // interpolate each component\r\n for (let dim = 0; dim < 4; dim++) {\r\n v[i * 4 + dim] =\r\n (1 - alpha) * v[(i - 1) * 4 + dim] + alpha * v[i * 4 + dim];\r\n }\r\n }\r\n }\r\n return new Vector(v.slice(degree * 4, (degree + 1) * 4));\r\n }\r\n at(t) {\r\n return this.at4(t).p3();\r\n }\r\n /**\r\n d(k, i, t) = a(i, k, t) * d(k - 1, i, t) + (1 - a(i, k, t)) * d(k - 1, i - 1, t)\r\n a(i, k, t) = (t - knots[i]) / (knots[i + 1 + n - k] - knots[i])\r\n a'(i, k, t) = 1 / (knots[i + 1 + n - k] - knots[i])\r\n \r\n d/dt = a(i, k, t) * d'(k - 1, i, t) + a'(i, k, t) * d(k - 1, i, t)\r\n + (1 - a(i, k, t)) * d'(k - 1, i - 1, t) + a'(i, k, t) * d(k - 1, i - 1, t)\r\n */\r\n ptDtDdt4(t) {\r\n const { points, degree, knots } = this;\r\n // find s (the spline segment) for the [t] value provided\r\n const s = this.tInterval(t);\r\n const v = Vector.pack(points, new Float64Array((degree + 1) * 4), s - degree, 0, degree + 1);\r\n let ddt = Vector.Zero(4);\r\n let derivative;\r\n for (let level = 0; level < degree; level++) {\r\n if (level == degree - 2) {\r\n // see https://www.globalspec.com/reference/61012/203279/10-8-derivatives\r\n const a = new Vector(v.slice(degree * 4, (degree + 1) * 4));\r\n const b = new Vector(v.slice((degree - 1) * 4, degree * 4));\r\n const c = new Vector(v.slice((degree - 2) * 4, (degree - 1) * 4));\r\n function step(k, i, dkMinus1iMinus1, dkMinus1i) {\r\n return dkMinus1i\r\n .minus(dkMinus1iMinus1)\r\n .times(k / (knots[i + degree - k] - knots[i - 1]));\r\n }\r\n ddt = step(degree, s + 1, step(degree - 1, s + 1, a, b), step(degree - 1, s, b, c));\r\n }\r\n if (level == degree - 1) {\r\n const a = new Vector(v.slice(degree * 4, (degree + 1) * 4));\r\n const b = new Vector(v.slice((degree - 1) * 4, degree * 4));\r\n derivative = b.minus(a).times(degree / (knots[s] - knots[s + 1]));\r\n }\r\n for (let i = degree; i > level; i--) {\r\n const alpha = (t - knots[i + s - degree]) /\r\n (knots[i + s - level] - knots[i + s - degree]);\r\n // interpolate each component\r\n for (let dim = 0; dim < 4; dim++) {\r\n v[i * 4 + dim] =\r\n (1 - alpha) * v[(i - 1) * 4 + dim] + alpha * v[i * 4 + dim];\r\n }\r\n }\r\n }\r\n const p = new Vector(v.slice(degree * 4, degree * 4 + 4));\r\n return [p, derivative, ddt];\r\n }\r\n tangentAt(t) {\r\n // x(t) = xw(t) / w(t)\r\n // quotient rule\r\n const [p, derivative] = this.ptDtDdt4(t);\r\n const expected = derivative\r\n .times(p.w)\r\n .minus(p.times(derivative.w))\r\n .div(Math.pow(p.w, 2))\r\n .V3();\r\n return expected;\r\n }\r\n ddt(t) {\r\n const [p, dt, ddt] = this.ptDtDdt4(t);\r\n // =(-w(t) x(t) w''(t) - 2 w(t) w'(t) x'(t) + 2 x(t) w'(t)^2 + w(t)^2 x''(t))/w(t)^3\r\n // =(x(t) ((-w(t)) w''(t) + 2 w'(t)^2) - x'(t) 2 w(t) w'(t) + x''(t) w(t)^2 )/w(t)^3\r\n // prettier-ignore\r\n return Vector.add(p.times(-p.w * ddt.w + 2 * Math.pow(dt.w, 2)), dt.times(-2 * p.w * dt.w), ddt.times(Math.pow(p.w, 2))).div(Math.pow(p.w, 3)).V3();\r\n }\r\n ptDtDdt(t) {\r\n const [pt, dt4, ddt4] = this.ptDtDdt4(t);\r\n return [\r\n pt.p3(),\r\n dt4\r\n .times(pt.w)\r\n .minus(pt.times(dt4.w))\r\n .div(Math.pow(pt.w, 2))\r\n .V3(),\r\n Vector.add(pt.times(-pt.w * ddt4.w + 2 * Math.pow(dt4.w, 2)), //\r\n dt4.times(-2 * pt.w * dt4.w), ddt4.times(Math.pow(pt.w, 2)))\r\n .div(Math.pow(pt.w, 3))\r\n .V3(),\r\n ];\r\n }\r\n pointT(pWC) {\r\n return this.closestTToPoint(pWC);\r\n }\r\n closestTToPoint(p, tStart, tMin = this.tMin, tMax = this.tMax) {\r\n // this.at(t) has minimal distance to p when this.tangentAt(t) is perpendicular to\r\n // the vector between this.at(t) and p. This is the case iff the dot product of the two is 0.\r\n // f = (this.at(t) - p) . (this.tangentAt(t)\r\n // df = this.tangentAt(t) . this.tangentAt(t) + (this.at(t) - p) . this.ddt(t)\r\n // = this.tangentAt(t)² + (this.at(t) - p) . this.ddt(t)\r\n const f = (t) => {\r\n const [pt, dt, ddt] = this.ptDtDdt(t);\r\n return [pt.minus(p).dot(dt), dt.squared() + pt.minus(p).dot(ddt)];\r\n };\r\n //checkDerivate(f, df, tMin, tMax)\r\n const STEPS = 32;\r\n if (undefined === tStart) {\r\n tStart = withMax(arraySamples(tMin, tMax, STEPS), (t) => -this.at(t).distanceTo(p));\r\n }\r\n const result = newtonIterateWithDerivative2(f, tStart, 8, this.tMin, this.tMax);\r\n //assert(undefined !== result)\r\n return result;\r\n }\r\n containsPoint(pWC) {\r\n const tGuess = this.closestTToPoint(pWC);\r\n return undefined === tGuess ? false : this.at(tGuess).like(pWC);\r\n }\r\n derivate() {\r\n const k = this.degree;\r\n const ps = arrayFromFunction(this.points.length - 1, (i) => this.points[i]\r\n .to(this.points[i + 1])\r\n .times(k / (this.knots[i + k + 1] - this.knots[i + 1])));\r\n return new NURBS(ps, this.degree - 1, this.knots.slice(1, -1), this.tMin, this.tMax);\r\n }\r\n /**\r\n * Create a new NURBS of equal degree with the added knot [newKnot]. New NURBS will have one additional control\r\n * point.\r\n */\r\n withKnot(newKnot) {\r\n assert(between(newKnot, this.tMin, this.tMax));\r\n const k = this.tInterval(newKnot);\r\n const { knots, points, degree } = this;\r\n const insertPoints = arrayFromFunction(this.degree, (j) => {\r\n const i = k - degree + 1 + j;\r\n const aiNumerator = newKnot - knots[i];\r\n // 0/0 defined as 0:\r\n const ai = aiNumerator == 0 ? 0 : aiNumerator / (knots[i + degree] - knots[i]);\r\n assert(between(ai, 0, 1));\r\n return Vector.lerp(points[i - 1], points[i], ai);\r\n });\r\n const newPoints = points.slice();\r\n newPoints.splice(k - degree + 1, degree - 1, ...insertPoints);\r\n const newKnots = knots.slice();\r\n newKnots.splice(k + 1, 0, newKnot);\r\n return new NURBS(newPoints, degree, newKnots, this.tMin, this.tMax);\r\n }\r\n removeKnot(t) {\r\n const { knots, points, degree } = this;\r\n let k = this.tInterval(t), s = 0; // s = multiplicity of the knot\r\n while (knots[k + 1] == t) {\r\n k++;\r\n s++;\r\n }\r\n if (s == 0)\r\n throw new Error(\"There is no knot \" + t + \"!\");\r\n // the points which were relevant when inserting were (k - p - 1) to (k - 1). (- 1) because the current k has\r\n // been increased by one due to the insertion.\r\n // p - 1 points were replaced by p points, hence we need to generate the original p - 1 point, + 1 to check if\r\n // this transformation is valid.\r\n const insertPoints = [points[k - degree - 1]];\r\n const oldKnots = knots.slice();\r\n oldKnots.splice(k, 1);\r\n for (let i = k - degree; i <= k - s; i++) {\r\n const alphaInv = (oldKnots[i + degree] - oldKnots[i]) / (t - oldKnots[i]);\r\n const oldPoint = Vector.lerp(getLast(insertPoints), points[i], alphaInv);\r\n insertPoints.push(oldPoint);\r\n }\r\n if (getLast(insertPoints).like(points[k + 1 - s])) {\r\n const oldPoints = points.slice();\r\n oldPoints.splice(k - degree - 1, degree - s + 3, ...insertPoints);\r\n return new NURBS(oldPoints, degree, oldKnots);\r\n }\r\n return undefined;\r\n }\r\n static openUniformKnots(pointCount, degree, tMin = 0, tMax = 1) {\r\n const knotsLength = pointCount + degree + 1;\r\n return arrayFromFunction(knotsLength, (i) => {\r\n if (i <= degree) {\r\n return tMin;\r\n }\r\n else if (i >= knotsLength - degree - 1) {\r\n return tMax;\r\n }\r\n else {\r\n return lerp(tMin, tMax, (i - degree) / (knotsLength - degree * 2 - 1));\r\n }\r\n });\r\n }\r\n static bezierKnots(degree, tMin = 0, tMax = 1) {\r\n const result = new Array((degree + 1) * 2);\r\n for (let i = 0; i < degree + 1; i++) {\r\n result[i] = tMin;\r\n result[degree + 1 + i] = tMax;\r\n }\r\n return result;\r\n }\r\n static fromBezier(bezier) {\r\n const bezier01 = bezier.selectPart(bezier.tMin, bezier.tMax);\r\n return NURBS.Bezier(bezier01.points);\r\n }\r\n static Bezier(points, tMin = 0, tMax = 1) {\r\n return new NURBS(points.map((p) => p instanceof V3 ? new Vector(new Float64Array([p.x, p.y, p.z, 1])) : p), points.length - 1, arrayFromFunction(points.length * 2, (i) => (i < points.length ? 0 : 1)), tMin, tMax);\r\n }\r\n static fromHyperbola(hyperbola, tMin = hyperbola.tMin, tMax = hyperbola.tMax) {\r\n const p0 = HyperbolaCurve.XY.at(tMin);\r\n const p2 = HyperbolaCurve.XY.at(tMax);\r\n const p1 = new V3((sinh(tMin) - sinh(tMax)) / sinh(tMin - tMax), (cosh(tMin) - cosh(tMax)) / sinh(tMin - tMax), 0);\r\n // M: midpoint between p0 and p2\r\n // X: intersection of line through p1 and M and unit hyperbola\r\n // result.at(1/2) = X\r\n // result.at(1/2) = (1/4 p0 + 1/2 p1 w + 1/4 p2) / (1/4 + 1/ 2 w + 1/4)\r\n // result.at(1/2) = (1/2 p0 + p1 w + 1/2 p2) / (1 + w)\r\n // result.at(1/2) = (M + p1 w) / (1 + w) = X\r\n // => w * (p1 - X) = (X - M)\r\n // as p1, X and M are all on the same line, we can solve this equation with only the x\r\n const M = p0.lerp(p2, 0.5);\r\n const Xx = 1 / sqrt(1 - Math.pow((M.y / M.x), 2));\r\n const w = (Xx - M.x) / (p1.x - Xx);\r\n return NURBS.fromV3s([p0, p1, p2], 2, undefined, [1, w, 1]).transform(hyperbola.matrix);\r\n }\r\n static fromParabola(parabola) {\r\n return NURBS.fromBezier(parabola.asBezier());\r\n }\r\n static fromEllipse(ellipse) {\r\n const unitSemiEllipse = new NURBS([\r\n VV(1, 0, 0, 1),\r\n VV(1, 1, 0, 1).times(SQRT1_2),\r\n VV(0, 1, 0, 1),\r\n VV(-1, 1, 0, 1).times(SQRT1_2),\r\n VV(-1, 0, 0, 1),\r\n VV(-1, -1, 0, 1).times(SQRT1_2),\r\n VV(0, -1, 0, 1),\r\n ], 2, [0, 0, 0, PI / 2, PI / 2, PI, PI, (3 * PI) / 2, (3 * PI) / 2, 2 * PI]);\r\n return unitSemiEllipse.transform(ellipse.matrix);\r\n }\r\n /**\r\n * Create a new NURBS from V3s, with optional weights.\r\n * @param points\r\n * @param degree\r\n * @param knots\r\n * @param weights\r\n */\r\n static fromV3s(points, degree, knots, weights = arrayFromFunction(points.length, () => 1)) {\r\n assert(points.length == weights.length);\r\n return new NURBS(points.map((p, i) => Vector.fromV3AndWeight(p, weights[i])), degree, knots);\r\n }\r\n isUniform(precision = 0) {\r\n const intervals = arrayFromFunction(this.knots.length - 1, (i) => this.knots[i + 1] - this.knots[i]);\r\n const [min, max] = minAndMax(intervals);\r\n return eq(min, max, precision);\r\n }\r\n /**\r\n * NURBS is a B spline if control points all have the same weight.\r\n */\r\n isBSpline(precision = 0) {\r\n const [minWeight, maxWeight] = minAndMax(this.points.map((p) => p.w));\r\n return eq(minWeight, maxWeight, precision);\r\n }\r\n /**\r\n * Whether this is a (rational) bezier curve.\r\n */\r\n isBezier(precision = 0) {\r\n if (this.degree + 1 != this.points.length)\r\n return false;\r\n const [min0, max0] = minAndMax(this.knots, 0, this.degree + 1);\r\n if (!eq(min0, max0, precision))\r\n return false;\r\n const [min1, max1] = minAndMax(this.knots, this.degree + 1);\r\n if (!eq(min1, max1, precision))\r\n return false;\r\n return true;\r\n }\r\n /**\r\n * Splits NURBS curve into rational bezier curves.\r\n * See https://pages.mtu.edu/~shene/COURSES/cs3621/NOTES/spline/B-spline/subdivision.html\r\n */\r\n getSegments() {\r\n const { knots, points, degree } = this;\r\n const result = [];\r\n const v = Vector.pack(points, new Float64Array(points.length * 4));\r\n const vectorFromV = (i) => new Vector(v.slice(i * 4, (i + 1) * 4));\r\n let k = degree + 1; // k = knot index we are duplicating\r\n while (k < knots.length - degree - 1) {\r\n const t = knots[k];\r\n const prevKnot = knots[k - 1];\r\n let s = 1; // s = multiplicity of the knot\r\n while (knots[k + 1] == t) {\r\n k++;\r\n s++;\r\n }\r\n const newNURBSPoints = new Array(degree + 1);\r\n // the first s + 1 points are identical to the current curve\r\n for (let i = 0; i < s + 1; i++) {\r\n newNURBSPoints[i] = vectorFromV(k - degree - s + i);\r\n }\r\n // we need to have multiplicity degree, so insert (degree - s) times\r\n for (let level = 1; level <= degree - s; level++) {\r\n for (let i = k - degree; i <= k - s - level; i++) {\r\n const alpha = (t - prevKnot) / (knots[i + degree + 1] - prevKnot);\r\n for (let dim = 0; dim < 4; dim++) {\r\n v[i * 4 + dim] =\r\n (1 - alpha) * v[i * 4 + dim] + alpha * v[(i + 1) * 4 + dim];\r\n }\r\n }\r\n newNURBSPoints[s + level] = vectorFromV(k - degree);\r\n }\r\n const newNURBSKnots = arrayFromFunction((degree + 1) * 2, (i) => i < degree + 1 ? knots[k - s] : t);\r\n result.push(new NURBS(newNURBSPoints, degree, newNURBSKnots));\r\n k++;\r\n }\r\n // last curve\r\n const newNURBSPoints = arrayFromFunction(degree + 1, (i) => vectorFromV(points.length - degree - 1 + i));\r\n const newNURBSKnots = arrayFromFunction((degree + 1) * 2, (i) => i < degree + 1 ? knots[k - 1] : knots[k]);\r\n result.push(new NURBS(newNURBSPoints, degree, newNURBSKnots));\r\n return result;\r\n }\r\n split(t) {\r\n const { knots, points, degree } = this;\r\n assert(le(this.tMin, t) && le(t, this.tMax));\r\n let k = this.tInterval(t), s = 0; // s = multiplicity of the knot\r\n while (knots[k + 1] == t) {\r\n k++;\r\n s++;\r\n }\r\n const vectorFromV = (i) => new Vector(v.slice(i * 4, (i + 1) * 4));\r\n const leftPoints = new Array(k + 1 - s);\r\n // the first k + s + 1 points are identical to the current curve\r\n for (let i = 0; i < k + s - degree + 1; i++) {\r\n leftPoints[i] = this.points[i];\r\n }\r\n const rightPointsLength = points.length - (k - degree);\r\n const v = Vector.pack(points, new Float64Array(rightPointsLength * 4), k - degree);\r\n // we need to have multiplicity degree, so insert (degree - s) times\r\n for (let level = 1; level <= degree - s; level++) {\r\n for (let i = k - degree; i <= k - s - level; i++) {\r\n const alpha = (t - knots[i + level]) / (knots[i + degree + 1] - knots[i + level]);\r\n const j = i - (k - degree);\r\n for (let dim = 0; dim < 4; dim++) {\r\n v[j * 4 + dim] =\r\n (1 - alpha) * v[j * 4 + dim] + alpha * v[(j + 1) * 4 + dim];\r\n }\r\n }\r\n leftPoints[k - degree + level] = vectorFromV(0);\r\n }\r\n const leftKnots = knots.slice(0, k + degree + 2 - s);\r\n for (let i = 0; i < degree - s + 1; i++) {\r\n leftKnots[k - s + 1 + i] = t;\r\n }\r\n const rightKnots = knots.slice(k - degree);\r\n for (let i = 0; i < degree + 1; i++) {\r\n rightKnots[i] = t;\r\n }\r\n const rightPoints = arrayFromFunction(rightPointsLength, (i) => vArrGet(v, 4, i));\r\n return [\r\n new NURBS(leftPoints, degree, leftKnots),\r\n new NURBS(rightPoints, degree, rightKnots),\r\n ];\r\n }\r\n simplify() {\r\n assert(this.isBezier());\r\n if (3 == this.degree && this.isBSpline()) {\r\n return new BezierCurve(this.points[0].p3(), this.points[1].p3(), this.points[2].p3(), this.points[3].p3(), this.tMin, this.tMax);\r\n }\r\n else if (2 == this.degree) {\r\n const [P0, P1, P2] = this.points;\r\n const [p0, p1, p2] = this.points.map((p) => p.p3());\r\n const c = NURBS.simplifyUnit2(P0.w, P1.w, P2.w).transform(M4.forSys(p1.to(p0), p1.to(p2), undefined, p1));\r\n const [tMin, tMax] = [c.pointT(p0), c.pointT(p2)].sort();\r\n return c.withBounds(snap(tMin, c.tMin), snap(tMax, c.tMax));\r\n }\r\n else if (1 == this.degree) {\r\n return L3.throughPoints(this.points[0].p3(), this.points[1].p3());\r\n }\r\n else {\r\n return this;\r\n }\r\n }\r\n static simplifyUnit2(w0, w1, w2) {\r\n // see https://math.stackexchange.com/a/2794874/230980\r\n const delta = w0 * w2 - Math.pow(w1, 2);\r\n const cxy = (w0 * w2) / 2 / delta;\r\n const center = new V3(cxy, cxy, 0);\r\n const k = (Math.pow(w1, 2) + delta - 2 * w1 * sqrt(abs(delta))) / 2 / delta;\r\n const p = V3.X;\r\n const q = new V3(k, cxy, 0);\r\n // const q = new V3(cxy, k, 0)\r\n if (eq0(delta)) {\r\n return new ParabolaCurve(new V3(1 / 4, 1 / 4, 0), new V3(1, -1, 0), new V3(1, 1, 0), -0.5, 0.5);\r\n }\r\n else if (delta < 0) {\r\n // hyperbola\r\n return new HyperbolaCurve(center, center.to(p), center.to(q));\r\n }\r\n else {\r\n // ellipse\r\n return new EllipseCurve(center, center.to(p), center.to(q), 0);\r\n }\r\n }\r\n elevateDegreeBezier() {\r\n assert(this.isBezier());\r\n const newPoints = new Array(this.points.length + 1);\r\n newPoints[0] = this.points[0];\r\n newPoints[this.points.length] = this.points[this.points.length - 1];\r\n for (let i = 1; i < this.points.length; i++) {\r\n newPoints[i] = Vector.lerp(this.points[i], this.points[i - 1], i / (this.degree + 1));\r\n }\r\n const newKnots = NURBS.bezierKnots(this.degree + 1, this.knots[0], this.knots[this.degree + 1]);\r\n return new NURBS(newPoints, this.degree + 1, newKnots, this.tMin, this.tMax);\r\n }\r\n elevateDegree() {\r\n const segmentsElevated = this.getSegments().map((b) => b.elevateDegreeBezier());\r\n // stitch together the segments\r\n const newPoints = new Array(2 + segmentsElevated.length * this.degree);\r\n newPoints[0] = segmentsElevated[0].points[0];\r\n setLast(newPoints, getLast(getLast(segmentsElevated).points));\r\n for (let i = 0; i < segmentsElevated.length; i++) {\r\n for (let pi = 1; pi < segmentsElevated[i].points.length - 1; pi++) {\r\n newPoints[i * (segmentsElevated[0].points.length - 2) + pi] =\r\n segmentsElevated[i].points[pi];\r\n }\r\n }\r\n const newKnots = new Array(newPoints.length + this.degree + 2);\r\n for (let i = 0; i < this.degree + 2; i++) {\r\n newKnots[i] = this.knots[0];\r\n }\r\n for (let i = 0; i < segmentsElevated.length; i++) {\r\n for (let pi = 1; pi < segmentsElevated[i].points.length - 1; pi++) {\r\n newKnots[i * (segmentsElevated[0].points.length - 2) + pi + this.degree + 1] = getLast(segmentsElevated[i].knots);\r\n }\r\n }\r\n newKnots[newKnots.length - 1] = getLast(this.knots);\r\n newKnots[newKnots.length - 2] = getLast(this.knots);\r\n let result = new NURBS(newPoints, this.degree + 1, newKnots, this.tMin, this.tMax);\r\n for (let i = 0; i < segmentsElevated.length - 1; i++) {\r\n let optimization;\r\n while ((optimization = result.removeKnot(getLast(segmentsElevated[i].knots)))) {\r\n result = optimization;\r\n }\r\n }\r\n return result;\r\n }\r\n transform(m4) {\r\n return this.transform4(m4);\r\n }\r\n transform4(m4) {\r\n return new NURBS(this.points.map((p) => m4.timesVector(p)), this.degree, this.knots, this.tMin, this.tMax);\r\n }\r\n /**\r\n * Returns the index of the interval which contains the value t.\r\n */\r\n tInterval(t) {\r\n const { degree, knots } = this;\r\n for (let s = degree; s < knots.length - 1 - degree; s++) {\r\n if (t >= knots[s] && t <= knots[s + 1]) {\r\n return s;\r\n }\r\n }\r\n throw new Error(t + \" \" + knots);\r\n }\r\n static UnitCircle(sections = 2, tMin = 0, tMax = PI) {\r\n const dt = tMax - tMin;\r\n const tStep = dt / sections;\r\n const w = sin(PI / 2 - tStep / 2);\r\n // cos\r\n const r = 1 / cos(tStep / 2);\r\n const points = arrayFromFunction(sections * 2 + 1, (i) => {\r\n const t = lerp(tMin, tMax, i / 2 / sections);\r\n if (i % 2 == 0) {\r\n // control point on circle\r\n return VV(cos(t), sin(t), 0, 1);\r\n }\r\n else {\r\n return VV(r * w * cos(t), r * w * sin(t), 0, w);\r\n }\r\n });\r\n const knots = [];\r\n knots.push(tMin, tMin, tMin);\r\n for (let i = 0; i < sections - 1; i++) {\r\n const knot = lerp(tMin, tMax, (i + 1) / sections);\r\n knots.push(knot, knot);\r\n }\r\n knots.push(tMax, tMax, tMax);\r\n return new NURBS(points, 2, knots);\r\n }\r\n debugInfo() {\r\n return {\r\n points: [\r\n ...this.knots.slice(this.degree, -this.degree).map((t) => this.at(t)),\r\n ...this.points.map((p) => p.p3()),\r\n ],\r\n lines: this.points.flatMap((p, i, ps) => ps[i + 1] ? [p.p3(), ps[i + 1].p3()] : []),\r\n };\r\n }\r\n isTsWithPlane(planeWC) {\r\n const { knots, degree, points } = this;\r\n const controlPointTs = [\r\n knots[degree],\r\n ...points\r\n .slice(1, -1)\r\n .map((p, i) => this.closestTToPoint(p.p3(), undefined, knots[i + 3], knots[i + degree])),\r\n knots[knots.length - degree - 1],\r\n ];\r\n const result = [];\r\n for (let i = 0; i < this.points.length - 1; i++) {\r\n const findClosest = (startT) => {\r\n console.log(\"startT\", startT);\r\n // try {\r\n const f = (t) => {\r\n const [p, dt] = this.ptDtDdt(t);\r\n return [planeWC.distanceToPointSigned(p), planeWC.normal1.dot(dt)];\r\n };\r\n let t = newtonIterateWithDerivative2(f, startT, 8, this.tMin, this.tMax);\r\n let [distanceAtT, distanceDtAtT] = undefined === t ? [undefined, undefined] : f(t);\r\n if (t === undefined || !eq0(distanceAtT) || eq0(distanceDtAtT)) {\r\n t = newtonIterateWithDerivative2((t) => {\r\n const [, dt, ddt] = this.ptDtDdt(t);\r\n return [planeWC.normal1.dot(dt), planeWC.normal1.dot(ddt)];\r\n }, startT, 8, this.tMin, this.tMax);\r\n }\r\n ;\r\n [distanceAtT, distanceDtAtT] = undefined === t ? [] : f(t);\r\n if (undefined !== t &&\r\n eq0(distanceAtT) &&\r\n !result.some((r) => eq(r, t))) {\r\n result.push(t);\r\n }\r\n };\r\n const a = this.points[i].p3();\r\n const b = this.points[i + 1].p3();\r\n const ad = snap0(planeWC.distanceToPointSigned(a));\r\n const bd = snap0(planeWC.distanceToPointSigned(b));\r\n if (ad * bd < 0) {\r\n const startT = lerp(controlPointTs[i], controlPointTs[i + 1], ad / (ad - bd));\r\n findClosest(startT);\r\n }\r\n else if (0 == bd) {\r\n findClosest(this.closestTToPoint(b, controlPointTs[i + 1]));\r\n }\r\n }\r\n return result;\r\n }\r\n isInfosWithCurve(curveWC) {\r\n if (curveWC instanceof L3) {\r\n return this.isInfosWithLine(curveWC.anchor, curveWC.dir1);\r\n }\r\n return super.isInfosWithCurve(curveWC);\r\n }\r\n isInfosWithLine(anchor, dir) {\r\n const thisPlane = P3.fromPoints(this.points.map((p) => p.p3()));\r\n const l = L3.anchorDirection(anchor, dir);\r\n const maxDistanceToPlane = max(this.points.map((p) => thisPlane.distanceToPoint(p.p3())));\r\n const thisIsPlanar = eq0(maxDistanceToPlane);\r\n if (thisIsPlanar && !thisPlane.containsLine(l)) {\r\n const [t] = l.isTsWithPlane(thisPlane);\r\n if (undefined === t)\r\n return [];\r\n const p = l.at(t);\r\n return this.containsPoint(p)\r\n ? [{ tThis: this.pointT(p), tOther: L3.pointT(anchor, dir, p), p }]\r\n : [];\r\n }\r\n else {\r\n const thisTs = this.isTsWithPlane(P3.normalOnAnchor(thisPlane.normal1.cross(dir), anchor));\r\n const infos = thisTs.map((tThis) => {\r\n const p = this.at(tThis);\r\n return { tThis, tOther: L3.pointT(anchor, dir, p), p };\r\n });\r\n return thisIsPlanar\r\n ? infos\r\n : infos.filter((info) => L3.containsPoint(anchor, dir, info.p));\r\n }\r\n }\r\n roots() {\r\n console.log(this.tMin, this.tMax);\r\n arraySamples(this.tMin, this.tMax, 30).forEach((t) => {\r\n console.log(t + \",\" + this.tangentAt(t).z);\r\n });\r\n const result = [[], [], []];\r\n for (let i = 0; i < this.points.length - 1; i++) {\r\n const findClosest = (startT, d) => {\r\n console.log(\"d\", d, \"startT\", startT);\r\n // try {\r\n const root = newtonIterateWithDerivative2((t) => {\r\n const [, dt, ddt] = this.ptDtDdt(t);\r\n return [dt.e(d), ddt.e(d)];\r\n }, startT, 8, this.tMin, this.tMax);\r\n if (undefined !== root) {\r\n result[d].push(root);\r\n }\r\n console.log(\"d\", d, \"startT\", startT, \"root\", root);\r\n };\r\n const a = this.points[i].p3();\r\n const b = this.points[i + 1].p3();\r\n const ab = a.to(b);\r\n for (let d = 0; d < 3; d++) {\r\n if (0 !== i && eq0(ab.e(d))) {\r\n const startT = lerp(this.knots[i], this.knots[i + this.degree + 2], 0.5);\r\n findClosest(startT, d);\r\n }\r\n else if (i < this.points.length - 2) {\r\n const bc = b.to(this.points[i + 2].p3());\r\n if (!eq0(bc.e(d)) && ab.e(d) * bc.e(d) < 0) {\r\n findClosest(this.closestTToPoint(b, this.guessTClosestToControlPoint(i + 1)), d);\r\n }\r\n }\r\n }\r\n }\r\n console.log(result);\r\n return result;\r\n }\r\n //getAABB() {\r\n //\treturn new AABB().addPoints(this.points.map(p => p.p3()))\r\n //}\r\n /**\r\n * Rough approximation of t param for points closest to control point.\r\n */\r\n guessTClosestToControlPoint(pointIndex) {\r\n return lerp(this.knots[pointIndex], this.knots[pointIndex + this.degree + 1], 0.5);\r\n }\r\n likeCurve(curve) {\r\n return (this == curve ||\r\n (hasConstructor(curve, NURBS) &&\r\n this.degree === curve.degree &&\r\n this.points.every((p, i) => p.like(curve.points[i])) &&\r\n this.knots.every((k, i) => eq(k, curve.knots[i]))));\r\n }\r\n isColinearTo(curve) {\r\n throw new Error(\"This doesn't even make sense.\");\r\n }\r\n}\r\nNURBS.EX2D = NURBS.fromV3s([\r\n V(51, 141),\r\n V(11, 76),\r\n V(29, 32),\r\n V(46, 102),\r\n V(74, 148),\r\n V(189, 107),\r\n V(56, 10),\r\n V(206, 10),\r\n V(211, 98),\r\n V(195, 141),\r\n V(139, 148),\r\n], 4);\r\nNURBS.EX3D = new NURBS([\r\n VV(94, 0, -34, 1),\r\n VV(69, 57, 45, 0.5),\r\n VV(-20, 44, 91, 1),\r\n VV(-89, -13, 47, 0.5),\r\n VV(-56, -97, -7, 1),\r\n VV(34, -83, -54, 0.5),\r\n VV(112, -53, 16, 1),\r\n VV(79, 30, 70, 0.5),\r\n VV(-2, -9, 141, 1),\r\n VV(-80, -40, 72, 0.5),\r\n VV(-38, -150, 43, 1),\r\n VV(43, -110, -29, 0.5),\r\n VV(130, -106, 65, 1),\r\n], 2, [-12, -12, -12, -8, -8, -4, -4, 0, 0, 4, 4, 8, 8, 12, 12, 12]);\r\nNURBS.prototype.tIncrement = 1 / 128;\r\nfunction minAndMax(arr, start = 0, end = arr.length) {\r\n let min = Infinity, max = -Infinity;\r\n for (let i = start; i < end; i++) {\r\n if (min > arr[i])\r\n min = arr[i];\r\n if (max < arr[i])\r\n max = arr[i];\r\n }\r\n return [min, max];\r\n}\r\n//# sourceMappingURL=NURBS.js.map","import { assert, assertInst, assertNumbers, assertVectors, callsce, eq, eq0, floatHashCode, hasConstructor, M4, Transformable, V3, VV, } from \"ts3dutils\";\r\nimport { BezierCurve, EllipseCurve, HyperbolaCurve, L3, ParabolaCurve, } from \".\";\r\n/**\r\n * Plane x DOT this.normal1 = this.w\r\n */\r\nexport class P3 extends Transformable {\r\n /**\r\n * Oriented plane, i.e. splits R^3 in half, with one half being \"in front\" of the plane.\r\n * Leads to multiple comparisons: isCoplanarToPlane returns if the plane occupies the same space,\r\n * like returns if the plane occupies the same space and has the same orientation\r\n *\r\n * Points x on the plane fulfill the equation: normal1 DOT x = w\r\n *\r\n * @param normal1 unit plane normal1\r\n * @param w signed (rel to normal1) distance from the origin\r\n */\r\n constructor(normal1, w = 0) {\r\n super();\r\n this.normal1 = normal1;\r\n this.w = w;\r\n assertVectors(normal1);\r\n assertNumbers(w);\r\n assert(normal1.hasLength(1), \"normal1.hasLength(1)\" + normal1);\r\n }\r\n get anchor() {\r\n return this.normal1.times(this.w);\r\n }\r\n static throughPoints(a, b, c) {\r\n assertVectors(a, b, c);\r\n const n1 = b.minus(a).cross(c.minus(a)).unit();\r\n return new P3(n1, n1.dot(a));\r\n }\r\n static normalOnAnchor(normal, anchor) {\r\n assertVectors(normal, anchor);\r\n const n1 = normal.unit();\r\n return new this(n1, n1.dot(anchor));\r\n }\r\n /**\r\n * Create a plane which intersects the X, Y and Z axes at the specified offsets.\r\n * x/x0 + y/y0 + y/y0 = 1\r\n */\r\n static forAxisIntercepts(x0, y0, z0) {\r\n assertNumbers(x0, y0, z0);\r\n const normal = new V3(1 / x0, 1 / y0, 1 / z0);\r\n return new P3(normal.unit(), normal.length());\r\n }\r\n /**\r\n * Create a plane containing `anchor` and extending in directions `v0` and `v1`.\r\n * `v0` and `v1` may not be parallel.\r\n * @param anchor\r\n * @param v0\r\n * @param v1\r\n */\r\n static forAnchorAndPlaneVectors(anchor, v0, v1) {\r\n assertVectors(anchor, v0, v1);\r\n assert(!v0.isParallelTo(v1));\r\n return this.normalOnAnchor(v0.cross(v1), anchor);\r\n }\r\n /**\r\n * Create a plane which contains botha point and a line. The point may not lie on the line.\r\n * @param p\r\n * @param line\r\n */\r\n static forPointAndLine(p, line) {\r\n return this.forAnchorAndPlaneVectors(line.anchor, line.dir1, line.anchor.to(p));\r\n }\r\n /**\r\n * ax + by + cz + d = 0\r\n */\r\n static forABCD(a, b, c, d) {\r\n const normalLength = Math.hypot(a, b, c);\r\n if (eq0(normalLength))\r\n return undefined;\r\n return new P3(new V3(a / normalLength, b / normalLength, c / normalLength), -d / normalLength);\r\n }\r\n static vanishingPlane(m4) {\r\n return P3.forABCD(m4.m[12], m4.m[13], m4.m[14], m4.m[15]);\r\n }\r\n static forAABB(aabb, distance = 0) {\r\n return [\r\n new P3(V3.X, aabb.max.x + distance),\r\n new P3(V3.X.negated(), -aabb.min.x - distance),\r\n new P3(V3.Y, aabb.max.y + distance),\r\n new P3(V3.Y.negated(), -aabb.min.y - distance),\r\n new P3(V3.Z, aabb.max.z + distance),\r\n new P3(V3.Z.negated(), -aabb.min.z - distance),\r\n ];\r\n }\r\n // Fit a plane to a collection of points.\r\n // Fast, and accurate to within a few degrees.\r\n // Returns None if the points do not span a plane.\r\n static fromPoints(points) {\r\n const n = points.length;\r\n if (n < 3) {\r\n return undefined;\r\n }\r\n const centroid = V3.add(...points).div(n);\r\n // Calculate full 3x3 covariance matrix, excluding symmetries:\r\n let xx = 0.0;\r\n let xy = 0.0;\r\n let xz = 0.0;\r\n let yy = 0.0;\r\n let yz = 0.0;\r\n let zz = 0.0;\r\n for (const p of points) {\r\n const r = p.minus(centroid);\r\n xx += r.x * r.x;\r\n xy += r.x * r.y;\r\n xz += r.x * r.z;\r\n yy += r.y * r.y;\r\n yz += r.y * r.z;\r\n zz += r.z * r.z;\r\n }\r\n xx /= n;\r\n xy /= n;\r\n xz /= n;\r\n yy /= n;\r\n yz /= n;\r\n zz /= n;\r\n let weighted_dir = V3.O;\r\n {\r\n const det_x = yy * zz - yz * yz;\r\n const axis_dir = new V3(det_x, xz * yz - xy * zz, xy * yz - xz * yy);\r\n let weight = det_x * det_x;\r\n if (weighted_dir.dot(axis_dir) < 0.0) {\r\n weight = -weight;\r\n }\r\n weighted_dir = weighted_dir.plus(axis_dir.times(weight));\r\n }\r\n {\r\n const det_y = xx * zz - xz * xz;\r\n const axis_dir = new V3(xz * yz - xy * zz, det_y, xy * xz - yz * xx);\r\n let weight = det_y * det_y;\r\n if (weighted_dir.dot(axis_dir) < 0.0) {\r\n weight = -weight;\r\n }\r\n weighted_dir = weighted_dir.plus(axis_dir.times(weight));\r\n }\r\n {\r\n const det_z = xx * yy - xy * xy;\r\n const axis_dir = new V3(xy * yz - xz * yy, xy * xz - yz * xx, det_z);\r\n let weight = det_z * det_z;\r\n if (weighted_dir.dot(axis_dir) < 0.0) {\r\n weight = -weight;\r\n }\r\n weighted_dir = weighted_dir.plus(axis_dir.times(weight));\r\n }\r\n const normal = weighted_dir.unit();\r\n return P3.normalOnAnchor(normal, centroid);\r\n }\r\n axisIntercepts() {\r\n const w = this.w, n = this.normal1;\r\n return new V3(w / n.x, w / n.y, w / n.z);\r\n }\r\n isCoplanarToPlane(plane) {\r\n assertInst(P3, plane);\r\n return this.like(plane) || this.likeFlipped(plane);\r\n }\r\n like(plane) {\r\n assertInst(P3, plane);\r\n return eq(this.w, plane.w) && this.normal1.like(plane.normal1);\r\n }\r\n likeFlipped(plane) {\r\n assertInst(P3, plane);\r\n return eq(this.w, -plane.w) && this.normal1.like(plane.normal1.negated());\r\n }\r\n /**\r\n * True iff plane.normal1 is equal to this.normal1 or it's negation.\r\n *\r\n */\r\n isParallelToPlane(plane) {\r\n assertInst(P3, plane);\r\n return eq(1, Math.abs(this.normal1.dot(plane.normal1)));\r\n }\r\n isParallelToLine(line) {\r\n assertInst(L3, line);\r\n return eq0(this.normal1.dot(line.dir1));\r\n }\r\n isPerpendicularToLine(line) {\r\n assertInst(L3, line);\r\n // this.normal1 || line.dir1\r\n return eq(1, Math.abs(this.normal1.dot(line.dir1)));\r\n }\r\n isPerpendicularToPlane(plane) {\r\n assertInst(P3, plane);\r\n return eq0(this.normal1.dot(plane.normal1));\r\n }\r\n toSource() {\r\n return callsce(\"new P3\", this.normal1, this.w);\r\n }\r\n translated(offset) {\r\n return new P3(this.normal1, this.w + offset.dot(this.normal1));\r\n }\r\n transform(m4) {\r\n // See https://stackoverflow.com/questions/7685495/transforming-a-3d-plane-using-a-4x4-matrix\r\n // See http://www.songho.ca/opengl/gl_normaltransform.html\r\n // with homogeneous coordinates, the hessian normal form of this plane is\r\n // (p, 1) * (normal1, -w) = 0\r\n // transformation: (m4^-1 * (p, 1)) DOT (normal1, -w) = 0\r\n // => (p, 1) DOT ((m4^-T) * (normal1, -w)) = 0\r\n // (validity of the above transformation is easily seen by expanding the matrix multiplication and dot product)\r\n // hence, (newNormal, newW) = (m4^-T) * (normal1, -w)\r\n // we divide both newNormal and newW by newNormal.length() to normalize the normal vector\r\n const m4InversedTransposed = M4.transpose(M4.inverse(m4, M4.temp0), M4.temp1);\r\n const [nx, ny, nz] = this.normal1;\r\n const newNormal = m4InversedTransposed.timesVector(VV(nx, ny, nz, -this.w));\r\n return P3.forABCD(newNormal.x, newNormal.y, newNormal.z, newNormal.w);\r\n }\r\n distanceToLine(line) {\r\n assertInst(L3, line);\r\n if (!this.isParallelToLine(line)) {\r\n return this.distanceToPoint(line.anchor);\r\n }\r\n else {\r\n return 0;\r\n }\r\n }\r\n containsPoint(x) {\r\n assertVectors(x);\r\n return eq(this.w, this.normal1.dot(x));\r\n }\r\n containsLine(line) {\r\n assertInst(L3, line);\r\n return this.containsPoint(line.anchor) && this.isParallelToLine(line);\r\n }\r\n distanceToPointSigned(point) {\r\n assertInst(V3, point);\r\n return this.normal1.dot(point) - this.w;\r\n }\r\n distanceToPoint(point) {\r\n assertInst(V3, point);\r\n return Math.abs(this.normal1.dot(point) - this.w);\r\n }\r\n intersectionWithLine(line) {\r\n return line.intersectionWithPlane(this);\r\n }\r\n intersectionWithPlane(plane) {\r\n assertInst(P3, plane);\r\n /*\r\n \r\n this: n0 * x = w0\r\n plane: n1 * x = w1\r\n plane perpendicular to both which goes through origin:\r\n n2 := n0 X x1\r\n n2 * x = 0\r\n */\r\n if (this.isParallelToPlane(plane)) {\r\n return undefined;\r\n }\r\n /*\r\n var n0 = this.normal1, n1 = plane.normal1, n2 = n0.cross(n1).unit(), m = M4.forSys(n0, n1, n2)\r\n var x0 = this.anchor, x1 = plane.anchor, x2 = V3.O\r\n var p = n2.times(x2.dot(n2))\r\n .plus(n1.cross(n2).times(x0.dot(n0)))\r\n .plus(n2.cross(n0).times(x1.dot(n1)))\r\n .div(m.determinant())\r\n */\r\n const n0 = this.normal1, n1 = plane.normal1, n2 = n0.cross(n1).unit();\r\n const p = M4.forRows(n0, n1, n2)\r\n .inversed()\r\n .transformVector(new V3(this.w, plane.w, 0));\r\n return new L3(p, n2);\r\n }\r\n /**\r\n * Returns the point in the plane closest to the given point\r\n *\r\n */\r\n projectedPoint(x) {\r\n // See http://math.stackexchange.com/questions/444968/project-a-point-in-3d-on-a-given-plane\r\n // p = x - ((x - planeAnchor) * normal1) * normal1\r\n return x.minus(this.normal1.times(x.minus(this.anchor).dot(this.normal1)));\r\n }\r\n projectedVector(x) {\r\n // See V3.rejectedFrom. Simplified, as this.normal1.length() == 1\r\n return x.minus(this.normal1.times(x.dot(this.normal1)));\r\n }\r\n flipped() {\r\n return new P3(this.normal1.negated(), -this.w);\r\n }\r\n containsCurve(curve) {\r\n if (curve instanceof L3) {\r\n return this.containsLine(curve);\r\n }\r\n else if (curve instanceof EllipseCurve ||\r\n curve instanceof HyperbolaCurve ||\r\n curve instanceof ParabolaCurve) {\r\n return (this.containsPoint(curve.center) &&\r\n this.normal1.isParallelTo(curve.normal));\r\n }\r\n else if (curve instanceof BezierCurve) {\r\n return curve.points.every((p) => this.containsPoint(p));\r\n }\r\n else {\r\n throw new Error(\"\" + curve);\r\n }\r\n }\r\n equals(obj) {\r\n return (hasConstructor(obj, P3) &&\r\n this.normal1.equals(obj.normal1) &&\r\n this.w == obj.w);\r\n }\r\n hashCode() {\r\n return (this.normal1.hashCode() * 31) | (0 + floatHashCode(this.w));\r\n }\r\n}\r\nP3.YZ = new P3(V3.X, 0);\r\nP3.ZX = new P3(V3.Y, 0);\r\nP3.XY = new P3(V3.Z, 0);\r\n//# sourceMappingURL=P3.js.map","import { arrayEquals, arrayHashCode, callsce, eq, eq0, le, NLA_PRECISION, Transformable, } from \"ts3dutils\";\r\nimport { CalculateAreaVisitor, dotCurve2, ImplicitCurve, P3, PICurve, PPCurve, ZDirVolumeVisitor, } from \"..\";\r\nimport { ceil, floor, PI, sign } from \"../math\";\r\nexport class Surface extends Transformable {\r\n static loopContainsPointGeneral(loop, pWC, testLine, lineOut) {\r\n const testPlane = P3.normalOnAnchor(lineOut, pWC);\r\n // edges colinear to the testing line; these will always be counted as \"inside\" relative to the testing line\r\n const colinearEdges = loop.map((edge) => edge.colinearToLine(testLine));\r\n let inside = false;\r\n function logIS(isP) {\r\n const isT = testLine.pointT(isP);\r\n if (eq0(isT)) {\r\n return true;\r\n }\r\n else if (isT > 0) {\r\n inside = !inside;\r\n }\r\n return false;\r\n }\r\n for (let edgeIndex = 0; edgeIndex < loop.length; edgeIndex++) {\r\n const edge = loop[edgeIndex];\r\n const nextEdgeIndex = (edgeIndex + 1) % loop.length, nextEdge = loop[nextEdgeIndex];\r\n //console.log(edge.toSource()) {p:V(2, -2.102, 0),\r\n if (colinearEdges[edgeIndex]) {\r\n const lineAT = testLine.pointT(edge.a), lineBT = testLine.pointT(edge.b);\r\n if (Math.min(lineAT, lineBT) <= NLA_PRECISION &&\r\n -NLA_PRECISION <= Math.max(lineAT, lineBT)) {\r\n return PointVsFace.ON_EDGE;\r\n }\r\n // edge colinear to intersection\r\n const nextInside = colinearEdges[nextEdgeIndex] ||\r\n dotCurve2(nextEdge.curve, nextEdge.aT, lineOut, sign(nextEdge.deltaT())) < 0;\r\n if (!nextInside) {\r\n if (logIS(edge.b))\r\n return PointVsFace.ON_EDGE;\r\n }\r\n }\r\n else {\r\n for (const edgeT of edge.edgeISTsWithPlane(testPlane)) {\r\n if (edgeT == edge.bT) {\r\n if (!testLine.containsPoint(edge.b))\r\n continue;\r\n // endpoint lies on intersection line\r\n if (edge.b.like(pWC)) {\r\n // TODO: refactor, dont check for different sides, just logIs everything\r\n return PointVsFace.ON_EDGE;\r\n }\r\n const edgeInside = dotCurve2(edge.curve, edge.bT, lineOut, -sign(edge.deltaT())) < 0;\r\n const nextInside = colinearEdges[nextEdgeIndex] ||\r\n dotCurve2(nextEdge.curve, nextEdge.aT, lineOut, sign(nextEdge.deltaT())) < 0;\r\n if (edgeInside != nextInside) {\r\n if (logIS(edge.b))\r\n return PointVsFace.ON_EDGE;\r\n }\r\n }\r\n else if (edgeT != edge.aT) {\r\n const p = edge.curve.at(edgeT);\r\n if (!testLine.containsPoint(p))\r\n continue;\r\n // edge crosses line, neither starts nor ends on it\r\n if (logIS(p))\r\n return PointVsFace.ON_EDGE;\r\n // TODO: tangents?\r\n }\r\n }\r\n }\r\n }\r\n return inside ? PointVsFace.INSIDE : PointVsFace.OUTSIDE;\r\n }\r\n static loopContainsPointEllipse(loop, pWC, testLine, pWCT) {\r\n const lineOut = testLine.normal;\r\n const testPlane = P3.normalOnAnchor(testLine.normal, pWC);\r\n const colinearEdges = loop.map((edge) => testLine.isColinearTo(edge.curve));\r\n let inside = false;\r\n if (undefined === pWCT) {\r\n pWCT = testLine.pointT(pWC);\r\n }\r\n const pT = pWCT;\r\n function logIS(isP) {\r\n const isT = testLine.pointT(isP);\r\n if (eq(pT, isT)) {\r\n return true;\r\n }\r\n else if (pT < isT && le(isT, PI)) {\r\n inside = !inside;\r\n }\r\n return false;\r\n }\r\n for (let edgeIndex = 0; edgeIndex < loop.length; edgeIndex++) {\r\n const edge = loop[edgeIndex];\r\n const nextEdgeIndex = (edgeIndex + 1) % loop.length, nextEdge = loop[nextEdgeIndex];\r\n //console.log(edge.toSource()) {p:V(2, -2.102, 0),\r\n if (colinearEdges[edgeIndex]) {\r\n let edgeT;\r\n if (edge.curve.containsPoint(pWC) &&\r\n le(edge.minT, (edgeT = edge.curve.pointT(pWC))) &&\r\n le(edgeT, edge.maxT)) {\r\n return PointVsFace.ON_EDGE;\r\n }\r\n // edge colinear to intersection\r\n const nextInside = colinearEdges[nextEdgeIndex] ||\r\n dotCurve2(nextEdge.curve, nextEdge.aT, lineOut, sign(nextEdge.deltaT())) < 0;\r\n if (!nextInside && testLine.containsPoint(edge.b)) {\r\n if (logIS(edge.b))\r\n return PointVsFace.ON_EDGE;\r\n }\r\n }\r\n else {\r\n for (const edgeT of edge.edgeISTsWithPlane(testPlane)) {\r\n if (edgeT == edge.bT) {\r\n if (!testLine.containsPoint(edge.b))\r\n continue;\r\n // endpoint lies on intersection testLine\r\n const edgeInside = dotCurve2(edge.curve, edge.bT, lineOut, -sign(edge.deltaT())) < 0;\r\n const nextInside = colinearEdges[nextEdgeIndex] ||\r\n dotCurve2(nextEdge.curve, nextEdge.aT, lineOut, sign(nextEdge.deltaT())) < 0;\r\n if (edgeInside != nextInside) {\r\n if (logIS(edge.b))\r\n return PointVsFace.ON_EDGE;\r\n }\r\n }\r\n else if (edgeT != edge.aT) {\r\n const p = edge.curve.at(edgeT);\r\n if (!testLine.containsPoint(p))\r\n continue;\r\n // edge crosses testLine, neither starts nor ends on it\r\n if (logIS(p))\r\n return PointVsFace.ON_EDGE;\r\n // TODO: tangents?\r\n }\r\n }\r\n }\r\n }\r\n return inside ? PointVsFace.INSIDE : PointVsFace.OUTSIDE;\r\n }\r\n toString() {\r\n return this.toSource();\r\n }\r\n toSource(rounder = (x) => x) {\r\n return callsce.call(undefined, \"new \" + this.constructor.name, ...this.getConstructorParameters());\r\n }\r\n /**\r\n * Return points which would touch AABB. Doesnt include borders due to parametric bounds, for example.\r\n */\r\n getExtremePoints() {\r\n return [];\r\n }\r\n isCurvesWithSurface(surface) {\r\n return surface.isCurvesWithSurface(this); //.map(curve => curve.reversed())\r\n }\r\n containsCurve(curve) {\r\n if (curve instanceof PICurve) {\r\n // if (this.equals(curve.parametricSurface) || this.equals(curve.implicitSurface)) {\r\n // \treturn true\r\n // }\r\n }\r\n if (curve instanceof PPCurve) {\r\n if (this.equals(curve.parametricSurface1) ||\r\n this.equals(curve.parametricSurface2)) {\r\n return true;\r\n }\r\n }\r\n if (curve instanceof ImplicitCurve) {\r\n for (let i = ceil(curve.tMin) + 1; i <= floor(curve.tMax) - 1; i++) {\r\n if (!this.containsPoint(curve.points[i])) {\r\n return false;\r\n }\r\n }\r\n return true;\r\n }\r\n return false;\r\n }\r\n flipped2(doFlip) {\r\n return doFlip ? this.flipped() : this;\r\n }\r\n clipCurves(curves) {\r\n return curves;\r\n }\r\n equals(obj) {\r\n return (this === obj ||\r\n (this.constructor === obj.constructor &&\r\n arrayEquals(this.getConstructorParameters(), obj.getConstructorParameters())));\r\n }\r\n hashCode() {\r\n return arrayHashCode(this.getConstructorParameters());\r\n }\r\n zDirVolume(allEdges) {\r\n return this.visit(ZDirVolumeVisitor, allEdges);\r\n }\r\n calculateArea(allEdges) {\r\n return this.visit(CalculateAreaVisitor, allEdges);\r\n }\r\n}\r\nexport var PointVsFace;\r\n(function (PointVsFace) {\r\n PointVsFace[PointVsFace[\"INSIDE\"] = 0] = \"INSIDE\";\r\n PointVsFace[PointVsFace[\"OUTSIDE\"] = 1] = \"OUTSIDE\";\r\n PointVsFace[PointVsFace[\"ON_EDGE\"] = 2] = \"ON_EDGE\";\r\n})(PointVsFace || (PointVsFace = {}));\r\n//# sourceMappingURL=Surface.js.map","import { AABB, assert, assertNumbers, between, emod, isCCW, lerp, V, V3, } from \"ts3dutils\";\r\nimport { Mesh } from \"tsgl\";\r\nimport { breakDownPPCurves, Curve, MathFunctionR2R, PICurve, Surface, } from \"..\";\r\nimport { ceil, min } from \"../math\";\r\nexport class ParametricSurface extends Surface {\r\n constructor(uMin, uMax, vMin, vMax) {\r\n super();\r\n this.uMin = uMin;\r\n this.uMax = uMax;\r\n this.vMin = vMin;\r\n this.vMax = vMax;\r\n assertNumbers(uMin, uMax, vMin, vMax);\r\n assert(uMin < uMax);\r\n assert(vMin < vMax);\r\n assert(emod(this.getConstructorParameters(), -4) == this.uMin, this.getConstructorParameters(), this.uMin);\r\n }\r\n static isCurvesParametricImplicitSurface(ps, is, uStep, vStep = uStep, curveStepSize) {\r\n const pf = ps.pUVFunc(), icc = is.implicitFunction();\r\n const dpdu = ps.dpdu();\r\n const dpdv = ps.dpdv();\r\n const didp = is.didp.bind(is);\r\n const ist = (x, y) => icc(pf(x, y));\r\n const didu = (u, v) => didp(pf(u, v)).dot(dpdu(u, v));\r\n const didv = (u, v) => didp(pf(u, v)).dot(dpdv(u, v));\r\n const mf = MathFunctionR2R.forFFxFy(ist, didu, didv);\r\n const curves = Curve.breakDownIC(mf, ps, uStep, vStep, curveStepSize, (u, v) => is.containsPoint(pf(u, v))).map(({ points, tangents }, _i) => PICurve.forParametricPointsTangents(ps, is, points, tangents, curveStepSize));\r\n return curves;\r\n }\r\n static isCurvesParametricParametricSurface(ps1, ps2, s1Step, t1Step = s1Step, curveStepSize) {\r\n return breakDownPPCurves(ps1, ps2, s1Step, t1Step, curveStepSize);\r\n }\r\n static is(obj) {\r\n return obj.pUVFunc;\r\n }\r\n pUV(u, v) {\r\n return this.pUVFunc()(u, v);\r\n }\r\n pUVFunc() {\r\n return this.pUV.bind(this);\r\n }\r\n uvP(pWC) {\r\n return this.uvPFunc()(pWC);\r\n }\r\n uvPFunc() {\r\n return this.uvP.bind(this);\r\n }\r\n bounds(u, v) {\r\n return this.uMin <= u && u <= this.uMax && this.vMin <= v && v <= this.vMax;\r\n }\r\n /**\r\n * Positive values are inside bounds.\r\n */\r\n boundsSigned(u, v) {\r\n return min(u - this.uMin, this.uMax - u, v - this.vMin, this.vMax - v);\r\n }\r\n normalP(p) {\r\n const pmPoint = this.uvPFunc()(p);\r\n return this.normalUV(pmPoint.x, pmPoint.y);\r\n }\r\n normalUVFunc() {\r\n return this.normalUV.bind(this);\r\n }\r\n normalUV(u, v) {\r\n return this.normalUVFunc()(u, v);\r\n }\r\n parametersValid(u, v) {\r\n return between(u, this.uMin, this.uMax) && between(v, this.vMin, this.vMax);\r\n }\r\n toMesh(uStep = this.uStep, vStep = this.vStep) {\r\n assert(isFinite(this.vMin) &&\r\n isFinite(this.vMax) &&\r\n isFinite(this.uMin) &&\r\n isFinite(this.uMax));\r\n assert(isFinite(uStep) && isFinite(vStep));\r\n return Mesh.parametric(this.pUVFunc(), this.normalUVFunc(), this.uMin, this.uMax, this.vMin, this.vMax, ceil((this.uMax - this.uMin) / uStep), ceil((this.vMax - this.vMin) / vStep));\r\n }\r\n isCurvesWithImplicitSurface(is, uStep, vStep, stepSize) {\r\n return ParametricSurface.isCurvesParametricImplicitSurface(this, is, uStep, vStep, stepSize);\r\n }\r\n edgeLoopCCW(contour) {\r\n const ptpF = this.uvPFunc();\r\n return isCCW(contour.flatMap((e) => e.getVerticesNo0()).map((v) => ptpF(v)), V3.Z);\r\n }\r\n like(object) {\r\n if (!this.isCoplanarTo(object))\r\n return false;\r\n // normals need to point in the same direction (outwards or inwards) for both\r\n const pSMinTMin = this.pUVFunc()(this.uMin, this.vMin);\r\n const thisNormal = this.normalUVFunc()(this.uMin, this.vMin);\r\n const otherNormal = object.normalP(pSMinTMin);\r\n return 0 < thisNormal.dot(otherNormal);\r\n }\r\n getApproxAABB() {\r\n const result = new AABB();\r\n result.addPoints(this.getExtremePoints());\r\n const ps = [V(0, 0), V(0, 1), V(1, 0), V(1, 1), V(0.5, 0.5)].map((p) => this.pUV(lerp(this.uMin, this.uMax, p.x), lerp(this.vMin, this.vMax, p.y)));\r\n result.addPoints(ps);\r\n return result;\r\n }\r\n}\r\n//# sourceMappingURL=ParametricSurface.js.map","import { AABB, assert, assertInst, assertVectors, eq, eq0, getIntervals, M4, newtonIterate, pqFormula, TAU, V3, Vector, } from \"ts3dutils\";\r\nimport { CylinderSurface, EllipseCurve, HyperbolaCurve, ImplicitSurface, L3, P3, ParabolaCurve, ParametricSurface, PlaneSurface, Surface, } from \"..\";\r\nimport { abs, cos, max, min, PI, sign, sin, sqrt, SQRT1_2 } from \"../math\";\r\nexport class ConicSurface extends ParametricSurface {\r\n /**\r\n * returns new cone C = {apex + f1 * v * cos(u) + f2 * v * sin(u) + f3 * v |\r\n * -PI <= u <= PI, 0 <= v}\r\n *\r\n * If the coordinate system [f1 f2 dir] is right-handed, the normals will\r\n * point outwards, otherwise inwards.\r\n *\r\n * @param f1\r\n * @param f2\r\n * @param dir Direction in which the cone opens. The ellipse spanned by f1,\r\n * f2 is contained at (apex + dir).\r\n */\r\n constructor(center, f1, f2, dir, uMin = 0, uMax = PI, vMin = 0, vMax = 16) {\r\n super(uMin, uMax, vMin, vMax);\r\n this.center = center;\r\n this.f1 = f1;\r\n this.f2 = f2;\r\n this.dir = dir;\r\n assertVectors(center, f1, f2, dir);\r\n assert(-PI <= uMin && uMax <= PI);\r\n assert(0 <= vMin, vMin);\r\n this.matrix = M4.forSys(f1, f2, dir, center);\r\n this.matrixInverse = this.matrix.inversed();\r\n this.normalDir = sign(this.f1.cross(this.f2).dot(this.dir));\r\n this.pLCNormalWCMatrix = this.matrix\r\n .as3x3()\r\n .inversed()\r\n .transposed()\r\n .scale(this.normalDir);\r\n }\r\n getConstructorParameters() {\r\n return [\r\n this.center,\r\n this.f1,\r\n this.f2,\r\n this.dir,\r\n this.uMin,\r\n this.uMax,\r\n this.vMin,\r\n this.vMax,\r\n ];\r\n }\r\n pointFoot(pWC, startU, startV) {\r\n if (undefined === startU || undefined === startV) {\r\n // similar to uvP\r\n const pLC = this.matrixInverse.transformPoint(pWC);\r\n const angle = pLC.angleXY();\r\n if (undefined === startU) {\r\n startU = angle < -PI / 2 ? angle + TAU : angle;\r\n }\r\n if (undefined === startV) {\r\n startV = pLC.z + (pLC.lengthXY() - pLC.z) * SQRT1_2;\r\n }\r\n }\r\n const f = ([u, v]) => {\r\n const pUVToPWC = this.pUV(u, v).to(pWC);\r\n return [this.dpdu()(u, v).dot(pUVToPWC), this.dpdv()(u).dot(pUVToPWC)];\r\n };\r\n const { 0: x, 1: y } = newtonIterate(f, [startU, startV]);\r\n return new V3(x, y, 0);\r\n }\r\n get apex() {\r\n return this.center;\r\n }\r\n static atApexThroughEllipse(apex, ellipse, uMin, uMax, vMin, vMax) {\r\n assertVectors(apex);\r\n assertInst(EllipseCurve, ellipse);\r\n return new ConicSurface(apex, ellipse.f1, ellipse.f2, apex.to(ellipse.center), uMin, uMax, vMin, vMax);\r\n }\r\n static unitISLineTs(anchor, dir) {\r\n const { x: ax, y: ay, z: az } = anchor;\r\n const { x: dx, y: dy, z: dz } = dir;\r\n // this cone: x² + y² = z²\r\n // line: p = anchor + t * dir1\r\n // split line equation into 3 component equations, insert into cone equation\r\n // transform to form (a t² + b t + c = 0) and solve with pqFormula\r\n const a = dx * dx + dy * dy - dz * dz;\r\n const b = 2 * (ax * dx + ay * dy - az * dz);\r\n const c = ax * ax + ay * ay - az * az;\r\n // cone only defined for 0 <= z, so filter invalid values\r\n return pqFormula(b / a, c / a).filter((t) => 0 < az + t * dz);\r\n }\r\n // calculate intersection of plane ax + cz = d and cone x² + y² = z²\r\n static unitISPlane(a, c, d) {\r\n if (eq0(c)) {\r\n // plane is \"vertical\", i.e. parallel to Y and Z axes\r\n assert(!eq0(a)); // normal would be zero, which is invalid\r\n // z² - y² = d²/a²\r\n if (eq0(d)) {\r\n // d = 0 => z² - y² = 0 => z² = y² => z = y\r\n // plane goes through origin/V3.O\r\n return [\r\n new L3(V3.O, new V3(0, -SQRT1_2, -SQRT1_2), undefined, 0),\r\n new L3(V3.O, new V3(0, -SQRT1_2, SQRT1_2), 0),\r\n ];\r\n }\r\n else {\r\n // hyperbola\r\n const center = new V3(d / a, 0, 0);\r\n const f1 = new V3(0, 0, abs(d / a)); // abs, because we always want the\r\n // hyperbola to be pointing up\r\n const f2 = new V3(0, d / a, 0);\r\n return [new HyperbolaCurve(center, f1, f2)];\r\n }\r\n }\r\n else {\r\n // c != 0\r\n const aa = a * a, cc = c * c;\r\n if (eq0(d)) {\r\n // ax + cz = d => x = d - cz / a => x² = d² - 2cdz/a + c²z²/a²\r\n // x² + y² = z²\r\n // => d² - 2cdz/a + c²z²/a² + y² = z²\r\n if (eq(aa, cc)) {\r\n return [new L3(V3.O, new V3(c, 0, -a).unit())];\r\n }\r\n else if (aa < cc) {\r\n throw new Error(\"intersection is single point V3.O\");\r\n }\r\n else if (aa > cc) {\r\n return [\r\n new L3(V3.O, new V3(c, sqrt(aa - cc), -a).unit()),\r\n new L3(V3.O, new V3(c, -sqrt(aa - cc), -a).unit()),\r\n ];\r\n }\r\n }\r\n else {\r\n if (eq(aa, cc)) {\r\n // parabola\r\n const parabolaVertex = new V3(d / 2 / a, 0, d / 2 / c);\r\n const parabolaVertexTangentPoint = new V3(d / 2 / a, d / c, d / 2 / c);\r\n const p2 = new V3(0, 0, d / c);\r\n const f2 = p2.minus(parabolaVertex);\r\n return [\r\n new ParabolaCurve(parabolaVertex, parabolaVertexTangentPoint.minus(parabolaVertex), f2.z < 0 ? f2.negated() : f2),\r\n ];\r\n }\r\n else if (aa < cc) {\r\n // ellipse\r\n const center = new V3((-a * d) / (cc - aa), 0, (d * c) / (cc - aa));\r\n if (center.z < 0) {\r\n return [];\r\n }\r\n const p1 = new V3(d / (a - c), 0, -d / (a - c));\r\n const p2 = new V3((-a * d) / (cc - aa), d / sqrt(cc - aa), (d * c) / (cc - aa));\r\n return [\r\n new EllipseCurve(center, center.to(p1), center.to(p2), -PI, PI),\r\n ];\r\n }\r\n else if (aa > cc) {\r\n // hyperbola\r\n const center = new V3((-a * d) / (cc - aa), 0, (d * c) / (cc - aa));\r\n // const p1 = new V3(d / (a - c), 0, -d / (a - c))\r\n // const p2 = new V3(-a * d / (cc - aa), d / sqrt(aa - cc), d * c /\r\n // (cc - aa)) const f1 = center.to(p1)\r\n const f1 = new V3((d * c) / (aa - cc), 0, (-d * a) / (aa - cc));\r\n const f2 = new V3(0, d / sqrt(aa - cc), 0);\r\n return [new HyperbolaCurve(center, f1.z > 0 ? f1 : f1.negated(), f2)];\r\n }\r\n }\r\n }\r\n throw new Error(\"???\");\r\n }\r\n equals(obj) {\r\n return (this == obj ||\r\n (Object.getPrototypeOf(this) == Object.getPrototypeOf(obj) &&\r\n this.center.equals(obj.center) &&\r\n this.f1.equals(obj.f1) &&\r\n this.f2.equals(obj.f2) &&\r\n this.dir.equals(obj.dir)));\r\n }\r\n like(object) {\r\n if (!this.isCoplanarTo(object))\r\n return false;\r\n // normals need to point in the same direction (outwards or inwards) for\r\n // both\r\n return this.normalDir == object.normalDir;\r\n }\r\n getVectors() {\r\n return [\r\n { anchor: this.center, dir1: this.dir },\r\n { anchor: this.center.plus(this.dir), dir1: this.f1 },\r\n { anchor: this.center.plus(this.dir), dir1: this.f2 },\r\n ];\r\n }\r\n getSeamPlane() {\r\n return P3.forAnchorAndPlaneVectors(this.center, this.f1, this.dir);\r\n }\r\n loopContainsPoint(contour, p) {\r\n assertVectors(p);\r\n const line = this.center.like(p)\r\n ? new L3(p, this.matrix.transformVector(new V3(0, 1, 1)).unit())\r\n : L3.throughPoints(p, this.apex);\r\n const lineOut = line.dir1.cross(this.dir);\r\n return Surface.loopContainsPointGeneral(contour, p, line, lineOut);\r\n }\r\n isTsForLine(line) {\r\n // transforming line manually has advantage that dir1 will not be\r\n // renormalized, meaning that calculated values t for lineLC are directly\r\n // transferable to line\r\n const anchorLC = this.matrixInverse.transformPoint(line.anchor);\r\n const dirLC = this.matrixInverse.transformVector(line.dir1);\r\n return ConicSurface.unitISLineTs(anchorLC, dirLC);\r\n }\r\n /**\r\n * Interestingly, two cones don't need to have parallel dirs to be coplanar.\r\n */\r\n isCoplanarTo(surface) {\r\n if (this === surface)\r\n return true;\r\n if (!(surface instanceof ConicSurface) || !this.apex.like(surface.apex))\r\n return false;\r\n // at this point apexes are equal\r\n return this.containsEllipse(new EllipseCurve(surface.center.plus(surface.dir), surface.f1, surface.f2));\r\n }\r\n containsEllipse(ellipse) {\r\n const ellipseLC = ellipse.transform(this.matrixInverse);\r\n if (ellipseLC.center.z < 0) {\r\n return false;\r\n }\r\n const { f1, f2 } = ellipseLC.rightAngled();\r\n const p1 = ellipseLC.center.plus(f1), p2 = ellipseLC.center.plus(f2);\r\n // check if both endpoints are on the cone's surface\r\n // and that one main axis is perpendicular to the Z-axis\r\n return (eq(Math.pow(p1.x, 2) + Math.pow(p1.y, 2), Math.pow(p1.z, 2)) &&\r\n eq(Math.pow(p2.x, 2) + Math.pow(p2.y, 2), Math.pow(p2.z, 2)) &&\r\n (eq0(f1.z) || eq0(f2.z)));\r\n }\r\n containsLine(line) {\r\n const lineLC = line.transform(this.matrixInverse);\r\n const d = lineLC.dir1;\r\n return lineLC.containsPoint(V3.O) && eq(d.x * d.x + d.y * d.y, d.z * d.z);\r\n }\r\n containsParabola(curve) {\r\n assertInst(ParabolaCurve, curve);\r\n const curveLC = curve.transform(this.matrixInverse);\r\n if (curveLC.center.z < 0 || curveLC.f2.z < 0) {\r\n return false;\r\n }\r\n const { center, f1, f2 } = curveLC.rightAngled();\r\n // check if center is on the surface,\r\n // that tangent is perpendicular to the Z-axis\r\n // and that \"y\" axis is parallel to surface\r\n return (eq(center.x * center.x + center.y * center.y, center.z * center.z) &&\r\n eq0(f1.z) &&\r\n eq(f2.x * f2.x + f2.y * f2.y, f2.z * f2.z));\r\n }\r\n containsHyperbola(curve) {\r\n // calculate intersection of plane ax + cz = 1 and cone x² + y² = z²\r\n // const center = new V3(-a / (cc - aa), 0, 1 / (cc - aa))\r\n // const p1 = new V3(1 / (a - c), 0, -1 / (a - c))\r\n // const p2 = new V3(-a / (cc - aa), 1 / sqrt(aa - cc), 1 / (cc - aa))\r\n // const f1 = new V3(1 * c / (aa - cc), 0, -a / (aa - cc) )\r\n // const f2 = new V3(0, 1 / sqrt(aa - cc), 0)\r\n assertInst(HyperbolaCurve, curve);\r\n const curveLC = curve.transform(this.matrixInverse).rightAngled();\r\n const centerXY = curveLC.center.xy();\r\n if (centerXY.likeO()) {\r\n return false;\r\n }\r\n const rot = centerXY.angleXY();\r\n const { center, f1, f2 } = curveLC.rotateZ(-rot);\r\n // s = a / (aa - cc)\r\n // t = -c / (aa - cc)\r\n // s + t = 1 / (a + c)\r\n // s - t = 1 / (a - c)\r\n // (s + t)(s - t) = (ss - tt) = 1 / (aa - cc)\r\n // u = 1 / sqrt(aa - cc) = sqrt(ss - tt)\r\n // check if center is on the surface,\r\n // that tangent is perpendicular to the Z-axis\r\n return (f1.z > 0 &&\r\n eq(center.x, f1.z) &&\r\n eq(center.z, f1.x) &&\r\n eq0(center.y) &&\r\n eq0(f1.y) &&\r\n eq(sqrt(abs(Math.pow(center.x, 2) - Math.pow(center.z, 2))), abs(f2.y)) &&\r\n eq0(f2.x) &&\r\n eq0(f2.z));\r\n }\r\n containsCurve(curve) {\r\n if (curve instanceof EllipseCurve) {\r\n return this.containsEllipse(curve);\r\n }\r\n else if (curve instanceof L3) {\r\n return this.containsLine(curve);\r\n }\r\n else if (curve instanceof HyperbolaCurve) {\r\n return this.containsHyperbola(curve);\r\n }\r\n else if (curve instanceof ParabolaCurve) {\r\n return this.containsParabola(curve);\r\n }\r\n else {\r\n return super.containsCurve(curve);\r\n }\r\n }\r\n transform(m4) {\r\n return new ConicSurface(m4.transformPoint(this.center), m4.transformVector(this.f1).times(m4.isMirroring() ? -1 : 1), m4.transformVector(this.f2), m4.transformVector(this.dir), this.uMin, this.uMax, this.vMin, this.vMax);\r\n }\r\n transform4(m4) {\r\n const transformedApex = m4.timesVector(Vector.fromV3AndWeight(this.center, 1));\r\n const isometricV = (z) => new EllipseCurve(new V3(0, 0, z), new V3(z, 0, 0), new V3(0, z, 0));\r\n if (!eq0(transformedApex.w)) {\r\n // sMin doesn't change, but tMin does...\r\n const c = m4.transformPoint(this.center), f1 = m4\r\n .transformVector2(this.f1, this.center)\r\n .times(m4.isMirroring() ? -1 : 1), f2 = m4.transformVector2(this.f2, this.center), dir = m4.transformVector2(this.dir, this.center);\r\n const matrixInv = M4.forSys(f1, f2, dir, c).inversed();\r\n const x = isometricV(this.vMin).transform4(matrixInv.times(m4).times(this.matrix));\r\n const y = isometricV(this.vMax).transform4(matrixInv.times(m4).times(this.matrix));\r\n const aabb = AABB.forAABBs([x.getAABB(), y.getAABB()]);\r\n console.log(\"aabb\", aabb);\r\n console.log(matrixInv.str);\r\n console.log(x.str, y.str);\r\n return new ConicSurface(c, f1, f2, dir, this.uMin, this.uMax, aabb.min.z, aabb.max.z);\r\n }\r\n else {\r\n const dir = transformedApex.V3();\r\n const baseCurve = isometricV(this.vMin).transform4(m4.times(this.matrix));\r\n const matrixInv = M4.forSys(baseCurve.f1, baseCurve.f2, dir.unit(), baseCurve.center).inversed();\r\n const aabb = isometricV(this.vMax)\r\n .transform4(matrixInv.times(m4.times(this.matrix)))\r\n .getAABB();\r\n return new CylinderSurface(baseCurve, dir.unit(), this.uMin, this.uMax, min(0, aabb.min.z, aabb.max.z), max(0, aabb.min.z, aabb.max.z));\r\n }\r\n }\r\n flipped() {\r\n return new ConicSurface(this.center, this.f1.negated(), this.f2, this.dir);\r\n }\r\n normalUVFunc() {\r\n const { f1, f2 } = this, f3 = this.dir;\r\n return (d, _z) => {\r\n return f2\r\n .cross(f1)\r\n .plus(f2.cross(f3.times(Math.cos(d))))\r\n .plus(f3.cross(f1.times(Math.sin(d))))\r\n .unit();\r\n };\r\n }\r\n normalP(p) {\r\n //TODO assert(!p.like(this.center))\r\n const pLC = this.matrixInverse.transformPoint(p);\r\n return this.normalUVFunc()(pLC.angleXY(), pLC.z);\r\n }\r\n pUVFunc() {\r\n return (u, v) => {\r\n // center + f1 v cos u + f2 v sin u + v dir\r\n const resultLC = new V3(v * cos(u), v * sin(u), v);\r\n return this.matrix.transformPoint(resultLC);\r\n };\r\n }\r\n dpdu() {\r\n return (u, v) => {\r\n const resultLC = new V3(v * -sin(u), v * cos(u), 0);\r\n return this.matrix.transformVector(resultLC);\r\n };\r\n }\r\n dpdv() {\r\n return (s) => {\r\n const resultLC = new V3(cos(s), sin(s), 1);\r\n return this.matrix.transformVector(resultLC);\r\n };\r\n }\r\n implicitFunction() {\r\n return (pWC) => {\r\n const pLC = this.matrixInverse.transformPoint(pWC);\r\n const radiusLC = pLC.lengthXY();\r\n return this.normalDir * (radiusLC - pLC.z);\r\n };\r\n }\r\n didp(pWC) {\r\n const pLC = this.matrixInverse.transformPoint(pWC);\r\n return this.pLCNormalWCMatrix.transformVector(pLC.xy().unit().withElement(\"z\", -1).times(this.normalDir));\r\n }\r\n containsPoint(p) {\r\n return eq0(this.implicitFunction()(p));\r\n }\r\n uvP(pWC) {\r\n const pLC = this.matrixInverse.transformPoint(pWC);\r\n const angle = pLC.angleXY();\r\n return new V3(angle < -PI / 2 ? angle + TAU : angle, pLC.z, 0);\r\n }\r\n isCurvesWithSurface(surface) {\r\n if (surface instanceof PlaneSurface) {\r\n return this.isCurvesWithPlane(surface.plane);\r\n }\r\n else if (ImplicitSurface.is(surface)) {\r\n return ParametricSurface.isCurvesParametricImplicitSurface(this, surface, 0.1, 0.1 / this.dir.length(), 0.02);\r\n }\r\n return super.isCurvesWithSurface(surface);\r\n }\r\n getCenterLine() {\r\n return new L3(this.center, this.dir);\r\n }\r\n isCurvesWithPlane(plane) {\r\n assertInst(P3, plane);\r\n const planeLC = plane.transform(this.matrixInverse);\r\n const planeNormal = planeLC.normal1;\r\n const c = planeNormal.z;\r\n /** \"rotate\" plane normal1 when passing to {@link ConicSurface.unitISPlane} so that\r\n * y-component of normal1 is 0 */\r\n const a = planeNormal.lengthXY();\r\n const d = planeLC.w;\r\n // generated curves need to be rotated back before transforming to world\r\n // coordinates\r\n const rotationMatrix = M4.rotateZ(planeNormal.angleXY());\r\n const wcMatrix = eq0(planeNormal.lengthXY())\r\n ? this.matrix\r\n : this.matrix.times(rotationMatrix);\r\n return ConicSurface.unitISPlane(a, c, d).flatMap((curve) => {\r\n const curveWC = curve.transform(wcMatrix);\r\n if (curve instanceof EllipseCurve) {\r\n const curveLC = curve.transform(rotationMatrix);\r\n const ts = curveLC.isTsWithPlane(P3.ZX);\r\n const intervals = getIntervals(ts, -PI, PI).filter(([a, b]) => curveLC.at((a + b) / 2).y > 0);\r\n return intervals.flatMap(([a, b]) => curveWC.split(a, b));\r\n }\r\n const p = curveWC.at(0.2);\r\n return this.normalP(p).cross(plane.normal1).dot(curveWC.tangentAt(0.2)) >\r\n 0\r\n ? curveWC\r\n : curveWC.reversed();\r\n });\r\n }\r\n debugInfo() {\r\n return {\r\n ps: [this.center],\r\n lines: [\r\n this.center,\r\n this.center.plus(this.f1),\r\n this.center.plus(this.f2),\r\n this.center.plus(this.dir),\r\n ],\r\n };\r\n }\r\n}\r\n/**\r\n * Unit cone. x² + y² = z², 0 <= z\r\n */\r\nConicSurface.UNIT = new ConicSurface(V3.O, V3.X, V3.Y, V3.Z);\r\nConicSurface.prototype.uStep = PI / 16;\r\nConicSurface.prototype.vStep = 256;\r\n//# sourceMappingURL=ConicSurface.js.map","import { arrayHashCode, assert, assertInst, assertNumbers, assertVectors, hasConstructor, M4, V3, } from \"ts3dutils\";\r\nimport { ConicSurface, Curve, EllipseCurve, EllipsoidSurface, ImplicitCurve, ImplicitSurface, L3, P3, ParametricSurface, PlaneSurface, PointProjectedSurface, Surface, } from \"../index\";\r\nimport { sign } from \"../math\";\r\n/**\r\n * Surface normal1 is (t, z) => this.baseCurve.tangentAt(t) X this.dir\r\n * Choose dir appropriately to select surface orientation.\r\n */\r\nexport class ProjectedCurveSurface extends ParametricSurface {\r\n constructor(baseCurve, dir, uMin = baseCurve.tMin, uMax = baseCurve.tMax, vMin = -100, vMax = 100) {\r\n super(uMin, uMax, vMin, vMax);\r\n this.baseCurve = baseCurve;\r\n this.dir = dir;\r\n assertInst(Curve, baseCurve);\r\n assertInst(V3, dir);\r\n assert(uMin < uMax);\r\n assert(vMin < vMax);\r\n }\r\n getConstructorParameters() {\r\n return [\r\n this.baseCurve,\r\n this.dir,\r\n this.uMin,\r\n this.uMax,\r\n this.vMin,\r\n this.vMax,\r\n ];\r\n }\r\n equals(obj) {\r\n return (this == obj ||\r\n (Object.getPrototypeOf(this) == Object.getPrototypeOf(obj) &&\r\n this.dir.equals(obj.dir) &&\r\n this.baseCurve.equals(obj.baseCurve)));\r\n }\r\n hashCode() {\r\n return arrayHashCode([this.dir, this.baseCurve]);\r\n }\r\n containsLine(line) {\r\n return this.dir.isParallelTo(line.dir1) && this.containsPoint(line.anchor);\r\n }\r\n dpdu() {\r\n return (u, v) => this.baseCurve.tangentAt(u);\r\n }\r\n dpdv() {\r\n return (u, v) => this.dir;\r\n }\r\n normalUV(u, v) {\r\n return this.baseCurve.tangentAt(u).cross(this.dir).unit();\r\n }\r\n pUV(u, v) {\r\n return this.baseCurve.at(u).plus(this.dir.times(v));\r\n }\r\n pointFoot(pWC, ss) {\r\n const basePlane = new P3(this.dir.unit(), 0);\r\n const projCurve = this.baseCurve.project(basePlane);\r\n const projPoint = basePlane.projectedPoint(pWC);\r\n const t = projCurve.closestTToPoint(projPoint, ss, this.uMin, this.uMax);\r\n const z = L3.pointT(this.baseCurve.at(t), this.dir, pWC);\r\n return new V3(t, z, 0);\r\n }\r\n uvPFunc() {\r\n const projPlane = new P3(this.dir.unit(), 0);\r\n const projBaseCurve = this.baseCurve.project(projPlane);\r\n return (pWC) => {\r\n const projPoint = projPlane.projectedPoint(pWC);\r\n assertNumbers(this.uMin);\r\n const t = projBaseCurve.pointT(projPoint, this.uMin, this.uMax);\r\n const z = L3.pointT(this.baseCurve.at(t), this.dir, pWC);\r\n return new V3(t, z, 0);\r\n };\r\n }\r\n isCurvesWithPlane(plane) {\r\n assertInst(P3, plane);\r\n if (this.dir.isPerpendicularTo(plane.normal1)) {\r\n const ts = this.baseCurve.isTsWithPlane(plane);\r\n return ts.map((t) => {\r\n const l3dir = 0 < this.baseCurve.tangentAt(t).dot(plane.normal1)\r\n ? this.dir\r\n : this.dir.negated();\r\n return new L3(this.baseCurve.at(t), l3dir.unit());\r\n });\r\n }\r\n else {\r\n let projCurve = this.baseCurve.transform(M4.project(plane, this.dir));\r\n if (this.dir.dot(plane.normal1) > 0) {\r\n // we need to flip the ellipse so the tangent is correct\r\n projCurve = projCurve.reversed();\r\n }\r\n return [projCurve];\r\n }\r\n }\r\n isCurvesWithSurface(surface) {\r\n if (surface instanceof PlaneSurface) {\r\n return this.isCurvesWithPlane(surface.plane);\r\n }\r\n if (surface instanceof ProjectedCurveSurface) {\r\n const dir1 = surface.dir;\r\n if (this.dir.isParallelTo(dir1)) {\r\n const ts = surface.baseCurve.isTsWithSurface(this);\r\n return ts.map((t) => {\r\n const p = surface.baseCurve.at(t);\r\n const correctDir = this.normalP(p).cross(surface.normalP(p));\r\n return new L3(p, dir1.times(sign(correctDir.dot(dir1))));\r\n });\r\n }\r\n else if (ImplicitSurface.is(surface)) {\r\n let curves2 = ParametricSurface.isCurvesParametricImplicitSurface(this, surface, 0.1, 0.1 / surface.dir.length(), 0.05);\r\n curves2 = surface.clipCurves(curves2);\r\n return curves2;\r\n }\r\n else {\r\n let curves2 = ParametricSurface.isCurvesParametricParametricSurface(this, surface, 0.05, 0.1 / surface.dir.length(), 0.05);\r\n curves2 = this.clipCurves(curves2);\r\n curves2 = surface.clipCurves(curves2);\r\n return curves2;\r\n }\r\n }\r\n if (surface instanceof EllipsoidSurface) {\r\n return surface.isCurvesWithSurface(this);\r\n }\r\n return super.isCurvesWithSurface(surface);\r\n }\r\n containsPoint(pWC) {\r\n const uv = this.uvPFunc()(pWC);\r\n return this.pUVFunc()(uv.x, uv.y).like(pWC);\r\n }\r\n containsCurve(curve) {\r\n if (curve instanceof L3) {\r\n return (this.dir.isParallelTo(curve.dir1) && this.containsPoint(curve.anchor));\r\n }\r\n if (curve instanceof ImplicitCurve) {\r\n return super.containsCurve(curve);\r\n }\r\n // project baseCurve and test curve onto a common plane and check if the curves are alike\r\n const projPlane = new P3(this.dir.unit(), 0);\r\n const projBaseCurve = this.baseCurve.project(projPlane);\r\n const projCurve = curve.project(projPlane);\r\n return projBaseCurve.isColinearTo(projCurve);\r\n }\r\n isCoplanarTo(surface) {\r\n return (this == surface ||\r\n (hasConstructor(surface, ProjectedCurveSurface) &&\r\n this.dir.isParallelTo(surface.dir) &&\r\n this.containsCurve(surface.baseCurve)));\r\n }\r\n like(object) {\r\n if (!this.isCoplanarTo(object))\r\n return false;\r\n // normals need to point in the same direction (outwards or inwards) for both\r\n const p00 = this.pUVFunc()(0, 0);\r\n const thisNormal = this.normalUVFunc()(0, 0);\r\n const otherNormal = object.normalP(p00);\r\n return 0 < thisNormal.dot(otherNormal);\r\n }\r\n loopContainsPoint(loop, p) {\r\n assertVectors(p);\r\n assert(isFinite(p.x), p.y, p.z);\r\n const line = new L3(p, this.dir.unit());\r\n const ptpf = this.uvPFunc();\r\n const pp = ptpf(p);\r\n if (isNaN(pp.x)) {\r\n console.log(this.sce, p.sce);\r\n assert(false);\r\n }\r\n const lineOut = this.baseCurve.tangentAt(pp.x).rejectedFrom(this.dir);\r\n return Surface.loopContainsPointGeneral(loop, p, line, lineOut);\r\n }\r\n transform(m4) {\r\n const f = m4.isMirroring() ? -1 : 1;\r\n return new this.constructor(this.baseCurve.transform(m4), m4.transformVector(this.dir).times(f), this.uMin, this.uMax, 1 == f ? this.vMin : -this.vMax, 1 == f ? this.vMax : -this.vMin);\r\n }\r\n transform4(m4) {\r\n const vp = m4.vanishingPoint(this.dir);\r\n if (!vp) {\r\n const f = m4.isMirroring() ? -1 : 1;\r\n return new this.constructor(this.baseCurve.transform4(m4), m4.normalized().transformVector(this.dir).times(f), undefined, undefined, 1 == f ? this.vMin : -this.vMax, 1 == f ? this.vMax : -this.vMin);\r\n }\r\n const curveT = this.baseCurve.transform4(m4);\r\n if (curveT instanceof EllipseCurve) {\r\n console.log(vp.sce, curveT.sce);\r\n return ConicSurface.atApexThroughEllipse(vp, m4.isMirroring() ? curveT : curveT.reversed(), this.uMin, this.uMax, 1, 2);\r\n }\r\n return new PointProjectedSurface(curveT, vp, P3.throughPoints(curveT.at(curveT.tMin), curveT.at((curveT.tMin + curveT.tMax) / 2), curveT.at(curveT.tMax)), 1, this.uMin, this.uMax, 1, 2);\r\n }\r\n isTsForLine(line) {\r\n assertInst(L3, line);\r\n const projPlane = new P3(this.dir.unit(), 0);\r\n const projDir = projPlane.projectedVector(line.dir1);\r\n if (projDir.likeO()) {\r\n // line is parallel to this.dir\r\n return [];\r\n }\r\n const projAnchor = projPlane.projectedPoint(line.anchor);\r\n const projBaseCurve = this.baseCurve.project(projPlane);\r\n return projBaseCurve\r\n .isInfosWithLine(projAnchor, projDir, this.uMin, this.uMax, line.tMin, line.tMax)\r\n .map((info) => info.tOther);\r\n }\r\n flipped() {\r\n return new this.constructor(this.baseCurve, this.dir.negated(), this.uMin, this.uMax, -this.vMax, -this.vMin);\r\n }\r\n}\r\nProjectedCurveSurface.prototype.uStep = 1 / 128;\r\nProjectedCurveSurface.prototype.vStep = 256;\r\n//# sourceMappingURL=ProjectedCurveSurface.js.map","import { assert, assertInst, DEG, eq0, fuzzyBetween, hasConstructor, lerp, lt, M4, V3, VV, withMax, } from \"ts3dutils\";\r\nimport { EllipseCurve, HyperbolaCurve, intersectionUnitCircleLine2, L3, NURBS, NURBSSurface, P3, ParametricSurface, PlaneSurface, Surface, } from \"..\";\r\nimport { abs, cos, PI, sin } from \"../math\";\r\n/**\r\n * Rotation surface with r = f(z)\r\n */\r\nexport class RotatedCurveSurface extends ParametricSurface {\r\n constructor(curve, matrix = M4.IDENTITY, uMin = 0, uMax = PI, vMin = curve.tMin, vMax = curve.tMax) {\r\n // d/dz (r(z))\r\n super(uMin, uMax, vMin, vMax);\r\n this.curve = curve;\r\n this.matrix = matrix;\r\n assertInst(M4, matrix);\r\n assert(matrix.isNoProj());\r\n assert(eq0(curve.at(vMin).y));\r\n this.matrixInverse = matrix.inversed();\r\n this.vStep = this.curve.tIncrement;\r\n }\r\n getConstructorParameters() {\r\n return [this.curve, this.matrix, this.uMin, this.uMax, this.vMin, this.vMax];\r\n }\r\n flipped() {\r\n return new RotatedCurveSurface(this.curve, this.matrix.times(M4.mirror(P3.YZ)), this.uMin, this.uMax, this.vMin, this.vMax);\r\n }\r\n transform(m4) {\r\n return new RotatedCurveSurface(this.curve, m4.isMirroring()\r\n ? m4.times(this.matrix).times(M4.mirror(P3.YZ))\r\n : m4.times(this.matrix), this.uMin, this.uMax, this.vMin, this.vMax);\r\n }\r\n containsPoint(pWC) {\r\n const pLC = this.matrixInverse.transformPoint(pWC);\r\n const radius = pLC.lengthXY();\r\n return this.curve.containsPoint(new V3(radius, 0, pLC.z));\r\n }\r\n pUVFunc() {\r\n return (u, v) => {\r\n const { x: radius, z: z } = this.curve.at(v);\r\n return this.matrix.transformPoint(V3.polar(radius, u, z));\r\n };\r\n }\r\n dpdu() {\r\n return (u, v) => {\r\n const radius = this.curve.at(v).x;\r\n const resultLC = new V3(radius * -sin(u), radius * cos(u), 0);\r\n return this.matrix.transformVector(resultLC);\r\n };\r\n }\r\n dpdv() {\r\n return (u, v) => {\r\n const { x: drdt, z: dzdt } = this.curve.tangentAt(v);\r\n return this.matrix.transformVector(V3.polar(drdt, u, dzdt));\r\n };\r\n }\r\n normalUVFunc() {\r\n const matrix = this.matrix.inversed().transposed().as3x3();\r\n const normalLength = this.matrix.isMirroring() ? -1 : 1;\r\n return (u, v) => {\r\n const { x: drdt, z: dzdt } = this.curve.tangentAt(v);\r\n return matrix\r\n .transformVector(V3.polar(dzdt, u, -drdt))\r\n .toLength(normalLength);\r\n };\r\n }\r\n uvPFunc() {\r\n return (pWC) => {\r\n const pLC = this.matrixInverse.transformPoint(pWC);\r\n const angle = EllipseCurve.XYLCPointT(pLC, this.uMin, this.uMax);\r\n const radius = pLC.lengthXY();\r\n return new V3(angle, this.curve.pointT(new V3(radius, 0, pLC.z)), 0);\r\n };\r\n }\r\n pointFoot(pWC, startS, startT) {\r\n const pLC = this.matrixInverse.transformPoint(pWC);\r\n const angle = abs(pLC.angleXY());\r\n const radius = pLC.lengthXY();\r\n return new V3(angle, this.curve.closestTToPoint(new V3(radius, 0, pLC.z)), 0);\r\n }\r\n isTsForLine(line) {\r\n const anchorLC = this.matrixInverse.transformPoint(line.anchor);\r\n const dirLC = this.matrixInverse.transformVector(line.dir1);\r\n if (dirLC.isParallelTo(V3.Z)) {\r\n if (!fuzzyBetween(anchorLC.angleXY(), this.uMin, this.uMax))\r\n return [];\r\n return this.curve\r\n .isInfosWithLine(new V3(anchorLC.lengthXY(), 0, anchorLC.z), dirLC)\r\n .map((info) => info.tOther);\r\n }\r\n else if (L3.containsPoint(anchorLC.xy(), dirLC.xy(), V3.O)) {\r\n // line goes through Z axis\r\n const dotter = dirLC.xy().unit();\r\n return [\r\n ...this.curve.isInfosWithLine(new V3(dotter.dot(anchorLC), 0, anchorLC.z), new V3(dotter.dot(dirLC), 0, dirLC.z)),\r\n ...this.curve.isInfosWithLine(new V3(-dotter.dot(anchorLC), 0, anchorLC.z), new V3(-dotter.dot(dirLC), 0, dirLC.z)),\r\n ]\r\n .map((info) => info.tOther)\r\n .filter((t) => fuzzyBetween(L3.at(anchorLC, dirLC, t).angleXY(), this.uMin, this.uMax));\r\n }\r\n else if (dirLC.isPerpendicularTo(V3.Z)) {\r\n const secs = this.isCurvesWithPlaneLC(new P3(V3.Z, anchorLC.z));\r\n if (!secs)\r\n return [];\r\n return secs.flatMap((sec) => sec.isInfosWithLine(anchorLC, dirLC).map((info) => info.tOther));\r\n }\r\n else {\r\n // transform into hyperbola\r\n // f(t) = V(((ax + t dx)² + (ay + t dy)²) ** 1/2, 0, az + t dz)\r\n // f(t) = V((ax² + 2 ax t dx + t² dx² + ay² + 2 ay t dy + t² dy²) ** 1/2, 0, az + t dz)\r\n // f(t) = V((t² (dx² + dy²) + 2 t (ax dx + ay dy) + ax² + ay²) ** 1/2, 0, az + t * dz)\r\n // (anchorLC.xy + t * dirLC.xy) * dir.xy = 0\r\n // t * dirLC.xy² = -anchorLC.xy * dirLC.xy\r\n const closestTToZ = -anchorLC.xy().dot(dirLC.xy()) / dirLC.xy().squared();\r\n const closestPointToZ = L3.at(anchorLC, dirLC, closestTToZ);\r\n const scaleX = closestPointToZ.lengthXY();\r\n const lineGradientWC = dirLC.z / dirLC.lengthXY();\r\n const scaleZ = scaleX * lineGradientWC;\r\n const hc = HyperbolaCurve.XY.transform(M4.rotateX(90 * DEG)\r\n .scale(scaleX, 0, scaleZ)\r\n .translate(0, 0, closestPointToZ.z));\r\n const infos = hc.isInfosWithCurve(this.curve);\r\n return infos\r\n .map((info) => (info.p.z - anchorLC.z) / dirLC.z)\r\n .filter((t) => fuzzyBetween(L3.at(anchorLC, dirLC, t).angleXY(), this.uMin, this.uMax));\r\n }\r\n }\r\n isCurvesWithPlaneLC(planeLC) {\r\n if (planeLC.normal1.isParallelTo(V3.Z)) {\r\n return this.curve.isTsWithPlane(planeLC).map((t) => {\r\n const { x: radius } = this.curve.at(t);\r\n return new EllipseCurve(new V3(0, 0, planeLC.w), new V3(radius, 0, 0), new V3(0, radius, 0), this.uMin, this.uMax).transform(this.matrix);\r\n });\r\n }\r\n else if (planeLC.normal1.isPerpendicularTo(V3.Z) &&\r\n planeLC.containsPoint(V3.O)) {\r\n return [\r\n this.curve\r\n .rotateZ(V3.Y.angleRelativeNormal(planeLC.normal1, V3.Z))\r\n .transform(this.matrix),\r\n ];\r\n }\r\n return undefined;\r\n }\r\n isCurvesWithPlane(plane) {\r\n const planeLC = plane.transform(this.matrixInverse);\r\n const planeLCCurves = this.isCurvesWithPlaneLC(planeLC);\r\n if (planeLCCurves) {\r\n return planeLCCurves.map((curve) => curve.transform(this.matrix));\r\n }\r\n else {\r\n return ParametricSurface.isCurvesParametricImplicitSurface(this, new PlaneSurface(plane), 0.05, 0.05, 0.02);\r\n }\r\n }\r\n loopContainsPoint(loop, pWC) {\r\n const pLC = this.matrixInverse.transformPoint(pWC);\r\n const angle = EllipseCurve.XYLCPointT(pLC, this.uMin, this.uMax);\r\n const testCurveLC = EllipseCurve.semicircle(pLC.lengthXY(), new V3(0, 0, pLC.z));\r\n const testCurveWC = testCurveLC.transform(this.matrix);\r\n return Surface.loopContainsPointEllipse(loop, pWC, testCurveWC, angle);\r\n }\r\n isCoplanarTo(surface) {\r\n if (this === surface)\r\n return true;\r\n if (!hasConstructor(surface, RotatedCurveSurface))\r\n return false;\r\n const surfaceLCToThisLC = this.matrixInverse.times(surface.matrix);\r\n assert(!surfaceLCToThisLC.X.xy().likeO());\r\n const zRotation = surfaceLCToThisLC.X.angleXY();\r\n return surface.curve\r\n .transform(M4.rotateZ(-zRotation).times(surfaceLCToThisLC))\r\n .isColinearTo(this.curve);\r\n }\r\n isCurvesWithSurface(surface) {\r\n if (surface instanceof PlaneSurface) {\r\n return this.isCurvesWithPlane(surface.plane);\r\n }\r\n return super.isCurvesWithSurface(surface);\r\n }\r\n containsCurve(curve) {\r\n if (curve.constructor == this.curve.constructor) {\r\n const curveLC = curve.transform(this.matrixInverse);\r\n // find a point on curveLC which isn't on the Z-axis\r\n const t = withMax([0, 0.5, 1].map((x) => lerp(curveLC.tMin, curveLC.tMax, x)), (t) => curveLC.at(t).lengthXY());\r\n const angle = curveLC.at(t).angleXY();\r\n const curveLCRotated = curveLC.rotateZ(-angle);\r\n if (this.curve.isColinearTo(curveLCRotated)) {\r\n return true;\r\n }\r\n }\r\n if (curve instanceof EllipseCurve) {\r\n const curveLC = curve.transform(this.matrixInverse);\r\n if (curveLC.normal.isParallelTo(V3.Z)) {\r\n return (curveLC.isCircular() &&\r\n this.curve.containsPoint(new V3(curveLC.f1.length(), 0, curveLC.center.z)));\r\n }\r\n return false;\r\n }\r\n return super.containsCurve(curve);\r\n }\r\n getExtremePoints() {\r\n return getExtremePointsHelper.call(this, this.curve);\r\n }\r\n asNURBSSurface() {\r\n // y = 0 for baseNURBS\r\n const baseNURBS = NURBS.fromEllipse(this.curve);\r\n const rotationNURBS = NURBS.UnitCircle(2, this.vMin, this.vMax);\r\n return new NURBSSurface(rotationNURBS.points.flatMap((rv) => baseNURBS.points.map((b) => this.matrix.timesVector(VV(rv.x * b.x, rv.y * b.x, b.z * rv.w, rv.w * b.w)))), baseNURBS.knots, rotationNURBS.knots, baseNURBS.degree, rotationNURBS.degree, baseNURBS.tMin, baseNURBS.tMax, rotationNURBS.tMin, rotationNURBS.tMax);\r\n }\r\n}\r\nRotatedCurveSurface.prototype.uStep = EllipseCurve.prototype.tIncrement;\r\nexport function getExtremePointsHelper(curve) {\r\n // this logic comes from EllipseCurve.roots\r\n const f1 = this.matrix.X;\r\n const f2 = this.matrix.Y;\r\n return [0, 1, 2].flatMap((dim) => {\r\n const a = f2.e(dim);\r\n const b = -f1.e(dim);\r\n const xiEtas = eq0(a) && eq0(b) ? [[1, 0]] : intersectionUnitCircleLine2(a, b, 0);\r\n return xiEtas.flatMap(([xi, eta]) => {\r\n const u = Math.atan2(eta, xi);\r\n if (!(lt(this.uMin, u) && lt(u, this.uMax)))\r\n return [];\r\n const testCurve = curve.transform(this.matrix.times(M4.rotateZ(u)));\r\n return testCurve.roots()[dim].map((v) => this.pUV(u, v));\r\n });\r\n });\r\n}\r\n//# sourceMappingURL=RotatedCurveSurface.js.map","import { assert, assertInst, assertVectors, eq0, hasConstructor, M4, pqFormula, TAU, V3, } from \"ts3dutils\";\r\nimport { BezierCurve, EllipseCurve, L3, OUTSIDE, P3, ProjectedCurveSurface, Surface, } from \"..\";\r\nimport { sign } from \"../math\";\r\nexport class CylinderSurface extends ProjectedCurveSurface {\r\n // @ts-ignore\r\n // readonly baseCurve: EllipseCurve\r\n constructor(baseCurve, dir1, uMin = baseCurve.tMin, uMax = baseCurve.tMax, zMin = -Infinity, zMax = Infinity) {\r\n super(baseCurve, dir1, uMin, uMax, zMin, zMax);\r\n this.baseCurve = baseCurve;\r\n assertInst(EllipseCurve, baseCurve);\r\n //assert(!baseCurve.normal1.isPerpendicularTo(dir1), !baseCurve.normal1.isPerpendicularTo(dir1))\r\n this.matrix = M4.forSys(baseCurve.f1, baseCurve.f2, dir1, baseCurve.center);\r\n this.matrixInverse = this.matrix.inversed();\r\n this.normalDir = sign(this.baseCurve.normal.dot(this.dir));\r\n this.pLCNormalWCMatrix = this.matrix\r\n .as3x3()\r\n .inversed()\r\n .transposed()\r\n .scale(this.normalDir);\r\n this.pWCNormalWCMatrix = this.pLCNormalWCMatrix.times(this.matrixInverse);\r\n }\r\n static semicylinder(radius, sMin, sMax, tMin, tMax) {\r\n return new CylinderSurface(new EllipseCurve(V3.O, new V3(radius, 0, 0), new V3(0, radius, 0)), V3.Z, sMin, sMax, tMin, tMax);\r\n }\r\n /**\r\n *\r\n * @param anchorLC\r\n * @param dirLC not necessarily unit\r\n */\r\n static unitISLineTs(anchorLC, dirLC) {\r\n const { x: ax, y: ay } = anchorLC;\r\n const { x: dx, y: dy } = dirLC;\r\n // this cylinder: x² + y² = 1\r\n // line: p = anchorLC + t * dirLC\r\n // split line equation into 3 component equations, insert into cylinder equation\r\n // x = ax + t * dx\r\n // y = ay + t * dy\r\n // (ax² + 2 ax t dx + t²dx²) + (ay² + 2 ay t dy + t²dy²) = 1\r\n // transform to form (a t² + b t + c = 0) and solve with pqFormula\r\n const a = Math.pow(dx, 2) + Math.pow(dy, 2);\r\n const b = 2 * (ax * dx + ay * dy);\r\n const c = Math.pow(ax, 2) + Math.pow(ay, 2) - 1;\r\n return pqFormula(b / a, c / a).filter((t) => EllipseCurve.XYLCValid(new V3(ax + dx * t, ay + dy * t, 0)));\r\n }\r\n normalP(p) {\r\n return this.pLCNormalWCMatrix\r\n .transformVector(this.matrixInverse.transformPoint(p).xy())\r\n .unit();\r\n }\r\n loopContainsPoint(loop, p) {\r\n assertVectors(p);\r\n if (!this.containsPoint(p))\r\n return OUTSIDE;\r\n const line = new L3(p, this.dir.unit());\r\n const lineOut = this.dir.cross(this.normalP(p));\r\n return Surface.loopContainsPointGeneral(loop, p, line, lineOut);\r\n }\r\n isTsForLine(line) {\r\n assertInst(L3, line);\r\n // transforming line manually has advantage that dir1 will not be renormalized,\r\n // meaning that calculated values t for localLine are directly transferable to line\r\n const dirLC = this.matrixInverse.transformVector(line.dir1);\r\n if (dirLC.isParallelTo(V3.Z)) {\r\n // line is parallel to this.dir\r\n return [];\r\n }\r\n const anchorLC = this.matrixInverse.transformPoint(line.anchor);\r\n assert(!CylinderSurface.unitISLineTs(anchorLC, dirLC).length ||\r\n !isNaN(CylinderSurface.unitISLineTs(anchorLC, dirLC)[0]), \"sad \" + dirLC);\r\n return CylinderSurface.unitISLineTs(anchorLC, dirLC);\r\n }\r\n isCoplanarTo(surface) {\r\n return (this == surface ||\r\n (hasConstructor(surface, CylinderSurface) &&\r\n this.dir.isParallelTo(surface.dir) &&\r\n this.containsEllipse(surface.baseCurve, false)));\r\n }\r\n like(surface) {\r\n if (!this.isCoplanarTo(surface))\r\n return false;\r\n // normals need to point in the same direction (outwards or inwards) for both\r\n const thisFacesOut = 0 < this.baseCurve.normal.dot(this.dir);\r\n const objectFacesOut = 0 < surface.baseCurve.normal.dot(surface.dir);\r\n return thisFacesOut == objectFacesOut;\r\n }\r\n containsEllipse(ellipse, checkAABB = true) {\r\n const projEllipse = ellipse.transform(M4.project(this.baseCurve.getPlane(), this.dir));\r\n return this.baseCurve == ellipse || this.baseCurve.isColinearTo(projEllipse);\r\n }\r\n containsCurve(curve) {\r\n if (curve instanceof L3) {\r\n return this.containsLine(curve);\r\n }\r\n else if (curve instanceof EllipseCurve) {\r\n return this.containsEllipse(curve);\r\n }\r\n else if (curve instanceof BezierCurve) {\r\n return false;\r\n }\r\n else {\r\n return super.containsCurve(curve);\r\n }\r\n }\r\n implicitFunction() {\r\n return (pWC) => {\r\n const pLC = this.matrixInverse.transformPoint(pWC);\r\n return (pLC.lengthXY() - 1) * this.normalDir;\r\n };\r\n }\r\n didp(pWC) {\r\n const pLC = this.matrixInverse.transformPoint(pWC);\r\n const pLCLengthXY = pLC.lengthXY();\r\n const didpLC = new V3(pLC.x / pLCLengthXY, pLC.y / pLCLengthXY, 0);\r\n return this.pLCNormalWCMatrix.transformVector(didpLC);\r\n }\r\n containsPoint(pWC) {\r\n const pLC = this.matrixInverse.transformPoint(pWC);\r\n return this.baseCurve.isValidT(EllipseCurve.XYLCPointT(pLC, this.uMin, this.uMax));\r\n }\r\n uvP(pWC) {\r\n assert(arguments.length == 1);\r\n const pLC = this.matrixInverse.transformPoint(pWC);\r\n const u = EllipseCurve.XYLCPointT(pLC, this.vMin, this.vMax);\r\n return new V3(u, pLC.z, 0);\r\n }\r\n isCurvesWithSurface(surface2) {\r\n if (surface2 instanceof ProjectedCurveSurface) {\r\n if (surface2.dir.isParallelTo(this.dir)) {\r\n const projectedCurve = surface2.baseCurve.transform(M4.project(this.baseCurve.getPlane(), this.dir));\r\n return this.baseCurve.isInfosWithCurve(projectedCurve).map((info) => {\r\n const lineDir = sign(this.normalP(info.p)\r\n .cross(surface2.normalP(info.p))\r\n .dot(this.dir)) || 1;\r\n return new L3(info.p, this.dir.times(lineDir));\r\n });\r\n }\r\n }\r\n if (surface2 instanceof CylinderSurface) {\r\n if (eq0(this.getCenterLine().distanceToLine(surface2.getCenterLine()))) {\r\n throw new Error();\r\n }\r\n }\r\n return super.isCurvesWithSurface(surface2);\r\n }\r\n getCenterLine() {\r\n return new L3(this.baseCurve.center, this.dir);\r\n }\r\n facesOutwards() {\r\n return this.baseCurve.normal.dot(this.dir) > 0;\r\n }\r\n getSeamPlane() {\r\n let normal = this.baseCurve.f1.cross(this.dir);\r\n normal = normal.times(-sign(normal.dot(this.baseCurve.f2)));\r\n return P3.normalOnAnchor(normal, this.baseCurve.center);\r\n }\r\n clipCurves(curves) {\r\n return curves.flatMap((curve) => curve.clipPlane(this.getSeamPlane()));\r\n }\r\n}\r\nCylinderSurface.UNIT = new CylinderSurface(EllipseCurve.UNIT, V3.Z, undefined, undefined, 0, 1);\r\nCylinderSurface.prototype.uStep = TAU / 32;\r\nCylinderSurface.prototype.vStep = 256;\r\n//# sourceMappingURL=CylinderSurface.js.map","import { arrayFromFunction, assert, assertf, assertInst, assertNumbers, assertVectors, between, checkDerivate, clamp, eq, eq0, fuzzyBetween, gaussLegendreQuadrature24, getIntervals, getRoots, glqInSteps, hasConstructor, le, lt, M4, MINUS, newtonIterate, NLA_PRECISION, pqFormula, snap, sum, toSource, V, V3, } from \"ts3dutils\";\r\nimport { CylinderSurface, Edge, EllipseCurve, getExtremePointsHelper, L3, P3, ParametricSurface, PICurve, PlaneSurface, PointVsFace, ProjectedCurveSurface, Surface, } from \"..\";\r\nimport { abs, cos, max, min, PI, sign, sin, sqrt } from \"../math\";\r\nclass ArrayExt {\r\n}\r\nexport class EllipsoidSurface extends ParametricSurface {\r\n constructor(center, f1, f2, f3, uMin = 0, uMax = PI, vMin = -PI / 2, vMax = PI / 2) {\r\n super(uMin, uMax, vMin, vMax);\r\n this.center = center;\r\n this.f1 = f1;\r\n this.f2 = f2;\r\n this.f3 = f3;\r\n assert(0 <= uMin && uMin <= PI, uMin);\r\n assert(0 <= uMax && uMax <= PI, uMax);\r\n assert(-PI / 2 <= vMin && vMin <= PI / 2);\r\n assert(-PI / 2 <= vMax && vMax <= PI / 2);\r\n assertVectors(center, f1, f2, f3);\r\n this.matrix = M4.forSys(f1, f2, f3, center);\r\n this.matrixInverse = this.matrix.inversed();\r\n this.normalDir = sign(this.f1.cross(this.f2).dot(this.f3));\r\n this.pLCNormalWCMatrix = this.matrix\r\n .as3x3()\r\n .inversed()\r\n .transposed()\r\n .scale(this.normalDir);\r\n this.pWCNormalWCMatrix = this.pLCNormalWCMatrix.times(this.matrixInverse);\r\n }\r\n static unitArea(contour) {\r\n const totalArea = sum(contour.map((edge) => {\r\n if (edge.curve instanceof PICurve) {\r\n const points = edge.curve.calcSegmentPoints(edge.aT, edge.bT, edge.a, edge.b, edge.aT > edge.bT, true);\r\n let sum = 0;\r\n for (let i = 0; i < points.length - 1; i++) {\r\n const p = points[i], ppp = points[i + 1];\r\n sum += ((abs(p.angleXY()) + abs(ppp.angleXY())) / 2) * (ppp.z - p.z);\r\n }\r\n return sum;\r\n }\r\n else if (edge.curve instanceof EllipseCurve) {\r\n const f = (t) => {\r\n const at = edge.curve.at(t), tangent = edge.curve.tangentAt(t);\r\n const angleXY = abs(at.angleXY());\r\n //const arcLength = angleXY * Math.sqrt(1 - at.z ** 2) ( == at.lengthXY())\r\n //const scaling = tangent.z / at.lengthXY()\r\n return angleXY * tangent.z;\r\n };\r\n const val = glqInSteps(f, edge.aT, edge.bT, 1);\r\n return val;\r\n }\r\n else {\r\n throw new Error();\r\n }\r\n }));\r\n return totalArea;\r\n }\r\n /**\r\n * unit sphere: x² + y² + z² = 1\r\n * line: p = anchor + t * dir |^2\r\n * p² = (anchor + t * dir)^2\r\n * 1 == (anchor + t * dir)^2\r\n * 1 == anchor DOT anchor + 2 * anchor * t * dir + t² * dir DOT dir\r\n */\r\n static unitISTsWithLine(anchor, dir) {\r\n // for 0 = a t² + b t + c\r\n const a = dir.dot(dir);\r\n const b = 2 * anchor.dot(dir);\r\n const c = anchor.dot(anchor) - 1;\r\n return pqFormula(b / a, c / a).filter((t) => le(0, anchor.y + t * dir.y));\r\n }\r\n /**\r\n * unit sphere: x² + y² + z² = 1\r\n * plane: normal1 DOT p = w\r\n */\r\n static unitISCurvesWithPlane(plane) {\r\n const distPlaneCenter = Math.abs(plane.w);\r\n if (lt(distPlaneCenter, 1)) {\r\n // result is a circle\r\n // radius of circle: imagine right angled triangle (origin -> center of intersection circle -> point on\r\n // intersection circle) pythagoras: 1² == distPlaneCenter² + isCircleRadius² => isCircleRadius == sqrt(1 -\r\n // distPlaneCenter²)\r\n const isCircleRadius = Math.sqrt(1 - Math.pow(distPlaneCenter, 2));\r\n const anchorY = plane.normal1.y * plane.w;\r\n const d = abs(distPlaneCenter * isCircleRadius);\r\n if (le(anchorY, -d) && !eq0(distPlaneCenter)) {\r\n return [];\r\n }\r\n else if (le(anchorY, 0) && !plane.normal1.isParallelTo(V3.Y)) {\r\n const f1 = plane.normal1.isParallelTo(V3.Y)\r\n ? V3.Z\r\n : plane.normal1.cross(V3.Y).toLength(isCircleRadius);\r\n const f2 = f1.cross(plane.normal1);\r\n const minEta = -anchorY / f2.y, minT = max(0, Math.asin(minEta));\r\n return [new EllipseCurve(plane.anchor, f1, f2, minT, PI - minT)];\r\n }\r\n else {\r\n const f2 = (plane.normal1.isParallelTo(V3.Y)\r\n ? V3.X\r\n : plane.normal1.cross(V3.Y)).toLength(isCircleRadius);\r\n const f1 = f2.cross(plane.normal1);\r\n const minXi = eq0(f1.y) ? -1 : -anchorY / f1.y, maxT = Math.acos(max(-1, minXi - NLA_PRECISION));\r\n return [\r\n new EllipseCurve(plane.anchor, f1.negated(), f2, PI - maxT, PI),\r\n new EllipseCurve(plane.anchor, f1, f2.negated(), 0, maxT),\r\n ];\r\n }\r\n }\r\n else {\r\n return [];\r\n }\r\n }\r\n static unitISCurvesWithEllipsoidSurface(surface) {\r\n if (surface.isSphere()) {\r\n const surfaceRadius = surface.f1.length();\r\n const surfaceCenterDist = surface.center.length();\r\n if (le(1, surfaceCenterDist - surfaceRadius) ||\r\n le(surfaceCenterDist + surfaceRadius, 1) ||\r\n le(surfaceCenterDist - surfaceRadius, -1)) {\r\n return [];\r\n }\r\n else {\r\n // origin, surface.center and points on the intersection curves form a triangle.\r\n // the height on the segment origin - surface.center is the radius of the is curves\r\n // the distance from the origin to the lot point is the distance to the intersection plane\r\n function heron(a, b, c) {\r\n const p = (a + b + c) / 2;\r\n return sqrt(p * (p - a) * (p - b) * (p - c));\r\n }\r\n const triangleArea = heron(1, surfaceRadius, surfaceCenterDist);\r\n const radius = (triangleArea * 2) / surfaceCenterDist;\r\n const isCurvesCenterDist = sign(1 + Math.pow(surfaceCenterDist, 2) - Math.pow(surfaceRadius, 2)) *\r\n sqrt(1 - Math.pow(radius, 2));\r\n const plane = new P3(surface.center.unit(), isCurvesCenterDist);\r\n return EllipsoidSurface.unitISCurvesWithPlane(plane.flipped());\r\n }\r\n }\r\n throw new Error();\r\n }\r\n static unitISCurvesWithCylinderSurface(surface) {\r\n if (new L3(surface.baseCurve.center, surface.dir).containsPoint(V3.O)) {\r\n const projEllipse = surface.baseCurve.transform(M4.project(new P3(surface.dir, 0)));\r\n const f1Length = projEllipse.f1.length(), f2Length = projEllipse.f2.length();\r\n if (lt(1, min(f1Length, f2Length)))\r\n return [];\r\n if (projEllipse.isCircular()) {\r\n const distISCurveCenter = Math.sqrt(1 - Math.pow(min(1, f1Length), 2));\r\n const isCurveCenter = (surface.dir.y < 0\r\n ? surface.dir.negated()\r\n : surface.dir).times(distISCurveCenter);\r\n // isCurve.at(t).y = isCurveCenter.y + projEllipse.f1.y * cos(t) + projEllipse.f2.y * sin(t) = 0\r\n return [new EllipseCurve(isCurveCenter, projEllipse.f1, projEllipse.f2)];\r\n }\r\n }\r\n throw new Error();\r\n }\r\n static sphere(radius, center = V3.O) {\r\n assertNumbers(radius);\r\n return new EllipsoidSurface(center, new V3(radius, 0, 0), new V3(0, radius, 0), new V3(0, 0, radius));\r\n }\r\n /**\r\n * x²/a² + y²/b² + z²/c² = 1\r\n */\r\n static forABC(a, b, c, center = V3.O) {\r\n return new EllipsoidSurface(center, new V3(a, 0, 0), new V3(0, b, 0), new V3(0, 0, c));\r\n }\r\n static calculateAreaSpheroid(a, b, c, edges) {\r\n assertf(() => a.isPerpendicularTo(b));\r\n assertf(() => b.isPerpendicularTo(c));\r\n assertf(() => c.isPerpendicularTo(a));\r\n // handling discontinuities:\r\n // option 1: check for intersections with baseline, if there are any integrate parts separetely\r\n // \"rotate\" the edge so that there are no overlaps\r\n const matrix = M4.forSys(a, b, c), matrixInverse = matrix.inversed();\r\n const circleRadius = a.length();\r\n const c1 = c.unit();\r\n const totalArea = sum(edges.map((edge) => {\r\n if (edge.curve instanceof EllipseCurve) {\r\n const f = (t) => {\r\n const at = edge.curve.at(t), tangent = edge.tangentAt(t);\r\n const localAt = matrixInverse.transformPoint(at);\r\n const angleXY = localAt.angleXY();\r\n const arcLength = angleXY * circleRadius * Math.sqrt(1 + Math.pow(localAt.z, 2));\r\n const scaling = Math.sqrt(1 + Math.pow(c1.dot(tangent), 2));\r\n return arcLength * scaling;\r\n };\r\n const val = glqInSteps(f, edge.aT, edge.bT, 1);\r\n return val;\r\n }\r\n else {\r\n throw new Error();\r\n }\r\n }));\r\n return totalArea;\r\n }\r\n getConstructorParameters() {\r\n return [\r\n this.center,\r\n this.f1,\r\n this.f2,\r\n this.f3,\r\n this.uMin,\r\n this.uMax,\r\n this.vMin,\r\n this.vMax,\r\n ];\r\n }\r\n equals(obj) {\r\n return (this == obj ||\r\n (Object.getPrototypeOf(obj) == this.constructor.prototype &&\r\n this.matrix.equals(obj.matrix)));\r\n }\r\n edgeLoopCCW(loop) {\r\n return (EllipsoidSurface.unitArea(loop.map((edge) => edge.transform(this.matrixInverse))) > 0);\r\n //let totalAngle = 0\r\n //for (let i = 0; i < contour.length; i++) {\r\n // const ipp = (i + 1) % contour.length\r\n // const edge = contour[i], nextEdge = contour[ipp]\r\n // totalAngle += edge.bDir.angleRelativeNormal(nextEdge.aDir, this.normalP(edge.b))\r\n //}\r\n //return le(0, totalAngle)\r\n }\r\n like(object) {\r\n if (!this.isCoplanarTo(object))\r\n return false;\r\n // normals need to point in the same direction (outwards or inwards) for both\r\n return this.matrix.determinant3() * object.matrix.determinant3() > 0;\r\n }\r\n rootPoints() { }\r\n toMesh() {\r\n return ParametricSurface.prototype.toMesh.call(this);\r\n }\r\n clipCurves(curves) {\r\n return curves.flatMap((curve) => curve.clipPlane(this.getSeamPlane()));\r\n }\r\n dpdu() {\r\n // dp(u, v) = new V3(cos(t) * cos(s), cos(t) * sin(s), sin(t)\r\n return (u, v) => this.matrix.transformVector(new V3(cos(v) * -sin(u), cos(v) * cos(u), 0));\r\n }\r\n dpdv() {\r\n return (u, v) => this.matrix.transformVector(new V3(-sin(v) * cos(u), -sin(v) * sin(u), cos(v)));\r\n }\r\n isCurvesWithPCS(surface) {\r\n let curves2 = ParametricSurface.isCurvesParametricImplicitSurface(surface, this, 0.1, 0.1 / surface.dir.length(), 0.05);\r\n curves2 = this.clipCurves(curves2);\r\n return curves2;\r\n }\r\n isCurvesWithPCSSmart(surface) {\r\n const surfaceLC = surface.transform(this.matrixInverse);\r\n //const lcMinZ0RelO =\r\n const baseCurveLC = surfaceLC.baseCurve.project(new P3(surfaceLC.dir, 0));\r\n const ists = baseCurveLC.isTsWithSurface(EllipsoidSurface.UNIT);\r\n const insideIntervals = getIntervals(ists, baseCurveLC.tMin, baseCurveLC.tMax).filter(([a, b]) => baseCurveLC.at((a + b) / 2).length() < 1);\r\n const projectedCurves = [0, 1].map((id) => {\r\n return (t) => {\r\n const atSqr = snap(baseCurveLC.at(t).squared(), 1);\r\n const lineISTs = /* +- */ sqrt(1 - atSqr);\r\n //assert(!isNaN(lineISTs))\r\n return eq0(lineISTs)\r\n ? baseCurveLC.at(t)\r\n : baseCurveLC\r\n .at(t)\r\n .plus(surfaceLC.dir.times(sign(id - 0.5) * lineISTs));\r\n };\r\n });\r\n const dProjectedCurves = [0, 1].map((id) => {\r\n return (t) => {\r\n // d/dt sqrt(1 - baseCurveLC.at(t).squared())\r\n // = -1/2 * 1/sqrt(1 - baseCurveLC.at(t).squared()) * -2*baseCurveLC.at(t) * baseCurveLC.tangentAt(t)\r\n const atSqr = snap(baseCurveLC.at(t).squared(), 1);\r\n const lineISTs = /* +- */ baseCurveLC\r\n .at(t)\r\n .times(-1 / sqrt(1 - atSqr))\r\n .dot(baseCurveLC.tangentAt(t));\r\n //assert(!isNaN(lineISTs))\r\n return baseCurveLC\r\n .tangentAt(t)\r\n .plus(surfaceLC.dir.times(sign(id - 0.5) * lineISTs));\r\n };\r\n });\r\n //const f2 = t => sqrt(1 - baseCurveLC.at(t).squared())\r\n //const df2 = t => baseCurveLC.at(t).times(-1 / sqrt(1 -\r\n // baseCurveLC.at(t).squared())).dot(baseCurveLC.tangentAt(t)) checkDerivate(f2, df2, 0.31, 0.60)\r\n const curves = [];\r\n for (const [aT, bT] of insideIntervals) {\r\n //const aLine = new L3(baseCurveLC.at(aT), surfaceLC.dir1)\r\n //const a = EllipsoidSurface.UNIT.isTsForLine(aLine).map(t => aLine.at(t))\r\n //const bLine = new L3(baseCurveLC.at(bT), surfaceLC.dir1)\r\n //const b = EllipsoidSurface.UNIT.isTsForLine(bLine).map(t => bLine.at(t))\r\n for (const i of [0, 1]) {\r\n const f = (t) => projectedCurves[i](t).y;\r\n const df = (t) => dProjectedCurves[i](t).y;\r\n checkDerivate(f, df, aT + 0.1, bT - 0.1);\r\n const tsAtY0 = getRoots(f, aT + NLA_PRECISION, bT - NLA_PRECISION, 1 / (1 << 11), df);\r\n const ii2 = getIntervals(tsAtY0, aT, bT).filter(([a, b]) => f((a + b) / 2) > 0);\r\n for (const [aT2, bT2] of ii2) {\r\n let aP = projectedCurves[i](aT2), bP = projectedCurves[i](bT2);\r\n 0 === i && ([aP, bP] = [bP, aP]);\r\n assert(EllipsoidSurface.UNIT.containsPoint(aP));\r\n assert(EllipsoidSurface.UNIT.containsPoint(bP));\r\n curves.push(PICurve.forStartEnd(surface, this, this.matrix.transformPoint(bP), this.matrix.transformPoint(aP), undefined));\r\n }\r\n }\r\n }\r\n return surface.clipCurves(curves);\r\n }\r\n isCurvesWithSurface(surface) {\r\n if (surface instanceof PlaneSurface) {\r\n return this.isCurvesWithPlane(surface.plane);\r\n }\r\n else if (surface instanceof CylinderSurface) {\r\n return this.isCurvesWithCylinderSurface(surface);\r\n }\r\n else if (surface instanceof EllipsoidSurface) {\r\n const surfaceLC = surface.transform(this.matrixInverse);\r\n const curves = EllipsoidSurface.unitISCurvesWithEllipsoidSurface(surfaceLC).map((c) => c.transform(this.matrix));\r\n return surface.clipCurves(curves);\r\n }\r\n else if (surface instanceof ProjectedCurveSurface) {\r\n return this.isCurvesWithPCS(surface);\r\n }\r\n else if (surface instanceof ParametricSurface) {\r\n let curves2 = ParametricSurface.isCurvesParametricImplicitSurface(surface, this, 0.1, 0.1, 0.05);\r\n curves2 = this.clipCurves(curves2);\r\n curves2 = surface.clipCurves(curves2);\r\n return curves2;\r\n }\r\n else {\r\n throw new Error();\r\n }\r\n }\r\n isCurvesWithPlane(plane) {\r\n const planeLC = plane.transform(this.matrixInverse);\r\n return EllipsoidSurface.unitISCurvesWithPlane(planeLC).map((c) => c.transform(this.matrix));\r\n }\r\n isCurvesWithCylinderSurface(surface) {\r\n if (L3.containsPoint(surface.baseCurve.center, surface.dir, this.center)) {\r\n assert(this.isSphere());\r\n const ellipseProjected = surface.baseCurve.transform(M4.project(surface.baseCurve.getPlane(), surface.dir));\r\n if (ellipseProjected.isCircular()) {\r\n const thisRadius = this.f1.length();\r\n const surfaceRadius = ellipseProjected.f1.length();\r\n // sphereRadius² = distanceISFromCenter² + isRadius²\r\n if (eq(thisRadius, surfaceRadius)) {\r\n // return\r\n }\r\n else if (surfaceRadius < thisRadius) {\r\n }\r\n assert(false);\r\n }\r\n }\r\n return this.isCurvesWithPCS(surface);\r\n }\r\n isTsForLine(line) {\r\n assertInst(L3, line);\r\n // transforming line manually has advantage that dir1 will not be renormalized,\r\n // meaning that calculated values t for localLine are directly transferable to line\r\n const anchorLC = this.matrixInverse.transformPoint(line.anchor);\r\n const dirLC = this.matrixInverse.transformVector(line.dir1);\r\n return EllipsoidSurface.unitISTsWithLine(anchorLC, dirLC);\r\n }\r\n isCoplanarTo(surface) {\r\n if (this === surface)\r\n return true;\r\n if (!hasConstructor(surface, EllipsoidSurface))\r\n return false;\r\n if (!this.center.like(surface.center))\r\n return false;\r\n if (this.isSphere())\r\n return surface.isSphere() && eq(this.f1.length(), this.f2.length());\r\n const otherMatrixLC = this.matrixInverse.times(surface.matrix);\r\n // Ellipsoid with matrix otherMatrixLC is unit sphere iff otherMatrixLC is orthogonal\r\n return otherMatrixLC.like3x3() && otherMatrixLC.isOrthogonal();\r\n }\r\n containsEllipse(ellipse) {\r\n const ellipseLC = ellipse.transform(this.matrixInverse);\r\n const distEllipseLCCenter = ellipseLC.center.length();\r\n const correctRadius = Math.sqrt(1 - Math.pow(distEllipseLCCenter, 2));\r\n return (lt(distEllipseLCCenter, 1) &&\r\n ellipseLC.isCircular() &&\r\n ellipseLC.f1.hasLength(correctRadius));\r\n //&& le(0, ellipseLC.getAABB().min.y)\r\n }\r\n containsCurve(curve) {\r\n if (curve instanceof EllipseCurve) {\r\n return this.containsEllipse(curve);\r\n }\r\n else {\r\n return super.containsCurve(curve);\r\n }\r\n }\r\n transform(m4) {\r\n assert(m4.isNoProj(), () => m4.sce);\r\n return new EllipsoidSurface(m4.transformPoint(this.center), m4.transformVector(this.f1), m4.transformVector(this.f2), m4.transformVector(this.f3).times(m4.isMirroring() ? -1 : 1));\r\n }\r\n transform4(m4) {\r\n console.log(\"transform4\");\r\n const resultMatrix = m4.times(this.matrix);\r\n console.log(resultMatrix.toString());\r\n const scaleDir = V(resultMatrix.m[12], resultMatrix.m[13], resultMatrix.m[14]);\r\n // need to find parameters where scaleDir is parallel to the normal\r\n const pLC = this.pLCNormalWCMatrix.inversed().transformPoint(scaleDir);\r\n const s = pLC.angleXY();\r\n const t = Math.asin(clamp(pLC.z, -1, 1));\r\n const fa = resultMatrix.transformPoint(scaleDir.unit());\r\n const fb = resultMatrix.transformPoint(scaleDir.unit().negated());\r\n const newCenter = V3.lerp(fa, fb, 0.5);\r\n console.log(scaleDir.sce, s, t, fa, fb, \"newCenter\", newCenter.sce);\r\n return new EllipsoidSurface(newCenter, m4.transformVector2(this.f1, this.center), m4.transformVector2(this.f2, this.center), m4\r\n .transformVector2(this.f3, this.center)\r\n .times(m4.isMirroring() ? -1 : 1));\r\n }\r\n isInsideOut() {\r\n return this.f1.cross(this.f2).dot(this.f3) < 0;\r\n }\r\n flipped() {\r\n return new EllipsoidSurface(this.center, this.f1, this.f2, this.f3.negated(), this.uMin, this.uMax, -this.vMax, -this.vMin);\r\n }\r\n normalUVFunc() {\r\n // ugh\r\n // paramtric ellipsoid point q(a, b)\r\n // normal1 == (dq(a, b) / da) X (dq(a, b) / db) (cross product of partial derivatives)\r\n // normal1 == cos b * (f2 X f3 * cos b * cos a + f3 X f1 * cos b * sin a + f1 X f2 * sin b)\r\n return (a, b) => {\r\n const { f1, f2, f3 } = this;\r\n const normal = f2\r\n .cross(f3)\r\n .times(Math.cos(b) * Math.cos(a))\r\n .plus(f3.cross(f1).times(Math.cos(b) * Math.sin(a)))\r\n .plus(f1.cross(f2).times(Math.sin(b)))\r\n //.times(Math.cos(b))\r\n .unit();\r\n return normal;\r\n };\r\n }\r\n normalP(p) {\r\n return this.pLCNormalWCMatrix\r\n .transformVector(this.matrixInverse.transformPoint(p))\r\n .unit();\r\n }\r\n normalUV(u, v) {\r\n return this.pLCNormalWCMatrix.transformVector(V3.sphere(u, v)).unit();\r\n }\r\n uvPFunc() {\r\n return (pWC) => {\r\n const pLC = this.matrixInverse.transformPoint(pWC);\r\n const alpha = abs(pLC.angleXY());\r\n const beta = Math.asin(clamp(pLC.z, -1, 1));\r\n assert(isFinite(alpha));\r\n assert(isFinite(beta));\r\n return new V3(alpha, beta, 0);\r\n };\r\n }\r\n pUVFunc() {\r\n // this(a, b) = f1 cos a cos b + f2 sin a cos b + f2 sin b\r\n return (alpha, beta) => {\r\n return this.matrix.transformPoint(V3.sphere(alpha, beta));\r\n };\r\n }\r\n isSphere() {\r\n return (eq(this.f1.length(), this.f2.length()) &&\r\n eq(this.f2.length(), this.f3.length()) &&\r\n eq(this.f3.length(), this.f1.length()) &&\r\n this.f1.isPerpendicularTo(this.f2) &&\r\n this.f2.isPerpendicularTo(this.f3) &&\r\n this.f3.isPerpendicularTo(this.f1));\r\n }\r\n isVerticalSpheroid() {\r\n return (eq(this.f1.length(), this.f2.length()) &&\r\n this.f1.isPerpendicularTo(this.f2) &&\r\n this.f2.isPerpendicularTo(this.f3) &&\r\n this.f3.isPerpendicularTo(this.f1));\r\n }\r\n mainAxes() {\r\n // q(a, b) = f1 cos a cos b + f2 sin a cos b + f3 sin b\r\n // q(s, t, u) = s * f1 + t * f2 + u * f3 with s² + t² + u² = 1\r\n // (del q(a, b) / del a) = f1 (-sin a) cos b + f2 cos a cos b\r\n // (del q(a, b) / del b) = f1 cos a (-sin b) + f2 sin a (-sin b) + f2 cos b\r\n // del q(s, t, u) / del a = -t f1 + s f2\r\n // (del q(a, b) / del a) DOT q(a, b) == 0\r\n // (f1 (-sin a) cos b + f2 cos a cos b) DOT (f1 cos a cos b + f2 sin a cos b + f2 sin b) == 0\r\n // (del q(a, b) / del b) DOT q(a, b) == 0\r\n // (f1 cos a (-sin b) + f2 sin a (-sin b) + f2 cos b) DOT (f1 cos a cos b + f2 sin a cos b + f2 sin b) == 0\r\n // Solve[\r\n // (f1 (-sin a) cos b + f2 cos a cos b) * (f1 cos a cos b + f2 sin a cos b + f2 sin b) = 0,\r\n // (f1 cos a (-sin b) + f2 sin a (-sin b) + f2 cos b) * (f1 cos a cos b + f2 sin a cos b + f2 sin b) = 0}, a, b]\r\n const { f1, f2, f3 } = this;\r\n if (eq0(f1.dot(f2)) && eq0(f2.dot(f3)) && eq0(f3.dot(f1))) {\r\n return this;\r\n }\r\n //const f = ([a, b], x?) => {\r\n // const sinA = Math.sin(a), cosA = Math.cos(a), sinB = Math.sin(b), cosB = Math.cos(b)\r\n // const centerToP = V3.add(f1.times(cosA * cosB), f2.times(sinA * cosB), f3.times(sinB))\r\n // const centerToPdelA = f1.times(-sinA * cosB).plus(f2.times(cosA * cosB))\r\n // const centerToPdelB = V3.add(f1.times(cosA * -sinB), f2.times(sinA * -sinB), f3.times(cosB))\r\n // x && console.log(centerToP.sce, centerToPdelA.sce, centerToPdelB.sce)\r\n // return [centerToP.dot(centerToPdelA), centerToP.dot(centerToPdelB)]\r\n //}\r\n //const mainF1Params = newtonIterate(f, [0, 0], 8), mainF1 = this.pUVFunc()(mainF1Params[0], mainF1Params[1])\r\n //console.log(f(mainF1Params, 1).sce)\r\n //const mainF2Params = newtonIterate(f, this.uvPFunc()(f2.rejectedFrom(mainF1)).toArray(2), 8),\r\n // mainF2 = this.pUVFunc()(mainF2Params[0], mainF2Params[1])\r\n //console.log(this.normalUVFunc()(mainF2Params[0], mainF2Params[1]).sce)\r\n //assert(mainF1.isPerpendicularTo(mainF2), mainF1, mainF2, mainF1.dot(mainF2), mainF1Params)\r\n //const mainF3Params = this.uvPFunc()(mainF1.cross(mainF2)), mainF3 = this.pUVFunc()(mainF3Params[0],\r\n // mainF3Params[1]) return new EllipsoidSurface(this.center, mainF1, mainF2, mainF3)\r\n const { U, SIGMA } = this.matrix.svd3();\r\n assert(SIGMA.isDiagonal());\r\n assert(U.isOrthogonal());\r\n const U_SIGMA = U.times(SIGMA);\r\n // column vectors of U_SIGMA\r\n const [mainF1, mainF2, mainF3] = arrayFromFunction(3, (i) => new V3(U_SIGMA.m[i], U_SIGMA.m[i + 4], U_SIGMA.m[i + 8]));\r\n return new EllipsoidSurface(this.center, mainF1, mainF2, mainF3);\r\n }\r\n containsPoint(p) {\r\n return eq0(this.implicitFunction()(p));\r\n }\r\n boundsFunction() {\r\n return (a, b) => between(a, 0, PI) && between(b, -PI, PI);\r\n }\r\n volume() {\r\n return (4 / 3) * Math.PI * this.f1.dot(this.f2.cross(this.f3));\r\n }\r\n loopContainsPoint(loop, pWC) {\r\n if (!this.containsPoint(pWC))\r\n return PointVsFace.OUTSIDE;\r\n assertVectors(pWC);\r\n assert(Edge.isLoop(loop));\r\n const pLCXY = this.matrixInverse.transformPoint(pWC).xy();\r\n const testLine = new EllipseCurve(this.center, this.f3, pLCXY.likeO() ? this.f2 : this.matrix.transformVector(pLCXY.unit()));\r\n if (P3.normalOnAnchor(this.f2.unit(), this.center).containsPoint(pWC)) {\r\n return loop.some((edge) => edge.curve.containsPoint(pWC) &&\r\n fuzzyBetween(edge.curve.pointT(pWC), edge.minT, edge.maxT))\r\n ? PointVsFace.ON_EDGE\r\n : PointVsFace.OUTSIDE;\r\n }\r\n return Surface.loopContainsPointEllipse(loop, pWC, testLine);\r\n }\r\n surfaceAreaApprox() {\r\n // See https://en.wikipedia.org/wiki/Ellipsoid#Surface_area\r\n const mainAxes = this.mainAxes(), a = mainAxes.f1.length(), b = mainAxes.f2.length(), c = mainAxes.f3.length();\r\n const p = 1.6075;\r\n return (4 *\r\n PI *\r\n Math.pow((Math.pow(a * b, p) + Math.pow(b * c, p) + Math.pow(c * a, p)) / 3, 1 / p));\r\n }\r\n surfaceArea() {\r\n // See https://en.wikipedia.org/wiki/Ellipsoid#Surface_area\r\n const mainAxes = this.mainAxes(), f1l = mainAxes.f1.length(), f2l = mainAxes.f2.length(), f3l = mainAxes.f3.length(), [c, b, a] = [f1l, f2l, f3l].sort(MINUS);\r\n // https://en.wikipedia.org/w/index.php?title=Spheroid&oldid=761246800#Area\r\n function spheroidArea(a, c) {\r\n if (c < a) {\r\n const eccentricity2 = 1 - Math.pow(c, 2) / Math.pow(a, 2);\r\n const eccentricity = Math.sqrt(eccentricity2);\r\n return (2 *\r\n PI *\r\n Math.pow(a, 2) *\r\n (1 +\r\n ((1 - eccentricity2) / Math.sqrt(eccentricity)) *\r\n Math.atanh(eccentricity)));\r\n }\r\n else {\r\n const eccentricity = Math.sqrt(1 - Math.pow(a, 2) / Math.pow(c, 2));\r\n return (2 *\r\n PI *\r\n Math.pow(a, 2) *\r\n (1 + (c / a / eccentricity) * Math.asin(eccentricity)));\r\n }\r\n }\r\n if (eq(a, b)) {\r\n return spheroidArea(a, c);\r\n }\r\n else if (eq(b, c)) {\r\n return spheroidArea(b, a);\r\n }\r\n else if (eq(c, a)) {\r\n return spheroidArea(c, b);\r\n }\r\n const phi = Math.acos(c / a);\r\n const kk = (Math.pow(a, 2) * (Math.pow(b, 2) - Math.pow(c, 2))) / (Math.pow(b, 2) * (Math.pow(a, 2) - Math.pow(c, 2)));\r\n const incompleteEllipticInt1 = gaussLegendreQuadrature24((phi) => Math.pow(1 - kk * Math.pow(Math.sin(phi), 2), -0.5), 0, phi);\r\n const incompleteEllipticInt2 = gaussLegendreQuadrature24((phi) => Math.pow(1 - kk * Math.pow(Math.sin(phi), 2), 0.5), 0, phi);\r\n return ((2 * PI * Math.pow(c, 2) + (2 * PI * a * b) / Math.sin(phi)) *\r\n (incompleteEllipticInt2 * Math.pow(Math.sin(phi), 2) +\r\n incompleteEllipticInt1 * Math.pow(Math.cos(phi), 2)));\r\n }\r\n getSeamPlane() {\r\n const plane = P3.forAnchorAndPlaneVectors(this.center, this.f1, this.f3);\r\n return plane.normal1.dot(this.f2) < 0 ? plane : plane.flipped();\r\n }\r\n getExtremePoints() {\r\n return getExtremePointsHelper.call(this, new EllipseCurve(V3.O, V3.X, V3.Z, -PI / 2, PI / 2));\r\n }\r\n pointFoot(pWC, startS, startT) {\r\n console.log(pWC.sce);\r\n if (undefined === startS || undefined === startT) {\r\n let pLC1 = this.matrixInverse.transformPoint(pWC).unit();\r\n if (pLC1.y < 0)\r\n pLC1 = pLC1.negated();\r\n ({ x: startS, y: startT } = EllipsoidSurface.UNIT.uvP(pLC1));\r\n }\r\n const dpdu = this.dpdu();\r\n const dpdv = this.dpdv();\r\n const [u, v] = newtonIterate(([u, v]) => {\r\n const p = this.pUV(u, v);\r\n console.log([p, p.plus(dpdu(u, v)), p, p.plus(dpdv(u, v))].map(toSource).join() +\r\n \",\");\r\n const pUVToPWC = this.pUV(u, v).to(pWC);\r\n return [pUVToPWC.dot(dpdu(u, v)), pUVToPWC.dot(dpdv(u, v))];\r\n }, [startS, startT], 8, undefined, 0.1);\r\n return new V3(u, v, 0);\r\n }\r\n implicitFunction() {\r\n return (pWC) => {\r\n const pLC = this.matrixInverse.transformPoint(pWC);\r\n return (pLC.length() - 1) * this.normalDir;\r\n };\r\n }\r\n // = this.inverseMatrix.transformPoint(this.inverseMatrix.transformPoint(pWC).unit())\r\n didp(pWC) {\r\n // i(pWC) = this.inverseMatrix.transformPoint(pWC).length() - 1\r\n // chain diff rule\r\n const pLC = this.matrixInverse.transformPoint(pWC);\r\n return this.pLCNormalWCMatrix.transformVector(pLC.unit()); //.times(this.normalDir)\r\n }\r\n /*+\r\n * An ellipsoid remains an ellipsoid after a perspective transform (as long as it does not intersect the vanishing\r\n * plane. This transforms a matrix with a perspective component into one which would return an identical ellipsoid,\r\n * but with no perspective component.\r\n */\r\n static unitTransform4(m) {\r\n m.m[15] !== 1 && (m = m.divScalar(m.m[15]));\r\n // X * P = m => X = m * P^-1\r\n // prettier-ignore\r\n const Pinv = new M4(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -m.m[12], -m.m[13], -m.m[14], 1);\r\n const pn = new V3(m.m[12], m.m[13], m.m[14]), pw = m.m[15];\r\n const pwSqrMinusPnSqr = Math.pow(pw, 2) - pn.squared();\r\n if (lt(pwSqrMinusPnSqr, 0)) {\r\n throw new Error(\"vanishing plane intersects unit sphere\");\r\n }\r\n const c = pn.div(-pwSqrMinusPnSqr);\r\n const scale = pn.times((pw * pn.length()) / (pn.squared() * -pwSqrMinusPnSqr));\r\n const scale1 = pw / -pwSqrMinusPnSqr;\r\n const scale2 = 1 / sqrt(pwSqrMinusPnSqr);\r\n const rotNX = M4.forSys(pn.unit(), pn.getPerpendicular().unit());\r\n return M4.product(m, Pinv, M4.translate(c), rotNX, M4.scale(scale1, scale2, scale2), rotNX.transposed());\r\n }\r\n}\r\nEllipsoidSurface.UNIT = new EllipsoidSurface(V3.O, V3.X, V3.Y, V3.Z);\r\nEllipsoidSurface.prototype.uStep = PI / 32;\r\nEllipsoidSurface.prototype.vStep = PI / 32;\r\n//# sourceMappingURL=EllipsoidSurface.js.map","import { assert, assertInst, callsce, hasConstructor, isCCW, M4, V3, } from \"ts3dutils\";\r\nimport { Edge, ImplicitCurve, L3, P3, ParametricSurface, Surface, } from \"..\";\r\nexport class PlaneSurface extends ParametricSurface {\r\n constructor(plane, right = plane.normal1.getPerpendicular().unit(), up = plane.normal1.cross(right).unit(), uMin = -100, uMax = 100, vMin = -100, vMax = 100) {\r\n super(uMin, uMax, vMin, vMax);\r\n this.plane = plane;\r\n this.right = right;\r\n this.up = up;\r\n assertInst(P3, plane);\r\n assert(this.right.cross(this.up).like(this.plane.normal1));\r\n this.matrix = M4.forSys(right, up, plane.normal1, plane.anchor);\r\n }\r\n toSource(rounder = (x) => x) {\r\n return callsce.call(undefined, \"new PlaneSurface\", ...this.getConstructorParameters());\r\n }\r\n static throughPoints(a, b, c) {\r\n return new PlaneSurface(P3.throughPoints(a, b, c));\r\n }\r\n static forAnchorAndPlaneVectors(anchor, v0, v1, uMin, uMax, vMin, vMax) {\r\n return new PlaneSurface(P3.forAnchorAndPlaneVectors(anchor, v0, v1), v0, v1, uMin, uMax, vMin, vMax);\r\n }\r\n isCoplanarTo(surface) {\r\n return (hasConstructor(surface, PlaneSurface) &&\r\n this.plane.isCoplanarToPlane(surface.plane));\r\n }\r\n isTsForLine(line) {\r\n return line.isTsWithPlane(this.plane);\r\n }\r\n like(surface) {\r\n return (hasConstructor(surface, PlaneSurface) && this.plane.like(surface.plane));\r\n }\r\n pUV(u, v) {\r\n return this.matrix.transformPoint(new V3(u, v, 0));\r\n }\r\n implicitFunction() {\r\n return (p) => this.plane.distanceToPointSigned(p);\r\n }\r\n isCurvesWithSurface(surface2) {\r\n if (surface2 instanceof PlaneSurface) {\r\n return this.isCurvesWithPlane(surface2.plane);\r\n }\r\n return super.isCurvesWithSurface(surface2);\r\n }\r\n isCurvesWithPlane(plane) {\r\n const result = this.plane.intersectionWithPlane(plane);\r\n return result ? [result] : [];\r\n }\r\n edgeLoopCCW(contour) {\r\n assert(Edge.isLoop(contour), \"isLoop\");\r\n return isCCW(contour.flatMap((edge) => edge.points()), this.plane.normal1);\r\n }\r\n loopContainsPoint(loop, p) {\r\n const dir = this.right.plus(this.up.times(0.123)).unit();\r\n const line = new L3(p, dir);\r\n const lineOut = dir.cross(this.plane.normal1);\r\n return Surface.loopContainsPointGeneral(loop, p, line, lineOut);\r\n }\r\n uvPFunc() {\r\n const matrixInverse = this.matrix.inversed();\r\n return function (pWC) {\r\n return matrixInverse.transformPoint(pWC);\r\n };\r\n }\r\n pointFoot(pWC) {\r\n return this.uvP(pWC);\r\n }\r\n normalP(pWC) {\r\n return this.plane.normal1;\r\n }\r\n containsPoint(p) {\r\n return this.plane.containsPoint(p);\r\n }\r\n containsCurve(curve) {\r\n return curve instanceof ImplicitCurve\r\n ? super.containsCurve(curve)\r\n : this.plane.containsCurve(curve);\r\n }\r\n transform(m4) {\r\n return new PlaneSurface(this.plane.transform(m4));\r\n }\r\n transform4(m4) {\r\n return new PlaneSurface(this.plane.transform(m4));\r\n }\r\n flipped() {\r\n return new PlaneSurface(this.plane.flipped(), this.right, this.up.negated());\r\n }\r\n getConstructorParameters() {\r\n return [\r\n this.plane,\r\n this.right,\r\n this.up,\r\n this.uMin,\r\n this.uMax,\r\n this.vMin,\r\n this.vMax,\r\n ];\r\n }\r\n dpdu() {\r\n return () => this.right;\r\n }\r\n dpdv() {\r\n return () => this.up;\r\n }\r\n didp(pWC) {\r\n return this.plane.normal1;\r\n }\r\n normalUV() {\r\n return this.plane.normal1;\r\n }\r\n}\r\nPlaneSurface.prototype.uStep = 1e6;\r\nPlaneSurface.prototype.vStep = 1e6;\r\n//# sourceMappingURL=PlaneSurface.js.map","import { assert, assertInst, assertVectors, hasConstructor, M4, newtonIterate, pqFormula, V3, } from \"ts3dutils\";\r\nimport { Curve, EllipseCurve, ImplicitCurve, ImplicitSurface, L3, ParametricSurface, PlaneSurface, Surface, } from \"..\";\r\nexport class PointProjectedSurface extends ParametricSurface {\r\n constructor(curve, apex, curvePlane, normalDir = 1, uMin = curve.tMin, uMax = curve.tMax, vMin = 0, vMax = 16) {\r\n super(uMin, uMax, vMin, vMax);\r\n this.curve = curve;\r\n this.apex = apex;\r\n this.curvePlane = curvePlane;\r\n this.normalDir = normalDir;\r\n assertInst(Curve, curve);\r\n assert(!(curve instanceof L3), \"use PlaneSurface instead\");\r\n assert(!(curve instanceof EllipseCurve), \"use ConicSurface instead\");\r\n assert(!(curve instanceof ImplicitCurve), \"this just seems like a terrible idea\");\r\n assert(new PlaneSurface(curvePlane).containsCurve(curve));\r\n assertVectors(apex);\r\n assert(0 <= vMin);\r\n this.planeProjectionMatrix = M4.projectPlanePoint(apex, curvePlane);\r\n this.uStep = curve.tIncrement;\r\n }\r\n pointFoot(pWC, startU, startV) {\r\n if (undefined === startU || undefined === startV) {\r\n // similar to stP\r\n if (undefined === startU) {\r\n startU = pWC.like(this.apex)\r\n ? 0\r\n : this.curve.closestTToPoint(this.planeProjectionMatrix.transformPoint(pWC)) * this.normalDir;\r\n }\r\n if (undefined === startV) {\r\n startV = V3.inverseLerp(this.apex, this.curve.at(startU), pWC);\r\n }\r\n }\r\n const f = ([u, v]) => {\r\n const pUVToPWC = this.pUV(u, v).to(pWC);\r\n return [this.dpdu()(u, v).dot(pUVToPWC), this.dpdv()(u).dot(pUVToPWC)];\r\n };\r\n const { 0: x, 1: y } = newtonIterate(f, [startU, startV]);\r\n return new V3(x, y, 0);\r\n }\r\n getConstructorParameters() {\r\n return [\r\n this.curve,\r\n this.apex,\r\n this.curvePlane,\r\n this.normalDir,\r\n this.uMin,\r\n this.uMax,\r\n this.vMin,\r\n this.vMax,\r\n ];\r\n }\r\n static unitISLineTs(anchor, dir) {\r\n const { x: ax, y: ay, z: az } = anchor;\r\n const { x: dx, y: dy, z: dz } = dir;\r\n // this cone: x² + y² = z²\r\n // line: p = anchor + t * dir1\r\n // split line equation into 3 component equations, insert into cone equation\r\n // transform to form (a t² + b t + c = 0) and solve with pqFormula\r\n const a = dx * dx + dy * dy - dz * dz;\r\n const b = 2 * (ax * dx + ay * dy - az * dz);\r\n const c = ax * ax + ay * ay - az * az;\r\n // cone only defined for 0 <= z, so filter invalid values\r\n return pqFormula(b / a, c / a).filter((t) => 0 < az + t * dz);\r\n }\r\n equals(obj) {\r\n return (this == obj ||\r\n (hasConstructor(obj, PointProjectedSurface) &&\r\n this.curve.equals(obj.curve) &&\r\n this.apex.equals(this.apex)));\r\n }\r\n like(object) {\r\n if (!this.isCoplanarTo(object))\r\n return false;\r\n // normals need to point in the same direction (outwards or inwards) for both\r\n return this.normalDir == object.normalDir;\r\n }\r\n loopContainsPoint(contour, p) {\r\n assertVectors(p);\r\n const line = this.apex.like(p)\r\n ? new L3(p, this.apex.to(this.curve.at(this.curve.tMin)).unit())\r\n : L3.throughPoints(p, this.apex);\r\n const lineOut = line.dir1.cross(this.curvePlane.normal1);\r\n return Surface.loopContainsPointGeneral(contour, p, line, lineOut);\r\n }\r\n isTsForLine(line) {\r\n // transforming line manually has advantage that dir1 will not be renormalized,\r\n // meaning that calculated values t for lineLC are directly transferable to line\r\n const anchorPlane = this.planeProjectionMatrix.transformPoint(line.anchor);\r\n const anchor2Plane = this.planeProjectionMatrix.transformPoint(line.anchor.plus(line.dir1));\r\n if (anchorPlane.like(anchor2Plane)) {\r\n // line projects onto a point in plane.\r\n // there are either no or infinite intersection points\r\n return [];\r\n }\r\n return this.curve\r\n .isInfosWithLine(anchorPlane, anchorPlane.to(anchor2Plane), undefined, undefined, line.tMin, line.tMax)\r\n .map((info) => info.tOther);\r\n }\r\n /**\r\n * Interestingly, two cones don't need to have parallel dirs to be coplanar.\r\n */\r\n isCoplanarTo(surface) {\r\n if (this === surface)\r\n return true;\r\n if (!(surface instanceof PointProjectedSurface) ||\r\n !this.apex.like(surface.apex))\r\n return false;\r\n // at this point apexes are equal\r\n return this.containsCurve(surface.curve);\r\n }\r\n containsLine(line) {\r\n if (this.curvePlane.isParallelToLine(line)) {\r\n return false;\r\n }\r\n if (!line.containsPoint(this.apex)) {\r\n return false;\r\n }\r\n const p = this.curvePlane.intersectionWithLine(line);\r\n return this.curve.containsPoint(p);\r\n }\r\n containsCurve(curve) {\r\n if (curve instanceof L3) {\r\n return this.containsLine(curve);\r\n }\r\n else if (!(curve instanceof ImplicitCurve)) {\r\n const otherCurveOnThisPlane = curve.transform(this.planeProjectionMatrix);\r\n return this.curve.isColinearTo(otherCurveOnThisPlane);\r\n }\r\n else {\r\n return super.containsCurve(curve);\r\n }\r\n }\r\n transform(m4) {\r\n return new PointProjectedSurface(this.curve.transform(m4), m4.transformPoint(this.apex), this.curvePlane.transform(m4), (m4.isMirroring() ? -1 : 1) * this.normalDir, this.uMin, this.uMax, this.vMin, this.vMax);\r\n }\r\n flipped() {\r\n return new PointProjectedSurface(this.curve, this.apex, this.curvePlane, -this.normalDir, -this.uMax, -this.uMin, this.vMin, this.vMax);\r\n }\r\n normalUVFunc() {\r\n const dpdv = this.dpdv();\r\n return (u) => this.curve\r\n .tangentAt(u * this.normalDir)\r\n .times(this.normalDir)\r\n .cross(dpdv(u))\r\n .unit();\r\n }\r\n pUVFunc() {\r\n return (u, v) => {\r\n return this.apex.lerp(this.curve.at(u * this.normalDir), v);\r\n };\r\n }\r\n dpdu() {\r\n return (u, v) => {\r\n return this.curve.tangentAt(u * this.normalDir).times(v * this.normalDir);\r\n };\r\n }\r\n dpdv() {\r\n return (u) => {\r\n return this.apex.to(this.curve.at(u * this.normalDir));\r\n };\r\n }\r\n containsPoint(pWC) {\r\n return (this.apex.like(pWC) ||\r\n this.curve.containsPoint(this.planeProjectionMatrix.transformPoint(pWC)));\r\n }\r\n uvP(pWC) {\r\n const u = pWC.like(this.apex)\r\n ? 0\r\n : this.curve.pointT(this.planeProjectionMatrix.transformPoint(pWC));\r\n const v = V3.inverseLerp(this.apex, this.curve.at(u), pWC);\r\n return new V3(u * this.normalDir, v, 0);\r\n }\r\n isCurvesWithSurface(surface) {\r\n if (surface instanceof PlaneSurface) {\r\n return this.isCurvesWithPlane(surface.plane);\r\n }\r\n else if (ImplicitSurface.is(surface)) {\r\n return ParametricSurface.isCurvesParametricImplicitSurface(this, surface, 0.1, 0.1 / this.curvePlane.distanceToPoint(this.apex), 0.02);\r\n }\r\n return super.isCurvesWithSurface(surface);\r\n }\r\n isCurvesWithPlane(plane) {\r\n if (plane.containsPoint(this.apex)) {\r\n if (plane.isParallelToPlane(this.curvePlane)) {\r\n return [];\r\n }\r\n return this.curve\r\n .isTsWithPlane(plane)\r\n .map((t) => L3.throughPoints(this.apex, this.curve.at(t)));\r\n }\r\n return [this.curve.transform(M4.projectPlanePoint(this.apex, plane))];\r\n }\r\n}\r\nPointProjectedSurface.prototype.vStep = 256;\r\n//# sourceMappingURL=PointProjectedSurface.js.map","import { arrayFromFunction, assert, clamp, firstUnsorted, ilog, indexWithMax, lerp, MINUS, newtonIterate, sliceStep, V, V3, Vector, } from \"ts3dutils\";\r\nimport { NURBS, ParametricSurface } from \"..\";\r\nimport { ceil, floor } from \"../math\";\r\nexport class NURBSSurface extends ParametricSurface {\r\n constructor(\r\n /**\r\n * Control points in u-major order. I.e. the first pointCountU points are a NURBS.\r\n */\r\n points, knotsU, knotsV, degreeU, degreeV, uMin = knotsU[degreeU], uMax = knotsU[knotsU.length - degreeU - 1], vMin = knotsV[degreeV], vMax = knotsV[knotsV.length - degreeV - 1]) {\r\n super(uMin, uMax, vMin, vMax);\r\n this.points = points;\r\n this.knotsU = knotsU;\r\n this.knotsV = knotsV;\r\n this.degreeU = degreeU;\r\n this.degreeV = degreeV;\r\n const pointCountU = knotsU.length - 1 - degreeU;\r\n const pointCountV = knotsV.length - 1 - degreeV;\r\n assert(pointCountU * pointCountV == points.length);\r\n assert(degreeU <= degreeV, \"degreeU <= degreeV\");\r\n assert(-1 === firstUnsorted(knotsU, MINUS), \"knot values must be in ascending order\");\r\n assert(-1 === firstUnsorted(knotsV, MINUS), \"knot values must be in ascending order\");\r\n }\r\n getConstructorParameters() {\r\n return [\r\n this.points,\r\n this.knotsU,\r\n this.knotsV,\r\n this.degreeU,\r\n this.degreeV,\r\n this.uMin,\r\n this.uMax,\r\n this.vMin,\r\n this.vMax,\r\n ];\r\n }\r\n transform(m4) {\r\n return this.transform4(m4);\r\n }\r\n transform4(m4) {\r\n return new NURBSSurface(this.points.map((p) => m4.timesVector(p)), this.knotsU, this.knotsV, this.degreeU, this.degreeV, this.uMin, this.uMax, this.vMin, this.vMax);\r\n }\r\n pUV(u, v) {\r\n return this.isoparametricU(u).at(v);\r\n }\r\n dpdu() {\r\n return (u, v) => this.isoparametricV(v).tangentAt(u);\r\n }\r\n dpdv() {\r\n return (u, v) => this.isoparametricU(u).tangentAt(v);\r\n }\r\n normalUV(u, v) {\r\n const normal = this.dpdu()(u, v).cross(this.dpdv()(u, v));\r\n return normal.likeO() ? V3.X : normal.unit();\r\n }\r\n isoparametricU(u) {\r\n const pointCountU = this.knotsU.length - 1 - this.degreeU;\r\n const pointCountV = this.knotsV.length - 1 - this.degreeV;\r\n return new NURBS(arrayFromFunction(pointCountV, (i) => {\r\n return deBoor(this.points.slice(i * pointCountU, (i + 1) * pointCountU), this.degreeU, this.knotsU, u);\r\n }), this.degreeV, this.knotsV, this.vMin, this.vMax);\r\n }\r\n isoparametricV(v) {\r\n const pointCountU = this.knotsU.length - 1 - this.degreeU;\r\n return new NURBS(arrayFromFunction(pointCountU, (i) => {\r\n return deBoor(sliceStep(this.points, i, this.points.length, pointCountU, 1), this.degreeV, this.knotsV, v);\r\n }), this.degreeU, this.knotsU, this.uMin, this.uMax);\r\n }\r\n debugInfo() {\r\n const pointCountU = this.knotsU.length - 1 - this.degreeU;\r\n const pointCountV = this.knotsV.length - 1 - this.degreeV;\r\n const grid = [];\r\n for (let u = 0; u < pointCountU; u++) {\r\n for (let v = 0; v < pointCountV; v++) {\r\n const i = v * pointCountU + u;\r\n if (u < pointCountU - 1) {\r\n const j = v * pointCountU + u + 1;\r\n grid.push(this.points[i].p3(), this.points[j].p3());\r\n }\r\n if (v < pointCountV - 1) {\r\n const j = (v + 1) * pointCountU + u;\r\n grid.push(this.points[i].p3(), this.points[j].p3());\r\n }\r\n }\r\n }\r\n return { points: this.points.map((p) => p.p3()), lines: grid };\r\n }\r\n flipped() {\r\n const pointCountU = this.knotsU.length - 1 - this.degreeU;\r\n return new NURBSSurface(arrayFromFunction(this.points.length, (i) => {\r\n const u = i % pointCountU;\r\n return this.points[i - u + (pointCountU - u - 1)];\r\n }), this.knotsU.map((x) => -x).reverse(), this.knotsV, this.degreeU, this.degreeV, -this.uMax, -this.uMin, this.vMin, this.vMax);\r\n }\r\n isCoplanarTo(surface) {\r\n throw new Error(\"not implemented\");\r\n }\r\n isTsForLine(line) {\r\n // intersect line with\r\n const startT = 4;\r\n // Once we have a starting t param, there are two options:\r\n // 1. 1-D Newton iterate on (t) -> (distanceFromSurface)\r\n // 2. 3-D Newton iterate on (u, v, t) -> this.pUV(u, v).to(line.at(t))\r\n // Let's go with 2, because 1 will require doing a nested newton iteration.\r\n const [startU, startV] = this.pointFoot(line.at(startT));\r\n const [, , t] = newtonIterate(([u, v, t]) => {\r\n console.log(\"uvt\", u, v, t);\r\n const lineP = line.at(t);\r\n return ilog(this.pUV(u, v).to(lineP).toArray());\r\n }, [startU, startV, startT], 8);\r\n return [t];\r\n }\r\n pointFoot(pWC, startU, startV) {\r\n const closestPointIndex = indexWithMax(this.points, (p) => -p.p3().distanceTo(pWC));\r\n const pointCountU = this.knotsU.length - this.degreeU - 1;\r\n const closestPointPos = V(closestPointIndex % pointCountU, (closestPointIndex / pointCountU) | 0);\r\n const start = this.guessUVForMeshPos(closestPointPos.x, closestPointPos.y);\r\n const dpdu = this.dpdu();\r\n const dpdv = this.dpdv();\r\n try {\r\n const [u, v] = newtonIterate(([u, v]) => {\r\n // console.log(\"u,v\", u, v)\r\n const pUV = this.pUV(u, v);\r\n const pUVToPWC = pUV.to(pWC);\r\n return [pUVToPWC.dot(dpdu(u, v)), pUVToPWC.dot(dpdv(u, v))];\r\n }, [start.x, start.y], 16);\r\n return new V3(u, v, 0);\r\n }\r\n catch (e) {\r\n return undefined;\r\n }\r\n }\r\n isCurvesWithPlane(plane) {\r\n throw new Error(\"Method not implemented.\");\r\n }\r\n containsPoint(pWC) {\r\n const foot = this.pointFoot(pWC);\r\n return foot && this.pUV(foot.x, foot.y).like(pWC);\r\n }\r\n loopContainsPoint(contour, point) {\r\n throw new Error(\"Method not implemented.\");\r\n }\r\n guessUVForMeshPos(x, y) {\r\n function eLerp(arr, t, lerp) {\r\n if (0 === t % 1)\r\n return arr[t];\r\n return lerp(arr[floor(t)], arr[ceil(t)], t % 1);\r\n }\r\n return new V3(clamp(eLerp(this.knotsU, x + (this.degreeU + 1) / 2, lerp), this.uMin, this.uMax), clamp(eLerp(this.knotsV, y + (this.degreeV + 1) / 2, lerp), this.vMin, this.vMax), 0);\r\n }\r\n}\r\nNURBSSurface.prototype.uStep = 1 / 8;\r\nNURBSSurface.prototype.vStep = 1 / 8;\r\nfunction getInterval(degree, knots, t) {\r\n for (let s = degree; s < knots.length - 1 - degree; s++) {\r\n if (t >= knots[s] && t <= knots[s + 1]) {\r\n return s;\r\n }\r\n }\r\n throw new Error(t + \" \" + knots);\r\n}\r\nfunction deBoor(points, degree, knots, t) {\r\n // find s (the spline segment) for the [t] value provided\r\n const s = getInterval(degree, knots, t);\r\n const v = Vector.pack(points, new Float64Array(points.length * 4));\r\n // l (level) goes from 1 to the curve degree + 1\r\n for (let l = 1; l <= degree; l++) {\r\n // build level l of the pyramid\r\n for (let i = s; i > s - degree - 1 + l; i--) {\r\n const alpha = (t - knots[i]) / (knots[i + degree + 1 - l] - knots[i]);\r\n // interpolate each component\r\n for (let d = 0; d < 4; d++) {\r\n v[i * 4 + d] = (1 - alpha) * v[(i - 1) * 4 + d] + alpha * v[i * 4 + d];\r\n }\r\n }\r\n }\r\n return new Vector(v.slice(s * 4, s * 4 + 4));\r\n}\r\n//# sourceMappingURL=NURBSSurface.js.map","import { assert, gaussLegendre24Weights, gaussLegendre24Xs, gaussLegendreQuadrature24, glqInSteps, M4, sum, V, V3, } from \"ts3dutils\";\r\nimport { ConicSurface, EllipseCurve, EllipsoidSurface, HyperbolaCurve, ImplicitCurve, L3, ParabolaCurve, ParametricSurface, PlaneSurface, ProjectedCurveSurface, RotatedCurveSurface, } from \"../index\";\r\nimport { cos, sin } from \"../math\";\r\n/**\r\n * In general: the z-dir shadow volume of a face is the integral: SURFACE_INTEGRAL[p in face] (normal(p).z * p.z) dp\r\n * In general: the centroid of the z-dir shadow volume of a face is the integral:\r\n * SURFACE_INTEGRAL[p in face] ((p schur (1, 1, 0.5)) * normal(p).z * p.z) dp\r\n * dividing the z component by 2 is usually done at the very end\r\n */\r\nexport const ZDirVolumeVisitor = {\r\n [ConicSurface.name](edges) {\r\n console.log(this);\r\n const dpdu = this.dpdu();\r\n const dpdv = this.dpdv();\r\n // INT[edge.at; edge.bT] (at(t) DOT dir) * (at(t) - at(t).projectedOn(dir) / 2).z dt\r\n const totalVolume = sum(edges.map((edgeWC) => {\r\n const curveWC = edgeWC.curve;\r\n if (curveWC instanceof EllipseCurve ||\r\n curveWC instanceof HyperbolaCurve ||\r\n curveWC instanceof ParabolaCurve) {\r\n const f = (curveT) => {\r\n const at = curveWC.at(curveT), tangentWC = curveWC.tangentAt(curveT);\r\n const uvOfPWC = this.uvP(at);\r\n // INTEGRATE [0; atUV.y] (dpdu(atUV.x, t) X dpdv(atUV.x)).z * pUV(atUV.x, t).z dt\r\n // dpdu(u, v) === t * dpdu(s, 1)\r\n // => INTEGRATE [0; atUV.y] (t * dpdu(atUV.x, 1) X dpdv(atUV.x)).z * pUV(atUV.x, t).z dt\r\n // => (dpdu(atUV.x, 1) X dpdv(atUV.x)).z * INTEGRATE [0; atUV.y] t * pUV(atUV.x, t).z dt\r\n // pUV(u, v) === t * (pUV(s, 1) - center) + center\r\n // => (dpdu(atUV.x, 1) X dpdv(atUV.x)).z\r\n // * INTEGRATE [0; atUV.y] t² * (pUV(atUV.x, t) - center).z + t * center.z dt\r\n // => (dpdu(atUV.x, 1) X dpdv(atUV.x)).z\r\n // * INTEGRATE [0; atUV.y] t² * (pUV(atUV.x, t) - center).z + t * center.z dt\r\n // => (dpdu(atUV.x, 1) X dpdv(atUV.x)).z\r\n // * (1/3 t³ pUV(atUV.x, 1).z + 1/2 t² center.z)[0; atUV.y]\r\n const du = -M4.forSys(dpdu(uvOfPWC.x, uvOfPWC.y), dpdv(uvOfPWC.x))\r\n .inversed()\r\n .transformVector(tangentWC).x;\r\n const factor = (Math.pow(uvOfPWC.y, 3) / 3) *\r\n (this.pUV(uvOfPWC.x, 1).z - this.center.z) +\r\n (Math.pow(uvOfPWC.y, 2) / 2) * this.center.z;\r\n const actual = dpdu(uvOfPWC.x, factor).cross(dpdv(uvOfPWC.x)).z;\r\n return actual * du;\r\n };\r\n const val = glqInSteps(f, edgeWC.aT, edgeWC.bT, 1);\r\n return val;\r\n }\r\n else if (curveWC instanceof L3) {\r\n return 0;\r\n }\r\n else {\r\n throw new Error();\r\n }\r\n }));\r\n const centroidZX2Parts = edges.map((edgeWC) => {\r\n const curveWC = edgeWC.curve;\r\n if (curveWC instanceof EllipseCurve ||\r\n curveWC instanceof HyperbolaCurve ||\r\n curveWC instanceof ParabolaCurve) {\r\n const f = (curveT) => {\r\n const at = curveWC.at(curveT), tangentWC = curveWC.tangentAt(curveT);\r\n const uvOfPWC = this.uvP(at);\r\n // INTEGRATE [0; atUV.y] dpdu(atUV.x, t) X dpdv(atUV.x, t) * pUV(atUV.x, t).z dt\r\n // dpdv is constant with respect to t\r\n // => (dpdu(atUV.x, t) X dpdv(atUV.x, t)).z\r\n // * (INTEGRATE [0; atUV.y] t * pUV(atUV.x, t) * pUV(atUV.x, t).z dt)\r\n // dpdu(u, v) === t * dpdu(s, 1)\r\n // pUV(u, v) === t * (pUV(s, 1) - center) + center\r\n // INTEGRATE [0; atUV.y] t * pUV(atUV.x, t) * pUV(atUV.x, t).z dt\r\n // = INTEGRATE [0; atUV.y] t *\r\n // (t * (pUV(s, 1) - center) + center) *\r\n // (t (pUV(s, 1) - center).z + center.z) dt\r\n // = INTEGRATE [0; atUV.y] t³ (pUV(s, 1) - center) * (pUV(s, 1) - center).z\r\n // + t² ((pUV(s, 1) - center) * center.z + (pUV(s, 1) - center).z * center)\r\n // + t center center.z dt\r\n // = (1/4 t^4 (pUV(s, 1) - center) * (pUV(s, 1) - center).z\r\n // (1/3 t³ ((pUV(s, 1) - center) * center.z + (pUV(s, 1) - center).z * center)\r\n // (1/2 t² center center.z dt)[0; atUV.y]\r\n const pUVS1V = this.pUV(uvOfPWC.x, 1).minus(this.center);\r\n const factor = V3.add(pUVS1V.times((1 / 4) * Math.pow(uvOfPWC.y, 4) * pUVS1V.z +\r\n (1 / 3) * Math.pow(uvOfPWC.y, 3) * this.center.z), this.center.times((1 / 3) * Math.pow(uvOfPWC.y, 3) * pUVS1V.z +\r\n (1 / 2) * Math.pow(uvOfPWC.y, 2) * this.center.z));\r\n const partialCentroid = factor.times(dpdu(uvOfPWC.x, 1).cross(dpdv(uvOfPWC.x)).z);\r\n const ds = -M4.forSys(dpdu(uvOfPWC.x, uvOfPWC.y), dpdv(uvOfPWC.x))\r\n .inversed()\r\n .transformVector(tangentWC).x;\r\n return partialCentroid.times(ds);\r\n };\r\n return glqV3(f, edgeWC.aT, edgeWC.bT);\r\n }\r\n else if (curveWC instanceof L3) {\r\n return V3.O;\r\n }\r\n else {\r\n throw new Error();\r\n }\r\n });\r\n const centroid = V3.add(...centroidZX2Parts)\r\n .schur(new V3(1, 1, 0.5))\r\n .div(totalVolume);\r\n return { volume: totalVolume, centroid: centroid };\r\n },\r\n [PlaneSurface.name](edges) {\r\n const r1 = this.right;\r\n const u1 = this.up;\r\n const c = this.plane.anchor;\r\n assert(r1.hasLength(1));\r\n assert(u1.hasLength(1));\r\n assert(r1.isPerpendicularTo(u1));\r\n const volumeAndCentroidZX2Parts = edges.map((edgeWC) => {\r\n const curveWC = edgeWC.curve;\r\n if (curveWC instanceof L3) {\r\n // split shadow volume into two triangle shadow volumes and use the same logic as for mesh triangles:\r\n function triangleShadowVolumeAndCentroid(a, b, c) {\r\n const ab = b.minus(a), ac = c.minus(a);\r\n const normal = ab.cross(ac);\r\n const faceCentroid = V3.add(a, b, c).div(3);\r\n return [\r\n (faceCentroid.z * normal.z) / 2,\r\n V3.add(a.times(2 * a.z + b.z + c.z), b.times(a.z + 2 * b.z + c.z), c.times(a.z + b.z + 2 * c.z)).times(normal.z),\r\n ];\r\n }\r\n const a = edgeWC.a, b = edgeWC.b;\r\n const as = a.dot(r1);\r\n const bs = b.dot(r1);\r\n const aBase = this.pUV(as, 0);\r\n const bBase = this.pUV(bs, 0);\r\n const [v1, c1] = triangleShadowVolumeAndCentroid(a, b, aBase);\r\n const [v2, c2] = triangleShadowVolumeAndCentroid(bBase, aBase, b);\r\n return [v1 + v2, c1.plus(c2).div(24)];\r\n }\r\n else if (curveWC instanceof ImplicitCurve) {\r\n throw new Error();\r\n }\r\n else {\r\n const sliceAreaAndCentroidZX2TimesDs = (curveT) => {\r\n const p = curveWC.at(curveT);\r\n const s = p.dot(r1);\r\n const t = p.dot(u1);\r\n const area = t * c.z + s * t * r1.z + (1 / 2) * Math.pow(t, 2) * u1.z;\r\n const ds = -curveWC.tangentAt(curveT).dot(r1);\r\n return [\r\n area * ds,\r\n ...V3.add(c.times(area), r1.times(c.z * s * t + r1.z * Math.pow(s, 2) * t + (1 / 2) * s * Math.pow(t, 2) * u1.z), u1.times((1 / 2) * c.z * Math.pow(t, 2) +\r\n (1 / 2) * r1.z * s * Math.pow(t, 2) +\r\n (1 / 3) * Math.pow(t, 3) * u1.z)).times(ds),\r\n ];\r\n };\r\n const [vol, cx, cy, cz] = glqArray(sliceAreaAndCentroidZX2TimesDs, edgeWC.aT, edgeWC.bT, 4);\r\n return [\r\n vol * this.plane.normal1.z,\r\n new V3(cx, cy, cz).times(this.plane.normal1.z),\r\n ];\r\n }\r\n });\r\n return mergeVolumeAndCentroidZX2Parts(volumeAndCentroidZX2Parts);\r\n },\r\n /**\r\n * Generic implementation.\r\n */\r\n [ParametricSurface.name](edges) {\r\n const dpdu = this.dpdu();\r\n const dpdv = this.dpdv();\r\n const volume = edges.map((edgeWC) => {\r\n const curveWC = edgeWC.curve;\r\n if (curveWC instanceof ImplicitCurve) {\r\n throw new Error();\r\n }\r\n else {\r\n const sliceAreaAndCentroidZX2TimesDs = (curveT) => {\r\n // use curve.tangent not edge.tangent, reverse edges are handled by the integration boundaries\r\n const pWC = curveWC.at(curveT), tangentWC = curveWC.tangentAt(curveT);\r\n const uvOfPWC = this.uvP(pWC);\r\n const slice = (t) => {\r\n const p = this.pUV(uvOfPWC.x, t);\r\n const normal = dpdu(uvOfPWC.x, t).cross(dpdv(uvOfPWC.x, t));\r\n return p.z * normal.z;\r\n };\r\n const sliceIntegral0ToPWCT = glqInSteps(slice, 0, uvOfPWC.y, 1);\r\n // const dt = tangentWC.dot(scalingVector)\r\n const dt = -M4.forSys(dpdu(uvOfPWC.x, uvOfPWC.y), dpdv(uvOfPWC.x, uvOfPWC.y))\r\n .inversed()\r\n .transformVector(tangentWC).x;\r\n const sliceAreaTimesDs = sliceIntegral0ToPWCT * dt;\r\n const slice2 = (t) => {\r\n const p = this.pUV(uvOfPWC.x, t);\r\n const normal = dpdu(uvOfPWC.x, t).cross(dpdv(uvOfPWC.x, t));\r\n return p.times(p.z * normal.z);\r\n };\r\n const sliceIntegral0ToPWCT2 = glqV3(slice2, 0, uvOfPWC.y);\r\n // const dt = tangentWC.dot(scalingVector)\r\n const sliceCentroidZX2TimesDs = sliceIntegral0ToPWCT2.times(dt);\r\n return [sliceAreaTimesDs, ...sliceCentroidZX2TimesDs.toArray()];\r\n };\r\n const [vol, cx, cy, cz] = glqArray(sliceAreaAndCentroidZX2TimesDs, edgeWC.aT, edgeWC.bT, 4);\r\n return [vol, new V3(cx, cy, cz)];\r\n }\r\n });\r\n return mergeVolumeAndCentroidZX2Parts(volume);\r\n },\r\n /**\r\n * at(t)\r\n * |\\ ^\r\n * | \\ at(t).projectedOn(dir1) \\ dir1\r\n * | \\ \\\r\n * | \\ at(t).rejectedFrom(dir1) = b\r\n * | |\r\n * |___|\r\n * z = 0\r\n *\r\n *\r\n * A = ((at(t) + at(t).rejectedFrom(dir1)) / 2).z * at(t).projectedOn(dir1).lengthXY()\r\n * scaling = tangentAt(t) DOT dir1.cross(V3.Z).unit()\r\n */\r\n [ProjectedCurveSurface.name](edges) {\r\n if (V3.Z.cross(this.dir).likeO())\r\n return { volume: 0, centroid: V3.O };\r\n // normalize this.dir so it always points up\r\n const upDir1 = this.dir.toLength(Math.sign(this.dir.z) || 1);\r\n const scalingVector = V3.Z.cross(upDir1).unit();\r\n // the length of the base of the trapezoid is calculated by dotting with the baseVector\r\n const baseVector = upDir1.rejectedFrom(V3.Z).unit();\r\n // INT[edge.at; edge.bT] (at(t) DOT dir1) * (at(t) - at(t).projectedOn(dir) / 2).z\r\n const volume = edges.map((edgeWC) => {\r\n if (edgeWC.curve instanceof L3) {\r\n return [0, V3.O];\r\n }\r\n else if (edgeWC.curve instanceof ImplicitCurve) {\r\n return [0, V3.O];\r\n // \tconst { points, tangents } = edgeWC.curve\r\n // \tconst minT = edgeWC.minT,\r\n // \t\tmaxT = edgeWC.maxT\r\n // \tlet sum = 0\r\n // \tconst start = Math.ceil(minT + NLA_PRECISION)\r\n // \tconst end = Math.floor(maxT - NLA_PRECISION)\r\n // \tfor (let i = start; i <= end; i++) {\r\n // \t\tconst at = points[i],\r\n // \t\t\ttangent = tangents[i]\r\n // \t\tconst area = (at.z + at.rejectedFrom1(upDir1).z) / 2 * at.projectedOn(upDir1).dot(baseVector)\r\n // \t\tconst scale = tangent.dot(scalingVector)\r\n // \t\tsum += area * scale\r\n // \t}\r\n // \tconst f = (t: number) => {\r\n // \t\tconst at = edgeWC.curve.at(t),\r\n // \t\t\ttangent = edgeWC.curve.tangentAt(t)\r\n // \t\tconst area = (at.z + at.rejectedFrom1(upDir1).z) / 2 * at.projectedOn(upDir1).dot(baseVector)\r\n // \t\tconst scale = tangent.dot(scalingVector)\r\n // \t\treturn area * scale\r\n // \t}\r\n // \tsum += f(minT) * (start - minT - 0.5)\r\n // \tsum += f(maxT) * (maxT - end - 0.5)\r\n // \treturn sum * Math.sign(edgeWC.deltaT())\r\n }\r\n else {\r\n const f = (curveT) => {\r\n // use curve.tangent not edge.tangent, reverse edges are handled by the integration boundaries\r\n const at = edgeWC.curve.at(curveT), tangent = edgeWC.curve.tangentAt(curveT);\r\n const b = at.rejectedFrom1(upDir1);\r\n const area = (at.z * b.to(at).dot(baseVector)) / 2 +\r\n (b.z * b.to(at).dot(baseVector)) / 2;\r\n const areaCentroidA = V3.add(at.xy(), b, at).times((at.z * b.to(at).dot(baseVector)) / 2 / 3);\r\n const areaCentroidB = V3.add(at.xy(), b, b.xy()).times((b.z * b.to(at).dot(baseVector)) / 2 / 3);\r\n const scale = tangent.dot(scalingVector);\r\n return [\r\n area * scale,\r\n ...areaCentroidA.plus(areaCentroidB).times(scale).schur(V(1, 1, 2)),\r\n ];\r\n };\r\n const [vol, cx, cy, cz] = glqArray(f, edgeWC.aT, edgeWC.bT, 4);\r\n return [vol, new V3(cx, cy, cz)];\r\n }\r\n });\r\n return mergeVolumeAndCentroidZX2Parts(volume);\r\n },\r\n // volume does scale linearly, so this could be done in the local coordinate system\r\n // however, shear matrices lead to point-to-plane distances having to be calculated along a vector other than\r\n // the plane normal\r\n [RotatedCurveSurface.name](edges) {\r\n const dpdu = this.dpdu();\r\n const dpdv = this.dpdv();\r\n const totalVolume = sum(edges.map((edgeWC) => {\r\n const curveWC = edgeWC.curve;\r\n const f = (curveT) => {\r\n const pWC = curveWC.at(curveT), tangentWC = curveWC.tangentAt(curveT);\r\n const uvOfPWC = this.uvP(pWC);\r\n const pLC = this.matrixInverse.transformPoint(pWC);\r\n const dpdvAtS0 = this instanceof RotatedCurveSurface\r\n ? this.curve.tangentAt(uvOfPWC.y)\r\n : V(-pLC.z, 0, pLC.lengthXY());\r\n // const slice = (phi: number) => {\r\n // \tconst p = this.pUV(phi, uvOfPWC.y)\r\n // \tconst normal = dpdu(phi, uvOfPWC.y).cross(dpdv(phi, uvOfPWC.y))\r\n // \treturn p.z * normal.z\r\n // }\r\n // const z = this.curve.at(uvOfPWC.y).z\r\n // const r = this.curve.at(uvOfPWC.y).lengthXY()\r\n // const pz =\r\n // \tthis.f1.z * r * cos(s) +\r\n // \tthis.f2.z * r * sin(s) +\r\n // \tthis.f3.z * z +\r\n // \tthis.center.z\r\n // const dpdux = this.f1.x * r * -sin(s) + this.f2.x * r * cos(s)\r\n // const dpduy = this.f1.y * r * -sin(s) + this.f2.y * r * cos(s)\r\n // const dpdvx = this.f1.x * dr * cos(s) + this.f2.x * dr * sin(s) + this.f3.x * dz\r\n // const dpdvy = this.f1.y * dr * cos(s) + this.f2.y * dr * sin(s) + this.f3.y * dz\r\n // const normalz = dpdux * dpdvy - dpduy * dpdvx\r\n // result = pz * normalz\r\n const r = pLC.lengthXY(), z = pLC.z;\r\n const dr = dpdvAtS0.x;\r\n const dz = dpdvAtS0.z;\r\n const a = this.matrix.X.z * r, b = this.matrix.Y.z * r, c = this.matrix.Z.z * z + this.matrix.O.z;\r\n const t0 = (this.matrix.X.x * this.matrix.Y.y -\r\n this.matrix.X.y * this.matrix.Y.x) *\r\n r *\r\n dr;\r\n const t1 = (this.matrix.Y.x * this.matrix.X.y -\r\n this.matrix.Y.y * this.matrix.X.x) *\r\n r *\r\n dr;\r\n const t2 = (this.matrix.X.x * this.matrix.X.y -\r\n this.matrix.X.y * this.matrix.X.x) *\r\n r *\r\n dr;\r\n const t3 = (this.matrix.Y.x * this.matrix.Y.y -\r\n this.matrix.Y.y * this.matrix.Y.x) *\r\n r *\r\n dr;\r\n const t4 = (this.matrix.Y.x * this.matrix.Z.y -\r\n this.matrix.Y.y * this.matrix.Z.x) *\r\n r *\r\n dz;\r\n const t5 = (this.matrix.X.x * this.matrix.Z.y -\r\n this.matrix.X.y * this.matrix.Z.x) *\r\n r *\r\n dz;\r\n const sliceIntegral = (p) => {\r\n return ((6 * (c * (-t0 + t1) + a * t4 - b * t5) * p +\r\n 3 *\r\n (3 * b * t0 - b * t1 + a * (t2 - t3) + 4 * c * t5) *\r\n cos(p) +\r\n 3 *\r\n (3 * a * t1 - a * t0 - b * (t2 - t3) + 4 * c * t4) *\r\n sin(p) +\r\n 3 * (a * t5 - b * t4 + c * (t2 - t3)) * cos(2 * p) +\r\n 3 * (a * t4 + b * t5 + c * (t0 + t1)) * sin(2 * p) +\r\n (a * (t2 - t3) - b * (t0 + t1)) * cos(3 * p) +\r\n (a * (t0 + t1) + b * (t2 - t3)) * sin(3 * p)) /\r\n 12);\r\n };\r\n const dt = M4.forSys(dpdu(uvOfPWC.x, uvOfPWC.y), dpdv(uvOfPWC.x, uvOfPWC.y))\r\n .inversed()\r\n .transformVector(tangentWC).y;\r\n const sliceIntegral0ToPWCS = sliceIntegral(uvOfPWC.x); //- sliceIntegral(0) //(always 0)\r\n const result = sliceIntegral0ToPWCS * dt;\r\n return result;\r\n };\r\n return gaussLegendreQuadrature24(f, edgeWC.aT, edgeWC.bT);\r\n }));\r\n // calc centroid:\r\n const centroidZX2Parts = edges.map((edgeWC) => {\r\n const f = (curveT) => {\r\n const curveWC = edgeWC.curve;\r\n const pWC = curveWC.at(curveT), tangentWC = curveWC.tangentAt(curveT);\r\n const uvOfPWC = this.uvP(pWC);\r\n const slice = (phi) => {\r\n const p = this.pUV(phi, uvOfPWC.y);\r\n const normal = dpdu(phi, uvOfPWC.y).cross(dpdv(phi, uvOfPWC.y));\r\n return p.times(p.z * normal.z);\r\n };\r\n const sliceIntegral0ToPWCS = glqV3(slice, 0, uvOfPWC.x);\r\n const dt = M4.forSys(dpdu(uvOfPWC.x, uvOfPWC.y), dpdv(uvOfPWC.x, uvOfPWC.y))\r\n .inversed()\r\n .transformVector(tangentWC).y;\r\n const result = sliceIntegral0ToPWCS.times(dt);\r\n return result;\r\n };\r\n return glqV3(f, edgeWC.aT, edgeWC.bT);\r\n });\r\n const centroid = V3.add(...centroidZX2Parts)\r\n .schur(new V3(1, 1, 0.5))\r\n .div(totalVolume);\r\n return { volume: totalVolume, centroid: centroid };\r\n },\r\n};\r\nZDirVolumeVisitor[EllipsoidSurface.name] =\r\n ZDirVolumeVisitor[RotatedCurveSurface.name];\r\nexport function glqV3(f, startT, endT) {\r\n return gaussLegendre24Xs\r\n .reduce((val, currVal, index) => {\r\n const x = startT + ((currVal + 1) / 2) * (endT - startT);\r\n return val.plus(f(x).times(gaussLegendre24Weights[index]));\r\n }, V3.O)\r\n .times((endT - startT) / 2);\r\n}\r\nexport function glqArray(f, startT, endT, numEls = 3) {\r\n const result = new Array(numEls).fill(0);\r\n for (let i = 0; i < 24; i++) {\r\n const x = startT + ((gaussLegendre24Xs[i] + 1) / 2) * (endT - startT);\r\n const fx = f(x);\r\n for (let j = 0; j < numEls; j++) {\r\n result[j] += fx[j] * gaussLegendre24Weights[i];\r\n }\r\n }\r\n for (let j = 0; j < numEls; j++) {\r\n result[j] *= (endT - startT) / 2;\r\n }\r\n return result;\r\n}\r\nfunction mergeVolumeAndCentroidZX2Parts(volumeAndCentroidZX2Parts) {\r\n const volume = volumeAndCentroidZX2Parts.reduce((result, [volume]) => result + volume, 0);\r\n const weightedCentroid = V3.add(...volumeAndCentroidZX2Parts.map(([, centroidZX2]) => centroidZX2)).schur(new V3(1, 1, 0.5));\r\n return { volume, centroid: weightedCentroid.div(volume) };\r\n}\r\n//# sourceMappingURL=ZDirVolumeVisitor.js.map","import { assert, assertf, eq, glqInSteps, M4, NLA_PRECISION, sum, } from \"ts3dutils\";\r\nimport { ConicSurface, EllipseCurve, EllipsoidSurface, HyperbolaCurve, ImplicitCurve, L3, ParabolaCurve, PlaneSurface, ProjectedCurveSurface, RotatedCurveSurface, } from \"../index\";\r\nimport { ceil, cos, floor, sign, sin } from \"../math\";\r\nexport const CalculateAreaVisitor = {\r\n [ConicSurface.name](edges) {\r\n const dpdu = this.dpdu();\r\n const dpdv = this.dpdv();\r\n // calculation cannot be done in local coordinate system, as the area doesnt scale proportionally\r\n const totalArea = sum(edges.map((edge) => {\r\n if (edge.curve instanceof EllipseCurve ||\r\n edge.curve instanceof HyperbolaCurve ||\r\n edge.curve instanceof ParabolaCurve) {\r\n const f = (t) => {\r\n const at = edge.curve.at(t), tangentWC = edge.tangentAt(t);\r\n const uvOfPWC = this.uvP(at);\r\n // INTEGRATE [0; atUV.y]\r\n // dpdu(atUV.x, t) X dpdv(atUV.x, t)\r\n // dt\r\n // dpdv is constant with respect to t\r\n // => dpdv(atUV.x, 0) X (INTEGRATE [0; atUV.y] dpdu(atUV.x, t) dt)\r\n // dpdu(u, v) === v * dpdu(u, 1)\r\n // => dpdv(atUV.x, 0) X (1/2 t² dpdu(atUV.x, 1))[0; atUV.y]\r\n // => dpdv(atUV.x, 0) X dpdu(atUV.x, atUV.y² / 2)\r\n const du = -M4.forSys(dpdu(uvOfPWC.x, uvOfPWC.y), dpdv(uvOfPWC.x))\r\n .inversed()\r\n .transformVector(tangentWC).x;\r\n return (dpdu(uvOfPWC.x, Math.pow(uvOfPWC.y, 2) / 2)\r\n .cross(dpdv(uvOfPWC.x))\r\n .length() * du);\r\n };\r\n return glqInSteps(f, edge.aT, edge.bT, 1);\r\n }\r\n else if (edge.curve instanceof L3) {\r\n return 0;\r\n }\r\n else {\r\n throw new Error();\r\n }\r\n }));\r\n return totalArea * this.normalDir;\r\n },\r\n [PlaneSurface.name](edges) {\r\n let totalArea = 0;\r\n const r1 = this.right, u1 = this.up;\r\n for (const edge of edges) {\r\n let edgeArea;\r\n const curve = edge.curve;\r\n if (curve instanceof L3) {\r\n edgeArea =\r\n ((edge.a.dot(u1) + edge.b.dot(u1)) / 2) * edge.b.to(edge.a).dot(r1);\r\n }\r\n else if (curve instanceof EllipseCurve) {\r\n // INTEGRATE[aT; bT] (curve.at(t) * u1) * (tangent(t) * r1) dt\r\n // INTEGRATE[aT; bT] (u1 f1 cos t + u1 f2 sin t + u1 c) * (r1 f1 (-sin t) + r1 f2 cos t) dt\r\n const { f1, f2, center } = curve;\r\n const a = u1.dot(f1), b = u1.dot(f2), c = u1.dot(center), d = r1.dot(f1), e = r1.dot(f2);\r\n function fArea(t) {\r\n return (0.25 *\r\n (2 * (-b * d + a * e) * t +\r\n 4 * c * d * cos(t) +\r\n 4 * c * e * sin(t) +\r\n (a * d - b * e) * cos(2 * t) +\r\n (b * d + a * e) * sin(2 * t)));\r\n }\r\n edgeArea = -(fArea(edge.bT) - fArea(edge.aT));\r\n }\r\n else if (curve instanceof ImplicitCurve) {\r\n throw new Error(\"implement for implicitCurve\");\r\n }\r\n else {\r\n const dir1 = u1;\r\n assertf(() => dir1.hasLength(1));\r\n // INT[aT; bT] at(t) * dir1 * tangentAt(t).rejectedFrom(dir1) dt\r\n const f = (curveT) => {\r\n const at = curve.at(curveT);\r\n const tangent = curve.tangentAt(curveT);\r\n const ds = r1.dot(tangent);\r\n const t = u1.dot(at);\r\n return ds * t;\r\n };\r\n edgeArea = glqInSteps(f, edge.aT, edge.bT, 3);\r\n }\r\n totalArea += edgeArea;\r\n }\r\n assert(isFinite(totalArea));\r\n return totalArea;\r\n },\r\n [RotatedCurveSurface.name](edges, canApproximate = true) {\r\n const f1 = this.matrix.X, f2 = this.matrix.Y, f3 = this.matrix.Z;\r\n const likeVerticalSpheroid = eq(f1.length(), f2.length()) &&\r\n f1.isPerpendicularTo(f2) &&\r\n f2.isPerpendicularTo(f3) &&\r\n f3.isPerpendicularTo(f1);\r\n const areaParts = edges.map((edgeWC, ei) => {\r\n console.log(\"edge\", ei, edgeWC.sce);\r\n const curveWC = edgeWC.curve;\r\n if (edgeWC.curve instanceof ImplicitCurve) {\r\n throw new Error();\r\n }\r\n else {\r\n if (likeVerticalSpheroid) {\r\n const f = (curveT) => {\r\n const pWC = curveWC.at(curveT), tangent = curveWC.tangentAt(curveT);\r\n const pLC = this.matrixInverse.transformPoint(pWC);\r\n const { x: angleXY, y: t } = this.uvP(pWC);\r\n const arcRadius = this.matrix.transformVector(pLC.xy()).length();\r\n const arcLength = angleXY * arcRadius;\r\n const dpdv = this.dpdv()(angleXY, t).unit();\r\n const scaling = dpdv.dot(tangent);\r\n return arcLength * scaling;\r\n };\r\n return glqInSteps(f, edgeWC.aT, edgeWC.bT, 1);\r\n }\r\n else {\r\n const dpdu = this.dpdu(), dpdv = this.dpdv();\r\n const f2 = (curveT) => {\r\n const pWC = curveWC.at(curveT), tangentWC = curveWC.tangentAt(curveT);\r\n const uvPWC = this.uvP(pWC);\r\n const slice = (phi) => {\r\n //return this.dpdu()(phi, st.y).length() * this.dpdv()(phi, st.y).length()\r\n return dpdu(phi, uvPWC.y).cross(dpdv(phi, uvPWC.y)).length();\r\n };\r\n // we need to do a coordinate transform from curveT to dt, as that is what we are integrating\r\n const dt = M4.forSys(dpdu(uvPWC.x, uvPWC.y), dpdv(uvPWC.x, uvPWC.y))\r\n .inversed()\r\n .transformVector(tangentWC).y;\r\n return glqInSteps(slice, 0, uvPWC.x, 1) * dt;\r\n };\r\n return glqInSteps(f2, edgeWC.aT, edgeWC.bT, 1);\r\n }\r\n }\r\n });\r\n return sum(areaParts);\r\n },\r\n [ProjectedCurveSurface.name](edges) {\r\n // calculation cannot be done in local coordinate system, as the area doesn't scale proportionally\r\n const thisDir1 = this.dir.unit();\r\n const totalArea = sum(edges.map((edge) => {\r\n if (edge.curve instanceof L3) {\r\n return 0;\r\n }\r\n else if (edge.curve instanceof ImplicitCurve) {\r\n const { points, tangents } = edge.curve;\r\n const minT = edge.minT, maxT = edge.maxT;\r\n let sum = 0;\r\n const start = ceil(minT + NLA_PRECISION);\r\n const end = floor(maxT - NLA_PRECISION);\r\n for (let i = start; i <= end; i++) {\r\n const at = points[i], tangent = tangents[i]; //.toLength(edge.curve.stepSize)\r\n const scaling = this.normalP(at).cross(thisDir1).unit().dot(tangent);\r\n sum += at.dot(thisDir1) * scaling;\r\n }\r\n const f = (t) => {\r\n const at = edge.curve.at(t), tangent = edge.curve.tangentAt(t);\r\n const scaling = this.normalP(at).cross(thisDir1).unit().dot(tangent);\r\n return at.dot(thisDir1) * scaling;\r\n };\r\n sum += f(minT) * (start - minT - 0.5);\r\n sum += f(maxT) * (maxT - end - 0.5);\r\n return sum * sign(edge.deltaT());\r\n }\r\n else {\r\n const f = (t) => {\r\n const at = edge.curve.at(t);\r\n const tangent = edge.tangentAt(t);\r\n const scaling = tangent.rejected1Length(thisDir1);\r\n return at.dot(thisDir1) * scaling;\r\n };\r\n const val = glqInSteps(f, edge.aT, edge.bT, 1);\r\n const sign = Math.sign(this.normalP(edge.a)\r\n .cross(this.dir)\r\n .dot(edge.curve.tangentAt(edge.aT)));\r\n assert(0 !== sign);\r\n return val * sign;\r\n }\r\n }));\r\n console.log(\"totalArea\", totalArea);\r\n return totalArea;\r\n },\r\n};\r\nCalculateAreaVisitor[EllipsoidSurface.name] =\r\n CalculateAreaVisitor[RotatedCurveSurface.name];\r\n//# sourceMappingURL=CalculateAreaVisitor.js.map","import * as opentype from \"opentype.js\";\r\nimport { arrayFromFunction, assert, assertf, assertInst, assertNumbers, assertVectors, callsce, eq, eq0, getLast, GOLDEN_RATIO, le, lerp, lt, M4, MINUS, snap, TAU, V, V3, VV, } from \"ts3dutils\";\r\nimport { BezierCurve, BRep, ConicSurface, CylinderSurface, Edge, EllipseCurve, EllipsoidSurface, Face, getGlobalId, L3, NURBS, P3, PCurveEdge, PlaneFace, PlaneSurface, ProjectedCurveSurface, RotatedCurveSurface, StraightEdge, XiEtaCurve, createEdge, edgeForCurveAndTs, edgePathFromSVG, } from \".\";\r\nimport { max, min, PI, SQRT1_2 } from \"./math\";\r\nimport { NURBSSurface } from \"./surface/NURBSSurface\";\r\n/**\r\n * Create a surface by projecting a curve in a direction.\r\n *\r\n * @param curve The curve to project.\r\n * @param offset The direction and distance to project curve.\r\n * @param flipped Whether the surface's default orientation (normal = curve tangent cross offset) should be flipped.\r\n */\r\nexport function projectCurve(curve, offset, flipped) {\r\n if (curve instanceof L3) {\r\n const surfaceNormal = offset.cross(curve.dir1).toLength(flipped ? -1 : 1);\r\n return new PlaneSurface(P3.normalOnAnchor(surfaceNormal, curve.anchor));\r\n }\r\n if (curve instanceof EllipseCurve) {\r\n const curveDir = flipped ? offset : offset.negated();\r\n return new CylinderSurface(curve, curveDir.unit(), undefined, undefined);\r\n }\r\n if (curve instanceof BezierCurve || curve instanceof XiEtaCurve) {\r\n const curveDir = offset.times(flipped ? 1 : -1);\r\n return new ProjectedCurveSurface(curve, curveDir, undefined, undefined, flipped ? 0 : -1, flipped ? 1 : 0);\r\n }\r\n throw new Error();\r\n}\r\n/**\r\n * Create a surface by projecting a curve onto a point.\r\n */\r\nexport function projectPointCurve(curve, tMin = curve.tMin, tMax = curve.tMax, p, flipped) {\r\n if (curve instanceof L3) {\r\n const up = curve.anchor.to(p).rejectedFrom(curve.dir1);\r\n return PlaneSurface.forAnchorAndPlaneVectors(curve.anchor, curve.dir1, up.unit(), tMin, tMax, 0, up.length());\r\n }\r\n else if (curve instanceof EllipseCurve) {\r\n // flip f2 by default\r\n const factor = -1 * (flipped ? -1 : 1);\r\n return new ConicSurface(p, curve.f1.times(factor), curve.f2, p.to(curve.center), tMin, tMax, 0, 1);\r\n }\r\n else {\r\n throw new Error(\"projectPointCurve not implemented for \" + curve.constructor.name);\r\n }\r\n}\r\n/**\r\n * Create a surface by rotating a curve in the XZ-plane, with X > 0, around the Z-axis according to the right-hand rule.\r\n * @param curve The curve to rotate.\r\n * @param tMin The minimum value for t for which the surface should be defined.\r\n * @param tMax The maximum value for t for which the surface should be defined.\r\n * @param angle How much the curve should be rotated. sMin/sMax will be be 0/angle.\r\n * @param flipped Whether the surface's default orientation (normal = curve tangent cross rotation tangent) should be\r\n * flipped.\r\n */\r\nexport function rotateCurve(curve, tMin = curve.tMin, tMax = curve.tMax, angle, flipped) {\r\n assertf(() => new PlaneSurface(P3.ZX).containsCurve(curve));\r\n if (curve instanceof L3) {\r\n if (curve.dir1.isParallelTo(V3.Z)) {\r\n if (eq0(curve.anchor.x)) {\r\n return undefined;\r\n //throw new Error('Cannot rotate curve colinear to Z axis.')\r\n }\r\n const baseEllipse = new EllipseCurve(V3.O, curve.anchor.xy(), curve.anchor.xy().getPerpendicular(), 0, angle);\r\n // if curve.dir1 is going up (+Z), it the cylinder surface should face inwards\r\n const factor = (curve.dir1.z > 0 ? -1 : 1) * (flipped ? -1 : 1);\r\n const [zMin, zMax] = [\r\n curve.at(tMin).z * factor,\r\n curve.at(tMax).z * factor,\r\n ].sort(MINUS);\r\n return new CylinderSurface(baseEllipse, V3.Z.times(factor), 0, angle, zMin, zMax);\r\n }\r\n if (curve.at(tMin).xy().dot(curve.dir1) *\r\n curve.at(tMax).xy().dot(curve.dir1) <\r\n 0) {\r\n throw new Error(\"line cannot cross the Z axis in the [tMin, tMax] interval, as conic surfaces cannot have an hourglass shape.\");\r\n }\r\n if (curve.dir1.isPerpendicularTo(V3.Z)) {\r\n // if line.dir1 is pointing aways from V3.Z, then the surface should face up\r\n const factor = (curve.at(lerp(tMin, tMax, 0.5)).dot(curve.dir1) > 0 ? 1 : -1) *\r\n (flipped ? -1 : 1);\r\n return new PlaneSurface(new P3(V3.Z.times(factor), curve.anchor.z * factor));\r\n }\r\n else {\r\n // apex is intersection of segment with Z-axis\r\n const a = curve.at(tMin), b = curve.at(tMax);\r\n const apexZ = a.z - (a.x * (b.z - a.z)) / (b.x - a.x);\r\n const apex = new V3(0, 0, apexZ);\r\n const factor = -(a.x > b.x ? -1 : 1) * (flipped ? -1 : 1);\r\n const s = new ConicSurface(apex, new V3(curve.dir1.lengthXY(), 0, 0), new V3(0, curve.dir1.lengthXY(), 0), new V3(0, 0, (a.x > b.x ? -1 : 1) * curve.dir1.z), 0, angle, 0, 1);\r\n return factor > 0 ? s : s.flipped();\r\n }\r\n }\r\n if (curve instanceof EllipseCurve) {\r\n const a = curve.at(tMin), b = curve.at(tMax);\r\n const ell = curve.rightAngled();\r\n const f1Perp = ell.f1.isPerpendicularTo(V3.Z), f2Perp = ell.f2.isPerpendicularTo(V3.Z);\r\n if (L3.Z.containsPoint(ell.center) && (f1Perp || f2Perp)) {\r\n flipped = flipped == a.z > b.z;\r\n let width = ell.f1.length(), height = ell.f2.length();\r\n if (ell.f1.isParallelTo(V3.Z)) {\r\n ;\r\n [width, height] = [height, width];\r\n }\r\n return EllipsoidSurface.forABC(width, (!flipped ? 1 : -1) * width, height, ell.center);\r\n }\r\n else {\r\n const s = new RotatedCurveSurface(curve, M4.IDENTITY, tMin, tMax);\r\n return s;\r\n }\r\n }\r\n throw new Error();\r\n}\r\nexport var B2T;\r\n(function (B2T) {\r\n /**\r\n * Create a [BRep] of an axis-aligned box width starting at the origin and extending into +XYZ space.\r\n * @param width x-direction size.\r\n * @param height y-direction size.\r\n * @param depth z-direction size.\r\n * @param name\r\n */\r\n function box(width = 1, height = 1, depth = 1, name = \"box\" + getGlobalId()) {\r\n assertNumbers(width, height, depth);\r\n assert(\"string\" === typeof name);\r\n const baseVertices = [\r\n new V3(0, 0, 0),\r\n new V3(0, height, 0),\r\n new V3(width, height, 0),\r\n new V3(width, 0, 0),\r\n ];\r\n const generator = callsce(\"B2T.box\", width, height, depth, name);\r\n return B2T.extrudeVertices(baseVertices, P3.XY.flipped(), new V3(0, 0, depth), name, generator);\r\n }\r\n B2T.box = box;\r\n function puckman(radius, rads, height, name = \"puckman\" + getGlobalId()) {\r\n assertf(() => lt(0, radius));\r\n assertf(() => lt(0, rads) && le(rads, TAU));\r\n assertf(() => lt(0, height));\r\n const edges = StraightEdge.chain([\r\n V3.O,\r\n new V3(radius, 0, 0),\r\n new V3(radius, 0, height),\r\n new V3(0, 0, height),\r\n ], true);\r\n return B2T.rotateEdges(edges, rads, name);\r\n }\r\n B2T.puckman = puckman;\r\n function registerVertexName(map, name, p) {\r\n // TODO\r\n if (!Array.from(map.keys()).some((p2) => p2.like(p))) {\r\n map.set(p, name);\r\n }\r\n }\r\n B2T.registerVertexName = registerVertexName;\r\n /**\r\n * Create a [BRep] by projecting a number of edges in a direction.\r\n * @param baseFaceEdges\r\n * @param baseFacePlane\r\n * @param offset\r\n * @param name\r\n * @param gen\r\n * @param infoFactory\r\n */\r\n function extrudeEdges(baseFaceEdges, baseFacePlane = P3.XY, offset = V3.Z, name = \"extrude\" + getGlobalId(), gen, infoFactory) {\r\n baseFaceEdges = fixEdges(baseFaceEdges);\r\n //Array.from(combinations(baseFaceEdges.length)).forEach(({i, j}) => {\r\n //\tassertf(() => !Edge.edgesIntersect(baseFaceEdges[i], baseFaceEdges[j]), baseFaceEdges[i].sce +\r\n // baseFaceEdges[j].sce) })\r\n assertf(() => Edge.isLoop(baseFaceEdges));\r\n // TODO checks..\r\n //if (offset.dot(baseFacePlane.normal1) > 0) {\r\n //\tbaseFacePlane = baseFacePlane.flipped()\r\n //}\r\n const vertexNames = new Map();\r\n const basePlaneSurface = new PlaneSurface(baseFacePlane);\r\n //assert(basePlaneSurface.edgeLoopCCW(baseFaceEdges), 'edges not CCW on baseFacePlane')\r\n const translationMatrix = M4.translate(offset);\r\n const topEdges = baseFaceEdges.map((edge) => edge.transform(translationMatrix, \"top\"));\r\n const edgeCount = baseFaceEdges.length;\r\n const bottomInfo = infoFactory && infoFactory.extrudeBottom(basePlaneSurface, baseFaceEdges);\r\n const bottomFace = new PlaneFace(basePlaneSurface, baseFaceEdges, [], name + \"Bottom\", bottomInfo);\r\n const topFaceEdges = topEdges.map((edge) => edge.flipped()).reverse();\r\n const topSurface = new PlaneSurface(baseFacePlane.flipped().translated(offset));\r\n const topInfo = infoFactory && infoFactory.extrudeBottom(topSurface, topFaceEdges);\r\n const topFace = new PlaneFace(topSurface, topFaceEdges, [], name + \"Top\", topInfo);\r\n baseFaceEdges.forEach((edge) => B2T.registerVertexName(vertexNames, edge.name + \"A\", edge.a));\r\n topFaceEdges.forEach((edge) => B2T.registerVertexName(vertexNames, edge.name + \"A\", edge.a));\r\n const ribs = arrayFromFunction(edgeCount, (i) => StraightEdge.throughPoints(baseFaceEdges[i].a, topEdges[i].a, name + \"Rib\" + i));\r\n const faces = baseFaceEdges.map((edge, i) => {\r\n const faceName = name + \"Wall\" + i;\r\n const j = (i + 1) % edgeCount;\r\n const faceEdges = [\r\n baseFaceEdges[i].flipped(),\r\n ribs[i],\r\n topEdges[i],\r\n ribs[j].flipped(),\r\n ];\r\n const surface = projectCurve(edge.curve, offset, edge.reversed);\r\n const info = infoFactory && infoFactory.extrudeWall(i, surface, faceEdges);\r\n return Face.create(surface, faceEdges, undefined, faceName, info);\r\n });\r\n faces.push(bottomFace, topFace);\r\n gen =\r\n gen ||\r\n callsce(\"B2T.extrudeEdges\", baseFaceEdges, baseFacePlane, offset, name);\r\n return new BRep(faces, baseFacePlane.normal1.dot(offset) > 0, gen, vertexNames);\r\n }\r\n B2T.extrudeEdges = extrudeEdges;\r\n function cylinder(radius = 1, height = 1, rads = TAU, name = \"cylinder\" + getGlobalId()) {\r\n const vertices = [\r\n new V3(0, 0, 0),\r\n new V3(radius, 0, 0),\r\n new V3(radius, 0, height),\r\n new V3(0, 0, height),\r\n ];\r\n return rotateEdges(StraightEdge.chain(vertices, true), rads, name);\r\n }\r\n B2T.cylinder = cylinder;\r\n function cone(radius = 1, height = 1, rads = TAU, name = \"cone\" + getGlobalId()) {\r\n const vertices = [\r\n new V3(0, 0, 0),\r\n new V3(radius, 0, height),\r\n new V3(0, 0, height),\r\n ];\r\n return rotateEdges(StraightEdge.chain(vertices, true), rads, name);\r\n }\r\n B2T.cone = cone;\r\n function sphere(radius = 1, name = \"sphere\" + getGlobalId(), rot = TAU) {\r\n const ee = new PCurveEdge(new EllipseCurve(V3.O, new V3(0, 0, -radius), new V3(radius, 0, 0)), new V3(0, 0, -radius), new V3(0, 0, radius), 0, PI, undefined, new V3(radius, 0, 0), new V3(-radius, 0, 0));\r\n const generator = callsce(\"B2T.sphere\", radius, name, rot);\r\n return rotateEdges([StraightEdge.throughPoints(ee.b, ee.a), ee], rot, name, generator);\r\n }\r\n B2T.sphere = sphere;\r\n /**\r\n * Create a [[BRep]] of a menger sponge.\r\n * @param res 0: just a cube, 1: every cube face has one hole, 2: 9 holes, etc\r\n * @param name\r\n */\r\n function menger(res = 2, name = \"menger\" + getGlobalId()) {\r\n let result = B2T.box(1, 1, 1);\r\n if (0 == res)\r\n return result;\r\n const punch = B2T.box(1 / 3, 1 / 3, 2)\r\n .translate(1 / 3, 1 / 3, -1 / 2)\r\n .flipped();\r\n function recurse(steps, m4) {\r\n result = result.and(punch.transform(m4));\r\n if (steps > 1) {\r\n const scaled = m4.times(M4.scale(1 / 3, 1 / 3, 1));\r\n for (let i = 0; i < 9; i++) {\r\n if (4 == i)\r\n continue;\r\n recurse(steps - 1, scaled.times(M4.translate(i % 3, (i / 3) | 0, 0)));\r\n }\r\n }\r\n }\r\n recurse(res, M4.IDENTITY);\r\n recurse(res, M4.YZX);\r\n recurse(res, M4.ZXY);\r\n return result;\r\n }\r\n B2T.menger = menger;\r\n function menger2(res = 2, name = \"menger\" + getGlobalId()) {\r\n if (0 == res)\r\n return B2T.box(1, 1, 1);\r\n const punch = B2T.box(1 / 3, 1 / 3, 2)\r\n .translate(1 / 3, 1 / 3, -1 / 2)\r\n .flipped();\r\n const stencilFaces = [];\r\n function recurse(steps, m4) {\r\n stencilFaces.push(...punch.transform(m4).faces);\r\n if (steps > 1) {\r\n const scaled = m4.times(M4.scale(1 / 3, 1 / 3, 1));\r\n for (let i = 0; i < 9; i++) {\r\n if (4 == i)\r\n continue;\r\n recurse(steps - 1, scaled.times(M4.translate(i % 3, (i / 3) | 0, 0)));\r\n }\r\n }\r\n }\r\n recurse(res, M4.IDENTITY);\r\n const stencil = new BRep(stencilFaces, true);\r\n return B2T.box(1, 1, 1, name)\r\n .and(stencil)\r\n .and(stencil.transform(M4.YZX))\r\n .and(stencil.transform(M4.ZXY));\r\n }\r\n B2T.menger2 = menger2;\r\n /**\r\n * Create a [BRep] of a torus.\r\n * @param rSmall The radius to the surface of the torus.\r\n * @param rLarge The radius from the origin to the inside of the torus.\r\n * @param rads\r\n * @param name\r\n */\r\n function torus(rSmall, rLarge, rads = TAU, name = \"torus\" + getGlobalId()) {\r\n assertNumbers(rSmall, rLarge, rads);\r\n assertf(() => rLarge > rSmall);\r\n const curves = [\r\n EllipseCurve.semicircle(rSmall, new V3(rLarge, 0, 0)),\r\n EllipseCurve.semicircle(-rSmall, new V3(rLarge, 0, 0)),\r\n ];\r\n const baseEdges = curves.map((c) => PCurveEdge.forCurveAndTs(c, 0, Math.PI).rotateX(PI / 2));\r\n return B2T.rotateEdges(baseEdges, rads, name);\r\n }\r\n B2T.torus = torus;\r\n /**\r\n * Create a [BRep] by smoothly rotating edges around Z.\r\n * baseLoop should be CCW on XZ plane for a bounded BRep\r\n */\r\n function rotateEdges(baseLoop, totalRads, name = \"rotateEdges\" + getGlobalId(), generator, infoFactory) {\r\n assert(baseLoop.every((e) => new PlaneSurface(P3.ZX).containsCurve(e.curve)));\r\n assert(!eq(PI, totalRads) || PI == totalRads); // URHGJ\r\n assertf(() => lt(0, totalRads) && le(totalRads, TAU));\r\n totalRads = snap(totalRads, TAU);\r\n assertf(() => Edge.isLoop(baseLoop));\r\n const basePlane = new PlaneSurface(P3.ZX.flipped()).edgeLoopCCW(baseLoop)\r\n ? new PlaneSurface(P3.ZX.flipped())\r\n : new PlaneSurface(P3.ZX);\r\n // const rotationSteps = ceil((totalRads - NLA_PRECISION) / PI)\r\n // const angles = rotationSteps == 1 ? [-PI, -PI + totalRads] : [-PI, 0, totalRads - PI]\r\n const open = !eq(totalRads, 2 * PI);\r\n const baseRibCurves = baseLoop.map((edge) => {\r\n const a = edge.a, radius = a.lengthXY();\r\n if (!eq0(radius)) {\r\n return new EllipseCurve(V(0, 0, a.z), V(radius, 0, 0), V(0, radius, 0));\r\n }\r\n return undefined;\r\n });\r\n const baseSurfaces = baseLoop.map((edge) => {\r\n const s = rotateCurve(edge.curve, edge.minT, edge.maxT, PI, edge.deltaT() > 0);\r\n const t = lerp(edge.aT, edge.bT, 0.5);\r\n s &&\r\n assert(edge\r\n .tangentAt(t)\r\n .cross(V3.Y)\r\n .dot(s.normalP(edge.curve.at(t))) < 0);\r\n return s;\r\n });\r\n let stepStartEdges = baseLoop, stepEndEdges;\r\n const faces = [];\r\n for (let rot = 0; rot < totalRads; rot += PI) {\r\n const aT = 0, bT = min(totalRads - rot, PI);\r\n const rotation = M4.rotateZ(rot + bT);\r\n stepEndEdges =\r\n rot + bT == TAU\r\n ? baseLoop\r\n : baseLoop.map((edge) => edge.transform(rotation));\r\n const ribs = arrayFromFunction(baseLoop.length, (i) => {\r\n const a = stepStartEdges[i].a, radius = a.lengthXY();\r\n const b = stepEndEdges[i].a;\r\n if (!eq0(radius)) {\r\n const curve = 0 === rot ? baseRibCurves[i] : baseRibCurves[i].rotateZ(rot);\r\n return new PCurveEdge(curve, a, b, aT, bT, undefined, curve.tangentAt(aT), curve.tangentAt(bT), name + \"rib\" + i);\r\n }\r\n return undefined;\r\n });\r\n for (let edgeIndex = 0; edgeIndex < baseLoop.length; edgeIndex++) {\r\n if (baseSurfaces[edgeIndex]) {\r\n const edge = stepStartEdges[edgeIndex];\r\n const ipp = (edgeIndex + 1) % baseLoop.length;\r\n const faceEdges = [\r\n stepStartEdges[edgeIndex].flipped(),\r\n !eq0(edge.a.x) && ribs[edgeIndex],\r\n stepEndEdges[edgeIndex],\r\n !eq0(edge.b.x) && ribs[ipp].flipped(),\r\n ].filter((x) => x);\r\n const surface = 0 === rot\r\n ? baseSurfaces[edgeIndex]\r\n : baseSurfaces[edgeIndex].rotateZ(rot);\r\n const info = infoFactory &&\r\n infoFactory.extrudeWall(edgeIndex, surface, faceEdges, undefined);\r\n faces.push(Face.create(surface, faceEdges, undefined, name + \"Wall\" + edgeIndex, info));\r\n }\r\n }\r\n stepStartEdges = stepEndEdges;\r\n }\r\n if (open) {\r\n const endFaceEdges = Edge.reversePath(stepEndEdges);\r\n const infoStart = infoFactory && infoFactory.rotationStart(basePlane, baseLoop, undefined);\r\n const infoEnd = infoFactory &&\r\n infoFactory.rotationEnd(basePlane.flipped().rotateZ(totalRads), endFaceEdges, undefined);\r\n faces.push(new PlaneFace(basePlane, baseLoop, undefined, name + \"start\", infoStart), new PlaneFace(basePlane.flipped().rotateZ(totalRads), endFaceEdges, undefined, name + \"end\", infoEnd));\r\n }\r\n const infiniteVolume = new PlaneSurface(P3.ZX).edgeLoopCCW(baseLoop);\r\n return new BRep(faces, infiniteVolume, generator);\r\n }\r\n B2T.rotateEdges = rotateEdges;\r\n /**\r\n * loop should be CCW on XZ plane for a bounded BRep\r\n */\r\n //export function rotateEdgesUnsplit(loop: Edge[], rads: raddd, name: string): BRep {\r\n //\tassert(Edge.isLoop(loop))\r\n //\tconst rotationMatrix = M4.rotateZ(rads)\r\n //\tconst open = !eq(rads, 2 * PI)\r\n //\tconst endEdges = open ? loop.map(edge => edge.transform(rotationMatrix)) : loop\r\n //\tconst edgeCount = loop.length\r\n //\tconst ribs = arrayFromFunction(edgeCount, i => {\r\n //\t\tconst a = loop[i].a, radius = a.lengthXY()\r\n //\t\tconst b = endEdges[i].a\r\n //\t\tif (!eq0(radius)) {\r\n //\t\t\tconst curve = new EllipseCurve(V(0, 0, a.z), V(-radius, 0, 0), V(0, -radius, 0))\r\n //\t\t\tconst aT = -PI, bT = -PI + rads\r\n //\t\t\treturn new PCurveEdge(curve, a, b, aT, bT, undefined, curve.tangentAt(aT), curve.tangentAt(bT), name\r\n // + 'rib' + i) } }) const faces = loop.map((edge, i) => { const ipp = (i + 1) % edgeCount console.log('ljl', i,\r\n // ipp, ribs) const faceEdges = [ edge.flipped(), !eq0(edge.a.x) && ribs[i], endEdges[i], !eq0(edge.b.x) &&\r\n // ribs[ipp].flipped()].filter(x => x) if (edge instanceof StraightEdge) { const line = edge.curve let surface if\r\n // (line.dir1.isParallelTo(V3.Z)) { if (eq0(edge.a.x)) { return } let flipped = edge.a.z > edge.b.z surface = new\r\n // CylinderSurface(ribs[i].curve, !flipped ? V3.Z : V3.Z.negated()) } else if\r\n // (line.dir1.isPerpendicularTo(V3.Z)) { let flipped = edge.a.x > edge.b.x let surface = new PlaneSurface(new\r\n // P3(V3.Z, edge.a.z)) if (!flipped) surface = surface.flipped() if (!open) { const hole = flipped ? !eq0(edge.b.x)\r\n // && ribs[ipp].flipped() : !eq0(edge.a.x) && ribs[i] return new PlaneFace(surface, [flipped ? ribs[i] :\r\n // ribs[ipp].flipped()], hole && [[hole]]) } return new PlaneFace(surface, faceEdges) } else { // apex is\r\n // intersection of segment with Z-axis let a = edge.a, b = edge.b let apexZ = a.z - a.x * (b.z - a.z) / (b.x - a.x)\r\n // let apex = new V3(0, 0, apexZ) let flipped = edge.a.z > edge.b.z surface =\r\n // ConicSurface.atApexThroughEllipse(apex, ribs[a.x > b.x ? i : ipp].curve as EllipseCurve, !flipped ? 1 : -1)\r\n // } return Face.create(surface, faceEdges) } if (edge.curve instanceof EllipseCurve) { let flipped = undefined\r\n // let ell = edge.curve.rightAngled() let f1Perp = ell.f1.isPerpendicularTo(V3.Z), f2Perp =\r\n // ell.f2.isPerpendicularTo(V3.Z) if (L3.Z.containsPoint(ell.center) && (f1Perp || f2Perp)) { let f3length = f1Perp\r\n // ? ell.f1.length() : ell.f2.length() if (flipped) { f3length *= -1 } let surface = new\r\n // EllipsoidSurface(ell.center, ell.f1, ell.f2, ell.f1.cross(ell.f2).toLength(f3length)) return new\r\n // RotationFace(surface, faceEdges) } } else { assert(false, edge) } }).filter(x => x) if (open) { const\r\n // endFaceEdges = endEdges.map(edge => edge.flipped()).reverse() faces.push( new PlaneFace(new\r\n // PlaneSurface(P3.ZX.flipped()), loop), new PlaneFace(new PlaneSurface(P3.ZX.rotateZ(rads)), endFaceEdges)) }\r\n // return new BRep(faces, undefined) }\r\n function quaffle() {\r\n const baseK = B2T.sphere(1).translate(0, 1.7).flipped();\r\n //const baseK = B2T.box().scale(0.2).translate(0, 0.95).flipped()\r\n // const vs = B2T.DODECAHEDRON_VERTICES.concat(\r\n // B2T.DODECAHEDRON_FACE_VERTICES.map(fis => fis\r\n // .map(vi => B2T.DODECAHEDRON_VERTICES[vi])\r\n // .reduce((a,b) => a.plus(b), V3.O)\r\n // .unit()))\r\n const ss = new BRep(B2T.TETRAHEDRON_VERTICES.flatMap((v) => baseK.rotateAB(V3.Y, v).faces), false);\r\n //return ss\r\n return B2T.sphere().and(ss);\r\n }\r\n B2T.quaffle = quaffle;\r\n function extrudeFace(face, dir) {\r\n return new BRep(extrudeEdges(face.contour, face.surface.plane, dir)\r\n .faces.slice(0, -2)\r\n .concat(face, face.translate(dir.x, dir.y, dir.z).flipped(), face.holes.flatMap((hole) => extrudeEdges(hole, face.surface.plane.flipped(), dir).faces.slice(0, -2))), false);\r\n }\r\n B2T.extrudeFace = extrudeFace;\r\n function loadFonts() {\r\n return loadFont(\"fonts/FiraSansMedium.woff\").then((font) => (B2T.defaultFont = font));\r\n }\r\n B2T.loadFonts = loadFonts;\r\n const loadedFonts = new Map();\r\n function loadFont(fontPath) {\r\n return new Promise(function (resolve, reject) {\r\n const font = loadedFonts.get(fontPath);\r\n if (font) {\r\n resolve(font);\r\n }\r\n else {\r\n opentype.load(fontPath, function (err, f) {\r\n if (err) {\r\n reject(err);\r\n }\r\n else {\r\n loadedFonts.set(fontPath, f);\r\n resolve(f);\r\n }\r\n });\r\n }\r\n });\r\n }\r\n B2T.loadFont = loadFont;\r\n function loadFontsAsync(callback) {\r\n if (B2T.defaultFont) {\r\n callback();\r\n }\r\n else {\r\n opentype.load(\"fonts/FiraSansMedium.woff\", function (err, font) {\r\n if (err) {\r\n throw new Error(\"Could not load font: \" + err);\r\n }\r\n else {\r\n B2T.defaultFont = font;\r\n callback();\r\n }\r\n });\r\n }\r\n }\r\n B2T.loadFontsAsync = loadFontsAsync;\r\n /**\r\n * Create the [BRep] of a string rendered in a font.\r\n * @param text\r\n * @param size\r\n * @param depth\r\n * @param font An opentype.js font.\r\n */\r\n function text(text, size, depth = 1, font = B2T.defaultFont) {\r\n const path = font.getPath(text, 0, 0, size);\r\n const subpaths = [];\r\n path.commands.forEach((c) => {\r\n if (c.type == \"M\") {\r\n subpaths.push([]);\r\n }\r\n getLast(subpaths).push(c);\r\n });\r\n const loops = subpaths.map((sp) => {\r\n const path = new opentype.Path();\r\n path.commands = sp;\r\n const loop = Edge.reversePath(edgePathFromSVG(path.toPathData(13))).map((e) => e.mirrorY());\r\n assert(Edge.isLoop(loop));\r\n return loop;\r\n });\r\n const faces = Face.assembleFacesFromLoops(loops, new PlaneSurface(P3.XY), PlaneFace);\r\n const generator = callsce(\"B2T.text\", text, size, depth);\r\n return BRep.join(faces.map((face) => B2T.extrudeFace(face, V(0, 0, -depth))), generator);\r\n }\r\n B2T.text = text;\r\n function minorityReport() {\r\n const a = B2T.sphere();\r\n const b = B2T.text(\"LEO CROW\", 64, 128)\r\n .scale(0.1 / 32)\r\n .translate(-0.5, -0.05, 1.2)\r\n .flipped();\r\n const c = B2T.sphere(0.98);\r\n return a.and(b).plus(c);\r\n }\r\n B2T.minorityReport = minorityReport;\r\n function whatever() {\r\n const iso = icosahedron();\r\n const numbersBRep = BRep.join(iso.faces.map((face, i) => {\r\n const numberBRep = text(\"\" + (i + 1), 0.4, -2);\r\n const centroid = face.contour\r\n .map((edge) => edge.a)\r\n .reduce((a, b) => a.plus(b), V3.O)\r\n .div(3);\r\n const sys = M4.forSys(face.contour[0].aDir, centroid.cross(face.contour[0].aDir), centroid.unit(), centroid);\r\n return numberBRep.transform(sys.times(M4.translate(-numberBRep.getAABB().size().x / 2, -0.1, -0.04)));\r\n }));\r\n const s = sphere(0.9);\r\n //return iso.and(numbersBRep)\r\n return iso.and(s).and(numbersBRep);\r\n //return numbersBRep\r\n }\r\n B2T.whatever = whatever;\r\n function whatever3() {\r\n const t = B2T.torus(1, 2);\r\n return B2T.box(5, 5, 2).translate(-2.5, -2.5).minus(t);\r\n }\r\n B2T.whatever3 = whatever3;\r\n function d20() {\r\n const iso = icosahedron();\r\n const numbersBRep = BRep.join(iso.faces.map((face, i) => {\r\n const numberBRep = text(\"\" + (i + 1), 0.4, -2);\r\n const centroid = face.contour\r\n .map((edge) => edge.a)\r\n .reduce((a, b) => a.plus(b), V3.O)\r\n .div(3);\r\n const sys = M4.forSys(face.contour[0].aDir, centroid.cross(face.contour[0].aDir), centroid.unit(), centroid);\r\n return numberBRep.transform(sys.times(M4.translate(-numberBRep.getAABB().size().x / 2, -0.1, -0.04)));\r\n }));\r\n const s = sphere(0.9);\r\n //return iso.and(numbersBRep)\r\n return iso.and(s).and(numbersBRep);\r\n //return numbersBRep\r\n }\r\n B2T.d20 = d20;\r\n function rotStep(edges, totalRadsOrAngles, countO) {\r\n const angles = \"number\" === typeof totalRadsOrAngles\r\n ? arrayFromFunction(countO, (i) => ((i + 1) / countO) * totalRadsOrAngles)\r\n : totalRadsOrAngles;\r\n const count = angles.length;\r\n const open = !eq(TAU, getLast(angles));\r\n const ribs = [\r\n edges,\r\n ...angles.map((phi) => {\r\n if (eq(TAU, phi)) {\r\n return edges;\r\n }\r\n const matrix = M4.rotateZ(phi);\r\n return edges.map((edge) => edge.transform(matrix));\r\n }),\r\n ];\r\n const horizontalEdges = arrayFromFunction(count, (i) => {\r\n const ipp = (i + 1) % (count + 1);\r\n return arrayFromFunction(edges.length, (j) => {\r\n if (!eq0(edges[j].a.lengthXY())) {\r\n return StraightEdge.throughPoints(ribs[i][j].a, ribs[ipp][j].a);\r\n }\r\n return undefined;\r\n });\r\n });\r\n const faces = [];\r\n let face;\r\n edges.forEach((edge, i) => {\r\n const ipp = (i + 1) % edges.length;\r\n // for straight edges perpendicular to the Z-axis, we only create one face.\r\n if (edge instanceof StraightEdge &&\r\n edge.curve.dir1.isPerpendicularTo(V3.Z)) {\r\n const flipped = edge.a.x > edge.b.x;\r\n const surface = new PlaneSurface(flipped ? new P3(V3.Z, edge.a.z) : new P3(V3.Z.negated(), -edge.a.z));\r\n if (open) {\r\n const faceEdges = [];\r\n if (!eq0(edge.a.x)) {\r\n faceEdges.push(...arrayFromFunction(count, (j) => horizontalEdges[j][i]));\r\n }\r\n faceEdges.push(ribs[count][i]);\r\n if (!eq0(edge.b.x)) {\r\n faceEdges.push(...arrayFromFunction(count, (j) => horizontalEdges[count - j - 1][ipp].flipped()));\r\n }\r\n faceEdges.push(edge.flipped());\r\n face = new PlaneFace(surface, faceEdges);\r\n }\r\n else {\r\n const contour = flipped\r\n ? arrayFromFunction(count, (j) => horizontalEdges[j][i])\r\n : arrayFromFunction(count, (j) => horizontalEdges[count - j - 1][ipp].flipped());\r\n let hole;\r\n if (flipped && !eq0(edge.b.x)) {\r\n hole = arrayFromFunction(count, (j) => horizontalEdges[count - j - 1][ipp].flipped());\r\n }\r\n else if (!flipped && !eq0(edge.a.x)) {\r\n hole = arrayFromFunction(count, (j) => horizontalEdges[j][i]);\r\n }\r\n face = new PlaneFace(surface, contour, hole ? [hole] : []);\r\n }\r\n faces.push(face);\r\n return;\r\n }\r\n else if (edge instanceof StraightEdge) {\r\n if (eq0(edge.a.lengthXY()) && eq0(edge.b.lengthXY())) {\r\n return;\r\n }\r\n }\r\n for (let r = 0; r < count; r++) {\r\n const rpp = (r + 1) % (count + 1);\r\n const faceEdges = [\r\n ribs[r][i].flipped(),\r\n horizontalEdges[r][i],\r\n ribs[rpp][i],\r\n horizontalEdges[r][ipp] && horizontalEdges[r][ipp].flipped(),\r\n ].filter((x) => x);\r\n let surface;\r\n if (edge instanceof StraightEdge) {\r\n surface = new PlaneSurface(P3.throughPoints(faceEdges[0].a, faceEdges[1].a, faceEdges[2].a));\r\n }\r\n else {\r\n const maxX = edges[i].getAABB().max.x;\r\n const phi = angles[r], prevPhi = 0 == r ? 0 : angles[r - 1];\r\n const offset = V3.polar(maxX, prevPhi).to(V3.polar(maxX, phi));\r\n surface = projectCurve(ribs[r][i].curve, offset, false);\r\n }\r\n faces.push(Face.create(surface, faceEdges));\r\n }\r\n });\r\n if (open) {\r\n const endFaceEdges = ribs[count].map((edge) => edge.flipped()).reverse();\r\n const endFace = new PlaneFace(new PlaneSurface(P3.ZX.rotateZ(getLast(angles))), endFaceEdges);\r\n faces.push(new PlaneFace(new PlaneSurface(P3.ZX.flipped()), edges), endFace);\r\n }\r\n return new BRep(faces, new PlaneSurface(P3.ZX).edgeLoopCCW(edges));\r\n }\r\n B2T.rotStep = rotStep;\r\n function fixEdges(edges) {\r\n return edges.flatMap((edge) => {\r\n const c = edge.curve;\r\n if (c instanceof EllipseCurve && c.tMin === -PI && c.tMax === PI) {\r\n const splitEdges = edge.minT < 0 && edge.maxT > 0 ? edge.split(0) : [edge];\r\n return splitEdges.map((edge) => {\r\n if (edge.minT >= 0) {\r\n return createEdge(new EllipseCurve(c.center, c.f1, c.f2, max(0, c.tMin), c.tMax), edge.a, edge.b, edge.aT, edge.bT, undefined, edge.aDir, edge.bDir, edge.name);\r\n }\r\n else {\r\n // \"rotate\" the curve\r\n return createEdge(new EllipseCurve(c.center, c.f1.negated(), c.f2.negated(), c.tMin + PI, min(PI, c.tMax + PI)), edge.a, edge.b, edge.aT + PI, edge.bT + PI, undefined, edge.aDir, edge.bDir, edge.name);\r\n }\r\n });\r\n }\r\n if (c instanceof BezierCurve) {\r\n if (edge.a.like(edge.b)) {\r\n return edge.split(lerp(edge.aT, edge.bT, 0.5));\r\n }\r\n }\r\n return edge;\r\n });\r\n }\r\n B2T.fixEdges = fixEdges;\r\n /**\r\n * Create a [BRep] by projecting edges created by joining vertices with straight edges.\r\n * @param baseVertices\r\n * @param baseFacePlane\r\n * @param offset\r\n * @param name\r\n * @param generator\r\n */\r\n function extrudeVertices(baseVertices, baseFacePlane, offset, name, generator) {\r\n assert(baseVertices.every((v) => v instanceof V3), \"baseVertices.every(v => v instanceof V3)\");\r\n assertInst(P3, baseFacePlane);\r\n assertVectors(offset);\r\n if (baseFacePlane.normal1.dot(offset) > 0)\r\n baseFacePlane = baseFacePlane.flipped();\r\n const edges = StraightEdge.chain(baseVertices, true);\r\n generator =\r\n generator ||\r\n callsce(\"B2T.extrudeVertices\", baseVertices, baseFacePlane, offset, name);\r\n return B2T.extrudeEdges(edges, baseFacePlane, offset, name, generator);\r\n }\r\n B2T.extrudeVertices = extrudeVertices;\r\n /**\r\n * Create a tetrahedron (3 sided pyramid) [BRep].\r\n * `a`, `b`, `c` and `d` can be in any order. The only constraint is that they cannot be on a common plane.\r\n * The resulting tetrahedron will always have outwards facing faces.\r\n * @param a\r\n * @param b\r\n * @param c\r\n * @param d\r\n * @param name\r\n */\r\n function tetrahedron(a, b, c, d, name = \"tetra\" + getGlobalId()) {\r\n assertVectors(a, b, c, d);\r\n const dDistance = P3.throughPoints(a, b, c).distanceToPointSigned(d);\r\n if (eq0(dDistance)) {\r\n throw new Error(\"four points are coplanar\");\r\n }\r\n if (dDistance > 0) {\r\n ;\r\n [c, d] = [d, c];\r\n }\r\n const ab = StraightEdge.throughPoints(a, b);\r\n const ac = StraightEdge.throughPoints(a, c);\r\n const ad = StraightEdge.throughPoints(a, d);\r\n const bc = StraightEdge.throughPoints(b, c);\r\n const bd = StraightEdge.throughPoints(b, d);\r\n const cd = StraightEdge.throughPoints(c, d);\r\n const faces = [\r\n new PlaneFace(PlaneSurface.throughPoints(a, b, c), [ab, bc, ac.flipped()], [], name + \"abc\"),\r\n new PlaneFace(PlaneSurface.throughPoints(a, d, b), [ad, bd.flipped(), ab.flipped()], [], name + \"adb\"),\r\n new PlaneFace(PlaneSurface.throughPoints(b, d, c), [bd, cd.flipped(), bc.flipped()], [], name + \"bdc\"),\r\n new PlaneFace(PlaneSurface.throughPoints(c, d, a), [cd, ad.flipped(), ac], [], name + \"cda\"),\r\n ];\r\n const gen = callsce(\"B2T.tetrahedron\", a, b, c, d);\r\n return new BRep(faces, false, gen);\r\n }\r\n B2T.tetrahedron = tetrahedron;\r\n const b = 1 / GOLDEN_RATIO, c = 2 - GOLDEN_RATIO;\r\n B2T.TETRAHEDRON_VERTICES = [\r\n new V3(1, 0, -SQRT1_2),\r\n new V3(-1, 0, -SQRT1_2),\r\n new V3(0, -1, SQRT1_2),\r\n new V3(0, 1, SQRT1_2),\r\n ].map((v) => v.unit());\r\n B2T.DODECAHEDRON_VERTICES = [\r\n new V3(c, 0, 1),\r\n new V3(-c, 0, 1),\r\n new V3(-b, b, b),\r\n new V3(0, 1, c),\r\n new V3(b, b, b),\r\n new V3(b, -b, b),\r\n new V3(0, -1, c),\r\n new V3(-b, -b, b),\r\n new V3(c, 0, -1),\r\n new V3(-c, 0, -1),\r\n new V3(-b, -b, -b),\r\n new V3(0, -1, -c),\r\n new V3(b, -b, -b),\r\n new V3(b, b, -b),\r\n new V3(0, 1, -c),\r\n new V3(-b, b, -b),\r\n new V3(1, c, 0),\r\n new V3(-1, c, 0),\r\n new V3(-1, -c, 0),\r\n new V3(1, -c, 0),\r\n ].map((v) => v.unit());\r\n B2T.DODECAHEDRON_FACE_VERTICES = [\r\n [4, 3, 2, 1, 0],\r\n [7, 6, 5, 0, 1],\r\n [12, 11, 10, 9, 8],\r\n [15, 14, 13, 8, 9],\r\n [14, 3, 4, 16, 13],\r\n [3, 14, 15, 17, 2],\r\n [11, 6, 7, 18, 10],\r\n [6, 11, 12, 19, 5],\r\n [4, 0, 5, 19, 16],\r\n [12, 8, 13, 16, 19],\r\n [15, 9, 10, 18, 17],\r\n [7, 1, 2, 17, 18],\r\n ];\r\n B2T.OCTAHEDRON_VERTICES = [\r\n new V3(1, 0, 0),\r\n new V3(-1, 0, 0),\r\n new V3(0, 1, 0),\r\n new V3(0, -1, 0),\r\n new V3(0, 0, 1),\r\n new V3(0, 0, -1),\r\n ];\r\n B2T.OCTAHEDRON_FACE_VERTICES = [\r\n [0, 2, 4],\r\n [2, 1, 4],\r\n [1, 3, 4],\r\n [3, 0, 4],\r\n [2, 0, 5],\r\n [1, 2, 5],\r\n [3, 1, 5],\r\n [0, 3, 5],\r\n ];\r\n const { x: s, y: t } = new V3(1, GOLDEN_RATIO, 0).unit();\r\n B2T.ICOSAHEDRON_VERTICES = [\r\n new V3(-s, t, 0),\r\n new V3(s, t, 0),\r\n new V3(-s, -t, 0),\r\n new V3(s, -t, 0),\r\n new V3(0, -s, t),\r\n new V3(0, s, t),\r\n new V3(0, -s, -t),\r\n new V3(0, s, -t),\r\n new V3(t, 0, -s),\r\n new V3(t, 0, s),\r\n new V3(-t, 0, -s),\r\n new V3(-t, 0, s),\r\n ];\r\n B2T.ICOSAHEDRON_FACE_VERTICES = [\r\n // 5 faces around point 0\r\n [0, 11, 5],\r\n [0, 5, 1],\r\n [0, 1, 7],\r\n [0, 7, 10],\r\n [0, 10, 11],\r\n // 5 adjacent faces\r\n [1, 5, 9],\r\n [5, 11, 4],\r\n [11, 10, 2],\r\n [10, 7, 6],\r\n [7, 1, 8],\r\n // 5 faces around point 3\r\n [3, 9, 4],\r\n [3, 4, 2],\r\n [3, 2, 6],\r\n [3, 6, 8],\r\n [3, 8, 9],\r\n // 5 adjacent faces\r\n [4, 9, 5],\r\n [2, 4, 11],\r\n [6, 2, 10],\r\n [8, 6, 7],\r\n [9, 8, 1],\r\n ];\r\n /**\r\n * Create a dodecahedron [BRep]. The vertices are on the unit sphere.\r\n */\r\n function dodecahedron() {\r\n return makePlatonic(B2T.DODECAHEDRON_VERTICES, B2T.DODECAHEDRON_FACE_VERTICES, \"B2T.dodecahedron()\");\r\n }\r\n B2T.dodecahedron = dodecahedron;\r\n /**\r\n * Create an octahedron [BRep]. The vertices are on the unit sphere.\r\n */\r\n function octahedron() {\r\n return makePlatonic(B2T.OCTAHEDRON_VERTICES, B2T.OCTAHEDRON_FACE_VERTICES, \"B2T.octahedron()\");\r\n }\r\n B2T.octahedron = octahedron;\r\n /**\r\n * Create an icosahedron [BRep]. The vertices are on the unit sphere.\r\n */\r\n function icosahedron() {\r\n return makePlatonic(B2T.ICOSAHEDRON_VERTICES, B2T.ICOSAHEDRON_FACE_VERTICES, \"B2T.icosahedron()\");\r\n }\r\n B2T.icosahedron = icosahedron;\r\n function makePlatonic(VS, FVIS, generator) {\r\n const edgeMap = new Map();\r\n const faces = FVIS.map((faceIndexes) => {\r\n const surface = PlaneSurface.throughPoints(VS[faceIndexes[0]], VS[faceIndexes[1]], VS[faceIndexes[2]]);\r\n const contour = arrayFromFunction(faceIndexes.length, (i) => {\r\n const ipp = (i + 1) % faceIndexes.length;\r\n const iA = faceIndexes[i], iB = faceIndexes[ipp];\r\n const iMin = min(iA, iB), iMax = max(iA, iB), edgeID = iMin * VS.length + iMax;\r\n let edge = edgeMap.get(edgeID);\r\n !edge &&\r\n edgeMap.set(edgeID, (edge = StraightEdge.throughPoints(VS[iMin], VS[iMax])));\r\n return iA < iB ? edge : edge.flipped();\r\n });\r\n return new PlaneFace(surface, contour);\r\n });\r\n return new BRep(faces, false, generator);\r\n }\r\n /**\r\n * Create a [BRep] by projecting a number of edges onto a point.\r\n * @param baseEdges The edges forming the base of the pyramid.\r\n * @param apex The tip of the pyramid.\r\n * @param name\r\n */\r\n function pyramidEdges(baseEdges, apex, name = \"pyramid\" + getGlobalId()) {\r\n assertInst(Edge, ...baseEdges);\r\n assertVectors(apex);\r\n const ribs = baseEdges.map((baseEdge) => StraightEdge.throughPoints(apex, baseEdge.a));\r\n const faces = baseEdges.map((baseEdge, i) => {\r\n const faceName = name + \"Wall\" + i;\r\n const ipp = (i + 1) % baseEdges.length;\r\n const faceEdges = [ribs[i], baseEdge, ribs[ipp].flipped()];\r\n const surface = projectPointCurve(baseEdge.curve, baseEdge.minT, baseEdge.maxT, apex, baseEdge.deltaT() < 0);\r\n return Face.create(surface, faceEdges, undefined, faceName);\r\n });\r\n const baseSurface = new PlaneSurface(P3.XY).flipped();\r\n const bottomFace = Face.create(baseSurface, Edge.reversePath(baseEdges));\r\n faces.push(bottomFace);\r\n const generator = callsce(\"B2T.pyramidEdges\", baseEdges, apex, name);\r\n return new BRep(faces, false, generator);\r\n }\r\n B2T.pyramidEdges = pyramidEdges;\r\n function fromBPT(bpt) {\r\n const lineRegex = /.+/g;\r\n const readLine = () => lineRegex.exec(bpt)[0];\r\n const readLineNumbers = () => readLine()\r\n .trim()\r\n .split(/\\s+/)\r\n .map((s) => parseFloat(s));\r\n const numOfPatches = parseInt(readLine());\r\n const faces = arrayFromFunction(numOfPatches, () => {\r\n const [pointsUCount, pointsVCount] = readLineNumbers();\r\n const points = Array.from({ length: (pointsUCount + 1) * (pointsVCount + 1) }, () => VV(...readLineNumbers(), 1));\r\n const surface = new NURBSSurface(points, NURBS.bezierKnots(pointsUCount), NURBS.bezierKnots(pointsVCount), pointsUCount, pointsVCount, 0, 1, 0, 1);\r\n const edges = [\r\n edgeForCurveAndTs(surface.isoparametricV(0)),\r\n edgeForCurveAndTs(surface.isoparametricU(1)),\r\n edgeForCurveAndTs(surface.isoparametricV(1)).flipped(),\r\n edgeForCurveAndTs(surface.isoparametricU(0)).flipped(),\r\n ];\r\n return Face.create(surface, edges);\r\n });\r\n return new BRep(faces, false);\r\n }\r\n B2T.fromBPT = fromBPT;\r\n})(B2T || (B2T = {}));\r\n//# sourceMappingURL=BRepGenerators.js.map","import { callsce, min } from \"ts3dutils\";\r\nimport * as chroma from \"chroma.ts\";\r\nimport { GL_COLOR_BLACK } from \"tsgl\";\r\nimport { getGlobalId, L3, P3, PlaneSurface } from \".\";\r\nexport class CustomPlane extends P3 {\r\n constructor(anchor, right, up, name = \"CustomPlane\" + getGlobalId(), color = chroma.random().gl(), uMin = -500, uMax = 500, vMin = -500, vMax = 500) {\r\n const { normal1, w } = P3.forAnchorAndPlaneVectors(anchor, right, up);\r\n super(normal1, w);\r\n this.up = up;\r\n this.right = right;\r\n this.uMin = uMin;\r\n this.uMax = uMax;\r\n this.vMin = vMin;\r\n this.vMax = vMax;\r\n this.name = name;\r\n this.color = color;\r\n }\r\n get plane() {\r\n return this;\r\n }\r\n toPlaneSurface() {\r\n return new PlaneSurface(this, this.right, this.up);\r\n }\r\n toSource() {\r\n return callsce(\"new CustomPlane\", this.anchor, this.right, this.up, this.name, this.color, this.uMin, this.uMax, this.vMin, this.vMax);\r\n }\r\n static forPlane(plane, color = GL_COLOR_BLACK, name) {\r\n //assert(!name)\r\n const up = plane.normal1.getPerpendicular().unit(), right = up.cross(plane.normal1);\r\n return new CustomPlane(plane.anchor, right, up, name, color);\r\n }\r\n static fromPlaneSurface(surface) {\r\n return new CustomPlane(surface.plane.anchor, surface.right, surface.up, \"genCustomPlane\" + getGlobalId());\r\n }\r\n distanceTo(line, mindist) {\r\n return min([\r\n new L3(this.anchor.plus(this.right.times(this.uMin)), this.up),\r\n new L3(this.anchor.plus(this.right.times(this.uMax)), this.up),\r\n new L3(this.anchor.plus(this.up.times(this.vMin)), this.right),\r\n new L3(this.anchor.plus(this.up.times(this.vMax)), this.right),\r\n ].map((line2, line2Index) => {\r\n const info = line2.infoClosestToLine(line);\r\n if ((isNaN(info.t) || // parallel LINES\r\n (line2Index < 2 && this.vMin <= info.t && info.t <= this.vMax) ||\r\n (line2Index >= 2 && this.uMin <= info.t && info.t <= this.uMax)) &&\r\n info.distance <= mindist) {\r\n return info.s;\r\n }\r\n else {\r\n return Infinity;\r\n }\r\n }));\r\n }\r\n distanceTo2(line, mindist) {\r\n return min([\r\n new L3(this.anchor.plus(this.right.times(this.uMin)), this.up),\r\n new L3(this.anchor.plus(this.right.times(this.uMax)), this.up),\r\n new L3(this.anchor.plus(this.up.times(this.vMin)), this.right),\r\n new L3(this.anchor.plus(this.up.times(this.vMax)), this.right),\r\n ].map((line2, line2Index) => {\r\n const info = line2.infoClosestToLine(line);\r\n if ((isNaN(info.t) || // parallel LINES\r\n (line2Index < 2 && this.vMin <= info.t && info.t <= this.vMax) ||\r\n (line2Index >= 2 && this.uMin <= info.t && info.t <= this.uMax)) &&\r\n info.distance <= mindist) {\r\n return info.distance;\r\n }\r\n else {\r\n return Infinity;\r\n }\r\n }));\r\n }\r\n}\r\n//# sourceMappingURL=CustomPlane.js.map","import { AABB, arrayFromFunction, arrayRange, assert, assertf, assertInst, assertNumbers, assertVectors, callsce, clamp, eq, fuzzyBetween, le, lt, Transformable, V, } from \"ts3dutils\";\r\nimport { Curve, L3 } from \".\";\r\nimport { sign } from \"./math\";\r\nexport class Edge extends Transformable {\r\n constructor(curve, a, b, aT, bT, flippedOf, name) {\r\n super();\r\n this.curve = curve;\r\n this.a = a;\r\n this.b = b;\r\n this.aT = aT;\r\n this.bT = bT;\r\n this.flippedOf = flippedOf;\r\n this.name = name;\r\n assertNumbers(aT, bT);\r\n assert(!eq(aT, bT));\r\n assertVectors(a, b);\r\n assertf(() => curve instanceof Curve, curve);\r\n assertf(() => !curve.isValidT || (curve.isValidT(aT) && curve.isValidT(bT)), aT, bT, curve);\r\n //if (curve instanceof PICurve) {\r\n // assertf(() => curve.at(aT).to(a).length() < 0.1, ''+curve.at(aT)+a)\r\n // assertf(() => curve.at(bT).to(b).length() < 0.1, '' + curve.at(bT) + b)\r\n //} else {\r\n assertf(() => curve.at(aT).like(a), () => \"\" + curve.at(aT) + a + \" aT should have been \" + curve.pointT(a));\r\n assertf(() => curve.at(bT).like(b), () => \"\" + curve.at(bT) + b + \" bT should have been \" + curve.pointT(b));\r\n //}\r\n assertf(() => fuzzyBetween(aT, curve.tMin, curve.tMax), aT, curve.tMin, curve.tMax);\r\n assertf(() => fuzzyBetween(bT, curve.tMin, curve.tMax), bT, curve.tMin, curve.tMax);\r\n assert(!a.like(b), \"!a.like(b)\" + a + b);\r\n this.aT = clamp(aT, curve.tMin, curve.tMax);\r\n this.bT = clamp(bT, curve.tMin, curve.tMax);\r\n this.reversed = this.aT > this.bT;\r\n }\r\n get minT() {\r\n return Math.min(this.aT, this.bT);\r\n }\r\n get maxT() {\r\n return Math.max(this.aT, this.bT);\r\n }\r\n static isLoop(loop) {\r\n return loop.every((edge, i) => edge.b.like(loop[(i + 1) % loop.length].a));\r\n }\r\n static edgesIntersect(e1, e2) {\r\n // TODO: still getting some NaNs here..\r\n assertNumbers(e1.curve.hlol, e2.curve.hlol);\r\n assertInst(Edge, e1, e2);\r\n if (e1.curve.hlol < e2.curve.hlol) {\r\n ;\r\n [e2, e1] = [e1, e2];\r\n }\r\n const sts = e1.curve.isInfosWithCurve(e2.curve);\r\n if (sts.some((info) => isNaN(info.tThis) || isNaN(info.tOther))) {\r\n console.log(e1.sce);\r\n console.log(e2.sce);\r\n assert(false);\r\n }\r\n return sts.some(\r\n /// ( e1.aT < tThis < e1.bT ) && ( e2.aT < tOther < e2.bT )\r\n ({ tThis, tOther }) => {\r\n return e1.tValueInside(tThis) && e2.tValueInside(tOther);\r\n });\r\n }\r\n static assertLoop(edges) {\r\n edges.forEach((edge, i) => {\r\n const j = (i + 1) % edges.length;\r\n assert(edge.b.like(edges[j].a), `edges[${i}].b != edges[${j}].a (${edges[i].b.sce} != ${edges[j].a.sce})`);\r\n });\r\n }\r\n static reversePath(path, doReverse = true) {\r\n return doReverse\r\n ? arrayFromFunction(path.length, (i) => path[path.length - 1 - i].flipped())\r\n : path;\r\n }\r\n toString() {\r\n return callsce(\"new \" + this.constructor.name, this.curve, this.a, this.b, this.aT, this.bT, undefined, this.aDir, this.bDir);\r\n }\r\n colinearToLine(line) {\r\n return this.curve instanceof L3 && this.curve.isColinearTo(line);\r\n }\r\n tValueInside(t) {\r\n return this.aT < this.bT\r\n ? lt(this.aT, t) && lt(t, this.bT)\r\n : lt(this.bT, t) && lt(t, this.aT);\r\n }\r\n isValidT(t) {\r\n return this.aT < this.bT\r\n ? le(this.aT, t) && le(t, this.bT)\r\n : le(this.bT, t) && le(t, this.aT);\r\n }\r\n clampedT(t) {\r\n return this.aT < this.bT\r\n ? clamp(t, this.aT, this.bT)\r\n : clamp(t, this.bT, this.aT);\r\n }\r\n /**\r\n * this is equals-equals. \"isColinearTo\" might make more sense but can't be used, because you can't get a\r\n * consistent hashCode for colinear curves\r\n * @param obj\r\n * @returns\r\n */\r\n equals(obj) {\r\n return (this === obj ||\r\n (this.constructor == obj.constructor &&\r\n this.a.equals(obj.a) &&\r\n this.b.equals(obj.b) &&\r\n this.curve.equals(obj.curve)));\r\n }\r\n hashCode() {\r\n let hashCode = 0;\r\n hashCode = hashCode * 31 + this.a.hashCode();\r\n hashCode = hashCode * 31 + this.b.hashCode();\r\n hashCode = hashCode * 31 + this.curve.hashCode();\r\n return hashCode | 0;\r\n }\r\n like(edge) {\r\n // TODO this breaks on colinear edges,\r\n // TODO: what, where?\r\n return (this === edge ||\r\n (this.curve.isColinearTo(edge.curve) &&\r\n this.a.like(edge.a) &&\r\n this.b.like(edge.b) &&\r\n this.aDir.isParallelTo(edge.aDir) &&\r\n this.aDir.dot(edge.aDir) > 0));\r\n }\r\n isCanon() {\r\n return !this.reversed;\r\n }\r\n getCanon() {\r\n return this.reversed ? this.flipped() : this;\r\n }\r\n overlaps(edge, noback) {\r\n assert(this.curve.isColinearTo(edge.curve));\r\n const edgeAT = this.curve.containsPoint(edge.a) && this.curve.pointT(edge.a);\r\n const edgeBT = this.curve.containsPoint(edge.b) && this.curve.pointT(edge.b);\r\n if (false === edgeAT && false === edgeBT) {\r\n return noback ? false : edge.overlaps(this, true);\r\n }\r\n return !(le(edge.maxT, this.minT) || le(this.maxT, edge.minT));\r\n }\r\n getAABB() {\r\n const min = [Infinity, Infinity, Infinity], max = [-Infinity, -Infinity, -Infinity];\r\n this.curve.roots().forEach((ts, dim) => {\r\n ts.forEach((t) => {\r\n if (lt(this.minT, t) && lt(t, this.maxT)) {\r\n min[dim] = Math.min(min[dim], this.curve.at(t).e(dim));\r\n max[dim] = Math.max(max[dim], this.curve.at(t).e(dim));\r\n }\r\n });\r\n });\r\n const aabb = new AABB(V(min), V(max));\r\n aabb.addPoint(this.a);\r\n aabb.addPoint(this.b);\r\n return aabb;\r\n }\r\n length(steps = 1) {\r\n return this.curve.arcLength(this.minT, this.maxT, steps);\r\n }\r\n deltaT() {\r\n return this.bT - this.aT;\r\n }\r\n deltaTSign() {\r\n return sign(this.bT - this.aT);\r\n }\r\n atAvgT() {\r\n return this.curve.at((this.minT + this.maxT) / 2);\r\n }\r\n /**\r\n * Whether two edge loops are equal. Takes into account that two loops need not start with the same edge.\r\n * @param loop1\r\n * @param loop2\r\n */\r\n static loopsEqual(loop1, loop2) {\r\n return (loop1.length == loop2.length &&\r\n arrayRange(0, loop1.length, 1).some((offset) => loop1.every((edge, i) => edge.equals(loop2[(offset + i) % loop1.length]))));\r\n }\r\n}\r\n//# sourceMappingURL=Edge.js.map","import { arrayFromFunction, assertf, assertInst, assertVectors, callsce, eq0, snap2, } from \"ts3dutils\";\r\nimport { Edge, L3, PlaneSurface } from \".\";\r\nexport class StraightEdge extends Edge {\r\n constructor(line, a, b, aT, bT, flippedOf, name) {\r\n super(line, a, b, aT, bT, flippedOf, name);\r\n this.flippedOf = flippedOf;\r\n assertInst(L3, line);\r\n !flippedOf || assertInst(StraightEdge, flippedOf);\r\n !name || assertf(() => \"string\" === typeof name, name);\r\n this.tangent =\r\n this.aT < this.bT ? this.curve.dir1 : this.curve.dir1.negated();\r\n }\r\n get aDir() {\r\n return this.tangent;\r\n }\r\n get bDir() {\r\n return this.tangent;\r\n }\r\n static throughPoints(a, b, name) {\r\n return new StraightEdge(L3.throughPoints(a, b, 0, a.to(b).length()), a, b, 0, a.to(b).length(), undefined, name);\r\n }\r\n /**\r\n * Create a list of StraightEdges from a list of vertices.\r\n * @param vertices\r\n * @param closed Whether to connect the first and last vertices. Defaults to true.\r\n * @returns\r\n */\r\n static chain(vertices, closed = true) {\r\n const vc = vertices.length;\r\n return arrayFromFunction(closed ? vc : vc - 1, (i) => StraightEdge.throughPoints(vertices[i], vertices[(i + 1) % vc]));\r\n }\r\n toSource() {\r\n return callsce(\"new StraightEdge\", this.curve, this.a, this.b, this.aT, this.bT);\r\n }\r\n getVerticesNo0() {\r\n return [this.b];\r\n }\r\n pointsCount() {\r\n return 2;\r\n }\r\n points() {\r\n return [this.a, this.b];\r\n }\r\n edgeISTsWithPlane(plane) {\r\n const edgeT = snap2(this.curve.isTWithPlane(plane), this.aT, this.bT);\r\n return this.minT <= edgeT && edgeT <= this.maxT ? [edgeT] : [];\r\n }\r\n edgeISTsWithSurface(surface) {\r\n if (surface instanceof PlaneSurface) {\r\n return this.edgeISTsWithPlane(surface.plane);\r\n }\r\n else {\r\n return surface\r\n .isTsForLine(this.curve)\r\n .map((edgeT) => snap2(edgeT, this.aT, this.bT))\r\n .filter((edgeT) => this.minT <= edgeT && edgeT <= this.maxT);\r\n }\r\n }\r\n tangentAt() {\r\n return this.tangent;\r\n }\r\n flipped() {\r\n return (this.flippedOf ||\r\n (this.flippedOf = new StraightEdge(this.curve, this.b, this.a, this.bT, this.aT, this, this.name)));\r\n }\r\n transform(m4, desc) {\r\n const lineDir1TransLength = m4\r\n .transformVector2(this.curve.dir1, this.curve.anchor)\r\n .length();\r\n const curve = this.curve.transform(m4);\r\n const a = m4.transformPoint(this.a);\r\n const b = m4.transformPoint(this.b);\r\n return new StraightEdge(curve, a, b, m4.isNoProj() ? this.aT * lineDir1TransLength : curve.pointT(a), m4.isNoProj() ? this.bT * lineDir1TransLength : curve.pointT(b), undefined, \"\" + this.name + desc);\r\n }\r\n transform4(m4, desc) {\r\n const lineDir1TransLength = m4\r\n .transformVector2(this.curve.dir1, this.curve.anchor)\r\n .length();\r\n const curve = this.curve.transform4(m4);\r\n const a = m4.transformPoint(this.a);\r\n const b = m4.transformPoint(this.b);\r\n return new StraightEdge(curve, a, b, m4.isNoProj() ? this.aT * lineDir1TransLength : curve.pointT(a), m4.isNoProj() ? this.bT * lineDir1TransLength : curve.pointT(b), undefined, \"\" + this.name + desc);\r\n }\r\n isCoEdge(edge) {\r\n return (this === edge ||\r\n this === edge.flippedOf ||\r\n (edge.constructor instanceof StraightEdge &&\r\n ((this.a.like(edge.a) && this.b.like(edge.b)) ||\r\n (this.a.like(edge.b) && this.b.like(edge.a)))));\r\n }\r\n getEdgeT(p) {\r\n assertVectors(p);\r\n let edgeT = p.minus(this.curve.anchor).dot(this.curve.dir1);\r\n if (!eq0(this.curve.at(edgeT).distanceTo(p))) {\r\n return;\r\n }\r\n edgeT = snap2(edgeT, this.aT, this.bT);\r\n return this.minT <= edgeT && edgeT <= this.maxT ? edgeT : undefined;\r\n }\r\n split(t) {\r\n const p = this.curve.at(t);\r\n return [\r\n new StraightEdge(this.curve, this.a, p, this.aT, t, undefined, this.name + \"left\"),\r\n new StraightEdge(this.curve, p, this.b, t, this.bT, undefined, this.name + \"right\"),\r\n ];\r\n }\r\n}\r\n//# sourceMappingURL=StraightEdge.js.map","import { assert, assertf, assertVectors, callsce, snap2, snap, } from \"ts3dutils\";\r\nimport { Edge, PICurve } from \".\";\r\nexport class PCurveEdge extends Edge {\r\n constructor(curve, a, b, aT, bT, flippedOf, aDir, bDir, name) {\r\n super(curve, a, b, aT, bT, flippedOf, name);\r\n this.flippedOf = flippedOf;\r\n this.aDir = aDir;\r\n this.bDir = bDir;\r\n assertVectors(aDir, bDir);\r\n assertf(() => !aDir.likeO(), curve);\r\n assertf(() => !bDir.likeO(), curve);\r\n if (!(curve instanceof PICurve)) {\r\n // TODO\r\n assertf(() => curve.tangentAt(aT).likeOrReversed(aDir), \"\" + aT + curve.tangentAt(aT).sce + \" \" + aDir.sce);\r\n assertf(() => curve.tangentAt(bT).likeOrReversed(bDir), \"\" + bT + curve.tangentAt(bT).sce + \" \" + bDir.sce);\r\n }\r\n assert(this.reversed === this.aDir.dot(curve.tangentAt(aT)) < 0, aT +\r\n \" \" +\r\n bT +\r\n \" \" +\r\n curve.constructor.name +\r\n \" \" +\r\n this.aDir.sce +\r\n \" \" +\r\n this.bDir.sce +\r\n \" \" +\r\n curve.tangentAt(aT));\r\n assert(this.reversed === this.bDir.dot(curve.tangentAt(bT)) < 0, aT +\r\n \" \" +\r\n bT +\r\n \" \" +\r\n curve.constructor.name +\r\n \" \" +\r\n this.aDir.sce +\r\n \" \" +\r\n this.bDir.sce +\r\n \" \" +\r\n curve.tangentAt(aT));\r\n }\r\n static forCurveAndTs(curve, aT, bT, name) {\r\n return new PCurveEdge(curve, curve.at(aT), curve.at(bT), aT, bT, undefined, aT < bT ? curve.tangentAt(aT) : curve.tangentAt(aT).negated(), aT < bT ? curve.tangentAt(bT) : curve.tangentAt(bT).negated(), name);\r\n }\r\n toSource() {\r\n return callsce(\"new PCurveEdge\", this.curve, this.a, this.b, this.aT, this.bT, undefined, this.aDir, this.bDir, this.name);\r\n }\r\n getVerticesNo0() {\r\n return this.curve.calcSegmentPoints(this.aT, this.bT, this.a, this.b, this.reversed, false);\r\n }\r\n pointsCount() {\r\n return this.points().length;\r\n }\r\n points() {\r\n return this.curve.calcSegmentPoints(this.aT, this.bT, this.a, this.b, this.reversed, true);\r\n }\r\n edgeISTsWithSurface(surface) {\r\n return this.curve\r\n .isTsWithSurface(surface)\r\n .map((edgeT) => snap2(edgeT, this.aT, this.bT))\r\n .filter((edgeT) => this.minT <= edgeT && edgeT <= this.maxT);\r\n }\r\n edgeISTsWithPlane(surface) {\r\n return this.curve\r\n .isTsWithPlane(surface)\r\n .map((edgeT) => snap2(edgeT, this.aT, this.bT))\r\n .filter((edgeT) => this.minT <= edgeT && edgeT <= this.maxT);\r\n }\r\n tangentAt(t) {\r\n return !this.reversed\r\n ? this.curve.tangentAt(t)\r\n : this.curve.tangentAt(t).negated();\r\n }\r\n flipped() {\r\n return (this.flippedOf ||\r\n (this.flippedOf = new PCurveEdge(this.curve, this.b, this.a, this.bT, this.aT, this, this.bDir.negated(), this.aDir.negated(), this.name)));\r\n }\r\n transform(m4, desc) {\r\n return new PCurveEdge(this.curve.transform(m4), m4.transformPoint(this.a), m4.transformPoint(this.b), this.aT, this.bT, undefined, m4.transformVector(this.aDir), m4.transformVector(this.bDir), \"\" + this.name + desc);\r\n }\r\n transform4(m4, desc) {\r\n const a_ = m4.transformPoint(this.a);\r\n const b_ = m4.transformPoint(this.b);\r\n const curve_ = this.curve.transform4(m4);\r\n return new PCurveEdge(curve_, a_, b_, snap(curve_.pointT(a_), this.aT), snap(curve_.pointT(b_), this.bT), undefined, m4.transformVector(this.aDir), m4.transformVector(this.bDir), \"\" + this.name + desc);\r\n }\r\n isCoEdge(edge) {\r\n return (this === edge ||\r\n this === edge.flippedOf ||\r\n (this.curve.isColinearTo(edge.curve) &&\r\n ((this.a.like(edge.a) && this.b.like(edge.b)) ||\r\n (this.a.like(edge.b) && this.b.like(edge.a)))));\r\n }\r\n split(t) {\r\n const p = this.curve.at(t);\r\n const dir = this.tangentAt(t);\r\n return [\r\n new PCurveEdge(this.curve, this.a, p, this.aT, t, undefined, this.aDir, dir, this.name + \"left\"),\r\n new PCurveEdge(this.curve, p, this.b, t, this.bT, undefined, this.aDir, dir, this.name + \"right\"),\r\n ];\r\n }\r\n}\r\n//# sourceMappingURL=PCurveEdge.js.map","import { SVGPathData } from \"svg-pathdata\";\r\nimport { arrayFromFunction, arrayRange, assert, DEG, eq0, getIntervals, M4, MINUS, mod, newtonIterate, NLA_PRECISION, PI, TAU, V, V3, } from \"ts3dutils\";\r\nimport { BezierCurve, Edge, EllipseCurve, L3, ParabolaCurve, PCurveEdge, StraightEdge, } from \".\";\r\nimport { floor, ceil, abs, sign } from \"./math\";\r\nexport function edgePathFromSVG(pathString) {\r\n let currentPos = undefined;\r\n const parsed = new SVGPathData(pathString)\r\n .toAbs()\r\n .normalizeHVZ()\r\n .sanitize(NLA_PRECISION)\r\n .annotateArcs().commands;\r\n const path = [];\r\n for (const c of parsed) {\r\n assert(\"x\" in c && \"y\" in c);\r\n const endPos = new V3(c.x, c.y, 0);\r\n switch (c.type) {\r\n case SVGPathData.LINE_TO:\r\n path.push(StraightEdge.throughPoints(currentPos, endPos));\r\n break;\r\n case SVGPathData.CURVE_TO: {\r\n const c1 = new V3(c.x1, c.y1, 0);\r\n const c2 = new V3(c.x2, c.y2, 0);\r\n const curve = new BezierCurve(currentPos, c1, c2, endPos, 0, 1);\r\n const edge = new PCurveEdge(curve, currentPos, endPos, 0, 1, undefined, curve.tangentAt(0), curve.tangentAt(1));\r\n path.push(edge);\r\n break;\r\n }\r\n case SVGPathData.QUAD_TO: {\r\n const c1 = new V3(c.x1, c.y1, 0);\r\n const curve = ParabolaCurve.quadratic(currentPos, c1, endPos).rightAngled();\r\n const edge = new PCurveEdge(curve, currentPos, endPos, curve.tMin, curve.tMax, undefined, curve.tangentAt(curve.tMin), curve.tangentAt(curve.tMax));\r\n path.push(edge);\r\n break;\r\n }\r\n case SVGPathData.ARC: {\r\n const phi1 = c.phi1 * DEG, phi2 = c.phi2 * DEG, [phiMin, phiMax] = [phi1, phi2].sort(MINUS);\r\n const stops = arrayRange(-3, 4, 1)\r\n .map((n) => n * PI)\r\n .filter((stop) => phiMin <= stop && stop <= phiMax);\r\n const center = V(c.cX, c.cY);\r\n const f1 = V3.polar(c.rX, c.xRot * DEG);\r\n const f2 = V3.polar(c.rY, c.xRot * DEG + Math.PI / 2);\r\n const edges = getIntervals(stops, phiMin, phiMax).map(([t1, t2]) => {\r\n const deltaT = t2 - t1;\r\n const t1_ = mod(t1, TAU);\r\n const t2_ = t1_ + deltaT;\r\n assert(t1_ >= 0 == t2_ >= 0);\r\n const gtPI = t1_ > PI || t2_ > PI;\r\n const aT = gtPI ? t1_ - PI : t1_;\r\n const bT = gtPI ? t2_ - PI : t2_;\r\n const curve = new EllipseCurve(center, gtPI ? f1.negated() : f1, gtPI ? f2.negated() : f2);\r\n const a = phi1 == t1 ? currentPos : phi2 == t1 ? endPos : curve.at(aT);\r\n const b = phi1 == t2 ? currentPos : phi2 == t2 ? endPos : curve.at(bT);\r\n return new PCurveEdge(curve, a, b, aT, bT, undefined, curve.tangentAt(aT), curve.tangentAt(bT));\r\n });\r\n path.push(...(c.phiDelta > 0 ? edges : Edge.reversePath(edges)));\r\n break;\r\n }\r\n }\r\n currentPos = endPos;\r\n }\r\n return path;\r\n}\r\n/**\r\n * Create an axis-aligned rectangle of edges on the XY-plane with the bottom-left corner on the origin.\r\n * @param width\r\n * @param height\r\n */\r\nexport function edgeRect(width = 1, height = width) {\r\n const vertices = [\r\n new V3(0, 0, 0),\r\n new V3(width, 0, 0),\r\n new V3(width, height, 0),\r\n new V3(0, height, 0),\r\n ];\r\n return StraightEdge.chain(vertices);\r\n}\r\nexport function edgeNgon(n = 3, radius = 1) {\r\n return StraightEdge.chain(arrayFromFunction(n, (i) => V3.polar(radius, (TAU * i) / n)));\r\n}\r\nexport function edgeStar(pointCount = 5, r0 = 1, r1 = 0.5) {\r\n const vertices = arrayFromFunction(pointCount * 2, (i) => V3.polar(0 == i % 2 ? r0 : r1, (TAU * i) / pointCount / 2));\r\n return StraightEdge.chain(vertices);\r\n}\r\nexport function createEdge(curve, a, b, aT, bT, flippedOf, aDir, bDir, name) {\r\n if (curve instanceof L3) {\r\n return new StraightEdge(curve, a, b, aT, bT, flippedOf, name);\r\n }\r\n else {\r\n return new PCurveEdge(curve, a, b, aT, bT, flippedOf, aDir, bDir, name);\r\n }\r\n}\r\nexport function edgeForCurveAndTs(curve, aT = curve.tMin, bT = curve.tMax) {\r\n return createEdge(curve, curve.at(aT), curve.at(bT), aT, bT, undefined, aT < bT ? curve.tangentAt(aT) : curve.tangentAt(aT).negated(), aT < bT ? curve.tangentAt(bT) : curve.tangentAt(bT).negated());\r\n}\r\nexport function reuleaux(n = 3, radius = 1) {\r\n assert(3 <= n);\r\n assert(1 == n % 2);\r\n const corners = arrayFromFunction(n, (i) => V3.polar(radius, (TAU * i) / n));\r\n return arrayFromFunction(n, (i) => {\r\n const aI = (i + floor(n / 2)) % n, bI = (i + ceil(n / 2)) % n;\r\n const a = corners[aI], b = corners[bI];\r\n const center = corners[i];\r\n const f1 = center.to(a), curve = new EllipseCurve(center, f1, V3.Z.cross(f1));\r\n return createEdge(curve, a, b, 0, curve.pointT(b), undefined, V3.Z.cross(f1), V3.Z.cross(center.to(b)));\r\n });\r\n}\r\nexport function round(edges, radius) {\r\n if (eq0(radius)) {\r\n return edges;\r\n }\r\n const corners = edges.map((edge, i) => {\r\n const j = (i + 1) % edges.length, nextEdge = edges[j];\r\n if (!edge.b.like(nextEdge.a))\r\n return undefined;\r\n const angleToNext = edge.bDir.angleTo(nextEdge.aDir);\r\n const c1 = edge.curve, c2 = nextEdge.curve;\r\n if (c1 instanceof L3 && c2 instanceof L3) {\r\n const normal = c1.dir1.cross(c2.dir1);\r\n if (eq0(angleToNext))\r\n return undefined;\r\n const l1inside = normal.cross(c1.dir1), l2inside = normal.cross(c2.dir1);\r\n const l1offset = c1.transform(M4.translate(l1inside.toLength(radius)));\r\n const l2offset = c2.transform(M4.translate(l2inside.toLength(radius)));\r\n const center = l1offset.isInfoWithLine(l2offset);\r\n if (!center)\r\n throw new Error(\"tangential curves\");\r\n const cornerA = center.plus(l1inside.toLength(-radius));\r\n const cornerB = center.plus(l2inside.toLength(-radius));\r\n const f1 = l1inside.toLength(-radius);\r\n const curve = new EllipseCurve(center, f1, normal.cross(f1).toLength(radius));\r\n const cornerEdge = createEdge(curve, cornerA, cornerB, 0, curve.pointT(cornerB), undefined, c1.dir1, c2.dir1);\r\n return cornerEdge;\r\n }\r\n else {\r\n return arbitraryCorner(edge, nextEdge, radius);\r\n }\r\n });\r\n const result = edges.flatMap((edge, i) => {\r\n const h = (i + edges.length - 1) % edges.length;\r\n const prevCorner = corners[h], nextCorner = corners[i];\r\n if (!prevCorner && !nextCorner) {\r\n return edge;\r\n }\r\n const [aT, a, aDir] = !prevCorner\r\n ? [edge.aT, edge.a, edge.aDir]\r\n : [edge.curve.pointT(prevCorner.b), prevCorner.b, prevCorner.bDir];\r\n const [bT, b, bDir] = !nextCorner\r\n ? [edge.bT, edge.b, edge.bDir]\r\n : [edge.curve.pointT(nextCorner.a), nextCorner.a, nextCorner.aDir];\r\n const newEdge = createEdge(edge.curve, a, b, aT, bT, undefined, aDir, bDir);\r\n return !nextCorner ? newEdge : [newEdge, nextCorner];\r\n });\r\n return result;\r\n}\r\nexport function arbitraryCorner(e1, e2, radius) {\r\n const c1 = e1.curve, c2 = e2.curve;\r\n function f([t1, t2]) {\r\n const p1 = c1.at(t1), p2 = c2.at(t2);\r\n const dp1 = c1.tangentAt(t1), dp2 = c2.tangentAt(t2);\r\n const virtualPlaneNormal = dp1.cross(dp2);\r\n const normal1 = virtualPlaneNormal.cross(dp1).unit(), normal2 = virtualPlaneNormal.cross(dp2).unit();\r\n const dirCross = normal1.cross(normal2);\r\n if (virtualPlaneNormal.likeO()) {\r\n assert(false);\r\n } // lines parallel\r\n const p1p2 = p1.to(p2);\r\n // check if distance is zero (see also L3.distanceToLine)\r\n if (!eq0(p1p2.dot(virtualPlaneNormal))) {\r\n assert(false);\r\n }\r\n const dist1 = p1p2.cross(normal2).dot(dirCross) / dirCross.squared();\r\n const dist2 = p1p2.cross(normal1).dot(dirCross) / dirCross.squared();\r\n const g1 = p1.plus(normal1.times(dist1));\r\n const g2 = p2.plus(normal2.times(dist2));\r\n assert(g1.like(g2));\r\n return [abs(dist1) - radius, abs(dist2) - radius];\r\n }\r\n const startT1 = e1.bT - (radius * sign(e1.deltaT())) / e1.bDir.length();\r\n const startT2 = e2.aT + (radius * sign(e2.deltaT())) / e2.aDir.length();\r\n const [t1, t2] = newtonIterate(f, [startT1, startT2]);\r\n const cornerA = e1.curve.at(t1);\r\n const cornerB = e2.curve.at(t2);\r\n const dp1 = c1.tangentAt(t1), dp2 = c2.tangentAt(t2);\r\n const virtualPlaneNormal = dp1.cross(dp2);\r\n const normal1 = virtualPlaneNormal.cross(dp1).unit();\r\n const f1 = normal1.toLength(-radius);\r\n const center = cornerA.minus(f1);\r\n const curve = new EllipseCurve(center, f1, virtualPlaneNormal.cross(f1).toLength(radius));\r\n const cornerEdge = createEdge(curve, cornerA, cornerB, 0, curve.pointT(cornerB), undefined, c1.tangentAt(t1), c2.tangentAt(t2));\r\n return cornerEdge;\r\n}\r\n//# sourceMappingURL=edgeUtil.js.map","/**\r\n * Created by aval on 19.04.2017.\r\n */\r\nexport class FaceInfoFactory {\r\n static makeStatic(staticInfo) {\r\n return new (class extends FaceInfoFactory {\r\n constructor() {\r\n super();\r\n }\r\n info(surface, contour, holes) {\r\n return staticInfo;\r\n }\r\n })();\r\n }\r\n info(surface, contour, holes) {\r\n throw new Error(\"no default implementation\");\r\n }\r\n extrudeBottom(surface, contour, holes = []) {\r\n return this.info(surface, contour, holes);\r\n }\r\n extrudeTop(surface, contour, holes = []) {\r\n return this.info(surface, contour, holes);\r\n }\r\n extrudeWall(index, surface, contour, holes = []) {\r\n return this.info(surface, contour, holes);\r\n }\r\n rotationWall(index, surface, contour, holes = []) {\r\n return this.info(surface, contour, holes);\r\n }\r\n rotationStart(surface, contour, holes = []) {\r\n return this.info(surface, contour, holes);\r\n }\r\n rotationEnd(surface, contour, holes = []) {\r\n return this.info(surface, contour, holes);\r\n }\r\n newSubFace(original, surface, contour, holes = []) {\r\n return original.info;\r\n }\r\n transform(original, m4, desc, surface, contour, holes = []) {\r\n return original.info;\r\n }\r\n}\r\n//# sourceMappingURL=FaceInfo.js.map","import { Pair } from \"javasetmap.ts\";\r\nimport { AABB, arrayFromFunction, arrayRange, assert, assertf, assertInst, assertVectors, bagRemoveIndex, binaryIndexOf, binaryInsert, concatenated, disableConsole, doubleSignedArea, enableConsole, eq, eq0, ge, getLast, GOLDEN_RATIO, gt, indexWithMax, isCCW, le, lerp, lt, mapPush, MINUS, mod, NLA_PRECISION, snap, TAU, Transformable, V3, min as arrayMin, } from \"ts3dutils\";\r\nimport { Mesh, pushQuad } from \"tsgl\";\r\nimport { BRep, ConicSurface, COPLANAR_SAME, createEdge, dotCurve2, Edge, EllipsoidSurface, EPS, fff, getGlobalId, INSIDE, L3, P3, ParametricSurface, PlaneSurface, PointVsFace, splitsVolumeEnclosingCone2, splitsVolumeEnclosingFaces, splitsVolumeEnclosingFacesP, splitsVolumeEnclosingFacesP2, StraightEdge, triangulateVertices, } from \".\";\r\nimport { abs, ceil, floor, max, min, sign } from \"./math\";\r\nexport class Face extends Transformable {\r\n constructor(surface, contour, holes = [], name, info) {\r\n super();\r\n this.surface = surface;\r\n this.contour = contour;\r\n this.holes = holes;\r\n this.name = name;\r\n this.info = info;\r\n this.aabb = undefined;\r\n //assert(name)\r\n Edge.assertLoop(contour);\r\n assert(contour.every((f) => f instanceof Edge), () => \"contour.every(f => f instanceof Edge)\" + contour);\r\n // contour.forEach(e => !surface.containsCurve(e.curve) &&\r\n // console.log('FAIL:'+surface.distanceToPoint(e.curve.anchor)))\r\n //contour.forEach(e => {\r\n //\tassert(surface.containsCurve(e.curve), 'edge not in surface ' + e + surface)\r\n //})\r\n //assert(surface.edgeLoopCCW(contour), surface.toString() + contour.join('\\n'))\r\n holes && holes.forEach((hole) => Edge.assertLoop(hole));\r\n holes && holes.forEach((hole) => assert(!surface.edgeLoopCCW(hole)));\r\n assert(!holes || holes.constructor == Array, holes && holes.toString());\r\n this.allEdges = Array.prototype.concat.apply(this.contour, this.holes);\r\n }\r\n static assembleFacesFromLoops(loops, surface, faceConstructor) {\r\n function placeRecursively(newLoopInfo, loopInfos) {\r\n if (loopInfos.length == 0) {\r\n loopInfos.push(newLoopInfo);\r\n }\r\n else {\r\n const subLoopInfo = loopInfos.find((loopInfo) => BRep.loop1ContainsLoop2(loopInfo.loop, loopInfo.ccw, newLoopInfo.loop, newLoopInfo.ccw, surface));\r\n if (subLoopInfo) {\r\n placeRecursively(newLoopInfo, subLoopInfo.subloops);\r\n }\r\n else {\r\n // newLoopInfo isnt contained by any other subLoopInfo\r\n for (let i = loopInfos.length; --i >= 0;) {\r\n const subLoopInfo = loopInfos[i];\r\n //console.log('cheving subLoopInfo', surface.loopContainsPoint(newLoopInfo.edges,\r\n // subLoopInfo.edges[0].a))\r\n if (BRep.loop1ContainsLoop2(newLoopInfo.loop, newLoopInfo.ccw, subLoopInfo.loop, subLoopInfo.ccw, surface)) {\r\n newLoopInfo.subloops.push(subLoopInfo);\r\n loopInfos.splice(i, 1); // remove it\r\n }\r\n }\r\n loopInfos.push(newLoopInfo);\r\n }\r\n }\r\n }\r\n function newFacesRecursive(loopInfo) {\r\n newFaces.push(new faceConstructor(surface, loopInfo.ccw ? loopInfo.loop : Edge.reversePath(loopInfo.loop), loopInfo.subloops.map((sl) => sl.ccw ? Edge.reversePath(sl.loop) : sl.loop)));\r\n loopInfo.subloops.forEach((sl) => sl.subloops.forEach((sl2) => newFacesRecursive(sl2)));\r\n }\r\n const newFaces = [];\r\n const topLevelLoops = [];\r\n loops.forEach((loop) => placeRecursively({\r\n loop: loop,\r\n ccw: surface.edgeLoopCCW(loop),\r\n subloops: [],\r\n }, topLevelLoops));\r\n topLevelLoops.forEach((tll) => newFacesRecursive(tll));\r\n return newFaces;\r\n }\r\n //fromLoops(loops: Edge[][], surface: Surface) {\r\n //\ttype LoopInfo = {loop: Edge[], ccw: boolean, subloops: LoopInfo[]}\r\n //\tfunction placeRecursively(newLoopInfo: LoopInfo, loopInfos: LoopInfo[]) {\r\n //\t\tif (loopInfos.length == 0) {\r\n //\t\t\tloopInfos.push(newLoopInfo)\r\n //\t\t} else {\r\n //\t\t\tconst subLoopInfo = loopInfos.find(loopInfo => BRep.loop1ContainsLoop2(loopInfo.loop, loopInfo.ccw,\r\n // newLoopInfo.loop, newLoopInfo.ccw, surface)) if (subLoopInfo) { placeRecursively(newLoopInfo,\r\n // subLoopInfo.subloops) } else { // newLoopInfo isnt contained by any other subLoopInfo for (let i =\r\n // loopInfos.length; --i >= 0;) { const subLoopInfo = loopInfos[i] //console.log('cheving subLoopInfo',\r\n // surface.loopContainsPoint(newLoopInfo.edges, subLoopInfo.edges[0].a)) if\r\n // (BRep.loop1ContainsLoop2(newLoopInfo.loop, subLoopInfo.loop, surface)) { newLoopInfo.subloops.push(subLoopInfo)\r\n // loopInfos.splice(i, 1) // remove it } } loopInfos.push(newLoopInfo) } } } function newFacesRecursive(loopInfo:\r\n // LoopInfo): void { // CW loops can be top level, if they are holes in the original face not contained in the new\r\n // face if (loopInfo.ccw) { if (loopInfo.subloops.every(sl => !sl.ccw)) { const newFace = new\r\n // faceConstructor(surface, loopInfo.loop, loopInfo.subloops.map(sl => sl.loop)) newFaces.push(newFace)\r\n // loopInfo.subloops.forEach(sl => sl.subloops.forEach(slsl => slsl.ccw && newFacesRecursive(slsl))) } else {\r\n // loopInfo.subloops.forEach(sl => sl.ccw && newFacesRecursive(sl)) } } } const newFaces: Face[] = [] const\r\n // topLevelLoops:LoopInfo[] = [] loops.forEach(loop => placeRecursively({loop: loop, ccw:\r\n // surface.edgeLoopCCW(loop), subloops: []}, topLevelLoops)) topLevelLoops.forEach(tll => newFacesRecursive(tll))\r\n // return newFaces }\r\n static create(surface, faceEdges, holes, faceName, info) {\r\n return surface instanceof PlaneSurface\r\n ? new PlaneFace(surface, faceEdges, holes, faceName, info)\r\n : new RotationFace(surface, faceEdges, holes, faceName, info);\r\n }\r\n intersectFace(face2, thisBrep, face2Brep, faceMap, thisEdgePoints, otherEdgePoints, checkedPairs) {\r\n //thisEdgePoints = {\r\n // get(key) {\r\n // return _thisEdgePoints.get(key)\r\n // },\r\n // set(key, value) {\r\n // assert(thisBrep.edgeFaces.get(key))\r\n // _thisEdgePoints.set(key, value)\r\n // }\r\n //}\r\n function hasPair(a, b) {\r\n return checkedPairs.has(new Pair(a, b));\r\n }\r\n function addPair(a, b) {\r\n return checkedPairs.add(new Pair(a, b));\r\n }\r\n /**\r\n * @param newEdge generated segment\r\n * @param col1 if newEdge is colinear to an edge of this, the edge in question\r\n * @param col2 same for face2\r\n * @return whether new edge was added.\r\n */\r\n function handleNewEdge(newEdge, col1, col2) {\r\n if (!col1 && !col2) {\r\n let correctDir = face.surface\r\n .normalP(newEdge.a)\r\n .cross(face2.surface.normalP(newEdge.a));\r\n if (correctDir.likeO()) {\r\n const t = lerp(newEdge.aT, newEdge.bT, 1 / GOLDEN_RATIO), p = newEdge.curve.at(t);\r\n correctDir = face.surface.normalP(p).cross(face2.surface.normalP(p));\r\n }\r\n if (!correctDir.likeO()) {\r\n if (correctDir.dot(newEdge.aDir) < 0) {\r\n newEdge = newEdge.flipped();\r\n }\r\n mapPush(faceMap, face, newEdge);\r\n mapPush(faceMap, face2, newEdge.flipped());\r\n }\r\n else {\r\n const p = newEdge.a;\r\n const plane = P3.normalOnAnchor(newEdge.aDir, p);\r\n const up = face.surface.normalP(p);\r\n const sameDir = up.dot(face2.surface.normalP(p)) > 0;\r\n const canonDir = plane.normal1.cross(up);\r\n const curve = face.surface.isCurvesWithPlane(plane)[0], curveT = curve.pointT(p), curveDir = sign(canonDir.dot(curve.tangentAt(curveT)));\r\n const curve2 = face2.surface.isCurvesWithPlane(plane)[0], curve2T = curve2.pointT(p), curve2Dir = sign(canonDir.dot(curve.tangentAt(curve2T)));\r\n const foo = curve.diff(curveT, EPS * curveDir).dot(up);\r\n const foo2 = curve2.diff(curve2T, EPS * curve2Dir).dot(up);\r\n if (foo2 < foo) {\r\n mapPush(faceMap, face2, sameDir ? newEdge.flipped() : newEdge);\r\n }\r\n if (up.dot(face2.surface.normalP(p)) < 0 == foo2 < foo) {\r\n mapPush(faceMap, face, newEdge.flipped());\r\n }\r\n const bar = curve.diff(curveT, EPS * curveDir).dot(up);\r\n const bar2 = curve2.diff(curve2T, EPS * curve2Dir).dot(up);\r\n if (bar2 < bar) {\r\n mapPush(faceMap, face2, sameDir ? newEdge : newEdge.flipped());\r\n }\r\n if (sameDir != bar2 < bar) {\r\n mapPush(faceMap, face, newEdge);\r\n }\r\n }\r\n return true;\r\n }\r\n function handleEdgeInFace(col1, col2, face, face2, thisBrep, face2Brep, coplanarSameIsInside, has, add) {\r\n if (col1 && !col2) {\r\n if (hasPair(col1.getCanon(), face2))\r\n return false;\r\n //add(col1.getCanon(), face2)\r\n const surface2 = face2.surface;\r\n // NB: a new edge is inserted even though it may be the same as an old one\r\n // however it indicates that it intersects the other volume here, i.e. the old edge cannot\r\n // be counted as 'inside' for purposes of reconstitution\r\n thisBrep.edgeFaces.get(col1.getCanon()).forEach((faceInfo) => {\r\n //const dot = snap0(surface2.normal1.dot(faceInfo.inside))\r\n //if (dot == 0 ? !coplanarSameIsInside : dot < 0) {\r\n const pointsInsideFace = fff(faceInfo, face2.surface);\r\n const edgeInside = pointsInsideFace == INSIDE ||\r\n (!coplanarSameIsInside && pointsInsideFace == COPLANAR_SAME);\r\n const pushEdge = faceInfo.edge\r\n .tangentAt(faceInfo.edge.curve.pointT(newEdge.a))\r\n .like(newEdge.aDir)\r\n ? newEdge\r\n : newEdge.flipped();\r\n assert(faceInfo.edge\r\n .tangentAt(faceInfo.edge.curve.pointT(pushEdge.a))\r\n .like(pushEdge.aDir));\r\n edgeInside && mapPush(faceMap, faceInfo.face, pushEdge);\r\n });\r\n const surface2NormalAtNewEdgeA = surface2.normalP(newEdge.a);\r\n const newEdgeInside = surface2NormalAtNewEdgeA.cross(newEdge.aDir);\r\n const sVEF1 = splitsVolumeEnclosingFacesP(thisBrep, col1.getCanon(), newEdge.a, newEdgeInside, surface2NormalAtNewEdgeA);\r\n let addNewEdge, addNewEdgeFlipped;\r\n if ((addNewEdge =\r\n sVEF1 == INSIDE ||\r\n (coplanarSameIsInside && sVEF1 == COPLANAR_SAME))) {\r\n mapPush(faceMap, face2, newEdge);\r\n }\r\n const sVEF2 = splitsVolumeEnclosingFacesP(thisBrep, col1.getCanon(), newEdge.a, newEdgeInside.negated(), surface2NormalAtNewEdgeA);\r\n if ((addNewEdgeFlipped =\r\n sVEF2 == INSIDE ||\r\n (coplanarSameIsInside && sVEF2 == COPLANAR_SAME))) {\r\n mapPush(faceMap, face2, newEdge.flipped());\r\n }\r\n if (addNewEdge ||\r\n addNewEdgeFlipped ||\r\n (sVEF1 == COPLANAR_SAME && sVEF2 == INSIDE) ||\r\n (sVEF2 == COPLANAR_SAME && sVEF1 == INSIDE)) {\r\n return true;\r\n }\r\n }\r\n return false;\r\n }\r\n const c1 = handleEdgeInFace(col1, col2, face, face2, thisBrep, face2Brep, false, hasPair, addPair);\r\n const c2 = handleEdgeInFace(col2, col1, face2, face, face2Brep, thisBrep, true, (a, b) => hasPair(b, a), (a, b) => addPair(b, a));\r\n if (c1 || c2)\r\n return true;\r\n if (col1 && col2) {\r\n if (hasPair(col1.getCanon(), col2.getCanon()))\r\n return false;\r\n addPair(col1.getCanon(), col2.getCanon());\r\n function handleColinearEdgeFaces(col1, col2, thisBrep, face2Brep, coplanarSameIsInside, thisEdgePoints, has, add) {\r\n // not entirely sure for what i had the dirInsides in?\r\n //const aDirNegatedInside = (newEdge.a.like(col2.a) || newEdge.a.like(col2.b)) &&\r\n // splitsVolumeEnclosingCone(face2Brep, newEdge.a, newEdge.aDir.negated()) == INSIDE const\r\n // bDirInside = (newEdge.b.like(col2.a) || newEdge.b.like(col2.b)) &&\r\n // splitsVolumeEnclosingCone(face2Brep, newEdge.b, newEdge.bDir) == INSIDE\r\n for (const faceInfo of thisBrep.edgeFaces.get(col1.getCanon())) {\r\n const sVEF = splitsVolumeEnclosingFaces(face2Brep, col2.getCanon(), faceInfo.inside, faceInfo.normalAtCanonA);\r\n const edgeInside = sVEF == INSIDE || (coplanarSameIsInside && sVEF == COPLANAR_SAME);\r\n const pushEdge = faceInfo.edge.aDir.like(newEdge.aDir)\r\n ? newEdge\r\n : newEdge.flipped();\r\n if (edgeInside) {\r\n mapPush(faceMap, faceInfo.face, pushEdge);\r\n const aT = col1.getCanon().curve.pointT(newEdge.a);\r\n if (!eq(aT, col1.aT) && !eq(aT, col1.bT)) {\r\n // newEdge.a is in center of col1\r\n if (splitsVolumeEnclosingCone2(face2Brep, newEdge.a, newEdge.curve, newEdge.aT, -Math.sign(newEdge.deltaT())) == INSIDE) {\r\n mapPush(thisEdgePoints, col1.getCanon(), {\r\n p: newEdge.a,\r\n edgeT: aT,\r\n });\r\n }\r\n }\r\n const bT = col1.getCanon().curve.pointT(newEdge.b);\r\n if (!eq(bT, col1.aT) && !eq(bT, col1.bT)) {\r\n if (splitsVolumeEnclosingCone2(face2Brep, newEdge.b, newEdge.curve, newEdge.bT, Math.sign(newEdge.deltaT())) == INSIDE) {\r\n mapPush(thisEdgePoints, col1.getCanon(), {\r\n p: newEdge.b,\r\n edgeT: bT,\r\n });\r\n }\r\n }\r\n }\r\n }\r\n }\r\n handleColinearEdgeFaces(col1, col2, thisBrep, face2Brep, true, thisEdgePoints, hasPair, addPair);\r\n handleColinearEdgeFaces(col2, col1, face2Brep, thisBrep, false, otherEdgePoints, (a, b) => hasPair(b, a), (a, b) => addPair(b, a));\r\n return false;\r\n }\r\n return false;\r\n }\r\n // what needs to be generated: new edges on face\r\n // points on edges where they are cut by faces so that sub edges will be generated for loops\r\n // points on ends of edges where the edge will be an edge in the new volume where it goes from A to B\r\n // you don't want those to be marked as 'inside', otherwise invalid faces will be added\r\n // if a face cuts a corner, nothing needs to be done, as that alone does not limit what adjacent faces will be\r\n function handleEndPoint(a, b, newEdge) {\r\n // ends in the middle of b's face\r\n if (a && !b) {\r\n if (!a.colinear && a.edgeT != a.edge.aT && a.edgeT != a.edge.bT) {\r\n mapPush(thisEdgePoints, a.edge.getCanon(), a);\r\n assert(a.edge.isValidT(a.edgeT));\r\n }\r\n // else colinear segment ends in middle of other face, do nothing\r\n }\r\n // ends in the middle of a's face\r\n if (b && !a) {\r\n if (!b.colinear && b.edgeT != b.edge.aT && b.edgeT != b.edge.bT) {\r\n mapPush(otherEdgePoints, b.edge.getCanon(), b);\r\n assert(b.edge.isValidT(b.edgeT));\r\n }\r\n // else colinear segment ends in middle of other face, do nothing\r\n }\r\n if (a && b) {\r\n assert(a.colinear || b.colinear || eq(a.t, b.t));\r\n // if a or b is colinear the correct points will already have been added to the edge by handleNewEdge\r\n // segment starts/ends on edge/edge intersection\r\n function handleAB(a, b, face, face2, thisPlane, face2Plane, thisBrep, face2Brep, first, thisEdgePoints) {\r\n if (!a.colinear && a.edgeT != a.edge.aT && a.edgeT != a.edge.bT) {\r\n //if (!hasPair(a.edge.getCanon(), b.edge.getCanon())) {\r\n addPair(a.edge.getCanon(), b.edge.getCanon());\r\n // ends on a, on colinear segment b bT != a.edge.bT &&\r\n // b can be colinear, so edgeT == aT is possible\r\n if (a.p.like(b.edge.a) || a.p.like(b.edge.b)) {\r\n const corner = a.p.like(b.edge.a) ? b.edge.a : b.edge.b;\r\n // face2brep corner on edge\r\n const sVEC1 = splitsVolumeEnclosingCone2(face2Brep, corner, a.edge.curve, a.edgeT, 1);\r\n const sVEC2 = splitsVolumeEnclosingCone2(face2Brep, corner, a.edge.curve, a.edgeT, -1);\r\n // if either of these return ALONG_EDGE_OR_PLANE, then the breps share a colinear edge\r\n if (INSIDE == sVEC1 || INSIDE == sVEC2) {\r\n mapPush(thisEdgePoints, a.edge.getCanon(), a);\r\n assert(a.edge.isValidT(a.edgeT));\r\n }\r\n }\r\n else {\r\n // edge / edge center intersection\r\n // todo: is this even necessary considering we add edges anyway? i think so...\r\n // const testVector =\r\n // a.edge.tangentAt(a.edgeT).rejectedFrom(b.edge.tangentAt(b.edge.curve.pointT(a.p)))\r\n // assert(!testVector.likeO())\r\n const sVEF1 = splitsVolumeEnclosingFacesP2(face2Brep, b.edge.getCanon(), a.p, a.edge.curve, a.edgeT, 1, thisPlane.normalP(a.p));\r\n const sVEF2 = splitsVolumeEnclosingFacesP2(face2Brep, b.edge.getCanon(), a.p, a.edge.curve, a.edgeT, -1, thisPlane.normalP(a.p));\r\n if (INSIDE == sVEF1 ||\r\n (first && COPLANAR_SAME == sVEF1) ||\r\n INSIDE == sVEF2 ||\r\n (first && COPLANAR_SAME == sVEF2)) {\r\n mapPush(thisEdgePoints, a.edge.getCanon(), a);\r\n assert(a.edge.isValidT(a.edgeT));\r\n }\r\n }\r\n //}\r\n }\r\n }\r\n handleAB(a, b, face, face2, surface, surface2, thisBrep, face2Brep, true, thisEdgePoints);\r\n handleAB(b, a, face2, face, surface2, surface, face2Brep, thisBrep, false, otherEdgePoints);\r\n }\r\n }\r\n assertInst(Face, face2);\r\n const face = this;\r\n const surface = face.surface, surface2 = face2.surface;\r\n if (!this.getAABB().touchesAABBfuzzy(face2.getAABB())) {\r\n return;\r\n }\r\n if (surface.isCoplanarTo(surface2)) {\r\n return;\r\n }\r\n const isCurves = surface.isCurvesWithSurface(surface2);\r\n if (0 == isCurves.length) {\r\n return;\r\n }\r\n for (const isCurve of isCurves) {\r\n assert(surface.containsCurve(isCurve));\r\n assert(surface2.containsCurve(isCurve));\r\n }\r\n for (let isCurveIndex = 0; isCurveIndex < isCurves.length; isCurveIndex++) {\r\n // get intersections of newCurve with other edges of face and face2\r\n const isCurve = isCurves[isCurveIndex];\r\n const ps1 = face.edgeISPsWithSurface(isCurve, face2.surface);\r\n const ps2 = face2.edgeISPsWithSurface(isCurve, face.surface);\r\n // for non-endless curves, e.g. ellipses, the intersections of the faces can be non-zero, even if one of\r\n // the faces doesn't register any points on the curve. For example, if a cylinder is cut entirely by a\r\n // plane face (all its edges around the cylinder), then the face will contain the entire curve and\r\n // 'ps' for the plane face will be empty\r\n // TODO: behavior when curves touch face?\r\n // !! start in does depend on insideDir... TODO\r\n assertf(() => 0 == ps1.length ||\r\n !eq0(ps1[0].insideDir.dot(isCurve.tangentAt(ps1[0].t))), () => ps1[0].insideDir.dot(isCurve.tangentAt(ps1[0].t)));\r\n assertf(() => 0 == ps2.length ||\r\n !eq0(ps2[0].insideDir.dot(isCurve.tangentAt(ps2[0].t))), () => ps2[0].insideDir.dot(isCurve.tangentAt(ps2[0].t)));\r\n function startsInside(ps, face) {\r\n if (0 == ps.length) {\r\n return (isFinite(isCurve.tMin) &&\r\n face.containsPoint2(isCurve.at(isCurve.tMin)) == PointVsFace.INSIDE);\r\n }\r\n else {\r\n return ps[0].insideDir.dot(isCurve.tangentAt(ps[0].t)) < 0;\r\n }\r\n }\r\n // they can't both be empty currently\r\n // they can't both start 'inside'\r\n let in1 = startsInside(ps1, face);\r\n let in2 = startsInside(ps2, face2);\r\n if ((0 == ps1.length && !in1) || (0 == ps2.length && !in2)) {\r\n continue;\r\n }\r\n //assert(!in1 || !in2)\r\n let col1, col2;\r\n let i = 0, j = 0, last;\r\n let startP = in1 && in2 ? isCurve.at(isCurve.tMin) : undefined, startDir, startT = isCurve.tMin, startA, startB;\r\n while (i < ps1.length || j < ps2.length) {\r\n assert(i <= ps1.length);\r\n assert(j <= ps2.length);\r\n const a = ps1[i], b = ps2[j];\r\n assert(a || b);\r\n if (j == ps2.length || (i < ps1.length && lt(a.t, b.t))) {\r\n last = a;\r\n in1 = !in1;\r\n a.used = true;\r\n col1 = a.colinear ? a : undefined;\r\n i++;\r\n }\r\n else if (i == ps1.length || gt(a.t, b.t)) {\r\n last = b;\r\n b.used = true;\r\n in2 = !in2;\r\n col2 = b.colinear ? b : undefined;\r\n j++;\r\n }\r\n else {\r\n last = a;\r\n a.used = true;\r\n b.used = true;\r\n in1 = !in1;\r\n in2 = !in2;\r\n //if (in1 == in2) {\r\n col1 = a.colinear ? a : undefined;\r\n col2 = b.colinear ? b : undefined;\r\n //}\r\n i++;\r\n j++;\r\n }\r\n if (startP && !(in1 && in2)) {\r\n // segment end\r\n startDir = isCurve.tangentAt(startT);\r\n if (eq(startT, last.t)) {\r\n startP = undefined;\r\n continue;\r\n }\r\n assert(lt(startT, last.t));\r\n startT > last.t && (startDir = startDir.negated());\r\n let endDir = isCurve.tangentAt(last.t);\r\n startT > last.t && (endDir = endDir.negated());\r\n const newEdge = createEdge(isCurve, startP, last.p, startT, last.t, undefined, startDir, endDir, \"genseg\" + getGlobalId());\r\n startP = undefined;\r\n if (handleNewEdge(newEdge, col1 && col1.edge, col2 && col2.edge)) {\r\n handleEndPoint(startA || col1, startB || col2, newEdge);\r\n handleEndPoint((a && a.used && a) || col1, (b && b.used && b) || col2, newEdge);\r\n }\r\n }\r\n else if (in1 && in2) {\r\n // new segment just started\r\n startP = last.p;\r\n startDir = last.insideDir;\r\n startT = last.t;\r\n startA = a && a.used ? a : undefined;\r\n startB = b && b.used ? b : undefined;\r\n }\r\n }\r\n if (in1 && in2 && startT !== isCurve.tMax) {\r\n const endT = isCurve.tMax;\r\n startDir = isCurve.tangentAt(startT);\r\n startT > endT && (startDir = startDir.negated());\r\n let endDir = isCurve.tangentAt(endT);\r\n startT > endT && (endDir = endDir.negated());\r\n const newEdge = createEdge(isCurve, startP, isCurve.at(endT), startT, endT, undefined, startDir, endDir, \"genseg\" + getGlobalId());\r\n if (handleNewEdge(newEdge, col1 && col1.edge, col2 && col2.edge)) {\r\n handleEndPoint(startA || col1, startB || col2, newEdge);\r\n }\r\n }\r\n }\r\n face.getAllEdges().forEach((edge) => {\r\n checkedPairs.add(new Pair(edge.getCanon(), face2));\r\n });\r\n face2.getAllEdges().forEach((edge) => {\r\n checkedPairs.add(new Pair(edge.getCanon(), face));\r\n });\r\n }\r\n edgeISPsWithSurface(isCurve, surface2) {\r\n const face = this;\r\n const surface = face.surface;\r\n const loops = face.holes.concat([face.contour]);\r\n const ps = [];\r\n for (const loop of loops) {\r\n const colinearEdges = loop.map((edge) => edge.curve.isColinearTo(isCurve));\r\n //const colinearSides = loop.map((edge, edgeIndex) => -1 != colinearEdges[edgeIndex]\r\n // && -sign(isCurves[colinearEdges[edgeIndex]].tangentAt(edge.aT).dot(edge.aDir)))\r\n for (let edgeIndex = 0; edgeIndex < loop.length; edgeIndex++) {\r\n const edge = loop[edgeIndex];\r\n const nextEdgeIndex = (edgeIndex + 1) % loop.length, nextEdge = loop[nextEdgeIndex];\r\n //console.log(edge.toSource()) {p:V3(2, -2.102, 0),\r\n if (colinearEdges[edgeIndex]) {\r\n if (isCurve.containsPoint(edge.a)) {\r\n const prevEdgeIndex = (edgeIndex - 1 + loop.length) % loop.length, prevEdge = loop[prevEdgeIndex];\r\n const curveAT = isCurve.pointT(edge.a);\r\n const colinearOutA = edge.aDir.cross(surface.normalP(edge.a));\r\n if (!colinearEdges[prevEdgeIndex] &&\r\n dotCurve2(prevEdge.curve, prevEdge.bT, colinearOutA, -sign(prevEdge.deltaT())) > 0) {\r\n ps.push({\r\n p: prevEdge.b,\r\n insideDir: edge.aDir.negated(),\r\n t: curveAT,\r\n edge: prevEdge,\r\n edgeT: prevEdge.bT,\r\n colinear: false,\r\n });\r\n }\r\n ps.push({\r\n p: edge.a,\r\n insideDir: edge.aDir,\r\n t: curveAT,\r\n edge: edge,\r\n edgeT: edge.aT,\r\n colinear: true,\r\n });\r\n }\r\n if (isCurve.containsPoint(edge.b)) {\r\n const curveBT = isCurve.pointT(edge.b);\r\n const colinearOutB = edge.bDir.cross(surface.normalP(edge.b));\r\n if (!colinearEdges[nextEdgeIndex] &&\r\n dotCurve2(nextEdge.curve, nextEdge.aT, colinearOutB, sign(nextEdge.deltaT())) > 0) {\r\n ps.push({\r\n p: edge.b,\r\n insideDir: edge.bDir,\r\n t: curveBT,\r\n edge: nextEdge,\r\n edgeT: nextEdge.aT,\r\n colinear: false,\r\n });\r\n }\r\n ps.push({\r\n p: edge.b,\r\n insideDir: edge.bDir.negated(),\r\n t: curveBT,\r\n edge: edge,\r\n edgeT: edge.bT,\r\n colinear: true,\r\n });\r\n }\r\n }\r\n else {\r\n const edgeTs = edge.edgeISTsWithSurface(surface2);\r\n for (const edgeT of edgeTs) {\r\n const p = edge.curve.at(edgeT);\r\n if (!isCurve.containsPoint(p))\r\n continue;\r\n const curveT = isCurve.pointT(p);\r\n assert(!isNaN(curveT));\r\n const insideDir = edge\r\n .tangentAt(edgeT)\r\n .cross(surface.normalP(p))\r\n .negated();\r\n const isTangent = isCurve.tangentAt(curveT);\r\n //if(!eq0(insideDir.dot(isTangent))) {\r\n // Edge.edgeISTsWithSurface returns snapped values, so comparison with == is ok:\r\n if (edgeT == edge.bT) {\r\n // endpoint lies on intersection line\r\n if (!colinearEdges[nextEdgeIndex]) {\r\n if (!eq(curveT, isCurve.tMax)) {\r\n const pointsToInside = this.pointsToInside3(edge.b, isCurve, curveT, 1);\r\n assert(pointsToInside != PointVsFace.ON_EDGE);\r\n if (PointVsFace.INSIDE == pointsToInside) {\r\n ps.push({\r\n p: edge.b,\r\n insideDir: isTangent,\r\n t: curveT,\r\n edge: edge,\r\n edgeT: edge.bT,\r\n colinear: false,\r\n });\r\n }\r\n }\r\n if (!eq(curveT, isCurve.tMin)) {\r\n const pointsToInside = this.pointsToInside3(edge.b, isCurve, curveT, -1);\r\n assert(pointsToInside != PointVsFace.ON_EDGE);\r\n if (PointVsFace.INSIDE == pointsToInside) {\r\n ps.push({\r\n p: edge.b,\r\n insideDir: isTangent.negated(),\r\n t: curveT,\r\n edge: edge,\r\n edgeT: edge.bT,\r\n colinear: false,\r\n });\r\n }\r\n }\r\n //let thisSide = -normVector.dot(edge.bDir)\r\n //if (eq0(thisSide)) {\r\n // // advanced test\r\n // const dir = -sign(edge.deltaT())\r\n // const iscd = isCurve.at(curveT).to(isCurve.at(curveT + dir * dirFactor *\r\n // eps)).dot(normVector) const ecd = edge.curve.at(edgeT).to(edge.curve.at(edgeT + dir\r\n // * eps)).dot(normVector) thisSide = sign(ecd - iscd) } let nextSide =\r\n // normVector.dot(nextEdge.aDir) if (eq0(nextSide)) { // advanced test const dirFactor\r\n // = sign(snap0(isTangent.dot(nextEdge.curve.tangentAt(nextEdge.aT)))) assert(dirFactor\r\n // !== 0) const dir = sign(nextEdge.deltaT()) const iscd =\r\n // isCurve.at(curveT).to(isCurve.at(curveT + dir * dirFactor * eps)).dot(normVector)\r\n // const ecd = nextEdge.curve.at(nextEdge.aT).to(nextEdge.curve.at(nextEdge.aT + dir *\r\n // eps)).dot(normVector) nextSide = sign(ecd - iscd) } if (nextSide < 0 || thisSide <\r\n // 0) { assert(!eq0(insideDir.dot(isTangent))) // next segment is not colinear and ends\r\n // on different side ps.push({ p: edge.b, insideDir: insideDir, t: curveT, edge: edge,\r\n // edgeT: edge.bT, colinear: false}) }\r\n }\r\n }\r\n else if (edgeT != edge.aT) {\r\n // edge crosses/touches an intersection curve, neither starts nor ends on it\r\n if (eq0(insideDir.dot(isTangent))) {\r\n const dirFactor = sign(isTangent.dot(edge.curve.tangentAt(edgeT)));\r\n const eps = 1e-4;\r\n for (const dir of [-1, 1]) {\r\n if ((-1 == dir * dirFactor && edgeT == edge.minT) ||\r\n (1 == dir * dirFactor && edgeT == edge.maxT) ||\r\n (-1 == dir && curveT == isCurve.tMin) ||\r\n (1 == dir && curveT == isCurve.tMax))\r\n continue;\r\n const iscd = isCurve\r\n .at(curveT)\r\n .to(isCurve.at(curveT + dir * eps))\r\n .dot(insideDir);\r\n const ecd = edge.curve\r\n .at(edgeT)\r\n .to(edge.curve.at(edgeT + dir * dirFactor * eps))\r\n .dot(insideDir);\r\n if (iscd - ecd > 0) {\r\n ps.push({\r\n p,\r\n insideDir: isTangent.times(dir),\r\n t: curveT,\r\n edge: edge,\r\n edgeT: edgeT,\r\n colinear: false,\r\n });\r\n }\r\n }\r\n }\r\n else {\r\n ps.push({\r\n p: p,\r\n insideDir: insideDir,\r\n t: curveT,\r\n edge: edge,\r\n edgeT: edgeT,\r\n colinear: false,\r\n });\r\n }\r\n }\r\n //} else {\r\n //\r\n //\tconst dirFactor = sign(isTangent.dot(edge.curve.tangentAt(edgeT)))\r\n //\tconst eps = 1e-4\r\n //\tconst normVector = surface2.normalP(p)\r\n //\tfor (const dir of [-1, 1]) {\r\n //\t\tif (-1 == dir * dirFactor && edgeT == edge.minT ||\r\n //\t\t\t1 == dir * dirFactor && edgeT == edge.maxT ||\r\n //\t\t\t-1 == dir && curveT == isCurve.tMin ||\r\n //\t\t\t1 == dir && curveT == isCurve.tMax) continue\r\n //\t\tconst iscd = isCurve.at(curveT).to(isCurve.at(curveT + dir * eps)).dot(normVector)\r\n //\t\tconst ecd = edge.curve.at(edgeT).to(edge.curve.at(edgeT + dir * dirFactor *\r\n // eps)).dot(normVector) if (iscd > ecd) { ps.push({p, insideDir: isTangent.times(dir *\r\n // dirFactor), t: curveT, edge: edge, edgeT: edgeT, colinear: false}) } }\r\n // curveVsSurface(isCurve, curveT, p, surface2) }\r\n }\r\n }\r\n }\r\n }\r\n // duplicate 't's are ok, as sometimes a segment needs to stop and start again\r\n // should be sorted so that back facing ones are first\r\n ps.sort((a, b) => a.t - b.t || a.insideDir.dot(isCurve.tangentAt(a.t)));\r\n return ps;\r\n }\r\n transform(m4) {\r\n const mirroring = m4.isMirroring();\r\n const newEdges = Edge.reversePath(this.contour.map((e) => e.transform(m4)), mirroring);\r\n const newHoles = this.holes.map((hole) => Edge.reversePath(hole.map((e) => e.transform(m4)), mirroring));\r\n return new this.constructor(this.surface.transform(m4), newEdges, newHoles, this.name, this.info);\r\n }\r\n transform4(m4) {\r\n const mirroring = m4.isMirroring();\r\n const newEdges = Edge.reversePath(this.contour.map((e) => e.transform4(m4)), mirroring);\r\n const newHoles = this.holes.map((hole) => Edge.reversePath(hole.map((e) => e.transform4(m4)), mirroring));\r\n return new this.constructor(this.surface.transform4(m4), newEdges, newHoles, this.name, this.info);\r\n }\r\n flipped() {\r\n const newEdges = this.contour.map((e) => e.flipped()).reverse();\r\n const newHoles = this.holes.map((hole) => hole.map((e) => e.flipped()).reverse());\r\n return new this.constructor(this.surface.flipped(), newEdges, newHoles, this.name, this.info);\r\n }\r\n toString() {\r\n return (\"new \" +\r\n this.constructor.name +\r\n \"(\" +\r\n this.surface +\r\n \", [\" +\r\n this.contour.map((e) => \"\\n\\t\" + e).join() +\r\n \"]\" +\r\n this.holes.map((hole) => \"\\n\\t\\thole: \" + hole.join()) +\r\n \")\");\r\n }\r\n toSource() {\r\n return (\"new \" +\r\n this.constructor.name +\r\n \"(\" +\r\n this.surface.toSource() +\r\n \", [\" +\r\n this.contour.map((e) => \"\\n\\t\" + e.toSource() + \",\").join(\"\") +\r\n \"], [\" +\r\n this.holes\r\n .map((hole) => \"[\" + hole.map((e) => \"\\n\\t\" + e.toSource() + \",\").join(\"\") + \"]\")\r\n .join(\",\") +\r\n \"])\");\r\n }\r\n equals(obj) {\r\n return (this == obj ||\r\n (Object.getPrototypeOf(this) == Object.getPrototypeOf(obj) &&\r\n this.holes.length == obj.holes.length &&\r\n Edge.loopsEqual(this.contour, obj.contour) &&\r\n this.holes.every((hole) => obj.holes.some((hole2) => Edge.loopsEqual(hole, hole2)))));\r\n }\r\n hashCode() {\r\n function arrayHashCode(array) {\r\n let hashCode = 0;\r\n for (const val of array) {\r\n hashCode = (hashCode * 31 + val) | 0;\r\n }\r\n return hashCode;\r\n }\r\n function loopHashCode(loop) {\r\n return arrayHashCode(loop.map((edge) => edge.hashCode()).sort(MINUS));\r\n }\r\n let hashCode = 0;\r\n hashCode =\r\n (hashCode * 31 +\r\n arrayHashCode(this.holes.map((loop) => loopHashCode(loop)).sort(MINUS))) |\r\n 0;\r\n hashCode = (hashCode * 31 + loopHashCode(this.contour)) | 0;\r\n hashCode = (hashCode * 31 + this.surface.hashCode()) | 0;\r\n return hashCode;\r\n }\r\n likeFace(face2) {\r\n function loopsLike(a, b) {\r\n return (a.length == b.length &&\r\n arrayRange(0, a.length, 1).some((offset) => a.every((edge, i) => edge.like(b[(offset + i) % a.length]))));\r\n }\r\n assertInst(Face, face2);\r\n return (this.surface.like(face2.surface) &&\r\n this.holes.length == face2.holes.length &&\r\n loopsLike(this.contour, face2.contour) &&\r\n this.holes.every((hole) => face2.holes.some((hole2) => loopsLike(hole, hole2))));\r\n }\r\n getAllEdges() {\r\n return this.allEdges;\r\n }\r\n addEdgeLines(mesh) {\r\n assert(false, \"buggy, fix\");\r\n const vertices = this.contour.flatMap((edge) => edge.getVerticesNo0()), mvl = mesh.vertices.length;\r\n for (let i = 0; i < vertices.length; i++) {\r\n mesh.vertices.push(vertices[i]);\r\n mesh.LINES.push(mvl + i, mvl + ((i + 1) % vertices.length));\r\n }\r\n }\r\n containsPoint(p) {\r\n assertVectors(p);\r\n return (this.surface.loopContainsPoint(this.contour, p) != PointVsFace.OUTSIDE &&\r\n !this.holes.some((hole) => this.surface.loopContainsPoint(hole, p) != PointVsFace.OUTSIDE));\r\n }\r\n containsPoint2(p) {\r\n assertVectors(p);\r\n const contourContainsPoint = this.surface.loopContainsPoint(this.contour, p);\r\n if (contourContainsPoint != PointVsFace.INSIDE)\r\n return contourContainsPoint;\r\n for (const hole of this.holes) {\r\n const loopContainsPoint = this.surface.loopContainsPoint(hole, p);\r\n if (loopContainsPoint != PointVsFace.OUTSIDE) {\r\n return loopContainsPoint == PointVsFace.ON_EDGE\r\n ? PointVsFace.ON_EDGE\r\n : PointVsFace.OUTSIDE;\r\n }\r\n }\r\n return PointVsFace.INSIDE;\r\n }\r\n /**\r\n *\r\n * @param line\r\n * @returns t param of the line if there is an intersection, NaN otherwise\r\n */\r\n intersectsLine(line) {\r\n assertInst(L3, line);\r\n if (!this.getAABB().intersectsLine(line))\r\n return NaN;\r\n const containedIntersectionsTs = this.surface\r\n .isTsForLine(line)\r\n .filter((t) => this.containsPoint(line.at(t)));\r\n const nearestPointT = arrayMin(containedIntersectionsTs);\r\n return undefined != nearestPointT ? nearestPointT : NaN;\r\n }\r\n toMesh() {\r\n const mesh = new Mesh()\r\n .addIndexBuffer(\"TRIANGLES\")\r\n .addIndexBuffer(\"LINES\")\r\n .addVertexBuffer(\"normals\", \"ts_Normal\");\r\n this.addToMesh(mesh);\r\n //mesh.compile()\r\n return mesh;\r\n }\r\n zDirVolume() {\r\n return this.surface.zDirVolume(this.getAllEdges());\r\n }\r\n calcArea() {\r\n return this.surface.calculateArea(this.getAllEdges());\r\n }\r\n getLoops() {\r\n return [this.contour, ...this.holes];\r\n }\r\n getAABB() {\r\n return (this.aabb ||\r\n (this.aabb = AABB.forAABBs(this.contour.map((e) => e.getAABB()))));\r\n }\r\n pointsToInside3(p, curve, curveT, dir) {\r\n const eps = 1e-6;\r\n const normal = this.surface.normalP(p);\r\n const curveTangent = curve.tangentAt(curveT).times(dir);\r\n const up = normal.cross(curveTangent);\r\n const ecd = curve\r\n .at(curveT)\r\n .to(curve.at(curveT + dir * eps))\r\n .dot(up);\r\n let minValue = Infinity, result, advanced = false;\r\n for (const edge of this.getAllEdges()) {\r\n const aEqP = edge.a.like(p), bEqP = edge.b.like(p);\r\n assert(aEqP == edge.a.like(p));\r\n assert(bEqP == edge.b.like(p));\r\n if (!aEqP && !bEqP)\r\n continue;\r\n const edgeTangent = aEqP ? edge.aDir : edge.bDir.negated();\r\n const angle = curveTangent.angleRelativeNormal(edgeTangent, normal);\r\n if (eq0(angle)) {\r\n if (curve.isColinearTo(edge.curve)) {\r\n return PointVsFace.ON_EDGE;\r\n }\r\n const edgeT = aEqP ? edge.aT : edge.bT;\r\n const edgeDir = (aEqP ? 1 : -1) * sign(edge.deltaT());\r\n const iscd = edge.curve.diff(edgeT, edgeDir * eps).dot(up);\r\n //const iscd = edge.curve.at(edgeT).to(curve.at(edgeT + edgeDir * eps)).dot(up)\r\n const diff = iscd - ecd;\r\n if (diff > 0 && (!advanced || diff < minValue)) {\r\n advanced = true;\r\n minValue = diff;\r\n result = aEqP ? PointVsFace.OUTSIDE : PointVsFace.INSIDE;\r\n }\r\n }\r\n else if (!advanced) {\r\n const angle2 = (angle + TAU) % TAU;\r\n if (angle2 < minValue) {\r\n minValue = angle2;\r\n result = aEqP ? PointVsFace.OUTSIDE : PointVsFace.INSIDE;\r\n }\r\n }\r\n }\r\n if (result == undefined)\r\n throw new Error();\r\n return result;\r\n }\r\n pointsToInside2(p, dir) {\r\n return this.pointsToInside3(p, L3.anchorDirection(p, dir), 0, 1);\r\n //const normal = this.surface.normalP(p)\r\n //let minAngle = Infinity, inOut = false\r\n //function test(v, b) {\r\n //\tconst angle = (dir.angleRelativeNormal(v, normal) + TAU + NLA_PRECISION / 2) % TAU\r\n //\tif (angle <= 2 * NLA_PRECISION) {\r\n //\t\treturn true\r\n //\t}\r\n //\tif (angle < minAngle) {\r\n //\t\tminAngle = angle\r\n //\t\tinOut = b\r\n //\t}\r\n //}\r\n //for (const edge of this.getAllEdges()) {\r\n //\tassert(edge.a.equals(p) || !edge.a.like(p))\r\n //\tassert(edge.b.equals(p) || !edge.b.like(p))\r\n //\tif (edge.a.equals(p) && test(edge.aDir, false)) return PointVsFace.ON_EDGE\r\n //\tif (edge.b.equals(p) && test(edge.bDir.negated(), true)) return PointVsFace.ON_EDGE\r\n //}\r\n //return inOut ? PointVsFace.INSIDE : PointVsFace.OUTSIDE\r\n }\r\n}\r\nexport class PlaneFace extends Face {\r\n constructor(p, contour, holes, name, info) {\r\n assert(p instanceof P3 || p instanceof PlaneSurface);\r\n super(p instanceof P3 ? new PlaneSurface(p) : p, contour, holes, name, info);\r\n }\r\n static forVertices(planeSurface, vs, ...holeVss) {\r\n const _planeSurface = planeSurface instanceof P3 ? new PlaneSurface(planeSurface) : planeSurface;\r\n assert(isCCW(vs, _planeSurface.plane.normal1), \"isCCW(vs, planeSurface.plane.normal1)\");\r\n const edges = StraightEdge.chain(vs);\r\n holeVss.forEach((vs) => assert(doubleSignedArea(vs, _planeSurface.plane.normal1) >= 0, \"doubleSignedArea(vs, planeSurface.plane.normal1) >= 0\"));\r\n const holes = holeVss.map((hvs) => StraightEdge.chain(hvs));\r\n return new PlaneFace(planeSurface, edges, holes);\r\n }\r\n addToMesh(mesh) {\r\n const mvl = mesh.vertices.length;\r\n const normal = this.surface.plane.normal1;\r\n const vertices = this.contour.flatMap((edge) => edge.getVerticesNo0());\r\n for (let i = 0; i < vertices.length; i++) {\r\n mesh.LINES.push(mvl + i, mvl + ((i + 1) % vertices.length));\r\n }\r\n const holeStarts = [];\r\n this.holes.forEach((hole) => {\r\n holeStarts.push(vertices.length);\r\n vertices.push(...hole.flatMap((edge) => edge.getVerticesNo0()));\r\n });\r\n const triangles = triangulateVertices(normal, vertices, holeStarts).map((index) => index + mvl);\r\n Array.prototype.push.apply(mesh.vertices, vertices);\r\n Array.prototype.push.apply(mesh.TRIANGLES, triangles);\r\n Array.prototype.push.apply(mesh.normals, arrayFromFunction(vertices.length, () => normal));\r\n }\r\n intersectsLine(line) {\r\n assertInst(L3, line);\r\n const lambda = line.isTWithPlane(this.surface.plane);\r\n if (!Number.isFinite(lambda)) {\r\n return NaN;\r\n }\r\n const inside = this.containsPoint(line.at(lambda));\r\n return inside ? lambda : NaN;\r\n }\r\n //intersectPlaneFace(face2: PlaneFace,\r\n // thisBrep: BRep,\r\n // face2Brep: BRep,\r\n // faceMap: Map,\r\n // thisEdgePoints: CustomMap,\r\n // otherEdgePoints: CustomMap,\r\n // checkedPairs: CustomSet>) {\r\n //\tassertInst(CustomMap, thisEdgePoints, otherEdgePoints)\r\n //\r\n //\tfunction hasPair(a: Equalable, b: Equalable) {\r\n //\t\treturn checkedPairs.has(new Pair(a, b))\r\n //\t}\r\n //\tfunction addPair(a: Equalable, b: Equalable) {\r\n //\t\treturn checkedPairs.add(new Pair(a, b))\r\n //\t}\r\n //\r\n //\t/**\r\n //\t * @param newEdge generated segment\r\n //\t * @param col1 if newEdge is colinear to an edge of this, the edge in question\r\n //\t * @param col2 same for face2\r\n //\t */\r\n //\tfunction handleNewEdge(newEdge: StraightEdge, col1: Edge, col2: Edge) {\r\n //\t\tif (!col1 && !col2) {\r\n //\t\t\tmapPush(faceMap, face, newEdge)\r\n //\t\t\tmapPush(faceMap, face2, newEdge.flipped())\r\n //\t\t\treturn true\r\n //\t\t}\r\n //\t\tfunction handleEdgeInFace(col1, col2, face, face2, thisBrep, face2Brep, coplanarSameIsInside: boolean,\r\n // has, add) { if (col1 && !col2) { if (hasPair(col1.getCanon(), face2)) return //add(col1.getCanon(), face2)\r\n // const face2Plane = face2.surface.plane // NB: a new edge is inserted even though it may be the same as an old\r\n // one // however it indicates that it intersects the other volume here, i.e. the old edge cannot // be counted as\r\n // 'inside' for purposes of reconstitution thisBrep.edgeFaces.get(col1.getCanon()).forEach(faceInfo => { //const\r\n // dot = snap0(face2Plane.normal1.dot(faceInfo.inside)) //if (dot == 0 ? !coplanarSameIsInside : dot < 0) { const\r\n // pointsInsideFace = fff(faceInfo, face2.surface) const edgeInside = pointsInsideFace == INSIDE ||\r\n // !coplanarSameIsInside && pointsInsideFace == COPLANAR_SAME const pushEdge =\r\n // (faceInfo.edge.aDir.like(newEdge.aDir)) ? newEdge : newEdge.flipped()\r\n // assert(faceInfo.edge.aDir.like(pushEdge.aDir)) edgeInside && mapPush(faceMap, faceInfo.face, pushEdge) }) const\r\n // newEdgeInside = face2Plane.normal1.cross(newEdge.aDir) const sVEF1 = splitsVolumeEnclosingFaces(thisBrep,\r\n // col1.getCanon(), newEdgeInside, face2Plane.normal1) let addNewEdge, addNewEdgeFlipped if (addNewEdge = sVEF1 ==\r\n // INSIDE || coplanarSameIsInside && sVEF1 == COPLANAR_SAME) { mapPush(faceMap, face2, newEdge) } const sVEF2 =\r\n // splitsVolumeEnclosingFaces(thisBrep, col1.getCanon(), newEdgeInside.negated(), face2Plane.normal1) if\r\n // (addNewEdgeFlipped = sVEF2 == INSIDE || coplanarSameIsInside && sVEF2 == COPLANAR_SAME) { mapPush(faceMap,\r\n // face2, newEdge.flipped()) } if (addNewEdge || addNewEdgeFlipped || sVEF1 == COPLANAR_SAME && sVEF2 == INSIDE ||\r\n // sVEF2 == COPLANAR_SAME && sVEF1 == INSIDE) { return true } } } const c1 = handleEdgeInFace(col1, col2, face,\r\n // face2, thisBrep, face2Brep, false, hasPair, addPair) const c2 = handleEdgeInFace(col2, col1, face2, face,\r\n // face2Brep, thisBrep, true, (a, b) => hasPair(b, a), (a, b) => addPair(b, a)) if (c1 || c2) return true if (col1\r\n // && col2) { if (hasPair(col1.getCanon(), col2.getCanon())) return addPair(col1.getCanon(), col2.getCanon())\r\n // function handleColinearEdgeFaces(col1, col2, thisBrep, face2Brep, coplanarSameIsInside: boolean, thisEdgePoints,\r\n // has, add) { // not entirely sure for what i had the dirInsides in? //const aDirNegatedInside =\r\n // (newEdge.a.like(col2.a) || newEdge.a.like(col2.b)) && splitsVolumeEnclosingCone(face2Brep, newEdge.a,\r\n // newEdge.aDir.negated()) == INSIDE //const bDirInside = (newEdge.b.like(col2.a) || newEdge.b.like(col2.b)) &&\r\n // splitsVolumeEnclosingCone(face2Brep, newEdge.b, newEdge.bDir) == INSIDE\r\n // thisBrep.edgeFaces.get(col1.getCanon()).forEach(faceInfo => { const sVEF = splitsVolumeEnclosingFaces(face2Brep,\r\n // col2.getCanon(), faceInfo.inside, faceInfo.normalAtCanonA) const edgeInside = sVEF == INSIDE ||\r\n // coplanarSameIsInside && sVEF == COPLANAR_SAME const pushEdge = (faceInfo.edge.aDir.like(newEdge.aDir)) ? newEdge\r\n // : newEdge.flipped() edgeInside && mapPush(faceMap, faceInfo.face, pushEdge) }) } handleColinearEdgeFaces(col1,\r\n // col2, thisBrep, face2Brep, true, thisEdgePoints, hasPair, addPair) handleColinearEdgeFaces(col2, col1,\r\n // face2Brep, thisBrep, false, otherEdgePoints, (a, b) => hasPair(b, a), (a, b) => addPair(b, a)) } } // what\r\n // needs to be generated: new edges on face // points on edges where they are cut by faces so that sub edges will\r\n // be generated for loops // points on ends of edges where the edge will be an edge in the new volume where it goes\r\n // from A to B // you don't want thos to be marked as 'inside', otherwise invalid faces will be added // if\r\n // a face cuts a corner, nothings needs to be done, as that alone does not limit what adjacent faces will be\r\n // function handleEndPoint(a: IntersectionPointInfo, b: IntersectionPointInfo, newEdge: Edge) { // ends in the\r\n // middle of b's face if (a && !b) { if (!a.colinear && a.edgeT != a.edge.aT && a.edgeT != a.edge.bT) {\r\n // mapPush(thisEdgePoints, a.edge.getCanon(), a) assert(a.edge.isValidT(a.edgeT)) } // else colinear segment ends\r\n // in middle of other face, do nothing } // ends in the middle of a's face if (b && !a) { if (!b.colinear &&\r\n // b.edgeT != b.edge.aT && b.edgeT != b.edge.bT) { mapPush(otherEdgePoints, b.edge.getCanon(), b)\r\n // assert(b.edge.isValidT(b.edgeT)) } // else colinear segment ends in middle of other face, do nothing } if (a &&\r\n // b) { // if a or b is colinear the correct points will already have been added to the edge by handleNewEdge //\r\n // segment starts/ends on edge/edge intersection function foo(a, b, face, face2, thisPlane, face2Plane, thisBrep,\r\n // face2Brep, first, thisEdgePoints) { if (!a.colinear && a.edgeT != a.edge.aT && a.edgeT != a.edge.bT) { if\r\n // (!hasPair(a.edge.getCanon(), b.edge.getCanon())) { addPair(a.edge.getCanon(), b.edge.getCanon()) // ends on a,\r\n // on colinear segment b bT != a.edge.bT && // b can be colinear, so edgeT == aT is possible if (a.p.like(b.edge.a)\r\n // || a.p.like(b.edge.b)) { const corner = a.p.like(b.edge.a) ? b.edge.a : b.edge.b // face2brep corner on edge\r\n // const sVEC1 = splitsVolumeEnclosingCone(face2Brep, corner, a.edge.aDir) const sVEC2 =\r\n // splitsVolumeEnclosingCone(face2Brep, corner, a.edge.aDir.negated()) // if either of these return\r\n // ALONG_EDGE_OR_PLANE, then the breps share a colinear edge if (INSIDE == sVEC1 || INSIDE == sVEC2) {\r\n // mapPush(thisEdgePoints, a.edge.getCanon(), a) assert(a.edge.isValidT(a.edgeT)) } } else { // edge / edge center\r\n // intersection const aEdgeDir = a.edge.tangentAt(a.edgeT) const bEdgeDir = b.edge.tangentAt(b.edgeT) const\r\n // testVector = aEdgeDir.rejectedFrom(bEdgeDir) assert(!testVector.likeO()) const sVEF1 =\r\n // splitsVolumeEnclosingFaces(face2Brep, b.edge.getCanon()Vector, thisPlane.normal1) const sVEF2 =\r\n // splitsVolumeEnclosingFaces(face2Brep, b.edge.getCanon()Vector.negated(), thisPlane.normal1) if (INSIDE ==\r\n // sVEF1 || INSIDE == sVEF2) { mapPush(thisEdgePoints, a.edge.getCanon(), a) assert(a.edge.isValidT(a.edgeT)) } } }\r\n // } } foo(a, b, face, face2, thisPlane, face2Plane, thisBrep, face2Brep, true, thisEdgePoints) foo(b, a, face2,\r\n // face, face2Plane, thisPlane, face2Brep, thisBrep, false, otherEdgePoints) } } assertInst(PlaneFace, face2)\r\n // const face: PlaneFace = this // get intersection const thisPlane = this.surface.plane, face2Plane =\r\n // face2.surface.plane if (thisPlane.isParallelToPlane(face2Plane)) { if (thisPlane.like(face2Plane)) { // normal1\r\n // same and same location in space // addLikeSurfaceFaces(likeSurfaceFaces, this, face2) } return } const isLine =\r\n // L3.fromPlanes(thisPlane, face2Plane) // get intersections of newCurve with other edges of face and face2 const\r\n // ps1 = planeFaceEdgeISPsWithPlane(face, isLine, face2Plane) const ps2 = planeFaceEdgeISPsWithPlane(face2, isLine,\r\n // thisPlane) if (ps1.length == 0 || ps2.length == 0) { // faces to not intersect return } let col1:\r\n // IntersectionPointInfo, col2: IntersectionPointInfo let in1 = false, in2 = false let i = 0, j = 0, last let\r\n // startP, startDir, startT, startA, startB while (i < ps1.length || j < ps2.length) { assert(i <= ps1.length)\r\n // assert(j <= ps2.length) const a = ps1[i], b = ps2[j] assert(a || b) if (j == ps2.length || i < ps1.length &&\r\n // lt(a.t, b.t)) { last = a in1 = !in1 a.used = true in1 && (col1 = a.colinear && a) i++ } else if (i == ps1.length\r\n // || gt(a.t, b.t)) { last = b in2 = !in2 b.used = true in2 && (col2 = b.colinear && b) j++ } else { // TODO: this\r\n // will break if 3 points on the same t last = a in1 = !in1 in2 = !in2 //if (in1 == in2) { a.used = true b.used =\r\n // true in1 && (col1 = a.colinear && a) in2 && (col2 = b.colinear && b) //} i++ j++ } if (startP && !(in1 && in2))\r\n // { // segment end const newEdge = new StraightEdge(isLine, startP, last.p, startT, last.t, undefined, 'genseg' +\r\n // getGlobalId()) startP = undefined last.used = true if (handleNewEdge(newEdge, col1 && col1.edge, col2 &&\r\n // col2.edge)) { handleEndPoint(startA || col1, startB || col2, newEdge) handleEndPoint(a && a.used && a || col1, b\r\n // && b.used && b || col2, newEdge) } } else if (in1 && in2) { // new segment just started startP = last.p startDir\r\n // = last.insideDir startT = last.t startA = a && a.used && a startB = b && b.used && b } if (!in1 && a && last ==\r\n // a && a.colinear) { checkedPairs.add(new Pair(a.edge.getCanon(), face2)) } if (!in2 && b && (last == b || b.used)\r\n // && b.colinear) { checkedPairs.add(new Pair(b.edge.getCanon(), face)) } } }\r\n withHole(holeEdges) {\r\n return new PlaneFace(this.surface, this.contour, [holeEdges]);\r\n }\r\n pointsToInside(p, dir) {\r\n return this.containsPoint2(p.plus(dir.times(NLA_PRECISION * 8)));\r\n }\r\n edgeISPsWithPlane(isLine, plane2) {\r\n const face = this;\r\n assert(face.surface.plane.containsLine(isLine));\r\n assert(plane2.containsLine(isLine));\r\n const plane = face.surface.plane;\r\n const ps = [];\r\n const loops = [face.contour].concat(face.holes);\r\n loops.forEach((loop) => {\r\n const colinearEdges = loop.map((edge) => edge.colinearToLine(isLine) && -sign(edge.aDir.dot(isLine.dir1)));\r\n const isLineOut = isLine.dir1.cross(plane.normal1);\r\n loop.forEach((edge, edgeIndex, edges) => {\r\n const nextEdgeIndex = (edgeIndex + 1) % edges.length, nextEdge = edges[nextEdgeIndex], colinearEdge = colinearEdges[edgeIndex];\r\n //console.log(edge.toSource()) {p:V3(2, -2.102, 0),\r\n if (colinearEdge) {\r\n // edge colinear to intersection line\r\n const curveAT = isLine.pointT(edge.a), curveBT = isLine.pointT(edge.b);\r\n // add interval for colinear segment\r\n ps.push({\r\n p: edge.a,\r\n insideDir: edge.aDir,\r\n t: curveAT,\r\n edge: edge,\r\n edgeT: edge.aT,\r\n colinear: true,\r\n }, {\r\n p: edge.b,\r\n insideDir: edge.bDir.negated(),\r\n t: curveBT,\r\n edge: edge,\r\n edgeT: edge.bT,\r\n colinear: true,\r\n });\r\n // open next interval if necessary\r\n const nextSide = colinearEdges[nextEdgeIndex] ||\r\n dotCurve2(nextEdge.curve, nextEdge.aT, isLineOut, nextEdge.deltaTSign());\r\n if (colinearEdge * nextSide < 0) {\r\n // side changes\r\n ps.push({\r\n p: nextEdge.a,\r\n insideDir: edge.bDir,\r\n t: curveBT,\r\n edge: nextEdge,\r\n edgeT: nextEdge.aT,\r\n colinear: false,\r\n });\r\n }\r\n }\r\n else {\r\n // not necessarily a straight edge, so multiple intersections are possible\r\n const edgeTs = edge.edgeISTsWithPlane(plane2);\r\n assert(edgeTs.every((t) => plane2.containsPoint(edge.curve.at(t))), edgeTs);\r\n for (const edgeT of edgeTs) {\r\n if (edgeT == edge.bT) {\r\n // endpoint lies on intersection line\r\n const side = dotCurve2(edge.curve, edge.bT, isLineOut, -edge.deltaTSign());\r\n const nextSide = colinearEdges[nextEdgeIndex] ||\r\n dotCurve2(nextEdge.curve, nextEdge.aT, isLineOut, nextEdge.deltaTSign());\r\n if (side * nextSide < 0) {\r\n // next segment is not colinear and ends on different side\r\n ps.push({\r\n p: edge.b,\r\n insideDir: plane2.normal1.negated(),\r\n t: isLine.pointT(edge.b),\r\n edge: edge,\r\n edgeT: edge.bT,\r\n colinear: false,\r\n });\r\n }\r\n }\r\n else if (edgeT != edge.aT) {\r\n // edge crosses intersection line, neither starts nor ends on it\r\n const p = edge.curve.at(edgeT);\r\n assert(plane2.containsPoint(p), edge.toString(), p, edgeT, plane2.distanceToPoint(p));\r\n assert(isLine.containsPoint(p), edge.toString(), p, edgeT, isLine.distanceToPoint(p));\r\n const insideDir = plane2.normal1.negated();\r\n ps.push({\r\n p: p,\r\n insideDir: insideDir,\r\n t: isLine.pointT(p),\r\n edge: edge,\r\n edgeT: edgeT,\r\n colinear: false,\r\n });\r\n }\r\n }\r\n }\r\n });\r\n });\r\n // duplicate 't's are ok, as sometimes a segment needs to stop and start again\r\n // should be sorted so that back facing ones are first\r\n ps.sort((a, b) => a.t - b.t || a.insideDir.dot(isLine.dir1));\r\n return ps;\r\n }\r\n}\r\nexport class RotationFace extends Face {\r\n constructor(rot, contour, holes, name, info) {\r\n super(rot, contour, holes, name, info);\r\n }\r\n static loopDoesNotCrossPlane(loop, seamPlane) {\r\n let side = 0;\r\n // returns true if d is on the other side as previous calls\r\n function checkSide(d) {\r\n if (side == 0) {\r\n side = d;\r\n }\r\n else {\r\n return !side || side * d < 0;\r\n }\r\n return false;\r\n }\r\n for (const edge of loop) {\r\n const ts = edge.edgeISTsWithPlane(seamPlane);\r\n if (ts.length == 0) {\r\n if (!(edge.curve instanceof L3) &&\r\n checkSide(seamPlane.distanceToPointSigned(edge.a)))\r\n return false;\r\n }\r\n else {\r\n for (const t of ts) {\r\n // TODO: this part probably should be in a separate function\r\n // check 'backwards' only if if aT != t\r\n if (edge.aT != t) {\r\n if (checkSide(dotCurve2(edge.curve, t, seamPlane.normal1, -edge.deltaTSign())))\r\n return false;\r\n }\r\n if (edge.bT != t) {\r\n if (checkSide(dotCurve2(edge.curve, t, seamPlane.normal1, edge.deltaTSign())))\r\n return false;\r\n }\r\n }\r\n }\r\n }\r\n return true;\r\n }\r\n getAABB() {\r\n if (this.aabb)\r\n return this.aabb;\r\n this.aabb = AABB.forAABBs(this.contour.map((e) => e.getAABB()));\r\n this.aabb.addPoints(this.surface.getExtremePoints().filter((p) => this.containsPoint(p)));\r\n return this.aabb;\r\n }\r\n unrollLoop(edgeLoop) {\r\n const vs = [];\r\n const uvP = this.surface.uvPFunc();\r\n const verticesNo0s = edgeLoop.map((edge) => edge.getVerticesNo0());\r\n const startEdgeIndex = verticesNo0s.findIndex((edgeVertices) => !eq(uvP(edgeVertices[0]).x, Math.PI));\r\n assert(-1 != startEdgeIndex);\r\n // console.log(startEdgeIndex)\r\n for (let i = 0; i < edgeLoop.length; i++) {\r\n const edgeIndex = (i + startEdgeIndex) % edgeLoop.length;\r\n for (let j = 0; j < verticesNo0s[edgeIndex].length; j++) {\r\n const p = verticesNo0s[edgeIndex][j];\r\n const localP = uvP(p);\r\n // console.log(hint, p.sce, localP.sce)\r\n vs.push(localP);\r\n }\r\n }\r\n edgeLoop.forEach((edge) => {\r\n edge.getVerticesNo0().forEach((p) => {\r\n vs.push(uvP(p));\r\n });\r\n });\r\n console.log(\"vs\\n\", vs.join(\"\\n\"), vs.length);\r\n return vs;\r\n }\r\n /**\r\n * f1 cos t + f2 sin t\r\n * tan(phi) = sin / cos\r\n * = (f1x cos t + f2x sin t) / (f1y cos t + f2y sin t)\r\n *\r\n * = (-f1x sin t + f2x cos t) / (-f1y sin t + f2y cos t)\r\n */\r\n unrollEllipsoidLoops(edgeLoops) {\r\n const verticesUV = [], vertices = [], loopStarts = [];\r\n const ellipsoid = this.surface;\r\n const ptpf = ellipsoid.uvPFunc();\r\n const testDegeneratePoint = ellipsoid instanceof EllipsoidSurface\r\n ? (nextStart) => nextStart.like(ellipsoid.center.plus(ellipsoid.f3)) ||\r\n nextStart.like(ellipsoid.center.minus(ellipsoid.f3))\r\n : (nextStart) => nextStart.like(this.surface.center);\r\n for (const edgeLoop of edgeLoops) {\r\n loopStarts.push(verticesUV.length);\r\n // console.log(startEdgeIndex)\r\n for (let i = 0; i < edgeLoop.length; i++) {\r\n const ipp = (i + 1) % edgeLoop.length;\r\n const verticesNo0 = edgeLoop[i].getVerticesNo0();\r\n vertices.push(...verticesNo0);\r\n verticesUV.push(...verticesNo0.map((v) => ptpf(v)));\r\n const nextStart = edgeLoop[ipp].a;\r\n //console.log('BLAH', nextStart.str, ellipsoid.center.plus(ellipsoid.f3).str)\r\n if (testDegeneratePoint(nextStart)) {\r\n const bDirLC = ellipsoid.matrixInverse.transformVector(edgeLoop[i].bDir), aDirLC = ellipsoid.matrixInverse.transformVector(edgeLoop[ipp].aDir);\r\n const inAngle = Math.atan2(-bDirLC.y, -bDirLC.x);\r\n const outAngle = Math.atan2(aDirLC.y, aDirLC.x);\r\n const stLast = verticesUV.pop();\r\n verticesUV.push(new V3(inAngle, stLast.y, 0), new V3(outAngle, stLast.y, 0));\r\n vertices.push(getLast(vertices));\r\n }\r\n verticesUV.forEach(({ u, v }) => {\r\n assert(isFinite(u));\r\n assert(isFinite(v));\r\n });\r\n }\r\n }\r\n let normals;\r\n if (this.surface instanceof EllipsoidSurface) {\r\n normals = vertices.map((v) => ellipsoid.normalP(v));\r\n }\r\n else {\r\n const normalUV = ellipsoid.normalUVFunc();\r\n normals = verticesUV.map(({ u, v }) => normalUV(u, v));\r\n }\r\n assert(vertices.length == vertices.length);\r\n //console.log(verticesUV.map(v => v.str).join('\\n'))\r\n return {\r\n verticesUV: verticesUV,\r\n vertices: vertices,\r\n normals: normals,\r\n loopStarts: loopStarts,\r\n };\r\n }\r\n unrollCylinderLoops(loops) {\r\n const vertexLoops = loops.map((loop) => loop.flatMap((edge) => edge.getVerticesNo0()));\r\n const surface = this.surface;\r\n const vertices = concatenated(vertexLoops);\r\n // this.unrollLoop(loop).map(v => new V3(v.x / uStep, v.y / vStep, 0)))\r\n const loopStarts = vertexLoops.reduce((arr, loop) => (arr.push(getLast(arr) + loop.length), arr), [0]);\r\n const uvPFunc = surface.uvPFunc();\r\n const verticesUV = vertices.map((v) => uvPFunc(v));\r\n const uvN = surface.normalUVFunc();\r\n const normals = verticesUV.map(({ u, v }) => uvN(u, v));\r\n return {\r\n verticesUV: verticesUV,\r\n vertices: vertices,\r\n normals: normals,\r\n loopStarts: loopStarts,\r\n };\r\n }\r\n /**\r\n * at(s, t) = new V3(s cos t, s sin t, t + )\r\n *\r\n * x = 0\r\n *\r\n * s cos t = 0\r\n * ==> s = 0 || cos t = 0\r\n * ==> L3.Z || V3(0, +-s, k * 2 pi)\r\n *\r\n * x = c\r\n * s cos t = c\r\n * ==> V3(c, c sin t / cos t = c tan t, t)\r\n * ==> V3(c, c t, arctan t)\r\n *\r\n *\r\n * x . n = w\r\n * s cos t nx + s sin t ny + t nz = w\r\n * s = (w - t nz) / (cos t nx + sub t ny)\r\n * ==> V3(\r\n * cos t (w - t nz) / (cos t nx + sin t ny)\r\n * sin t (w - t nz) / (cos t nx + sin t ny)\r\n * t)\r\n *\r\n * ==> V3(\r\n * (w - z arctan t) / (x + t y)\r\n * (w - z arctan t) / (y + x / t)\r\n * arctan t)\r\n *\r\n *\r\n *\r\n */\r\n addToMesh(mesh, uStep = this.surface.uStep, vStep = this.surface.vStep) {\r\n assertf(() => uStep > 0 && vStep > 0, uStep, vStep, \"Surface: \" + this.surface);\r\n const triangles = [];\r\n const pMN = (m, n) => this.surface.pUVFunc()(m * uStep, n * vStep);\r\n const normalMN = (m, n) => this.surface.normalUVFunc()(m * uStep, n * vStep);\r\n const loops = this.getLoops();\r\n const { vertices, verticesUV, normals, loopStarts } = this.surface instanceof EllipsoidSurface ||\r\n this.surface instanceof ConicSurface\r\n ? this.unrollEllipsoidLoops(loops)\r\n : this.unrollCylinderLoops(loops);\r\n loopStarts.push(vertices.length);\r\n const verticesMN = verticesUV.map(({ u, v }) => new V3(u / uStep, v / vStep, 0));\r\n for (let vertexLoopIndex = 0; vertexLoopIndex < loops.length; vertexLoopIndex++) {\r\n const vertexLoopStart = loopStarts[vertexLoopIndex];\r\n const vertexLoopLength = loopStarts[vertexLoopIndex + 1] - vertexLoopStart;\r\n const base = mesh.vertices.length + loopStarts[vertexLoopIndex];\r\n for (let i = 0; i < vertexLoopLength; i++) {\r\n mesh.LINES.push(base + i, base + ((i + 1) % vertexLoopLength));\r\n }\r\n }\r\n disableConsole();\r\n let minM = Infinity, maxM = -Infinity, minN = Infinity, maxN = -Infinity;\r\n //console.log('surface', this.surface.str)\r\n //console.log(verticesMN)\r\n //drPs.push(...verticesMN.map((v, i) => ({p: vertices[i], text: `${i} uv: ${v.toString(x => round10(x,\r\n // -4))}`})))\r\n verticesMN.forEach(([m, n]) => {\r\n assert(isFinite(m));\r\n assert(isFinite(n));\r\n minM = min(minM, m);\r\n maxM = max(maxM, m);\r\n minN = min(minN, n);\r\n maxN = max(maxN, n);\r\n });\r\n if (ParametricSurface.is(this.surface)) {\r\n //assert(this.surface.boundsSigned(minM * uStep, minN * vStep) > -NLA_PRECISION)\r\n //assert(this.surface.boundsSigned(maxM * uStep, maxN * vStep) > -NLA_PRECISION)\r\n }\r\n const mOffset = floor(minM + NLA_PRECISION), nOffset = floor(minN + NLA_PRECISION);\r\n const mRes = ceil(maxM - NLA_PRECISION) - mOffset, nRes = ceil(maxN - NLA_PRECISION) - nOffset;\r\n console.log(uStep, vStep, mRes, nRes);\r\n if (mRes == 1 && nRes == 1) {\r\n // triangulate this face as if it were a plane\r\n const polyTriangles = triangulateVertices(V3.Z, verticesMN, loopStarts.slice(1, 1 + this.holes.length));\r\n triangles.push(...polyTriangles);\r\n }\r\n else {\r\n const partss = new Array(mRes * nRes);\r\n function fixUpPart(part, baseM, baseN) {\r\n assert(baseM < mRes && baseN < nRes, `${baseM}, ${baseN}, ${mRes}, ${nRes}`);\r\n console.log(\"complete part\", part, baseM, baseN);\r\n //console.trace()\r\n assert(part.length);\r\n const cellM = baseM + mOffset, cellN = baseN + nOffset;\r\n for (const index of part) {\r\n assert(le(cellM, verticesMN[index].x) &&\r\n le(verticesMN[index].x, cellM + 1), `${index} ${verticesMN[index].str} ${cellM} ${cellM}`);\r\n assert(le(cellN, verticesMN[index].y) &&\r\n le(verticesMN[index].y, cellN + 1));\r\n }\r\n const pos = baseN * mRes + baseM;\r\n (partss[pos] || (partss[pos] = [])).push(part);\r\n //const outline = partss[pos] || (partss[pos] = [minM + baseM * uStep, minN + baseN * vStep, minM +\r\n // (baseM + 1) * uStep, minN + (baseN + 1) * vStep])\r\n }\r\n // 'some' instead of forEach so we can return out of the entire function if this.edges crosses no borders\r\n // and\r\n for (let vertexLoopIndex = 0; vertexLoopIndex < loops.length; vertexLoopIndex++) {\r\n let part = undefined;\r\n let firstPart = undefined;\r\n let firstPartBaseM = -1;\r\n let firstPartBaseN = -1;\r\n let lastBaseM = -1, lastBaseN = -1;\r\n let partCount = 0;\r\n const vertexLoopStart = loopStarts[vertexLoopIndex];\r\n const vertexLoopLength = loopStarts[vertexLoopIndex + 1] - vertexLoopStart;\r\n for (let vlvi = 0; vlvi < vertexLoopLength; vlvi++) {\r\n const vx0index = vertexLoopStart + vlvi, vx0 = verticesMN[vx0index];\r\n const vx1index = vertexLoopStart + ((vlvi + 1) % vertexLoopLength), vx1 = verticesMN[vx1index];\r\n //console.log('dask', vx0index, vx1index)\r\n const vx01 = vx0.to(vx1);\r\n assert(vx0);\r\n const di = vx01.x, dj = vx01.y;\r\n let vxIndex = vx0index, vx = vx0, currentT = 0;\r\n let whileLimit = 400;\r\n while (--whileLimit) {\r\n // points which are on a grid line are assigned to the cell into which they are going (+\r\n // NLA_PRECISION * sign(di)) if they are parallel to the gridline (eq0(di)), they belong the\r\n // the cell for which they are a CCW boundary\r\n const baseM = floor(vx.u + (!eq0(di) ? sign(di) : -sign(dj)) * NLA_PRECISION) -\r\n mOffset;\r\n const baseN = floor(vx.v + (!eq0(dj) ? sign(dj) : sign(di)) * NLA_PRECISION) -\r\n nOffset;\r\n assert(baseM < mRes && baseN < nRes, `${baseM}, ${baseN}, ${mRes}, ${nRes}`);\r\n // figure out the next intersection with a gridline:\r\n // iNext is the positive horizontal distance to the next vertical gridline\r\n const iNext = ceil(sign(di) * vx.u + NLA_PRECISION) - sign(di) * vx.u;\r\n const jNext = ceil(sign(dj) * vx.v + NLA_PRECISION) - sign(dj) * vx.v;\r\n const iNextT = currentT + iNext / abs(di);\r\n const jNextT = currentT + jNext / abs(dj);\r\n //console.log(vxIndex, vx.str, 'vij', vx.u, vx.v, 'd', di, dj, 'ijNext', iNext, jNext, 'nextT',\r\n // iNextT, jNextT)\r\n if (lastBaseM != baseM || lastBaseN != baseN) {\r\n if (part) {\r\n if (!firstPart) {\r\n firstPart = part;\r\n firstPartBaseM = lastBaseM;\r\n firstPartBaseN = lastBaseN;\r\n }\r\n else {\r\n partCount++;\r\n fixUpPart(part, lastBaseM, lastBaseN);\r\n }\r\n }\r\n part = [vxIndex];\r\n }\r\n lastBaseM = baseM;\r\n lastBaseN = baseN;\r\n currentT = min(iNextT, jNextT);\r\n if (ge(currentT, 1)) {\r\n //console.log('breaking ', vx1index)\r\n part.push(vx1index);\r\n break;\r\n }\r\n else {\r\n const nextPoint = vx0.lerp(vx1, currentT);\r\n const nextPointIndex = addVertex(nextPoint.x, nextPoint.y);\r\n //console.log('pushing ', nextPointIndex)\r\n part.push(nextPointIndex);\r\n vx = nextPoint;\r\n vxIndex = nextPointIndex;\r\n }\r\n }\r\n assert(whileLimit, \"whileLimit\");\r\n }\r\n if (0 == partCount) {\r\n // complete loop\r\n assert(false, \"found a hole, try increasing resolution\");\r\n }\r\n // at this point, the firstPart hasn't been added, and the last part also hasn't been added\r\n // either they belong to the same cell, or not\r\n if (firstPartBaseM == lastBaseM && firstPartBaseN == lastBaseN) {\r\n part.pop();\r\n fixUpPart(part.concat(firstPart), lastBaseM, lastBaseN);\r\n }\r\n else {\r\n fixUpPart(firstPart, firstPartBaseM, firstPartBaseN);\r\n fixUpPart(part, lastBaseM, lastBaseN);\r\n }\r\n console.log(\"firstPart\", firstPart);\r\n }\r\n console.log(\"calculated parts\", partss);\r\n const fieldVertexIndices = new Array((mRes + 1) * (nRes + 1));\r\n function addVertex(m, n) {\r\n verticesMN.push(new V3(m, n, 0));\r\n normals.push(normalMN(m, n));\r\n return vertices.push(pMN(m, n)) - 1;\r\n }\r\n function getGridVertexIndex(i, j) {\r\n const index = j * (mRes + 1) + i;\r\n return (fieldVertexIndices[index] ||\r\n (fieldVertexIndices[index] = addVertex(i + mOffset, j + nOffset)));\r\n }\r\n for (let col = 0; col < mRes; col++) {\r\n let inside = false;\r\n for (let row = 0; row < nRes; row++) {\r\n const pos = row * mRes + col;\r\n const fieldU = mOffset + col, fieldV = nOffset + row;\r\n const parts = partss[pos];\r\n if (!parts) {\r\n if (inside) {\r\n pushQuad(triangles, false, getGridVertexIndex(col, row), getGridVertexIndex(col + 1, row), getGridVertexIndex(col, row + 1), getGridVertexIndex(col + 1, row + 1));\r\n }\r\n }\r\n else {\r\n // assemble the field with segments in in\r\n function opos(index) {\r\n const p = verticesMN[index], u1 = p.x - fieldU, v1 = p.y - fieldV;\r\n assert(-NLA_PRECISION < u1 &&\r\n u1 < 1 + NLA_PRECISION &&\r\n -NLA_PRECISION < v1 &&\r\n v1 < 1 + NLA_PRECISION, \"oob u1 v1 \" +\r\n u1 +\r\n \" \" +\r\n v1 +\r\n \" \" +\r\n index +\r\n \" \" +\r\n p.str +\r\n \"IF THIS FAILS check canonSeamU is correct\");\r\n return v1 < u1 ? u1 + v1 : 4 - u1 - v1;\r\n }\r\n while (parts.length) {\r\n const outline = [];\r\n const startPart = parts[0];\r\n assert(startPart.length > 0);\r\n let currentPart = startPart;\r\n do {\r\n outline.push(...currentPart);\r\n const currentPartEndOpos = opos(getLast(currentPart));\r\n const nextPartIndex = indexWithMax(parts, (part) => -mod(opos(part[0]) - currentPartEndOpos, 4));\r\n const nextPart = bagRemoveIndex(parts, nextPartIndex);\r\n let currentOpos = currentPartEndOpos;\r\n const nextPartStartOpos = opos(nextPart[0]) > currentOpos\r\n ? opos(nextPart[0])\r\n : opos(nextPart[0]) + 4;\r\n let nextOpos = ceil(currentOpos + NLA_PRECISION);\r\n let flipping = eq0(((currentOpos + NLA_PRECISION) % 1) - NLA_PRECISION);\r\n //inside = inside != (!eq0(currentOpos % 1) && currentOpos % 2 < 1)\r\n while (lt(nextOpos, nextPartStartOpos)) {\r\n switch (nextOpos % 4) {\r\n case 0:\r\n outline.push(getGridVertexIndex(col, row));\r\n break;\r\n case 1:\r\n inside = inside != flipping;\r\n outline.push(getGridVertexIndex(col + 1, row));\r\n break;\r\n case 2:\r\n outline.push(getGridVertexIndex(col + 1, row + 1));\r\n break;\r\n case 3:\r\n inside = inside != flipping;\r\n outline.push(getGridVertexIndex(col, row + 1));\r\n break;\r\n }\r\n flipping = true;\r\n nextOpos++;\r\n }\r\n // if the next loop would have completed a top or bottom segment\r\n inside =\r\n inside !=\r\n (flipping &&\r\n nextOpos % 2 == 1 &&\r\n eq(nextOpos, nextPartStartOpos));\r\n currentOpos = nextOpos;\r\n currentPart = nextPart;\r\n } while (currentPart != startPart);\r\n // triangulate outline\r\n if (outline.length == 3) {\r\n // its just a triangle\r\n triangles.push(...outline);\r\n }\r\n else {\r\n const polyTriangles = triangulateVertices(V3.Z, outline.map((i) => verticesMN[i]), []).map((i) => outline[i]);\r\n triangles.push(...polyTriangles);\r\n }\r\n //console.log('outline', col, row, outline)\r\n }\r\n }\r\n }\r\n }\r\n }\r\n //console.log('trinagle', triangles.max(), vertices.length, triangles.length, triangles.toSource(),\r\n // triangles.map(col => vertices[col].$).toSource() ) assert(normals.every(n => n.hasLength(1)), normals.find(n\r\n // => !n.hasLength(1)).length() +' '+normals.findIndex(n => !n.hasLength(1)))\r\n Array.prototype.push.apply(mesh.TRIANGLES, triangles.map((index) => index + mesh.vertices.length));\r\n Array.prototype.push.apply(mesh.vertices, vertices);\r\n Array.prototype.push.apply(mesh.normals, normals);\r\n //this.addEdgeLines(mesh)\r\n enableConsole();\r\n }\r\n addToMesh2(mesh) {\r\n const closed = false;\r\n const zSplit = 8;\r\n const ribs = [];\r\n let minZ = Infinity, maxZ = -Infinity;\r\n //let cmp = (a, b) => a.value - b.value\r\n const f = this.surface.pUVFunc();\r\n const normalF = this.surface.normalUVFunc();\r\n const vertexLoops = this.holes\r\n .concat([this.contour])\r\n .map((loop) => this.unrollLoop(loop));\r\n vertexLoops.forEach((vertexLoop) => {\r\n vertexLoop.forEach(({ x: d, y: z }) => {\r\n const index0 = binaryIndexOf(ribs, d, (a, b) => snap(a.value - b, 0));\r\n if (index0 < 0) {\r\n ribs.splice(-index0 - 1, 0, { value: d, left: [], right: [] });\r\n }\r\n minZ = min(minZ, z);\r\n maxZ = max(maxZ, z);\r\n });\r\n });\r\n console.log(\"zzzs\", minZ, maxZ, vertexLoops[0].toSource().replace(/\\), /g, \",\\n\"));\r\n const correction = 1;\r\n vertexLoops.forEach((vertexLoop) => {\r\n vertexLoop.forEach((v0, i, vs) => {\r\n let v1 = vs[(i + 1) % vs.length], dDiff = v1.x - v0.x;\r\n //console.log(v0.sce, v1.sce)\r\n if (eq0(dDiff)) {\r\n return;\r\n }\r\n if (dDiff < 0) {\r\n ;\r\n [v0, v1] = [v1, v0];\r\n dDiff = -dDiff;\r\n }\r\n const index0 = binaryIndexOf(ribs, v0.x, (a, b) => snap(a.value - b, 0));\r\n const index1 = binaryIndexOf(ribs, v1.x, (a, b) => snap(a.value - b, 0));\r\n binaryInsert(ribs[index0].right, v0.y);\r\n for (let j = (index0 + correction) % ribs.length; j != index1; j = (j + correction) % ribs.length) {\r\n const x = ribs[j].value;\r\n const part = (x - v0.x) / dDiff;\r\n const interpolated = v1.y * part + v0.y * (1 - part);\r\n binaryInsert(ribs[j].left, interpolated);\r\n binaryInsert(ribs[j].right, interpolated);\r\n }\r\n binaryInsert(ribs[index1].left, v1.y);\r\n // console.log(ribs.map(r=>r.toSource()).join('\\n'))\r\n });\r\n });\r\n const vertices = [], triangles0 = [], normals = [];\r\n for (let i = 0; i < ribs.length; i++) {\r\n const ribLeft = ribs[i], ribRight = ribs[(i + 1) % ribs.length];\r\n assert(ribLeft.right.length == ribRight.left.length);\r\n for (let j = 0; j < ribLeft.right.length; j++) {\r\n vertices.push(f(ribLeft.value, ribLeft.right[j]), f(ribRight.value, ribRight.left[j]));\r\n normals.push(normalF(ribLeft.value, ribLeft.right[j]), normalF(ribRight.value, ribRight.left[j]));\r\n }\r\n }\r\n //console.log(ribs.map(r=>r.toSource()).join('\\n'))\r\n const vss = vertices.length, detailVerticesStart = vss;\r\n const zInterval = maxZ - minZ, zStep = zInterval / zSplit;\r\n const detailZs = arrayFromFunction(zSplit - 1, (i) => minZ + (1 + i) * zStep);\r\n console.log(\"detailsZs\", detailZs);\r\n for (let i = 0; i < ribs.length; i++) {\r\n const d = ribs[i].value;\r\n for (let j = 0; j < detailZs.length; j++) {\r\n vertices.push(f(d, detailZs[j]));\r\n normals.push(normalF(d, detailZs[j]));\r\n }\r\n }\r\n // console.log('detailVerticesStart', detailVerticesStart, 'vl', vertices.length, vertices.length -\r\n // detailVerticesStart, ribs.length) finally, fill in the ribs\r\n let vsStart = 0;\r\n const flipped2 = true;\r\n //for (var i = 0; i < 1; i++) {\r\n const end = closed ? ribs.length : ribs.length - 1;\r\n for (let i = 0; i < end; i++) {\r\n const ipp = (i + 1) % ribs.length;\r\n let inside = false, colPos = 0;\r\n const ribLeft = ribs[i], ribRight = ribs[(i + 1) % ribs.length];\r\n for (let j = 0; j < detailZs.length + 1; j++) {\r\n const detailZ = detailZs[j] || 100000;\r\n if (!inside) {\r\n if (ribLeft.right[colPos] < detailZ &&\r\n ribRight.left[colPos] < detailZ) {\r\n if (ribLeft.right[colPos + 1] < detailZ ||\r\n ribRight.left[colPos + 1] < detailZ) {\r\n pushQuad(triangles0, flipped2, vsStart + colPos * 2, vsStart + (colPos + 1) * 2, vsStart + colPos * 2 + 1, vsStart + (colPos + 1) * 2 + 1);\r\n colPos += 2;\r\n if (ribLeft.right[colPos] < detailZ ||\r\n ribRight.left[colPos] < detailZ) {\r\n j--;\r\n }\r\n }\r\n else {\r\n pushQuad(triangles0, flipped2, vsStart + colPos * 2, vsStart + colPos * 2 + 1, detailVerticesStart + i * detailZs.length + j, detailVerticesStart + ipp * detailZs.length + j);\r\n inside = true;\r\n colPos++;\r\n }\r\n }\r\n }\r\n else {\r\n if (ribLeft.right[colPos] < detailZ ||\r\n ribRight.left[colPos] < detailZ) {\r\n pushQuad(triangles0, flipped2, detailVerticesStart + i * detailZs.length + j - 1, detailVerticesStart + ipp * detailZs.length + j - 1, vsStart + colPos * 2, vsStart + colPos * 2 + 1);\r\n inside = false;\r\n colPos++;\r\n if (ribLeft.right[colPos] < detailZ ||\r\n ribRight.left[colPos] < detailZ) {\r\n j--;\r\n }\r\n }\r\n else {\r\n pushQuad(triangles0, flipped2, detailVerticesStart + i * detailZs.length + j, detailVerticesStart + i * detailZs.length + j - 1, detailVerticesStart + ipp * detailZs.length + j, detailVerticesStart + ipp * detailZs.length + j - 1);\r\n }\r\n }\r\n }\r\n vsStart += ribLeft.right.length * 2;\r\n }\r\n //console.log('trinagle', triangles0.max(), vertices.length, triangles0.length, triangles0.toSource(),\r\n // triangles0.map(i => vertices[i].$).toSource() )\r\n const triangles = triangles0.map((index) => index + mesh.vertices.length);\r\n //assert(normals.every(n => n.hasLength(1)), normals.find(n => !n.hasLength(1)).length() +'\r\n // '+normals.findIndex(n => !n.hasLength(1)))\r\n Array.prototype.push.apply(mesh.vertices, vertices);\r\n Array.prototype.push.apply(mesh.TRIANGLES, triangles);\r\n Array.prototype.push.apply(mesh.normals, normals);\r\n //this.addEdgeLines(mesh)\r\n }\r\n}\r\n//# sourceMappingURL=Face.js.map","import earcut from \"earcut\";\r\nimport { JavaMap, JavaSet, JavaSet as CustomSet } from \"javasetmap.ts\";\r\nimport nerdamer from \"nerdamer\";\r\nimport { AABB, assert, assertf, assertInst, assertNever, assertNumbers, assertVectors, concatenated, eq, eq0, getLast, gt, indexWithMax, lt, mapFilter, mapPush, newtonIterate2d, newtonIterateWithDerivative, NLA_DEBUG, NLA_PRECISION, SCE, snap, snap0, sum, TAU, Transformable, V, V3, withMax, } from \"ts3dutils\";\r\nimport { Mesh } from \"tsgl\";\r\nimport { curvePointMF, Face, L3, P3, PlaneFace, PointVsFace, uvInAABB2, createEdge, } from \".\";\r\nimport { abs, sign, sqrt } from \"./math\";\r\nexport const EPS = 1e-5;\r\nlet globalId = 0;\r\nexport function getGlobalId() {\r\n return globalId++;\r\n}\r\nexport function addLikeSurfaceFaces(likeSurfaceFaces, face1, face2) {\r\n // There cannot be two subgroups which will later be connected, as the \"graph\" of like surface faces is fully\r\n // connected\r\n for (let i = 0; i < likeSurfaceFaces.length; i++) {\r\n const faceGroup = likeSurfaceFaces[i];\r\n let foundFace1 = false, foundFace2 = false;\r\n for (let j = 0; j < faceGroup.length; j++) {\r\n const face = faceGroup[j];\r\n if (face == face1) {\r\n foundFace1 = true;\r\n }\r\n if (face == face2) {\r\n foundFace2 = true;\r\n }\r\n }\r\n if (foundFace1 != foundFace2) {\r\n faceGroup.push(foundFace1 ? face2 : face1);\r\n return;\r\n }\r\n else if (foundFace1) {\r\n // found both\r\n return;\r\n }\r\n }\r\n // nothing found, add a new group\r\n likeSurfaceFaces.push([face1, face2]);\r\n}\r\nexport function assembleFaceFromLooseEdges(edges, surface, originalFace) {\r\n const visited = new Set();\r\n function nextStart() {\r\n return edges.find((edge) => !visited.has(edge));\r\n }\r\n const loops = [];\r\n let startEdge, currentEdge = undefined;\r\n while ((startEdge = nextStart())) {\r\n currentEdge = startEdge;\r\n const loop = [];\r\n let total = 0;\r\n do {\r\n visited.add(currentEdge);\r\n loop.push(currentEdge);\r\n const possibleEdges = edges.filter((edge) => currentEdge.b.like(edge.a));\r\n const normalAtCurrentB = surface.normalP(currentEdge.b);\r\n const nextEdgeIndex = indexWithMax(possibleEdges, (edge) => currentEdge.bDir.angleRelativeNormal(edge.aDir, normalAtCurrentB));\r\n currentEdge = possibleEdges[nextEdgeIndex];\r\n } while (startEdge != currentEdge && total++ < 200);\r\n assert(total != 201);\r\n loops.push(loop);\r\n }\r\n const assembledFaces = BRep.assembleFacesFromLoops(loops, surface, originalFace);\r\n assertf(() => 1 == assembledFaces.length);\r\n return assembledFaces[0];\r\n}\r\n/**\r\n * ## Markdown header\r\n * ![foo](screenshots/Capture.PNG)\r\n * {@link ../screenshots/Capture.PNG}\r\n * find the next edge with the MAXIMUM angle\r\n */\r\nexport function calcNextEdgeIndex(currentEdge, possibleEdges, faceNormalAtCurrentB) {\r\n let maxValue = -20, advanced = false, result = Number.MAX_SAFE_INTEGER;\r\n const normVector = currentEdge.bDir.cross(faceNormalAtCurrentB);\r\n const eps = 1e-4;\r\n const dir = sign(currentEdge.deltaT());\r\n const ecd = currentEdge.curve.diff(currentEdge.bT, -dir * eps).dot(normVector);\r\n for (let i = possibleEdges.length; i--;) {\r\n const edge = possibleEdges[i];\r\n const angle1 = currentEdge.bDir\r\n .negated()\r\n .angleRelativeNormal(edge.aDir, faceNormalAtCurrentB);\r\n const angle = ((angle1 + TAU + NLA_PRECISION) % TAU) - NLA_PRECISION;\r\n if (eq0(angle)) {\r\n // do advanced analysis\r\n if (currentEdge.curve.isColinearTo(edge.curve)) {\r\n continue;\r\n }\r\n const edgeDir = sign(edge.deltaT());\r\n const iscd = edge.curve.diff(edge.aT, edgeDir * eps).dot(normVector);\r\n const diff = iscd - ecd;\r\n // if diff > 0, the angle is actually ~= 0\r\n if (diff < 0 && (!advanced || diff > maxValue)) {\r\n advanced = true;\r\n maxValue = diff;\r\n result = i;\r\n }\r\n }\r\n else if (!advanced) {\r\n if (gt(angle, maxValue)) {\r\n maxValue = angle;\r\n result = i;\r\n }\r\n }\r\n }\r\n return result == Number.MAX_SAFE_INTEGER ? 0 : result;\r\n}\r\nexport class BRep extends Transformable {\r\n constructor(faces, infiniteVolume, generator, vertexNames) {\r\n super();\r\n this.faces = faces;\r\n assertInst(Face, ...faces);\r\n this.infiniteVolume = infiniteVolume;\r\n assert(!this.infiniteVolume || true === this.infiniteVolume);\r\n this.generator = generator;\r\n this.vertexNames = vertexNames;\r\n this.edgeFaces = undefined;\r\n //this.assertSanity()\r\n }\r\n static loop1ContainsLoop2(loop1, ccw1, loop2, ccw2, surface) {\r\n for (const edge of loop2) {\r\n const loop1ContainsPoint = surface.loopContainsPoint(loop1, edge.a);\r\n if (PointVsFace.ON_EDGE != loop1ContainsPoint)\r\n return PointVsFace.INSIDE == loop1ContainsPoint;\r\n }\r\n for (const edge of loop2) {\r\n const edgePoint = edge.curve.at(edge.aT * 0.2 + edge.bT * 0.8);\r\n const loop1ContainsPoint = surface.loopContainsPoint(loop1, edgePoint);\r\n if (PointVsFace.ON_EDGE != loop1ContainsPoint)\r\n return PointVsFace.INSIDE == loop1ContainsPoint;\r\n }\r\n if (ccw1 != ccw2) {\r\n return ccw2;\r\n }\r\n throw new Error(loop1.sce + loop2.sce);\r\n }\r\n static assembleFacesFromLoops(loops, surface, originalFace, infoFactory) {\r\n function placeRecursively(newLoopInfo, loopInfos) {\r\n if (loopInfos.length == 0) {\r\n loopInfos.push(newLoopInfo);\r\n }\r\n else {\r\n const subLoopInfo = loopInfos.find((loopInfo) => BRep.loop1ContainsLoop2(loopInfo.loop, loopInfo.ccw, newLoopInfo.loop, newLoopInfo.ccw, surface));\r\n if (subLoopInfo) {\r\n placeRecursively(newLoopInfo, subLoopInfo.subloops);\r\n }\r\n else {\r\n // newLoopInfo isnt contained by any other subLoopInfo\r\n for (let i = loopInfos.length; --i >= 0;) {\r\n const subLoopInfo = loopInfos[i];\r\n //console.log(\"cheving subLoopInfo\", surface.loopContainsPoint(newLoopInfo.edges,\r\n // subLoopInfo.edges[0].a))\r\n if (BRep.loop1ContainsLoop2(newLoopInfo.loop, newLoopInfo.ccw, subLoopInfo.loop, subLoopInfo.ccw, surface)) {\r\n newLoopInfo.subloops.push(subLoopInfo);\r\n loopInfos.splice(i, 1); // remove it\r\n }\r\n }\r\n loopInfos.push(newLoopInfo);\r\n }\r\n }\r\n }\r\n function newFacesRecursive(loopInfo) {\r\n // CW loops can be top level, if they are holes in the original face not contained in the new face\r\n if (loopInfo.ccw) {\r\n if (loopInfo.subloops.every((sl) => !sl.ccw)) {\r\n const holes = loopInfo.subloops.map((sl) => sl.loop);\r\n const info = infoFactory &&\r\n infoFactory.newSubFace(originalFace, surface, loopInfo.loop, holes);\r\n const newFace = new originalFace.constructor(surface, loopInfo.loop, holes, \"genface\" + getGlobalId(), info);\r\n newFaces.push(newFace);\r\n loopInfo.subloops.forEach((sl) => sl.subloops.forEach((slsl) => slsl.ccw && newFacesRecursive(slsl)));\r\n }\r\n else {\r\n loopInfo.subloops.forEach((sl) => sl.ccw && newFacesRecursive(sl));\r\n }\r\n }\r\n }\r\n const newFaces = [];\r\n const topLevelLoops = [];\r\n loops.forEach((loop) => placeRecursively({\r\n loop: loop,\r\n ccw: surface.edgeLoopCCW(loop),\r\n subloops: [],\r\n }, topLevelLoops));\r\n topLevelLoops.forEach((tll) => newFacesRecursive(tll));\r\n return newFaces;\r\n }\r\n /**\r\n * Create a [BRep] by concatenating the faces of other BReps. Only use this if certain that the faces of the BReps do not intersect.\r\n * Otherwise, use [BRep.plus].\r\n * @param bReps\r\n * @param generator\r\n */\r\n static join(bReps, generator) {\r\n return new BRep(bReps.flatMap((b2) => b2.faces), false, generator);\r\n }\r\n containsPoint(p, forceInsideOutside = false) {\r\n const dirs = [\r\n V(-0.3920414696448526, -0.12936136783391444, -0.9108068525164064),\r\n V(0.6520650903544943, -0.07151288645511984, -0.7547827667692488),\r\n V(0.9433494201061395, -0.2402757256238473, -0.22882186797013926),\r\n V(0.13678704228501923, -0.04480387361087783, 0.9895867410047372),\r\n V(0.0662057922721913, -0.5865836917435423, 0.8071780259955845),\r\n V(-0.7322576567870621, -0.12953393611526787, 0.6685953061989045),\r\n V(0.6579719127258273, -0.012300218400456116, 0.7529420075219719),\r\n V(-0.5576497966736425, 0.8006695748324647, 0.2189861552871446),\r\n ];\r\n dirLoop: for (const dir of dirs) {\r\n const testLine = new L3(p, dir);\r\n let inside = this.infiniteVolume, minT = Infinity;\r\n for (const face of this.faces) {\r\n assert(!face.surface.containsCurve(testLine));\r\n const ists = face.surface.isTsForLine(testLine);\r\n for (const t of ists) {\r\n const p = testLine.at(t);\r\n const pvf = face.containsPoint2(p);\r\n //assert(pvf != PointVsFace.ON_EDGE)\r\n !forceInsideOutside && assert(!eq0(t));\r\n if (t > 0) {\r\n if (pvf == PointVsFace.ON_EDGE) {\r\n continue dirLoop;\r\n }\r\n if (pvf == PointVsFace.INSIDE) {\r\n inside = !inside;\r\n if (t < minT) {\r\n minT = t;\r\n }\r\n }\r\n }\r\n }\r\n }\r\n return inside;\r\n }\r\n return false;\r\n }\r\n withMergedFaces() {\r\n const likeSurfaceFaces = [];\r\n for (let i = 0; i < this.faces.length; i++) {\r\n let addedToGroup = false;\r\n for (let j = 0; j < i; j++) {\r\n if (this.faces[i].surface.isCoplanarTo(this.faces[j].surface)) {\r\n const faceGroup = likeSurfaceFaces.find((faceGroup) => faceGroup.includes(this.faces[j]));\r\n if (faceGroup) {\r\n faceGroup.push(this.faces[i]);\r\n addedToGroup = true;\r\n }\r\n }\r\n }\r\n !addedToGroup && likeSurfaceFaces.push([this.faces[i]]);\r\n }\r\n console.log(\"likeSurfaceFaces\", likeSurfaceFaces);\r\n if (likeSurfaceFaces.every((group) => group.length == 1))\r\n return this;\r\n const newFaces = [];\r\n let total = 0;\r\n for (const faceGroup of likeSurfaceFaces) {\r\n console.log(faceGroup);\r\n if (faceGroup.length == 1) {\r\n newFaces.push(faceGroup[0]);\r\n }\r\n else {\r\n const allEdges = faceGroup.flatMap((face) => face.getAllEdges());\r\n for (let i = allEdges.length; i-- > 0;) {\r\n for (let j = 0; j < i; j++) {\r\n console.log(\"blugh\", total);\r\n assert(i >= 0 && j >= 0 && total++ < 500, i + \" \" + j + \" \" + total);\r\n if (allEdges[i].isCoEdge(allEdges[j])) {\r\n // remove both\r\n allEdges.splice(i, 1);\r\n allEdges.splice(j, 1);\r\n i--;\r\n break;\r\n }\r\n }\r\n }\r\n const newFace = assembleFaceFromLooseEdges(allEdges, faceGroup[0].surface, faceGroup[0]);\r\n newFaces.push(newFace);\r\n }\r\n }\r\n return new BRep(newFaces, this.infiniteVolume, this.generator && this.generator + \".withMergedFaces()\", this.vertexNames);\r\n }\r\n calculateVolume() {\r\n return sum(this.faces.map((face) => face.zDirVolume().volume));\r\n }\r\n toMesh() {\r\n const mesh = new Mesh()\r\n .addVertexBuffer(\"normals\", \"ts_Normal\")\r\n .addIndexBuffer(\"TRIANGLES\")\r\n .addIndexBuffer(\"LINES\");\r\n mesh.faceIndexes = new Map();\r\n for (const face of this.faces) {\r\n const triangleStart = mesh.TRIANGLES.length;\r\n face.addToMesh(mesh);\r\n mesh.faceIndexes.set(face, {\r\n start: triangleStart,\r\n count: mesh.TRIANGLES.length - triangleStart,\r\n });\r\n }\r\n //this.buildAdjacencies()\r\n //for (const edge of this.edgeFaces.keys()) {\r\n //\r\n //}\r\n return mesh;\r\n }\r\n minus(other, infoFactory) {\r\n const generator = this.generator &&\r\n other.generator &&\r\n this.generator + \".minus(\" + other.generator + \")\";\r\n return this.intersection(other.flipped(), true, true, generator, infoFactory);\r\n }\r\n plus(other, infoFactory) {\r\n const generator = this.generator &&\r\n other.generator &&\r\n this.generator + \".plus(\" + other.generator + \")\";\r\n return this.flipped()\r\n .intersection(other.flipped(), true, true, generator, infoFactory)\r\n .flipped();\r\n }\r\n and(other, infoFactory) {\r\n const generator = this.generator &&\r\n other.generator &&\r\n this.generator + \".and(\" + other.generator + \")\";\r\n return this.intersection(other, true, true, generator, infoFactory);\r\n }\r\n xor(other, infoFactory) {\r\n const generator = this.generator &&\r\n other.generator &&\r\n this.generator + \".xor(\" + other.generator + \")\";\r\n return new BRep(this.minus(other, infoFactory).faces.concat(other.minus(this, infoFactory).faces), this.infiniteVolume != other.infiniteVolume, generator);\r\n }\r\n equals(obj) {\r\n return (this.faces.length == obj.faces.length &&\r\n this.faces.every((face) => obj.faces.some((face2) => face.equals(face2))));\r\n }\r\n like(brep) {\r\n return (this.faces.length == brep.faces.length &&\r\n this.faces.every((face) => brep.faces.some((face2) => face.likeFace(face2))));\r\n }\r\n //reconstituteCoplanarFaces(likeSurfacePlanes, edgeLooseSegments, faceMap, newFaces) {\r\n // likeSurfacePlanes.forEach(faceGroup => {\r\n // // calculate total contours\r\n // let surface = faceGroup[0].surface, bag = []\r\n // faceGroup.forEach(face => {\r\n // Array.prototype.push.apply(bag, faceMap(face))\r\n // face.getAllEdges().forEach(edge => {\r\n // let edgeSubSegments\r\n // if (edgeSubSegments = edgeLooseSegments.get(edge)) {\r\n // Array.prototype.push.apply(bag, edgeSubSegments)\r\n // } else {\r\n // bag.push(edge)\r\n // }\r\n // })\r\n // })\r\n // let currentEdge, loops = []\r\n // while (currentEdge = bag.find(edge => !edge.visited)) {\r\n // let path = []\r\n // do {\r\n // currentEdge.visited = true\r\n // path.push(currentEdge)\r\n // let possibleNextEdges = bag.filter(edge => currentEdge.b.like(edge.a))\r\n // // lowest angle, i.e. the right-most next edge\r\n // let nextEdgeIndex = possibleNextEdges.indexWithMax((edge, index) =>\r\n // -currentEdge.bDir.angleRelativeNormal(edge.aDir, surface.normalP(currentEdge.b))) currentEdge =\r\n // possibleNextEdges[nextEdgeIndex] } while (!currentEdge.visited) let startIndex = path.find(currentEdge) if (-1\r\n // != startIndex) { loops.push(path.slice(startIndex)) } } }) }\r\n toString() {\r\n return `new BRep([\\n${this.faces.join(\",\\n\").replace(/^/gm, \"\\t\")}], ${this.infiniteVolume})`;\r\n }\r\n getConstructorParameters() {\r\n return [this.faces, this.infiniteVolume];\r\n }\r\n toSource(useGenerator = true) {\r\n return ((useGenerator && this.generator) ||\r\n `new BRep([\\n${this.faces.map(SCE).join(\",\\n\").replace(/^/gm, \"\\t\")}], ${this.infiniteVolume})`);\r\n }\r\n /**\r\n * Rightmost next segment doesn't work, as the correct next segment isn't obvious from the current corner\r\n * alone.\r\n * (at least, not without extensive pre-analysis on the face edges, which shouldn't be necessary, as the\r\n * correct new faces are defined by the new edges already.) Leftmost edge should work. Holes which touch the\r\n * edge of the face will be added to the face contour.\r\n *\r\n * New segments will always be part left-er than existing ones, so no special check is required.\r\n *\r\n */\r\n reconstituteFaces(oldFaces, edgeSubEdges, faceMap, newFaces, infoFactory) {\r\n const oldFaceStatuses = new Map();\r\n // reconstitute faces\r\n const insideEdges = [];\r\n for (const face of oldFaces) {\r\n const usableOldEdges = face\r\n .getAllEdges()\r\n .filter((edge) => !edgeSubEdges.get(edge));\r\n const subEdges = concatenated(mapFilter(face.getAllEdges(), (edge) => edgeSubEdges.get(edge)));\r\n const newEdges = faceMap.get(face) || [];\r\n if (newEdges.length || subEdges.length) {\r\n oldFaceStatuses.set(face, \"partial\");\r\n const loops = [];\r\n // new edges are definitely part of a resulting loop\r\n // old edges (both contour and holes) can either be part of a new loop, in which case they will already\r\n // have been visited when starting a loop search with a new edge, OR they can be stranded, OR they can\r\n // remain in their old loop\r\n function getNextStart() {\r\n return (newEdges.find((edge) => !visitedEdges.has(edge)) ||\r\n subEdges.find((edge) => !visitedEdges.has(edge)) ||\r\n usableOldEdges.find((edge) => !visitedEdges.has(edge)));\r\n }\r\n const visitedEdges = new Set();\r\n // search for a loop:\r\n let currentEdge;\r\n while ((currentEdge = getNextStart())) {\r\n const startEdge = currentEdge, edges = [];\r\n let i = 0;\r\n // wether only new edges are used (can include looseSegments)\r\n do {\r\n visitedEdges.add(currentEdge);\r\n edges.push(currentEdge);\r\n // find next edge\r\n const possibleOldEdges = usableOldEdges.filter((edge) => currentEdge.b.like(edge.a));\r\n const possibleSubEdges = subEdges.filter((edge) => currentEdge.b.like(edge.a));\r\n const possibleNewEdges = newEdges.filter((edge) => currentEdge.b.like(edge.a));\r\n const possibleEdges = possibleOldEdges.concat(possibleSubEdges, possibleNewEdges);\r\n if (0 == possibleEdges.length)\r\n break;\r\n assert(0 < possibleEdges.length, () => face.sce);\r\n const faceNormalAtCurrentB = face.surface.normalP(currentEdge.b);\r\n const nextEdgeIndex = calcNextEdgeIndex(currentEdge, possibleEdges, faceNormalAtCurrentB);\r\n currentEdge = possibleEdges[nextEdgeIndex];\r\n if (visitedEdges.has(currentEdge)) {\r\n break;\r\n }\r\n assert(currentEdge);\r\n assert(currentEdge != startEdge);\r\n } while (++i < 400);\r\n if (400 == i) {\r\n assert(false, \"too many\");\r\n }\r\n // check if we found a loop\r\n if (edges.length > 1 && currentEdge == startEdge) {\r\n loops.push(edges);\r\n }\r\n }\r\n const faceNewFaces = BRep.assembleFacesFromLoops(loops, face.surface, face, infoFactory);\r\n newFaces.push(...faceNewFaces);\r\n const faceNewFacesEdges = faceNewFaces.flatMap((face) => face.getAllEdges());\r\n insideEdges.push(...usableOldEdges.filter((edge) => faceNewFacesEdges.includes(edge)));\r\n }\r\n }\r\n while (insideEdges.length != 0) {\r\n const insideEdge = insideEdges.pop();\r\n const adjacentFaces = this.edgeFaces.get(insideEdge.getCanon());\r\n adjacentFaces.forEach((info) => {\r\n if (!oldFaceStatuses.has(info.face)) {\r\n oldFaceStatuses.set(info.face, \"inside\");\r\n insideEdges.push.apply(insideEdges, info.face.getAllEdges());\r\n }\r\n });\r\n }\r\n newFaces.push(...oldFaces.filter((face) => oldFaceStatuses.get(face) == \"inside\"));\r\n }\r\n static getLooseEdgeSegments(edgePointInfoss, edgeFaces) {\r\n const result = new JavaMap();\r\n // if there are no point info, the original edge will be kept, so we should return nothing\r\n // otherwise, something will be returned, even if it a new edge identical to the base edge\r\n for (const [canonEdge, pointInfos] of edgePointInfoss) {\r\n if (0 == pointInfos.length)\r\n continue;\r\n const allFaces = edgeFaces.get(canonEdge);\r\n pointInfos.sort((a, b) => snap0(a.edgeT - b.edgeT) || +!!undefined);\r\n let startP = canonEdge.a, startDir = canonEdge.aDir, startT = canonEdge.aT, startInfo;\r\n function addNewEdge(startInfo, endInfo, newEdge) {\r\n for (let i = 0; i < allFaces.length; i++) {\r\n const faceInfo = allFaces[i];\r\n mapPush(result, !faceInfo.reversed ? canonEdge : canonEdge.flipped(), !faceInfo.reversed ? newEdge : newEdge.flipped());\r\n }\r\n }\r\n for (let i = 0; i < pointInfos.length; i++) {\r\n const info = pointInfos[i];\r\n const pDir = canonEdge.tangentAt(info.edgeT);\r\n if (!eq(info.edgeT, startT)) {\r\n const newEdge = createEdge(canonEdge.curve, startP, info.p, startT, info.edgeT, undefined, startDir, pDir, \"looseSegment\" + getGlobalId());\r\n addNewEdge(startInfo, info, newEdge);\r\n }\r\n startP = info.p;\r\n startT = info.edgeT;\r\n startInfo = info;\r\n startDir = pDir;\r\n }\r\n if (startInfo && !eq(startT, canonEdge.bT)) {\r\n const newEdge = createEdge(canonEdge.curve, startP, canonEdge.b, startT, canonEdge.bT, undefined, startDir, canonEdge.bDir, \"looseSegment\" + getGlobalId());\r\n addNewEdge(startInfo, undefined, newEdge);\r\n }\r\n }\r\n return result;\r\n }\r\n getIntersectionEdges(brep2) {\r\n const faceMap = new Map(), thisEdgePoints = new JavaMap(), otherEdgePoints = new JavaMap();\r\n const checkedPairs = new JavaSet();\r\n this.faces.forEach((face) => {\r\n //console.log('face', face.toString())\r\n brep2.faces.forEach((face2) => {\r\n //console.log('face2', face2.toString())\r\n face.intersectFace(face2, this, brep2, faceMap, thisEdgePoints, otherEdgePoints, checkedPairs);\r\n });\r\n });\r\n return concatenated(Array.from(faceMap.values()));\r\n }\r\n shellCount() {\r\n const foundFaces = new Set();\r\n let face, result = 0;\r\n while ((face = this.faces.find((face) => !foundFaces.has(face)))) {\r\n result++;\r\n const stack = [face];\r\n while ((face = stack.pop())) {\r\n // @ts-ignore\r\n for (const edge of face.getAllEdges()) {\r\n // @ts-ignore\r\n for (const { face: face2 } of this.edgeFaces.get(edge.getCanon())) {\r\n if (face !== face2 && !foundFaces.has(face2)) {\r\n foundFaces.add(face2);\r\n stack.push(face2);\r\n }\r\n }\r\n }\r\n }\r\n }\r\n return result;\r\n }\r\n getAABB() {\r\n return AABB.forAABBs(this.faces.map((face) => face.getAABB()));\r\n }\r\n assertSanity() {\r\n if (!NLA_DEBUG)\r\n return;\r\n // const allFaceEdges = this.faces.flatMap(face => face.getAllEdges())\r\n // for (const { i, j } of combinations(allFaceEdges.length)) {\r\n // const a = allFaceEdges[i],\r\n // \tb = allFaceEdges[j]\r\n // assert(i == j || !a.isCoEdge(b) || a == b || a.flippedOf == b, 'coedges not linked properly', a, b)\r\n // assert(\r\n // \ti == j ||\r\n // \t\t!a.curve.isColinearTo(b.curve) ||\r\n // \t\t(a.curve.equals(b.curve) && a.isCoEdge(b)) ||\r\n // \t\t!a.overlaps(b),\r\n // \t'colinear edges overlap',\r\n // \ta,\r\n // \tb,\r\n // )\r\n // }\r\n this.buildAdjacencies();\r\n for (const [canonEdge, edgeFaceInfos] of this.edgeFaces) {\r\n // TODO handle curved faces\r\n assert(edgeFaceInfos.length % 2 == 0, () => canonEdge + edgeFaceInfos.sce);\r\n }\r\n }\r\n //intersection3(other: BRep, buildThis: boolean, buildOther: boolean, name?: string): BRep {\r\n // this.assertSanity()\r\n // other.assertSanity()\r\n // this.buildAdjacencies()\r\n // other.buildAdjacencies()\r\n //\r\n // // edge / edge\r\n // for (const [edge1, edge1Faces] of this.edgeFaces) {\r\n // for (const [edge2, edge2Faces] of other.edgeFaces) {\r\n // const curve1 = edge1.curve, curve2 = edge2.curve\r\n // if (curve1.isColinearTo(curve2)) {\r\n // if (edge1.overlaps(edge2)) {\r\n // // faces have a common edge\r\n // const aT = curve1.pointT(edge2.a), bT = curve1.pointT(edge2.a)\r\n // const minT = min(aT, bT), maxT = max(aT, bT)\r\n // const commonEdge = createEdge(curve1, min(edge1.minT, minT), min(edge1.maxT, maxT), )\r\n // }\r\n // } else if (x = curve1.isInfosWithCurve(edge2.curve)) {\r\n // // edges intersect in a point\r\n // }\r\n // }\r\n // }\r\n //\r\n // // point / edge\r\n // function pointEdge(b1, b2, has, add) {\r\n // for (const v1 of this.vertFaces.keys()) {\r\n // for (const edge2 of other.edgeFaces.keys()) {\r\n // if (edge2.curve.containsPoint(v1)) {\r\n // const edge2T = edge2.curve.pointT(v1)\r\n // if (eq(edge2.aT, edge2T) || eq(edge2.bT, edge2T)) {\r\n // add(v1, eq(edge2.aT, edge2T) ? edge2.a : edge2.b)\r\n // }\r\n // }\r\n // }\r\n // }\r\n // }\r\n // const pairs: CustomSet<[Equalable, Equalable]> = new CustomSet<[Equalable, Equalable]>()\r\n // pointEdge(this, other, (a, b) => pairs.has([a, b]), (a, b) => pairs.add([a, b]))\r\n // pointEdge(other, this, (b, a) => pairs.has([a, b]), (b, a) => pairs.add([a, b]))\r\n //\r\n //\r\n // // point / point\r\n // for (const v1 of this.vertFaces.keys()) {\r\n // for (const v2 of other.vertFaces.keys()) {\r\n // if (v1.like(v2)) {\r\n //\r\n // }\r\n // }\r\n // }\r\n //\r\n // for (const face1 of this.faces) {\r\n // for (const face2 of other.faces) {\r\n // face1.intersectFace(face2)\r\n // }\r\n // }\r\n //\r\n //}\r\n buildAdjacencies() {\r\n if (this.edgeFaces)\r\n return this;\r\n this.edgeFaces = new JavaMap();\r\n for (const face of this.faces) {\r\n for (const edge of face.getAllEdges()) {\r\n const canon = edge.getCanon();\r\n const normalAtCanonA = face.surface.normalP(canon.a);\r\n const inside = normalAtCanonA.cross(canon == edge ? edge.aDir : edge.bDir);\r\n mapPush(this.edgeFaces, canon, {\r\n face: face,\r\n edge: edge,\r\n normalAtCanonA: normalAtCanonA,\r\n reversed: canon != edge,\r\n inside: inside,\r\n angle: 0,\r\n });\r\n }\r\n }\r\n for (const [canonEdge, edgeFaceInfos] of this.edgeFaces) {\r\n // TODO handle curved faces\r\n //assert(edgeFaceInfos.length % 2 == 0, () => canonEdge + edgeFaceInfos.sce)\r\n const faceInfo0 = edgeFaceInfos.find((faceInfo) => faceInfo.reversed);\r\n if (!faceInfo0) {\r\n console.warn(\"invalid brep\");\r\n continue;\r\n }\r\n edgeFaceInfos.forEach((faceInfo) => {\r\n if (faceInfo != faceInfo0) {\r\n faceInfo.angle = faceInfo0.inside.angleRelativeNormal(faceInfo.inside, canonEdge.aDir.unit());\r\n if (faceInfo.angle < 0)\r\n faceInfo.angle += 2 * Math.PI;\r\n }\r\n });\r\n edgeFaceInfos.sort((a, b) => snap(a.angle - b.angle, 0)); // TODO || assertNever()\r\n }\r\n return this;\r\n }\r\n /**\r\n * Cases for volumes A and B\r\n *\r\n * 1. Volumes do not touch.\r\n * 2. face/face Face surfaces intersect each other.\r\n * implies edges going through faces.\r\n * e.g. box(5, 5, 5) - box(5, 5, 5).translate(1, 1, 1)\r\n * 3. face/edge Edge of A lies in a face of B\r\n * implies vertices of A lying in face of B\r\n * e.g. box(5, 5, 5) - box(3, 3, 3).rotateZ([0, 1, 2] * PI / 2).translate(0, 1, 1)\r\n * 4. edge/edge Two edges are colinear.\r\n * implies vertex of A lying in edge of B\r\n * 5. vertex/edge Vertex of A lies on edge of B (but no edge/edge)\r\n * 6. vertex/vertex with/without edge/edge, edge/face and face/face intersections\r\n * 7. vertex lies in face\r\n *\r\n *\r\n *\r\n */\r\n intersection(other, buildThis, buildOther, generator, infoFactory) {\r\n this.assertSanity();\r\n other.assertSanity();\r\n this.buildAdjacencies();\r\n other.buildAdjacencies();\r\n const faceMap = new Map();\r\n const thisEdgePoints = new JavaMap(), otherEdgePoints = new JavaMap();\r\n const checkedPairs = new CustomSet();\r\n for (const thisFace of this.faces) {\r\n for (const otherFace of other.faces) {\r\n thisFace.intersectFace(otherFace, this, other, faceMap, thisEdgePoints, otherEdgePoints, checkedPairs);\r\n }\r\n }\r\n for (const edge of thisEdgePoints.keys()) {\r\n assert(this.edgeFaces.get(edge));\r\n }\r\n for (const edge of otherEdgePoints.keys()) {\r\n assert(other.edgeFaces.get(edge));\r\n }\r\n const newFaces = [];\r\n if (0 == faceMap.size &&\r\n 0 == thisEdgePoints.size &&\r\n 0 == otherEdgePoints.size) {\r\n const thisInOther = other.containsPoint(this.faces[0].contour[0].a, true) !==\r\n other.infiniteVolume;\r\n const otherInThis = !thisInOther &&\r\n this.containsPoint(other.faces[0].contour[0].a) !== this.infiniteVolume;\r\n if (thisInOther || otherInThis) {\r\n const [inside, outside] = thisInOther ? [this, other] : [other, this];\r\n if (inside.infiniteVolume) {\r\n if (outside.infiniteVolume) {\r\n return outside;\r\n }\r\n else {\r\n return BRep.join([inside, outside]);\r\n }\r\n }\r\n else {\r\n if (outside.infiniteVolume) {\r\n return BRep.EMPTY;\r\n }\r\n else {\r\n return inside;\r\n }\r\n }\r\n }\r\n else {\r\n if (this.infiniteVolume) {\r\n if (other.infiniteVolume) {\r\n return BRep.join([this, other]);\r\n }\r\n else {\r\n other;\r\n }\r\n }\r\n else {\r\n if (other.infiniteVolume) {\r\n return this;\r\n }\r\n else {\r\n return BRep.EMPTY;\r\n }\r\n }\r\n }\r\n return BRep.EMPTY;\r\n }\r\n else {\r\n if (buildThis) {\r\n const edgeLooseSegments = BRep.getLooseEdgeSegments(thisEdgePoints, this.edgeFaces);\r\n // @ts-ignore\r\n const els = this.faces.map((face) => [\r\n face,\r\n Array.from(edgeLooseSegments.entries()).flatMap(([edge, subs]) => face.getAllEdges().some((e) => e.equals(edge)) ? subs : []),\r\n ]);\r\n this.reconstituteFaces(this.faces, edgeLooseSegments, faceMap, newFaces, infoFactory);\r\n }\r\n if (buildOther) {\r\n const edgeLooseSegments = BRep.getLooseEdgeSegments(otherEdgePoints, other.edgeFaces);\r\n // @ts-ignore\r\n const els = other.faces.map((face) => [\r\n face,\r\n Array.from(edgeLooseSegments.entries()).flatMap(([edge, subs]) => face.getAllEdges().some((e) => e.equals(edge)) ? subs : []),\r\n ]);\r\n other.reconstituteFaces(other.faces, edgeLooseSegments, faceMap, newFaces, infoFactory);\r\n }\r\n }\r\n //buildCoplanar && this.reconstituteCoplanarFaces(likeSurfaceFaces, edgeLooseSegments, faceMap, newFaces,\r\n // this.infiniteVolume, other.infiniteVolume)\r\n const result = new BRep(newFaces, this.infiniteVolume && other.infiniteVolume, generator);\r\n //result.buildAdjacencies()\r\n return result;\r\n }\r\n transform(m4, desc) {\r\n let vertexNames;\r\n if (this.vertexNames) {\r\n vertexNames = new Map();\r\n this.vertexNames.forEach((name, vertex) => vertexNames.set(m4.transformPoint(vertex), name + desc));\r\n }\r\n return new BRep(this.faces.map((f) => f.transform(m4)), this.infiniteVolume, this.generator && desc && this.generator + desc, // if desc isn't set, the generator will be invalid\r\n vertexNames);\r\n }\r\n transform4(m4, desc) {\r\n let vertexNames;\r\n if (this.vertexNames) {\r\n vertexNames = new Map();\r\n this.vertexNames.forEach((name, vertex) => vertexNames.set(m4.transformPoint(vertex), name + desc));\r\n }\r\n return new BRep(this.faces.map((f) => f.transform4(m4)), this.infiniteVolume, this.generator && desc && this.generator + desc, // if desc isn't set, the generator will be invalid\r\n vertexNames);\r\n }\r\n flipped() {\r\n return new BRep(this.faces.map((f) => f.flipped()), !this.infiniteVolume, this.generator && this.generator + \".flipped()\", this.vertexNames);\r\n }\r\n}\r\nBRep.EMPTY = new BRep([], false, \"BRep.EMPTY\", new Map()).buildAdjacencies();\r\nBRep.R3 = new BRep([], true, \"BRep.R3\", new Map()).buildAdjacencies();\r\nexport function dotCurve(v, cDir, cDDT) {\r\n let dot = v.dot(cDir);\r\n if (eq0(dot)) {\r\n dot = v.dot(cDDT);\r\n }\r\n assert(!eq0(dot));\r\n return dot;\r\n}\r\nexport function dotCurve2(curve, t, normal, sign) {\r\n assert(sign == 1 || sign == -1, sign);\r\n const tangentDot = curve.tangentAt(t).dot(normal);\r\n // if tangentDot != 0 the curve simply crosses the plane\r\n if (!eq0(tangentDot)) {\r\n return sign * tangentDot;\r\n }\r\n if (curve.ddt) {\r\n const ddtDot = curve.ddt(t).dot(normal);\r\n // tangentDot == 0 ==> critical point at t, if ddtDot != 0, then it is a turning point, otherwise we can't be sure\r\n // and must do a numeric test\r\n if (!eq0(ddtDot)) {\r\n return ddtDot;\r\n }\r\n }\r\n const numericDot = curve\r\n .at(t)\r\n .to(curve.at(t + sign * 4 * NLA_PRECISION))\r\n .dot(normal);\r\n assert(!(curve instanceof L3));\r\n return numericDot;\r\n}\r\nexport const INSIDE = 0, OUTSIDE = 1, COPLANAR_SAME = 2, COPLANAR_OPPOSITE = 3, ALONG_EDGE_OR_PLANE = 4;\r\n/**\r\n *\r\n * @param brep BREP to check\r\n * @param edge edge to check\r\n * @param dirAtEdgeA the direction vector to check\r\n * @param faceNormal If dirAtEdgeA doesn't split a volume, but is along a face, the returned value depends on\r\n * wether that faces normal1 points in the same direction as faceNormal\r\n * @returns INSIDE, OUTSIDE, COPLANAR_SAME or COPLANAR_OPPOSITE\r\n */\r\n//function splitsVolumeEnclosingFaces(brep: BRep, edge: Edge, dirAtEdgeA: V3, faceNormal: V3): int {\r\n// assert(arguments.length == 4)\r\n// //assert(p.equals(edge.a))\r\n// const ab1 = edge.aDir.unit()\r\n// const relFaces = facesWithEdge(edge, brep.faces) as any[]\r\n// relFaces.forEach(faceInfo => {\r\n// faceInfo.normalAtEdgeA = faceInfo.face.surface.normalP(edge.a)\r\n// faceInfo.edgeDirAtEdgeA = !faceInfo.reversed\r\n// ? faceInfo.edge.aDir\r\n// : faceInfo.edge.bDir\r\n// faceInfo.outsideVector = faceInfo.edgeDirAtEdgeA.cross(faceInfo.normalAtEdgeA)\r\n// faceInfo.angle = (dirAtEdgeA.angleRelativeNormal(faceInfo.outsideVector.negated(), ab1) + 2 * Math.PI +\r\n// NLA_PRECISION / 2) % (2 * Math.PI) }) assert(relFaces.length != 0, edge.toSource()) relFaces.sort((a, b) => a.angle\r\n// - b.angle) // assert(relFaces.length % 2 == 0, edge.toSource()) // even number of touching faces if\r\n// (eq0(relFaces[0].angle)) { //assert(false) todo const coplanarSame = relFaces[0].normalAtEdgeA.dot(faceNormal) > 0;\r\n// return coplanarSame ? COPLANAR_SAME : COPLANAR_OPPOSITE } else { return !relFaces[0].reversed ? INSIDE : OUTSIDE } }\r\nexport function splitsVolumeEnclosingFaces(brep, canonEdge, dirAtEdgeA, faceNormal) {\r\n assert(arguments.length == 4);\r\n assert(canonEdge == canonEdge.getCanon());\r\n //assert(p.equals(canonEdge.a))\r\n const edgeFaceInfos = brep.edgeFaces.get(canonEdge);\r\n assertf(() => edgeFaceInfos.length % 2 == 0);\r\n assertf(() => brep.edgeFaces);\r\n const faceInfo0 = edgeFaceInfos[0];\r\n const aDir1 = canonEdge.aDir.unit();\r\n const angleToCanon = ((faceInfo0.inside.angleRelativeNormal(dirAtEdgeA, aDir1) +\r\n 2 * Math.PI +\r\n NLA_PRECISION) %\r\n (2 * Math.PI)) -\r\n NLA_PRECISION;\r\n const nearestFaceInfoIndex = edgeFaceInfos.findIndex((faceInfo) => lt(angleToCanon, faceInfo.angle));\r\n const nearestFaceInfo = edgeFaceInfos[nearestFaceInfoIndex == -1\r\n ? edgeFaceInfos.length - 1\r\n : nearestFaceInfoIndex - 1];\r\n if (eq(nearestFaceInfo.angle, angleToCanon)) {\r\n //assert(false) todo\r\n const coplanarSame = nearestFaceInfo.normalAtCanonA.dot(faceNormal) > 0;\r\n return coplanarSame ? COPLANAR_SAME : COPLANAR_OPPOSITE;\r\n }\r\n else {\r\n return nearestFaceInfo.reversed ? INSIDE : OUTSIDE;\r\n }\r\n}\r\nexport function splitsVolumeEnclosingFacesP(brep, canonEdge, p, pInside, pFaceNormal) {\r\n assert(arguments.length == 5);\r\n assert(canonEdge == canonEdge.getCanon());\r\n //assert(p.equals(canonEdge.a))\r\n assertf(() => brep.edgeFaces);\r\n const edgeFaceInfos = brep.edgeFaces.get(canonEdge);\r\n assertf(() => edgeFaceInfos.length % 2 == 0);\r\n const pDir1 = canonEdge.tangentAt(canonEdge.curve.pointT(p)).unit();\r\n const faceInfoAngleFromPInsideNeg = (faceInfo) => {\r\n const faceInfoPDir = faceInfo.edge.getCanon() == faceInfo.edge ? pDir1 : pDir1.negated();\r\n const faceInfoInsideAtP = faceInfo.face.surface\r\n .normalP(p)\r\n .cross(faceInfoPDir);\r\n const faceInfoAngleAtP = pInside.angleRelativeNormal(faceInfoInsideAtP, pDir1);\r\n return -(((faceInfoAngleAtP + TAU + NLA_PRECISION) % TAU) - NLA_PRECISION);\r\n };\r\n const nearestFaceInfo = withMax(edgeFaceInfos, faceInfoAngleFromPInsideNeg);\r\n if (eq0(faceInfoAngleFromPInsideNeg(nearestFaceInfo))) {\r\n //assert(false) todo\r\n const coplanarSame = nearestFaceInfo.face.surface.normalP(p).dot(pFaceNormal) > 0;\r\n return coplanarSame ? COPLANAR_SAME : COPLANAR_OPPOSITE;\r\n }\r\n else {\r\n return nearestFaceInfo.reversed ? OUTSIDE : INSIDE;\r\n }\r\n}\r\nexport function splitsVolumeEnclosingFacesP2(brep, canonEdge, p, testCurve, curveT, dir, faceNormal) {\r\n assert(canonEdge == canonEdge.getCanon());\r\n //assert(p.equals(canonEdge.a))\r\n assertf(() => brep.edgeFaces);\r\n const edgeFaceInfos = brep.edgeFaces.get(canonEdge);\r\n assertf(() => edgeFaceInfos.length % 2 == 0);\r\n const pDir1 = canonEdge.tangentAt(canonEdge.curve.pointT(p)).unit();\r\n let pInside = testCurve.tangentAt(curveT).times(dir);\r\n if (pInside.isParallelTo(pDir1)) {\r\n pInside = testCurve\r\n .diff(curveT, (1e-4 * dir) / testCurve.tangentAt(curveT).length())\r\n .rejectedFrom(pDir1);\r\n pInside = pInside.div(pInside.length());\r\n }\r\n let minValue = 20, advanced = false, result = OUTSIDE;\r\n for (const faceInfo of edgeFaceInfos) {\r\n const faceInfoPDir = faceInfo.edge.getCanon() == faceInfo.edge ? pDir1 : pDir1.negated();\r\n const faceInfoInsideAtP = faceInfo.face.surface\r\n .normalP(p)\r\n .cross(faceInfoPDir);\r\n const faceInfoAngleAtP = pInside.angleRelativeNormal(faceInfoInsideAtP, pDir1);\r\n const angle = ((faceInfoAngleAtP + TAU + NLA_PRECISION) % TAU) - NLA_PRECISION;\r\n if (eq0(angle)) {\r\n // do advanced analysis\r\n const normVector = faceInfo.face.surface.normalP(p);\r\n if (faceInfo.face.surface.containsCurve(testCurve)) {\r\n const coplanarSame = normVector.dot(faceNormal) > 0;\r\n return coplanarSame ? COPLANAR_SAME : COPLANAR_OPPOSITE;\r\n }\r\n const testPlane = P3.normalOnAnchor(pDir1, p);\r\n const isCurve = faceInfo.face.surface.isCurvesWithPlane(testPlane)[0];\r\n const isCurvePT = isCurve.pointT(p);\r\n const dirFactor = sign(isCurve.tangentAt(isCurvePT).dot(pInside));\r\n const eps = 1e-4;\r\n const iscd = isCurve\r\n .at(isCurvePT)\r\n .to(isCurve.at(isCurvePT + dir * dirFactor * eps))\r\n .dot(normVector);\r\n const ecd = testCurve\r\n .at(curveT)\r\n .to(testCurve.at(curveT + dir * eps))\r\n .dot(normVector);\r\n const diff = (iscd - ecd) * (faceInfo.reversed ? -1 : 1);\r\n if (diff > 0 && (!advanced || diff < minValue)) {\r\n advanced = true;\r\n minValue = diff;\r\n result = faceInfo.reversed ? OUTSIDE : INSIDE;\r\n }\r\n }\r\n else if (!advanced) {\r\n if (angle < minValue) {\r\n minValue = angle;\r\n result = faceInfo.reversed ? OUTSIDE : INSIDE;\r\n }\r\n }\r\n }\r\n return result;\r\n}\r\nexport function splitsVolumeEnclosingCone(brep, p, dir) {\r\n const testPlane = P3.forAnchorAndPlaneVectors(p, dir, dir.getPerpendicular());\r\n const rays = [];\r\n for (let k = 0; k < brep.faces.length; k++) {\r\n const planeFace = brep.faces[k];\r\n assertf(() => planeFace instanceof PlaneFace);\r\n if (planeFace.getAllEdges().some((edge) => edge.a.like(p))) {\r\n if (testPlane.isParallelToPlane(planeFace.surface.plane)) {\r\n if (planeFace.pointsToInside(p, dir) != PointVsFace.OUTSIDE) {\r\n return ALONG_EDGE_OR_PLANE;\r\n }\r\n }\r\n else {\r\n const isLine = L3.fromPlanes(testPlane, planeFace.surface.plane);\r\n const ps = planeFace.edgeISPsWithPlane(isLine, testPlane);\r\n let i = 0;\r\n while (i < ps.length) {\r\n const a = ps[i++], b = ps[i++];\r\n const out = a.p.like(p);\r\n if (out || b.p.like(p)) {\r\n const dir2 = out ? isLine.dir1 : isLine.dir1.negated();\r\n const angle = (dir.angleRelativeNormal(dir2, testPlane.normal1) +\r\n 2 * Math.PI +\r\n NLA_PRECISION / 2) %\r\n (2 * Math.PI);\r\n rays.push({ angle: angle, out: out });\r\n }\r\n }\r\n }\r\n }\r\n }\r\n rays.sort((a, b) => a.angle - b.angle);\r\n //console.log(\"testPlane\"Plane.toSource(), \"rays\", rays.toSource())\r\n if (eq0(rays[0].angle)) {\r\n return ALONG_EDGE_OR_PLANE;\r\n }\r\n else {\r\n return rays[0].out ? OUTSIDE : INSIDE;\r\n }\r\n}\r\nexport function splitsVolumeEnclosingCone2(brep, p, curve, curveT, fb) {\r\n assert(curve.containsPoint(p));\r\n const pFaces = brep.faces.filter((face) => face.getAllEdges().some((edge) => edge.a.like(p)));\r\n for (let k = 0; k < pFaces.length; k++) {\r\n const face = pFaces[k];\r\n if (face.surface.containsCurve(curve)) {\r\n //assert(false)\r\n if (face.pointsToInside3(p, curve, curveT, fb) != PointVsFace.OUTSIDE) {\r\n return ALONG_EDGE_OR_PLANE;\r\n }\r\n }\r\n }\r\n const EPS = 1e-6;\r\n return brep.containsPoint(curve.at(curveT + fb * EPS), true)\r\n ? INSIDE\r\n : OUTSIDE;\r\n}\r\nexport function fff(info, surface) {\r\n const canonA = info.edge.reversed ? info.edge.b : info.edge.a;\r\n const surfaceNormalAtCanonA = surface.normalP(canonA);\r\n const dot = snap0(info.inside.dot(surfaceNormalAtCanonA));\r\n if (0 !== dot) {\r\n return 0 < dot ? OUTSIDE : INSIDE;\r\n }\r\n if (surface.isCoplanarTo(info.face.surface)) {\r\n return 0 < info.normalAtCanonA.dot(surfaceNormalAtCanonA)\r\n ? COPLANAR_SAME\r\n : COPLANAR_OPPOSITE;\r\n }\r\n throw new Error();\r\n}\r\nexport function triangulateVertices(normal, vertices, holeStarts) {\r\n const absMaxDim = normal.maxAbsDim(), factor = sign(normal.e(absMaxDim));\r\n const contour = new Float64Array(vertices.length * 2);\r\n let i = vertices.length;\r\n /*\r\n var [coord0, coord1] = [['y', 'z'], ['z', 'x'], ['x', 'y']][maxAbsDim]\r\n while (i--) {\r\n contour[i * 2 ] = vertices[i][coord0] * factor\r\n contour[i * 2 + 1] = vertices[i][coord1]\r\n }\r\n */\r\n while (i--) {\r\n // unroll disambiguation instead of accessing elements by string name ([coord0] etc)\r\n // as it confuses google closure\r\n switch (absMaxDim) {\r\n case 0:\r\n contour[i * 2] = vertices[i].y * factor;\r\n contour[i * 2 + 1] = vertices[i].z;\r\n break;\r\n case 1:\r\n contour[i * 2] = vertices[i].z * factor;\r\n contour[i * 2 + 1] = vertices[i].x;\r\n break;\r\n case 2:\r\n contour[i * 2] = vertices[i].x * factor;\r\n contour[i * 2 + 1] = vertices[i].y;\r\n break;\r\n }\r\n }\r\n return earcut(contour, holeStarts);\r\n}\r\n/**\r\n * Solves a quadratic system of equations of the form\r\n * a * x + b * y = c\r\n * x² + y² = 1\r\n * This can be understood as the intersection of the unit circle with a line.\r\n * => y = (c - a x) / b\r\n * => x² + (c - a x)² / b² = 1\r\n * => x² b² + c² - 2 c a x + a² x² = b²\r\n * => (a² + b²) x² - 2 a c x + (c² - b²) = 0\r\n *\r\n * a * b + (b -c) * (b + c)\r\n */\r\nexport function intersectionUnitCircleLine(a, b, c) {\r\n assertNumbers(a, b, c);\r\n // TODO: disambiguate on a < b\r\n const term = sqrt(a * a + b * b - c * c);\r\n return {\r\n x1: (a * c + b * term) / (a * a + b * b),\r\n x2: (a * c - b * term) / (a * a + b * b),\r\n y1: (b * c - a * term) / (a * a + b * b),\r\n y2: (b * c + a * term) / (a * a + b * b),\r\n };\r\n}\r\nexport function intersectionUnitCircleLine2(a, b, c) {\r\n assertNumbers(a, b, c);\r\n // TODO: disambiguate on a < b\r\n // cf. pqFormula\r\n const termSqr = snap0(a * a + b * b - c * c);\r\n if (termSqr < 0) {\r\n return [];\r\n }\r\n else if (termSqr == 0) {\r\n return [[(a * c) / (a * a + b * b), (b * c) / (a * a + b * b)]];\r\n }\r\n else {\r\n const term = sqrt(termSqr);\r\n return [\r\n [\r\n (a * c + b * term) / (a * a + b * b),\r\n (b * c - a * term) / (a * a + b * b),\r\n ],\r\n [\r\n (a * c - b * term) / (a * a + b * b),\r\n (b * c + a * term) / (a * a + b * b),\r\n ],\r\n ];\r\n }\r\n}\r\nexport function intersectionCircleLine(a, b, c, r) {\r\n assertNumbers(a, b, c, r);\r\n const term = sqrt(r * r * (a * a + b * b) - c * c);\r\n return {\r\n x1: (a * c + b * term) / (a * a + b * b),\r\n x2: (a * c - b * term) / (a * a + b * b),\r\n y1: (b * c - a * term) / (a * a + b * b),\r\n y2: (b * c + a * term) / (a * a + b * b),\r\n };\r\n}\r\n/**\r\n * Solves a quadratic system of equations of the form\r\n * a * x + b * y = c\r\n * x^2 - y^2 = 1\r\n * This can be understood as the intersection of the unit hyperbola with a line.\r\n *\r\n * @returns with x1 >= x2 and y1 <= y2\r\n * a * b + (b -c) * (b + c)\r\n */\r\nexport function intersectionUnitHyperbolaLine(a, b, c) {\r\n assertNumbers(a, b, c);\r\n const aa = a * a, bb = b * b, cc = c * c;\r\n // TODO: disambiguate on a < b\r\n //var xTerm = sqrt(4*cc*aa-4*(bb-aa)*(-cc-bb))\r\n const xTerm = 2 * sqrt(bb * cc + bb * bb - aa * bb);\r\n const yTerm = sqrt(4 * cc * bb - 4 * (bb - aa) * (cc - aa));\r\n return {\r\n x1: (-2 * a * c + xTerm) / 2 / (bb - aa),\r\n x2: (-2 * a * c - xTerm) / 2 / (bb - aa),\r\n y1: (2 * b * c - yTerm) / 2 / (bb - aa),\r\n y2: (2 * b * c + yTerm) / 2 / (bb - aa),\r\n };\r\n}\r\nexport function curvePointPP(ps1, ps2, startPoint, dontCheck) {\r\n const EPS = NLA_PRECISION / 4;\r\n //if (!dontCheck) {\r\n // const p = curvePointPP(ps1, ps2, startPoint, true).p\r\n // if (!ps1.containsPoint(p)) {\r\n // console.log(\"foo, startPoint was \" + startPoint.sce)\r\n // ps1.containsPoint(p)\r\n // }\r\n //}\r\n let Q = startPoint;\r\n let st1 = ps1.pointFoot(Q);\r\n let st2 = ps2.pointFoot(Q);\r\n let a, b, aNormal, bNormal, abNormalsCross;\r\n //console.log(\"curvePointPP, startPoint was \" + startPoint.sce)\r\n //console.log(Q.sce+ ',')\r\n let i = 16;\r\n do {\r\n a = ps1.pUV(st1.x, st1.y);\r\n b = ps2.pUV(st2.x, st2.y);\r\n if (eq0(a.distanceTo(b), EPS))\r\n break;\r\n // drPs.push({p:a,text:'a'+j+' '+i})\r\n // drPs.push({p:b,text:'b'+j+' '+i})\r\n aNormal = ps1.normalUV(st1.x, st1.y);\r\n bNormal = ps2.normalUV(st2.x, st2.y);\r\n // next Q is the intersection of the planes\r\n // (x - a) * aNormal,\r\n // (x - b) * bNormal and\r\n // (x - Q) * (aNormal X bNormal)\r\n abNormalsCross = aNormal.cross(bNormal);\r\n // drVs.push({anchor: Q, dir: aNormal})\r\n // drVs.push({anchor: Q, dir: bNormal})\r\n Q = V3.add(bNormal.cross(abNormalsCross).times(a.dot(aNormal)), abNormalsCross.cross(aNormal).times(b.dot(bNormal)), abNormalsCross.times(abNormalsCross.dot(Q))).div(abNormalsCross.squared());\r\n //console.log(Q.sce+ ',')\r\n // feet of Q on ps1 and ps2 (closest points)\r\n st1 = ps1.pointFoot(Q, st1.x, st1.y);\r\n st2 = ps2.pointFoot(Q, st2.x, st2.y);\r\n } while (--i);\r\n //assert(ps1.containsPoint(Q), Q, ps1)\r\n //assert(ps2.containsPoint(Q))\r\n if (!eq0(a.distanceTo(b), EPS)) {\r\n return undefined;\r\n }\r\n return { p: Q, st1: st1, st2: st2 };\r\n}\r\n/**\r\n * Follow the intersection curve of two parametric surfaces starting from a given point.\r\n * @param {ParametricSurface} ps1\r\n * @param {ParametricSurface} ps2\r\n * @param {number} s1Step\r\n * @param {number} t1Step\r\n * @param {number} s2Step\r\n * @param {number} t2Step\r\n * @param {number} curveStepSize\r\n * @return {Curve[]}\r\n */\r\nexport function followAlgorithmPP(ps1, ps2, startPoint, curveStepSize, bounds1 = uvInAABB2.bind(undefined, ps1), bounds2 = uvInAABB2.bind(undefined, ps2)) {\r\n const points = [];\r\n const tangents = [];\r\n const st1s = [];\r\n const st2s = [];\r\n let Q = startPoint;\r\n let st1 = ps1.uvP(Q);\r\n let st2 = ps2.uvP(Q);\r\n assert(ps1.pUV(st1.x, st1.y).like(Q));\r\n assert(st1.like(ps1.pointFoot(Q, st1.x, st1.y)));\r\n assert(ps2.pUV(st2.x, st2.y).like(Q));\r\n assert(st2.like(ps2.pointFoot(Q, st2.x, st2.y)));\r\n for (let i = 0; i < 1000; i++) {\r\n ;\r\n ({ p: Q, st1, st2 } = curvePointPP(ps1, ps2, Q));\r\n assert(ps1.containsPoint(Q), Q, ps1);\r\n assert(ps2.containsPoint(Q));\r\n const aNormal = ps1.normalUV(st1.x, st1.y);\r\n const bNormal = ps2.normalUV(st2.x, st2.y);\r\n const tangent = aNormal.cross(bNormal).toLength(curveStepSize);\r\n tangents.push(tangent);\r\n points.push(Q);\r\n st1s.push(st1);\r\n st2s.push(st2);\r\n if (i > 4) {\r\n if (!bounds1(st1.x, st1.y) || !bounds2(st2.x, st2.y)) {\r\n break;\r\n }\r\n }\r\n Q = Q.plus(tangent);\r\n }\r\n return { points, tangents, st1s, st2s };\r\n}\r\n/**\r\n * Iteratively calculate points on an implicit 2D curve.\r\n * @param ic The curve in question.\r\n * @param startP The point at which to start.\r\n * @param stepLength The step the algorithm takes. Will be the approximate distance between points.\r\n * @param bounds Bounds function.\r\n * @param endP End point. If undefined, algorithm will continue until out of bounds or back at start point.\r\n * @param startTangent TODO Ignore this.\r\n * @returns Calculated points and tangents. points[0] and tangents[0] will be startP and startTangent.\r\n */\r\nexport function followAlgorithm2d(ic, startP, stepLength = 0.5, bounds, validUV, endP, startTangent) {\r\n assertNumbers(stepLength, ic(0, 0));\r\n assertVectors(startP);\r\n if (!startTangent) {\r\n startTangent = new V3(-ic.y(startP.x, startP.y), ic.x(startP.x, startP.y), 0).toLength(stepLength);\r\n }\r\n assertVectors(startTangent);\r\n const points = [];\r\n const tangents = [];\r\n assert(eq0(ic(startP.x, startP.y), 0.01), \"isZero(implicitCurve(startPoint.x, startPoint.y))\", ic(startP.x, startP.y));\r\n let i = 0, p = startP, tangent = startTangent, fullLoop = false;\r\n do {\r\n points.push(p);\r\n tangents.push(tangent);\r\n const searchStart = p.plus(tangent);\r\n assert(searchStart);\r\n const newP = curvePointMF(ic, searchStart);\r\n const dfpdx = ic.x(newP.x, newP.y), dfpdy = ic.y(newP.x, newP.y);\r\n const newTangent = new V3(-dfpdy, dfpdx, 0).toLength(stepLength);\r\n //const reversedDir = p.minus(prevp).dot(tangent) < 0\r\n assert(!p.equals(newP));\r\n // check if we passed a singularity\r\n if (tangent.dot(newTangent) < 0) {\r\n const singularity = newtonIterate2d(ic.x, ic.y, p.x, p.y);\r\n if (eq0(ic(singularity.x, singularity.y)) &&\r\n singularity.distanceTo(p) < abs(stepLength)) {\r\n // end on this point\r\n points.push(singularity);\r\n tangents.push(p.to(singularity));\r\n break;\r\n }\r\n else {\r\n throw new Error();\r\n }\r\n }\r\n // check for endP\r\n if (endP && p.equals(endP)) {\r\n break;\r\n }\r\n // check if loop\r\n if (fullLoop) {\r\n if (p.distanceTo(startP) > abs(stepLength)) {\r\n points.pop();\r\n tangents.pop();\r\n assert(getLast(points).distanceTo(startP) <= abs(stepLength));\r\n break;\r\n }\r\n }\r\n else {\r\n if (i > 4 && p.distanceTo(startP) <= abs(stepLength)) {\r\n fullLoop = true;\r\n }\r\n }\r\n // check if out of bounds\r\n if (i > 1 && !uvInAABB2(bounds, p.x, p.y)) {\r\n const endP = figureOutBorderPoint(bounds, p, ic);\r\n points.pop();\r\n tangents.pop();\r\n if (getLast(points).distanceTo(endP) < abs(stepLength) / 2) {\r\n points.pop();\r\n tangents.pop();\r\n }\r\n const endTangent = new V3(-ic.y(endP.x, endP.y), ic.x(endP.x, endP.y), 0).toLength(stepLength);\r\n points.push(endP);\r\n tangents.push(endTangent);\r\n break;\r\n }\r\n if (i > 4 && !validUV(p.x, p.y)) {\r\n break;\r\n }\r\n assert(eq0(ic(newP.x, newP.y), NLA_PRECISION * 2), p, newP, searchStart, ic(newP.x, newP.y));\r\n tangent = newTangent;\r\n p = newP;\r\n } while (++i < 1000);\r\n assert(i < 1000);\r\n //assert(points.length > 6)\r\n return { points, tangents };\r\n}\r\n/**\r\n * Given a point p just outside the bounds, figure out the nearby intersection of the bounds with the ic.\r\n * @param bounds\r\n * @param p\r\n * @param ic\r\n */\r\nfunction figureOutBorderPoint(bounds, p, ic) {\r\n if (p.x < bounds.uMin || bounds.uMax < p.x) {\r\n const u = bounds.uMax < p.x ? bounds.uMax : bounds.uMin;\r\n const v = newtonIterateWithDerivative((t) => ic(u, t), p.y, 4, (t) => ic.y(u, t));\r\n if (uvInAABB2(bounds, u, v)) {\r\n return new V3(u, v, 0);\r\n }\r\n }\r\n if (p.y < bounds.vMin || bounds.vMax < p.y) {\r\n const v = bounds.vMax < p.y ? bounds.vMax : bounds.vMin;\r\n const u = newtonIterateWithDerivative((s) => ic(s, v), p.x, 4, (s) => ic.x(s, v));\r\n assert(uvInAABB2(bounds, u, v));\r\n return new V3(u, v, 0);\r\n }\r\n throw new Error(p + \" \" + bounds);\r\n}\r\nexport function followAlgorithm2dAdjustable(ic, start, stepLength = 0.5, bounds, endp = start) {\r\n assertNumbers(stepLength, ic(0, 0));\r\n assertVectors(start);\r\n //assert (!startDir || startDir instanceof V3)\r\n const points = [];\r\n const tangents = [];\r\n assert(eq0(ic(start.x, start.y), 0.01), \"isZero(implicitCurve(startPoint.x, startPoint.y))\");\r\n let p = start, prevp = p;\r\n let i = 0;\r\n do {\r\n const dfpdx = ic.x(p.x, p.y), dfpdy = ic.y(p.x, p.y);\r\n const dfpdxx = ic.xx(p.x, p.y), dfpdyy = ic.yy(p.x, p.y), dfpdxy = ic.xy(p.x, p.y);\r\n const c2factor = abs((Math.pow(dfpdy, 2) * dfpdxx - 2 * dfpdx * dfpdy * dfpdxy + Math.pow(dfpdx, 2) * dfpdyy) /\r\n Math.pow((Math.pow(dfpdx, 2) + Math.pow(dfpdy, 2)), 2));\r\n const c2 = new V3(dfpdx, dfpdy, 0).times(c2factor);\r\n const s = 1 / 16 / c2.length();\r\n const tangent = new V3(-dfpdy, dfpdx, 0).unit();\r\n const newPStart = p.plus(tangent.times(s).plus(c2.times(Math.pow(s, 2) / 2)));\r\n points.push(p);\r\n tangents.push(tangent);\r\n prevp = p;\r\n const newP = curvePointMF(ic, newPStart);\r\n if (newP.equals(p)) {\r\n assertNever();\r\n }\r\n console.log(p.to(newP).length());\r\n p = newP;\r\n assert(eq0(ic(p.x, p.y)));\r\n } while (i++ < 1000 &&\r\n (i < 4 || prevp.distanceTo(endp) > stepLength) &&\r\n bounds(p.x, p.y));\r\n assert(i != 1000);\r\n //assert(bounds(p.x, p.y))\r\n const end = i < 4 || prevp.distanceTo(endp) > stepLength ? p : endp;\r\n const endTangent = new V3(-ic.y(end.x, end.y), ic.x(end.x, end.y), 0).toLength(stepLength);\r\n points.push(end);\r\n tangents.push(endTangent);\r\n //assert(points.length > 6)\r\n // TODO gleichmäßige Verteilung der Punkte\r\n return { points, tangents };\r\n}\r\n// both curves must be in the same s-t coordinates for this to make sense\r\nexport function intersectionICurveICurve(iCurve1, startParams1, endParams1, startDir, stepLength, iCurve2) {\r\n assertNumbers(stepLength, iCurve1(0, 0), iCurve2(0, 0));\r\n assertVectors(startParams1, endParams1);\r\n assert(!startDir || startDir instanceof V3);\r\n const vertices = [];\r\n assert(eq0(iCurve1(startParams1.x, startParams1.y)));\r\n stepLength = stepLength || 0.5;\r\n const eps = 1e-5;\r\n let p = startParams1, prevp = p; // startDir ? p.minus(startDir) : p\r\n let i = 0;\r\n while (i++ < 1000 && (i < 4 || p.distanceTo(endParams1) > 1.1 * stepLength)) {\r\n const fp = iCurve1(p.x, p.y);\r\n const dfpdx = (iCurve1(p.x + eps, p.y) - fp) / eps, dfpdy = (iCurve1(p.x, p.y + eps) - fp) / eps;\r\n let tangent = new V3(-dfpdy, dfpdx, 0).toLength(stepLength);\r\n if (p.minus(prevp).dot(tangent) < 0)\r\n tangent = tangent.negated();\r\n prevp = p;\r\n p = curvePointMF(iCurve1, p.plus(tangent));\r\n vertices.push(p);\r\n }\r\n // TODO gleichmäßige Verteilung der Punkte\r\n return vertices;\r\n}\r\nexport function intersectionICurveICurve2(iCurve1, loopPoints1, iCurve2) {\r\n let p = loopPoints1[0], val = iCurve2(p.x, p.y), lastVal;\r\n const iss = [];\r\n for (let i = 0; i < loopPoints1.length; i++) {\r\n lastVal = val;\r\n p = loopPoints1[i];\r\n val = iCurve2(p.x, p.y);\r\n if (val * lastVal <= 0) {\r\n // TODO < ?\r\n iss.push(newtonIterate2d(iCurve1, iCurve2, p.x, p.y));\r\n }\r\n }\r\n return iss;\r\n}\r\n// export function intersectionPCurveISurface(\r\n// \tparametricCurve: Curve,\r\n// \tsearchStart: number,\r\n// \tsearchEnd: number,\r\n// \tsearchStep: number,\r\n// \timplicitSurface: ImplicitSurface,\r\n// ) {\r\n// \tassertNumbers(searchStart, searchEnd, searchStep)\r\n// \tconst iss = []\r\n// \tlet val = implicitSurface(parametricCurve(searchStart)),\r\n// \t\tlastVal\r\n// \tfor (let t = searchStart + searchStep; t <= searchEnd; t += searchStep) {\r\n// \t\tlastVal = val\r\n// \t\tval = implicitSurface(parametricCurve(t))\r\n// \t\tif (val * lastVal <= 0) {\r\n// \t\t\tiss.push(newtonIterate1d(t => implicitSurface(parametricCurve(t)), t))\r\n// \t\t}\r\n// \t}\r\n// \treturn iss\r\n// }\r\nexport function cassini(a, c) {\r\n return (x, y) => (x * x + y * y) * (x * x + y * y) -\r\n 2 * c * c * (x * x - y * y) -\r\n (Math.pow(a, 4) - Math.pow(c, 4));\r\n}\r\nexport var MathFunctionR2R;\r\n(function (MathFunctionR2R) {\r\n function forNerdamer(expression, args = [\"x\", \"y\"]) {\r\n const ndf = nerdamer(expression);\r\n const ndfs = nerdamer.diff(ndf, args[0]);\r\n const ndft = nerdamer.diff(ndf, args[1]);\r\n const f = ndf.buildFunction(args);\r\n f.x = ndfs.buildFunction(args);\r\n f.y = ndft.buildFunction(args);\r\n f.xx = nerdamer.diff(ndfs, args[0]).buildFunction(args);\r\n f.xy = nerdamer.diff(ndfs, args[1]).buildFunction(args);\r\n f.yy = nerdamer.diff(ndft, args[1]).buildFunction(args);\r\n return f;\r\n }\r\n MathFunctionR2R.forNerdamer = forNerdamer;\r\n function nerdamerToR2_R(expression, args = [\"x\", \"y\"]) {\r\n return expression.buildFunction(args);\r\n }\r\n MathFunctionR2R.nerdamerToR2_R = nerdamerToR2_R;\r\n function forFFxFy(f, fx, fy) {\r\n ;\r\n f.x = fx;\r\n f.y = fy;\r\n return f;\r\n }\r\n MathFunctionR2R.forFFxFy = forFFxFy;\r\n})(MathFunctionR2R || (MathFunctionR2R = {}));\r\nexport const cas2 = cassini(0.9, 1.02);\r\nexport function arrayLerp(lerp, arr, t) {\r\n if (0 === t % 1)\r\n return arr[t];\r\n return lerp(arr[Math.floor(t)], arr[Math.ceil(t)], t % 1);\r\n}\r\n//# sourceMappingURL=BRep.js.map","import { assert } from \"ts3dutils\";\r\nimport { getGlobalId } from \".\";\r\nexport function doNotSerialize(target, key) {\r\n const map = target.__SERIALIZATION_BLACKLIST || (target.__SERIALIZATION_BLACKLIST = {});\r\n map[key] = \"no\";\r\n}\r\nexport class ClassSerializer {\r\n constructor() {\r\n this.CLASS_NAMES = new Map();\r\n this.NAME_CLASSES = new Map();\r\n this.addClass(\"Object\", Object);\r\n }\r\n addClass(name, clazz) {\r\n if (this.NAME_CLASSES.has(name)) {\r\n throw new Error(name);\r\n }\r\n this.NAME_CLASSES.set(name, clazz);\r\n this.CLASS_NAMES.set(clazz, name);\r\n return this;\r\n }\r\n addNamespace(namespace, namespaceName) {\r\n Object.keys(namespace).forEach((symbol) => {\r\n const o = namespace[symbol];\r\n if (\"function\" == typeof o && o.name) {\r\n this.addClass((namespaceName ? namespaceName + \".\" : \"\") + symbol, o);\r\n }\r\n });\r\n return this;\r\n }\r\n setUpdater(f) {\r\n this.updater = f;\r\n return this;\r\n }\r\n serialize(v) {\r\n return JSON.stringify(this.serializeObj(v));\r\n }\r\n serializeObj(v) {\r\n const path = [];\r\n const gatherList = (v) => {\r\n //console.log(path.toString())\r\n if (undefined !== v &&\r\n v.hasOwnProperty(\"constructor\") &&\r\n this.CLASS_NAMES.has(v.constructor)) {\r\n // do nothing, this is a class/function prototype\r\n }\r\n else if (Array.isArray(v)) {\r\n if (visited.has(v)) {\r\n if (!listMap.has(v)) {\r\n listMap.set(v, resultList.length);\r\n resultList.push(v);\r\n }\r\n }\r\n else {\r\n visited.add(v);\r\n for (let i = 0; i < v.length; i++) {\r\n path.push(\"\" + i);\r\n gatherList(v[i]);\r\n path.pop();\r\n }\r\n }\r\n }\r\n else if (undefined !== v && \"object\" == typeof v) {\r\n if (visited.has(v)) {\r\n if (!listMap.has(v)) {\r\n listMap.set(v, resultList.length);\r\n resultList.push(v);\r\n }\r\n }\r\n else {\r\n assert(!v.__noxTarget || !visited.has(v.__noxTarget));\r\n assert(!v.__noxProxy || !visited.has(v.__noxProxy));\r\n visited.add(v);\r\n if (!v.getConstructorParameters) {\r\n for (const key of Object.keys(v).sort()) {\r\n if (key == \"__noxProxy\" || key == \"__noxTarget\")\r\n continue;\r\n if (!v.__SERIALIZATION_BLACKLIST ||\r\n !v.__SERIALIZATION_BLACKLIST[key]) {\r\n path.push(key);\r\n gatherList(v[key]);\r\n path.pop();\r\n }\r\n }\r\n }\r\n path.push(\"proto\");\r\n gatherList(Object.getPrototypeOf(v));\r\n path.pop();\r\n }\r\n }\r\n };\r\n const transform = (v, allowLinks, first) => {\r\n if (\"string\" == typeof v ||\r\n \"number\" == typeof v ||\r\n \"boolean\" == typeof v ||\r\n null === v) {\r\n return v;\r\n }\r\n if (\"undefined\" == typeof v) {\r\n return { \"#REF\": -1 };\r\n }\r\n if (v.hasOwnProperty(\"constructor\") &&\r\n this.CLASS_NAMES.has(v.constructor)) {\r\n return { \"#REF\": this.CLASS_NAMES.get(v.constructor) };\r\n }\r\n let index;\r\n if (allowLinks && !first && undefined !== (index = listMap.get(v))) {\r\n return { \"#REF\": index };\r\n }\r\n if (Array.isArray(v)) {\r\n return v.map((x) => transform(x, allowLinks));\r\n }\r\n //if (mobx && mobx.isObservableArray(v)) {\r\n //\tconst result = {'#PROTO': 'ObservableArray'} as any\r\n //\tv.forEach((val, i) => result[i] = transform(val))\r\n //\treturn result\r\n //}\r\n if (\"object\" == typeof v) {\r\n if (v.getConstructorParameters) {\r\n return {\r\n \"#CONSTRUCTOR\": this.CLASS_NAMES.get(v.constructor),\r\n \"#ARGS\": transform(v.getConstructorParameters(), false),\r\n };\r\n }\r\n const result = {};\r\n if (Object.prototype !== Object.getPrototypeOf(v)) {\r\n result[\"#PROTO\"] = transform(Object.getPrototypeOf(v), allowLinks);\r\n }\r\n for (const key of Object.keys(v)) {\r\n if (key == \"__noxProxy\" || key == \"__noxTarget\")\r\n continue;\r\n if (!v.__SERIALIZATION_BLACKLIST ||\r\n !v.__SERIALIZATION_BLACKLIST[key]) {\r\n result[key] = transform(v[key], allowLinks);\r\n }\r\n }\r\n return result;\r\n }\r\n throw new Error(\"?\" + typeof v + v.toString());\r\n };\r\n const visited = new Set();\r\n const listMap = new Map();\r\n let resultList = [];\r\n listMap.set(v, 0);\r\n resultList.push(v);\r\n gatherList(v);\r\n resultList = resultList.map((v) => transform(v, true, true));\r\n return resultList;\r\n }\r\n unserialize(string) {\r\n let depth = 0;\r\n const fixObject = (v, onReady) => {\r\n depth++;\r\n if (depth > 100)\r\n throw new Error();\r\n if (v && v.constructor === Array) {\r\n onReady(v);\r\n for (let i = 0; i < v.length; i++) {\r\n fixObject(v[i], (x) => (v[i] = x));\r\n }\r\n }\r\n else if (\"object\" == typeof v && undefined != v) {\r\n if (\"#CONSTRUCTOR\" in v) {\r\n const protoName = v[\"#CONSTRUCTOR\"];\r\n const proto = this.NAME_CLASSES.get(protoName);\r\n assert(proto, protoName + \" Missing \");\r\n let args = undefined;\r\n fixObject(v[\"#ARGS\"], (x) => (args = x));\r\n onReady(new proto(...args));\r\n }\r\n else if (\"#REF\" in v) {\r\n const ref = v[\"#REF\"];\r\n if (\"string\" == typeof ref) {\r\n onReady(this.NAME_CLASSES.get(ref).prototype);\r\n }\r\n else if (\"number\" == typeof ref) {\r\n if (-1 == ref) {\r\n onReady(undefined);\r\n }\r\n else if (fixedObjects[ref]) {\r\n onReady(fixedObjects[ref]);\r\n }\r\n else {\r\n fixObject(tree[ref], (x) => onReady((fixedObjects[ref] = x)));\r\n }\r\n }\r\n }\r\n else {\r\n let result;\r\n if (\"#PROTO\" in v) {\r\n fixObject(v[\"#PROTO\"], (x) => {\r\n result = Object.create(x);\r\n onReady(result);\r\n });\r\n }\r\n else {\r\n onReady((result = v));\r\n }\r\n const keys = Object.keys(v);\r\n for (let i = 0; i < keys.length; i++) {\r\n //if ('name' == keys[i]) console.log(result)\r\n if (\"#PROTO\" != keys[i]) {\r\n fixObject(v[keys[i]], (x) => (result[keys[i]] = x));\r\n //Object.defineProperty(result, keys[i], {\r\n //\tvalue: fixObjects(v[keys[i]]),\r\n //\tenumerable: true,\r\n //\twritable: true,\r\n //\tconfigurable: true\r\n //})\r\n }\r\n }\r\n Object.defineProperty(result, \"loadID\", {\r\n value: getGlobalId(),\r\n enumerable: false,\r\n writable: false,\r\n });\r\n this.updater && this.updater(result);\r\n }\r\n }\r\n else {\r\n onReady(v);\r\n }\r\n depth--;\r\n };\r\n // const linkReferences = (v: any) => {\r\n // \tif (v && v.constructor === Array) {\r\n // \t\tfor (let i = 0; i < v.length; i++) {\r\n // \t\t\tv[i] = linkReferences(v[i])\r\n // \t\t}\r\n // \t\treturn v\r\n // \t} else if ('object' == typeof v && undefined != v) {\r\n // \t\tif ('#REF' in v) {\r\n // \t\t\treturn tree[v['#REF']]\r\n // \t\t} else {\r\n // \t\t\tconst keys = Object.keys(v)\r\n // \t\t\tfor (let i = 0; i < keys.length; i++) {\r\n // \t\t\t\tv[keys[i]] = linkReferences(v[keys[i]])\r\n // \t\t\t}\r\n // \t\t\treturn v\r\n // \t\t}\r\n // \t} else {\r\n // \t\treturn v\r\n // \t}\r\n // }\r\n const tree = JSON.parse(string);\r\n // console.log(tree)\r\n const fixedObjects = new Array(tree.length);\r\n fixObject({ \"#REF\": 0 }, () => { });\r\n // console.log(tree)\r\n // linkReferences(tree)\r\n // console.log(tree)\r\n return fixedObjects[0];\r\n }\r\n}\r\n//# sourceMappingURL=ClassSerializer.js.map","export const fragmentShaderLighting = `\n\tprecision highp float;\n\tuniform vec4 color;\n\tuniform vec3 camPos;\n\tvarying vec3 normal;\n\tvarying vec4 vPosition;\n\tvoid main() {\n\t\tvec3 normal1 = normalize(normal);\n\t\tvec3 lightPos = vec3(1000, 2000, 4000);\n\t\tvec3 lightDir = normalize(vPosition.xyz - lightPos);\n vec3 reflectionDirection = reflect(lightDir, normal1);\n vec3 eyeDirection = normalize(camPos.xyz-vPosition.xyz);\n float uMaterialShininess = 256.0;\n\t\tfloat specularLightWeighting = pow(max(dot(reflectionDirection, eyeDirection), 0.0), uMaterialShininess);\n\t\tfloat lightIntensity = 0.6 + 0.2 * max(0.0, -dot(lightDir, normal1)) + 0.2*specularLightWeighting;\n\t\tgl_FragColor = vec4(vec3(color) * lightIntensity, 1);\n\t}\n`;\r\nexport const vertexShaderLighting = `\n\tuniform mat4 ts_ModelViewProjectionMatrix;\n\tuniform mat4 ts_ModelViewMatrix;\n\tattribute vec4 ts_Vertex;\n\tuniform mat3 ts_NormalMatrix;\n\tattribute vec3 ts_Normal;\n\tuniform vec4 color;\n\tvarying vec3 normal;\n\tvarying vec4 vPosition;\n\tvoid main() {\n\t\tgl_Position = ts_ModelViewProjectionMatrix * ts_Vertex;\n vPosition = ts_ModelViewMatrix * ts_Vertex;\n\t\tnormal = normalize(ts_NormalMatrix * ts_Normal);\n\t}\n`;\r\nexport const vertexShaderWaves = `\n\tuniform mat4 ts_ModelViewProjectionMatrix;\n\tuniform mat4 ts_ModelViewMatrix;\n\tattribute vec4 ts_Vertex;\n\tuniform mat3 ts_NormalMatrix;\n\tattribute vec3 ts_Normal;\n\tuniform vec4 color;\n\tvarying vec3 normal;\n\tvarying vec4 vPosition;\n\tvoid main() {\n\t\tnormal = normalize(ts_NormalMatrix * ts_Normal);\n\t\tfloat offset = mod (((ts_Vertex.x + ts_Vertex.y + ts_Vertex.z) * 31.0), 20.0) - 10.0;\n\t\tvec4 modPos = ts_Vertex + vec4(normal * offset, 0);\n\t\tgl_Position = ts_ModelViewProjectionMatrix * modPos;\n vPosition = ts_ModelViewMatrix * modPos;\n\t}\n`;\r\nexport const vertexShader = `\n\tvarying vec4 pos;\n\tvoid main() {\n\t\tpos = vec4(position,1.0);\n\t\tgl_Position = projectionMatrix *\n\t\t\tmodelViewMatrix *\n\t\t\tvec4(position,1.0);\n\t}\n`;\r\nexport const fragmentShader = `\n\tprecision highp float;\n\tuniform vec3 color;\n\tvarying vec4 pos;\n\tvoid main() {\n\t\tfloat distance = pos.x * pos.x + pos.y * pos.y;\n\t\tif (distance <= 0.98) {\n\t\t\tgl_FragColor = vec4(color, 1.0);\n\t\t} else if (distance <= 1.0) {\n\t\t\tgl_FragColor = vec4(color, 0.5);\n\t\t} else {\n\t\t\tgl_FragColor = vec4(0.0, 0.0, 0.0, 0.0);\n\t\t}\n\t}\n\t/*\n\t precision mediump float;\n\n\t varying vec4 pos;\n\n\n\t void main() {\n\t float inside = pos.r * pos.r + pos.g * pos.g;\n\t if (inside <= 1) {\n\t gl_FragColor = vec4(0.0, 1.0, 0.0, 1.0);\n\t } else {\n\t gl_FragColor = vec4(0.0, 0.0, 0.0, 0.0);\n\t }\n\t }\n\t */\n`;\r\nexport const vertexShaderBasic = `\n\tuniform mat4 ts_ModelViewProjectionMatrix;\n\tattribute vec4 ts_Vertex;\n\tvoid main() {\n\t\tgl_Position = ts_ModelViewProjectionMatrix * ts_Vertex;\n\t}\n`;\r\nexport const vertexShaderColor = `\n\tuniform mat4 ts_ModelViewProjectionMatrix;\n\tattribute vec4 ts_Vertex;\n\tattribute vec4 ts_Color;\n\tvarying vec4 fragColor;\n\tvoid main() {\n\t\tgl_Position = ts_ModelViewProjectionMatrix * ts_Vertex;\n\t\tfragColor = ts_Color;\n\t}\n`;\r\nexport const vertexShaderArc = `\n\tuniform mat4 ts_ModelViewProjectionMatrix;\n\tattribute vec4 ts_Vertex;\n\tuniform float step, offset;\n\tuniform float radius, width;\n\tvoid main() {\n\t\tfloat r = radius;\n\t\tfloat t = offset + ts_Vertex.x * step;\n\t\tfloat pRadius = r - ts_Vertex.y * width;\n\t\tvec4 p = vec4(pRadius * cos(t), pRadius * sin(t), 0, 1);\n\t\tgl_Position = ts_ModelViewProjectionMatrix * p;\n}\n`;\r\nexport const vertexShaderConic3d = `\n\tuniform mat4 ts_ModelViewProjectionMatrix;\n\tattribute vec4 ts_Vertex;\n\tuniform float startT, endT, scale;\n\tuniform vec3 center, f1, f2;\n\tuniform int mode;\n\tfloat sinh(float x) { return (exp(x) - exp(-x)) / 2.0; }\n\tfloat cosh(float x) { return (exp(x) + exp(-x)) / 2.0; }\n\tvoid main() {\n\t\tfloat t = startT + ts_Vertex.x * (endT - startT);\n\n\t\tvec3 normal = normalize(cross(f1, f2));\n\n\t\tvec3 p, tangent;\n\t\tif (0 == mode) { // ellipse\n\t\t\tp = center + f1 * cos(t) + f2 * sin(t);\n\t\t\ttangent = f1 * -sin(t) + f2 * cos(t);\n\t\t}\n\t\tif (1 == mode) { // parabola\n\t\t\tp = center + f1 * t + f2 * t * t;\n\t\t\ttangent = f1 + 2.0 * f2 * t;\n\t\t}\n\t\tif (2 == mode) { // hyperbola\n\t\t\tp = center + f1 * cosh(t) + f2 * sinh(t);\n\t\t\ttangent = f1 * sinh(t) + f2 * cosh(t);\n\t\t}\n\t\tvec3 outDir = normalize(cross(normal, tangent));\n\t\tvec3 p2 = p + scale * (outDir * ts_Vertex.y + normal * ts_Vertex.z);\n\t\tgl_Position = ts_ModelViewProjectionMatrix * vec4(p2, 1);\n\t}\n`;\r\nexport const vertexShaderNURBS = `#version 300 es\n\tuniform mat4 ts_ModelViewProjectionMatrix;\n\tin vec4 ts_Vertex;\n\tuniform float startT, endT, scale;\n\tuniform vec4 points[32];\n\tuniform int pointCount, degree;\n\tuniform float knots[40];\n\tuniform vec3 normal;\n\tconst int MIN_DEGREE = 1;\n\tconst int MAX_DEGREE = 6;\n\t\n\tint tInterval(float t) {\n\t\tfor (int s = degree; s < 40 - 1 - degree; s++) {\n\t\t\tif (t >= knots[s] && t <= knots[s + 1]) {\n\t\t\t\treturn s;\n\t\t\t}\n\t\t}\n\t}\n\t\n\tvec4 stepp(int k, int i, vec4 dkMinus1iMinus1, vec4 dkMinus1i) {\n\t return dkMinus1i - dkMinus1iMinus1 * float(k) / (knots[i + degree - k] - knots[i - 1]);\n\t}\n\t\n\tvoid main() {\n\t\t// ts_Vertex.x is in [0, 1]\n\t\tfloat t = startT + ts_Vertex.x * (endT - startT);\n\t\t\n\t\tint s = tInterval(t);\n\t\t\n\t\tvec4 v[MAX_DEGREE + 1];\n\t\tfor (int i = 0; i < degree + 1; i++) {\n\t\t v[i] = points[s - degree + i];\n\t\t}\n\t\t\n\t\tvec4 pTangent4, ddt4 = vec4(0, 0, 1, 0);\n\t\tfor (int level = 0; level < degree; level++) {\n\t\t\tif (level == degree - 2) {\n\t\t\t\t// see https://www.globalspec.com/reference/61012/203279/10-8-derivatives\n\t\t\t\tvec4 a = v[degree];\n\t\t\t\tvec4 b = v[degree - 1];\n\t\t\t\tvec4 c = v[degree - 2];\n\t\t\t\tddt4 = stepp(degree, s + 1, stepp(degree - 1, s + 1, a, b), stepp(degree - 1, s, b, c));\n\t\t\t}\n\t\t\tif (level == degree - 1) {\n\t\t\t\tvec4 a = v[degree];\n\t\t\t\tvec4 b = v[degree - 1];\n\t\t\t\tpTangent4 = (b - a) * (float(degree) / (knots[s] - knots[s + 1]));\n\t\t\t}\n\t\t\tfor (int i = degree; i > level; i--) {\n\t\t\t\tfloat alpha = (t - knots[i + s - degree]) / (knots[i + s - level] - knots[i + s - degree]);\n\n\t\t\t\t// interpolate each component\n v[i] = (1.0 - alpha) * v[i - 1] + alpha * v[i];\n\t\t\t}\n\t\t}\n\t\t\n\t\tvec4 p4 = v[degree];\n\t\t\n\t\tvec3 p = p4.xyz / p4.w;\n\t\tvec3 pTangent = ((pTangent4.xyz * p4.w) - (p4.xyz * pTangent4.w)) / (p4.w * p4.w);\n\t\tvec3 ddt = (\n\t\t p4.xyz * (-p4.w * ddt4.w + 2.0 * pow(pTangent4.w, 2.0))\n\t\t + pTangent4.xyz * (-2.0 * p4.w * pTangent4.w) \n\t\t + ddt4.xyz * pow(p4.w, 2.0)\n ) / pow(p4.w, 3.0);\n\t\t\n\t\tvec3 outDir = normalize(cross(ddt, pTangent));\n\t\tvec3 correctNormal = normalize(cross(pTangent, outDir));\n\t\tvec3 p2 = p + scale * (outDir * ts_Vertex.y + correctNormal * ts_Vertex.z);\n\t\tgl_Position = ts_ModelViewProjectionMatrix * vec4(p2, 1);\n }\n`;\r\nexport const vertexShaderBezier = `\n // calculates a bezier curve using ts_Vertex.x as the (t) parameter of the curve\n\tuniform mat4 ts_ModelViewProjectionMatrix;\n\tattribute vec4 ts_Vertex;\n\tuniform float width, startT, endT;\n\tuniform vec3 p0, p1, p2, p3;\n\tvoid main() {\n\t\t// ts_Vertex.x is in [0, 1]\n\t\tfloat t = startT + ts_Vertex.x * (endT - startT), s = 1.0 - t;\n\t\tfloat c0 = s * s * s, c1 = 3.0 * s * s * t, c2 = 3.0 * s * t * t, c3 = t * t * t;\n\t\tvec3 pPos = p0 * c0 + p1 * c1 + p2 * c2 + p3 * c3;\n\t\tfloat c01 = 3.0 * s * s, c12 = 6.0 * s * t, c23 = 3.0 * t * t;\n\t\tvec3 pTangent = (p1 - p0) * c01 + (p2 - p1) * c12 + (p3 - p2) * c23;\n\t\tvec3 pNormal = normalize(vec3(pTangent.y, -pTangent.x, 0));\n\t\tvec4 p = vec4(pPos - ts_Vertex.y * width * pNormal, 1);\n\t\tgl_Position = ts_ModelViewProjectionMatrix * p;\n\t}\n`;\r\nexport const vertexShaderBezier3d = `\n precision highp float;\n // calculates a bezier curve using ts_Vertex.x as the (t) parameter of the curve\n\tuniform float scale, startT, endT;\n\tuniform vec3 ps[4];\n\tuniform vec3 p0, p1, p2, p3, normal;\n\tuniform mat4 ts_ModelViewProjectionMatrix;\n\tattribute vec4 ts_Vertex;\n\tvoid main() {\n\t\t// ts_Vertex.y is in [0, 1]\n\t\tvec3 p5 = ps[0];\n\t\tfloat t = startT * (1.0 - ts_Vertex.x) + endT * ts_Vertex.x, s = 1.0 - t;\n\t\tfloat c0 = s * s * s, \n\t\t c1 = 3.0 * s * s * t, \n\t\t c2 = 3.0 * s * t * t, c3 = t * t * t;\n\t\tvec3 p = (p0 * c0 + p1 * c1) + (p2 * c2 + p3 * c3);\n\t\tfloat c01 = 3.0 * s * s, \n\t\t c12 = 6.0 * s * t, \n\t\t c23 = 3.0 * t * t;\n\t\tvec3 pTangent = (p1 - p0) * c01 + (p2 - p1) * c12 + (p3 - p2) * c23;\n\t\tvec3 outDir = normalize(cross(normal, pTangent));\n\t\tvec3 correctNormal = normalize(cross(pTangent, outDir));\n\t\tvec3 p2 = p + scale * (outDir * ts_Vertex.y + correctNormal * ts_Vertex.z);\n\t\tgl_Position = ts_ModelViewProjectionMatrix * vec4(p2, 1);\n\t}\n`;\r\nexport const vertexShaderGeneric = `\n\tuniform float scale;\n\tuniform mat4 ts_ModelViewProjectionMatrix;\n\tattribute vec4 ts_Vertex;\n\tuniform mat3 ts_NormalMatrix;\n\tattribute vec3 ts_Normal;\n\tvoid main() {\n\t\tvec3 normal = normalize(ts_NormalMatrix * ts_Normal);\n\t\tvec4 vertexPos = ts_Vertex + vec4(normal * scale, 0);\n\t\tgl_Position = ts_ModelViewProjectionMatrix * vertexPos;\n\t}\n`;\r\nexport const vertexShaderRing = `\n\t#define M_PI 3.1415926535897932384626433832795\n\tuniform float step;\n\tuniform float innerRadius, outerRadius;\n\tattribute float index;\n\tuniform mat4 ts_ModelViewProjectionMatrix;\n\tattribute vec4 ts_Vertex;\n\tvoid main() {\n\t\tgl_Position = ts_ModelViewProjectionMatrix * vec4(index, index, index, 1);\n\t\tfloat id = atan(ts_Vertex.x, ts_Vertex.y) / M_PI * 32.0;\n\t\tfloat radius = mod(id, 2.0) < 1.0 ? outerRadius : innerRadius;\n\t\tgl_Position = ts_ModelViewProjectionMatrix * vec4(radius * cos(index * step), radius * sin(index * step), 0, 1);\n\t}\n`;\r\nexport const fragmentShaderColor = `\n\tprecision highp float;\n\tuniform vec4 color;\n\tvoid main() {\n\t\tgl_FragColor = color;\n\t}\n`;\r\nexport const fragmentShaderColor3 = `#version 300 es\n\tprecision highp float;\n\tuniform vec4 color;\n\tout vec4 fragColor;\n\tvoid main() {\n\t\tfragColor = color;\n\t}\n`;\r\nexport const fragmentShaderVaryingColor = `\n\tprecision highp float;\n\tvarying vec4 fragColor;\n\tvoid main() {\n\t\tgl_FragColor = fragColor;\n\t}\n`;\r\nexport const fragmentShaderColorHighlight = `\n\tprecision highp float;\n\tuniform vec4 color;\n\tvoid main() {\n\t\tfloat diagonal = (gl_FragCoord.x + 2.0 * gl_FragCoord.y);\n\t\tif (mod(diagonal, 50.0) > 40.0) { // mod(diagonal, 2.0) > 1.0\n\t\t\tdiscard;\n\t\t\t//gl_FragColor = color + vec4(0.2,0.2,0.2,0);\n\t\t} else {\n\t\t\tgl_FragColor = color - vec4(0.2,0.2,0.2,0);\n\t\t}\n\t}\n`;\r\nexport const vertexShaderTexture = `\n\tvarying vec2 texturePos;\n\tattribute vec4 ts_Vertex;\n\tuniform mat4 ts_ModelViewProjectionMatrix;\n\tvoid main() {\n\t\ttexturePos = ts_Vertex.xy;\n\t\tgl_Position = ts_ModelViewProjectionMatrix * ts_Vertex;\n\t}\n`;\r\nexport const fragmentShaderTextureColor = `\n\tprecision highp float;\n\tvarying vec2 texturePos;\n\tuniform vec4 color;\n\tuniform sampler2D texture;\n\tvoid main() {\n\t\tgl_FragColor = texture2D(texture, texturePos) * color;\n\t}\n`;\r\nexport const fragmentShaderTexture = `\n\tprecision highp float;\n\tvarying vec2 texturePos;\n\tuniform sampler2D texture;\n\tvoid main() {\n\t\tgl_FragColor = texture2D(texture, texturePos);\n\t}\n`;\r\n//# sourceMappingURL=shaders.js.map","import * as chroma from \"chroma.ts\";\r\nimport { addOwnProperties, arrayFromFunction, DEG, M4, TAU, V, V3, Vector, } from \"ts3dutils\";\r\nimport { GL_COLOR_BLACK, Mesh, Shader } from \"tsgl\";\r\nimport { B2T, BezierCurve, EllipseCurve, HyperbolaCurve, ImplicitCurve, L3, NURBS, ParabolaCurve, PICurve, PPCurve, } from \".\";\r\nimport { ceil, floor, pow, sign } from \"./math\";\r\nimport * as shaders from \"./shaders\";\r\nexport function parseGetParams(str) {\r\n const result = {};\r\n str.split(\"&\").forEach(function (item) {\r\n const splitIndex = item.indexOf(\"=\");\r\n if (-1 == splitIndex) {\r\n result[item] = item;\r\n }\r\n else {\r\n result[item.substr(0, splitIndex)] = decodeURI(item.substr(splitIndex + 1));\r\n }\r\n });\r\n return result;\r\n}\r\nexport const COLORS = {\r\n RD_FILL: chroma.color(\"#9EDBF9\"),\r\n RD_STROKE: chroma.color(\"#77B0E0\"),\r\n TS_FILL: chroma.color(\"#D19FE3\"),\r\n TS_STROKE: chroma.color(\"#A76BC2\"),\r\n PP_FILL: chroma.color(\"#F3B6CF\"),\r\n PP_STROKE: chroma.color(\"#EB81B4\"),\r\n};\r\nexport class BREPGLContext {\r\n constructor(gl) {\r\n this.cachedMeshes = new WeakMap();\r\n this.shaders = initShaders(gl);\r\n initMeshes((this.meshes = {}), gl);\r\n }\r\n static create(gl) {\r\n addOwnProperties(gl, BREPGLContext.prototype);\r\n addOwnProperties(gl, new BREPGLContext(gl));\r\n return gl;\r\n }\r\n drawPoint(p, color = GL_COLOR_BLACK, size = 5) {\r\n this.pushMatrix();\r\n this.translate(p);\r\n this.scale(size / 2, size / 2, size / 2);\r\n this.shaders.singleColor\r\n .uniforms({ color: color })\r\n .draw(this.meshes.sphere1);\r\n this.popMatrix();\r\n }\r\n drawEdge(edge, color = GL_COLOR_BLACK, width = 2) {\r\n CURVE_PAINTERS[edge.curve.constructor.name](this, edge.curve, color, edge.minT, edge.maxT, width);\r\n }\r\n drawCurve(curve, color = GL_COLOR_BLACK, width = 2, tStart, tEnd) {\r\n CURVE_PAINTERS[curve.constructor.name](this, curve, color, tStart, tEnd, width);\r\n }\r\n drawVector(vector, anchor, color = GL_COLOR_BLACK, size = 1) {\r\n if (vector.likeO())\r\n return;\r\n this.pushMatrix();\r\n const headLength = size * 4;\r\n if (headLength > vector.length())\r\n return;\r\n const vT = vector.getPerpendicular().unit();\r\n this.multMatrix(M4.forSys(vector.unit(), vT, vector.cross(vT).unit(), anchor));\r\n this.scale(vector.length() - headLength, size / 2, size / 2);\r\n this.shaders.singleColor\r\n .uniforms({\r\n color: color,\r\n })\r\n .draw(this.meshes.vectorShaft);\r\n this.scale(1 / (vector.length() - headLength), 1, 1);\r\n this.translate(vector.length() - headLength, 0, 0);\r\n this.scale(headLength / 2, 1, 1);\r\n this.shaders.singleColor.draw(this.meshes.vectorHead);\r\n this.popMatrix();\r\n }\r\n drawVectors(drVs, size = undefined) {\r\n this.drawVector(V3.X, V3.O, chroma.color(\"red\").gl(), size);\r\n this.drawVector(V3.Y, V3.O, chroma.color(\"green\").gl(), size);\r\n this.drawVector(V3.Z, V3.O, chroma.color(\"blue\").gl(), size);\r\n drVs.forEach((vi) => this.drawVector(vi.v, vi.anchor, vi.color, size));\r\n }\r\n drawPlane(customPlane, color, dotted = false) {\r\n this.pushMatrix();\r\n this.multMatrix(M4.forSys(customPlane.right, customPlane.up, customPlane.normal1, customPlane.anchor));\r\n this.translate(customPlane.uMin, customPlane.vMin, 0);\r\n this.scale(customPlane.uMax - customPlane.uMin, customPlane.vMax - customPlane.vMin, 1);\r\n const mesh = dotted\r\n ? this.meshes.xyDottedLinePlane\r\n : this.meshes.xyLinePlane;\r\n this.shaders.singleColor.uniforms({ color: color }).draw(mesh, this.LINES);\r\n this.popMatrix();\r\n }\r\n drawBox(m4, color) {\r\n this.pushMatrix();\r\n this.multMatrix(m4.m[15] >= 0 ? m4 : m4.mulScalar(-1));\r\n if (color) {\r\n this.shaders.singleColor\r\n .uniforms({ color: color })\r\n .draw(this.meshes.cube, this.LINES);\r\n }\r\n else {\r\n this.shaders.multiColor.draw(this.meshes.cube, this.LINES);\r\n }\r\n this.popMatrix();\r\n }\r\n}\r\nfunction conicPainter(mode, gl, ellipse, color, startT, endT, width = 2) {\r\n gl.shaders.ellipse3d\r\n .uniforms({\r\n f1: ellipse.f1,\r\n f2: ellipse.f2,\r\n center: ellipse.center,\r\n color: color,\r\n startT: startT,\r\n endT: endT,\r\n scale: width,\r\n mode: mode,\r\n })\r\n .draw(gl.meshes.pipe);\r\n}\r\nexport const CURVE_PAINTERS = {\r\n [EllipseCurve.name]: conicPainter.bind(undefined, 0),\r\n [ParabolaCurve.name]: conicPainter.bind(undefined, 1),\r\n [HyperbolaCurve.name]: conicPainter.bind(undefined, 2),\r\n [ImplicitCurve.name](gl, curve, color, startT, endT, width = 2) {\r\n let mesh = gl.cachedMeshes.get(curve);\r\n const RES = 4;\r\n if (!mesh) {\r\n mesh = new Mesh()\r\n .addIndexBuffer(\"TRIANGLES\")\r\n .addVertexBuffer(\"normals\", \"ts_Normal\");\r\n curve.addToMesh(mesh, RES);\r\n mesh.compile();\r\n gl.cachedMeshes.set(curve, mesh);\r\n }\r\n const startIndex = ceil(startT);\r\n const endIndex = floor(endT);\r\n if (startIndex <= endIndex) {\r\n const indexFactor = 2 * // no of triangles per face\r\n RES * // no of faces\r\n 3; // no of indexes per triangle\r\n gl.shaders.generic3d\r\n .uniforms({\r\n color: color,\r\n scale: width,\r\n })\r\n .draw(mesh, gl.TRIANGLES, startIndex * indexFactor, (floor(endT) - startIndex) * indexFactor);\r\n if (startT % 1 !== 0) {\r\n const p = curve.at(startT);\r\n gl.pushMatrix();\r\n const m = M4.forSys(p.to(curve.points[startIndex]), mesh.normals[startIndex * RES].toLength(width), mesh.normals[startIndex * RES + 1].toLength(width), p);\r\n gl.multMatrix(m);\r\n gl.shaders.singleColor\r\n .uniforms({ color: color })\r\n .draw(gl.meshes.pipeSegmentForICurve);\r\n console.log(gl.meshes.pipeSegmentForICurve);\r\n gl.popMatrix();\r\n }\r\n if (endT % 1 !== 0) {\r\n const p = curve.at(endT);\r\n gl.pushMatrix();\r\n const m = M4.forSys(curve.points[endIndex].to(p), mesh.normals[endIndex * RES].toLength(width), mesh.normals[endIndex * RES + 1].toLength(width), curve.points[endIndex]);\r\n gl.multMatrix(m);\r\n gl.shaders.singleColor\r\n .uniforms({ color: color })\r\n .draw(gl.meshes.pipeSegmentForICurve);\r\n gl.popMatrix();\r\n }\r\n }\r\n else {\r\n const p1 = curve.at(startT);\r\n const p2 = curve.at(endT);\r\n gl.pushMatrix();\r\n const v0 = p1.to(p2), v1 = v0.getPerpendicular().toLength(width), v2 = v0.cross(v1).toLength(width);\r\n const m = M4.forSys(v0, v1, v2, p1);\r\n gl.multMatrix(m);\r\n gl.shaders.singleColor\r\n .uniforms({ color: color })\r\n .draw(gl.meshes.pipeSegmentForICurve);\r\n gl.popMatrix();\r\n }\r\n },\r\n [BezierCurve.name](gl, curve, color, startT, endT, width = 2, normal = V3.Z) {\r\n gl.shaders.bezier3d\r\n .uniforms({\r\n p0: curve.p0,\r\n p1: curve.p1,\r\n p2: curve.p2,\r\n p3: curve.p3,\r\n color: color,\r\n startT: startT,\r\n endT: endT,\r\n scale: width,\r\n normal: normal,\r\n })\r\n .draw(gl.meshes.pipe);\r\n },\r\n [NURBS.name](gl, curve, color, startT, endT, width = 2, normal = V3.Z) {\r\n gl.shaders.nurbs\r\n .uniforms({\r\n \"points[0]\": Vector.pack(curve.points),\r\n degree: curve.degree,\r\n \"knots[0]\": curve.knots,\r\n color: color,\r\n startT: startT,\r\n endT: endT,\r\n scale: width,\r\n normal: normal,\r\n })\r\n .draw(gl.meshes.pipe);\r\n },\r\n [L3.name](gl, curve, color, startT, endT, width = 2, normal = V3.Z) {\r\n gl.pushMatrix();\r\n const a = curve.at(startT), b = curve.at(endT);\r\n const ab = b.minus(a), abT = ab.getPerpendicular().unit();\r\n const m = M4.forSys(ab, abT, ab.cross(abT).unit(), a);\r\n gl.multMatrix(m);\r\n gl.scale(1, width, width);\r\n gl.shaders.singleColor\r\n .uniforms({\r\n color: color,\r\n })\r\n .draw(gl.meshes.pipe);\r\n gl.popMatrix();\r\n },\r\n};\r\nCURVE_PAINTERS[PICurve.name] = CURVE_PAINTERS[ImplicitCurve.name];\r\nCURVE_PAINTERS[PPCurve.name] = CURVE_PAINTERS[ImplicitCurve.name];\r\nexport function initMeshes(_meshes, _gl) {\r\n _gl.makeCurrent();\r\n _meshes.cube = (() => {\r\n const cube = B2T.box().toMesh().addVertexBuffer(\"colors\", \"ts_Color\");\r\n cube.colors = cube.vertices.map((p) => [p.x, p.y, p.z, 1].map((x) => x * 0.9));\r\n cube.compile();\r\n return cube;\r\n })();\r\n _meshes.sphere1 = Mesh.sphere(2);\r\n _meshes.segment = Mesh.plane({ startY: -0.5, height: 1, detailX: 128 });\r\n _meshes.text = Mesh.plane();\r\n _meshes.vector = Mesh.rotation([V3.O, V(0, 0.05, 0), V(0.8, 0.05), V(0.8, 0.1), V(1, 0)], L3.X, TAU, 16, true);\r\n _meshes.vectorShaft = Mesh.rotation([V3.O, V3.Y, V3.XY], L3.X, TAU, 8, true);\r\n _meshes.vectorHead = Mesh.rotation([V3.Y, V(0, 2, 0), V(2, 0, 0)], L3.X, TAU, 8, true);\r\n _meshes.pipe = Mesh.rotation(arrayFromFunction(512, (i, l) => new V3(i / (l - 1), -0.5, 0)), L3.X, TAU, 8, true);\r\n _meshes.xyLinePlane = Mesh.plane();\r\n _meshes.xyDottedLinePlane = makeDottedLinePlane();\r\n _meshes.pipeSegmentForICurve = Mesh.offsetVertices(M4.rotateY(90 * DEG).transformedPoints(arrayFromFunction(4, (i) => V3.polar(1, (TAU * i) / 4))), V3.X, true);\r\n}\r\nexport function initShaders(_gl) {\r\n _gl.makeCurrent();\r\n return {\r\n singleColor: Shader.create(shaders.vertexShaderBasic, shaders.fragmentShaderColor),\r\n multiColor: Shader.create(shaders.vertexShaderColor, shaders.fragmentShaderVaryingColor),\r\n singleColorHighlight: Shader.create(shaders.vertexShaderBasic, shaders.fragmentShaderColorHighlight),\r\n textureColor: Shader.create(shaders.vertexShaderTexture, shaders.fragmentShaderTextureColor),\r\n arc: Shader.create(shaders.vertexShaderRing, shaders.fragmentShaderColor),\r\n arc2: Shader.create(shaders.vertexShaderArc, shaders.fragmentShaderColor),\r\n ellipse3d: Shader.create(shaders.vertexShaderConic3d, shaders.fragmentShaderColor),\r\n generic3d: Shader.create(shaders.vertexShaderGeneric, shaders.fragmentShaderColor),\r\n bezier3d: Shader.create(shaders.vertexShaderBezier3d, shaders.fragmentShaderColor),\r\n nurbs: Shader.create(shaders.vertexShaderNURBS, shaders.fragmentShaderColor3),\r\n bezier: Shader.create(shaders.vertexShaderBezier, shaders.fragmentShaderColor),\r\n lighting: Shader.create(shaders.vertexShaderLighting, shaders.fragmentShaderLighting),\r\n waves: Shader.create(shaders.vertexShaderWaves, shaders.fragmentShaderLighting),\r\n };\r\n}\r\nfunction makeDottedLinePlane(count = 128) {\r\n const mesh = new Mesh().addIndexBuffer(\"LINES\");\r\n const OXvertices = arrayFromFunction(count, (i) => new V3(i / count, 0, 0));\r\n mesh.vertices.push(...OXvertices);\r\n mesh.vertices.push(...M4.forSys(V3.Y, V3.O, V3.O, V3.X).transformedPoints(OXvertices));\r\n mesh.vertices.push(...M4.forSys(V3.X.negated(), V3.O, V3.O, new V3(1, 1, 0)).transformedPoints(OXvertices));\r\n mesh.vertices.push(...M4.forSys(V3.Y.negated(), V3.O, V3.O, V3.Y).transformedPoints(OXvertices));\r\n mesh.LINES = arrayFromFunction(count * 4, (i) => i - (i >= count * 2 ? 1 : 0));\r\n mesh.compile();\r\n return mesh;\r\n}\r\nexport function initNavigationEvents(_gl, eye, paintScreen) {\r\n const canvas = _gl.canvas;\r\n let lastPos = V3.O;\r\n //_gl.onmousedown.push((e) => {\r\n //\te.preventDefault()\r\n //\te.stopPropagation()\r\n //})\r\n //_gl.onmouseup.push((e) => {\r\n //\te.preventDefault()\r\n //\te.stopPropagation()\r\n //})\r\n canvas.addEventListener(\"mousemove\", (e) => {\r\n const pagePos = V(e.pageX, e.pageY);\r\n const delta = lastPos.to(pagePos);\r\n //noinspection JSBitwiseOperatorUsage\r\n if (e.buttons & 4) {\r\n // pan\r\n const moveCamera = V((-delta.x * 2) / _gl.canvas.width, (delta.y * 2) / _gl.canvas.height);\r\n const inverseProjectionMatrix = _gl.projectionMatrix.inversed();\r\n const worldMoveCamera = inverseProjectionMatrix.transformVector(moveCamera);\r\n eye.pos = eye.pos.plus(worldMoveCamera);\r\n eye.focus = eye.focus.plus(worldMoveCamera);\r\n setupCamera(eye, _gl);\r\n paintScreen();\r\n }\r\n // scene rotation\r\n //noinspection JSBitwiseOperatorUsage\r\n if (e.buttons & 2) {\r\n const rotateLR = (-delta.x / 6.0) * DEG;\r\n const rotateUD = (-delta.y / 6.0) * DEG;\r\n // rotate\r\n let matrix = M4.rotateLine(eye.focus, eye.up, rotateLR);\r\n //let horizontalRotationAxis = focus.minus(pos).cross(up)\r\n const horizontalRotationAxis = eye.up.cross(eye.pos.minus(eye.focus));\r\n matrix = matrix.times(M4.rotateLine(eye.focus, horizontalRotationAxis, rotateUD));\r\n eye.pos = matrix.transformPoint(eye.pos);\r\n eye.up = matrix.transformVector(eye.up);\r\n setupCamera(eye, _gl);\r\n paintScreen();\r\n }\r\n lastPos = pagePos;\r\n });\r\n canvas.addEventListener(\"wheel\", (e) => {\r\n // zoom\r\n const wheelY = -sign(e.deltaY) * 2;\r\n // console.log(e.deltaY, e.deltaX)\r\n eye.zoomFactor *= pow(0.9, -wheelY);\r\n const mouseCoordsOnCanvas = getPosOnTarget(e);\r\n const mousePosFrustrum = V((mouseCoordsOnCanvas.x * 2) / _gl.canvas.offsetWidth - 1, (-mouseCoordsOnCanvas.y * 2) / _gl.canvas.offsetHeight + 1, 0);\r\n const moveCamera = mousePosFrustrum.times(1 - 1 / pow(0.9, -wheelY));\r\n const inverseProjectionMatrix = _gl.projectionMatrix.inversed();\r\n const worldMoveCamera = inverseProjectionMatrix.transformVector(moveCamera);\r\n //console.log(\"moveCamera\", moveCamera)\r\n //console.log(\"worldMoveCamera\", worldMoveCamera)\r\n eye.pos = eye.pos.plus(worldMoveCamera);\r\n eye.focus = eye.focus.plus(worldMoveCamera);\r\n // tilt\r\n const mousePosWC = inverseProjectionMatrix.transformPoint(mousePosFrustrum);\r\n const tiltMatrix = M4.rotateLine(mousePosWC, eye.pos.to(eye.focus), -sign(e.deltaX) * 10 * DEG);\r\n eye.up = tiltMatrix.transformVector(eye.up);\r\n eye.pos = tiltMatrix.transformPoint(eye.pos);\r\n eye.focus = tiltMatrix.transformPoint(eye.focus);\r\n setupCamera(eye, _gl);\r\n paintScreen();\r\n e.preventDefault();\r\n });\r\n}\r\n/**\r\n * Transforms position on the screen into a line in world coordinates.\r\n */\r\nexport function getMouseLine(pos, _gl) {\r\n const ndc1 = V((pos.x * 2) / _gl.canvas.width - 1, (-pos.y * 2) / _gl.canvas.height + 1, 0);\r\n const ndc2 = V((pos.x * 2) / _gl.canvas.width - 1, (-pos.y * 2) / _gl.canvas.height + 1, 1);\r\n //console.log(ndc)\r\n const inverseProjectionMatrix = _gl.projectionMatrix.inversed();\r\n const s = inverseProjectionMatrix.transformPoint(ndc1);\r\n const dir = inverseProjectionMatrix.transformPoint(ndc2).minus(s);\r\n return L3.anchorDirection(s, dir);\r\n}\r\nexport function getPosOnTarget(e) {\r\n const target = e.target;\r\n const targetRect = target.getBoundingClientRect();\r\n const mouseCoordsOnElement = {\r\n x: e.clientX - targetRect.left,\r\n y: e.clientY - targetRect.top,\r\n };\r\n return mouseCoordsOnElement;\r\n}\r\nexport function setupCamera(_eye, _gl, suppressEvents = false) {\r\n const { pos, focus, up, zoomFactor } = _eye;\r\n //console.log(\"pos\", pos.$, \"focus\", focus.$, \"up\", up.$)\r\n _gl.matrixMode(_gl.PROJECTION);\r\n _gl.loadIdentity();\r\n //_gl.perspective(70, _gl.canvas.width / _gl.canvas.height, 0.1, 1000);\r\n const lr = _gl.canvas.width / 2 / zoomFactor;\r\n const bt = _gl.canvas.height / 2 / zoomFactor;\r\n _gl.ortho(-lr, lr, -bt, bt, -1e4, 1e4);\r\n _gl.lookAt(pos, focus, up);\r\n _gl.matrixMode(_gl.MODELVIEW);\r\n !suppressEvents && cameraChangeListeners.forEach((l) => l(_eye));\r\n}\r\nexport const cameraChangeListeners = [];\r\nexport const SHADERS_TYPE_VAR = false && initShaders(0);\r\n// let shaders: typeof SHADERS_TYPE_VAR\r\n// declare let a: BRep, b: BRep, c: BRep, d: BRep, edges: Edge[] = [], hovering: any,\r\n// \t, normallines: boolean = false, b2s: BRep[] = []\r\n// const\r\n//# sourceMappingURL=BREPGLContext.js.map","import { assertf, eq, floatHashCode, M4, V3 } from \"ts3dutils\";\r\nimport { acos, cos, sin } from \"./math\";\r\nexport class Quaternion {\r\n constructor(s, x, y, z) {\r\n this.s = s;\r\n this.x = x;\r\n this.y = y;\r\n this.z = z;\r\n }\r\n static axis(axis, rotation) {\r\n assertf(() => axis.hasLength(1));\r\n return new Quaternion(cos(rotation / 2), sin(rotation / 2) * axis.x, sin(rotation / 2) * axis.y, sin(rotation / 2) * axis.z);\r\n }\r\n static of(s, x, y, z) {\r\n return new Quaternion(s, x, y, z);\r\n }\r\n plus(q) {\r\n return new Quaternion(this.s + q.s, this.x + q.x, this.y + q.y, this.z + q.z);\r\n }\r\n times(q) {\r\n return \"number\" == typeof q\r\n ? new Quaternion(q * this.s, q * this.x, q * this.y, q * this.z)\r\n : new Quaternion(this.s * q.s - (this.x * q.x + this.y * q.y + this.z * q.z), this.y * q.z - this.z * q.y + this.s * q.x + q.s * this.x, this.z * q.x - this.x * q.z + this.s * q.y + q.s * this.y, this.x * q.y - this.y * q.x + this.s * q.z + q.s * this.z);\r\n }\r\n conjugated() {\r\n return new Quaternion(this.s, -this.x, -this.y, -this.z);\r\n }\r\n length() {\r\n return Math.hypot(this.s, this.x, this.y, this.z);\r\n }\r\n norm() {\r\n return Math.pow(this.s, 2) + Math.pow(this.x, 2) + (Math.pow(this.y, 2) + Math.pow(this.z, 2));\r\n }\r\n unit() {\r\n const l = this.length();\r\n return new Quaternion(this.s / l, this.x / l, this.y / l, this.z / l);\r\n }\r\n inverse() {\r\n return this.conjugated().times(1 / this.norm());\r\n }\r\n toM4() {\r\n assertf(() => eq(1, this.length()));\r\n const { s, x, y, z } = this;\r\n // prettier-ignore\r\n return new M4([\r\n 1 - 2 * (y * y + z * z), 2 * (x * y - z * s), 2 * (x * z + y * s), 0,\r\n 2 * (x * y + z * s), 1 - 2 * (x * x + z * z), 2 * (y * z - x * s), 0,\r\n 2 * (x * z - y * s), 2 * (y * z + x * s), 1 - 2 * (x * x + y * y), 0,\r\n 0, 0, 0, 1,\r\n ]);\r\n }\r\n static fromRotation(m4) {\r\n const sqrtTracePlus1 = Math.sqrt(m4.trace() + 1);\r\n const f = 1 / (2 * sqrtTracePlus1);\r\n return new Quaternion(sqrtTracePlus1 / 2, f * (m4.e(2, 1) - m4.e(1, 2)), f * (m4.e(0, 2) - m4.e(2, 0)), f * (m4.e(1, 0) - m4.e(0, 1)));\r\n }\r\n rotatePoint(p) {\r\n const v = this.times(Quaternion.of(1, p.x, p.y, p.z)).times(this.conjugated());\r\n return new V3(v.x, v.y, v.z);\r\n }\r\n like(q, precision) {\r\n return (eq(this.s, q.s, precision) &&\r\n eq(this.x, q.x, precision) &&\r\n eq(this.y, q.y, precision) &&\r\n eq(this.z, q.z, precision));\r\n }\r\n equals(q) {\r\n return (this == q ||\r\n (q instanceof Quaternion &&\r\n this.s == q.s &&\r\n this.x == q.x &&\r\n this.y == q.y &&\r\n this.z == q.z));\r\n }\r\n hashCode() {\r\n let hashCode = 0;\r\n hashCode = (hashCode * 31 + floatHashCode(this.s)) | 0;\r\n hashCode = (hashCode * 31 + floatHashCode(this.x)) | 0;\r\n hashCode = (hashCode * 31 + floatHashCode(this.y)) | 0;\r\n hashCode = (hashCode * 31 + floatHashCode(this.z)) | 0;\r\n return hashCode;\r\n }\r\n slerp(b, f) {\r\n assertf(() => eq(1, this.length()));\r\n assertf(() => eq(1, b.length()));\r\n const a = this;\r\n let dot = a.s * b.s + a.x * b.x + a.y * b.y + a.z * b.z;\r\n if (dot < 0) {\r\n dot = -dot;\r\n b = b.times(-1);\r\n console.log(\"dot < 0\");\r\n }\r\n const DOT_THRESHOLD = 0.9995;\r\n if (dot > DOT_THRESHOLD) {\r\n // If the inputs are too close for comfort, linearly interpolate\r\n // and normalize the result.\r\n return a\r\n .times(1 - f)\r\n .plus(b.times(f))\r\n .unit();\r\n }\r\n // Since dot is in range [0, DOT_THRESHOLD], acos is safe\r\n const theta0 = acos(dot); // theta_0 = angle between input vectors\r\n const theta = theta0 * f; // theta = angle between v0 and result\r\n const s0 = cos(theta) - (dot * sin(theta)) / sin(theta0); // == sin(theta_0 - theta) / sin(theta_0)\r\n const s1 = sin(theta) / sin(theta0);\r\n console.log(s0, s1, a.times(s0), b.times(s1));\r\n return a.times(s0).plus(b.times(s1));\r\n }\r\n toArray() {\r\n return [this.s, this.x, this.y, this.z];\r\n }\r\n}\r\nQuaternion.O = new Quaternion(1, 0, 0, 0);\r\n//# sourceMappingURL=Quaternion.js.map","import { Surface } from \"..\";\r\nexport class ImplicitSurface extends Surface {\r\n static is(obj) {\r\n return obj.implicitFunction && obj.didp;\r\n }\r\n}\r\n//# sourceMappingURL=ImplicitSurface.js.map"],"names":["Transformable","assertNumbers","assert","eq","newtonIterate2dWithDerivatives","NLA_PRECISION","fuzzyUniquesF","eq0","callsce","le","withMax","arrayFromFunction","newtonIterateWithDerivative","clamp","AABB","V3","newtonIterate1d","glqInSteps","hasConstructor","arrayEquals","arrayHashCode","mapFilter","getIntervals","V","getLast","assertVectors","M4","TAU","pushQuad","assertInst","solveCubicReal2","snap0","toSource","arrayRange","bisect","between","assertNever","assertf","fuzzyUniques","concatenated","MINUS","combinations","lerp","lt","VV","MathFunctionR2R","newtonIterate","pqFormula","fuzzyBetween","checkDerivate","newtonIterateSmart","NLA_DEBUG","firstUnsorted","Vector","arraySamples","newtonIterateWithDerivative2","vArrGet","snap","setLast","max","L3","EllipseCurve","HyperbolaCurve","ParabolaCurve","BezierCurve","floatHashCode","P3","PointVsFace","dotCurve2","PPCurve","ImplicitCurve","ZDirVolumeVisitor","CalculateAreaVisitor","Surface","emod","Curve","PICurve","breakDownPPCurves","Mesh","isCCW","ParametricSurface","CylinderSurface","PlaneSurface","ImplicitSurface","DEG","NURBS","NURBSSurface","intersectionUnitCircleLine2","ProjectedCurveSurface","OUTSIDE","sum","getRoots","Edge","gaussLegendreQuadrature24","getExtremePointsHelper","sliceStep","ilog","indexWithMax","gaussLegendre24Xs","gaussLegendre24Weights","XiEtaCurve","ConicSurface","EllipsoidSurface","RotatedCurveSurface","getGlobalId","StraightEdge","PlaneFace","Face","BRep","PCurveEdge","opentype.load","opentype.Path","edgePathFromSVG","createEdge","GOLDEN_RATIO","edgeForCurveAndTs","B2T","chroma.random","GL_COLOR_BLACK","min","snap2","SVGPathData","PI","mod","round","Pair","mapPush","EPS","fff","INSIDE","COPLANAR_SAME","splitsVolumeEnclosingFacesP","splitsVolumeEnclosingFaces","splitsVolumeEnclosingCone2","splitsVolumeEnclosingFacesP2","gt","arrayMin","doubleSignedArea","triangulateVertices","disableConsole","ge","bagRemoveIndex","enableConsole","binaryIndexOf","binaryInsert","SCE","JavaMap","JavaSet","CustomSet","earcut","uvInAABB2","curvePointMF","newtonIterate2d","nerdamer","chroma.color","addOwnProperties","Shader","shaders.vertexShaderBasic","shaders.fragmentShaderColor","shaders.vertexShaderColor","shaders.fragmentShaderVaryingColor","shaders.fragmentShaderColorHighlight","shaders.vertexShaderTexture","shaders.fragmentShaderTextureColor","shaders.vertexShaderRing","shaders.vertexShaderArc","shaders.vertexShaderConic3d","shaders.vertexShaderGeneric","shaders.vertexShaderBezier3d","shaders.vertexShaderNURBS","shaders.fragmentShaderColor3","shaders.vertexShaderBezier","shaders.vertexShaderLighting","shaders.fragmentShaderLighting","shaders.vertexShaderWaves"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAO,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,EAAE,EAAE,OAAO,EAAE,KAAK,GAAG,GAAG,IAAI;;ACGjS,IAAI,sBAAsB,GAAG,KAAK,CAAC;AAC5B,MAAM,KAAK,SAASA,uBAAa,C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I,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAC7D,QAAQ,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE;AACtC,YAAY,OAAO,GAAG,CAAC;AACvB,SAAS;AACT,QAAQ,MAAM,MAAM,GAAG,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC;AAC3D,QAAQ,OAAO,MAAM,GAAG,MAAM,GAAG,GAAG,CAAC;AACrC,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAI,QAAQ,CAAC,SAAS,EAAE;AACxB,QAAQ,OAAO,IAAI,SAAS,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,CAAC,SAAS,CAAC,CAAC,CAAC;AACtE,KAAK;AACL,IAAI,cAAc,CAAC,CAAC,EAAE,GAAG,EAAE;AAC3B,QAAQ,OAAO,IAAI,CAAC,cAAc,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,CAACvD,uBAAa,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;AACzE,KAAK;AACL,IAAI,iBAAiB,CAAC,MAAM,EAAE,MAAM,EA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,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;AACxC;AACA,QAAQ,MAAM,YAAY,GAAG,IAAI,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;AACpD,QAAQ,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,EAAE,MAAM,GAAG,CAAC,CAAC;AAC5C;AACA;AACA;AACA,QAAQ,OAAO,YAAY,CAAC,CAAC,CAAC,CAAC;AAC/B,KAAK;AACL;;AC5PO,MAAM,sBAAsB,GAAG,CAAC;AACvC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC,CAAC;AACK,MAAM,oBAAoB,GAAG,CAAC;AACrC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC,CAAC;AACK,MAAM,iBAAiB,GAAG,CAAC;AAClC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC,CAAC;AAwCK,MAAM,iBAAiB,GAAG,CAAC;AAClC;AACA;AACA;AACA;AACA;AACA,CAAC,CAAC;AACK,MAAM,iBAAiB,GAAG,CAAC;AAClC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC,CAAC;AACK,MAAM,eAAe,GAAG,CAAC;AAChC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC,CAAC;AACK,MAAM,mBAAmB,GAAG,CAAC;AACpC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC,CAAC;AACK,MAAM,iBAAiB,GAAG,CAAC;AAClC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC,CAAC;AACK,MAAM,kBAAkB,GAAG,CAAC;AACnC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC,CAAC;AACK,MAAM,oBAAoB,GAAG,CAAC;AACrC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC,CAAC;AACK,MAAM,mBAAmB,GAAG,CAAC;AACpC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC,CAAC;AACK,MAAM,gBAAgB,GAAG,CAAC;AACjC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC,CAAC;AACK,MAAM,mBAAmB,GAAG,CAAC;AACpC;AACA;AACA;AACA;AACA;AACA,CAAC,CAAC;AACK,MAAM,oBAAoB,GAAG,CAAC;AACrC;AACA;AACA;AACA;AACA;AACA;AACA,CAAC,CAAC;AACK,MAAM,0BAA0B,GAAG,CAAC;AAC3C;AACA;AACA;AACA;AACA;AACA,CAAC,CAAC;AACK,MAAM,4BAA4B,GAAG,CAAC;AAC7C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC,CAAC;AACK,MAAM,mBAAmB,GAAG,CAAC;AACpC;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC,CAAC;AACK,MAAM,0BAA0B,GAAG,CAAC;AAC3C;AACA;AACA;AACA;AACA;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AC,EAAE,CAAC,CAAC,CAAC;AAC7C,KAAK;AACL,IAAI,OAAO,GAAG;AACd,QAAQ,OAAO,CAAC,IAAI,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC;AAChD,KAAK;AACL,CAAC;AACD,UAAU,CAAC,CAAC,GAAG,IAAI,UAAU,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;;AChHlC,MAAM,eAAe,SAASsE,UAAO,CAAC;AAC7C,IAAI,OAAO,EAAE,CAAC,GAAG,EAAE;AACnB,QAAQ,OAAO,GAAG,CAAC,gBAAgB,IAAI,GAAG,CAAC,IAAI,CAAC;AAChD,KAAK;AACL;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"} \ No newline at end of file diff --git a/dist/bundle.min.js b/dist/bundle.min.js deleted file mode 100644 index 125e68f..0000000 --- a/dist/bundle.min.js +++ /dev/null @@ -1 +0,0 @@ -"use strict";function _interopDefault(t){return t&&"object"==typeof t&&"default"in t?t.default:t}Object.defineProperty(exports,"__esModule",{value:!0});var ts3dutils=require("ts3dutils"),tsgl=require("tsgl"),opentype=require("opentype.js"),chroma=_interopDefault(require("chroma-js")),svgPathdata=require("svg-pathdata"),javasetmap_ts=require("javasetmap.ts"),earcut=_interopDefault(require("earcut")),nerdamer=_interopDefault(require("nerdamer"));const{abs:abs,acos:acos,acosh:acosh,asin:asin,asinh:asinh,atan:atan,atanh:atanh,atan2:atan2,ceil:ceil,cbrt:cbrt,expm1:expm1,clz32:clz32,cos:cos,cosh:cosh,exp:exp,floor:floor,fround:fround,hypot:hypot,imul:imul,log:log,log1p:log1p,log2:log2,log10:log10,max:max,min:min,pow:pow,random:random,round:round,sign:sign,sin:sin,sinh:sinh,sqrt:sqrt,tan:tan,tanh:tanh,trunc:trunc,E:E,LN10:LN10,LN2:LN2,LOG10E:LOG10E,LOG2E:LOG2E,PI:PI,SQRT1_2:SQRT1_2,SQRT2:SQRT2}=Math;let insideIsInfosWithCurve=!1;class Curve$$1 extends ts3dutils.Transformable{constructor(t,s){super(),this.tMin=t,this.tMax=s,ts3dutils.assertNumbers(t,s),ts3dutils.assert("number"==typeof t&&!isNaN(t)),ts3dutils.assert("number"==typeof s&&!isNaN(s)),ts3dutils.assert(tts3dutils.eq(t.tThis,s)&&ts3dutils.eq(t.tOther,e))){const r=(s,e)=>t.tangentAt(s).dot(t.at(s).minus(i.at(e))),n=(s,e)=>i.tangentAt(e).dot(t.at(s).minus(i.at(e))),a=(t,s,e,i)=>t.ddt(e).dot(t.at(e).minus(s.at(i)))+t.tangentAt(e).squared(),u=(t,s,e,i)=>-t.tangentAt(e).dot(s.tangentAt(i)),l=ts3dutils.newtonIterate2dWithDerivatives(r,n,s,e,16,a.bind(void 0,t,i),u.bind(void 0,t,i),(s,e)=>-u(i,t,e,s),(s,e)=>-a(i,t,e,s));ts3dutils.assert(isFinite(l.x)),ts3dutils.assert(isFinite(l.y)),void 0==l&&console.log(s,e,t.sce,i.sce),o.push({tThis:l.x,tOther:l.y,p:t.at(l.x)})}}(u,l),!0;{const o=t.getAABB(e,u),h=i.getAABB(n,l);let d,p;s(e,u,n,l,o,h,c+1)||s(e,u,l,a,o,p=i.getAABB(l,a),c+1)||s(u,r,n,l,d=t.getAABB(u,r),h,c+1)||s(u,r,l,a,d,p,c+1)}}return!1}(s,e,r,n,t.getAABB(s,e),i.getAABB(r,n)),ts3dutils.fuzzyUniquesF(o,t=>t.tThis)}static breakDownIC(t,s,e,i,r,n){const{uMin:o,uMax:a,vMin:u,vMax:l}=s,c=l-u,h=ceil((a-o)/e),d=ceil(c/i),p=new Array(h*d).fill(0),f=(t,s)=>p[s*h+t],m=(t,s)=>0<=t&&t2);for(const{x:s,y:r}of t.points){const t=(s-o)/e,n=(r-u)/i;m(t-.5|0,n-.5|0),m(t-.5|0,n+.5|0),m(t+.5|0,n-.5|0),m(t+.5|0,n+.5|0)}}$.push(...a)}}for(const{points:t}of $)for(let s=0;st)){return ts3dutils.callsce.call(void 0,"new "+this.constructor.name,...this.getConstructorParameters(),this.tMin,this.tMax)}withBounds(t=this.tMin,s=this.tMax){return new this.constructor(...this.getConstructorParameters(),t,s)}closestPointToPoint(t){return this.at(this.closestTToPoint(t))}isValidT(t){return ts3dutils.le(this.tMin,t)&&ts3dutils.le(t,this.tMax)}diff(t,s){return this.at(t).to(this.at(t+s))}closestTToPoint(t,s,e=this.tMin,i=this.tMax){return void 0===s&&(s=ts3dutils.arrayFromFunction(32,t=>e+(i-e)*t/31).withMax(s=>-this.at(s).distanceTo(t))),ts3dutils.newtonIterateWithDerivative(s=>this.at(s).minus(t).dot(this.tangentAt(s)),s,16,s=>this.tangentAt(s).squared()+this.at(s).minus(t).dot(this.ddt(s)))}calcSegmentPoints(t,s,e,i,r,n){ts3dutils.assert(this.tIncrement,"tIncrement not defined on "+this);const o=this.tIncrement,a=[];if(n&&a.push(e),ts3dutils.assert(r!=t=i;t--)a.push(this.at(t*o))}return a.push(i),a}calcSegmentTs(t,s,e,i){ts3dutils.assert(this.tIncrement,"tIncrement not defined on "+this);const r=this.tIncrement,n=[];if(i&&n.push(t),ts3dutils.assert(e!=t=i;t--)n.push(t*r)}return n.push(s),n}distanceToPoint(t,s,e){const i=this.closestTToPoint(t,s,e);return this.at(i).distanceTo(t)}asSegmentDistanceToPoint(t,s,e){let i=this.closestTToPoint(t,s,e);return i=ts3dutils.clamp(i,s,e),this.at(i).distanceTo(t)}isInfosWithCurve(t){if(insideIsInfosWithCurve)return Curve$$1.ispsRecursive(this,this.tMin,this.tMax,t,t.tMin,t.tMax);try{return insideIsInfosWithCurve=!0,t.isInfosWithCurve(this).map(t=>{ts3dutils.assert(t);const{tThis:s,tOther:e,p:i}=t;return{tOther:s,tThis:e,p:i}})}finally{insideIsInfosWithCurve=!1}}isTsWithSurface(t){if(t instanceof PlaneSurface$$1)return this.isTsWithPlane(t.plane);if(t instanceof ProjectedCurveSurface$$1){const s=new P3$$1(t.dir.unit(),0),e=this.project(s);return t.baseCurve.project(s).isInfosWithCurve(e).map(t=>t.tOther)}if(t instanceof EllipsoidSurface$$1){const s=this.transform(t.matrixInverse);if(!s.getAABB().touchesAABBfuzzy(new ts3dutils.AABB(ts3dutils.V3.XYZ.negated(),ts3dutils.V3.XYZ)))return[];const e=t=>s.at(t).length()-1,i=t=>s.at(t).unit().dot(s.tangentAt(t)),r=1/2048,n=[];for(let t=this.tMin;t<=this.tMax;t+=r){const o=r*s.tangentAt(t).length();if(abs(e(t))<=o){let s=ts3dutils.newtonIterateWithDerivative(e,t,16,i);ts3dutils.eq0(e(s))&&!ts3dutils.eq0(i(s))||(s=ts3dutils.newtonIterate1d(i,t,16)),ts3dutils.eq0(e(s))&&!n.some(t=>ts3dutils.eq(t,s))&&n.push(s)}}return n.filter(s=>t.containsPoint(this.at(s)))}throw new Error}arcLength(t,s,e=1){return ts3dutils.assert(tthis.tangentAt(t).length(),t,s,e)}equals(t){return this===t||ts3dutils.hasConstructor(t,this.constructor)&&this.getConstructorParameters().equals(t.getConstructorParameters())}hashCode(){return this.getConstructorParameters().hashCode()}getAABB(t=this.tMin,s=this.tMax){t=isFinite(t)?t:this.tMin,s=isFinite(s)?s:this.tMax;const e=this.at(t),i=this.at(s),r=this.roots(),n=new Array(3),o=new Array(3);for(let a=0;a<3;a++){const u=r[a];n[a]=Math.min(e.e(a),i.e(a)),o[a]=Math.max(e.e(a),i.e(a));for(const e of u)tthis.tMin<=t&&t<=this.tMax);return ts3dutils.getIntervals(s,this.tMin,this.tMax).mapFilter(([s,e])=>{const i=(s+e)/2;return!ts3dutils.eq(s,e)&&t.distanceToPointSigned(this.at(i))<0&&this.withBounds(s,e)})}}function mkcurves(t,s,e,i,r,n){const o=ts3dutils.V(s,e);ts3dutils.assert(i>0);const{points:a,tangents:u}=followAlgorithm2d$$1(t,o,i,r,n);if(a.length>4&&a[0].distanceTo(a.last)<=abs(i)){for(let t=0;t2),[a]}}function breakDownPPCurves$$1(t,s,e,i,r){const{uMin:n,uMax:o,vMin:a,vMax:u}=t,l=uvInAABB2$$1.bind(void 0,t),c=uvInAABB2$$1.bind(void 0,s),h=u-a,d=ceil((o-n)/e),p=ceil(h/i),f=new Array(d*p).fill(0),m=(t,s)=>f[s*d+t],$=(t,s)=>0<=t&&t2);for(const{x:s,y:r}of t.st1s){const t=(s-n)/e,o=(r-a)/i;$(t-.5|0,o-.5|0),$(t-.5|0,o+.5|0),$(t+.5|0,o-.5|0),$(t+.5|0,o+.5|0)}}g.push(...o)}}console.table(v);for(const{points:t}of g)for(let s=0;snew PPCurve$$1(e,i,t,s,n,void 0,r,1))}function mkPPCurves(t,s,e,i,r,n){const{points:o,tangents:a,st1s:u}=followAlgorithmPP$$1(t,s,e,i,r,n);if(o[0].distanceTo(o.last)2){for(let t=0;t2),[a]}}function AABB2$$1(t,s,e,i){return{uMin:t,uMax:s,vMin:e,vMax:i}}function uvInAABB2$$1(t,s,e){return t.uMin<=s&&s<=t.uMax&&t.vMin<=e&&e<=t.vMax}function curvePoint$$1(t,s,e,i){let r=s;for(let s=0;s<8;s++){const s=t(r.x,r.y),n=e(r.x,r.y),o=i(r.x,r.y),a=s/(n*n+o*o);r=r.minus(new ts3dutils.V3(a*n,a*o,0))}return r}function curvePointMF$$1(t,s,e=8,i=1/(1<<30)){let r=s;for(let s=0;sts3dutils.V3.polar(1,ts3dutils.TAU*t/s)),n=ts3dutils.arrayFromFunction(s,t=>ts3dutils.V3.polar(e,ts3dutils.TAU*t/s)),o=this.tIncrement,a=Math.ceil((this.tMin+ts3dutils.NLA_PRECISION)/o),u=Math.floor((this.tMax-ts3dutils.NLA_PRECISION)/o);for(let e=a;e<=u;e+=i){const i=e*o,a=t.vertices.length;if(0!==e)for(let e=0;e{const e=this.at(s);if(t.containsPoint(e))return{tThis:s,tOther:t.pointT(e),p:e}}):super.isInfosWithCurve(t)}transform(t){return new this.constructor(t.transformPoint(this.center),t.transformVector(this.f1),t.transformVector(this.f2),this.tMin,this.tMax)}equals(t){return this==t||void 0!=t&&this.constructor==t.constructor&&this.center.equals(t.center)&&this.f1.equals(t.f1)&&this.f2.equals(t.f2)}hashCode(){let t=0;return 0|(t=31*(t=31*(t=31*t+this.center.hashCode())+this.f1.hashCode())+this.f2.hashCode())}likeCurve(t){return ts3dutils.hasConstructor(t,this.constructor)&&this.center.like(t.center)&&this.f1.like(t.f1)&&this.f2.like(t.f2)}normalP(t){return this.tangentAt(t).cross(this.normal)}getPlane(){return P3$$1.normalOnAnchor(this.normal,this.center)}isTsWithPlane(t){if(ts3dutils.assertInst(P3$$1,t),t.normal1.isParallelTo(this.normal))return[];const s=t.normal1,e=t.w,i=this.center,r=this.f1,n=this.f2,o=s.dot(r),a=s.dot(n),u=e-s.dot(i);return this.constructor.intersectionUnitLine(o,a,u,this.tMin,this.tMax)}pointT(t){ts3dutils.assertVectors(t);const s=this.matrixInverse.transformPoint(t);return this.constructor.XYLCPointT(s)}containsPoint(t){const s=this.matrixInverse.transformPoint(t);return ts3dutils.eq0(s.z)&&this.isValidT(this.constructor.XYLCPointT(s,this.tMin,this.tMax))}isInfosWithLine(t,s,e=this.tMin,i=this.tMax,r=-1e5,n=1e5){const o=this.matrixInverse.transformPoint(t),a=this.matrixInverse.transformVector(s);if(ts3dutils.eq0(a.z)){if(ts3dutils.eq0(o.z))return this.constructor.unitIsInfosWithLine(o,a,t,s,e,i)}else{const e=o.z/a.z,i=a.times(e).plus(o);if(this.constructor.XYLCValid(i))return[{tThis:this.constructor.XYLCPointT(i),tOther:e,p:t.plus(s.times(e))}]}return[]}isTsWithSurface(t){if(t instanceof PlaneSurface$$1)return this.isTsWithPlane(t.plane);if(t instanceof EllipsoidSurface$$1){return t.isCurvesWithPlane(this.getPlane()).flatMap(t=>this.isInfosWithCurve(t)).filter(s=>t.containsPoint(s.p)).map(t=>t.tThis)}if(t instanceof ProjectedCurveSurface$$1||t instanceof ConicSurface$$1)return t.isCurvesWithPlane(this.getPlane()).flatMap(t=>this.isInfosWithCurve(t)).map(t=>t.tThis);throw new Error}isInfosWithBezier(t){const s=t.transform(this.matrixInverse);if(new PlaneSurface$$1(P3$$1.XY).containsCurve(s))return this.isInfosWithBezier2D(t);return s.isTsWithPlane(P3$$1.XY).mapFilter(e=>{const i=s.at(e);if(this.constructor.XYLCValid(i))return{tOther:e,p:t.at(e),tThis:this.constructor.XYLCPointT(i)}})}isInfosWithBezier2D(t,s=t.tMin,e=t.tMax){return Curve$$1.ispsRecursive(this,this.tMin,this.tMax,t,s,e)}isOrthogonal(){return this.f1.isPerpendicularTo(this.f2)}at2(t,s){return ts3dutils.assertNumbers(t,s),this.center.plus(this.f1.times(t)).plus(this.f2.times(s))}debugInfo(){return{points:[this.center,this.at2(.5,0),this.at2(0,1/3),this.at2(0,2/3)],lines:[this.center,this.at2(0,1),this.center,this.at2(1,0)]}}}function parabola4Projection$$1(t,s,e){return HyperbolaCurve$$1.XY.rotateZ(45*ts3dutils.DEG)}class ImplicitCurve$$1 extends Curve$$1{constructor(t,s,e=1,i,r=(1==e?0:-(t.length-1)),n=(1==e?t.length-1:0)){super(r,n),this.points=t,this.tangents=s,this.dir=e,this.generator=i,ts3dutils.assert(t.length>2),ts3dutils.assert(0<=r&&r<=t.length-1,r,t.length),ts3dutils.assert(0<=n&&n<=t.length-1,n,t.length)}likeCurve(t){throw new Error("Method not implemented.")}toSource(t=(t=>t)){return this.generator||super.toSource(t)}containsPoint(t){return ts3dutils.assertVectors(t),!isNaN(this.pointT(t))}equals(t){return this==t||Object.getPrototypeOf(t)==PICurve$$1.prototype&&this.points[0].equals(t.points[0])&&this.tangents[0].equals(t.tangents[0])}hashCode(){return[this.points[0],this.tangents[0]].hashCode()}tangentP(t){ts3dutils.assertVectors(t),ts3dutils.assert(this.containsPoint(t),"this.containsPoint(pWC)"+this.containsPoint(t));const s=this.pointT(t);return this.tangentAt(s)}tangentAt(t){return t=ts3dutils.clamp(t,this.tMin,this.tMax),ts3dutils.V3.lerp(this.tangents[floor(t)],this.tangents[ceil(t)],t%1)}at(t){return ts3dutils.assert(isFinite(t)),ts3dutils.V3.lerp(this.points[floor(t)],this.points[ceil(t)],t%1)}getConstructorParameters(){throw new Error}roots(){const t=ts3dutils.arrayRange(0,this.points.length);return[t,t,t]}addToMesh(t,s=4,e=0,i=1){const r=ts3dutils.arrayFromFunction(s,t=>ts3dutils.V3.polar(1,ts3dutils.TAU*t/s)),n=ts3dutils.arrayFromFunction(s,t=>ts3dutils.V3.polar(e,ts3dutils.TAU*t/s));let o=ts3dutils.V3.Z,a=ts3dutils.M4.IDENTITY;for(let e=0;e-t.distanceTo(this.points[s]));if(void 0===s)throw new Error;if(this.points[s].like(t))return s;const e=max(0,s-1),i=min(this.points.length-1,s+1),r=this.tangentAt(s),n=ts3dutils.bisect(s=>this.at(s).to(t).dot(r),e,i,32);return isFinite(n)&&ts3dutils.eq0(this.at(n).distanceTo(t))?n:NaN}}function surfaceIsICurveIsInfosWithLine$$1(t,s,e,i,r,n,o,a){const u=new L3$$1(e,i.unit()),l=t.isTsForLine(u),c=s.isTsForLine(u);l.filter(t=>c.some(s=>ts3dutils.eq(t,s))).map(t=>({tThis:0,tOther:t/i.length(),p:u.at(t)})).filter(t=>this.containsPoint(t.p)).forEach(t=>t.tThis=this.pointT(t.p))}ImplicitCurve$$1.prototype.tIncrement=1;class BezierCurve$$1 extends Curve$$1{constructor(t,s,e,i,r=-.1,n=1.1){super(r,n),ts3dutils.assertVectors(t,s,e,i),ts3dutils.assert(isFinite(r)&&isFinite(n)),this.p0=t,this.p1=s,this.p2=e,this.p3=i}get points(){return[this.p0,this.p1,this.p2,this.p3]}static graphXY(t,s,e,i,r,n){const o=i,a=e/3+o,u=s/3-o+2*a,l=t+o-3*a+3*u;return new BezierCurve$$1(ts3dutils.V(0,o),ts3dutils.V(1/3,a),ts3dutils.V(2/3,u),ts3dutils.V(1,l),r,n)}static quadratic(t,s,e,i=0,r=1){const n=L3$$1.throughPoints(t,e);return n.containsPoint(s)?n:new BezierCurve$$1(t,s.times(2).plus(t).div(3),s.times(2).plus(e).div(3),e,i,r)}static approximateUnitArc(t){const s=4/3*Math.tan(t/4);return new BezierCurve$$1(ts3dutils.V3.X,new ts3dutils.V3(1,s,0),new ts3dutils.V3(cos(t)+s*sin(t),sin(t)-s*cos(t),0),ts3dutils.V3.sphere(t,0),0,1)}getConstructorParameters(){return[this.p0,this.p1,this.p2,this.p3]}at(t){ts3dutils.assertNumbers(t);const s=this.p0,e=this.p1,i=this.p2,r=this.p3,n=1-t,o=n*n*n,a=3*n*n*t,u=3*n*t*t,l=t*t*t;return new ts3dutils.V3(s.x*o+e.x*a+i.x*u+r.x*l,s.y*o+e.y*a+i.y*u+r.y*l,s.z*o+e.z*a+i.z*u+r.z*l)}tangentAt(t){ts3dutils.assertNumbers(t);const s=this.p0,e=this.p1,i=this.p2,r=this.p3,n=1-t,o=3*n*n,a=6*n*t,u=3*t*t;return new ts3dutils.V3((e.x-s.x)*o+(i.x-e.x)*a+(r.x-i.x)*u,(e.y-s.y)*o+(i.y-e.y)*a+(r.y-i.y)*u,(e.z-s.z)*o+(i.z-e.z)*a+(r.z-i.z)*u)}ddt(t){ts3dutils.assertNumbers(t);const s=this.p0,e=this.p1,i=this.p2,r=this.p3,n=6*(1-t),o=6*t;return new ts3dutils.V3((i.x-2*e.x+s.x)*n+(r.x-2*i.x+e.x)*o,(i.y-2*e.y+s.y)*n+(r.y-2*i.y+e.y)*o,(i.z-2*e.z+s.z)*n+(r.z-2*i.z+e.z)*o)}normalP(t){const s=this.tangentAt(t);return s.cross(this.ddt(t)).cross(s)}isTsWithPlane(t){ts3dutils.assertInst(P3$$1,t);const{p0:s,p1:e,p2:i,p3:r}=this,n=t.normal1,o=e.minus(i).times(3).minus(s).plus(r),a=s.plus(i).times(3).minus(e.times(6)),u=e.minus(s).times(3),l=s;return ts3dutils.solveCubicReal2(o.dot(n),a.dot(n),u.dot(n),l.dot(n)-t.w).filter(t=>ts3dutils.between(t,this.tMin,this.tMax))}isTsWithSurface(t){if(t instanceof CylinderSurface$$1){const s=new P3$$1(t.dir.unit(),0),e=this.project(s);return t.baseCurve.project(s).isInfosWithBezier2D(e).map(t=>t.tOther)}return super.isTsWithSurface(t)}likeCurve(t){return this==t||ts3dutils.hasConstructor(t,BezierCurve$$1)&&this.p0.like(t.p0)&&this.p1.like(t.p1)&&this.p2.like(t.p2)&&this.p3.like(t.p3)}equals(t){return this==t||ts3dutils.hasConstructor(t,BezierCurve$$1)&&this.p0.equals(t.p0)&&this.p1.equals(t.p1)&&this.p2.equals(t.p2)&&this.p3.equals(t.p3)}hashCode(){let t=0;return 0|(t=31*(t=31*(t=31*(t=31*t+this.p0.hashCode())+this.p1.hashCode())+this.p2.hashCode())+this.p3.hashCode())}isColinearTo(t){if(this===t||this.likeCurve(t))return!0;if(!(t instanceof BezierCurve$$1))return!1;let s,e,i;if(isNaN(s=this.pointT(t.p0))||isNaN(e=this.pointT(t.p3)))return!1;if(ts3dutils.eq(1,s))i=this.split(e)[1].reversed();else{const t=(e-s)/(1-s);i=this.split(s)[1].split(t)[0]}return t.likeCurve(i)}selectPart(t,s){const e=(s-t)/(1-t);return this.split(t)[1].split(e)[0]}reversed(){return new BezierCurve$$1(this.p3,this.p2,this.p1,this.p0,1-this.tMax,1-this.tMin)}getCoefficients(){const{p0:t,p1:s,p2:e,p3:i}=this;return[s.minus(e).times(3).minus(t).plus(i),t.plus(e).times(3).minus(s.times(6)),s.minus(t).times(3),t]}tangentCoefficients(){const{p0:t,p1:s,p2:e,p3:i}=this,r=s.minus(t),n=e.minus(s),o=i.minus(e),a=r.plus(o).times(3).minus(n.times(6)),u=n.minus(r).times(6),l=r.times(3);return[ts3dutils.V3.O,a,u,l]}pointT2(t,s=this.tMin,e=this.tMax){const i=this.closestTToPoint(t,void 0,s,e);return ts3dutils.assert(this.at(i).like(t)),i}pointT(t){const{p0:s,p1:e,p2:i,p3:r}=this,n=e.minus(i).times(3).minus(s).plus(r),o=s.plus(i).times(3).minus(e.times(6)),a=e.minus(s).times(3),u=s.minus(t),l=ts3dutils.NLA_PRECISIONthis.at(s).like(t));if(0==c.length)return NaN;if(1==c.length)return c[0];throw new Error("multiple intersection "+this.toString()+t.sce)}pointT3(t){const{p0:s,p1:e,p2:i,p3:r}=this,n=e.minus(i).times(3).minus(s).plus(r).els(),o=s.plus(i).times(3).minus(e.times(6)).els(),a=e.minus(s).times(3).els(),u=s.minus(t).els();let l=void 0;for(let t=0;t<3;t++)if(ts3dutils.eq0(n[t])&&ts3dutils.eq0(o[t])&&ts3dutils.eq0(a[t])){if(!ts3dutils.eq0(u[t]))return NaN}else{const s=ts3dutils.solveCubicReal2(n[t],o[t],a[t],u[t]);if(0==s.length)return NaN;if(1==s.length)return s[0];if(l){if(0==(l=l.filter(t=>s.some(s=>ts3dutils.eq(t,s)))).length)return NaN;if(1==l.length)return l[0]}else l=s}throw new Error("multiple intersection "+l+this.toString()+t.sce)}transform(t){return ts3dutils.assert(t.isNoProj(),t.str),new BezierCurve$$1(t.transformPoint(this.p0),t.transformPoint(this.p1),t.transformPoint(this.p2),t.transformPoint(this.p3),this.tMin,this.tMax)}isClosed(){return this.p0.like(this.p3)}isQuadratic(){return this.p0.lerp(this.p1,1.5).like(this.p3.lerp(this.p2,1.5))}debugInfo(){return{lines:[0,1,1,2,2,3].map(t=>this.points[t]),points:this.points}}split(t){const s=1-t,{p0:e,p1:i,p2:r,p3:n}=this,o=e.times(s).plus(i.times(t)),a=i.times(s).plus(r.times(t)),u=r.times(s).plus(n.times(t)),l=o.times(s).plus(a.times(t)),c=a.times(s).plus(u.times(t)),h=l.times(s).plus(c.times(t));return[new BezierCurve$$1(e,o,l,h),new BezierCurve$$1(h,c,u,n)]}containsPoint(t){return isFinite(this.pointT(t))}roots(){const{p0:t,p1:s,p2:e,p3:i}=this,r=s.minus(t),n=e.minus(s),o=i.minus(e),a=r.plus(o).times(3).minus(n.times(6)),u=n.minus(r).times(6),l=r.times(3);return ts3dutils.arrayFromFunction(3,t=>ts3dutils.solveCubicReal2(0,a.e(t),u.e(t),l.e(t)))}isInfosWithLine(t,s,e,i,r=-1e5,n=1e5){const{p0:o,p1:a,p2:u,p3:l}=this,c=a.minus(u).times(3).minus(o).plus(l),h=ts3dutils.V3.UNITS[c.minAbsDim()],d=P3$$1.forAnchorAndPlaneVectors(t,s,h.isParallelTo(s)?c:h);return this.isTsWithPlane(d).map(e=>{const i=this.at(e);return{tThis:e,tOther:L3$$1.pointT(t,s,i),p:i}}).filter(e=>L3$$1.containsPoint(t,s,e.p))}closestPointToLine(t,s,e){s=isFinite(s)?s:this.tMin,e=isFinite(e)?e:this.tMax;const i=t.anchor.dot(t.dir1),r=s=>{const e=this.at(s);return e.minus(t.at(e.dot(t.dir1)-i)).dot(this.tangentAt(s))},n=ts3dutils.arrayFromFunction(32,t=>s+(e-s)*t/32).withMax(t=>-r(t));return ts3dutils.newtonIterate1d(r,n,8)}isInfosWithBezier3(t,s,e,i,r){const n=(s,e)=>{if(!a.some(t=>ts3dutils.eq(t.tThis,s)&&ts3dutils.eq(t.tOther,e))){const i=(s,e)=>this.tangentAt(s).dot(this.at(s).minus(t.at(e))),r=(s,e)=>t.tangentAt(e).dot(this.at(s).minus(t.at(e))),n=(t,s,e,i)=>t.ddt(e).dot(t.at(e).minus(s.at(i)))+t.tangentAt(e).squared(),o=(t,s,e,i)=>-t.tangentAt(e).dot(s.tangentAt(i)),u=ts3dutils.newtonIterate2dWithDerivatives(i,r,s,e,16,n.bind(void 0,this,t),o.bind(void 0,this,t),(s,e)=>-o(t,this,e,s),(s,e)=>-n(t,this,e,s));a.push({tThis:u.x,tOther:u.y,p:this.at(u.x)})}},o=[s=void 0!==s?s:this.tMin,e=void 0!==e?e:this.tMax,i=void 0!==i?i:t.tMin,r=void 0!==r?r:t.tMax],a=[];for(;o.length;){const s=o.length-4,e=o[s],i=o[s+1],r=o[s+2],a=o[s+3];o.length-=4;const u=this.getAABB(e,i),l=t.getAABB(r,a);if(u&&l&&u.intersectsAABB2d(l)){const t=(e+i)/2,s=(r+a)/2,c=1e-5;i-esi{Math.abs(s-e)>2&&n.push(...Curve$$1.ispsRecursive(this,a[s],a[s+1],t,a[e],a[e+1]))})}return n}selfIntersectionsInfo(){return this.isInfosWithBezier(this)}isInfosWithCurve(t){return t instanceof L3$$1?this.isInfosWithLine(t.anchor,t.dir1,t.tMin,t.tMax):t instanceof BezierCurve$$1?this.isInfosWithBezier(t):t.isInfosWithCurve(this).map(({tThis:t,tOther:s,p:e})=>({tThis:s,tOther:t,p:e}))}circleApprox(t=this.tMin,s=this.tMax,e=1/1024,i=[]){const r=this.at(t),n=this.at(s),o=(t+s)/2,a=this.at(o),u=L3$$1.throughPoints(r,n);if(!u.containsPoint(a)&&ts3dutils.between(u.pointT(a),0,u.pointT(n))){const o=EllipseCurve$$1.circleThroughPoints(r,a,n),u=o.f1.length(),l=this.at(ts3dutils.lerp(t,s,.25)),c=this.at(ts3dutils.lerp(t,s,.75));if(abs(o.center.distanceTo(l)/u-1)<=e&&abs(o.center.distanceTo(c)/u-1)<=e)return i.push(o),i}return this.circleApprox(t,o,e,i),this.circleApprox(o,s,e,i),i}}BezierCurve$$1.EX2D=BezierCurve$$1.graphXY(2,-3,-3,2),BezierCurve$$1.EX3D=new BezierCurve$$1(ts3dutils.V3.O,ts3dutils.V(-.1,-1,1),ts3dutils.V(1.1,1,1),ts3dutils.V3.X),BezierCurve$$1.QUARTER_CIRCLE=BezierCurve$$1.approximateUnitArc(PI/2),BezierCurve$$1.prototype.hlol=Curve$$1.hlol++,BezierCurve$$1.prototype.tIncrement=1/80;class HyperbolaCurve$$1 extends XiEtaCurve$$1{constructor(t,s,e,i=-7,r=7){super(t,s,e,i,r)}static XYLCValid(t){return t.x>0&&ts3dutils.eq(1,t.x*t.x-t.y*t.y)}static XYLCPointT(t){return Math.asinh(t.y)}static intersectionUnitLine(t,s,e){if(ts3dutils.eq0(s)){const s=ts3dutils.snap0(Math.pow(e,2)/Math.pow(t,2)-1);if(s<0||e*t<0)return[];if(0==s)return[0];const i=Math.sqrt(s);return[-Math.asinh(i),Math.asinh(i)]}if(ts3dutils.eq(abs(t),abs(s))){if(ts3dutils.le(e*t,0))return[];const i=sign(t*s)*(Math.pow(e,2)-Math.pow(t,2))/2/t/e;return[Math.asinh(i)]}{const i=ts3dutils.snap0(Math.pow(s,2)*(-Math.pow(t,2)+Math.pow(s,2)+Math.pow(e,2)));if(i<0)return[];const r=(t*e-Math.sqrt(i))/(Math.pow(t,2)-Math.pow(s,2)),n=(t*e+Math.sqrt(i))/(Math.pow(t,2)-Math.pow(s,2)),o=(Math.pow(s,2)*e-t*Math.sqrt(i))/(s*(Math.pow(s,2)-Math.pow(t,2))),a=(Math.pow(s,2)*e+t*Math.sqrt(i))/(s*(Math.pow(s,2)-Math.pow(t,2)));return[r>0&&Math.asinh(o),n>0&&Math.asinh(a)].filter(t=>!1!==t)}}at(t){return ts3dutils.assertNumbers(t),this.center.plus(this.f1.times(Math.cosh(t))).plus(this.f2.times(Math.sinh(t)))}toString(){return`${this.center} + ${this.f1} * cosh(t) + ${this.f2} * sinh(t)`}tangentAt(t){return ts3dutils.assertNumbers(t),this.f1.times(Math.sinh(t)).plus(this.f2.times(Math.cosh(t)))}tangentAt2(t,s){return ts3dutils.assertNumbers(t,s),this.f1.times(s).plus(this.f2.times(t))}ddt(t){return ts3dutils.assertNumbers(t),this.f1.times(Math.cosh(t)).plus(this.f2.times(Math.sinh(t)))}isColinearTo(t){if(!ts3dutils.hasConstructor(t,HyperbolaCurve$$1))return!1;if(!t.center||!this.center.like(t.center))return!1;if(this===t)return!0;const{f1:s,f2:e}=this.rightAngled(),{f1:i,f2:r}=t.rightAngled();return ts3dutils.eq(s.squared(),Math.abs(s.dot(i)))&&ts3dutils.eq(e.squared(),Math.abs(e.dot(r)))}reversed(){return new HyperbolaCurve$$1(this.center,this.f1,this.f2.negated(),-this.tMax,-this.tMin)}rightAngled(){const t=this.f1,s=this.f2,e=t.dot(s),i=s.squared()+t.squared();if(ts3dutils.eq0(e))return this;const r=2*e,n=i+Math.sqrt(i*i-4*e*e),{x1:o,y1:a}=intersectionUnitHyperbolaLine$$1(r,n,0);return new HyperbolaCurve$$1(this.center,t.times(o).plus(s.times(a)),t.times(a).plus(s.times(o)))}eccentricity(){const t=this.rightAngled(),s=t.f1.length(),e=t.f1.length(),[i,r]=s>e?[s,e]:[e,s];return Math.sqrt(1+r*r/i/i)}roots(){return ts3dutils.arrayFromFunction(3,t=>{const s=this.f2.e(t),e=this.f1.e(t);return HyperbolaCurve$$1.intersectionUnitLine(s,e,0)})}transform4(t){const s=t=>sign(t)*min(10,sqrt(-(1-cosh(t))/(1+cosh(t)))),e=new ts3dutils.M4(0,1,0,1,2,0,0,0,0,0,1,0,0,-1,0,1);return parabola4Projection$$1(ts3dutils.M4.product(t,this.matrix,e),s(this.tMin),s(this.tMax))}}HyperbolaCurve$$1.XY=new HyperbolaCurve$$1(ts3dutils.V3.O,ts3dutils.V3.X,ts3dutils.V3.Y),HyperbolaCurve$$1.prototype.tIncrement=PI/16;class L3$$1 extends Curve$$1{constructor(t,s,e=-4096,i=4096){super(e,i),this.anchor=t,this.dir1=s,ts3dutils.assertVectors(t,s),ts3dutils.assert(s.hasLength(1),"dir must be unit"+s),ts3dutils.assertf(()=>!Number.isNaN(t.x))}isTsWithSurface(t){return t.isTsForLine(this)}static throughPoints(t,s,e=0,i){const r=s.minus(t);return new L3$$1(t,r.unit(),e,void 0!==i?i:r.length())}static anchorDirection(t,s,e=0,i=s.length()){const r=s.unit();return new L3$$1(t,r,"number"==typeof e?e:e.minus(t).dot(r),"number"==typeof i?i:i.minus(t).dot(r))}static pointT(t,s,e){return ts3dutils.assertVectors(t,s,e),e.minus(t).dot(s)/s.squared()}static at(t,s,e){return t.plus(s.times(e))}static fromPlanes(t,s){if(ts3dutils.assertInst(P3$$1,t,s),t.normal1.cross(s.normal1).length()<1e-10)throw new Error("Parallel planes");return t.intersectionWithPlane(s)}static containsPoint(t,s,e){const i=L3$$1.pointT(t,s,e),r=L3$$1.at(t,s,i).distanceTo(e);return ts3dutils.eq0(r)}roots(){return[[],[],[]]}containsPoint(t){ts3dutils.assertVectors(t);const s=this.distanceToPoint(t);return ts3dutils.assertNumbers(s),ts3dutils.eq0(s)}likeCurve(t){return this==t||ts3dutils.hasConstructor(t,L3$$1)&&this.anchor.like(t.anchor)&&this.dir1.like(t.dir1)}equals(t){return this==t||Object.getPrototypeOf(t)==L3$$1.prototype&&this.anchor.equals(t.anchor)&&this.dir1.equals(t.dir1)}isColinearTo(t){return t instanceof L3$$1&&this.containsPoint(t.anchor)&&ts3dutils.eq(1,Math.abs(this.dir1.dot(t.dir1)))}distanceToLine(t){if(ts3dutils.assertInst(L3$$1,t),this.isParallelToLine(t))return this.distanceToPoint(t.anchor);const s=this.dir1.cross(t.dir1).unit(),e=this.anchor.minus(t.anchor);return Math.abs(e.dot(s))}distanceToPoint(t){ts3dutils.assertVectors(t);const s=t.minus(this.anchor).dot(this.dir1);return this.at(s).distanceTo(t)}asSegmentDistanceToPoint(t,s,e){let i=t.minus(this.anchor).dot(this.dir1);return i=ts3dutils.clamp(i,s,e),this.at(i).minus(t).length()}asSegmentDistanceToLine(t,s,e){ts3dutils.assertInst(L3$$1,t);const i=this.dir1.cross(t.dir1),r=i.squared();if(ts3dutils.eq0(r))return;const n=t.anchor.minus(this.anchor);if(!ts3dutils.eq0(n.dot(i.unit())))return;let o=this.infoClosestToLine(t).t;return o=ts3dutils.clamp(o,s,e),this.at(ts3dutils.clamp(o,s,e))}at(t){return ts3dutils.assertNumbers(t),this.anchor.plus(this.dir1.times(t))}pointT(t){return ts3dutils.assertVectors(t),t.minus(this.anchor).dot(this.dir1)}isParallelToLine(t){return ts3dutils.assertInst(L3$$1,t),ts3dutils.eq(1,Math.abs(this.dir1.dot(t.dir1)))}angleToLine(t){return ts3dutils.assertInst(L3$$1,t),this.dir1.angleTo(t.dir1)}intersectsLine(t){return ts3dutils.eq0(this.distanceToLine(t))}isInfosWithCurve(t){return t instanceof L3$$1?this.isInfosWithLine(t.anchor,t.dir1):super.isInfosWithCurve(t)}isInfosWithLine(t,s){const e=this.dir1.cross(s),i=e.squared();if(ts3dutils.eq0(i))return[];const r=t.minus(this.anchor);if(ts3dutils.eq0(r.dot(e))){const t=r.cross(s).dot(e)/i;return[{tThis:t,tOther:r.cross(this.dir1).dot(e)/i,p:this.at(t)}]}return[]}isInfoWithLine(t){ts3dutils.assertInst(L3$$1,t);const s=this.dir1.cross(t.dir1),e=s.squared();if(ts3dutils.eq0(e))return;const i=t.anchor.minus(this.anchor);if(!ts3dutils.eq0(i.dot(s.unit())))return;const r=i.cross(t.dir1).dot(s)/e;return this.at(r)}intersectionLineST(t){ts3dutils.assertInst(L3$$1,t);const s=this.dir1.cross(t.dir1),e=s.squared(),i=t.anchor.minus(this.anchor);return{s:i.cross(this.dir1).dot(s)/e,t:i.cross(t.dir1).dot(s)/e}}ddt(){return ts3dutils.V3.O}getConstructorParameters(){return[this.anchor,this.dir1]}closestTToPoint(t){return t.minus(this.anchor).dot(this.dir1)}infoClosestToLine(t){if(this.isParallelToLine(t))return{t:NaN,s:NaN,distance:this.distanceToLine(t)};const s=t.anchor,e=t.dir1,i=this.anchor,r=this.dir1,n=e.dot(r),o=e.squared(),a=r.squared(),u=s.minus(i),l=n*n-a*o,c=(u.dot(e)*n-u.dot(r)*o)/l,h=(u.dot(e)*a-u.dot(r)*n)/l;return{t:c,s:h,closest:this.at(c),closest2:t.at(h),distance:this.at(c).distanceTo(t.at(h))}}intersectionWithPlane(t){const s=(t.w-t.normal1.dot(this.anchor))/t.normal1.dot(this.dir1);return this.anchor.plus(this.dir1.times(s))}tangentAt(){return this.dir1}isTWithPlane(t){const s=t.normal1.dot(this.dir1);return ts3dutils.eq0(s)?NaN:(t.w-t.normal1.dot(this.anchor))/s}reversed(){return new L3$$1(this.anchor,this.dir1.negated(),-this.tMax,-this.tMin)}isTsWithPlane(t){const s=this.isTWithPlane(t);return isNaN(s)?[]:[s]}flipped(){return new L3$$1(this.anchor,this.dir1.negated())}transform(t){const s=t.transformPoint(this.anchor),e=t.transformVector(this.dir1);return new L3$$1(s,e.unit(),this.tMin*e.length(),this.tMax*e.length())}transform4(t){const s=P3$$1.vanishingPlane(t);if(!s)return this.transform(t);const e=this.at(this.tMin),i=this.at(this.tMax);if(ts3dutils.le(s.distanceToPointSigned(e),0)||ts3dutils.le(s.distanceToPointSigned(i),0))throw new Error("line must be in front of vanishingPlane in [tMin, tMax]");const r=ts3dutils.lt(0,s.distanceToPointSigned(this.anchor))?this.anchor:this.at((this.tMin+this.tMax)/2),n=t.timesVector(ts3dutils.VV(r.x,r.y,r.z,1)),o=t.timesVector(ts3dutils.VV(this.dir1.x,this.dir1.y,this.dir1.z,0)),a=o.times(n.w).minus(n.times(o.w)).V3(),u=n.p3();return L3$$1.anchorDirection(u,a,t.transformPoint(e),t.transformPoint(i))}hashCode(){return 31*this.anchor.hashCode()+this.dir1.hashCode()}}L3$$1.X=new L3$$1(ts3dutils.V3.O,ts3dutils.V3.X),L3$$1.Y=new L3$$1(ts3dutils.V3.O,ts3dutils.V3.Y),L3$$1.Z=new L3$$1(ts3dutils.V3.O,ts3dutils.V3.Z),L3$$1.prototype.hlol=Curve$$1.hlol++,L3$$1.prototype.tIncrement=256;class PICurve$$1 extends ImplicitCurve$$1{constructor(t,s,e,i,r,n,o,a=1,u,l,c){super(t,s,a,u,l,c),this.parametricSurface=e,this.implicitSurface=i,this.pmPoints=r,this.pmTangents=n,this.stepSize=o,ts3dutils.assert(Array.isArray(r)),ts3dutils.assert(1==a),ts3dutils.assert(o<=1);const h=e.pUVFunc(),d=e.dpdu(),p=e.dpdv(),f=i.didp.bind(i);this.didu=((t,s)=>f(h(t,s)).dot(d(t,s))),this.didv=((t,s)=>f(h(t,s)).dot(p(t,s)));for(let s=0;sr(e(t,s)),(t,s)=>u(e(t,s)).dot(n(t,s)),(t,s)=>u(e(t,s)).dot(a(t,s))),{points:c}=followAlgorithm2d$$1(l,this.pmPoints[0],o,t,(t,i)=>s.containsPoint(e(t,i)),this.pmPoints.last,this.pmTangents[0]);c.length!==this.points.length&&followAlgorithm2d$$1(l,this.pmPoints[0],o,t,(t,i)=>s.containsPoint(e(t,i)),this.pmPoints.last,this.pmTangents[0]),ts3dutils.assert(c.length==this.points.length,c.length,this.points.length)}}static forParametricStartEnd(t,s,e,i,r=.02,n,o,a){const u=t.pUVFunc(),l=s.implicitFunction(),c=t.dpdu(),h=t.dpdv(),d=s.didp.bind(s),p=exports.MathFunctionR2R.forFFxFy((t,s)=>l(u(t,s)),(t,s)=>d(u(t,s)).dot(c(t,s)),(t,s)=>d(u(t,s)).dot(h(t,s))),{points:f,tangents:m}=followAlgorithm2d$$1(p,e,r,t,(t,e)=>s.containsPoint(u(t,e)),i,n);return PICurve$$1.forParametricPointsTangents(t,s,f,m,r,1,o,a)}static forStartEnd(t,s,e,i,r=.02,n,o,a){const u=t.uvP(e),l=t.dpdu()(u.x,u.y),c=t.dpdv()(u.x,u.y),h=n&&ts3dutils.M4.forSys(l,c).inversed().transformVector(n),d=PICurve$$1.forParametricStartEnd(t,s,u,t.uvP(i),r,h);return d.withBounds(o&&d.pointT(o),a&&d.pointT(a))}static forParametricPointsTangents(t,s,e,i,r,n=1,o,a){const u=t.pUVFunc(),l=t.dpdu(),c=t.dpdv(),h=e.map(({x:t,y:s})=>u(t,s)),d=e.map(({x:t,y:s},e)=>{const r=l(t,s),n=c(t,s);return r.times(i[e].x).plus(n.times(i[e].y))});return new PICurve$$1(h,d,t,s,e,i,r,n,void 0,o,a)}getConstructorParameters(){return[this.points,this.tangents,this.parametricSurface,this.implicitSurface,this.pmPoints,this.pmTangents,this.stepSize,this.dir,this.generator]}implicitCurve(){const t=this.parametricSurface.pUVFunc(),s=this.implicitSurface.implicitFunction();return(e,i)=>s(t(e,i))}isColinearTo(t){return t instanceof PICurve$$1&&(!!this.equals(t)||(this.parametricSurface.isCoplanarTo(t.parametricSurface)&&this.implicitSurface.isCoplanarTo(t.implicitSurface),!1))}containsPoint(t){ts3dutils.assertVectors(t);const s=this.pointT(t);return!isNaN(s)&&this.isValidT(s)}equals(t){return Object.getPrototypeOf(t)==PICurve$$1.prototype&&this.parametricSurface.equals(t.parametricSurface)&&this.implicitSurface.equals(t.implicitSurface)&&this.points[0].equals(t.points[0])&&this.tangents[0].equals(t.tangents[0])&&this.dir===t.dir}hashCode(){let t=0;return 0|(t=31*(t=31*(t=31*(t=31*t+this.parametricSurface.hashCode())+this.implicitSurface.hashCode())+this.points[0].hashCode())+this.tangents[0].hashCode())}tangentP(t){ts3dutils.assertVectors(t),ts3dutils.assert(this.containsPoint(t),"this.containsPoint(point)");const s=this.pointT(t);return this.tangentAt(s)}tangentAt(t){if(ts3dutils.assert(!isNaN(t)),0==t%1)return this.tangents[t];const s=this.uvT(t),e=new ts3dutils.V3(-this.didv(s.x,s.y),this.didu(s.x,s.y),0).toLength(this.stepSize),i=this.parametricSurface.dpdu()(s.x,s.y),r=this.parametricSurface.dpdv()(s.x,s.y);return i.times(e.x).plus(r.times(e.y))}at(t){if(ts3dutils.assert(!isNaN(t)),0==t%1)return this.points[t];const s=ts3dutils.V3.lerp(this.pmPoints[floor(t)],this.pmPoints[ceil(t)],t%1);return this.closestPointToParams(s)}uvT(t){if(ts3dutils.assert(!isNaN(t)),0==t%1)return this.pmPoints[t];const s=ts3dutils.V3.lerp(this.pmPoints[floor(t)],this.pmPoints[ceil(t)],t%1);return curvePoint$$1(this.implicitCurve(),s,this.didu,this.didv)}closestTToPoint(t,s){return 0}closestPointToParams(t){const s=curvePoint$$1(this.implicitCurve(),t,this.didu,this.didv);return this.parametricSurface.pUVFunc()(s.x,s.y)}isTsWithSurface(t){if(t instanceof EllipsoidSurface$$1){const s=this.parametricSurface,e=this.implicitSurface;if(s instanceof ProjectedCurveSurface$$1&&e instanceof EllipsoidSurface$$1){const i=e.isCurvesWithSurface(t).flatMap(t=>t.isTsWithSurface(s).map(s=>t.at(s)));return ts3dutils.fuzzyUniques(i.map(t=>this.pointT(t))).filter(t=>!isNaN(t)&&this.isValidT(t))}}else if(ImplicitSurface$$1.is(t)){const s=[],e=t.implicitFunction();let i=e(this.points[0]);for(let r=1;re(n(t,s)),l.x,l.y,4,this.didu,this.didv,(s,e)=>a(s,e).dot(t.didp(n(s,e))),(s,e)=>u(s,e).dot(t.didp(n(s,e))));s.push(this.pointT(this.parametricSurface.pUV(c.x,c.y)))}i=o}return s}throw new Error}isTsWithPlane(t){return this.isTsWithSurface(new PlaneSurface$$1(t))}pointT(t){if(ts3dutils.assertVectors(t),!this.parametricSurface.containsPoint(t)||!this.implicitSurface.containsPoint(t))return NaN;const s=this.parametricSurface.uvPFunc()(t),e=this.points,i=this.pmPoints;let r=0,n=s.distanceTo(i[0]);for(;n>abs(this.stepSize)&&r1.1*abs(this.stepSize))return NaN;if(r==e.length-1&&r--,e[r].like(t))return r;if(e[r+1].like(t))return r+1;const o=ts3dutils.arrayRange(floor(this.tMin),ceil(this.tMax),1).withMax(t=>-s.distanceTo(i[t]));if(void 0===o)throw new Error;if(e[o].like(t))return o;const a=max(0,o-1),u=min(this.points.length-1,o+1),l=this.tangentAt(o);return r=ts3dutils.bisect(s=>this.at(ts3dutils.clamp(s,0,this.points.length-1)).to(t).dot(l),a,u,32),!isFinite(r)||this.at(r).distanceTo(t)>abs(this.stepSize)?NaN:r}transform(t){const s=t.isMirroring()?-1:1;return PICurve$$1.forStartEnd(this.parametricSurface.transform(t),this.implicitSurface.transform(t),t.transformPoint(this.points[0]),t.transformPoint(this.points.last),this.stepSize*s,t.transformVector(this.tangents[0]),t.transformPoint(this.at(this.tMin)),t.transformPoint(this.at(this.tMax)))}roots(){const t=ts3dutils.arrayRange(0,this.points.length);return[t,t,t]}isInfosWithLine(t,s,e,i,r,n){return surfaceIsICurveIsInfosWithLine$$1.call(this,t,s,e,i,r,n)}toSource(t=(t=>t)){return ts3dutils.callsce("PICurve.forParametricStartEnd",this.parametricSurface,this.implicitSurface,this.pmPoints[0],this.pmPoints.last,this.stepSize,this.pmTangents[0],this.tMin,this.tMax)}}PICurve$$1.prototype.tIncrement=1;class PPCurve$$1 extends ImplicitCurve$$1{constructor(t,s,e,i,r,n,o,a=1,u,l,c){super(t,s,a,u,l,c),this.parametricSurface1=e,this.parametricSurface2=i,this.st1s=r,this.pmTangents=n,this.stepSize=o,ts3dutils.assert(ParametricSurface$$1.is(e)),ts3dutils.assert(ParametricSurface$$1.is(i)),ts3dutils.assert(Array.isArray(r)),ts3dutils.assert(1==a),ts3dutils.assert(o<=1)}at(t){if(ts3dutils.assert(!isNaN(t)),0==t%1)return this.points[t];const s=ts3dutils.V3.lerp(this.points[floor(t)],this.points[ceil(t)],t%1);return curvePointPP$$1(this.parametricSurface1,this.parametricSurface2,s).p}isColinearTo(t){return t instanceof PPCurve$$1&&(!!this.equals(t)||(this.parametricSurface1.isCoplanarTo(t.parametricSurface1)&&this.parametricSurface1.isCoplanarTo(t.parametricSurface2),!1))}containsPoint(t){return ts3dutils.assertVectors(t),this.parametricSurface1.containsPoint(t)&&this.parametricSurface2.containsPoint(t)&&!isNaN(this.pointT(t))}rootPoints(){const t=this.parametricSurface1.pUVFunc(),s=this.parametricSurface2.pUVFunc(),e=this.parametricSurface1.normalUVFunc(),i=this.parametricSurface2.normalUVFunc(),r=this.rootsApprox(),n=[[],[],[]];for(let a=0;a<3;a++)for(let u=0;ut.map(t=>this.pointT(t)))}pointTangent(t){ts3dutils.assertVectors(t),ts3dutils.assert(this.containsPoint(t),"this.containsPoint(pWC)");const s=this.parametricSurface1.normalP(t),e=this.parametricSurface2.normalP(t);return s.cross(e)}transform(t){return new PPCurve$$1(t.transformedPoints(this.points),t.transformedVectors(this.tangents),this.parametricSurface1.transform(t),this.parametricSurface2.transform(t),this.st1s,void 0,this.stepSize,this.dir,void 0)}toSource(){return ts3dutils.callsce("PPCurve.forStartEnd",this.parametricSurface1,this.parametricSurface2,this.points[0],this.points.last,this.stepSize)}static forStartEnd(t,s,e,i,r=.02){const{points:n,tangents:o,st1s:a}=followAlgorithmPP$$1(t,s,e,r);return new PPCurve$$1(n,o,t,s,a,void 0,r,1)}isInfosWithLine(t,s,e,i,r,n){return surfaceIsICurveIsInfosWithLine$$1.call(this,t,s,e,i,r,n)}isTsWithSurface(t){if(ImplicitSurface$$1.is(t)){const s=[],e=t.implicitFunction(),i=this.parametricSurface1.pUVFunc(),r=this.parametricSurface2.pUVFunc();let n=e(this.points[0]);for(let t=1;t{const a=i(t,s),u=r(n,o);return[...a.to(u),e(a)]},[l.x,l.y,c.x,c.y]);s.push(this.pointT(this.parametricSurface1.pUV(h[0],h[1])))}n=a}return s}throw new Error("Method not implemented.")}isTsWithPlane(t){return this.isTsWithSurface(new PlaneSurface$$1(t))}}class ParabolaCurve$$1 extends XiEtaCurve$$1{constructor(t,s,e,i=-10,r=10){super(t,s,e,i,r)}static eccentricity(){return 1}static unitIsInfosWithLine(t,s,e,i){const r=Math.pow(s.x,2);return ts3dutils.pqFormula((t.x*s.x+s.y)/r,(Math.pow(t.x,2)+t.y)/r).filter(e=>ts3dutils.le(0,t.y+e*s.y)).map(r=>({tThis:s.x*r+t.x,tOther:r,p:L3$$1.at(e,i,r)}))}static intersectionUnitLine(t,s,e){return ts3dutils.pqFormula(t/s,-e/s)}static XYLCValid(t){return ts3dutils.eq(Math.pow(t.x,2),t.y)}static XYLCPointT(t){return t.x}static quadratic(t,s,e){const i=t.plus(e).minus(s.times(2)),r=s.minus(t).times(2);return new ParabolaCurve$$1(t,r,i,0,1)}at(t){return this.center.plus(this.f1.times(t)).plus(this.f2.times(t*t))}tangentAt(t){return ts3dutils.assertNumbers(t),this.f1.plus(this.f2.times(2*t))}ddt(t){return ts3dutils.assertNumbers(t),this.f2.times(2)}tangentAt2(t,s){return ts3dutils.assertNumbers(t,s),this.f1.plus(this.f2.times(2*s))}reversed(){return new this.constructor(this.center,this.f1.negated(),this.f2,-this.tMax,-this.tMin)}roots(){return ts3dutils.arrayFromFunction(3,t=>ts3dutils.eq0(this.f2.e(t))?[]:[-this.f1.e(t)/2/this.f2.e(t)])}isColinearTo(t){if(!ts3dutils.hasConstructor(t,ParabolaCurve$$1))return!1;const s=this.rightAngled(),e=t.rightAngled();return s.center.like(e.center)&&s.f2.like(e.f2)&&s.f1.likeOrReversed(e.f1)}rightAngled(){const t=this.f1,s=this.f2,e=t.dot(s);if(ts3dutils.eq0(e)&&t.hasLength(1))return this;const i=-e/s.squared()/2,r=this.at(i),n=this.tangentAt(i),o=n.length(),a=n.unit(),u=t=>this.at(t).minus(r).dot(a);return new ParabolaCurve$$1(r,a,s.div(Math.pow(o,2)),u(this.tMin),u(this.tMax))}arcLength(t,s){let e=this.f1;const i=this.f2,r=e.dot(i);let n=0;ts3dutils.eq0(r)||(n=-r/i.squared()/2,e=e.plus(i.times(2*n)));const o=e.length(),a=i.length()/o;function u(t){return Math.asinh(2*a*t)/4/a+t*Math.sqrt(1+a*a*4*t*t)/2}return o*(u(s-n)-u(t-n))}transform4(t){return parabola4Projection$$1(this.matrix.transform(t),this.tMin,this.tMax)}asBezier(){return BezierCurve$$1.quadratic(this.at(-1),new L3$$1(this.at(-1),this.tangentAt(-1).unit()).isInfoWithLine(new L3$$1(this.at(1),this.tangentAt(1).unit())),this.at(1))}recenter(t){return new ParabolaCurve$$1(this.at(t),this.f1.plus(this.f2.times(2*t)),this.f2)}}ParabolaCurve$$1.XY=new ParabolaCurve$$1(ts3dutils.V3.O,ts3dutils.V3.X,ts3dutils.V3.Y),ParabolaCurve$$1.YZ=new ParabolaCurve$$1(ts3dutils.V3.O,ts3dutils.V3.Y,ts3dutils.V3.Z),ParabolaCurve$$1.ZX=new ParabolaCurve$$1(ts3dutils.V3.O,ts3dutils.V3.Z,ts3dutils.V3.X),ParabolaCurve$$1.prototype.tIncrement=1/32;class EllipseCurve$$1 extends XiEtaCurve$$1{constructor(t,s,e,i=0,r=PI){super(t,s,e,i,r),ts3dutils.assert(-PI<=this.tMin&&this.tMints3dutils.lerp(e,s+ts3dutils.TAU,.5)?i-ts3dutils.TAU:i}static intersectionUnitLine(t,s,e,i,r){const n=intersectionUnitCircleLine2$$1(t,s,e),o=[];for(const[t,s]of n){const e=EllipseCurve$$1.XYLCPointT(new ts3dutils.V3(t,s,0),i,r);ts3dutils.fuzzyBetween(e,i,r)&&o.push(e)}return o}static unitIsInfosWithLine(t,s,e,i,r,n){const o=s.squared();return ts3dutils.pqFormula(2*s.dot(t)/o,(t.squared()-1)/o).filter(e=>ts3dutils.le(0,t.y+e*s.y)).map(o=>({tThis:EllipseCurve$$1.XYLCPointT(s.times(o).plus(t),r,n),tOther:o,p:L3$$1.at(e,i,o)}))}static semicircle(t,s=ts3dutils.V3.O,e,i){return new EllipseCurve$$1(s,new ts3dutils.V3(t,0,0),new ts3dutils.V3(0,t,0),e,i)}static circleForCenter2P(t,s,e,i,r,n){const o=t.to(s),a=o.cross(t.to(e)).cross(o).toLength(o.length());return new EllipseCurve$$1(t,o,a,void 0!==r?r:0,void 0!==n?n:o.angleTo(t.to(e)))}split(t=this.tMin,s=this.tMax){const e=[];return t<0&&e.push(new EllipseCurve$$1(this.center,this.f1.negated(),this.f2.negated(),t+PI,min(0,s)+PI)),s>0&&e.push(new EllipseCurve$$1(this.center,this.f1,this.f2,max(0,t),s)),e}static forAB(t,s,e=ts3dutils.V3.O){return super.forAB(t,s,e)}static circleThroughPoints(t,s,e,i=0,r){ts3dutils.assertf(()=>!L3$$1.throughPoints(t,e).containsPoint(s));const n=t.to(s).cross(s.to(e)),o=new L3$$1(t.lerp(s,.5),n.cross(t.to(s)).unit()).isInfoWithLine(new L3$$1(s.lerp(e,.5),n.cross(s.to(e)).unit())),a=o.to(t).negated();return new EllipseCurve$$1(o,a,n.unit().cross(a),-PI,void 0===r?a.angleRelativeNormal(o.to(e),n.unit()):r)}getAreaInDir(t,s,e,i){ts3dutils.assertf(()=>t.isPerpendicularTo(this.normal)),ts3dutils.assertf(()=>s.isPerpendicularTo(this.normal));const r=this.matrixInverse.transformVector(s),n=r.cross(ts3dutils.V3.Z),o=e-n.angleXY(),a=i-n.angleXY(),u=this.matrixInverse.getTranslation().dot(r.unit());function l(t){return(t-Math.sin(t)*Math.cos(t))/2}function c(t){return Math.pow(Math.sin(t),3)/3}function h(t){return(Math.cos(3*t)-9*Math.cos(t))/24}const d=-u*(-Math.cos(a)+Math.cos(o)),p=l(a)-l(o)+d,f=(c(a)-c(o)+-u*(-Math.cos(a)-Math.cos(o))/2*d)/p,m=(h(a)-h(o)- -u/2*d)/p,$=this.matrix.xyAreaFactor();return ts3dutils.assert(!ts3dutils.eq0($)),{area:p*$,centroid:this.matrix.transformPoint(ts3dutils.M4.rotateZ(n.angleXY()).transformPoint(new ts3dutils.V3(f,m,0)))}}at(t){return ts3dutils.assertNumbers(t),this.center.plus(this.f1.times(Math.cos(t))).plus(this.f2.times(Math.sin(t)))}tangentAt(t){return ts3dutils.assertNumbers(t),this.f2.times(Math.cos(t)).minus(this.f1.times(Math.sin(t)))}ddt(t){return ts3dutils.assertNumbers(t),ts3dutils.assert(this.isValidT(t)),this.f2.times(-Math.sin(t)).minus(this.f1.times(Math.cos(t)))}tangentAt2(t,s){return this.f2.times(t).minus(this.f1.times(s))}isCircular(){return ts3dutils.eq(this.f1.length(),this.f2.length())&&this.f1.isPerpendicularTo(this.f2)}isColinearTo(t){if(!ts3dutils.hasConstructor(t,EllipseCurve$$1))return!1;if(!this.center.like(t.center))return!1;if(this==t)return!0;if(this.isCircular())return t.isCircular()&&ts3dutils.eq(this.f1.length(),t.f1.length())&&this.normal.isParallelTo(t.normal);{let{f1:s,f2:e}=this.rightAngled(),{f1:i,f2:r}=t.rightAngled();return s.length()>e.length()&&([s,e]=[e,s]),i.length()>r.length()&&([i,r]=[r,i]),ts3dutils.eq(s.squared(),Math.abs(s.dot(i)))&&ts3dutils.eq(e.squared(),Math.abs(e.dot(r)))}}pointT(t){ts3dutils.assertVectors(t),ts3dutils.assert(this.containsPoint(t));const s=this.matrixInverse.transformPoint(t),e=EllipseCurve$$1.XYLCPointT(s,this.tMin,this.tMax);return ts3dutils.assert(this.isValidT(e)),e}reversed(){return new EllipseCurve$$1(this.center,this.f1.negated(),this.f2,PI-this.tMax,PI-this.tMin)}eccentricity(){const t=this.rightAngled(),s=t.f1.length(),e=t.f1.length(),[i,r]=s>e?[s,e]:[e,s];return Math.sqrt(1-r*r/i/i)}circumference(){return this.arcLength(-Math.PI,Math.PI)}arcLength(t=this.tMin,s=this.tMax,e=2){ts3dutils.assert(ts.at(t).lengthXY()-1,u=t=>s.at(t).xy().dot(s.tangentAt(t))/s.at(t).lengthXY();ts3dutils.checkDerivate(a,u,-PI,PI,1);const l=[];for(let t=-.8*PI;tts3dutils.eq(s,t))&&l.push(s)}const c=[];for(const e of l){const i=this.matrix.transformPoint(s.at(e));this.containsPoint(i)&&t.containsPoint(i)&&c.push({tThis:this.pointT(i),tOther:t.pointT(i),p:i})}return c}return this.isTsWithPlane(P3$$1.normalOnAnchor(t.normal.unit(),t.center)).mapFilter(s=>{const e=this.at(s);if(t.containsPoint(e))return{tThis:s,tOther:t.pointT(e),p:e}})}isInfosWithCurve(t){return t instanceof EllipseCurve$$1?this.isInfosWithEllipse(t):super.isInfosWithCurve(t)}transform4(t){const s=t=>sign(t)*sqrt((1-cos(t))/(1+cos(t))),e=new ts3dutils.M4(0,-1,0,1,2,0,0,0,0,0,1,0,0,1,0,1);return parabola4Projection$$1(ts3dutils.M4.product(t,this.matrix,e),s(this.tMin),s(this.tMax))}roots(){return ts3dutils.arrayFromFunction(3,t=>{return intersectionUnitCircleLine2$$1(this.f2.e(t),-this.f1.e(t),0).map(([t,s])=>Math.atan2(s,t)).filter(t=>this.isValidT(t))})}closestTToPoint(t,s){s=s||this.matrixInverse.transformPoint(t).angleXY();const e=t.minus(this.center);return ts3dutils.newtonIterate1d(t=>this.tangentAt(t).dot(this.f1.times(Math.cos(t)).plus(this.f2.times(Math.sin(t))).minus(e)),s,8)}area(){return Math.PI*this.f1.cross(this.f2).length()}angleToT(t){const s=this.f1.unit().times(Math.cos(t)).plus(this.f2.rejectedFrom(this.f1).unit().times(Math.sin(t)));return this.matrixInverse.transformVector(s).angleXY()}}EllipseCurve$$1.UNIT=new EllipseCurve$$1(ts3dutils.V3.O,ts3dutils.V3.X,ts3dutils.V3.Y),EllipseCurve$$1.prototype.hlol=Curve$$1.hlol++,EllipseCurve$$1.prototype.tIncrement=2*Math.PI/128;class NURBS$$1 extends Curve$$1{constructor(t,s,e=NURBS$$1.openUniformKnots(t.length,s),i=e[s],r=e[e.length-s-1]){super(i,r),this.points=t,this.degree=s,this.knots=e;const n=t.length+s+1;ts3dutils.assert(e.length===n,"bad knot vector length: expected "+n+" (degree = "+s+" pcount = "+t.length+"), but was "+e.length),ts3dutils.assert(e[s]<=i),ts3dutils.assert(r<=e[e.length-s-1]);for(let s=0;s=1,"degree must be at least 1 (linear)"),ts3dutils.assert(s%1==0);for(let t=0;ts;o--){const a=(t-i[o+r-e])/(i[o+r-s]-i[o+r-e]);for(let t=0;t<4;t++)n[4*o+t]=(1-a)*n[4*(o-1)+t]+a*n[4*o+t]}return new ts3dutils.Vector(n.slice(4*e,4*(e+1)))}at(t){return this.at4(t).p3()}ptDtDdt4(t){const{points:s,degree:e,knots:i}=this,r=this.tInterval(t),n=ts3dutils.Vector.pack(s,new Float64Array(4*(e+1)),r-e,0,e+1);let o,a=ts3dutils.Vector.Zero(4);for(let s=0;ss;o--){const a=(t-i[o+r-e])/(i[o+r-s]-i[o+r-e]);for(let t=0;t<4;t++)n[4*o+t]=(1-a)*n[4*(o-1)+t]+a*n[4*o+t]}}return[new ts3dutils.Vector(n.slice(4*e,4*e+4)),o,a]}tangentAt(t){const[s,e]=this.ptDtDdt4(t);return e.times(s.w).minus(s.times(e.w)).div(Math.pow(s.w,2)).V3()}ddt(t){const[s,e,i]=this.ptDtDdt4(t);return ts3dutils.Vector.add(s.times(-s.w*i.w+2*Math.pow(e.w,2)),e.times(-2*s.w*e.w),i.times(Math.pow(s.w,2))).div(Math.pow(s.w,3)).V3()}ptDtDdt(t){const[s,e,i]=this.ptDtDdt4(t);return[s.p3(),e.times(s.w).minus(s.times(e.w)).div(Math.pow(s.w,2)).V3(),ts3dutils.Vector.add(s.times(-s.w*i.w+2*Math.pow(e.w,2)),e.times(-2*s.w*e.w),i.times(Math.pow(s.w,2))).div(Math.pow(s.w,3)).V3()]}pointT(t){return this.closestTToPoint(t)}closestTToPoint(t,s,e=this.tMin,i=this.tMax){return void 0===s&&(s=ts3dutils.arraySamples(e,i,32).withMax(s=>-this.at(s).distanceTo(t))),ts3dutils.newtonIterateWithDerivative2(s=>{const[e,i,r]=this.ptDtDdt(s);return[e.minus(t).dot(i),i.squared()+e.minus(t).dot(r)]},s,8,this.tMin,this.tMax)}containsPoint(t){const s=this.closestTToPoint(t);return void 0!==s&&this.at(s).like(t)}derivate(){const t=this.degree,s=ts3dutils.arrayFromFunction(this.points.length-1,s=>this.points[s].to(this.points[s+1]).times(t/(this.knots[s+t+1]-this.knots[s+1])));return new NURBS$$1(s,this.degree-1,this.knots.slice(1,-1),this.tMin,this.tMax)}withKnot(t,s=1){ts3dutils.assert(ts3dutils.between(t,this.tMin,this.tMax));const e=this.tInterval(t),{knots:i,points:r,degree:n}=this,o=ts3dutils.arrayFromFunction(this.degree,s=>{const o=e-n+1+s,a=t-i[o],u=0==a?0:a/(i[o+n]-i[o]);return ts3dutils.assert(ts3dutils.between(u,0,1)),ts3dutils.Vector.lerp(r[o-1],r[o],u)}),a=r.slice();a.splice(e-n+1,n-1,...o);const u=i.slice();return u.splice(e+1,0,t),new NURBS$$1(a,n,u,this.tMin,this.tMax)}removeKnot(t){const{knots:s,points:e,degree:i}=this;let r=this.tInterval(t),n=0;for(;s[r+1]==t;)r++,n++;if(0==n)throw new Error("There is no knot "+t+"!");const o=[e[r-i-1]],a=s.slice();a.splice(r,1);for(let s=r-i;s<=r-n;s++){const r=(a[s+i]-a[s])/(t-a[s]),n=ts3dutils.Vector.lerp(o.last,e[s],r);o.push(n)}if(o.last.like(e[r+1-n])){const t=e.slice();return t.splice(r-i-1,i-n+3,...o),new NURBS$$1(t,i,a)}}static openUniformKnots(t,s,e=0,i=1){const r=t+s+1;return ts3dutils.arrayFromFunction(r,t=>t<=s?e:t>=r-s-1?i:ts3dutils.lerp(e,i,(t-s)/(r-2*s-1)))}static bezierKnots(t,s=0,e=1){const i=new Array(2*(t+1));for(let r=0;rt instanceof ts3dutils.V3?new ts3dutils.Vector(new Float64Array([t.x,t.y,t.z,1])):t),t.length-1,ts3dutils.arrayFromFunction(2*t.length,s=>s1)){return ts3dutils.assert(t.length==i.length),new NURBS$$1(t.map((t,s)=>ts3dutils.Vector.fromV3AndWeight(t,i[s])),s,e)}isUniform(t=0){const s=ts3dutils.arrayFromFunction(this.knots.length-1,t=>this.knots[t+1]-this.knots[t]),[e,i]=minAndMax(s);return ts3dutils.eq(e,i,t)}isBSpline(t=0){const[s,e]=minAndMax(this.points.map(t=>t.w));return ts3dutils.eq(s,e,t)}isBezier(t=0){if(this.degree+1!=this.points.length)return!1;const[s,e]=minAndMax(this.knots,0,this.degree+1);if(!ts3dutils.eq(s,e,t))return!1;const[i,r]=minAndMax(this.knots,this.degree+1);return!!ts3dutils.eq(i,r,t)}getSegments(){const{knots:t,points:s,degree:e}=this,i=[],r=ts3dutils.Vector.pack(s,new Float64Array(4*s.length)),n=t=>new ts3dutils.Vector(r.slice(4*t,4*(t+1)));let o=e+1;for(;oin(s.length-e-1+t)),u=ts3dutils.arrayFromFunction(2*(e+1),s=>snew ts3dutils.Vector(l.slice(4*t,4*(t+1))),a=new Array(r+1-n);for(let t=0;tts3dutils.vArrGet(l,4,t));return[new NURBS$$1(a,i,c),new NURBS$$1(d,i,h)]}simplify(){if(ts3dutils.assert(this.isBezier()),3==this.degree&&this.isBSpline())return new BezierCurve$$1(this.points[0].p3(),this.points[1].p3(),this.points[2].p3(),this.points[3].p3(),this.tMin,this.tMax);if(2==this.degree){const[t,s,e]=this.points,[i,r,n]=this.points.map(t=>t.p3()),o=NURBS$$1.simplifyUnit2(t.w,s.w,e.w).transform(ts3dutils.M4.forSys(r.to(i),r.to(n),void 0,r)),[a,u]=[o.pointT(i),o.pointT(n)].sort();return o.withBounds(ts3dutils.snap(a,o.tMin),ts3dutils.snap(u,o.tMax))}return 1==this.degree?L3$$1.throughPoints(this.points[0].p3(),this.points[1].p3()):this}static simplifyUnit2(t,s,e){const i=t*e-Math.pow(s,2),r=t*e/2/i,n=new ts3dutils.V3(r,r,0),o=(Math.pow(s,2)+i-2*s*sqrt(abs(i)))/2/i,a=ts3dutils.V3.X,u=new ts3dutils.V3(o,r,0);return ts3dutils.eq0(i)?new ParabolaCurve$$1(new ts3dutils.V3(.25,.25,0),new ts3dutils.V3(1,-1,0),new ts3dutils.V3(1,1,0),-.5,.5):i<0?new HyperbolaCurve$$1(n,n.to(a),n.to(u)):new EllipseCurve$$1(n,n.to(a),n.to(u),0)}elevateDegreeBezier(){ts3dutils.assert(this.isBezier());const t=new Array(this.points.length+1);t[0]=this.points[0],t[this.points.length]=this.points[this.points.length-1];for(let s=1;st.elevateDegreeBezier()),s=new Array(2+t.length*this.degree);s[0]=t[0].points[0],s.last=t.last.points.last;for(let e=0;et.timesVector(s)),this.degree,this.knots,this.tMin,this.tMax)}tInterval(t){const{degree:s,knots:e}=this;for(let i=s;i=e[i]&&t<=e[i+1])return i;throw new Error(t+" "+e)}static UnitCircle(t=2,s=0,e=PI){const i=(e-s)/t,r=sin(PI/2-i/2);console.log(i/2/ts3dutils.DEG);const n=1/cos(i/2),o=ts3dutils.arrayFromFunction(2*t+1,i=>{const o=ts3dutils.lerp(s,e,i/2/t);return i%2==0?ts3dutils.VV(cos(o),sin(o),0,1):ts3dutils.VV(n*r*cos(o),n*r*sin(o),0,r)}),a=[];a.push(s,s,s);for(let i=0;ithis.at(t)),...this.points.map(t=>t.p3())],lines:this.points.flatMap((t,s,e)=>e[s+1]?[t.p3(),e[s+1].p3()]:[])}}isTsWithPlane(t){const{knots:s,degree:e,points:i}=this,r=[s[e],...i.slice(1,-1).map((t,i)=>this.closestTToPoint(t.p3(),void 0,s[i+3],s[i+e])),s[s.length-e-1]],n=[];for(let s=0;s{console.log("startT",s);const e=s=>{const[e,i]=this.ptDtDdt(s);return[t.distanceToPointSigned(e),t.normal1.dot(i)]};let i=ts3dutils.newtonIterateWithDerivative2(e,s,8,this.tMin,this.tMax),[r,o]=void 0===i?[]:e(i);void 0!==i&&ts3dutils.eq0(r)&&!ts3dutils.eq0(o)||(i=ts3dutils.newtonIterateWithDerivative2(s=>{const[,e,i]=this.ptDtDdt(s);return[t.normal1.dot(e),t.normal1.dot(i)]},s,8,this.tMin,this.tMax)),[r,o]=void 0===i?[]:e(i),void 0!==i&&ts3dutils.eq0(r)&&!n.some(t=>ts3dutils.eq(t,i))&&n.push(i)},i=this.points[s].p3(),o=this.points[s+1].p3(),a=ts3dutils.snap0(t.distanceToPointSigned(i)),u=ts3dutils.snap0(t.distanceToPointSigned(o));if(a*u<0){e(ts3dutils.lerp(r[s],r[s+1],a/(a-u)))}else 0==u&&e(this.closestTToPoint(o,r[s+1]))}return n}isInfosWithCurve(t){return t instanceof L3$$1?this.isInfosWithLine(t.anchor,t.dir1):super.isInfosWithCurve(t)}isInfosWithLine(t,s){const e=P3$$1.fromPoints(this.points.map(t=>t.p3())),i=L3$$1.anchorDirection(t,s),r=this.points.map(t=>e.distanceToPoint(t.p3())).max(),n=ts3dutils.eq0(r);if(n&&!e.containsLine(i)){const[r]=i.isTsWithPlane(e);if(void 0===r)return[];const n=i.at(r);return this.containsPoint(n)?[{tThis:this.pointT(n),tOther:L3$$1.pointT(t,s,n),p:n}]:[]}{const i=this.isTsWithPlane(P3$$1.normalOnAnchor(e.normal1.cross(s),t)).map(e=>{const i=this.at(e);return{tThis:e,tOther:L3$$1.pointT(t,s,i),p:i}});return n?i:i.filter(e=>L3$$1.containsPoint(t,s,e.p))}}roots(){console.log(this.tMin,this.tMax),ts3dutils.arraySamples(this.tMin,this.tMax,30).forEach(t=>{console.log(t+","+this.tangentAt(t).z)});const t=[[],[],[]];for(let s=0;s{console.log("d",e,"startT",s);const i=ts3dutils.newtonIterateWithDerivative2(t=>{const[,s,i]=this.ptDtDdt(t);return[s.e(e),i.e(e)]},s,8,this.tMin,this.tMax);void 0!==i&&t[e].push(i),console.log("d",e,"startT",s,"root",i)},i=this.points[s].p3(),r=this.points[s+1].p3(),n=i.to(r);for(let t=0;t<3;t++)if(0!==s&&ts3dutils.eq0(n.e(t))){e(ts3dutils.lerp(this.knots[s],this.knots[s+this.degree+2],.5),t)}else if(ss.like(t.points[e]))&&this.knots.every((s,e)=>ts3dutils.eq(s,t.knots[e]))}isColinearTo(t){throw new Error("This doesn't even make sense.")}}function minAndMax(t,s=0,e=t.length){let i=1/0,r=-1/0;for(let n=s;nt[n]&&(i=t[n]),rthis.containsPoint(t));throw new Error(""+t)}equals(t){return ts3dutils.hasConstructor(t,P3$$1)&&this.normal1.equals(t.normal1)&&this.w==t.w}hashCode(){return 31*this.normal1.hashCode()|0+ts3dutils.floatHashCode(this.w)}}P3$$1.YZ=new P3$$1(ts3dutils.V3.X,0),P3$$1.ZX=new P3$$1(ts3dutils.V3.Y,0),P3$$1.XY=new P3$$1(ts3dutils.V3.Z,0);class Surface$$1 extends ts3dutils.Transformable{static loopContainsPointGeneral(t,s,e,i){const r=P3$$1.normalOnAnchor(i,s),n=t.map(t=>t.colinearToLine(e));let o=!1;function a(t){const s=e.pointT(t);return!!ts3dutils.eq0(s)||(s>0&&(o=!o),!1)}for(let o=0;oe.isColinearTo(t.curve));let a=!1;void 0===i&&(i=e.pointT(s));const u=i;function l(t){const s=e.pointT(t);return!!ts3dutils.eq(u,s)||(ut)){return ts3dutils.callsce.call(void 0,"new "+this.constructor.name,...this.getConstructorParameters())}getExtremePoints(){return[]}isCurvesWithSurface(t){return t.isCurvesWithSurface(this)}containsCurve(t){if(t instanceof PPCurve$$1&&(this.equals(t.parametricSurface1)||this.equals(t.parametricSurface2)))return!0;if(t instanceof ImplicitCurve$$1){for(let s=ceil(t.tMin)+1;s<=floor(t.tMax)-1;s++)if(!this.containsPoint(t.points[s]))return!1;return!0}return!1}flipped2(t){return t?this.flipped():this}clipCurves(t){return t}equals(t){return this===t||this.constructor===t.constructor&&this.getConstructorParameters().equals(t.getConstructorParameters())}hashCode(){return this.getConstructorParameters().hashCode()}zDirVolume(t){return this.visit(ZDirVolumeVisitor$$1,t)}calculateArea(t){return this.visit(CalculateAreaVisitor$$1,t)}}!function(t){t[t.INSIDE=0]="INSIDE",t[t.OUTSIDE=1]="OUTSIDE",t[t.ON_EDGE=2]="ON_EDGE"}(exports.PointVsFace||(exports.PointVsFace={}));class ImplicitSurface$$1 extends Surface$$1{static is(t){return t.implicitFunction&&t.didp}}class ParametricSurface$$1 extends Surface$$1{constructor(t,s,e,i){super(),this.uMin=t,this.uMax=s,this.vMin=e,this.vMax=i,ts3dutils.assertNumbers(t,s,e,i),ts3dutils.assert(tt[t.length-4])(this.getConstructorParameters())==this.uMin,this.getConstructorParameters(),this.uMin)}static isCurvesParametricImplicitSurface(t,s,e,i=e,r){const n=t.pUVFunc(),o=s.implicitFunction(),a=t.dpdu(),u=t.dpdv(),l=s.didp.bind(s),c=exports.MathFunctionR2R.forFFxFy((t,s)=>o(n(t,s)),(t,s)=>l(n(t,s)).dot(a(t,s)),(t,s)=>l(n(t,s)).dot(u(t,s)));return Curve$$1.breakDownIC(c,t,e,i,r,(t,e)=>s.containsPoint(n(t,e))).map(({points:e,tangents:i},n)=>PICurve$$1.forParametricPointsTangents(t,s,e,i,r))}static isCurvesParametricParametricSurface(t,s,e,i=e,r){return breakDownPPCurves$$1(t,s,e,i,r)}static is(t){return t.pUVFunc}pUV(t,s){return this.pUVFunc()(t,s)}pUVFunc(){return this.pUV.bind(this)}uvP(t){return this.uvPFunc()(t)}uvPFunc(){return this.uvP.bind(this)}bounds(t,s){return this.uMin<=t&&t<=this.uMax&&this.vMin<=s&&s<=this.vMax}boundsSigned(t,s){return min(t-this.uMin,this.uMax-t,s-this.vMin,this.vMax-s)}normalP(t){const s=this.uvPFunc()(t);return this.normalUV(s.x,s.y)}normalUVFunc(){return this.normalUV.bind(this)}normalUV(t,s){return this.normalUVFunc()(t,s)}parametersValid(t,s){return ts3dutils.between(t,this.uMin,this.uMax)&&ts3dutils.between(s,this.vMin,this.vMax)}toMesh(t=this.uStep,s=this.vStep){return ts3dutils.assert(isFinite(this.vMin)&&isFinite(this.vMax)&&isFinite(this.uMin)&&isFinite(this.uMax)),ts3dutils.assert(isFinite(t)&&isFinite(s)),tsgl.Mesh.parametric(this.pUVFunc(),this.normalUVFunc(),this.uMin,this.uMax,this.vMin,this.vMax,ceil((this.uMax-this.uMin)/t),ceil((this.vMax-this.vMin)/s))}isCurvesWithImplicitSurface(t,s,e,i){return ParametricSurface$$1.isCurvesParametricImplicitSurface(this,t,s,e,i)}edgeLoopCCW(t){const s=this.uvPFunc();return ts3dutils.isCCW(t.flatMap(t=>t.getVerticesNo0()).map(t=>s(t)),ts3dutils.V3.Z)}like(t){if(!this.isCoplanarTo(t))return!1;const s=this.pUVFunc()(this.uMin,this.vMin),e=this.normalUVFunc()(this.uMin,this.vMin),i=t.normalP(s);return 0this.pUV(ts3dutils.lerp(this.uMin,this.uMax,t.x),ts3dutils.lerp(this.vMin,this.vMax,t.y)));return t.addPoints(s),t}}class ConicSurface$$1 extends ParametricSurface$$1{constructor(t,s,e,i,r=0,n=PI,o=0,a=16){super(r,n,o,a),this.center=t,this.f1=s,this.f2=e,this.dir=i,ts3dutils.assertVectors(t,s,e,i),ts3dutils.assert(0<=o),this.matrix=ts3dutils.M4.forSys(s,e,i,t),this.matrixInverse=this.matrix.inversed(),this.normalDir=sign(this.f1.cross(this.f2).dot(this.dir)),this.pLCNormalWCMatrix=this.matrix.as3x3().inversed().transposed().scale(this.normalDir)}pointFoot(t,s,e){if(void 0===s||void 0===e){const i=this.matrixInverse.transformPoint(t),r=i.angleXY();void 0===s&&(s=r<-PI/2?r+ts3dutils.TAU:r),void 0===e&&(e=i.z+(i.lengthXY()-i.z)*SQRT1_2)}const{0:i,1:r}=ts3dutils.newtonIterate(([s,e])=>{const i=this.pUV(s,e).to(t);return[this.dpdu()(s,e).dot(i),this.dpdv()(s).dot(i)]},[s,e]);return new ts3dutils.V3(i,r,0)}get apex(){return this.center}static atApexThroughEllipse(t,s,e,i,r,n){return ts3dutils.assertVectors(t),ts3dutils.assertInst(EllipseCurve$$1,s),new ConicSurface$$1(t,s.f1,s.f2,t.to(s.center),e,i,r,n)}static unitISLineTs(t,s){const{x:e,y:i,z:r}=t,{x:n,y:o,z:a}=s,u=n*n+o*o-a*a,l=2*(e*n+i*o-r*a),c=e*e+i*i-r*r;return ts3dutils.pqFormula(l/u,c/u).filter(t=>0r)return[new L3$$1(ts3dutils.V3.O,new ts3dutils.V3(s,sqrt(i-r),-t).unit()),new L3$$1(ts3dutils.V3.O,new ts3dutils.V3(s,-sqrt(i-r),-t).unit())]}else{if(ts3dutils.eq(i,r)){const i=new ts3dutils.V3(e/2/t,0,e/2/s),r=new ts3dutils.V3(e/2/t,e/s,e/2/s),n=new ts3dutils.V3(0,0,e/s).minus(i);return[new ParabolaCurve$$1(i,r.minus(i),n.z<0?n.negated():n)]}if(ir){const n=new ts3dutils.V3(-t*e/(r-i),0,e*s/(r-i)),o=new ts3dutils.V3(e*s/(i-r),0,-e*t/(i-r)),a=new ts3dutils.V3(0,e/sqrt(i-r),0);return[new HyperbolaCurve$$1(n,o.z>0?o:o.negated(),a)]}}}throw new Error("???")}equals(t){return this==t||Object.getPrototypeOf(this)==Object.getPrototypeOf(t)&&this.center.equals(t.center)&&this.f1.equals(t.f1)&&this.f2.equals(t.f2)&&this.dir.equals(t.dir)}like(t){return!!this.isCoplanarTo(t)&&this.normalDir==t.normalDir}getVectors(){return[{anchor:this.center,dir1:this.dir},{anchor:this.center.plus(this.dir),dir1:this.f1},{anchor:this.center.plus(this.dir),dir1:this.f2}]}getSeamPlane(){return P3$$1.forAnchorAndPlaneVectors(this.center,this.f1,this.dir)}loopContainsPoint(t,s){ts3dutils.assertVectors(s);const e=this.center.like(s)?new L3$$1(s,this.matrix.transformVector(new ts3dutils.V3(0,1,1)).unit()):L3$$1.throughPoints(s,this.apex),i=e.dir1.cross(this.dir);return Surface$$1.loopContainsPointGeneral(t,s,e,i)}getConstructorParameters(){return[this.center,this.f1,this.f2,this.dir,this.uMin,this.uMax,this.vMin,this.vMax]}isTsForLine(t){const s=this.matrixInverse.transformPoint(t.anchor),e=this.matrixInverse.transformVector(t.dir1);return ConicSurface$$1.unitISLineTs(s,e)}isCoplanarTo(t){return this===t||!!(t instanceof ConicSurface$$1&&this.apex.like(t.apex))&&this.containsEllipse(new EllipseCurve$$1(t.center.plus(t.dir),t.f1,t.f2))}containsEllipse(t){const s=t.transform(this.matrixInverse);if(s.center.z<0)return!1;const{f1:e,f2:i}=s.rightAngled(),r=s.center.plus(e),n=s.center.plus(i);return ts3dutils.eq(Math.pow(r.x,2)+Math.pow(r.y,2),Math.pow(r.z,2))&&ts3dutils.eq(Math.pow(n.x,2)+Math.pow(n.y,2),Math.pow(n.z,2))&&(ts3dutils.eq0(e.z)||ts3dutils.eq0(i.z))}containsLine(t){const s=t.transform(this.matrixInverse),e=s.dir1;return s.containsPoint(ts3dutils.V3.O)&&ts3dutils.eq(e.x*e.x+e.y*e.y,e.z*e.z)}containsParabola(t){ts3dutils.assertInst(ParabolaCurve$$1,t);const s=t.transform(this.matrixInverse);if(s.center.z<0||s.f2.z<0)return!1;const{center:e,f1:i,f2:r}=s.rightAngled();return ts3dutils.eq(e.x*e.x+e.y*e.y,e.z*e.z)&&ts3dutils.eq0(i.z)&&ts3dutils.eq(r.x*r.x+r.y*r.y,r.z*r.z)}containsHyperbola(t){ts3dutils.assertInst(HyperbolaCurve$$1,t);const s=t.transform(this.matrixInverse).rightAngled(),e=s.center.xy();if(e.likeO())return!1;const i=e.angleXY(),{center:r,f1:n,f2:o}=s.rotateZ(-i);return n.z>0&&ts3dutils.eq(r.x,n.z)&&ts3dutils.eq(r.z,n.x)&&ts3dutils.eq0(r.y)&&ts3dutils.eq0(n.y)&&ts3dutils.eq(sqrt(abs(Math.pow(r.x,2)-Math.pow(r.z,2))),abs(o.y))&&ts3dutils.eq0(o.x)&&ts3dutils.eq0(o.z)}containsCurve(t){return t instanceof EllipseCurve$$1?this.containsEllipse(t):t instanceof L3$$1?this.containsLine(t):t instanceof HyperbolaCurve$$1?this.containsHyperbola(t):t instanceof ParabolaCurve$$1?this.containsParabola(t):super.containsCurve(t)}transform(t){return new ConicSurface$$1(t.transformPoint(this.center),t.transformVector(this.f1).times(t.isMirroring()?-1:1),t.transformVector(this.f2),t.transformVector(this.dir),this.uMin,this.uMax,this.vMin,this.vMax)}transform4(t){const s=t.timesVector(ts3dutils.Vector.fromV3AndWeight(this.center,1)),e=t=>new EllipseCurve$$1(new ts3dutils.V3(0,0,t),new ts3dutils.V3(t,0,0),new ts3dutils.V3(0,t,0));if(ts3dutils.eq0(s.w)){const i=s.V3(),r=e(this.vMin).transform4(t.times(this.matrix)),n=ts3dutils.M4.forSys(r.f1,r.f2,i.unit(),r.center).inversed(),o=e(this.vMax).transform4(n.times(t.times(this.matrix))).getAABB();return new CylinderSurface$$1(r,i.unit(),this.uMin,this.uMax,min(0,o.min.z,o.max.z),max(0,o.min.z,o.max.z))}{const s=t.transformPoint(this.center),i=t.transformVector2(this.f1,this.center).times(t.isMirroring()?-1:1),r=t.transformVector2(this.f2,this.center),n=t.transformVector2(this.dir,this.center),o=ts3dutils.M4.forSys(i,r,n,s).inversed(),a=e(this.vMin).transform4(o.times(t.times(this.matrix))).getAABB().addAABB(e(this.vMax).transform4(o.times(t.times(this.matrix))).getAABB());return new ConicSurface$$1(s,i,r,n,this.uMin,this.uMax,a.min.z,a.max.z)}}flipped(){return new ConicSurface$$1(this.center,this.f1.negated(),this.f2,this.dir)}normalUVFunc(){const{f1:t,f2:s}=this,e=this.dir;return(i,r)=>s.cross(t).plus(s.cross(e.times(Math.cos(i)))).plus(e.cross(t.times(Math.sin(i)))).unit()}normalP(t){const s=this.matrixInverse.transformPoint(t);return this.normalUVFunc()(s.angleXY(),s.z)}pUVFunc(){return(t,s)=>{const e=new ts3dutils.V3(s*cos(t),s*sin(t),s);return this.matrix.transformPoint(e)}}dpdu(){return(t,s)=>{const e=new ts3dutils.V3(s*-sin(t),s*cos(t),0);return this.matrix.transformVector(e)}}dpdv(){return t=>{const s=new ts3dutils.V3(cos(t),sin(t),1);return this.matrix.transformVector(s)}}implicitFunction(){return t=>{const s=this.matrixInverse.transformPoint(t),e=s.lengthXY();return this.normalDir*(e-s.z)}}didp(t){const s=this.matrixInverse.transformPoint(t);return this.pLCNormalWCMatrix.transformVector(s.xy().unit().withElement("z",-1).times(this.normalDir))}containsPoint(t){return ts3dutils.eq0(this.implicitFunction()(t))}uvP(t){const s=this.matrixInverse.transformPoint(t),e=s.angleXY();return new ts3dutils.V3(e<-PI/2?e+ts3dutils.TAU:e,s.z,0)}isCurvesWithSurface(t){return t instanceof PlaneSurface$$1?this.isCurvesWithPlane(t.plane):ImplicitSurface$$1.is(t)?ParametricSurface$$1.isCurvesParametricImplicitSurface(this,t,.1,.1/this.dir.length(),.02):super.isCurvesWithSurface(t)}getCenterLine(){return new L3$$1(this.center,this.dir)}isCurvesWithPlane(t){ts3dutils.assertInst(P3$$1,t);const s=t.transform(this.matrixInverse),e=s.normal1,i=e.z,r=e.lengthXY(),n=s.w,o=ts3dutils.M4.rotateZ(e.angleXY()),a=ts3dutils.eq0(e.lengthXY())?this.matrix:this.matrix.times(o);return ConicSurface$$1.unitISPlane(r,i,n).flatMap(s=>{const e=s.transform(a);if(s instanceof EllipseCurve$$1){const t=s.transform(o),i=t.isTsWithPlane(P3$$1.ZX);return ts3dutils.getIntervals(i,-PI,PI).filter(([s,e])=>t.at((s+e)/2).y>0).flatMap(([t,s])=>e.split(t,s))}const i=e.at(.2);return this.normalP(i).cross(t.normal1).dot(e.tangentAt(.2))>0?e:e.reversed()})}debugInfo(){return{ps:[this.center],lines:[this.center,this.center.plus(this.f1),this.center.plus(this.f2),this.center.plus(this.dir)]}}}ConicSurface$$1.UNIT=new ConicSurface$$1(ts3dutils.V3.O,ts3dutils.V3.X,ts3dutils.V3.Y,ts3dutils.V3.Z),ConicSurface$$1.prototype.uStep=PI/16,ConicSurface$$1.prototype.vStep=256;class ProjectedCurveSurface$$1 extends ParametricSurface$$1{constructor(t,s,e=t.tMin,i=t.tMax,r=-100,n=100){super(e,i,r,n),this.baseCurve=t,this.dir=s,ts3dutils.assertInst(Curve$$1,t),ts3dutils.assertInst(ts3dutils.V3,s),ts3dutils.assert(ethis.baseCurve.tangentAt(t)}dpdv(){return(t,s)=>this.dir}normalUV(t,s){return this.baseCurve.tangentAt(t).cross(this.dir).unit()}pUV(t,s){return this.baseCurve.at(t).plus(this.dir.times(s))}pointFoot(t,s){const e=new P3$$1(this.dir.unit(),0),i=this.baseCurve.project(e),r=e.projectedPoint(t),n=i.closestTToPoint(r,s,this.uMin,this.uMax),o=L3$$1.pointT(this.baseCurve.at(n),this.dir,t);return new ts3dutils.V3(n,o,0)}uvPFunc(){const t=new P3$$1(this.dir.unit(),0),s=this.baseCurve.project(t);return e=>{const i=t.projectedPoint(e);ts3dutils.assertNumbers(this.uMin);const r=s.pointT(i,this.uMin,this.uMax),n=L3$$1.pointT(this.baseCurve.at(r),this.dir,e);return new ts3dutils.V3(r,n,0)}}isCurvesWithPlane(t){if(ts3dutils.assertInst(P3$$1,t),this.dir.isPerpendicularTo(t.normal1)){return this.baseCurve.isTsWithPlane(t).map(s=>{const e=00&&(s=s.reversed()),[s]}}isCurvesWithSurface(t){if(t instanceof PlaneSurface$$1)return this.isCurvesWithPlane(t.plane);if(t instanceof ProjectedCurveSurface$$1){const s=t.dir;if(this.dir.isParallelTo(s)){return t.baseCurve.isTsWithSurface(this).map(e=>{const i=t.baseCurve.at(e),r=this.normalP(i).cross(t.normalP(i));return new L3$$1(i,s.times(sign(r.dot(s))))})}if(ImplicitSurface$$1.is(t)){let s=ParametricSurface$$1.isCurvesParametricImplicitSurface(this,t,.1,.1/t.dir.length(),.05);return s=t.clipCurves(s)}{let s=ParametricSurface$$1.isCurvesParametricParametricSurface(this,t,.05,.1/t.dir.length(),.05);return s=this.clipCurves(s),s=t.clipCurves(s)}}return t instanceof EllipsoidSurface$$1?t.isCurvesWithSurface(this):super.isCurvesWithSurface(t)}containsPoint(t){const s=this.uvPFunc()(t);return this.pUVFunc()(s.x,s.y).like(t)}containsCurve(t){if(t instanceof L3$$1)return this.dir.isParallelTo(t.dir1)&&this.containsPoint(t.anchor);if(t instanceof ImplicitCurve$$1)return super.containsCurve(t);const s=new P3$$1(this.dir.unit(),0),e=this.baseCurve.project(s),i=t.project(s);return e.isColinearTo(i)}isCoplanarTo(t){return this==t||ts3dutils.hasConstructor(t,ProjectedCurveSurface$$1)&&this.dir.isParallelTo(t.dir)&&this.containsCurve(t.baseCurve)}like(t){if(!this.isCoplanarTo(t))return!1;const s=this.pUVFunc()(0,0),e=this.normalUVFunc()(0,0),i=t.normalP(s);return 0t.tOther)}flipped(){return new this.constructor(this.baseCurve,this.dir.negated(),this.uMin,this.uMax,-this.vMax,-this.vMin)}}ProjectedCurveSurface$$1.prototype.uStep=1/128,ProjectedCurveSurface$$1.prototype.vStep=256;class RotatedCurveSurface$$1 extends ParametricSurface$$1{constructor(t,s=ts3dutils.M4.IDENTITY,e=0,i=PI,r=t.tMin,n=t.tMax){super(e,i,r,n),this.curve=t,this.matrix=s,ts3dutils.assertInst(ts3dutils.M4,s),ts3dutils.assert(s.isNoProj()),ts3dutils.assert(ts3dutils.eq0(t.at(r).y)),this.matrixInverse=s.inversed(),this.vStep=this.curve.tIncrement}getConstructorParameters(){return[this.curve,this.matrix,this.uMin,this.uMax,this.vMin,this.vMax]}flipped(){return new RotatedCurveSurface$$1(this.curve,this.matrix.times(ts3dutils.M4.mirror(P3$$1.YZ)),this.uMin,this.uMax,this.vMin,this.vMax)}transform(t){return new RotatedCurveSurface$$1(this.curve,t.isMirroring()?t.times(this.matrix).times(ts3dutils.M4.mirror(P3$$1.YZ)):t.times(this.matrix),this.uMin,this.uMax,this.vMin,this.vMax)}containsPoint(t){const s=this.matrixInverse.transformPoint(t),e=s.lengthXY();return this.curve.containsPoint(new ts3dutils.V3(e,0,s.z))}pUVFunc(){return(t,s)=>{const{x:e,z:i}=this.curve.at(s);return this.matrix.transformPoint(ts3dutils.V3.polar(e,t,i))}}dpdu(){return(t,s)=>{const e=this.curve.at(s).x,i=new ts3dutils.V3(e*-sin(t),e*cos(t),0);return this.matrix.transformVector(i)}}dpdv(){return(t,s)=>{const{x:e,z:i}=this.curve.tangentAt(s);return this.matrix.transformVector(ts3dutils.V3.polar(e,t,i))}}normalUVFunc(){const t=this.matrix.inversed().transposed().as3x3(),s=this.matrix.isMirroring()?-1:1;return(e,i)=>{const{x:r,z:n}=this.curve.tangentAt(i);return t.transformVector(ts3dutils.V3.polar(n,e,-r)).toLength(s)}}uvPFunc(){return t=>{const s=this.matrixInverse.transformPoint(t),e=EllipseCurve$$1.XYLCPointT(s,this.uMin,this.uMax),i=s.lengthXY();return new ts3dutils.V3(e,this.curve.pointT(new ts3dutils.V3(i,0,s.z)),0)}}pointFoot(t,s,e){const i=this.matrixInverse.transformPoint(t),r=abs(i.angleXY()),n=i.lengthXY();return new ts3dutils.V3(r,this.curve.closestTToPoint(new ts3dutils.V3(n,0,i.z)),0)}isTsForLine(t){const s=this.matrixInverse.transformPoint(t.anchor),e=this.matrixInverse.transformVector(t.dir1);if(e.isParallelTo(ts3dutils.V3.Z))return ts3dutils.fuzzyBetween(s.angleXY(),this.uMin,this.uMax)?this.curve.isInfosWithLine(new ts3dutils.V3(s.lengthXY(),0,s.z),e).map(t=>t.tOther):[];if(L3$$1.containsPoint(s.xy(),e.xy(),ts3dutils.V3.O)){const t=e.xy().unit();return[...this.curve.isInfosWithLine(new ts3dutils.V3(t.dot(s),0,s.z),new ts3dutils.V3(t.dot(e),0,e.z)),...this.curve.isInfosWithLine(new ts3dutils.V3(-t.dot(s),0,s.z),new ts3dutils.V3(-t.dot(e),0,e.z))].map(t=>t.tOther).filter(t=>ts3dutils.fuzzyBetween(L3$$1.at(s,e,t).angleXY(),this.uMin,this.uMax))}if(e.isPerpendicularTo(ts3dutils.V3.Z)){const t=this.isCurvesWithPlaneLC(new P3$$1(ts3dutils.V3.Z,s.z));return t?t.flatMap(t=>t.isInfosWithLine(s,e).map(t=>t.tOther)):[]}{const t=-s.xy().dot(e.xy())/e.xy().squared(),i=L3$$1.at(s,e,t),r=i.lengthXY(),n=r*(e.z/e.lengthXY());return HyperbolaCurve$$1.XY.transform(ts3dutils.M4.rotateX(90*ts3dutils.DEG).scale(r,0,n).translate(0,0,i.z)).isInfosWithCurve(this.curve).map(t=>(t.p.z-s.z)/e.z).filter(t=>ts3dutils.fuzzyBetween(L3$$1.at(s,e,t).angleXY(),this.uMin,this.uMax))}}isCurvesWithPlaneLC(t){return t.normal1.isParallelTo(ts3dutils.V3.Z)?this.curve.isTsWithPlane(t).map(s=>{const{x:e}=this.curve.at(s);return new EllipseCurve$$1(new ts3dutils.V3(0,0,t.w),new ts3dutils.V3(e,0,0),new ts3dutils.V3(0,e,0),this.uMin,this.uMax).transform(this.matrix)}):t.normal1.isPerpendicularTo(ts3dutils.V3.Z)&&t.containsPoint(ts3dutils.V3.O)?[this.curve.rotateZ(ts3dutils.V3.Y.angleRelativeNormal(t.normal1,ts3dutils.V3.Z)).transform(this.matrix)]:void 0}isCurvesWithPlane(t){const s=t.transform(this.matrixInverse),e=this.isCurvesWithPlaneLC(s);return e?e.map(t=>t.transform(this.matrix)):ParametricSurface$$1.isCurvesParametricImplicitSurface(this,new PlaneSurface$$1(t),.05,.05,.02)}loopContainsPoint(t,s){const e=this.matrixInverse.transformPoint(s),i=EllipseCurve$$1.XYLCPointT(e,this.uMin,this.uMax),r=EllipseCurve$$1.semicircle(e.lengthXY(),new ts3dutils.V3(0,0,e.z)).transform(this.matrix);return Surface$$1.loopContainsPointEllipse(t,s,r,i)}isCoplanarTo(t){if(this===t)return!0;if(!ts3dutils.hasConstructor(t,RotatedCurveSurface$$1))return!1;const s=this.matrixInverse.times(t.matrix);ts3dutils.assert(!s.X.xy().likeO());const e=s.X.angleXY();return t.curve.transform(ts3dutils.M4.rotateZ(-e).times(s)).isColinearTo(this.curve)}isCurvesWithSurface(t){return t instanceof PlaneSurface$$1?this.isCurvesWithPlane(t.plane):super.isCurvesWithSurface(t)}containsCurve(t){if(t.constructor==this.curve.constructor){const s=t.transform(this.matrixInverse),e=[0,.5,1].map(t=>ts3dutils.lerp(s.tMin,s.tMax,t)).withMax(t=>s.at(t).lengthXY()),i=s.at(e).angleXY(),r=s.rotateZ(-i);if(this.curve.isColinearTo(r))return!0}if(t instanceof EllipseCurve$$1){const s=t.transform(this.matrixInverse);return!!s.normal.isParallelTo(ts3dutils.V3.Z)&&(s.isCircular()&&this.curve.containsPoint(new ts3dutils.V3(s.f1.length(),0,s.center.z)))}return super.containsCurve(t)}getExtremePoints(){return getExtremePointsHelper$$1.call(this,this.curve)}asNURBSSurface(){const t=NURBS$$1.fromEllipse(this.curve),s=NURBS$$1.UnitCircle(2,this.tMin,this.tMax);return new NURBSSurface$$1(s.points.flatMap(s=>t.points.map(t=>this.matrix.timesVector(ts3dutils.VV(s.x*t.x,s.y*t.x,t.z*s.w,s.w*t.w)))),t.knots,s.knots,t.degree,s.degree,t.tMin,t.tMax,s.tMin,s.tMax)}}function getExtremePointsHelper$$1(t){const s=this.matrix.X,e=this.matrix.Y;return[0,1,2].flatMap(i=>{const r=e.e(i),n=-s.e(i);return(ts3dutils.eq0(r)&&ts3dutils.eq0(n)?[[1,0]]:intersectionUnitCircleLine2$$1(r,n,0)).flatMap(([s,e])=>{const r=Math.atan2(e,s);return ts3dutils.lt(this.uMin,r)&&ts3dutils.lt(r,this.uMax)?t.transform(this.matrix.times(ts3dutils.M4.rotateZ(r))).roots()[i].map(t=>this.pUV(r,t)):[]})})}RotatedCurveSurface$$1.prototype.uStep=EllipseCurve$$1.prototype.tIncrement;class CylinderSurface$$1 extends ProjectedCurveSurface$$1{constructor(t,s,e=t.tMin,i=t.tMax,r=-1/0,n=1/0){super(t,s,e,i,r,n),this.baseCurve=t,ts3dutils.assertInst(EllipseCurve$$1,t),this.matrix=ts3dutils.M4.forSys(t.f1,t.f2,s,t.center),this.matrixInverse=this.matrix.inversed(),this.normalDir=sign(this.baseCurve.normal.dot(this.dir)),this.pLCNormalWCMatrix=this.matrix.as3x3().inversed().transposed().scale(this.normalDir),this.pWCNormalWCMatrix=this.pLCNormalWCMatrix.times(this.matrixInverse)}static semicylinder(t,s,e,i,r){return new CylinderSurface$$1(new EllipseCurve$$1(ts3dutils.V3.O,new ts3dutils.V3(t,0,0),new ts3dutils.V3(0,t,0)),ts3dutils.V3.Z,s,e,i,r)}static unitISLineTs(t,s){const{x:e,y:i}=t,{x:r,y:n}=s,o=Math.pow(r,2)+Math.pow(n,2),a=2*(e*r+i*n),u=Math.pow(e,2)+Math.pow(i,2)-1;return ts3dutils.pqFormula(a/o,u/o).filter(t=>EllipseCurve$$1.XYLCValid(new ts3dutils.V3(e+r*t,i+n*t,0)))}normalP(t){return this.pLCNormalWCMatrix.transformVector(this.matrixInverse.transformPoint(t).xy()).unit()}loopContainsPoint(t,s){if(ts3dutils.assertVectors(s),!this.containsPoint(s))return OUTSIDE$$1;const e=new L3$$1(s,this.dir.unit()),i=this.dir.cross(this.normalP(s));return Surface$$1.loopContainsPointGeneral(t,s,e,i)}isTsForLine(t){ts3dutils.assertInst(L3$$1,t);const s=this.matrixInverse.transformVector(t.dir1);if(s.isParallelTo(ts3dutils.V3.Z))return[];const e=this.matrixInverse.transformPoint(t.anchor);return ts3dutils.assert(!CylinderSurface$$1.unitISLineTs(e,s).length||!isNaN(CylinderSurface$$1.unitISLineTs(e,s)[0]),"sad "+s),CylinderSurface$$1.unitISLineTs(e,s)}isCoplanarTo(t){return this==t||ts3dutils.hasConstructor(t,CylinderSurface$$1)&&this.dir.isParallelTo(t.dir)&&this.containsEllipse(t.baseCurve,!1)}like(t){if(!this.isCoplanarTo(t))return!1;return 0{return(this.matrixInverse.transformPoint(t).lengthXY()-1)*this.normalDir}}didp(t){const s=this.matrixInverse.transformPoint(t),e=s.lengthXY(),i=new ts3dutils.V3(s.x/e,s.y/e,0);return this.pLCNormalWCMatrix.transformVector(i)}containsPoint(t){const s=this.matrixInverse.transformPoint(t);return this.baseCurve.isValidT(EllipseCurve$$1.XYLCPointT(s,this.uMin,this.uMax))}uvP(t){ts3dutils.assert(1==arguments.length);const s=this.matrixInverse.transformPoint(t),e=EllipseCurve$$1.XYLCPointT(s,this.vMin,this.vMax);return new ts3dutils.V3(e,s.z,0)}isCurvesWithSurface(t){if(t instanceof ProjectedCurveSurface$$1&&t.dir.isParallelTo(this.dir)){const s=t.baseCurve.transform(ts3dutils.M4.project(this.baseCurve.getPlane(),this.dir));return this.baseCurve.isInfosWithCurve(s).map(s=>{const e=sign(this.normalP(s.p).cross(t.normalP(s.p)).dot(this.dir))||1;return new L3$$1(s.p,this.dir.times(e))})}if(t instanceof CylinderSurface$$1&&ts3dutils.eq0(this.getCenterLine().distanceToLine(t.getCenterLine())))throw new Error;return super.isCurvesWithSurface(t)}getCenterLine(){return new L3$$1(this.baseCurve.center,this.dir)}facesOutwards(){return this.baseCurve.normal.dot(this.dir)>0}getSeamPlane(){let t=this.baseCurve.f1.cross(this.dir);return t=t.times(-sign(t.dot(this.baseCurve.f2))),P3$$1.normalOnAnchor(t,this.baseCurve.center)}clipCurves(t){return t.flatMap(t=>t.clipPlane(this.getSeamPlane()))}}CylinderSurface$$1.UNIT=new CylinderSurface$$1(EllipseCurve$$1.UNIT,ts3dutils.V3.Z,void 0,void 0,0,1),CylinderSurface$$1.prototype.uStep=ts3dutils.TAU/32,CylinderSurface$$1.prototype.vStep=256;class EllipsoidSurface$$1 extends ParametricSurface$$1{constructor(t,s,e,i,r=0,n=PI,o=-PI/2,a=PI/2){super(r,n,o,a),this.center=t,this.f1=s,this.f2=e,this.f3=i,ts3dutils.assert(0<=r&&r<=PI),ts3dutils.assert(0<=n&&n<=PI),ts3dutils.assert(-PI/2<=o&&o<=PI/2),ts3dutils.assert(-PI/2<=a&&a<=PI/2),ts3dutils.assertVectors(t,s,e,i),this.matrix=ts3dutils.M4.forSys(s,e,i,t),this.matrixInverse=this.matrix.inversed(),this.normalDir=sign(this.f1.cross(this.f2).dot(this.f3)),this.pLCNormalWCMatrix=this.matrix.as3x3().inversed().transposed().scale(this.normalDir),this.pWCNormalWCMatrix=this.pLCNormalWCMatrix.times(this.matrixInverse)}static unitArea(t){return t.map(t=>{if(t.curve instanceof PICurve$$1){const s=t.curve.calcSegmentPoints(t.aT,t.bT,t.a,t.b,t.aT>t.bT,!0);let e=0;for(let t=0;t{const e=t.curve.at(s),i=t.curve.tangentAt(s);return abs(e.angleXY())*i.z};return ts3dutils.glqInSteps(s,t.aT,t.bT,1)}throw new Error}).sum()}static unitISTsWithLine(t,s){const e=s.dot(s),i=2*t.dot(s),r=t.dot(t)-1;return ts3dutils.pqFormula(i/e,r/e).filter(e=>ts3dutils.le(0,t.y+e*s.y))}static unitISCurvesWithPlane(t){const s=Math.abs(t.w);if(ts3dutils.lt(s,1)){const e=Math.sqrt(1-Math.pow(s,2)),i=t.normal1.y*t.w,r=abs(s*e);if(ts3dutils.le(i,-r)&&!ts3dutils.eq0(s))return[];if(ts3dutils.le(i,0)&&!t.normal1.isParallelTo(ts3dutils.V3.Y)){const s=t.normal1.isParallelTo(ts3dutils.V3.Y)?ts3dutils.V3.Z:t.normal1.cross(ts3dutils.V3.Y).toLength(e),r=s.cross(t.normal1),n=-i/r.y,o=max(0,Math.asin(n));return[new EllipseCurve$$1(t.anchor,s,r,o,PI-o)]}{const s=(t.normal1.isParallelTo(ts3dutils.V3.Y)?ts3dutils.V3.X:t.normal1.cross(ts3dutils.V3.Y)).toLength(e),r=s.cross(t.normal1),n=ts3dutils.eq0(r.y)?-1:-i/r.y,o=Math.acos(max(-1,n-ts3dutils.NLA_PRECISION));return[new EllipseCurve$$1(t.anchor,r.negated(),s,PI-o,PI),new EllipseCurve$$1(t.anchor,r,s.negated(),0,o)]}}return[]}static unitISCurvesWithEllipsoidSurface(t){if(t.isSphere()){const s=t.f1.length(),e=t.center.length();if(ts3dutils.le(1,e-s)||ts3dutils.le(e+s,1)||ts3dutils.le(e-s,-1))return[];{const i=2*function(t,s,e){const i=(t+s+e)/2;return sqrt(i*(i-t)*(i-s)*(i-e))}(1,s,e)/e,r=sign(1+Math.pow(e,2)-Math.pow(s,2))*sqrt(1-Math.pow(i,2)),n=new P3$$1(t.center.unit(),r);return EllipsoidSurface$$1.unitISCurvesWithPlane(n.flipped())}}throw new Error}static unitISCurvesWithCylinderSurface(t){if(new L3$$1(t.baseCurve.center,t.dir).containsPoint(ts3dutils.V3.O)){const s=t.baseCurve.transform(ts3dutils.M4.project(new P3$$1(t.dir,0))),e=s.f1.length(),i=s.f2.length();if(ts3dutils.lt(1,min(e,i)))return[];if(s.isCircular()){const i=Math.sqrt(1-Math.pow(min(1,e),2)),r=(t.dir.y<0?t.dir.negated():t.dir).times(i);return[new EllipseCurve$$1(r,s.f1,s.f2)]}}throw new Error}static sphere(t,s=ts3dutils.V3.O){return ts3dutils.assertNumbers(t),new EllipsoidSurface$$1(s,new ts3dutils.V3(t,0,0),new ts3dutils.V3(0,t,0),new ts3dutils.V3(0,0,t))}static forABC(t,s,e,i=ts3dutils.V3.O){return new EllipsoidSurface$$1(i,new ts3dutils.V3(t,0,0),new ts3dutils.V3(0,s,0),new ts3dutils.V3(0,0,e))}static calculateAreaSpheroid(t,s,e,i){ts3dutils.assertf(()=>t.isPerpendicularTo(s)),ts3dutils.assertf(()=>s.isPerpendicularTo(e)),ts3dutils.assertf(()=>e.isPerpendicularTo(t));const r=ts3dutils.M4.forSys(t,s,e).inversed(),n=t.length(),o=e.unit();return i.map(t=>{if(t.curve instanceof EllipseCurve$$1){const s=s=>{const e=t.curve.at(s),i=t.tangentAt(s),a=r.transformPoint(e);return a.angleXY()*n*Math.sqrt(1+Math.pow(a.z,2))*Math.sqrt(1+Math.pow(o.dot(i),2))};return ts3dutils.glqInSteps(s,t.aT,t.bT,1)}throw new Error}).sum()}getConstructorParameters(){return[this.center,this.f1,this.f2,this.f3,this.uMin,this.uMax,this.vMin,this.vMax]}equals(t){return this==t||Object.getPrototypeOf(t)==this.constructor.prototype&&this.matrix.equals(t.matrix)}edgeLoopCCW(t){return EllipsoidSurface$$1.unitArea(t.map(t=>t.transform(this.matrixInverse)))>0}like(t){return!!this.isCoplanarTo(t)&&this.matrix.determinant3()*t.matrix.determinant3()>0}rootPoints(){}toMesh(){return ParametricSurface$$1.prototype.toMesh.call(this)}clipCurves(t){return t.flatMap(t=>t.clipPlane(this.getSeamPlane()))}dpdu(){return(t,s)=>this.matrix.transformVector(new ts3dutils.V3(cos(s)*-sin(t),cos(s)*cos(t),0))}dpdv(){return(t,s)=>this.matrix.transformVector(new ts3dutils.V3(-sin(s)*cos(t),-sin(s)*sin(t),cos(s)))}isCurvesWithPCS(t){let s=ParametricSurface$$1.isCurvesParametricImplicitSurface(t,this,.1,.1/t.dir.length(),.05);return s=this.clipCurves(s)}isCurvesWithPCSSmart(t){const s=t.transform(this.matrixInverse),e=s.baseCurve.project(new P3$$1(s.dir,0)),i=e.isTsWithSurface(EllipsoidSurface$$1.UNIT),r=ts3dutils.getIntervals(i,e.tMin,e.tMax).filter(([t,s])=>e.at((t+s)/2).length()<1),n=[0,1].map(t=>i=>{const r=ts3dutils.snap(e.at(i).squared(),1),n=sqrt(1-r);return ts3dutils.eq0(n)?e.at(i):e.at(i).plus(s.dir.times(sign(t-.5)*n))}),o=[0,1].map(t=>i=>{const r=ts3dutils.snap(e.at(i).squared(),1),n=e.at(i).times(-1/sqrt(1-r)).dot(e.tangentAt(i));return e.tangentAt(i).plus(s.dir.times(sign(t-.5)*n))}),a=[];for(const[s,e]of r)for(const i of[0,1]){const r=t=>n[i](t).y,u=t=>o[i](t).y;ts3dutils.checkDerivate(r,u,s+.1,e-.1);const l=ts3dutils.getRoots(r,s+ts3dutils.NLA_PRECISION,e-ts3dutils.NLA_PRECISION,1/2048,u),c=ts3dutils.getIntervals(l,s,e).filter(([t,s])=>r((t+s)/2)>0);for(const[s,e]of c){let r=n[i](s),o=n[i](e);0===i&&([r,o]=[o,r]),ts3dutils.assert(EllipsoidSurface$$1.UNIT.containsPoint(r)),ts3dutils.assert(EllipsoidSurface$$1.UNIT.containsPoint(o)),a.push(PICurve$$1.forStartEnd(t,this,this.matrix.transformPoint(o),this.matrix.transformPoint(r),void 0))}}return t.clipCurves(a)}isCurvesWithSurface(t){if(t instanceof PlaneSurface$$1)return this.isCurvesWithPlane(t.plane);if(t instanceof CylinderSurface$$1)return this.isCurvesWithCylinderSurface(t);if(t instanceof EllipsoidSurface$$1){const s=t.transform(this.matrixInverse),e=EllipsoidSurface$$1.unitISCurvesWithEllipsoidSurface(s).map(t=>t.transform(this.matrix));return t.clipCurves(e)}if(t instanceof ProjectedCurveSurface$$1)return this.isCurvesWithPCS(t);if(t instanceof ParametricSurface$$1){let s=ParametricSurface$$1.isCurvesParametricImplicitSurface(t,this,.1,.1,.05);return s=this.clipCurves(s),s=t.clipCurves(s)}throw new Error}isCurvesWithPlane(t){const s=t.transform(this.matrixInverse);return EllipsoidSurface$$1.unitISCurvesWithPlane(s).map(t=>t.transform(this.matrix))}isCurvesWithCylinderSurface(t){if(L3$$1.containsPoint(t.baseCurve.center,t.dir,this.center)){ts3dutils.assert(this.isSphere());const s=t.baseCurve.transform(ts3dutils.M4.project(t.baseCurve.getPlane(),t.dir));if(s.isCircular()){const t=this.f1.length(),e=s.f1.length();ts3dutils.eq(t,e),ts3dutils.assert(!1)}}return this.isCurvesWithPCS(t)}isTsForLine(t){ts3dutils.assertInst(L3$$1,t);const s=this.matrixInverse.transformPoint(t.anchor),e=this.matrixInverse.transformVector(t.dir1);return EllipsoidSurface$$1.unitISTsWithLine(s,e)}isCoplanarTo(t){if(this===t)return!0;if(!ts3dutils.hasConstructor(t,EllipsoidSurface$$1))return!1;if(!this.center.like(t.center))return!1;if(this.isSphere())return t.isSphere()&&ts3dutils.eq(this.f1.length(),this.f2.length());const s=this.matrixInverse.times(t.matrix);return s.like3x3()&&s.isOrthogonal()}containsEllipse(t){const s=t.transform(this.matrixInverse),e=s.center.length(),i=Math.sqrt(1-Math.pow(e,2));return ts3dutils.lt(e,1)&&s.isCircular()&&s.f1.hasLength(i)}containsCurve(t){return t instanceof EllipseCurve$$1?this.containsEllipse(t):super.containsCurve(t)}transform(t){return ts3dutils.assert(t.isNoProj(),()=>t.sce),new EllipsoidSurface$$1(t.transformPoint(this.center),t.transformVector(this.f1),t.transformVector(this.f2),t.transformVector(this.f3).times(t.isMirroring()?-1:1))}transform4(t){console.log("transform4");const s=t.times(this.matrix);console.log(s.toString());const e=ts3dutils.V(s.m[12],s.m[13],s.m[14]),i=this.pLCNormalWCMatrix.inversed().transformPoint(e),r=i.angleXY(),n=Math.asin(ts3dutils.clamp(i.z,-1,1)),o=s.transformPoint(e.unit()),a=s.transformPoint(e.unit().negated()),u=ts3dutils.V3.lerp(o,a,.5);return console.log(e.sce,r,n,o,a,"newCenter",u.sce),new EllipsoidSurface$$1(u,t.transformVector2(this.f1,this.center),t.transformVector2(this.f2,this.center),t.transformVector2(this.f3,this.center).times(t.isMirroring()?-1:1))}isInsideOut(){return this.f1.cross(this.f2).dot(this.f3)<0}flipped(){return new EllipsoidSurface$$1(this.center,this.f1,this.f2,this.f3.negated(),this.uMin,this.uMax,-this.vMax,-this.vMin)}normalUVFunc(){return(t,s)=>{const{f1:e,f2:i,f3:r}=this;return i.cross(r).times(Math.cos(s)*Math.cos(t)).plus(r.cross(e).times(Math.cos(s)*Math.sin(t))).plus(e.cross(i).times(Math.sin(s))).unit()}}normalP(t){return this.pLCNormalWCMatrix.transformVector(this.matrixInverse.transformPoint(t)).unit()}normalUV(t,s){return this.pLCNormalWCMatrix.transformVector(ts3dutils.V3.sphere(t,s)).unit()}uvPFunc(){return t=>{const s=this.matrixInverse.transformPoint(t),e=abs(s.angleXY()),i=Math.asin(ts3dutils.clamp(s.z,-1,1));return ts3dutils.assert(isFinite(e)),ts3dutils.assert(isFinite(i)),new ts3dutils.V3(e,i,0)}}pUVFunc(){return(t,s)=>this.matrix.transformPoint(ts3dutils.V3.sphere(t,s))}isSphere(){return ts3dutils.eq(this.f1.length(),this.f2.length())&&ts3dutils.eq(this.f2.length(),this.f3.length())&&ts3dutils.eq(this.f3.length(),this.f1.length())&&this.f1.isPerpendicularTo(this.f2)&&this.f2.isPerpendicularTo(this.f3)&&this.f3.isPerpendicularTo(this.f1)}isVerticalSpheroid(){return ts3dutils.eq(this.f1.length(),this.f2.length())&&this.f1.isPerpendicularTo(this.f2)&&this.f2.isPerpendicularTo(this.f3)&&this.f3.isPerpendicularTo(this.f1)}mainAxes(){const{f1:t,f2:s,f3:e}=this;if(ts3dutils.eq0(t.dot(s))&&ts3dutils.eq0(s.dot(e))&&ts3dutils.eq0(e.dot(t)))return this;const{U:i,SIGMA:r}=this.matrix.svd3();ts3dutils.assert(r.isDiagonal()),ts3dutils.assert(i.isOrthogonal());const n=i.times(r),[o,a,u]=ts3dutils.arrayFromFunction(3,t=>new ts3dutils.V3(n.m[t],n.m[t+4],n.m[t+8]));return new EllipsoidSurface$$1(this.center,o,a,u)}containsPoint(t){return ts3dutils.eq0(this.implicitFunction()(t))}boundsFunction(){return(t,s)=>ts3dutils.between(t,0,PI)&&ts3dutils.between(s,-PI,PI)}volume(){return 4/3*Math.PI*this.f1.dot(this.f2.cross(this.f3))}loopContainsPoint(t,s){if(!this.containsPoint(s))return exports.PointVsFace.OUTSIDE;ts3dutils.assertVectors(s),ts3dutils.assert(Edge$$1.isLoop(t));const e=this.matrixInverse.transformPoint(s).xy(),i=new EllipseCurve$$1(this.center,this.f3,e.likeO()?this.f2:this.matrix.transformVector(e.unit()));return P3$$1.normalOnAnchor(this.f2.unit(),this.center).containsPoint(s)?t.some(t=>t.curve.containsPoint(s)&&ts3dutils.fuzzyBetween(t.curve.pointT(s),t.minT,t.maxT))?exports.PointVsFace.ON_EDGE:exports.PointVsFace.OUTSIDE:Surface$$1.loopContainsPointEllipse(t,s,i)}surfaceAreaApprox(){const t=this.mainAxes(),s=t.f1.length(),e=t.f2.length(),i=t.f3.length(),r=1.6075;return 4*PI*Math.pow((Math.pow(s*e,r)+Math.pow(e*i,r)+Math.pow(i*s,r))/3,1/r)}surfaceArea(){const t=this.mainAxes(),s=t.f1.length(),e=t.f2.length(),i=t.f3.length(),[r,n,o]=[s,e,i].sort(ts3dutils.MINUS);function a(t,s){if(sMath.pow(1-l*Math.pow(Math.sin(t),2),-.5),0,u),h=ts3dutils.gaussLegendreQuadrature24(t=>Math.pow(1-l*Math.pow(Math.sin(t),2),.5),0,u);return(2*PI*Math.pow(r,2)+2*PI*o*n/Math.sin(u))*(h*Math.pow(Math.sin(u),2)+c*Math.pow(Math.cos(u),2))}getSeamPlane(){const t=P3$$1.forAnchorAndPlaneVectors(this.center,this.f1,this.f3);return t.normal1.dot(this.f2)<0?t:t.flipped()}getExtremePoints(){return getExtremePointsHelper$$1.call(this,new EllipseCurve$$1(ts3dutils.V3.O,ts3dutils.V3.X,ts3dutils.V3.Z,-PI/2,PI/2))}pointFoot(t,s,e){if(console.log(t.sce),void 0===s||void 0===e){let i=this.matrixInverse.transformPoint(t).unit();i.y<0&&(i=i.negated()),({x:s,y:e}=EllipsoidSurface$$1.UNIT.uvP(i))}const i=this.dpdu(),r=this.dpdv(),[n,o]=ts3dutils.newtonIterate(([s,e])=>{const n=this.pUV(s,e);console.log([n,n.plus(i(s,e)),n,n.plus(r(s,e))].map(ts3dutils.toSource).join()+",");const o=this.pUV(s,e).to(t);return[o.dot(i(s,e)),o.dot(r(s,e))]},[s,e],8,void 0,.1);return new ts3dutils.V3(n,o,0)}implicitFunction(){return t=>{return(this.matrixInverse.transformPoint(t).length()-1)*this.normalDir}}didp(t){const s=this.matrixInverse.transformPoint(t);return this.pLCNormalWCMatrix.transformVector(s.unit())}static unitTransform4(t){1!==t.m[15]&&(t=t.divScalar(t.m[15]));const s=new ts3dutils.M4(1,0,0,0,0,1,0,0,0,0,1,0,-t.m[12],-t.m[13],-t.m[14],1),e=new ts3dutils.V3(t.m[12],t.m[13],t.m[14]),i=t.m[15],r=Math.pow(i,2)-e.squared();if(ts3dutils.lt(r,0))throw new Error("vanishing plane intersects unit sphere");const n=e.div(-r),o=(e.times(i*e.length()/(e.squared()*-r)),i/-r),a=1/sqrt(r),u=ts3dutils.M4.forSys(e.unit(),e.getPerpendicular().unit());return ts3dutils.M4.product(t,s,ts3dutils.M4.translate(n),u,ts3dutils.M4.scale(o,a,a),u.transposed())}}EllipsoidSurface$$1.UNIT=new EllipsoidSurface$$1(ts3dutils.V3.O,ts3dutils.V3.X,ts3dutils.V3.Y,ts3dutils.V3.Z),EllipsoidSurface$$1.prototype.uStep=PI/32,EllipsoidSurface$$1.prototype.vStep=PI/32;class PlaneSurface$$1 extends ParametricSurface$$1{constructor(t,s=t.normal1.getPerpendicular().unit(),e=t.normal1.cross(s).unit(),i=-100,r=100,n=-100,o=100){super(i,r,n,o),this.plane=t,this.right=s,this.up=e,ts3dutils.assertInst(P3$$1,t),ts3dutils.assert(this.right.cross(this.up).like(this.plane.normal1)),this.matrix=ts3dutils.M4.forSys(s,e,t.normal1,t.anchor)}toSource(t=(t=>t)){return ts3dutils.callsce.call(void 0,"new PlaneSurface",...this.getConstructorParameters())}static throughPoints(t,s,e){return new PlaneSurface$$1(P3$$1.throughPoints(t,s,e))}static forAnchorAndPlaneVectors(t,s,e,i,r,n,o){return new PlaneSurface$$1(P3$$1.forAnchorAndPlaneVectors(t,s,e),s,e,i,r,n,o)}isCoplanarTo(t){return ts3dutils.hasConstructor(t,PlaneSurface$$1)&&this.plane.isCoplanarToPlane(t.plane)}isTsForLine(t){return t.isTsWithPlane(this.plane)}like(t){return ts3dutils.hasConstructor(t,PlaneSurface$$1)&&this.plane.like(t.plane)}pUV(t,s){return this.matrix.transformPoint(new ts3dutils.V3(t,s,0))}implicitFunction(){return t=>this.plane.distanceToPointSigned(t)}isCurvesWithSurface(t){return t instanceof PlaneSurface$$1?this.isCurvesWithPlane(t.plane):super.isCurvesWithSurface(t)}isCurvesWithPlane(t){const s=this.plane.intersectionWithPlane(t);return s?[s]:[]}edgeLoopCCW(t){return ts3dutils.assert(Edge$$1.isLoop(t),"isLoop"),ts3dutils.isCCW(t.flatMap(t=>t.points()),this.plane.normal1)}loopContainsPoint(t,s){const e=this.right.plus(this.up.times(.123)).unit(),i=new L3$$1(s,e),r=e.cross(this.plane.normal1);return Surface$$1.loopContainsPointGeneral(t,s,i,r)}uvPFunc(){const t=this.matrix.inversed();return function(s){return t.transformPoint(s)}}pointFoot(t){return this.uvP(t)}normalP(t){return this.plane.normal1}containsPoint(t){return this.plane.containsPoint(t)}containsCurve(t){return t instanceof ImplicitCurve$$1?super.containsCurve(t):this.plane.containsCurve(t)}transform(t){return new PlaneSurface$$1(this.plane.transform(t))}transform4(t){return new PlaneSurface$$1(this.plane.transform(t))}flipped(){return new PlaneSurface$$1(this.plane.flipped(),this.right,this.up.negated())}getConstructorParameters(){return[this.plane,this.right,this.up,this.uMin,this.uMax,this.vMin,this.vMax]}dpdu(){return()=>this.right}dpdv(){return()=>this.up}didp(t){return this.plane.normal1}normalUV(){return this.plane.normal1}}PlaneSurface$$1.prototype.uStep=1e6,PlaneSurface$$1.prototype.vStep=1e6;class PointProjectedSurface$$1 extends ParametricSurface$$1{constructor(t,s,e,i=1,r=t.tMin,n=t.tMax,o=0,a=16){super(r,n,o,a),this.curve=t,this.apex=s,this.curvePlane=e,this.normalDir=i,ts3dutils.assertInst(Curve$$1,t),ts3dutils.assert(!(t instanceof L3$$1),"use PlaneSurface instead"),ts3dutils.assert(!(t instanceof EllipseCurve$$1),"use ConicSurface instead"),ts3dutils.assert(!(t instanceof ImplicitCurve$$1),"this just seems like a terrible idea"),ts3dutils.assert(new PlaneSurface$$1(e).containsCurve(t)),ts3dutils.assertVectors(s),ts3dutils.assert(0<=o),this.planeProjectionMatrix=ts3dutils.M4.projectPlanePoint(s,e),this.uStep=t.tIncrement}pointFoot(t,s,e){void 0!==s&&void 0!==e||(void 0===s&&(s=t.like(this.apex)?0:this.curve.closestTToPoint(this.planeProjectionMatrix.transformPoint(t))*this.normalDir),void 0===e&&(e=ts3dutils.V3.inverseLerp(this.apex,this.curve.at(s),t)));const{0:i,1:r}=ts3dutils.newtonIterate(([s,e])=>{const i=this.pST(s,e).to(t);return[this.dpds()(s,e).dot(i),this.dpdt()(s).dot(i)]},[s,e]);return new ts3dutils.V3(i,r,0)}getConstructorParameters(){return[this.curve,this.apex,this.curvePlane,this.normalDir,this.sMin,this.sMax,this.tMin,this.tMax]}static unitISLineTs(t,s){const{x:e,y:i,z:r}=t,{x:n,y:o,z:a}=s,u=n*n+o*o-a*a,l=2*(e*n+i*o-r*a),c=e*e+i*i-r*r;return ts3dutils.pqFormula(l/u,c/u).filter(t=>0t.tOther)}isCoplanarTo(t){return this===t||!!(t instanceof PointProjectedSurface$$1&&this.apex.like(t.apex))&&this.containsCurve(t.curve)}containsLine(t){if(this.curvePlane.isParallelToLine(t))return!1;if(!t.containsPoint(this.apex))return!1;const s=this.curvePlane.intersectionWithLine(t);return this.curve.containsPoint(s)}containsCurve(t){if(t instanceof L3$$1)return this.containsLine(t);if(t instanceof ImplicitCurve$$1)return super.containsCurve(t);{const s=t.transform(this.planeProjectionMatrix);return this.curve.isColinearTo(s)}}transform(t){return new PointProjectedSurface$$1(this.curve.transform(t),t.transformPoint(this.apex),this.curvePlane.transform(t),(t.isMirroring()?-1:1)*this.normalDir,this.sMin,this.sMax,this.tMin,this.tMax)}flipped(){return new PointProjectedSurface$$1(this.curve,this.apex,this.curvePlane,-this.normalDir,-this.sMax,-this.sMin,this.tMin,this.tMax)}normalSTFunc(){const t=this.dpdt();return(s,e)=>this.curve.tangentAt(s*this.normalDir).times(this.normalDir).cross(t(s)).unit()}pSTFunc(){return(t,s)=>this.apex.lerp(this.curve.at(t*this.normalDir),s)}dpds(){return(t,s)=>this.curve.tangentAt(t*this.normalDir).times(s*this.normalDir)}dpdt(){return t=>this.apex.to(this.curve.at(t*this.normalDir))}containsPoint(t){return this.apex.like(t)||this.curve.containsPoint(this.planeProjectionMatrix.transformPoint(t))}stP(t){const s=t.like(this.apex)?0:this.curve.pointT(this.planeProjectionMatrix.transformPoint(t)),e=ts3dutils.V3.inverseLerp(this.apex,this.curve.at(s),t);return new ts3dutils.V3(s*this.normalDir,e,0)}isCurvesWithSurface(t){return t instanceof PlaneSurface$$1?this.isCurvesWithPlane(t.plane):ImplicitSurface$$1.is(t)?ParametricSurface$$1.isCurvesParametricImplicitSurface(this,t,.1,.1/this.curvePlane.distanceToPoint(this.apex),.02):super.isCurvesWithSurface(t)}isCurvesWithPlane(t){return t.containsPoint(this.apex)?t.isParallelToPlane(this.curvePlane)?[]:this.curve.isTsWithPlane(t).map(t=>L3$$1.throughPoints(this.apex,this.curve.at(t))):[this.curve.transform(ts3dutils.M4.projectPlanePoint(this.apex,t))]}}PointProjectedSurface$$1.prototype.vStep=256;class NURBSSurface$$1 extends ParametricSurface$$1{constructor(t,s,e,i,r,n=s[i],o=s[s.length-i-1],a=e[r],u=e[e.length-r-1]){super(n,o,a,u),this.points=t,this.knotsU=s,this.knotsV=e,this.degreeU=i,this.degreeV=r;const l=s.length-1-i,c=e.length-1-r;ts3dutils.assert(l*c==t.length),ts3dutils.assert(i<=r,"degreeU <= degreeV")}getConstructorParameters(){return[this.points,this.knotsU,this.knotsV,this.degreeU,this.degreeV,this.sMin,this.sMax,this.tMin,this.tMax]}transform(t){return this.transform4(t)}transform4(t){return new NURBSSurface$$1(this.points.map(s=>t.timesVector(s)),this.knotsU,this.knotsV,this.degreeU,this.degreeV,this.sMin,this.sMax,this.tMin,this.tMax)}pST(t,s){return this.isoparametricU(t).at(s)}dpds(){return(t,s)=>this.isoparametricV(s).tangentAt(t)}dpdt(){return(t,s)=>this.isoparametricU(t).tangentAt(s)}normalST(t,s){return this.dpds()(t,s).cross(this.dpdt()(t,s)).unit()}isoparametricU(t){const s=this.knotsU.length-1-this.degreeU,e=this.knotsV.length-1-this.degreeV;return new NURBS$$1(ts3dutils.arrayFromFunction(e,e=>deBoor(this.points.slice(e*s,(e+1)*s),this.degreeU,this.knotsU,t)),this.degreeV,this.knotsV,this.tMin,this.tMax)}isoparametricV(t){const s=this.knotsU.length-1-this.degreeU;this.knotsV.length,this.degreeV;return new NURBS$$1(ts3dutils.arrayFromFunction(s,e=>deBoor(this.points.sliceStep(e,this.points.length,s,1),this.degreeV,this.knotsV,t)),this.degreeU,this.knotsU,this.sMin,this.sMax)}debugInfo(){const t=this.knotsU.length-1-this.degreeU,s=this.knotsV.length-1-this.degreeV,e=[];for(let i=0;it.p3()),lines:e}}}function getInterval(t,s,e){for(let i=t;i=s[i]&&e<=s[i+1])return i;throw new Error(e+" "+s)}function deBoor(t,s,e,i){const r=getInterval(s,e,i),n=ts3dutils.Vector.pack(t,new Float64Array(4*t.length));for(let t=1;t<=s;t++)for(let o=r;o>r-s-1+t;o--){const r=(i-e[o])/(e[o+s+1-t]-e[o]);for(let t=0;t<4;t++)n[4*o+t]=(1-r)*n[4*(o-1)+t]+r*n[4*o+t]}return new ts3dutils.Vector(n.slice(4*r,4*r+4))}NURBSSurface$$1.prototype.uStep=1/8,NURBSSurface$$1.prototype.vStep=1/8;const ZDirVolumeVisitor$$1={[ConicSurface$$1.name](t){console.log(this);const s=this.dpdu(),e=this.dpdv(),i=t.map(t=>{const i=t.curve;if(i instanceof EllipseCurve$$1||i instanceof HyperbolaCurve$$1||i instanceof ParabolaCurve$$1){const r=t=>{const r=i.at(t),n=i.tangentAt(t),o=this.uvP(r),a=-ts3dutils.M4.forSys(s(o.x,o.y),e(o.x)).inversed().transformVector(n).x,u=Math.pow(o.y,3)/3*(this.pUV(o.x,1).z-this.center.z)+Math.pow(o.y,2)/2*this.center.z;return s(o.x,u).cross(e(o.x)).z*a};return ts3dutils.glqInSteps(r,t.aT,t.bT,1)}if(i instanceof L3$$1)return 0;throw new Error}).sum(),r=t.map(t=>{const i=t.curve;if(i instanceof EllipseCurve$$1||i instanceof HyperbolaCurve$$1||i instanceof ParabolaCurve$$1){return glqV3$$1(t=>{const r=i.at(t),n=i.tangentAt(t),o=this.uvP(r),a=this.pUV(o.x,1).minus(this.center),u=ts3dutils.V3.add(a.times(.25*Math.pow(o.y,4)*a.z+1/3*Math.pow(o.y,3)*this.center.z),this.center.times(1/3*Math.pow(o.y,3)*a.z+.5*Math.pow(o.y,2)*this.center.z)).times(s(o.x,1).cross(e(o.x)).z),l=-ts3dutils.M4.forSys(s(o.x,o.y),e(o.x)).inversed().transformVector(n).x;return u.times(l)},t.aT,t.bT)}if(i instanceof L3$$1)return ts3dutils.V3.O;throw new Error});return{volume:i,centroid:ts3dutils.V3.add(...r).schur(new ts3dutils.V3(1,1,.5)).div(i)}},[PlaneSurface$$1.name](t){const s=this.right,e=this.up,i=this.plane.anchor;return ts3dutils.assert(s.hasLength(1)),ts3dutils.assert(e.hasLength(1)),ts3dutils.assert(s.isPerpendicularTo(e)),mergeVolumeAndCentroidZX2Parts(t.map(t=>{const r=t.curve;if(r instanceof L3$$1){function n(t,s,e){const i=s.minus(t),r=e.minus(t),n=i.cross(r);return[ts3dutils.V3.add(t,s,e).div(3).z*n.z/2,ts3dutils.V3.add(t.times(2*t.z+s.z+e.z),s.times(t.z+2*s.z+e.z),e.times(t.z+s.z+2*e.z)).times(n.z)]}const e=t.a,i=t.b,r=e.dot(s),o=i.dot(s),a=this.pUV(r,0),u=this.pUV(o,0),[l,c]=n(e,i,a),[h,d]=n(u,a,i);return[l+h,c.plus(d).div(24)]}if(r instanceof ImplicitCurve$$1)throw new Error;{const n=t=>{const n=r.at(t),o=n.dot(s),a=n.dot(e),u=a*i.z+o*a*s.z+.5*Math.pow(a,2)*e.z,l=-r.tangentAt(t).dot(s);return[u*l,...ts3dutils.V3.add(i.times(u),s.times(i.z*o*a+s.z*Math.pow(o,2)*a+.5*o*Math.pow(a,2)*e.z),e.times(.5*i.z*Math.pow(a,2)+.5*s.z*o*Math.pow(a,2)+1/3*Math.pow(a,3)*e.z)).times(l)]},[o,a,u,l]=glqArray$$1(n,t.aT,t.bT,4);return[o*this.plane.normal1.z,new ts3dutils.V3(a,u,l).times(this.plane.normal1.z)]}}))},[ParametricSurface$$1.name](t){const s=this.dpdu(),e=this.dpdv();return mergeVolumeAndCentroidZX2Parts(t.map(t=>{const i=t.curve;if(i instanceof ImplicitCurve$$1)throw new Error;{const r=t=>{const r=i.at(t),n=i.tangentAt(t),o=this.uvP(r),a=ts3dutils.glqInSteps(t=>{const i=this.pUV(o.x,t),r=s(o.x,t).cross(e(o.x,t));return i.z*r.z},0,o.y,1),u=-ts3dutils.M4.forSys(s(o.x,o.y),e(o.x,o.y)).inversed().transformVector(n).x;return[a*u,...glqV3$$1(t=>{const i=this.pUV(o.x,t),r=s(o.x,t).cross(e(o.x,t));return i.times(i.z*r.z)},0,o.y).times(u).toArray()]},[n,o,a,u]=glqArray$$1(r,t.aT,t.bT,4);return[n,new ts3dutils.V3(o,a,u)]}}))},[ProjectedCurveSurface$$1.name](t){if(ts3dutils.V3.Z.cross(this.dir).likeO())return{volume:0,centroid:ts3dutils.V3.O};const s=this.dir.toLength(Math.sign(this.dir.z)||1),e=ts3dutils.V3.Z.cross(s).unit(),i=s.rejectedFrom(ts3dutils.V3.Z).unit();return mergeVolumeAndCentroidZX2Parts(t.map(t=>{if(t.curve instanceof L3$$1)return[0,ts3dutils.V3.O];if(t.curve instanceof ImplicitCurve$$1)return[0,ts3dutils.V3.O];{const r=r=>{const n=t.curve.at(r),o=t.curve.tangentAt(r),a=n.rejectedFrom1(s),u=n.z*a.to(n).dot(i)/2+a.z*a.to(n).dot(i)/2,l=ts3dutils.V3.add(n.xy(),a,n).times(n.z*a.to(n).dot(i)/2/3),c=ts3dutils.V3.add(n.xy(),a,a.xy()).times(a.z*a.to(n).dot(i)/2/3),h=o.dot(e);return[u*h,...l.plus(c).times(h).schur(ts3dutils.V(1,1,2))]},[n,o,a,u]=glqArray$$1(r,t.aT,t.bT,4);return[n,new ts3dutils.V3(o,a,u)]}}))},[RotatedCurveSurface$$1.name](t){const s=this.dpdu(),e=this.dpdv(),i=t.map(t=>{const i=t.curve;return ts3dutils.gaussLegendreQuadrature24(t=>{const r=i.at(t),n=i.tangentAt(t),o=this.uvP(r),a=this.matrixInverse.transformPoint(r),u=this instanceof RotatedCurveSurface$$1?this.curve.tangentAt(o.y):ts3dutils.V(-a.z,0,a.lengthXY()),l=a.lengthXY(),c=a.z,h=u.x,d=u.z,p=this.matrix.X.z*l,f=this.matrix.Y.z*l,m=this.matrix.Z.z*c+this.matrix.O.z,$=(this.matrix.X.x*this.matrix.Y.y-this.matrix.X.y*this.matrix.Y.x)*l*h,g=(this.matrix.Y.x*this.matrix.X.y-this.matrix.Y.y*this.matrix.X.x)*l*h,v=(this.matrix.X.x*this.matrix.X.y-this.matrix.X.y*this.matrix.X.x)*l*h,P=(this.matrix.Y.x*this.matrix.Y.y-this.matrix.Y.y*this.matrix.Y.x)*l*h,x=(this.matrix.Y.x*this.matrix.Z.y-this.matrix.Y.y*this.matrix.Z.x)*l*d,C=(this.matrix.X.x*this.matrix.Z.y-this.matrix.X.y*this.matrix.Z.x)*l*d,M=ts3dutils.M4.forSys(s(o.x,o.y),e(o.x,o.y)).inversed().transformVector(n).y;return(t=>(6*(m*(-$+g)+p*x-f*C)*t+3*(3*f*$-f*g+p*(v-P)+4*m*C)*cos(t)+3*(3*p*g-p*$-f*(v-P)+4*m*x)*sin(t)+3*(p*C-f*x+m*(v-P))*cos(2*t)+3*(p*x+f*C+m*($+g))*sin(2*t)+(p*(v-P)-f*($+g))*cos(3*t)+(p*($+g)+f*(v-P))*sin(3*t))/12)(o.x)*M},t.aT,t.bT)}).sum(),r=t.map(t=>{return glqV3$$1(i=>{const r=t.curve,n=r.at(i),o=r.tangentAt(i),a=this.uvP(n),u=glqV3$$1(t=>{const i=this.pUV(t,a.y),r=s(t,a.y).cross(e(t,a.y));return i.times(i.z*r.z)},0,a.x),l=ts3dutils.M4.forSys(s(a.x,a.y),e(a.x,a.y)).inversed().transformVector(o).y;return u.times(l)},t.aT,t.bT)});return{volume:i,centroid:ts3dutils.V3.add(...r).schur(new ts3dutils.V3(1,1,.5)).div(i)}}};function glqV3$$1(t,s,e){return ts3dutils.gaussLegendre24Xs.reduce((i,r,n)=>{const o=s+(r+1)/2*(e-s);return i.plus(t(o).times(ts3dutils.gaussLegendre24Weights[n]))},ts3dutils.V3.O).times((e-s)/2)}function glqArray$$1(t,s,e,i=3){const r=new Array(i).fill(0);for(let n=0;n<24;n++){const o=t(s+(ts3dutils.gaussLegendre24Xs[n]+1)/2*(e-s));for(let t=0;tt+s,0);return{volume:s,centroid:ts3dutils.V3.add(...t.map(([,t])=>t)).schur(new ts3dutils.V3(1,1,.5)).div(s)}}ZDirVolumeVisitor$$1[EllipsoidSurface$$1.name]=ZDirVolumeVisitor$$1[RotatedCurveSurface$$1.name];const CalculateAreaVisitor$$1={[ConicSurface$$1.name](t){const s=this.dpdu(),e=this.dpdv();return t.map(t=>{if(t.curve instanceof EllipseCurve$$1||t.curve instanceof HyperbolaCurve$$1||t.curve instanceof ParabolaCurve$$1){const i=i=>{const r=t.curve.at(i),n=t.tangentAt(i),o=this.uvP(r),a=-ts3dutils.M4.forSys(s(o.x,o.y),e(o.x)).inversed().transformVector(n).x;return s(o.x,Math.pow(o.y,2)/2).cross(e(o.x)).length()*a};return ts3dutils.glqInSteps(i,t.aT,t.bT,1)}if(t.curve instanceof L3$$1)return 0;throw new Error}).sum()*this.normalDir},[PlaneSurface$$1.name](t){let s=0;const e=this.right,i=this.up;for(const n of t){let t;const o=n.curve;if(o instanceof L3$$1)t=(n.a.dot(i)+n.b.dot(i))/2*n.b.to(n.a).dot(e);else if(o instanceof EllipseCurve$$1){const{f1:s,f2:a,center:u}=o,l=i.dot(s),c=i.dot(a),h=i.dot(u),d=e.dot(s),p=e.dot(a);function r(t){return.25*(2*(-c*d+l*p)*t+4*h*d*cos(t)+4*h*p*sin(t)+(l*d-c*p)*cos(2*t)+(c*d+l*p)*sin(2*t))}t=-(r(n.bT)-r(n.aT))}else{if(o instanceof ImplicitCurve$$1)throw new Error("implement for implicitCurve");{const s=i;ts3dutils.assertf(()=>s.hasLength(1));const r=t=>{const s=o.at(t),r=o.tangentAt(t);return e.dot(r)*i.dot(s)};t=ts3dutils.glqInSteps(r,n.aT,n.bT,3)}}s+=t}return ts3dutils.assert(isFinite(s)),s},[RotatedCurveSurface$$1.name](t,s=!0){const e=this.matrix.X,i=this.matrix.Y,r=this.matrix.Z,n=ts3dutils.eq(e.length(),i.length())&&e.isPerpendicularTo(i)&&i.isPerpendicularTo(r)&&r.isPerpendicularTo(e);return t.map((t,s)=>{console.log("edge",s,t.sce);const e=t.curve;if(t.curve instanceof ImplicitCurve$$1)throw new Error;if(n){const s=t=>{const s=e.at(t),i=e.tangentAt(t),r=this.matrixInverse.transformPoint(s),{x:n,y:o}=this.uvP(s);return n*this.matrix.transformVector(r.xy()).length()*this.dpdv()(n,o).unit().dot(i)};return ts3dutils.glqInSteps(s,t.aT,t.bT,1)}{const s=this.dpdu(),i=this.dpdv(),r=t=>{const r=e.at(t),n=e.tangentAt(t),o=this.uvP(r),a=ts3dutils.M4.forSys(s(o.x,o.y),i(o.x,o.y)).inversed().transformVector(n).y;return ts3dutils.glqInSteps(t=>s(t,o.y).cross(i(t,o.y)).length(),0,o.x,1)*a};return ts3dutils.glqInSteps(r,t.aT,t.bT,1)}}).sum()},[ProjectedCurveSurface$$1.name](t){const s=this.dir.unit(),e=t.map(t=>{if(t.curve instanceof L3$$1)return 0;if(t.curve instanceof ImplicitCurve$$1){const{points:e,tangents:i}=t.curve,r=t.minT,n=t.maxT;let o=0;const a=ceil(r+ts3dutils.NLA_PRECISION),u=floor(n-ts3dutils.NLA_PRECISION);for(let t=a;t<=u;t++){const r=e[t],n=i[t],a=this.normalP(r).cross(s).unit().dot(n);o+=r.dot(s)*a}const l=e=>{const i=t.curve.at(e),r=t.curve.tangentAt(e),n=this.normalP(i).cross(s).unit().dot(r);return i.dot(s)*n};return o+=l(r)*(a-r-.5),(o+=l(n)*(n-u-.5))*sign(t.deltaT())}{const e=e=>{const i=t.curve.at(e),r=t.tangentAt(e).rejected1Length(s);return i.dot(s)*r},i=ts3dutils.glqInSteps(e,t.aT,t.bT,1),r=Math.sign(this.normalP(t.a).cross(this.dir).dot(t.curve.tangentAt(t.aT)));return ts3dutils.assert(0!==r),i*r}}).sum();return console.log("totalArea",e),e}};function projectCurve$$1(t,s,e){if(t instanceof L3$$1){const i=s.cross(t.dir1).toLength(e?-1:1);return new PlaneSurface$$1(P3$$1.normalOnAnchor(i,t.anchor))}if(t instanceof EllipseCurve$$1){const i=e?s:s.negated();return new CylinderSurface$$1(t,i.unit(),void 0,void 0)}if(t instanceof BezierCurve$$1||t instanceof XiEtaCurve$$1){const i=s.times(e?1:-1);return new ProjectedCurveSurface$$1(t,i,void 0,void 0,e?0:-1,e?1:0)}throw new Error}function projectPointCurve$$1(t,s=t.tMin,e=t.tMax,i,r){if(t instanceof L3$$1){const r=t.anchor.to(i).rejectedFrom(t.dir1);return PlaneSurface$$1.forAnchorAndPlaneVectors(t.anchor,t.dir1,r.unit(),s,e,0,r.length())}if(t instanceof EllipseCurve$$1){const n=-1*(r?-1:1);return new ConicSurface$$1(i,t.f1.times(n),t.f2,i.to(t.center),s,e,0,1)}throw new Error("projectPointCurve not implemented for "+t.constructor.name)}function rotateCurve$$1(t,s=t.tMin,e=t.tMax,i,r){if(ts3dutils.assertf(()=>new PlaneSurface$$1(P3$$1.ZX).containsCurve(t)),t instanceof L3$$1){if(t.dir1.isParallelTo(ts3dutils.V3.Z)){if(ts3dutils.eq0(t.anchor.x))return;const n=new EllipseCurve$$1(ts3dutils.V3.O,t.anchor.xy(),t.anchor.xy().getPerpendicular(),0,i),o=(t.dir1.z>0?-1:1)*(r?-1:1),[a,u]=[t.at(s).z*o,t.at(e).z*o].sort(ts3dutils.MINUS);return new CylinderSurface$$1(n,ts3dutils.V3.Z.times(o),0,i,a,u)}if(t.at(s).xy().dot(t.dir1)*t.at(e).xy().dot(t.dir1)<0)throw new Error("line cannot cross the Z axis in the [tMin, tMax] interval, as conic surfaces cannot have an hourglass shape.");if(t.dir1.isPerpendicularTo(ts3dutils.V3.Z)){const i=(t.at(ts3dutils.lerp(s,e,.5)).dot(t.dir1)>0?1:-1)*(r?-1:1);return new PlaneSurface$$1(new P3$$1(ts3dutils.V3.Z.times(i),t.anchor.z*i))}{const n=t.at(s),o=t.at(e),a=n.z-n.x*(o.z-n.z)/(o.x-n.x),u=new ts3dutils.V3(0,0,a),l=-(n.x>o.x?-1:1)*(r?-1:1),c=new ConicSurface$$1(u,new ts3dutils.V3(t.dir1.lengthXY(),0,0),new ts3dutils.V3(0,t.dir1.lengthXY(),0),new ts3dutils.V3(0,0,(n.x>o.x?-1:1)*t.dir1.z),0,i,0,1);return l>0?c:c.flipped()}}if(t instanceof EllipseCurve$$1){const i=t.at(s),n=t.at(e),o=t.rightAngled(),a=o.f1.isPerpendicularTo(ts3dutils.V3.Z),u=o.f2.isPerpendicularTo(ts3dutils.V3.Z);if(L3$$1.Z.containsPoint(o.center)&&(a||u)){r=r==i.z>n.z;let t=o.f1.length(),s=o.f2.length();return o.f1.isParallelTo(ts3dutils.V3.Z)&&([t,s]=[s,t]),EllipsoidSurface$$1.forABC(t,(r?-1:1)*t,s,o.center)}return new RotatedCurveSurface$$1(t,ts3dutils.M4.IDENTITY,s,e)}throw new Error}CalculateAreaVisitor$$1[EllipsoidSurface$$1.name]=CalculateAreaVisitor$$1[RotatedCurveSurface$$1.name],function(t){function s(s,e=P3$$1.XY,i=ts3dutils.V3.Z,r="extrude"+getGlobalId$$1(),n,o){s=a(s),ts3dutils.assertf(()=>Edge$$1.isLoop(s));const u=new Map,l=new PlaneSurface$$1(e),c=ts3dutils.M4.translate(i),h=s.map(t=>t.transform(c,"top")),d=s.length,p=o&&o.extrudeBottom(l,s),f=new PlaneFace$$1(l,s,[],r+"Bottom",p),m=h.map(t=>t.flipped()).reverse(),$=new PlaneSurface$$1(e.flipped().translated(i)),g=o&&o.extrudeBottom($,m),v=new PlaneFace$$1($,m,[],r+"Top",g);s.forEach(s=>t.registerVertexName(u,s.name+"A",s.a)),m.forEach(s=>t.registerVertexName(u,s.name+"A",s.a));const P=ts3dutils.arrayFromFunction(d,t=>StraightEdge$$1.throughPoints(s[t].a,h[t].a,r+"Rib"+t)),x=s.map((t,e)=>{const n=r+"Wall"+e,a=(e+1)%d,u=[s[e].flipped(),P[e],h[e],P[a].flipped()],l=projectCurve$$1(t.curve,i,t.reversed),c=o&&o.extrudeWall(e,l,u);return Face$$1.create(l,u,void 0,n,c)});return x.push(f,v),n=n||ts3dutils.callsce("B2T.extrudeEdges",s,e,i,r),new BRep$$1(x,e.normal1.dot(i)>0,n,u)}function e(t=1,s="sphere"+getGlobalId$$1(),e=ts3dutils.TAU){const r=PCurveEdge$$1.create(new EllipseCurve$$1(ts3dutils.V3.O,new ts3dutils.V3(0,0,-t),new ts3dutils.V3(t,0,0)),new ts3dutils.V3(0,0,-t),new ts3dutils.V3(0,0,t),0,PI,void 0,new ts3dutils.V3(t,0,0),new ts3dutils.V3(-t,0,0)),n=ts3dutils.callsce("B2T.sphere",t,s,e);return i([StraightEdge$$1.throughPoints(r.b,r.a),r],e,s,n)}function i(t,s,e="rotateEdges"+getGlobalId$$1(),i,r){ts3dutils.assert(t.every(t=>new PlaneSurface$$1(P3$$1.ZX).containsCurve(t.curve))),ts3dutils.assert(!ts3dutils.eq(PI,s)||PI==s),ts3dutils.assertf(()=>ts3dutils.lt(0,s)&&ts3dutils.le(s,ts3dutils.TAU)),s=ts3dutils.snap(s,ts3dutils.TAU),ts3dutils.assertf(()=>Edge$$1.isLoop(t));const n=new PlaneSurface$$1(P3$$1.ZX.flipped()).edgeLoopCCW(t)?new PlaneSurface$$1(P3$$1.ZX.flipped()):new PlaneSurface$$1(P3$$1.ZX),o=!ts3dutils.eq(s,2*PI),a=t.map(t=>{const s=t.a,e=s.lengthXY();if(!ts3dutils.eq0(e))return new EllipseCurve$$1(ts3dutils.V(0,0,s.z),ts3dutils.V(e,0,0),ts3dutils.V(0,e,0))}),u=t.map((t,s)=>{const e=rotateCurve$$1(t.curve,t.minT,t.maxT,PI,t.deltaT()>0),i=ts3dutils.lerp(t.aT,t.bT,.5);return e&&ts3dutils.assert(t.tangentAt(i).cross(ts3dutils.V3.Y).dot(e.normalP(t.curve.at(i)))<0),e});let l,c=t;const h=[];for(let i=0;it.transform(d));const p=ts3dutils.arrayFromFunction(t.length,t=>{const s=c[t].a,r=s.lengthXY(),u=l[t].a;if(!ts3dutils.eq0(r)){const r=0===i?a[t]:a[t].rotateZ(i);return new PCurveEdge$$1(r,s,u,n,o,void 0,r.tangentAt(n),r.tangentAt(o),e+"rib"+t)}});for(let s=0;st),d=0===i?u[s]:u[s].rotateZ(i),f=r&&r.extrudeWall(s,d,a,void 0);h.push(Face$$1.create(d,a,void 0,e+"Wall"+s,f))}c=l}if(o){const i=Edge$$1.reversePath(l),o=r&&r.rotationStart(n,t,void 0),a=r&&r.rotationEnd(n.flipped().rotateZ(s),i,void 0);h.push(new PlaneFace$$1(n,t,void 0,e+"start",o),new PlaneFace$$1(n.flipped().rotateZ(s),i,void 0,e+"end",a))}const d=new PlaneSurface$$1(P3$$1.ZX).edgeLoopCCW(t);return new BRep$$1(h,d,i)}t.box=function(s=1,e=1,i=1,r="box"+getGlobalId$$1()){ts3dutils.assertNumbers(s,e,i),ts3dutils.assert("string"==typeof r);const n=[new ts3dutils.V3(0,0,0),new ts3dutils.V3(0,e,0),new ts3dutils.V3(s,e,0),new ts3dutils.V3(s,0,0)],o=ts3dutils.callsce("B2T.box",s,e,i,r);return t.extrudeVertices(n,P3$$1.XY.flipped(),new ts3dutils.V3(0,0,i),r,o)},t.puckman=function(s,e,i,r="puckman"+getGlobalId$$1()){ts3dutils.assertf(()=>ts3dutils.lt(0,s)),ts3dutils.assertf(()=>ts3dutils.lt(0,e)&&ts3dutils.le(e,ts3dutils.TAU)),ts3dutils.assertf(()=>ts3dutils.lt(0,i));const n=StraightEdge$$1.chain([ts3dutils.V3.O,new ts3dutils.V3(s,0,0),new ts3dutils.V3(s,0,i),new ts3dutils.V3(0,0,i)],!0);return t.rotateEdges(n,e,r)},t.registerVertexName=function(t,s,e){Array.from(t.keys()).some(t=>t.like(e))||t.set(e,s)},t.extrudeEdges=s,t.cylinder=function(t=1,s=1,e=ts3dutils.TAU,r="cylinder"+getGlobalId$$1()){const n=[new ts3dutils.V3(0,0,0),new ts3dutils.V3(t,0,0),new ts3dutils.V3(t,0,s),new ts3dutils.V3(0,0,s)];return i(StraightEdge$$1.chain(n,!0),e,r)},t.cone=function(t=1,s=1,e=ts3dutils.TAU,r="cone"+getGlobalId$$1()){const n=[new ts3dutils.V3(0,0,0),new ts3dutils.V3(t,0,s),new ts3dutils.V3(0,0,s)];return i(StraightEdge$$1.chain(n,!0),e,r)},t.sphere=e,t.menger=function(s=2,e="menger"+getGlobalId$$1()){let i=t.box(1,1,1);if(0==s)return i;const r=t.box(1/3,1/3,2).translate(1/3,1/3,-.5).flipped();function n(t,s){if(i=i.and(r.transform(s)),t>1){const e=s.times(ts3dutils.M4.scale(1/3,1/3,1));for(let s=0;s<9;s++)4!=s&&n(t-1,e.times(ts3dutils.M4.translate(s%3,s/3|0,0)))}}return n(s,ts3dutils.M4.IDENTITY),n(s,ts3dutils.M4.YZX),n(s,ts3dutils.M4.ZXY),i},t.menger2=function(s=2,e="menger"+getGlobalId$$1()){if(0==s)return t.box(1,1,1);const i=t.box(1/3,1/3,2).translate(1/3,1/3,-.5).flipped(),r=[];!function t(s,e){if(r.push(...i.transform(e).faces),s>1){const i=e.times(ts3dutils.M4.scale(1/3,1/3,1));for(let e=0;e<9;e++)4!=e&&t(s-1,i.times(ts3dutils.M4.translate(e%3,e/3|0,0)))}}(s,ts3dutils.M4.IDENTITY);const n=new BRep$$1(r,!0);return t.box().and(n).and(n.transform(ts3dutils.M4.YZX)).and(n.transform(ts3dutils.M4.ZXY))},t.torus=function(s,e,i=ts3dutils.TAU,r="torus"+getGlobalId$$1()){ts3dutils.assertNumbers(s,e,i),ts3dutils.assertf(()=>e>s);const n=[EllipseCurve$$1.semicircle(s,new ts3dutils.V3(e,0,0)),EllipseCurve$$1.semicircle(-s,new ts3dutils.V3(e,0,0))].map(t=>PCurveEdge$$1.forCurveAndTs(t,0,Math.PI).rotateX(PI/2));return t.rotateEdges(n,i,r)},t.rotateEdges=i,t.quaffle=function(){const s=t.sphere(1).translate(0,1.7).flipped(),e=new BRep$$1(t.TETRAHEDRON_VERTICES.flatMap(t=>s.rotateAB(ts3dutils.V3.Y,t).faces),!1);return t.sphere().and(e)},t.extrudeFace=function(t,e){return new BRep$$1(s(t.contour,t.surface.plane,e).faces.slice(0,-2).concat(t,t.translate(e.x,e.y,e.z).flipped(),t.holes.flatMap(i=>s(i,t.surface.plane.flipped(),e).faces.slice(0,-2))),!1)},t.loadFonts=function(){return n("fonts/FiraSansMedium.woff").then(s=>t.defaultFont=s)};const r=new Map;function n(t){return new Promise(function(s,e){const i=r.get(t);i?s(i):opentype.load(t,function(i,n){i?e(i):(r.set(t,n),s(n))})})}function o(s,e,i=1,r=t.defaultFont){const n=[];r.getPath(s,0,0,e).commands.forEach(t=>{"M"==t.type&&n.push([]),n.last.push(t)});const o=n.map(t=>{const s=new opentype.Path;s.commands=t;const e=Edge$$1.reversePath(Edge$$1.pathFromSVG(s.toPathData(13))).map(t=>t.mirrorY());return ts3dutils.assert(Edge$$1.isLoop(e)),e}),a=Face$$1.assembleFacesFromLoops(o,new PlaneSurface$$1(P3$$1.XY),PlaneFace$$1),u=ts3dutils.callsce("B2T.text",s,e,i);return BRep$$1.join(a.map(s=>t.extrudeFace(s,ts3dutils.V(0,0,-i))),u)}function a(t){return t.flatMap(t=>{const s=t.curve;if(s instanceof EllipseCurve$$1&&s.tMin===-PI&&s.tMax===PI){return(t.minT<0&&t.maxT>0?t.split(0):[t]).map(t=>t.minT>=0?Edge$$1.create(new EllipseCurve$$1(s.center,s.f1,s.f2,max(0,s.tMin),s.tMax),t.a,t.b,t.aT,t.bT,void 0,t.aDir,t.bDir,t.name):Edge$$1.create(new EllipseCurve$$1(s.center,s.f1.negated(),s.f2.negated(),s.tMin+PI,min(PI,s.tMax+PI)),t.a,t.b,t.aT+PI,t.bT+PI,void 0,t.aDir,t.bDir,t.name))}return s instanceof BezierCurve$$1&&t.a.like(t.b)?t.split(ts3dutils.lerp(t.aT,t.bT,.5)):t})}t.loadFont=n,t.loadFontsAsync=function(s){t.defaultFont?s():opentype.load("fonts/FiraSansMedium.woff",function(e,i){if(e)throw new Error("Could not load font: "+e);t.defaultFont=i,s()})},t.text=o,t.minorityReport=function(){const s=t.sphere(),e=t.text("LEO CROW",64,128).scale(.1/32).translate(-.5,-.05,1.2).flipped(),i=t.sphere(.98);return s.and(e).plus(i)},t.whatever=function(){const t=d(),s=BRep$$1.join(t.faces.map((t,s)=>{const e=o(""+(s+1),.4,-2),i=t.contour.map(t=>t.a).reduce((t,s)=>t.plus(s),ts3dutils.V3.O).div(3),r=ts3dutils.M4.forSys(t.contour[0].aDir,i.cross(t.contour[0].aDir),i.unit(),i);return e.transform(r.times(ts3dutils.M4.translate(-e.getAABB().size().x/2,-.1,-.04)))})),i=e(.9);return t.and(i).and(s)},t.whatever3=function(){const s=t.torus(1,2);return t.box(5,5,2).translate(-2.5,-2.5).minus(s)},t.d20=function(){const t=d(),s=BRep$$1.join(t.faces.map((t,s)=>{const e=o(""+(s+1),.4,-2),i=t.contour.map(t=>t.a).reduce((t,s)=>t.plus(s),ts3dutils.V3.O).div(3),r=ts3dutils.M4.forSys(t.contour[0].aDir,i.cross(t.contour[0].aDir),i.unit(),i);return e.transform(r.times(ts3dutils.M4.translate(-e.getAABB().size().x/2,-.1,-.04)))})),i=e(.9);return t.and(i).and(s)},t.rotStep=function(t,s,e){const i="number"==typeof s?ts3dutils.arrayFromFunction(e,t=>(t+1)/e*s):s,r=i.length,n=!ts3dutils.eq(ts3dutils.TAU,i.last),o=[t,...i.map(s=>{if(ts3dutils.eq(ts3dutils.TAU,s))return t;const e=ts3dutils.M4.rotateZ(s);return t.map(t=>t.transform(e))})],a=ts3dutils.arrayFromFunction(r,s=>{const e=(s+1)%(r+1);return ts3dutils.arrayFromFunction(t.length,i=>{if(!ts3dutils.eq0(t[i].a.lengthXY()))return StraightEdge$$1.throughPoints(o[s][i].a,o[e][i].a)})}),u=[];let l;if(t.forEach((s,e)=>{const c=(e+1)%t.length;if(s instanceof StraightEdge$$1&&s.curve.dir1.isPerpendicularTo(ts3dutils.V3.Z)){const t=s.a.x>s.b.x,i=new PlaneSurface$$1(t?new P3$$1(ts3dutils.V3.Z,s.a.z):new P3$$1(ts3dutils.V3.Z.negated(),-s.a.z));if(n){const t=[];ts3dutils.eq0(s.a.x)||t.push(...ts3dutils.arrayFromFunction(r,t=>a[t][e])),t.push(o[r][e]),ts3dutils.eq0(s.b.x)||t.push(...ts3dutils.arrayFromFunction(r,t=>a[r-t-1][c].flipped())),t.push(s.flipped()),l=new PlaneFace$$1(i,t)}else{const n=t?ts3dutils.arrayFromFunction(r,t=>a[t][e]):ts3dutils.arrayFromFunction(r,t=>a[r-t-1][c].flipped());let o;t&&!ts3dutils.eq0(s.b.x)?o=ts3dutils.arrayFromFunction(r,t=>a[r-t-1][c].flipped()):t||ts3dutils.eq0(s.a.x)||(o=ts3dutils.arrayFromFunction(r,t=>a[t][e])),l=new PlaneFace$$1(i,n,o?[o]:[])}u.push(l)}else if(!(s instanceof StraightEdge$$1&&ts3dutils.eq0(s.a.lengthXY())&&ts3dutils.eq0(s.b.lengthXY())))for(let n=0;nt);let d;if(s instanceof StraightEdge$$1)d=new PlaneSurface$$1(P3$$1.throughPoints(h[0].a,h[1].a,h[2].a));else{const s=t[e].getAABB().max.x,r=i[n],a=0==n?0:i[n-1],u=ts3dutils.V3.polar(s,a).to(ts3dutils.V3.polar(s,r));d=projectCurve$$1(o[n][e].curve,u,!1)}u.push(Face$$1.create(d,h))}}),n){const s=o[r].map(t=>t.flipped()).reverse(),e=new PlaneFace$$1(new PlaneSurface$$1(P3$$1.ZX.rotateZ(i.last)),s);u.push(new PlaneFace$$1(new PlaneSurface$$1(P3$$1.ZX.flipped()),t),e)}return new BRep$$1(u,new PlaneSurface$$1(P3$$1.ZX).edgeLoopCCW(t))},t.fixEdges=a,t.extrudeVertices=function(s,e,i,r,n){ts3dutils.assert(s.every(t=>t instanceof ts3dutils.V3),"baseVertices.every(v => v instanceof V3)"),ts3dutils.assertInst(P3$$1,e),ts3dutils.assertVectors(i),e.normal1.dot(i)>0&&(e=e.flipped());const o=StraightEdge$$1.chain(s,!0);return n=n||ts3dutils.callsce("B2T.extrudeVertices",s,e,i,r),t.extrudeEdges(o,e,i,r,n)},t.tetrahedron=function(t,s,e,i,r="tetra"+getGlobalId$$1()){ts3dutils.assertVectors(t,s,e,i);const n=P3$$1.throughPoints(t,s,e).distanceToPointSigned(i);if(ts3dutils.eq0(n))throw new Error("four points are coplanar");n>0&&([e,i]=[i,e]);const o=StraightEdge$$1.throughPoints(t,s),a=StraightEdge$$1.throughPoints(t,e),u=StraightEdge$$1.throughPoints(t,i),l=StraightEdge$$1.throughPoints(s,e),c=StraightEdge$$1.throughPoints(s,i),h=StraightEdge$$1.throughPoints(e,i),d=[new PlaneFace$$1(PlaneSurface$$1.throughPoints(t,s,e),[o,l,a.flipped()],[],r+"abc"),new PlaneFace$$1(PlaneSurface$$1.throughPoints(t,i,s),[u,c.flipped(),o.flipped()],[],r+"adb"),new PlaneFace$$1(PlaneSurface$$1.throughPoints(s,i,e),[c,h.flipped(),l.flipped()],[],r+"bdc"),new PlaneFace$$1(PlaneSurface$$1.throughPoints(e,i,t),[h,u.flipped(),a],[],r+"cda")],p=ts3dutils.callsce("B2T.tetrahedron",t,s,e,i);return new BRep$$1(d,!1,p)};const u=1/ts3dutils.GOLDEN_RATIO,l=2-ts3dutils.GOLDEN_RATIO;t.TETRAHEDRON_VERTICES=[new ts3dutils.V3(1,0,-SQRT1_2),new ts3dutils.V3(-1,0,-SQRT1_2),new ts3dutils.V3(0,-1,SQRT1_2),new ts3dutils.V3(0,1,SQRT1_2)].map(t=>t.unit()),t.DODECAHEDRON_VERTICES=[new ts3dutils.V3(l,0,1),new ts3dutils.V3(-l,0,1),new ts3dutils.V3(-u,u,u),new ts3dutils.V3(0,1,l),new ts3dutils.V3(u,u,u),new ts3dutils.V3(u,-u,u),new ts3dutils.V3(0,-1,l),new ts3dutils.V3(-u,-u,u),new ts3dutils.V3(l,0,-1),new ts3dutils.V3(-l,0,-1),new ts3dutils.V3(-u,-u,-u),new ts3dutils.V3(0,-1,-l),new ts3dutils.V3(u,-u,-u),new ts3dutils.V3(u,u,-u),new ts3dutils.V3(0,1,-l),new ts3dutils.V3(-u,u,-u),new ts3dutils.V3(1,l,0),new ts3dutils.V3(-1,l,0),new ts3dutils.V3(-1,-l,0),new ts3dutils.V3(1,-l,0)].map(t=>t.unit()),t.DODECAHEDRON_FACE_VERTICES=[[4,3,2,1,0],[7,6,5,0,1],[12,11,10,9,8],[15,14,13,8,9],[14,3,4,16,13],[3,14,15,17,2],[11,6,7,18,10],[6,11,12,19,5],[4,0,5,19,16],[12,8,13,16,19],[15,9,10,18,17],[7,1,2,17,18]],t.OCTAHEDRON_VERTICES=[new ts3dutils.V3(1,0,0),new ts3dutils.V3(-1,0,0),new ts3dutils.V3(0,1,0),new ts3dutils.V3(0,-1,0),new ts3dutils.V3(0,0,1),new ts3dutils.V3(0,0,-1)],t.OCTAHEDRON_FACE_VERTICES=[[0,2,4],[2,1,4],[1,3,4],[3,0,4],[2,0,5],[1,2,5],[3,1,5],[0,3,5]];const{x:c,y:h}=new ts3dutils.V3(1,ts3dutils.GOLDEN_RATIO,0).unit();function d(){return p(t.ICOSAHEDRON_VERTICES,t.ICOSAHEDRON_FACE_VERTICES,"B2T.icosahedron()")}function p(t,s,e){const i=new Map,r=s.map(s=>{const e=PlaneSurface$$1.throughPoints(t[s[0]],t[s[1]],t[s[2]]),r=ts3dutils.arrayFromFunction(s.length,e=>{const r=(e+1)%s.length,n=s[e],o=s[r],a=min(n,o),u=max(n,o),l=a*t.length+u;let c=i.get(l);return!c&&i.set(l,c=StraightEdge$$1.throughPoints(t[a],t[u])),nStraightEdge$$1.throughPoints(s,t.a)),r=t.map((r,n)=>{const o=e+"Wall"+n,a=(n+1)%t.length,u=[i[n],r,i[a].flipped()],l=projectPointCurve$$1(r.curve,r.minT,r.maxT,s,r.deltaT()<0);return Face$$1.create(l,u,void 0,o)}),n=new PlaneSurface$$1(P3$$1.XY).flipped(),o=Face$$1.create(n,Edge$$1.reversePath(t));r.push(o);const a=ts3dutils.callsce("B2T.pyramidEdges",t,s,e);return new BRep$$1(r,!1,a)},t.fromBPT=function(t){const s=/.*/g,e=()=>s.exec(t)[0],i=()=>e().trim().split(/\s+/).map(t=>parseFloat(t)),r=parseInt(e()),n=ts3dutils.arrayFromFunction(r,()=>{const[t,s]=i(),e=ts3dutils.arrayFromFunction(t*s,()=>ts3dutils.VV(...i(),1)),r=new NURBSSurface$$1(e,NURBS$$1.bezierKnots(t),NURBS$$1.bezierKnots(s),t,s,0,1,0,1),n=[Edge$$1.forCurveAndTs(r.isoparametricV(0)),Edge$$1.forCurveAndTs(r.isoparametricU(1)),Edge$$1.forCurveAndTs(r.isoparametricV(1)).flipped(),Edge$$1.forCurveAndTs(r.isoparametricU(0)).flipped()];return Face$$1.create(r,n)});return new BRep$$1(n,!1)}}(exports.B2T||(exports.B2T={}));class CustomPlane$$1 extends P3$$1{constructor(t,s,e,i="CustomPlane"+getGlobalId$$1(),r=chroma.random().gl(),n=-500,o=500,a=-500,u=500){const{normal1:l,w:c}=P3$$1.forAnchorAndPlaneVectors(t,s,e);super(l,c),this.up=e,this.right=s,this.uMin=n,this.uMax=o,this.vMin=a,this.vMax=u,this.name=i,this.color=r}get plane(){return this}toPlaneSurface(){return new PlaneSurface$$1(this,this.right,this.up)}toSource(){return ts3dutils.callsce("new CustomPlane",this.anchor,this.right,this.up,this.name,this.color,this.sMin,this.sMax,this.tMin,this.tMax)}static forPlane(t,s=tsgl.GL_COLOR_BLACK,e){const i=t.normal1.getPerpendicular().unit(),r=i.cross(t.normal1);return new CustomPlane$$1(t.anchor,r,i,e,s)}static fromPlaneSurface(t){return new CustomPlane$$1(t.plane.anchor,t.right,t.up,"genCustomPlane"+getGlobalId$$1())}distanceTo(t,s){return[new L3$$1(this.anchor.plus(this.right.times(this.uMin)),this.up),new L3$$1(this.anchor.plus(this.right.times(this.uMax)),this.up),new L3$$1(this.anchor.plus(this.up.times(this.vMin)),this.right),new L3$$1(this.anchor.plus(this.up.times(this.vMax)),this.right)].map((e,i)=>{const r=e.infoClosestToLine(t);return(isNaN(r.t)||i<2&&this.vMin<=r.t&&r.t<=this.vMax||i>=2&&this.uMin<=r.t&&r.t<=this.uMax)&&r.distance<=s?r.s:1/0}).min()}distanceTo2(t,s){return[new L3$$1(this.anchor.plus(this.right.times(this.uMin)),this.up),new L3$$1(this.anchor.plus(this.right.times(this.uMax)),this.up),new L3$$1(this.anchor.plus(this.up.times(this.vMin)),this.right),new L3$$1(this.anchor.plus(this.up.times(this.vMax)),this.right)].map((e,i)=>{const r=e.infoClosestToLine(t);return(isNaN(r.t)||i<2&&this.vMin<=r.t&&r.t<=this.vMax||i>=2&&this.uMin<=r.t&&r.t<=this.uMax)&&r.distance<=s?r.distance:1/0}).min()}}class Edge$$1 extends ts3dutils.Transformable{constructor(t,s,e,i,r,n,o){super(),this.curve=t,this.a=s,this.b=e,this.aT=i,this.bT=r,this.flippedOf=n,this.name=o,ts3dutils.assertNumbers(i,r),ts3dutils.assert(!ts3dutils.eq(i,r)),ts3dutils.assertVectors(s,e),ts3dutils.assertf(()=>t instanceof Curve$$1,t),ts3dutils.assertf(()=>!t.isValidT||t.isValidT(i)&&t.isValidT(r),i,r,t),ts3dutils.assertf(()=>t.at(i).like(s),()=>""+t.at(i)+s+" aT should have been "+t.pointT(s)),ts3dutils.assertf(()=>t.at(r).like(e),()=>""+t.at(r)+e+" bT should have been "+t.pointT(e)),ts3dutils.assertf(()=>ts3dutils.fuzzyBetween(i,t.tMin,t.tMax),i,t.tMin,t.tMax),ts3dutils.assertf(()=>ts3dutils.fuzzyBetween(r,t.tMin,t.tMax),r,t.tMin,t.tMax),this.aT=ts3dutils.clamp(i,t.tMin,t.tMax),this.bT=ts3dutils.clamp(r,t.tMin,t.tMax),this.reversed=this.aT>this.bT}get minT(){return Math.min(this.aT,this.bT)}get maxT(){return Math.max(this.aT,this.bT)}static forCurveAndTs(t,s=t.tMin,e=t.tMax){return Edge$$1.create(t,t.at(s),t.at(e),s,e,void 0,ss.b.like(t[(e+1)%t.length].a))}static edgesIntersect(t,s){ts3dutils.assertNumbers(t.curve.hlol,s.curve.hlol),ts3dutils.assertInst(Edge$$1,t,s),t.curve.hlolisNaN(t.tThis)||isNaN(t.tOther))&&(console.log(t.sce),console.log(s.sce),ts3dutils.assert(!1)),e.some(({tThis:e,tOther:i})=>t.tValueInside(e)&&s.tValueInside(i))}static assertLoop(t){t.forEach((s,e)=>{const i=(e+1)%t.length;ts3dutils.assert(s.b.like(t[i].a),`edges[${e}].b != edges[${i}].a (${t[e].b.sce} != ${t[i].a.sce})`)})}static ngon(t=3,s=1){return StraightEdge$$1.chain(ts3dutils.arrayFromFunction(t,e=>ts3dutils.V3.polar(s,ts3dutils.TAU*e/t)))}static star(t=5,s=1,e=.5){const i=ts3dutils.arrayFromFunction(2*t,i=>ts3dutils.V3.polar(0==i%2?s:e,ts3dutils.TAU*i/t/2));return StraightEdge$$1.chain(i)}static reversePath(t,s=!0){return s?ts3dutils.arrayFromFunction(t.length,s=>t[t.length-1-s].flipped()):t}static rect(t=1,s=t){const e=[new ts3dutils.V3(0,0,0),new ts3dutils.V3(t,0,0),new ts3dutils.V3(t,s,0),new ts3dutils.V3(0,s,0)];return StraightEdge$$1.chain(e)}static reuleaux(t=3,s=1){ts3dutils.assert(3<=t),ts3dutils.assert(1==t%2);const e=ts3dutils.arrayFromFunction(t,e=>ts3dutils.V3.polar(s,ts3dutils.TAU*e/t));return ts3dutils.arrayFromFunction(t,s=>{const i=(s+floor(t/2))%t,r=(s+ceil(t/2))%t,n=e[i],o=e[r],a=e[s],u=a.to(n),l=new EllipseCurve$$1(a,u,ts3dutils.V3.Z.cross(u));return Edge$$1.create(l,n,o,0,l.pointT(o),void 0,ts3dutils.V3.Z.cross(u),ts3dutils.V3.Z.cross(a.to(o)))})}static round(t,s){if(ts3dutils.eq0(s))return t;const e=t.map((e,i)=>{const r=(i+1)%t.length,n=t[r];if(!e.b.like(n.a))return;const o=e.bDir.angleTo(n.aDir),a=e.curve,u=n.curve;if(a instanceof L3$$1&&u instanceof L3$$1){const t=a.dir1.cross(u.dir1);if(ts3dutils.eq0(o))return;const e=t.cross(a.dir1),i=t.cross(u.dir1),r=a.transform(ts3dutils.M4.translate(e.toLength(s))),n=u.transform(ts3dutils.M4.translate(i.toLength(s))),l=r.isInfoWithLine(n);if(!l)throw new Error("tangential curves");const c=l.plus(e.toLength(-s)),h=l.plus(i.toLength(-s)),d=e.toLength(-s),p=new EllipseCurve$$1(l,d,t.cross(d).toLength(s));return Edge$$1.create(p,c,h,0,p.pointT(h),void 0,a.dir1,u.dir1)}return Edge$$1.arbitraryCorner(e,n,s)});return t.flatMap((s,i)=>{const r=(i+t.length-1)%t.length,n=e[r],o=e[i];if(!n&&!o)return s;const[a,u,l]=n?[s.curve.pointT(n.b),n.b,n.bDir]:[s.aT,s.a,s.aDir],[c,h,d]=o?[s.curve.pointT(o.a),o.a,o.aDir]:[s.bT,s.b,s.bDir],p=Edge$$1.create(s.curve,u,h,a,c,void 0,l,d);return o?[p,o]:p})}static arbitraryCorner(t,s,e){const i=t.curve,r=s.curve;const n=t.bT-e*sign(t.deltaT())/t.bDir.length(),o=s.aT+e*sign(s.deltaT())/s.aDir.length(),[a,u]=ts3dutils.newtonIterate(function([t,s]){const n=i.at(t),o=r.at(s),a=i.tangentAt(t),u=r.tangentAt(s),l=a.cross(u),c=l.cross(a).unit(),h=l.cross(u).unit(),d=c.cross(h);l.likeO()&&ts3dutils.assert(!1);const p=n.to(o);ts3dutils.eq0(p.dot(l))||ts3dutils.assert(!1);const f=p.cross(h).dot(d)/d.squared(),m=p.cross(c).dot(d)/d.squared(),$=n.plus(c.times(f)),g=o.plus(h.times(m));return ts3dutils.assert($.like(g)),[abs(f)-e,abs(m)-e]},[n,o]),l=t.curve.at(a),c=s.curve.at(u),h=i.tangentAt(a),d=r.tangentAt(u),p=h.cross(d),f=p.cross(h).unit().toLength(-e),m=l.minus(f),$=new EllipseCurve$$1(m,f,p.cross(f).toLength(e));return Edge$$1.create($,l,c,0,$.pointT(c),void 0,i.tangentAt(a),r.tangentAt(u))}static pathFromSVG(t){let s=void 0;const e=new svgPathdata.SVGPathData(t).toAbs().normalizeHVZ().sanitize(ts3dutils.NLA_PRECISION).annotateArcs().commands,i=[];for(const t of e){ts3dutils.assert("x"in t&&"y"in t);const e=new ts3dutils.V3(t.x,t.y,0);switch(t.type){case svgPathdata.SVGPathData.LINE_TO:i.push(StraightEdge$$1.throughPoints(s,e));break;case svgPathdata.SVGPathData.CURVE_TO:{const r=new ts3dutils.V3(t.x1,t.y1,0),n=new ts3dutils.V3(t.x2,t.y2,0),o=new BezierCurve$$1(s,r,n,e,0,1),a=new PCurveEdge$$1(o,s,e,0,1,void 0,o.tangentAt(0),o.tangentAt(1));i.push(a);break}case svgPathdata.SVGPathData.QUAD_TO:{const r=new ts3dutils.V3(t.x1,t.y1,0),n=ParabolaCurve$$1.quadratic(s,r,e).rightAngled(),o=new PCurveEdge$$1(n,s,e,n.tMin,n.tMax,void 0,n.tangentAt(n.tMin),n.tangentAt(n.tMax));i.push(o);break}case svgPathdata.SVGPathData.ARC:{const r=t.phi1*ts3dutils.DEG,n=t.phi2*ts3dutils.DEG,[o,a]=[r,n].sort(ts3dutils.MINUS),u=ts3dutils.arrayRange(-3,4,1).map(t=>t*PI).filter(t=>o<=t&&t<=a),l=ts3dutils.V(t.cX,t.cY),c=ts3dutils.V3.polar(t.rX,t.xRot*ts3dutils.DEG),h=ts3dutils.V3.polar(t.rY,t.xRot*ts3dutils.DEG+Math.PI/2),d=ts3dutils.getIntervals(u,o,a).map(([t,i])=>{const o=i-t,a=ts3dutils.mod(t,ts3dutils.TAU),u=a+o;ts3dutils.assert(a>=0==u>=0);const d=a>PI||u>PI,p=d?a-PI:a,f=d?u-PI:u,m=new EllipseCurve$$1(l,d?c.negated():c,d?h.negated():h),$=r==t?s:n==t?e:m.at(p),g=r==i?s:n==i?e:m.at(f);return new PCurveEdge$$1(m,$,g,p,f,void 0,m.tangentAt(p),m.tangentAt(f))});i.push(...t.phiDelta>0?d:Edge$$1.reversePath(d));break}}s=e}return i}toString(){return ts3dutils.callsce("new "+this.constructor.name,this.curve,this.a,this.b,this.aT,this.bT,void 0,this.aDir,this.bDir)}split(t){const s=this.curve.at(t),e=this.tangentAt(t);return[Edge$$1.create(this.curve,this.a,s,this.aT,t,void 0,this.aDir,e,this.name+"left"),Edge$$1.create(this.curve,s,this.b,t,this.bT,void 0,e,this.bDir,this.name+"left")]}colinearToLine(t){return this.curve instanceof L3$$1&&this.curve.isColinearTo(t)}tValueInside(t){return this.aT{e.forEach(e=>{ts3dutils.lt(this.minT,e)&&ts3dutils.lt(e,this.maxT)&&(t[i]=Math.min(t[i],this.curve.at(e).e(i)),s[i]=Math.max(s[i],this.curve.at(e).e(i)))})});const e=new ts3dutils.AABB(ts3dutils.V(t),ts3dutils.V(s));return e.addPoint(this.a),e.addPoint(this.b),e}length(t=1){return this.curve.arcLength(this.minT,this.maxT,t)}deltaT(){return this.bT-this.aT}deltaTSign(){return sign(this.bT-this.aT)}atAvgT(){return this.curve.at((this.minT+this.maxT)/2)}static loopsEqual(t,s){return t.length==s.length&&ts3dutils.arrayRange(0,t.length,1).some(e=>t.every((i,r)=>i.equals(s[(e+r)%t.length])))}}class PCurveEdge$$1 extends Edge$$1{constructor(t,s,e,i,r,n,o,a,u){super(t,s,e,i,r,n,u),this.flippedOf=n,this.aDir=o,this.bDir=a,ts3dutils.assertVectors(o,a),ts3dutils.assertf(()=>!o.likeO(),t),ts3dutils.assertf(()=>!a.likeO(),t),t instanceof PICurve$$1||(ts3dutils.assertf(()=>t.tangentAt(i).likeOrReversed(o),""+i+t.tangentAt(i).sce+" "+o.sce),ts3dutils.assertf(()=>t.tangentAt(r).likeOrReversed(a),""+r+t.tangentAt(r).sce+" "+a.sce)),ts3dutils.assert(this.reversed===this.aDir.dot(t.tangentAt(i))<0,i+" "+r+" "+t.constructor.name+" "+this.aDir.sce+" "+this.bDir.sce+" "+t.tangentAt(i)),ts3dutils.assert(this.reversed===this.bDir.dot(t.tangentAt(r))<0,i+" "+r+" "+t.constructor.name+" "+this.aDir.sce+" "+this.bDir.sce+" "+t.tangentAt(i))}static forCurveAndTs(t,s,e,i){return new PCurveEdge$$1(t,t.at(s),t.at(e),s,e,void 0,sts3dutils.snap2(t,this.aT,this.bT)).filter(t=>this.minT<=t&&t<=this.maxT)}edgeISTsWithPlane(t){return this.curve.isTsWithPlane(t).map(t=>ts3dutils.snap2(t,this.aT,this.bT)).filter(t=>this.minT<=t&&t<=this.maxT)}tangentAt(t){return this.reversed?this.curve.tangentAt(t).negated():this.curve.tangentAt(t)}flipped(){return this.flippedOf||(this.flippedOf=new PCurveEdge$$1(this.curve,this.b,this.a,this.bT,this.aT,this,this.bDir.negated(),this.aDir.negated(),this.name))}transform(t,s){return new PCurveEdge$$1(this.curve.transform(t),t.transformPoint(this.a),t.transformPoint(this.b),this.aT,this.bT,void 0,t.transformVector(this.aDir),t.transformVector(this.bDir),""+this.name+s)}transform4(t,s){const e=t.transformPoint(this.a),i=t.transformPoint(this.b),r=this.curve.transform4(t);return new PCurveEdge$$1(r,e,i,ts3dutils.snap(r.pointT(e),this.aT),ts3dutils.snap(r.pointT(i),this.bT),void 0,t.transformVector(this.aDir),t.transformVector(this.bDir),""+this.name+s)}isCoEdge(t){return this===t||this===t.flippedOf||this.curve.isColinearTo(t.curve)&&(this.a.like(t.a)&&this.b.like(t.b)||this.a.like(t.b)&&this.b.like(t.a))}}class StraightEdge$$1 extends Edge$$1{constructor(t,s,e,i,r,n,o){super(t,s,e,i,r,n,o),this.flippedOf=n,ts3dutils.assertInst(L3$$1,t),!n||ts3dutils.assertInst(StraightEdge$$1,n),!o||ts3dutils.assertf(()=>"string"==typeof o,o),ts3dutils.assert(!s.like(e),"!a.like(b)"+s+e),this.tangent=this.aTStraightEdge$$1.throughPoints(t[s],t[(s+1)%e]))}toSource(){return ts3dutils.callsce("new StraightEdge",this.curve,this.a,this.b,this.aT,this.bT)}getVerticesNo0(){return[this.b]}pointsCount(){return 2}points(){return[this.a,this.b]}edgeISTsWithPlane(t){const s=ts3dutils.snap2(this.curve.isTWithPlane(t),this.aT,this.bT);return this.minT<=s&&s<=this.maxT?[s]:[]}edgeISTsWithSurface(t){return t instanceof PlaneSurface$$1?this.edgeISTsWithPlane(t.plane):t.isTsForLine(this.curve).map(t=>ts3dutils.snap2(t,this.aT,this.bT)).filter(t=>this.minT<=t&&t<=this.maxT)}tangentAt(){return this.tangent}flipped(){return this.flippedOf||(this.flippedOf=new StraightEdge$$1(this.curve,this.b,this.a,this.bT,this.aT,this,this.name))}transform(t,s){const e=t.transformVector2(this.curve.dir1,this.curve.anchor).length(),i=this.curve.transform(t),r=t.transformPoint(this.a),n=t.transformPoint(this.b);return new StraightEdge$$1(i,r,n,t.isNoProj()?this.aT*e:i.pointT(r),t.isNoProj()?this.bT*e:i.pointT(n),void 0,""+this.name+s)}transform4(t,s){const e=t.transformVector2(this.curve.dir1,this.curve.anchor).length(),i=this.curve.transform4(t),r=t.transformPoint(this.a),n=t.transformPoint(this.b);return new StraightEdge$$1(i,r,n,t.isNoProj()?this.aT*e:i.pointT(r),t.isNoProj()?this.bT*e:i.pointT(n),void 0,""+this.name+s)}isCoEdge(t){return this===t||this===t.flippedOf||t.constructor===StraightEdge$$1&&(this.a.like(t.a)&&this.b.like(t.b)||this.a.like(t.b)&&this.b.like(t.a))}getEdgeT(t){ts3dutils.assertVectors(t);let s=t.minus(this.curve.anchor).dot(this.curve.dir1);if(ts3dutils.eq0(this.curve.at(s).distanceTo(t)))return s=ts3dutils.snap2(s,this.aT,this.bT),this.minT<=s&&s<=this.maxT?s:void 0}}class FaceInfoFactory{static makeStatic(t){return new class extends FaceInfoFactory{constructor(){super()}info(s,e,i){return t}}}info(t,s,e){throw new Error("no default implementation")}extrudeBottom(t,s,e=[]){return this.info(t,s,e)}extrudeTop(t,s,e=[]){return this.info(t,s,e)}extrudeWall(t,s,e,i=[]){return this.info(s,e,i)}rotationWall(t,s,e,i=[]){return this.info(s,e,i)}rotationStart(t,s,e=[]){return this.info(t,s,e)}rotationEnd(t,s,e=[]){return this.info(t,s,e)}newSubFace(t,s,e,i=[]){return t.info}transform(t,s,e,i,r,n=[]){return t.info}}class Face$$1 extends ts3dutils.Transformable{constructor(t,s,e=[],i,r){super(),this.surface=t,this.contour=s,this.holes=e,this.name=i,this.info=r,this.aabb=void 0,Edge$$1.assertLoop(s),ts3dutils.assert(s.every(t=>t instanceof Edge$$1),()=>"contour.every(f => f instanceof Edge)"+s),ts3dutils.assert(t.edgeLoopCCW(s),t.toString()+s.join("\n")),e&&e.forEach(t=>Edge$$1.assertLoop(t)),e&&e.forEach(s=>ts3dutils.assert(!t.edgeLoopCCW(s))),ts3dutils.assert(!e||e.constructor==Array,e&&e.toString()),this.allEdges=Array.prototype.concat.apply(this.contour,this.holes)}static assembleFacesFromLoops(t,s,e){const i=[],r=[];return t.forEach(t=>(function t(e,i){if(0==i.length)i.push(e);else{const r=i.find(t=>BRep$$1.loop1ContainsLoop2(t.loop,t.ccw,e.loop,e.ccw,s));if(r)t(e,r.subloops);else{for(let t=i.length;--t>=0;){const r=i[t];BRep$$1.loop1ContainsLoop2(e.loop,e.ccw,r.loop,r.ccw,s)&&(e.subloops.push(r),i.splice(t,1))}i.push(e)}}})({loop:t,ccw:s.edgeLoopCCW(t),subloops:[]},r)),r.forEach(t=>(function t(r){i.push(new e(s,r.ccw?r.loop:Edge$$1.reversePath(r.loop),r.subloops.map(t=>t.ccw?Edge$$1.reversePath(t.loop):t.loop))),r.subloops.forEach(s=>s.subloops.forEach(s=>t(s)))})(t)),i}static create(t,s,e,i,r){return t instanceof PlaneSurface$$1?new PlaneFace$$1(t,s,e,i,r):new RotationFace$$1(t,s,e,i,r)}intersectFace(t,s,e,i,r,n,o){function a(t,s){return o.has(new javasetmap_ts.Pair(t,s))}function u(t,s){return o.add(new javasetmap_ts.Pair(t,s))}function l(o,l,c){if(!l&&!c){let s=h.surface.normalP(o.a).cross(t.surface.normalP(o.a));if(s.likeO()){const e=ts3dutils.lerp(o.aT,o.bT,1/ts3dutils.GOLDEN_RATIO),i=o.curve.at(e);s=h.surface.normalP(i).cross(t.surface.normalP(i))}if(s.likeO()){const s=o.a,e=P3$$1.normalOnAnchor(o.aDir,s),r=h.surface.normalP(s),n=r.dot(t.surface.normalP(s))>0,a=e.normal1.cross(r),u=h.surface.isCurvesWithPlane(e)[0],l=u.pointT(s),c=sign(a.dot(u.tangentAt(l))),d=t.surface.isCurvesWithPlane(e)[0],p=d.pointT(s),f=sign(a.dot(u.tangentAt(p))),m=u.diff(l,EPS$$1*c).dot(r),$=d.diff(p,EPS$$1*f).dot(r);${const s=fff$$1(t,r.surface),e=s==INSIDE$$1||!l&&s==COPLANAR_SAME$$1,n=t.edge.tangentAt(t.edge.curve.pointT(o.a)).like(o.aDir)?o:o.flipped();console.log(o.sce),ts3dutils.assert(t.edge.tangentAt(t.edge.curve.pointT(n.a)).like(n.aDir)),e&&ts3dutils.mapPush(i,t.face,n)});const e=s.normalP(o.a),u=e.cross(o.aDir),c=splitsVolumeEnclosingFacesP$$1(n,t.getCanon(),o.a,u,e);let h,d;(h=c==INSIDE$$1||l&&c==COPLANAR_SAME$$1)&&ts3dutils.mapPush(i,r,o);const p=splitsVolumeEnclosingFacesP$$1(n,t.getCanon(),o.a,u.negated(),e);if((d=p==INSIDE$$1||l&&p==COPLANAR_SAME$$1)&&ts3dutils.mapPush(i,r,o.flipped()),h||d||c==COPLANAR_SAME$$1&&p==INSIDE$$1||p==COPLANAR_SAME$$1&&c==INSIDE$$1)return!0}return!1}const p=d(l,c,0,t,s,0,!1),f=d(c,l,0,h,e,0,!0);if(p||f)return!0;if(l&&c){if(a(l.getCanon(),c.getCanon()))return!1;function m(t,s,e,r,n,a,u,l){for(const u of e.edgeFaces.get(t.getCanon())){const e=splitsVolumeEnclosingFaces$$1(r,s.getCanon(),u.inside,u.normalAtCanonA),l=e==INSIDE$$1||n&&e==COPLANAR_SAME$$1,c=u.edge.aDir.like(o.aDir)?o:o.flipped();if(l){ts3dutils.mapPush(i,u.face,c);const s=t.getCanon().curve.pointT(o.a);ts3dutils.eq(s,t.aT)||ts3dutils.eq(s,t.bT)||splitsVolumeEnclosingCone2$$1(r,o.a,o.curve,o.aT,-Math.sign(o.deltaT()))==INSIDE$$1&&ts3dutils.mapPush(a,t.getCanon(),{p:o.a,edgeT:s});const e=t.getCanon().curve.pointT(o.b);ts3dutils.eq(e,t.aT)||ts3dutils.eq(e,t.bT)||splitsVolumeEnclosingCone2$$1(r,o.b,o.curve,o.bT,Math.sign(o.deltaT()))==INSIDE$$1&&ts3dutils.mapPush(a,t.getCanon(),{p:o.b,edgeT:e})}}}return u(l.getCanon(),c.getCanon()),m(l,c,s,e,!0,r),m(c,l,e,s,!1,n),!1}return!1}function c(t,i,o){if(t&&!i&&(t.colinear||t.edgeT==t.edge.aT||t.edgeT==t.edge.bT||(ts3dutils.mapPush(r,t.edge.getCanon(),t),ts3dutils.assert(t.edge.isValidT(t.edgeT)))),i&&!t&&(i.colinear||i.edgeT==i.edge.aT||i.edgeT==i.edge.bT||(ts3dutils.mapPush(n,i.edge.getCanon(),i),ts3dutils.assert(i.edge.isValidT(i.edgeT)))),t&&i){function a(t,s,e,i,r,n,o,a,l,c){if(!t.colinear&&t.edgeT!=t.edge.aT&&t.edgeT!=t.edge.bT)if(u(t.edge.getCanon(),s.edge.getCanon()),t.p.like(s.edge.a)||t.p.like(s.edge.b)){const e=t.p.like(s.edge.a)?s.edge.a:s.edge.b,i=splitsVolumeEnclosingCone2$$1(a,e,t.edge.curve,t.edgeT,1),r=splitsVolumeEnclosingCone2$$1(a,e,t.edge.curve,t.edgeT,-1);INSIDE$$1!=i&&INSIDE$$1!=r||(ts3dutils.mapPush(c,t.edge.getCanon(),t),ts3dutils.assert(t.edge.isValidT(t.edgeT)))}else{const e=splitsVolumeEnclosingFacesP2$$1(a,s.edge.getCanon(),t.p,t.edge.curve,t.edgeT,1,r.normalP(t.p)),i=splitsVolumeEnclosingFacesP2$$1(a,s.edge.getCanon(),t.p,t.edge.curve,t.edgeT,-1,r.normalP(t.p));(INSIDE$$1==e||l&&COPLANAR_SAME$$1==e||INSIDE$$1==i||l&&COPLANAR_SAME$$1==i)&&(ts3dutils.mapPush(c,t.edge.getCanon(),t),ts3dutils.assert(t.edge.isValidT(t.edgeT)))}}ts3dutils.assert(t.colinear||i.colinear||ts3dutils.eq(t.t,i.t)),a(t,i,0,0,d,0,0,e,!0,r),a(i,t,0,0,p,0,0,s,!1,n)}}ts3dutils.assertInst(Face$$1,t);const h=this,d=h.surface,p=t.surface;if(!this.getAABB().touchesAABBfuzzy(t.getAABB()))return;if(d.isCoplanarTo(p))return;const f=d.isCurvesWithSurface(p);if(0!=f.length){for(const t of f)ts3dutils.assert(d.containsCurve(t)),ts3dutils.assert(p.containsCurve(t));for(let s=0;s0==i.length||!ts3dutils.eq0(i[0].insideDir.dot(e.tangentAt(i[0].t))),()=>i[0].insideDir.dot(e.tangentAt(i[0].t))),ts3dutils.assertf(()=>0==r.length||!ts3dutils.eq0(r[0].insideDir.dot(e.tangentAt(r[0].t))),()=>r[0].insideDir.dot(e.tangentAt(r[0].t)));let n,o,a=m(i,h),u=m(r,t);if(0==i.length&&!a||0==r.length&&!u)continue;let d,p,$,g,v=0,P=0,x=a&&u?e.at(e.tMin):void 0,C=e.tMin;for(;vd.t&&(p=p.negated());let i=e.tangentAt(d.t);C>d.t&&(i=i.negated());const r=Edge$$1.create(e,x,d.p,C,d.t,void 0,p,i,"genseg"+getGlobalId$$1());x=void 0,l(r,n&&n.edge,o&&o.edge)&&(c($||n,g||o),c(t&&t.used&&t||n,s&&s.used&&s||o))}}if(a&&u&&C!==e.tMax){const t=e.tMax;p=e.tangentAt(C),C>t&&(p=p.negated());let s=e.tangentAt(t);C>t&&(s=s.negated());const i=Edge$$1.create(e,x,e.at(t),C,t,void 0,p,s,"genseg"+getGlobalId$$1());l(i,n&&n.edge,o&&o.edge)&&c($||n,g||o)}}h.getAllEdges().forEach(s=>{o.add(new javasetmap_ts.Pair(s.getCanon(),t))}),t.getAllEdges().forEach(t=>{o.add(new javasetmap_ts.Pair(t.getCanon(),h))})}}edgeISPsWithSurface(t,s){const e=this.surface,i=this.holes.concat([this.contour]),r=[];for(const n of i){const i=n.map(s=>s.curve.isColinearTo(t));for(let o=0;o0&&r.push({p:u.b,insideDir:a.aDir.negated(),t:l,edge:u,edgeT:u.bT,colinear:!1}),r.push({p:a.a,insideDir:a.aDir,t:l,edge:a,edgeT:a.aT,colinear:!0})}if(t.containsPoint(a.b)){const s=t.pointT(a.b),n=a.bDir.cross(e.normalP(a.b));!i[u]&&dotCurve2$$1(l.curve,l.aT,n,sign(l.deltaT()))>0&&r.push({p:a.b,insideDir:a.bDir,t:s,edge:l,edgeT:l.aT,colinear:!1}),r.push({p:a.b,insideDir:a.bDir.negated(),t:s,edge:a,edgeT:a.bT,colinear:!0})}}else{const n=a.edgeISTsWithSurface(s);for(const s of n){const n=a.curve.at(s);if(!t.containsPoint(n))continue;const o=t.pointT(n);ts3dutils.assert(!isNaN(o));const l=a.tangentAt(s).cross(e.normalP(n)).negated(),c=t.tangentAt(o);if(s==a.bT){if(!i[u]){if(!ts3dutils.eq(o,t.tMax)){const s=this.pointsToInside3(a.b,t,o,1);ts3dutils.assert(s!=exports.PointVsFace.ON_EDGE),exports.PointVsFace.INSIDE==s&&r.push({p:a.b,insideDir:c,t:o,edge:a,edgeT:a.bT,colinear:!1})}if(!ts3dutils.eq(o,t.tMin)){const s=this.pointsToInside3(a.b,t,o,-1);ts3dutils.assert(s!=exports.PointVsFace.ON_EDGE),exports.PointVsFace.INSIDE==s&&r.push({p:a.b,insideDir:c.negated(),t:o,edge:a,edgeT:a.bT,colinear:!1})}}}else if(s!=a.aT)if(ts3dutils.eq0(l.dot(c))){const e=sign(c.dot(a.curve.tangentAt(s))),i=1e-4;for(const u of[-1,1]){if(-1==u*e&&s==a.minT||1==u*e&&s==a.maxT||-1==u&&o==t.tMin||1==u&&o==t.tMax)continue;t.at(o).to(t.at(o+u*i)).dot(l)-a.curve.at(s).to(a.curve.at(s+u*e*i)).dot(l)>0&&r.push({p:n,insideDir:c.times(u),t:o,edge:a,edgeT:s,colinear:!1})}}else r.push({p:n,insideDir:l,t:o,edge:a,edgeT:s,colinear:!1})}}}}return r.sort((s,e)=>s.t-e.t||s.insideDir.dot(t.tangentAt(s.t))),r}transform(t){const s=t.isMirroring(),e=Edge$$1.reversePath(this.contour.map(s=>s.transform(t)),s),i=this.holes.map(e=>Edge$$1.reversePath(e.map(s=>s.transform(t)),s));return new this.constructor(this.surface.transform(t),e,i,this.name,this.info)}transform4(t){const s=t.isMirroring(),e=Edge$$1.reversePath(this.contour.map(s=>s.transform4(t)),s),i=this.holes.map(e=>Edge$$1.reversePath(e.map(s=>s.transform4(t)),s));return new this.constructor(this.surface.transform4(t),e,i,this.name,this.info)}flipped(){const t=this.contour.map(t=>t.flipped()).reverse(),s=this.holes.map(t=>t.map(t=>t.flipped()).reverse());return new this.constructor(this.surface.flipped(),t,s,this.name,this.info)}toString(){return"new "+this.constructor.name+"("+this.surface+", ["+this.contour.map(t=>"\n\t"+t).join()+"]"+this.holes.map(t=>"\n\t\thole: "+t.join())+")"}toSource(){return"new "+this.constructor.name+"("+this.surface.toSource()+", ["+this.contour.map(t=>"\n\t"+t.toSource()+",").join("")+"], ["+this.holes.map(t=>"["+t.map(t=>"\n\t"+t.toSource()+",").join("")+"]").join(",")+"])"}equals(t){return this==t||Object.getPrototypeOf(this)==Object.getPrototypeOf(t)&&this.holes.length==t.holes.length&&Edge$$1.loopsEqual(this.contour,t.contour)&&this.holes.every(s=>t.holes.some(t=>Edge$$1.loopsEqual(s,t)))}hashCode(){function t(t){let s=0;for(const e of t)s=31*s+e|0;return s}function s(s){return t(s.map(t=>t.hashCode()).sort(ts3dutils.MINUS))}let e=0;return e=31*(e=31*(e=31*e+t(this.holes.map(t=>s(t)).sort(ts3dutils.MINUS))|0)+s(this.contour)|0)+this.surface.hashCode()|0}likeFace(t){function s(t,s){return t.length==s.length&&ts3dutils.arrayRange(0,t.length,1).some(e=>t.every((i,r)=>i.like(s[(e+r)%t.length])))}return ts3dutils.assertInst(Face$$1,t),this.surface.like(t.surface)&&this.holes.length==t.holes.length&&s(this.contour,t.contour)&&this.holes.every(e=>t.holes.some(t=>s(e,t)))}getAllEdges(){return this.allEdges}addEdgeLines(t){ts3dutils.assert(!1,"buggy, fix");const s=this.contour.flatMap(t=>t.getVerticesNo0()),e=t.vertices.length;for(let i=0;ithis.surface.loopContainsPoint(s,t)!=exports.PointVsFace.OUTSIDE)}containsPoint2(t){ts3dutils.assertVectors(t);const s=this.surface.loopContainsPoint(this.contour,t);if(s!=exports.PointVsFace.INSIDE)return s;for(const s of this.holes){const e=this.surface.loopContainsPoint(s,t);if(e!=exports.PointVsFace.OUTSIDE)return e==exports.PointVsFace.ON_EDGE?exports.PointVsFace.ON_EDGE:exports.PointVsFace.OUTSIDE}return exports.PointVsFace.INSIDE}intersectsLine(t){if(ts3dutils.assertInst(L3$$1,t),!this.getAABB().intersectsLine(t))return NaN;const s=this.surface.isTsForLine(t).filter(s=>this.containsPoint(t.at(s))).withMax(t=>-t);return void 0!=s?s:NaN}toMesh(){const t=(new tsgl.Mesh).addIndexBuffer("TRIANGLES").addIndexBuffer("LINES").addVertexBuffer("normals","ts_Normal");return this.addToMesh(t),t}zDirVolume(){return this.surface.zDirVolume(this.getAllEdges())}calcArea(){return this.surface.calculateArea(this.getAllEdges())}getLoops(){return[this.contour,...this.holes]}getAABB(){return this.aabb||(this.aabb=ts3dutils.AABB.forAABBs(this.contour.map(t=>t.getAABB())))}pointsToInside3(t,s,e,i){const r=this.surface.normalP(t),n=s.tangentAt(e).times(i),o=r.cross(n),a=s.at(e).to(s.at(e+1e-6*i)).dot(o);let u,l=1/0,c=!1;for(const e of this.getAllEdges()){const i=e.a.like(t),h=e.b.like(t);if(ts3dutils.assert(i==e.a.like(t)),ts3dutils.assert(h==e.b.like(t)),!i&&!h)continue;const d=i?e.aDir:e.bDir.negated(),p=n.angleRelativeNormal(d,r);if(ts3dutils.eq0(p)){if(s.isColinearTo(e.curve))return exports.PointVsFace.ON_EDGE;const t=i?e.aT:e.bT,r=(i?1:-1)*sign(e.deltaT()),n=e.curve.diff(t,1e-6*r).dot(o)-a;n>0&&(!c||nts3dutils.assert(ts3dutils.doubleSignedArea(t,i.plane.normal1)>=0,"doubleSignedArea(vs, planeSurface.plane.normal1) >= 0"));const n=e.map(t=>StraightEdge$$1.chain(t));return new PlaneFace$$1(t,r,n)}addToMesh(t){const s=t.vertices.length,e=this.surface.plane.normal1,i=this.contour.flatMap(t=>t.getVerticesNo0());for(let e=0;e{r.push(i.length),i.push(...t.flatMap(t=>t.getVerticesNo0()))});const n=triangulateVertices$$1(e,i,r).map(t=>t+s);Array.prototype.push.apply(t.vertices,i),Array.prototype.push.apply(t.TRIANGLES,n),Array.prototype.push.apply(t.normals,ts3dutils.arrayFromFunction(i.length,()=>e))}intersectsLine(t){ts3dutils.assertInst(L3$$1,t);const s=t.isTWithPlane(this.surface.plane);return Number.isFinite(s)&&this.containsPoint(t.at(s))?s:NaN}withHole(t){return new PlaneFace$$1(this.surface,this.contour,[t])}pointsToInside(t,s){return this.containsPoint2(t.plus(s.times(8*ts3dutils.NLA_PRECISION)))}edgeISPsWithPlane(t,s){ts3dutils.assert(this.surface.plane.containsLine(t)),ts3dutils.assert(s.containsLine(t));const e=this.surface.plane,i=[];return[this.contour].concat(this.holes).forEach(r=>{const n=r.map(s=>s.colinearToLine(t)&&-sign(s.aDir.dot(t.dir1))),o=t.dir1.cross(e.normal1);r.forEach((e,r,a)=>{const u=(r+1)%a.length,l=a[u],c=n[r];if(c){const s=t.pointT(e.a),r=t.pointT(e.b);i.push({p:e.a,insideDir:e.aDir,t:s,edge:e,edgeT:e.aT,colinear:!0},{p:e.b,insideDir:e.bDir.negated(),t:r,edge:e,edgeT:e.bT,colinear:!0}),c*(n[u]||dotCurve2$$1(l.curve,l.aT,o,l.deltaTSign()))<0&&i.push({p:l.a,insideDir:e.bDir,t:r,edge:l,edgeT:l.aT,colinear:!1})}else{const r=e.edgeISTsWithPlane(s);ts3dutils.assert(r.every(t=>s.containsPoint(e.curve.at(t))),r);for(const a of r)if(a==e.bT){dotCurve2$$1(e.curve,e.bT,o,-e.deltaTSign())*(n[u]||dotCurve2$$1(l.curve,l.aT,o,l.deltaTSign()))<0&&i.push({p:e.b,insideDir:s.normal1.negated(),t:t.pointT(e.b),edge:e,edgeT:e.bT,colinear:!1})}else if(a!=e.aT){const r=e.curve.at(a);ts3dutils.assert(s.containsPoint(r),e.toString(),r,a,s.distanceToPoint(r)),ts3dutils.assert(t.containsPoint(r),e.toString(),r,a,t.distanceToPoint(r));const n=s.normal1.negated();i.push({p:r,insideDir:n,t:t.pointT(r),edge:e,edgeT:a,colinear:!1})}}})}),i.sort((s,e)=>s.t-e.t||s.insideDir.dot(t.dir1)),i}}class RotationFace$$1 extends Face$$1{constructor(t,s,e,i,r){super(t,s,e,i,r)}static loopDoesNotCrossPlane(t,s){let e=0;function i(t){return 0!=e?!e||e*t<0:(e=t,!1)}for(const e of t){const t=e.edgeISTsWithPlane(s);if(0==t.length){if(!(e.curve instanceof L3$$1)&&i(s.distanceToPointSigned(e.a)))return!1}else for(const r of t){if(e.aT!=r&&i(dotCurve2$$1(e.curve,r,s.normal1,-e.deltaTSign())))return!1;if(e.bT!=r&&i(dotCurve2$$1(e.curve,r,s.normal1,e.deltaTSign())))return!1}}return!0}getAABB(){return this.aabb?this.aabb:(this.aabb=ts3dutils.AABB.forAABBs(this.contour.map(t=>t.getAABB())),this.aabb.addPoints(this.surface.getExtremePoints().filter(t=>this.containsPoint(t))),this.aabb)}unrollLoop(t){const s=[],e=this.surface.uvPFunc(),i=t.map(t=>t.getVerticesNo0()),r=i.findIndex(t=>!ts3dutils.eq(e(t[0]).x,Math.PI));ts3dutils.assert(-1!=r);for(let n=0;n{t.getVerticesNo0().forEach(t=>{s.push(e(t))})}),console.log("vs\n",s.join("\n"),s.length),s}unrollEllipsoidLoops(t){const s=[],e=[],i=[],r=this.surface,n=r.uvPFunc(),o=r instanceof EllipsoidSurface$$1?t=>t.like(r.center.plus(r.f3))||t.like(r.center.minus(r.f3)):t=>t.like(this.surface.center);for(const a of t){i.push(s.length);for(let t=0;tn(t))),o(a[i].a)){const n=r.matrixInverse.transformVector(a[t].bDir),o=r.matrixInverse.transformVector(a[i].aDir),u=Math.atan2(-n.y,-n.x),l=Math.atan2(o.y,o.x),c=s.pop();s.push(new ts3dutils.V3(u,c.y,0),new ts3dutils.V3(l,c.y,0)),e.push(e.last)}s.forEach(({u:t,v:s})=>{ts3dutils.assert(isFinite(t)),ts3dutils.assert(isFinite(s))})}}let a;if(this.surface instanceof EllipsoidSurface$$1)a=e.map(t=>r.normalP(t));else{const t=r.normalUVFunc();a=s.map(({u:s,v:e})=>t(s,e))}return ts3dutils.assert(e.length==e.length),{verticesUV:s,vertices:e,normals:a,loopStarts:i}}unrollCylinderLoops(t){const s=t.map(t=>t.flatMap(t=>t.getVerticesNo0())),e=this.surface,i=s.concatenated(),r=s.reduce((t,s)=>(t.push(t.last+s.length),t),[0]),n=e.uvPFunc(),o=i.map(t=>n(t)),a=e.normalUVFunc();return{verticesUV:o,vertices:i,normals:o.map(({u:t,v:s})=>a(t,s)),loopStarts:r}}addToMesh(t,s=this.surface.uStep,e=this.surface.vStep){ts3dutils.assertf(()=>s>0&&e>0,s,e,"Surface: "+this.surface);const i=[],r=(t,i)=>this.surface.pUVFunc()(t*s,i*e),n=(t,i)=>this.surface.normalUVFunc()(t*s,i*e),o=this.getLoops(),{vertices:a,verticesUV:u,normals:l,loopStarts:c}=this.surface instanceof EllipsoidSurface$$1||this.surface instanceof ConicSurface$$1?this.unrollEllipsoidLoops(o):this.unrollCylinderLoops(o);c.push(a.length);const h=u.map(({u:t,v:i})=>new ts3dutils.V3(t/s,i/e,0));for(let s=0;s{ts3dutils.assert(isFinite(t)),ts3dutils.assert(isFinite(s)),d=min(d,t),p=max(p,t),f=min(f,s),m=max(m,s)}),ParametricSurface$$1.is(this.surface);const $=floor(d+ts3dutils.NLA_PRECISION),g=floor(f+ts3dutils.NLA_PRECISION),v=ceil(p-ts3dutils.NLA_PRECISION)-$,P=ceil(m-ts3dutils.NLA_PRECISION)-g;if(console.log(s,e,v,P),1==v&&1==P){const t=triangulateVertices$$1(ts3dutils.V3.Z,h,c.slice(1,1+this.holes.length));i.push(...t)}else{const t=new Array(v*P);function x(s,e,i){ts3dutils.assert(e0);let o=n;do{t.push(...o);const i=V(o.last),n=a.indexWithMax(t=>-ts3dutils.mod(V(t[0])-i,4)),u=a.removeIndex(n);let l=i;const c=V(u[0])>l?V(u[0]):V(u[0])+4;let h=ceil(l+ts3dutils.NLA_PRECISION),d=ts3dutils.eq0((l+ts3dutils.NLA_PRECISION)%1-ts3dutils.NLA_PRECISION);for(;ts3dutils.lt(h,c);){switch(h%4){case 0:t.push(M(s,r));break;case 1:e=e!=d,t.push(M(s+1,r));break;case 2:t.push(M(s+1,r+1));break;case 3:e=e!=d,t.push(M(s,r+1))}d=!0,h++}e=e!=(d&&h%2==1&&ts3dutils.eq(h,c)),l=h,o=u}while(o!=n);if(3==t.length)i.push(...t);else{const s=triangulateVertices$$1(ts3dutils.V3.Z,t.map(t=>h[t]),[]).map(s=>t[s]);i.push(...s)}}}else e&&tsgl.pushQuad(i,!1,M(s,r),M(s+1,r),M(s,r+1),M(s+1,r+1))}}}Array.prototype.push.apply(t.TRIANGLES,i.map(s=>s+t.vertices.length)),Array.prototype.push.apply(t.vertices,a),Array.prototype.push.apply(t.normals,l),ts3dutils.enableConsole()}addToMesh2(t){const s=[];let e=1/0,i=-1/0;const r=this.surface.pUVFunc(),n=this.surface.normalUVFunc(),o=this.holes.concat([this.contour]).map(t=>this.unrollLoop(t));o.forEach(t=>{t.forEach(({x:t,y:r})=>{const n=s.binaryIndexOf(t,(t,s)=>ts3dutils.snap(t.value-s,0));n<0&&s.splice(-n-1,0,{value:t,left:[],right:[]}),e=min(e,r),i=max(i,r)})}),console.log("zzzs",e,i,o[0].toSource().replace(/\), /g,",\n"));o.forEach(t=>{t.forEach((t,e,i)=>{let r=i[(e+1)%i.length],n=r.x-t.x;if(ts3dutils.eq0(n))return;n<0&&([t,r]=[r,t],n=-n);const o=s.binaryIndexOf(t.x,(t,s)=>ts3dutils.snap(t.value-s,0)),a=s.binaryIndexOf(r.x,(t,s)=>ts3dutils.snap(t.value-s,0));s[o].right.binaryInsert(t.y);for(let e=(o+1)%s.length;e!=a;e=(e+1)%s.length){const i=(s[e].value-t.x)/n,o=r.y*i+t.y*(1-i);s[e].left.binaryInsert(o),s[e].right.binaryInsert(o)}s[a].left.binaryInsert(r.y)})});const a=[],u=[],l=[];for(let t=0;te+(1+t)*h);console.log("detailsZs",d);for(let t=0;ts+t.vertices.length);Array.prototype.push.apply(t.vertices,a),Array.prototype.push.apply(t.TRIANGLES,m),Array.prototype.push.apply(t.normals,l)}}const EPS$$1=1e-5;let globalId=0;function getGlobalId$$1(){return globalId++}function addLikeSurfaceFaces$$1(t,s,e){for(let i=0;i!i.has(t));){o=n;const e=[];let a=0;do{i.add(o),e.push(o);const r=t.filter(t=>o.b.like(t.a)),n=s.normalP(o.b),a=r.indexWithMax(t=>o.bDir.angleRelativeNormal(t.aDir,n));o=r[a]}while(n!=o&&a++<200);ts3dutils.assert(201!=a),r.push(e)}const a=BRep$$1.assembleFacesFromLoops(r,s,e);return ts3dutils.assertf(()=>1==a.length),a[0]}function calcNextEdgeIndex$$1(t,s,e){let i=-20,r=!1,n=Number.MAX_SAFE_INTEGER;const o=t.bDir.cross(e),a=sign(t.deltaT()),u=t.curve.diff(t.bT,1e-4*-a).dot(o);for(let a=s.length;a--;){const l=s[a],c=(t.bDir.negated().angleRelativeNormal(l.aDir,e)+ts3dutils.TAU+ts3dutils.NLA_PRECISION)%ts3dutils.TAU-ts3dutils.NLA_PRECISION;if(ts3dutils.eq0(c)){if(t.curve.isColinearTo(l.curve))continue;const s=sign(l.deltaT()),e=l.curve.diff(l.aT,1e-4*s).dot(o)-u;e<0&&(!r||e>i)&&(r=!0,i=e,n=a)}else r||ts3dutils.gt(c,i)&&(i=c,n=a)}return n==Number.MAX_SAFE_INTEGER?0:n}class BRep$$1 extends ts3dutils.Transformable{constructor(t,s,e,i){super(),this.faces=t,ts3dutils.assertInst(Face$$1,...t),this.infiniteVolume=s,ts3dutils.assert(!this.infiniteVolume||!0===this.infiniteVolume),this.generator=e,this.vertexNames=i,this.edgeFaces=void 0}static loop1ContainsLoop2(t,s,e,i,r){for(const s of e){const e=r.loopContainsPoint(t,s.a);if(exports.PointVsFace.ON_EDGE!=e)return exports.PointVsFace.INSIDE==e}for(const s of e){const e=s.curve.at(.2*s.aT+.8*s.bT),i=r.loopContainsPoint(t,e);if(exports.PointVsFace.ON_EDGE!=i)return exports.PointVsFace.INSIDE==i}if(s!=i)return i;throw new Error(t.sce+e.sce)}static assembleFacesFromLoops(t,s,e,i){const r=[],n=[];return t.forEach(t=>(function t(e,i){if(0==i.length)i.push(e);else{const r=i.find(t=>BRep$$1.loop1ContainsLoop2(t.loop,t.ccw,e.loop,e.ccw,s));if(r)t(e,r.subloops);else{for(let t=i.length;--t>=0;){const r=i[t];BRep$$1.loop1ContainsLoop2(e.loop,e.ccw,r.loop,r.ccw,s)&&(e.subloops.push(r),i.splice(t,1))}i.push(e)}}})({loop:t,ccw:s.edgeLoopCCW(t),subloops:[]},n)),n.forEach(t=>(function t(n){if(n.ccw)if(n.subloops.every(t=>!t.ccw)){const o=n.subloops.map(t=>t.loop),a=i&&i.newSubFace(e,s,n.loop,o),u=new e.constructor(s,n.loop,o,"genface"+getGlobalId$$1(),a);r.push(u),n.subloops.forEach(s=>s.subloops.forEach(s=>s.ccw&&t(s)))}else n.subloops.forEach(s=>s.ccw&&t(s))})(t)),r}static join(t,s){return new BRep$$1(t.flatMap(t=>t.faces),!1,s)}containsPoint(t,s=!1){const e=[ts3dutils.V(-.3920414696448526,-.12936136783391444,-.9108068525164064),ts3dutils.V(.6520650903544943,-.07151288645511984,-.7547827667692488),ts3dutils.V(.9433494201061395,-.2402757256238473,-.22882186797013926),ts3dutils.V(.13678704228501923,-.04480387361087783,.9895867410047372),ts3dutils.V(.0662057922721913,-.5865836917435423,.8071780259955845),ts3dutils.V(-.7322576567870621,-.12953393611526787,.6685953061989045),ts3dutils.V(.6579719127258273,-.012300218400456116,.7529420075219719),ts3dutils.V(-.5576497966736425,.8006695748324647,.2189861552871446)];t:for(const i of e){const e=new L3$$1(t,i);let r=this.infiniteVolume;for(const t of this.faces){ts3dutils.assert(!t.surface.containsCurve(e));const i=t.surface.isTsForLine(e);for(const n of i){const i=e.at(n),o=t.containsPoint2(i);if(!s&&ts3dutils.assert(!ts3dutils.eq0(n)),n>0){if(o==exports.PointVsFace.ON_EDGE)continue t;o==exports.PointVsFace.INSIDE&&(r=!r)}}}return r}return!1}withMergedFaces(){const t=[];for(let s=0;st.includes(this.faces[i]));r&&(r.push(this.faces[s]),e=!0)}!e&&t.push([this.faces[s]])}if(console.log("likeSurfaceFaces",t),t.every(t=>1==t.length))return this;const s=[];let e=0;for(const i of t)if(console.log(i),1==i.length)s.push(i[0]);else{const t=i.flatMap(t=>t.getAllEdges());for(let s=t.length;s-- >0;)for(let i=0;i=0&&i>=0&&e++<500,s+" "+i+" "+e),t[s].isCoEdge(t[i])){t.splice(s,1),t.splice(i,1),s--;break}const r=assembleFaceFromLooseEdges$$1(t,i[0].surface,i[0]);s.push(r)}return new BRep$$1(s,this.infiniteVolume,this.generator&&this.generator+".withMergedFaces()",this.vertexNames)}calculateVolume(){return this.faces.map(t=>t.zDirVolume().volume).sum()}toMesh(){const t=(new tsgl.Mesh).addVertexBuffer("normals","ts_Normal").addIndexBuffer("TRIANGLES").addIndexBuffer("LINES");t.faceIndexes=new Map;for(const s of this.faces){const e=t.TRIANGLES.length;s.addToMesh(t),t.faceIndexes.set(s,{start:e,count:t.TRIANGLES.length-e})}return t}minus(t,s){const e=this.generator&&t.generator&&this.generator+".minus("+t.generator+")";return this.intersection(t.flipped(),!0,!0,e,s)}plus(t,s){const e=this.generator&&t.generator&&this.generator+".plus("+t.generator+")";return this.flipped().intersection(t.flipped(),!0,!0,e,s).flipped()}and(t,s){const e=this.generator&&t.generator&&this.generator+".and("+t.generator+")";return this.intersection(t,!0,!0,e,s)}xor(t,s){const e=this.generator&&t.generator&&this.generator+".xor("+t.generator+")";return new BRep$$1(this.minus(t,s).faces.concat(t.minus(this,s).faces),this.infiniteVolume!=t.infiniteVolume,e)}equals(t){return this.faces.length==t.faces.length&&this.faces.every(s=>t.faces.some(t=>s.equals(t)))}like(t){return this.faces.length==t.faces.length&&this.faces.every(s=>t.faces.some(t=>s.likeFace(t)))}toString(){return`new BRep([\n${this.faces.join(",\n").replace(/^/gm,"\t")}], ${this.infiniteVolume})`}getConstructorParameters(){return[this.faces,this.infiniteVolume]}toSource(t=!0){return t&&this.generator||`new BRep([\n${this.faces.map(ts3dutils.SCE).join(",\n").replace(/^/gm,"\t")}], ${this.infiniteVolume})`}reconstituteFaces(t,s,e,i,r){const n=new Map,o=[];for(const u of t){const t=u.getAllEdges().filter(t=>!s.get(t)),l=u.getAllEdges().mapFilter(t=>s.get(t)).concatenated(),c=e.get(u)||[];if(c.length||l.length){n.set(u,"partial");const s=[];function a(){return c.find(t=>!e.has(t))||l.find(t=>!e.has(t))||t.find(t=>!e.has(t))}const e=new Set;let h;for(;h=a();){const i=h,r=[];let n=0;do{e.add(h),r.push(h);const s=t.filter(t=>h.b.like(t.a)),n=l.filter(t=>h.b.like(t.a)),o=c.filter(t=>h.b.like(t.a)),a=s.concat(n,o);if(0==a.length)break;ts3dutils.assert(0u.sce);const d=u.surface.normalP(h.b),p=calcNextEdgeIndex$$1(h,a,d);if(h=a[p],e.has(h))break;ts3dutils.assert(h),ts3dutils.assert(h!=i)}while(++n<400);400==n&&ts3dutils.assert(!1,"too many"),r.length>1&&h==i&&s.push(r)}const d=BRep$$1.assembleFacesFromLoops(s,u.surface,u,r);i.push(...d);const p=d.flatMap(t=>t.getAllEdges());o.push(...t.filter(t=>p.includes(t)))}}for(;0!=o.length;){const t=o.pop();this.edgeFaces.get(t.getCanon()).forEach(t=>{n.has(t.face)||(n.set(t.face,"inside"),o.push.apply(o,t.face.getAllEdges()))})}i.push(...t.filter(t=>"inside"==n.get(t)))}static getLooseEdgeSegments(t,s){const e=new javasetmap_ts.JavaMap;for(const[r,n]of t){if(0==n.length)continue;const t=s.get(r);n.sort((t,s)=>ts3dutils.snap0(t.edgeT-s.edgeT)||0);let o,a=r.a,u=r.aDir,l=r.aT;function i(s,i,n){for(let s=0;s{t.faces.forEach(o=>{n.intersectFace(o,this,t,s,e,i,r)})}),Array.from(s.values()).concatenated()}shellCount(){const t=new Set;let s,e=0;for(;s=this.faces.find(s=>!t.has(s));){e++;const i=[s];for(;s=i.pop();)for(const e of s.getAllEdges())for(const{face:r}of this.edgeFaces.get(e.getCanon()))s===r||t.has(r)||(t.add(r),i.push(r))}return e}getAABB(){return ts3dutils.AABB.forAABBs(this.faces.map(t=>t.getAABB()))}assertSanity(){if(ts3dutils.NLA_DEBUG){this.buildAdjacencies();for(const[t,s]of this.edgeFaces)ts3dutils.assert(s.length%2==0,()=>t+s.sce)}}buildAdjacencies(){if(this.edgeFaces)return this;this.edgeFaces=new javasetmap_ts.JavaMap;for(const t of this.faces)for(const s of t.getAllEdges()){const e=s.getCanon(),i=t.surface.normalP(e.a),r=i.cross(e==s?s.aDir:s.bDir);ts3dutils.mapPush(this.edgeFaces,e,{face:t,edge:s,normalAtCanonA:i,reversed:e!=s,inside:r,angle:0})}for(const[t,s]of this.edgeFaces){const e=s.find(t=>t.reversed);e?(s.forEach(s=>{s!=e&&(s.angle=e.inside.angleRelativeNormal(s.inside,t.aDir.unit()),s.angle<0&&(s.angle+=2*Math.PI))}),s.sort((t,s)=>ts3dutils.snap(t.angle-s.angle,0))):console.warn("invalid brep")}return this}intersection(t,s,e,i,r){this.assertSanity(),t.assertSanity(),this.buildAdjacencies(),t.buildAdjacencies();const n=new Map,o=new javasetmap_ts.JavaMap,a=new javasetmap_ts.JavaMap,u=new javasetmap_ts.JavaSet;for(const s of this.faces)for(const e of t.faces)s.intersectFace(e,this,t,n,o,a,u);for(const t of o.keys())ts3dutils.assert(this.edgeFaces.get(t));for(const s of a.keys())ts3dutils.assert(t.edgeFaces.get(s));const l=[];if(0==n.size&&0==o.size&&0==a.size){const s=t.containsPoint(this.faces[0].contour[0].a,!0)!==t.infiniteVolume,e=!s&&this.containsPoint(t.faces[0].contour[0].a)!==this.infiniteVolume;if(s||e){const[e,i]=s?[this,t]:[t,this];return e.infiniteVolume?i.infiniteVolume?i:BRep$$1.join([e,i]):i.infiniteVolume?BRep$$1.EMPTY:e}return this.infiniteVolume?t.infiniteVolume?BRep$$1.join([this,t]):BRep$$1.EMPTY:t.infiniteVolume?this:BRep$$1.EMPTY}if(s){const t=BRep$$1.getLooseEdgeSegments(o,this.edgeFaces);this.faces.map(s=>[s,Array.from(t.entries()).flatMap(([t,e])=>s.getAllEdges().some(s=>s.equals(t))?e:[])]);this.reconstituteFaces(this.faces,t,n,l,r)}if(e){const s=BRep$$1.getLooseEdgeSegments(a,t.edgeFaces);t.faces.map(t=>[t,Array.from(s.entries()).flatMap(([s,e])=>t.getAllEdges().some(t=>t.equals(s))?e:[])]);t.reconstituteFaces(t.faces,s,n,l,r)}return new BRep$$1(l,this.infiniteVolume&&t.infiniteVolume,i)}transform(t,s){let e;return this.vertexNames&&(e=new Map,this.vertexNames.forEach((i,r)=>e.set(t.transformPoint(r),i+s))),new BRep$$1(this.faces.map(s=>s.transform(t)),this.infiniteVolume,this.generator&&s&&this.generator+s,e)}transform4(t,s){let e;return this.vertexNames&&(e=new Map,this.vertexNames.forEach((i,r)=>e.set(t.transformPoint(r),i+s))),new BRep$$1(this.faces.map(s=>s.transform4(t)),this.infiniteVolume,this.generator&&s&&this.generator+s,e)}flipped(){return new BRep$$1(this.faces.map(t=>t.flipped()),!this.infiniteVolume,this.generator&&this.generator+".flipped()",this.vertexNames)}}function dotCurve$$1(t,s,e){let i=t.dot(s);return ts3dutils.eq0(i)&&(i=t.dot(e)),ts3dutils.assert(!ts3dutils.eq0(i)),i}function dotCurve2$$1(t,s,e,i){ts3dutils.assert(1==i||-1==i,i);const r=t.tangentAt(s).dot(e);if(!ts3dutils.eq0(r))return i*r;if(t.ddt){const i=t.ddt(s).dot(e);if(!ts3dutils.eq0(i))return i}const n=t.at(s).to(t.at(s+4*i*ts3dutils.NLA_PRECISION)).dot(e);return ts3dutils.assert(!(t instanceof L3$$1)),n}BRep$$1.EMPTY=new BRep$$1([],!1,"BRep.EMPTY",new Map).buildAdjacencies(),BRep$$1.R3=new BRep$$1([],!0,"BRep.R3",new Map).buildAdjacencies();const INSIDE$$1=0,OUTSIDE$$1=1,COPLANAR_SAME$$1=2,COPLANAR_OPPOSITE$$1=3,ALONG_EDGE_OR_PLANE$$1=4;function splitsVolumeEnclosingFaces$$1(t,s,e,i){ts3dutils.assert(4==arguments.length),ts3dutils.assert(s==s.getCanon());const r=t.edgeFaces.get(s);ts3dutils.assertf(()=>r.length%2==0),ts3dutils.assertf(()=>t.edgeFaces);const n=r[0],o=s.aDir.unit(),a=(n.inside.angleRelativeNormal(e,o)+2*Math.PI+ts3dutils.NLA_PRECISION)%(2*Math.PI)-ts3dutils.NLA_PRECISION,u=r.findIndex(t=>ts3dutils.lt(a,t.angle)),l=r[-1==u?r.length-1:u-1];if(ts3dutils.eq(l.angle,a)){return l.normalAtCanonA.dot(i)>0?COPLANAR_SAME$$1:COPLANAR_OPPOSITE$$1}return l.reversed?INSIDE$$1:OUTSIDE$$1}function splitsVolumeEnclosingFacesP$$1(t,s,e,i,r){ts3dutils.assert(5==arguments.length),ts3dutils.assert(s==s.getCanon()),ts3dutils.assertf(()=>t.edgeFaces);const n=t.edgeFaces.get(s);ts3dutils.assertf(()=>n.length%2==0);const o=s.tangentAt(s.curve.pointT(e)).unit(),a=t=>{const s=t.edge.getCanon()==t.edge?o:o.negated(),r=t.face.surface.normalP(e).cross(s);return-((i.angleRelativeNormal(r,o)+ts3dutils.TAU+ts3dutils.NLA_PRECISION)%ts3dutils.TAU-ts3dutils.NLA_PRECISION)},u=n.withMax(a);if(ts3dutils.eq0(a(u))){return u.face.surface.normalP(e).dot(r)>0?COPLANAR_SAME$$1:COPLANAR_OPPOSITE$$1}return u.reversed?OUTSIDE$$1:INSIDE$$1}function splitsVolumeEnclosingFacesP2$$1(t,s,e,i,r,n,o){ts3dutils.assert(s==s.getCanon()),ts3dutils.assertf(()=>t.edgeFaces);const a=t.edgeFaces.get(s);ts3dutils.assertf(()=>a.length%2==0);const u=s.tangentAt(s.curve.pointT(e)).unit();let l=i.tangentAt(r).times(n);l.isParallelTo(u)&&(l=(l=i.diff(r,1e-4*n/i.tangentAt(r).length()).rejectedFrom(u)).div(l.length()));let c=20,h=!1,d=OUTSIDE$$1;for(const t of a){const s=t.edge.getCanon()==t.edge?u:u.negated(),a=t.face.surface.normalP(e).cross(s),p=(l.angleRelativeNormal(a,u)+ts3dutils.TAU+ts3dutils.NLA_PRECISION)%ts3dutils.TAU-ts3dutils.NLA_PRECISION;if(ts3dutils.eq0(p)){const s=t.face.surface.normalP(e);if(t.face.surface.containsCurve(i)){return s.dot(o)>0?COPLANAR_SAME$$1:COPLANAR_OPPOSITE$$1}const a=P3$$1.normalOnAnchor(u,e),p=t.face.surface.isCurvesWithPlane(a)[0],f=p.pointT(e),m=sign(p.tangentAt(f).dot(l)),$=1e-4,g=(p.at(f).to(p.at(f+n*m*$)).dot(s)-i.at(r).to(i.at(r+n*$)).dot(s))*(t.reversed?-1:1);g>0&&(!h||go instanceof PlaneFace$$1),o.getAllEdges().some(t=>t.a.like(s)))if(i.isParallelToPlane(o.surface.plane)){if(o.pointsToInside(s,e)!=exports.PointVsFace.OUTSIDE)return ALONG_EDGE_OR_PLANE$$1}else{const t=L3$$1.fromPlanes(i,o.surface.plane),n=o.edgeISPsWithPlane(t,i);let a=0;for(;at.angle-s.angle),ts3dutils.eq0(r[0].angle)?ALONG_EDGE_OR_PLANE$$1:r[0].out?OUTSIDE$$1:INSIDE$$1}function splitsVolumeEnclosingCone2$$1(t,s,e,i,r){ts3dutils.assert(e.containsPoint(s));const n=t.faces.filter(t=>t.getAllEdges().some(t=>t.a.like(s)));for(let t=0;t4&&(!r(h.x,h.y)||!n(d.x,d.y)))break;c=c.plus(m)}return{points:o,tangents:a,st1s:u,st2s:l}}function followAlgorithm2d$$1(t,s,e=.5,i,r,n,o){ts3dutils.assertNumbers(e,t(0,0)),ts3dutils.assertVectors(s),o||(o=new ts3dutils.V3(-t.y(s.x,s.y),t.x(s.x,s.y),0).toLength(e)),ts3dutils.assertVectors(o);const a=[],u=[];ts3dutils.assert(ts3dutils.eq0(t(s.x,s.y),.01),"isZero(implicitCurve(startPoint.x, startPoint.y))",t(s.x,s.y));let l=0,c=s,h=o,d=!1;do{a.push(c),u.push(h);const o=c.plus(h);ts3dutils.assert(o);const p=curvePointMF$$1(t,o),f=t.x(p.x,p.y),m=t.y(p.x,p.y),$=new ts3dutils.V3(-m,f,0).toLength(e);if(ts3dutils.assert(!c.equals(p)),h.dot($)<0){const s=ts3dutils.newtonIterate2d(t.x,t.y,c.x,c.y);if(ts3dutils.eq0(t(s.x,s.y))&&s.distanceTo(c)abs(e)){a.pop(),u.pop(),ts3dutils.assert(a.last.distanceTo(s)<=abs(e));break}}else l>4&&c.distanceTo(s)<=abs(e)&&(d=!0);if(l>1&&!uvInAABB2$$1(i,c.x,c.y)){const s=figureOutBorderPoint(i,c,t);a.pop(),u.pop(),a.last.distanceTo(s)4&&!r(c.x,c.y))break;ts3dutils.assert(ts3dutils.eq0(t(p.x,p.y),2*ts3dutils.NLA_PRECISION),c,p,o,t(p.x,p.y)),h=$,c=p}while(++l<1e3);return ts3dutils.assert(l<1e3),{points:a,tangents:u}}function figureOutBorderPoint(t,s,e){if(s.xe(i,t),s.y,4,t=>e.y(i,t));if(uvInAABB2$$1(t,i,r))return new ts3dutils.V3(i,r,0)}if(s.ye(t,i),s.x,4,t=>e.x(t,i));return ts3dutils.assert(uvInAABB2$$1(t,r,i)),new ts3dutils.V3(r,i,0)}throw new Error(s+" "+t)}function followAlgorithm2dAdjustable$$1(t,s,e=.5,i,r=s){ts3dutils.assertNumbers(e,t(0,0)),ts3dutils.assertVectors(s);const n=[],o=[];ts3dutils.assert(ts3dutils.eq0(t(s.x,s.y),.01),"isZero(implicitCurve(startPoint.x, startPoint.y))");let a=s,u=a,l=0;do{const s=t.x(a.x,a.y),e=t.y(a.x,a.y),i=t.xx(a.x,a.y),r=t.yy(a.x,a.y),l=t.xy(a.x,a.y),c=abs((Math.pow(e,2)*i-2*s*e*l+Math.pow(s,2)*r)/Math.pow(Math.pow(s,2)+Math.pow(e,2),2)),h=new ts3dutils.V3(s,e,0).times(c),d=1/16/h.length(),p=new ts3dutils.V3(-e,s,0).unit(),f=a.plus(p.times(d).plus(h.times(Math.pow(d,2)/2)));n.push(a),o.push(p),u=a;const m=curvePointMF$$1(t,f);m.equals(a)&&ts3dutils.assertNever(),console.log(a.to(m).length()),a=m,ts3dutils.assert(ts3dutils.eq0(t(a.x,a.y)))}while(l++<1e3&&(l<4||u.distanceTo(r)>e)&&i(a.x,a.y));ts3dutils.assert(1e3!=l);const c=l<4||u.distanceTo(r)>e?a:r,h=new ts3dutils.V3(-t.y(c.x,c.y),t.x(c.x,c.y),0).toLength(e);return n.push(c),o.push(h),{points:n,tangents:o}}function intersectionICurveICurve$$1(t,s,e,i,r,n){ts3dutils.assertNumbers(r,t(0,0),n(0,0)),ts3dutils.assertVectors(s,e),ts3dutils.assert(!i||i instanceof ts3dutils.V3);const o=[];ts3dutils.assert(ts3dutils.eq0(t(s.x,s.y))),r=r||.5;let a=s,u=a,l=0;for(;l++<1e3&&(l<4||a.distanceTo(e)>1.1*r);){const s=t(a.x,a.y),e=(t(a.x+1e-5,a.y)-s)/1e-5,i=(t(a.x,a.y+1e-5)-s)/1e-5;let n=new ts3dutils.V3(-i,e,0).toLength(r);a.minus(u).dot(n)<0&&(n=n.negated()),u=a,a=curvePointMF$$1(t,a.plus(n)),o.push(a)}return o}function intersectionICurveICurve2$$1(t,s,e){let i,r=s[0],n=e(r.x,r.y);const o=[];for(let a=0;a(e*e+i*i)*(e*e+i*i)-2*s*s*(e*e-i*i)-(Math.pow(t,4)-Math.pow(s,4))}!function(t){t.forNerdamer=function(t,s=["x","y"]){const e=nerdamer(t),i=nerdamer.diff(e,s[0]),r=nerdamer.diff(e,s[1]),n=e.buildFunction(s);return n.x=i.buildFunction(s),n.y=r.buildFunction(s),n.xx=nerdamer.diff(i,s[0]).buildFunction(s),n.xy=nerdamer.diff(i,s[1]).buildFunction(s),n.yy=nerdamer.diff(r,s[1]).buildFunction(s),n},t.nerdamerToR2_R=function(t,s=["x","y"]){return t.buildFunction(s)},t.forFFxFy=function(t,s,e){return t.x=s,t.y=e,t}}(exports.MathFunctionR2R||(exports.MathFunctionR2R={}));const cas2$$1=cassini$$1(.9,1.02);function arrayLerp$$1(t,s,e){return 0==e%1?s[e]:t(s[Math.floor(e)],s[Math.ceil(e)],e%1)}function doNotSerialize$$1(t,s){(t.__SERIALIZATION_BLACKLIST||(t.__SERIALIZATION_BLACKLIST={}))[s]="no"}class ClassSerializer$$1{constructor(){this.CLASS_NAMES=new Map,this.NAME_CLASSES=new Map,this.addClass("Object",Object)}addClass(t,s){if(this.NAME_CLASSES.has(t))throw new Error(t);return this.NAME_CLASSES.set(t,s),this.CLASS_NAMES.set(s,t),this}addNamespace(t,s){return Object.keys(t).forEach(e=>{const i=t[e];"function"==typeof i&&i.name&&this.addClass((s?s+".":"")+e,i)}),this}setUpdater(t){return this.updater=t,this}serialize(t){return JSON.stringify(this.serializeObj(t))}serializeObj(t){const s=t=>{if(void 0!==t&&t.hasOwnProperty("constructor")&&this.CLASS_NAMES.has(t.constructor));else if(Array.isArray(t))if(i.has(t))r.has(t)||(r.set(t,n.length),n.push(t));else{i.add(t);for(let e=0;e{if("string"==typeof t||"number"==typeof t||"boolean"==typeof t||null===t)return t;if(void 0===t)return{"#REF":-1};if(t.hasOwnProperty("constructor")&&this.CLASS_NAMES.has(t.constructor))return{"#REF":this.CLASS_NAMES.get(t.constructor)};let n;if(s&&!i&&void 0!==(n=r.get(t)))return{"#REF":n};if(Array.isArray(t))return t.map(t=>e(t,s));if("object"==typeof t){if(t.getConstructorParameters)return{"#CONSTRUCTOR":this.CLASS_NAMES.get(t.constructor),"#ARGS":e(t.getConstructorParameters(),!1)};const i={};Object.prototype!==Object.getPrototypeOf(t)&&(i["#PROTO"]=e(Object.getPrototypeOf(t),s));for(const r of Object.keys(t))"__noxProxy"!=r&&"__noxTarget"!=r&&(t.__SERIALIZATION_BLACKLIST&&t.__SERIALIZATION_BLACKLIST[r]||(i[r]=e(t[r],s)));return i}throw new Error("?"+typeof t+t.toString())},i=new Set,r=new Map;let n=[];return r.set(t,0),n.push(t),s(t),n=n.map(t=>e(t,!0,!0))}unserialize(t){let s=0;const e=(t,n)=>{if(++s>100)throw new Error;if(t&&t.constructor===Array){n(t);for(let s=0;st[s]=e)}else if("object"==typeof t&&void 0!=t)if("#CONSTRUCTOR"in t){const s=t["#CONSTRUCTOR"],i=this.NAME_CLASSES.get(s);ts3dutils.assert(i,s+" Missing ");let r=void 0;e(t["#ARGS"],t=>r=t),n(new i(...r))}else if("#REF"in t){const s=t["#REF"];"string"==typeof s?n(this.NAME_CLASSES.get(s).prototype):"number"==typeof s&&(-1==s?n(void 0):r[s]?n(r[s]):e(i[s],t=>n(r[s]=t)))}else{let s;"#PROTO"in t?e(t["#PROTO"],t=>{s=Object.create(t),n(s)}):n(s=t);const i=Object.keys(t);for(let r=0;rs[i[r]]=t);Object.defineProperty(s,"loadID",{value:getGlobalId$$1(),enumerable:!1,writable:!1}),this.updater&&this.updater(s)}else n(t);s--},i=JSON.parse(t),r=new Array(i.length);return e({"#REF":0},()=>{}),r[0]}}const fragmentShaderLighting="\n\tprecision highp float;\n\tuniform vec4 color;\n\tuniform vec3 camPos;\n\tvarying vec3 normal;\n\tvarying vec4 vPosition;\n\tvoid main() {\n\t\tvec3 normal1 = normalize(normal);\n\t\tvec3 lightPos = vec3(1000, 2000, 4000);\n\t\tvec3 lightDir = normalize(vPosition.xyz - lightPos);\n vec3 reflectionDirection = reflect(lightDir, normal1);\n vec3 eyeDirection = normalize(camPos.xyz-vPosition.xyz);\n float uMaterialShininess = 256.0;\n\t\tfloat specularLightWeighting = pow(max(dot(reflectionDirection, eyeDirection), 0.0), uMaterialShininess);\n\t\tfloat lightIntensity = 0.6 + 0.2 * max(0.0, -dot(lightDir, normal1)) + 0.2*specularLightWeighting;\n\t\tgl_FragColor = vec4(vec3(color) * lightIntensity, 1);\n\t}\n",vertexShaderLighting="\n\tuniform mat4 ts_ModelViewProjectionMatrix;\n\tuniform mat4 ts_ModelViewMatrix;\n\tattribute vec4 ts_Vertex;\n\tuniform mat3 ts_NormalMatrix;\n\tattribute vec3 ts_Normal;\n\tuniform vec4 color;\n\tvarying vec3 normal;\n\tvarying vec4 vPosition;\n\tvoid main() {\n\t\tgl_Position = ts_ModelViewProjectionMatrix * ts_Vertex;\n vPosition = ts_ModelViewMatrix * ts_Vertex;\n\t\tnormal = normalize(ts_NormalMatrix * ts_Normal);\n\t}\n",vertexShaderWaves="\n\tuniform mat4 ts_ModelViewProjectionMatrix;\n\tuniform mat4 ts_ModelViewMatrix;\n\tattribute vec4 ts_Vertex;\n\tuniform mat3 ts_NormalMatrix;\n\tattribute vec3 ts_Normal;\n\tuniform vec4 color;\n\tvarying vec3 normal;\n\tvarying vec4 vPosition;\n\tvoid main() {\n\t\tnormal = normalize(ts_NormalMatrix * ts_Normal);\n\t\tfloat offset = mod (((ts_Vertex.x + ts_Vertex.y + ts_Vertex.z) * 31.0), 20.0) - 10.0;\n\t\tvec4 modPos = ts_Vertex + vec4(normal * offset, 0);\n\t\tgl_Position = ts_ModelViewProjectionMatrix * modPos;\n vPosition = ts_ModelViewMatrix * modPos;\n\t}\n",vertexShaderBasic="\n\tuniform mat4 ts_ModelViewProjectionMatrix;\n\tattribute vec4 ts_Vertex;\n\tvoid main() {\n\t\tgl_Position = ts_ModelViewProjectionMatrix * ts_Vertex;\n\t}\n",vertexShaderColor="\n\tuniform mat4 ts_ModelViewProjectionMatrix;\n\tattribute vec4 ts_Vertex;\n\tattribute vec4 ts_Color;\n\tvarying vec4 fragColor;\n\tvoid main() {\n\t\tgl_Position = ts_ModelViewProjectionMatrix * ts_Vertex;\n\t\tfragColor = ts_Color;\n\t}\n",vertexShaderArc="\n\tuniform mat4 ts_ModelViewProjectionMatrix;\n\tattribute vec4 ts_Vertex;\n\tuniform float step, offset;\n\tuniform float radius, width;\n\tvoid main() {\n\t\tfloat r = radius;\n\t\tfloat t = offset + ts_Vertex.x * step;\n\t\tfloat pRadius = r - ts_Vertex.y * width;\n\t\tvec4 p = vec4(pRadius * cos(t), pRadius * sin(t), 0, 1);\n\t\tgl_Position = ts_ModelViewProjectionMatrix * p;\n}\n",vertexShaderConic3d="\n\tuniform mat4 ts_ModelViewProjectionMatrix;\n\tattribute vec4 ts_Vertex;\n\tuniform float startT, endT, scale;\n\tuniform vec3 center, f1, f2;\n\tuniform int mode;\n\tfloat sinh(float x) { return (exp(x) - exp(-x)) / 2.0; }\n\tfloat cosh(float x) { return (exp(x) + exp(-x)) / 2.0; }\n\tvoid main() {\n\t\tfloat t = startT + ts_Vertex.x * (endT - startT);\n\n\t\tvec3 normal = normalize(cross(f1, f2));\n\n\t\tvec3 p, tangent;\n\t\tif (0 == mode) { // ellipse\n\t\t\tp = center + f1 * cos(t) + f2 * sin(t);\n\t\t\ttangent = f1 * -sin(t) + f2 * cos(t);\n\t\t}\n\t\tif (1 == mode) { // parabola\n\t\t\tp = center + f1 * t + f2 * t * t;\n\t\t\ttangent = f1 + 2.0 * f2 * t;\n\t\t}\n\t\tif (2 == mode) { // hyperbola\n\t\t\tp = center + f1 * cosh(t) + f2 * sinh(t);\n\t\t\ttangent = f1 * sinh(t) + f2 * cosh(t);\n\t\t}\n\t\tvec3 outDir = normalize(cross(normal, tangent));\n\t\tvec3 p2 = p + scale * (outDir * ts_Vertex.y + normal * ts_Vertex.z);\n\t\tgl_Position = ts_ModelViewProjectionMatrix * vec4(p2, 1);\n\t}\n",vertexShaderNURBS="#version 300 es\n\tuniform mat4 ts_ModelViewProjectionMatrix;\n\tin vec4 ts_Vertex;\n\tuniform float startT, endT, scale;\n\tuniform vec4 points[32];\n\tuniform int pointCount, degree;\n\tuniform float knots[40];\n\tuniform vec3 normal;\n\tconst int MIN_DEGREE = 1;\n\tconst int MAX_DEGREE = 6;\n\t\n\tint tInterval(float t) {\n\t\tfor (int s = degree; s < 40 - 1 - degree; s++) {\n\t\t\tif (t >= knots[s] && t <= knots[s + 1]) {\n\t\t\t\treturn s;\n\t\t\t}\n\t\t}\n\t}\n\t\n\tvec4 stepp(int k, int i, vec4 dkMinus1iMinus1, vec4 dkMinus1i) {\n\t return dkMinus1i - dkMinus1iMinus1 * float(k) / (knots[i + degree - k] - knots[i - 1]);\n\t}\n\t\n\tvoid main() {\n\t\t// ts_Vertex.x is in [0, 1]\n\t\tfloat t = startT + ts_Vertex.x * (endT - startT);\n\t\t\n\t\tint s = tInterval(t);\n\t\t\n\t\tvec4 v[MAX_DEGREE + 1];\n\t\tfor (int i = 0; i < degree + 1; i++) {\n\t\t v[i] = points[s - degree + i];\n\t\t}\n\t\t\n\t\tvec4 pTangent4, ddt4 = vec4(0, 0, 1, 0);\n\t\tfor (int level = 0; level < degree; level++) {\n\t\t\tif (level == degree - 2) {\n\t\t\t\t// see https://www.globalspec.com/reference/61012/203279/10-8-derivatives\n\t\t\t\tvec4 a = v[degree];\n\t\t\t\tvec4 b = v[degree - 1];\n\t\t\t\tvec4 c = v[degree - 2];\n\t\t\t\tddt4 = stepp(degree, s + 1, stepp(degree - 1, s + 1, a, b), stepp(degree - 1, s, b, c));\n\t\t\t}\n\t\t\tif (level == degree - 1) {\n\t\t\t\tvec4 a = v[degree];\n\t\t\t\tvec4 b = v[degree - 1];\n\t\t\t\tpTangent4 = (b - a) * (float(degree) / (knots[s] - knots[s + 1]));\n\t\t\t}\n\t\t\tfor (int i = degree; i > level; i--) {\n\t\t\t\tfloat alpha = (t - knots[i + s - degree]) / (knots[i + s - level] - knots[i + s - degree]);\n\n\t\t\t\t// interpolate each component\n v[i] = (1.0 - alpha) * v[i - 1] + alpha * v[i];\n\t\t\t}\n\t\t}\n\t\t\n\t\tvec4 p4 = v[degree];\n\t\t\n\t\tvec3 p = p4.xyz / p4.w;\n\t\tvec3 pTangent = ((pTangent4.xyz * p4.w) - (p4.xyz * pTangent4.w)) / (p4.w * p4.w);\n\t\tvec3 ddt = (\n\t\t p4.xyz * (-p4.w * ddt4.w + 2.0 * pow(pTangent4.w, 2.0))\n\t\t + pTangent4.xyz * (-2.0 * p4.w * pTangent4.w) \n\t\t + ddt4.xyz * pow(p4.w, 2.0)\n ) / pow(p4.w, 3.0);\n\t\t\n\t\tvec3 outDir = normalize(cross(ddt, pTangent));\n\t\tvec3 correctNormal = normalize(cross(pTangent, outDir));\n\t\tvec3 p2 = p + scale * (outDir * ts_Vertex.y + correctNormal * ts_Vertex.z);\n\t\tgl_Position = ts_ModelViewProjectionMatrix * vec4(p2, 1);\n }\n",vertexShaderBezier="\n // calculates a bezier curve using ts_Vertex.x as the (t) parameter of the curve\n\tuniform mat4 ts_ModelViewProjectionMatrix;\n\tattribute vec4 ts_Vertex;\n\tuniform float width, startT, endT;\n\tuniform vec3 p0, p1, p2, p3;\n\tvoid main() {\n\t\t// ts_Vertex.x is in [0, 1]\n\t\tfloat t = startT + ts_Vertex.x * (endT - startT), s = 1.0 - t;\n\t\tfloat c0 = s * s * s, c1 = 3.0 * s * s * t, c2 = 3.0 * s * t * t, c3 = t * t * t;\n\t\tvec3 pPos = p0 * c0 + p1 * c1 + p2 * c2 + p3 * c3;\n\t\tfloat c01 = 3.0 * s * s, c12 = 6.0 * s * t, c23 = 3.0 * t * t;\n\t\tvec3 pTangent = (p1 - p0) * c01 + (p2 - p1) * c12 + (p3 - p2) * c23;\n\t\tvec3 pNormal = normalize(vec3(pTangent.y, -pTangent.x, 0));\n\t\tvec4 p = vec4(pPos - ts_Vertex.y * width * pNormal, 1);\n\t\tgl_Position = ts_ModelViewProjectionMatrix * p;\n\t}\n",vertexShaderBezier3d="\n precision highp float;\n // calculates a bezier curve using ts_Vertex.x as the (t) parameter of the curve\n\tuniform float scale, startT, endT;\n\tuniform vec3 ps[4];\n\tuniform vec3 p0, p1, p2, p3, normal;\n\tuniform mat4 ts_ModelViewProjectionMatrix;\n\tattribute vec4 ts_Vertex;\n\tvoid main() {\n\t\t// ts_Vertex.y is in [0, 1]\n\t\tvec3 p5 = ps[0];\n\t\tfloat t = startT * (1.0 - ts_Vertex.x) + endT * ts_Vertex.x, s = 1.0 - t;\n\t\tfloat c0 = s * s * s, \n\t\t c1 = 3.0 * s * s * t, \n\t\t c2 = 3.0 * s * t * t, c3 = t * t * t;\n\t\tvec3 p = (p0 * c0 + p1 * c1) + (p2 * c2 + p3 * c3);\n\t\tfloat c01 = 3.0 * s * s, \n\t\t c12 = 6.0 * s * t, \n\t\t c23 = 3.0 * t * t;\n\t\tvec3 pTangent = (p1 - p0) * c01 + (p2 - p1) * c12 + (p3 - p2) * c23;\n\t\tvec3 outDir = normalize(cross(normal, pTangent));\n\t\tvec3 correctNormal = normalize(cross(pTangent, outDir));\n\t\tvec3 p2 = p + scale * (outDir * ts_Vertex.y + correctNormal * ts_Vertex.z);\n\t\tgl_Position = ts_ModelViewProjectionMatrix * vec4(p2, 1);\n\t}\n",vertexShaderGeneric="\n\tuniform float scale;\n\tuniform mat4 ts_ModelViewProjectionMatrix;\n\tattribute vec4 ts_Vertex;\n\tuniform mat3 ts_NormalMatrix;\n\tattribute vec3 ts_Normal;\n\tvoid main() {\n\t\tvec3 normal = normalize(ts_NormalMatrix * ts_Normal);\n\t\tvec4 vertexPos = ts_Vertex + vec4(normal * scale, 0);\n\t\tgl_Position = ts_ModelViewProjectionMatrix * vertexPos;\n\t}\n",vertexShaderRing="\n\t#define M_PI 3.1415926535897932384626433832795\n\tuniform float step;\n\tuniform float innerRadius, outerRadius;\n\tattribute float index;\n\tuniform mat4 ts_ModelViewProjectionMatrix;\n\tattribute vec4 ts_Vertex;\n\tvoid main() {\n\t\tgl_Position = ts_ModelViewProjectionMatrix * vec4(index, index, index, 1);\n\t\tfloat id = atan(ts_Vertex.x, ts_Vertex.y) / M_PI * 32.0;\n\t\tfloat radius = mod(id, 2.0) < 1.0 ? outerRadius : innerRadius;\n\t\tgl_Position = ts_ModelViewProjectionMatrix * vec4(radius * cos(index * step), radius * sin(index * step), 0, 1);\n\t}\n",fragmentShaderColor="\n\tprecision highp float;\n\tuniform vec4 color;\n\tvoid main() {\n\t\tgl_FragColor = color;\n\t}\n",fragmentShaderColor3="#version 300 es\n\tprecision highp float;\n\tuniform vec4 color;\n\tout vec4 fragColor;\n\tvoid main() {\n\t\tfragColor = color;\n\t}\n",fragmentShaderVaryingColor="\n\tprecision highp float;\n\tvarying vec4 fragColor;\n\tvoid main() {\n\t\tgl_FragColor = fragColor;\n\t}\n",fragmentShaderColorHighlight="\n\tprecision highp float;\n\tuniform vec4 color;\n\tvoid main() {\n\t\tfloat diagonal = (gl_FragCoord.x + 2.0 * gl_FragCoord.y);\n\t\tif (mod(diagonal, 50.0) > 40.0) { // mod(diagonal, 2.0) > 1.0\n\t\t\tdiscard;\n\t\t\t//gl_FragColor = color + vec4(0.2,0.2,0.2,0);\n\t\t} else {\n\t\t\tgl_FragColor = color - vec4(0.2,0.2,0.2,0);\n\t\t}\n\t}\n",vertexShaderTexture="\n\tvarying vec2 texturePos;\n\tattribute vec4 ts_Vertex;\n\tuniform mat4 ts_ModelViewProjectionMatrix;\n\tvoid main() {\n\t\ttexturePos = ts_Vertex.xy;\n\t\tgl_Position = ts_ModelViewProjectionMatrix * ts_Vertex;\n\t}\n",fragmentShaderTextureColor="\n\tprecision highp float;\n\tvarying vec2 texturePos;\n\tuniform vec4 color;\n\tuniform sampler2D texture;\n\tvoid main() {\n\t\tgl_FragColor = texture2D(texture, texturePos) * color;\n\t}\n";function parseGetParams$$1(t){const s={};return t.split("&").forEach(function(t){const e=t.indexOf("=");-1==e?s[t]=t:s[t.substr(0,e)]=decodeURI(t.substr(e+1))}),s}const COLORS$$1={RD_FILL:chroma("#9EDBF9"),RD_STROKE:chroma("#77B0E0"),TS_FILL:chroma("#D19FE3"),TS_STROKE:chroma("#A76BC2"),PP_FILL:chroma("#F3B6CF"),PP_STROKE:chroma("#EB81B4")};class BREPGLContext$$1{constructor(t){this.cachedMeshes=new WeakMap,this.shaders=initShaders$$1(t),initMeshes$$1(this.meshes={},t)}static create(t){return ts3dutils.addOwnProperties(t,BREPGLContext$$1.prototype),ts3dutils.addOwnProperties(t,new BREPGLContext$$1(t)),t}drawPoint(t,s=tsgl.GL_COLOR_BLACK,e=5){this.pushMatrix(),this.translate(t),this.scale(e/2,e/2,e/2),this.shaders.singleColor.uniforms({color:s}).draw(this.meshes.sphere1),this.popMatrix()}drawEdge(t,s=tsgl.GL_COLOR_BLACK,e=2){CURVE_PAINTERS$$1[t.curve.constructor.name](this,t.curve,s,t.minT,t.maxT,e)}drawCurve(t,s=tsgl.GL_COLOR_BLACK,e=2,i,r){CURVE_PAINTERS$$1[t.constructor.name](this,t,s,i,r,e)}drawVector(t,s,e=tsgl.GL_COLOR_BLACK,i=1){if(t.likeO())return;this.pushMatrix();const r=4*i;if(r>t.length())return;const n=t.getPerpendicular().unit();this.multMatrix(ts3dutils.M4.forSys(t.unit(),n,t.cross(n).unit(),s)),this.scale(t.length()-r,i/2,i/2),this.shaders.singleColor.uniforms({color:e}).draw(this.meshes.vectorShaft),this.scale(1/(t.length()-r),1,1),this.translate(t.length()-r,0,0),this.scale(r/2,1,1),this.shaders.singleColor.draw(this.meshes.vectorHead),this.popMatrix()}drawVectors(t,s){this.drawVector(ts3dutils.V3.X,ts3dutils.V3.O,chroma("red").gl(),s),this.drawVector(ts3dutils.V3.Y,ts3dutils.V3.O,chroma("green").gl(),s),this.drawVector(ts3dutils.V3.Z,ts3dutils.V3.O,chroma("blue").gl(),s),t.forEach(t=>this.drawVector(t.v,t.anchor,t.color,s))}drawPlane(t,s,e=!1){this.pushMatrix(),this.multMatrix(ts3dutils.M4.forSys(t.right,t.up,t.normal1)),this.translate(t.uMin,t.vMin,t.w),this.scale(t.uMax-t.uMin,t.vMax-t.vMin,1);const i=e?this.meshes.xyDottedLinePlane:this.meshes.xyLinePlane;this.shaders.singleColor.uniforms({color:s}).draw(i,this.LINES),this.popMatrix()}drawBox(t,s){this.pushMatrix(),this.multMatrix(t),s?this.shaders.singleColor.uniforms({color:s}).draw(this.meshes.cube,this.LINES):this.shaders.multiColor.draw(this.meshes.cube,this.LINES),this.popMatrix()}}function conicPainter(t,s,e,i,r,n,o=2){s.shaders.ellipse3d.uniforms({f1:e.f1,f2:e.f2,center:e.center,color:i,startT:r,endT:n,scale:o,mode:t}).draw(s.meshes.pipe)}const CURVE_PAINTERS$$1={[EllipseCurve$$1.name]:conicPainter.bind(void 0,0),[ParabolaCurve$$1.name]:conicPainter.bind(void 0,1),[HyperbolaCurve$$1.name]:conicPainter.bind(void 0,2),[ImplicitCurve$$1.name](t,s,e,i,r,n=2){let o=t.cachedMeshes.get(s);o||(o=(new tsgl.Mesh).addIndexBuffer("TRIANGLES").addVertexBuffer("normals","ts_Normal"),s.addToMesh(o,4),o.compile(),t.cachedMeshes.set(s,o));const a=ceil(i),u=floor(r);if(a<=u){const l=24;if(t.shaders.generic3d.uniforms({color:e,scale:n}).draw(o,t.TRIANGLES,a*l,(floor(r)-a)*l),i%1!=0){const r=s.at(i);t.pushMatrix();const u=ts3dutils.M4.forSys(r.to(s.points[a]),o.normals[4*a].toLength(n),o.normals[4*a+1].toLength(n),r);t.multMatrix(u),t.shaders.singleColor.uniforms({color:e}).draw(t.meshes.pipeSegmentForICurve),console.log(t.meshes.pipeSegmentForICurve),t.popMatrix()}if(r%1!=0){const i=s.at(r);t.pushMatrix();const a=ts3dutils.M4.forSys(s.points[u].to(i),o.normals[4*u].toLength(n),o.normals[4*u+1].toLength(n),s.points[u]);t.multMatrix(a),t.shaders.singleColor.uniforms({color:e}).draw(t.meshes.pipeSegmentForICurve),t.popMatrix()}}else{const o=s.at(i),a=s.at(r);t.pushMatrix();const u=o.to(a),l=u.getPerpendicular().toLength(n),c=u.cross(l).toLength(n),h=ts3dutils.M4.forSys(u,l,c,o);t.multMatrix(h),t.shaders.singleColor.uniforms({color:e}).draw(t.meshes.pipeSegmentForICurve),t.popMatrix()}},[BezierCurve$$1.name](t,s,e,i,r,n=2,o=ts3dutils.V3.Z){t.shaders.bezier3d.uniforms({p0:s.p0,p1:s.p1,p2:s.p2,p3:s.p3,color:e,startT:i,endT:r,scale:n,normal:o}).draw(t.meshes.pipe)},[NURBS$$1.name](t,s,e,i,r,n=2,o=ts3dutils.V3.Z){t.shaders.nurbs.uniforms({"points[0]":ts3dutils.Vector.pack(s.points),degree:s.degree,"knots[0]":s.knots,color:e,startT:i,endT:r,scale:n,normal:o}).draw(t.meshes.pipe)},[L3$$1.name](t,s,e,i,r,n=2,o=ts3dutils.V3.Z){t.pushMatrix();const a=s.at(i),u=s.at(r).minus(a),l=u.getPerpendicular().unit(),c=ts3dutils.M4.forSys(u,l,u.cross(l).unit(),a);t.multMatrix(c),t.scale(1,n,n),t.shaders.singleColor.uniforms({color:e}).draw(t.meshes.pipe),t.popMatrix()}};function initMeshes$$1(t,s){s.makeCurrent(),t.cube=(()=>{const t=exports.B2T.box().toMesh().addVertexBuffer("colors","ts_Color");return t.colors=t.vertices.map(t=>[t.x,t.y,t.z,1].map(t=>.9*t)),t.compile(),t})(),t.sphere1=tsgl.Mesh.sphere(2),t.segment=tsgl.Mesh.plane({startY:-.5,height:1,detailX:128}),t.text=tsgl.Mesh.plane(),t.vector=tsgl.Mesh.rotation([ts3dutils.V3.O,ts3dutils.V(0,.05,0),ts3dutils.V(.8,.05),ts3dutils.V(.8,.1),ts3dutils.V(1,0)],L3$$1.X,ts3dutils.TAU,16,!0),t.vectorShaft=tsgl.Mesh.rotation([ts3dutils.V3.O,ts3dutils.V3.Y,ts3dutils.V3.XY],L3$$1.X,ts3dutils.TAU,8,!0),t.vectorHead=tsgl.Mesh.rotation([ts3dutils.V3.Y,ts3dutils.V(0,2,0),ts3dutils.V(2,0,0)],L3$$1.X,ts3dutils.TAU,8,!0),t.pipe=tsgl.Mesh.rotation(ts3dutils.arrayFromFunction(512,(t,s)=>new ts3dutils.V3(t/(s-1),-.5,0)),L3$$1.X,ts3dutils.TAU,8,!0),t.xyLinePlane=tsgl.Mesh.plane(),t.xyDottedLinePlane=makeDottedLinePlane(),t.pipeSegmentForICurve=tsgl.Mesh.offsetVertices(ts3dutils.M4.rotateY(90*ts3dutils.DEG).transformedPoints(ts3dutils.arrayFromFunction(4,t=>ts3dutils.V3.polar(1,ts3dutils.TAU*t/4))),ts3dutils.V3.X,!0)}function initShaders$$1(t){return t.makeCurrent(),{singleColor:tsgl.Shader.create(vertexShaderBasic,fragmentShaderColor),multiColor:tsgl.Shader.create(vertexShaderColor,fragmentShaderVaryingColor),singleColorHighlight:tsgl.Shader.create(vertexShaderBasic,fragmentShaderColorHighlight),textureColor:tsgl.Shader.create(vertexShaderTexture,fragmentShaderTextureColor),arc:tsgl.Shader.create(vertexShaderRing,fragmentShaderColor),arc2:tsgl.Shader.create(vertexShaderArc,fragmentShaderColor),ellipse3d:tsgl.Shader.create(vertexShaderConic3d,fragmentShaderColor),generic3d:tsgl.Shader.create(vertexShaderGeneric,fragmentShaderColor),bezier3d:tsgl.Shader.create(vertexShaderBezier3d,fragmentShaderColor),nurbs:tsgl.Shader.create(vertexShaderNURBS,fragmentShaderColor3),bezier:tsgl.Shader.create(vertexShaderBezier,fragmentShaderColor),lighting:tsgl.Shader.create(vertexShaderLighting,fragmentShaderLighting),waves:tsgl.Shader.create(vertexShaderWaves,fragmentShaderLighting)}}function makeDottedLinePlane(t=128){const s=(new tsgl.Mesh).addIndexBuffer("LINES"),e=ts3dutils.arrayFromFunction(t,s=>new ts3dutils.V3(s/t,0,0));return s.vertices.push(...e),s.vertices.push(...ts3dutils.M4.forSys(ts3dutils.V3.Y,ts3dutils.V3.O,ts3dutils.V3.O,ts3dutils.V3.X).transformedPoints(e)),s.vertices.push(...ts3dutils.M4.forSys(ts3dutils.V3.X.negated(),ts3dutils.V3.O,ts3dutils.V3.O,new ts3dutils.V3(1,1,0)).transformedPoints(e)),s.vertices.push(...ts3dutils.M4.forSys(ts3dutils.V3.Y.negated(),ts3dutils.V3.O,ts3dutils.V3.O,ts3dutils.V3.Y).transformedPoints(e)),s.LINES=ts3dutils.arrayFromFunction(4*t,s=>s-(s>=2*t?1:0)),s.compile(),s}function initNavigationEvents$$1(t,s,e){const i=t.canvas;let r=ts3dutils.V3.O;i.addEventListener("mousemove",i=>{const n=ts3dutils.V(i.pageX,i.pageY),o=r.to(n);if(4&i.buttons){const i=ts3dutils.V(2*-o.x/t.canvas.width,2*o.y/t.canvas.height),r=t.projectionMatrix.inversed().transformVector(i);s.pos=s.pos.plus(r),s.focus=s.focus.plus(r),setupCamera$$1(s,t),e()}if(2&i.buttons){const i=-o.x/6*ts3dutils.DEG,r=-o.y/6*ts3dutils.DEG;let n=ts3dutils.M4.rotateLine(s.focus,s.up,i);const a=s.up.cross(s.pos.minus(s.focus));n=n.times(ts3dutils.M4.rotateLine(s.focus,a,r)),s.pos=n.transformPoint(s.pos),s.up=n.transformVector(s.up),setupCamera$$1(s,t),e()}r=n}),i.addEventListener("wheel",i=>{const r=2*-sign(i.deltaY);s.zoomFactor*=pow(.9,-r);const n=getPosOnTarget$$1(i),o=ts3dutils.V(2*n.x/t.canvas.offsetWidth-1,2*-n.y/t.canvas.offsetHeight+1,0),a=o.times(1-1/pow(.9,-r)),u=t.projectionMatrix.inversed(),l=u.transformVector(a);s.pos=s.pos.plus(l),s.focus=s.focus.plus(l);const c=u.transformPoint(o),h=ts3dutils.M4.rotateLine(c,s.pos.to(s.focus),10*-sign(i.deltaX)*ts3dutils.DEG);s.up=h.transformVector(s.up),s.pos=h.transformPoint(s.pos),s.focus=h.transformPoint(s.focus),setupCamera$$1(s,t),e(),i.preventDefault()})}function getMouseLine$$1(t,s){const e=ts3dutils.V(2*t.x/s.canvas.width-1,2*-t.y/s.canvas.height+1,0),i=ts3dutils.V(2*t.x/s.canvas.width-1,2*-t.y/s.canvas.height+1,1),r=s.projectionMatrix.inversed(),n=r.transformPoint(e),o=r.transformPoint(i).minus(n);return L3$$1.anchorDirection(n,o)}function getPosOnTarget$$1(t){const s=t.target.getBoundingClientRect();return{x:t.clientX-s.left,y:t.clientY-s.top}}function setupCamera$$1(t,s,e=!1){const{pos:i,focus:r,up:n,zoomFactor:o}=t;s.matrixMode(s.PROJECTION),s.loadIdentity();const a=s.canvas.width/2/o,u=s.canvas.height/2/o;s.ortho(-a,a,-u,u,-1e4,1e4),s.lookAt(i,r,n),s.matrixMode(s.MODELVIEW),!e&&cameraChangeListeners$$1.forEach(s=>s(t))}CURVE_PAINTERS$$1[PICurve$$1.name]=CURVE_PAINTERS$$1[ImplicitCurve$$1.name],CURVE_PAINTERS$$1[PPCurve$$1.name]=CURVE_PAINTERS$$1[ImplicitCurve$$1.name];const cameraChangeListeners$$1=[],SHADERS_TYPE_VAR$$1=!1;exports.Curve=Curve$$1,exports.breakDownPPCurves=breakDownPPCurves$$1,exports.AABB2=AABB2$$1,exports.uvInAABB2=uvInAABB2$$1,exports.curvePoint=curvePoint$$1,exports.curvePointMF=curvePointMF$$1,exports.XiEtaCurve=XiEtaCurve$$1,exports.parabola4Projection=parabola4Projection$$1,exports.ImplicitCurve=ImplicitCurve$$1,exports.surfaceIsICurveIsInfosWithLine=surfaceIsICurveIsInfosWithLine$$1,exports.BezierCurve=BezierCurve$$1,exports.HyperbolaCurve=HyperbolaCurve$$1,exports.L3=L3$$1,exports.PICurve=PICurve$$1,exports.PPCurve=PPCurve$$1,exports.ParabolaCurve=ParabolaCurve$$1,exports.EllipseCurve=EllipseCurve$$1,exports.NURBS=NURBS$$1,exports.P3=P3$$1,exports.Surface=Surface$$1,exports.ImplicitSurface=ImplicitSurface$$1,exports.ParametricSurface=ParametricSurface$$1,exports.ConicSurface=ConicSurface$$1,exports.ProjectedCurveSurface=ProjectedCurveSurface$$1,exports.RotatedCurveSurface=RotatedCurveSurface$$1,exports.getExtremePointsHelper=getExtremePointsHelper$$1,exports.CylinderSurface=CylinderSurface$$1,exports.EllipsoidSurface=EllipsoidSurface$$1,exports.PlaneSurface=PlaneSurface$$1,exports.PointProjectedSurface=PointProjectedSurface$$1,exports.NURBSSurface=NURBSSurface$$1,exports.ZDirVolumeVisitor=ZDirVolumeVisitor$$1,exports.glqV3=glqV3$$1,exports.glqArray=glqArray$$1,exports.CalculateAreaVisitor=CalculateAreaVisitor$$1,exports.projectCurve=projectCurve$$1,exports.projectPointCurve=projectPointCurve$$1,exports.rotateCurve=rotateCurve$$1,exports.CustomPlane=CustomPlane$$1,exports.Edge=Edge$$1,exports.PCurveEdge=PCurveEdge$$1,exports.StraightEdge=StraightEdge$$1,exports.FaceInfoFactory=FaceInfoFactory,exports.Face=Face$$1,exports.PlaneFace=PlaneFace$$1,exports.RotationFace=RotationFace$$1,exports.EPS=EPS$$1,exports.getGlobalId=getGlobalId$$1,exports.addLikeSurfaceFaces=addLikeSurfaceFaces$$1,exports.assembleFaceFromLooseEdges=assembleFaceFromLooseEdges$$1,exports.calcNextEdgeIndex=calcNextEdgeIndex$$1,exports.BRep=BRep$$1,exports.dotCurve=dotCurve$$1,exports.dotCurve2=dotCurve2$$1,exports.INSIDE=INSIDE$$1,exports.OUTSIDE=OUTSIDE$$1,exports.COPLANAR_SAME=COPLANAR_SAME$$1,exports.COPLANAR_OPPOSITE=COPLANAR_OPPOSITE$$1,exports.ALONG_EDGE_OR_PLANE=ALONG_EDGE_OR_PLANE$$1,exports.splitsVolumeEnclosingFaces=splitsVolumeEnclosingFaces$$1,exports.splitsVolumeEnclosingFacesP=splitsVolumeEnclosingFacesP$$1,exports.splitsVolumeEnclosingFacesP2=splitsVolumeEnclosingFacesP2$$1,exports.splitsVolumeEnclosingCone=splitsVolumeEnclosingCone$$1,exports.splitsVolumeEnclosingCone2=splitsVolumeEnclosingCone2$$1,exports.fff=fff$$1,exports.triangulateVertices=triangulateVertices$$1,exports.intersectionUnitCircleLine=intersectionUnitCircleLine$$1,exports.intersectionUnitCircleLine2=intersectionUnitCircleLine2$$1,exports.intersectionCircleLine=intersectionCircleLine$$1,exports.intersectionUnitHyperbolaLine=intersectionUnitHyperbolaLine$$1,exports.curvePointPP=curvePointPP$$1,exports.followAlgorithmPP=followAlgorithmPP$$1,exports.followAlgorithm2d=followAlgorithm2d$$1,exports.followAlgorithm2dAdjustable=followAlgorithm2dAdjustable$$1,exports.intersectionICurveICurve=intersectionICurveICurve$$1,exports.intersectionICurveICurve2=intersectionICurveICurve2$$1,exports.cassini=cassini$$1,exports.cas2=cas2$$1,exports.arrayLerp=arrayLerp$$1,exports.doNotSerialize=doNotSerialize$$1,exports.ClassSerializer=ClassSerializer$$1,exports.parseGetParams=parseGetParams$$1,exports.COLORS=COLORS$$1,exports.BREPGLContext=BREPGLContext$$1,exports.CURVE_PAINTERS=CURVE_PAINTERS$$1,exports.initMeshes=initMeshes$$1,exports.initShaders=initShaders$$1,exports.initNavigationEvents=initNavigationEvents$$1,exports.getMouseLine=getMouseLine$$1,exports.getPosOnTarget=getPosOnTarget$$1,exports.setupCamera=setupCamera$$1,exports.cameraChangeListeners=cameraChangeListeners$$1,exports.SHADERS_TYPE_VAR=!1; \ No newline at end of file diff --git a/dist/bundle.module.js b/dist/bundle.module.js deleted file mode 100644 index 2ef31f5..0000000 --- a/dist/bundle.module.js +++ /dev/null @@ -1,12846 +0,0 @@ -import { Transformable, assertNumbers, assert, fuzzyUniquesF, eq0, callsce, le, withMax, arrayFromFunction, newtonIterateWithDerivative, clamp, AABB, V3, newtonIterate1d, eq, glqInSteps, hasConstructor, arrayEquals, arrayHashCode, mapFilter, getIntervals, V, getLast, NLA_PRECISION, newtonIterate2dWithDerivatives, assertVectors, M4, TAU, assertInst, solveCubicReal2, snap0, toSource, arrayRange, bisect, between, assertNever, assertf, fuzzyUniques, concatenated, MINUS, combinations, lerp, lt, VV, newtonIterate, pqFormula, fuzzyBetween, checkDerivate, newtonIterateSmart, NLA_DEBUG, firstUnsorted, Vector, arraySamples, newtonIterateWithDerivative2, vArrGet, snap, setLast, max as max$1, floatHashCode, emod, isCCW, DEG, sum, getRoots, gaussLegendreQuadrature24, sliceStep, ilog, indexWithMax, gaussLegendre24Xs, gaussLegendre24Weights, GOLDEN_RATIO, min as min$1, snap2, PI as PI$1, mod, gt, doubleSignedArea, disableConsole, ge, bagRemoveIndex, enableConsole, binaryIndexOf, binaryInsert, mapPush, SCE, newtonIterate2d, addOwnProperties } from 'ts3dutils'; -import { pushQuad, Mesh, GL_COLOR_BLACK, Shader } from 'tsgl'; -import { L3 as L3$1, EllipseCurve as EllipseCurve$1, HyperbolaCurve as HyperbolaCurve$1, ParabolaCurve as ParabolaCurve$1, BezierCurve as BezierCurve$1, PlaneSurface as PlaneSurface$2, P3 as P3$2, CylinderSurface as CylinderSurface$2, XiEtaCurve as XiEtaCurve$1, ProjectedCurveSurface as ProjectedCurveSurface$2, ConicSurface as ConicSurface$1, EllipsoidSurface as EllipsoidSurface$1, RotatedCurveSurface as RotatedCurveSurface$1, getGlobalId as getGlobalId$1, StraightEdge as StraightEdge$1, createEdge as createEdge$1, Edge as Edge$2, PlaneFace as PlaneFace$1, Face as Face$1, BRep as BRep$1, PCurveEdge as PCurveEdge$1, edgePathFromSVG as edgePathFromSVG$1, NURBS as NURBS$2, edgeForCurveAndTs as edgeForCurveAndTs$1, Curve as Curve$2, PICurve as PICurve$2, dotCurve2 as dotCurve2$2, PointVsFace as PointVsFace$2, triangulateVertices as triangulateVertices$1, ParametricSurface as ParametricSurface$2, EPS as EPS$1, fff as fff$1, splitsVolumeEnclosingFacesP as splitsVolumeEnclosingFacesP$1, INSIDE as INSIDE$1, COPLANAR_SAME as COPLANAR_SAME$1, splitsVolumeEnclosingFaces as splitsVolumeEnclosingFaces$1, splitsVolumeEnclosingCone2 as splitsVolumeEnclosingCone2$1, splitsVolumeEnclosingFacesP2 as splitsVolumeEnclosingFacesP2$1, uvInAABB2 as uvInAABB2$1, curvePointMF as curvePointMF$1, ImplicitCurve as ImplicitCurve$2, PPCurve as PPCurve$2, B2T as B2T$1 } from '.'; -import { P3 as P3$1, dotCurve2 as dotCurve2$1, PPCurve as PPCurve$1, ImplicitCurve as ImplicitCurve$1, ZDirVolumeVisitor as ZDirVolumeVisitor$1, CalculateAreaVisitor as CalculateAreaVisitor$1, Surface as Surface$1, MathFunctionR2R as MathFunctionR2R$1, Curve as Curve$1, PICurve as PICurve$1, breakDownPPCurves as breakDownPPCurves$1, ParametricSurface as ParametricSurface$1, EllipseCurve as EllipseCurve$2, L3 as L3$2, HyperbolaCurve as HyperbolaCurve$2, ParabolaCurve as ParabolaCurve$2, CylinderSurface as CylinderSurface$1, PlaneSurface as PlaneSurface$1, ImplicitSurface as ImplicitSurface$1, NURBS as NURBS$1, NURBSSurface as NURBSSurface$1, intersectionUnitCircleLine2 as intersectionUnitCircleLine2$1, ProjectedCurveSurface as ProjectedCurveSurface$1, OUTSIDE as OUTSIDE$1, BezierCurve as BezierCurve$2, PointVsFace as PointVsFace$1, Edge as Edge$1, getExtremePointsHelper as getExtremePointsHelper$1 } from '..'; -import { load, Path } from 'opentype.js'; -import { random as random$1, color } from 'chroma.ts'; -import { SVGPathData } from 'svg-pathdata'; -import { Pair, JavaMap, JavaSet } from 'javasetmap.ts'; -import earcut from 'earcut'; -import nerdamer from 'nerdamer'; - -const { abs, acos, acosh, asin, asinh, atan, atanh, atan2, ceil, cbrt, expm1, clz32, cos, cosh, exp, floor, fround, hypot, imul, log, log1p, log2, log10, max, min, pow, random, round, sign, sin, sinh, sqrt, tan, tanh, trunc, E, LN10, LN2, LOG10E, LOG2E, PI, SQRT1_2, SQRT2, } = Math; - -let insideIsInfosWithCurve = false; -class Curve extends Transformable { - constructor(tMin, tMax) { - super(); - this.tMin = tMin; - this.tMax = tMax; - assertNumbers(tMin, tMax); - assert("number" === typeof tMin && !isNaN(tMin)); - assert("number" === typeof tMax && !isNaN(tMax)); - assert(tMin < tMax, "tMin < tMax " + tMin + " < " + tMax); - } - static integrate(curve, startT, endT, steps) { - const step = (endT - startT) / steps; - let length = 0; - let p = curve.at(startT); - let i = 0, t = startT + step; - for (; i < steps; i++, t += step) { - const next = curve.at(t); - length += p.distanceTo(next); - p = next; - } - return length; - } - static ispsRecursive(curve1, tMin, tMax, curve2, sMin, sMax) { - // the recursive function finds good approximates for the intersection points - // curve1 function uses newton iteration to improve the result as much as possible - function handleStartTS(startT, startS) { - if (!result.some((info) => eq(info.tThis, startT) && eq(info.tOther, startS))) { - const f1 = (t, s) => curve1.tangentAt(t).dot(curve1.at(t).minus(curve2.at(s))); - const f2 = (t, s) => curve2.tangentAt(s).dot(curve1.at(t).minus(curve2.at(s))); - // f = (b1, b2, t1, t2) = b1.tangentAt(t1).dot(b1.at(t1).minus(b2.at(t2))) - const dfdt1 = (b1, b2, t1, t2) => b1.ddt(t1).dot(b1.at(t1).minus(b2.at(t2))) + - b1.tangentAt(t1).squared(); - const dfdt2 = (b1, b2, t1, t2) => -b1.tangentAt(t1).dot(b2.tangentAt(t2)); - const ni = newtonIterate2dWithDerivatives(f1, f2, startT, startS, 16, dfdt1.bind(undefined, curve1, curve2), dfdt2.bind(undefined, curve1, curve2), (t, s) => -dfdt2(curve2, curve1, s, t), (t, s) => -dfdt1(curve2, curve1, s, t)); - assert(isFinite(ni.x)); - assert(isFinite(ni.y)); - if (ni == undefined) - console.log(startT, startS, curve1.sce, curve2.sce); - result.push({ tThis: ni.x, tOther: ni.y, p: curve1.at(ni.x) }); - } - } - // returns whether an intersection was immediately found (i.e. without further recursion) - function findRecursive(tMin, tMax, sMin, sMax, curve1AABB, curve2AABB, depth = 0) { - const EPS = NLA_PRECISION; - if (curve1AABB.touchesAABBfuzzy(curve2AABB)) { - const tMid = (tMin + tMax) / 2; - const sMid = (sMin + sMax) / 2; - if (Math.abs(tMax - tMin) < EPS || Math.abs(sMax - sMin) < EPS) { - handleStartTS(tMid, sMid); - return true; - } - else { - const curve1AABBleft = curve1.getAABB(tMin, tMid); - const curve2AABBleft = curve2.getAABB(sMin, sMid); - let curve1AABBright, curve2AABBright; - // if one of the following calls immediately finds an intersection, we don't want to call the others - // as that will lead to the same intersection being output multiple times - findRecursive(tMin, tMid, sMin, sMid, curve1AABBleft, curve2AABBleft, depth + 1) || - findRecursive(tMin, tMid, sMid, sMax, curve1AABBleft, (curve2AABBright = curve2.getAABB(sMid, sMax)), depth + 1) || - findRecursive(tMid, tMax, sMin, sMid, (curve1AABBright = curve1.getAABB(tMid, tMax)), curve2AABBleft, depth + 1) || - findRecursive(tMid, tMax, sMid, sMax, curve1AABBright, curve2AABBright, depth + 1); - } - } - return false; - } - const result = []; - findRecursive(tMin, tMax, sMin, sMax, curve1.getAABB(tMin, tMax), curve2.getAABB(sMin, sMax)); - return fuzzyUniquesF(result, (info) => info.tThis); - } - /** - * Searches a 2d area for (an) implicit curve(s). - * @param implicitCurve - * @param bounds Defines area to search. - * @param uStep Granularity of search in s-direction. - * @param vStep Granularity of search in t-direction. - * @param stepSize step size to take along the curve - * @return - */ - static breakDownIC(implicitCurve, bounds, uStep, vStep, stepSize, validUV) { - //undefined == didu && (didu = (u, v) => (implicitCurve(u + EPS, v) - implicitCurve(u, v)) / EPS) - //undefined == didv && (didv = (u, v) => (implicitCurve(u, v + EPS) - implicitCurve(u, v)) / EPS) - const { uMin, uMax, vMin, vMax } = bounds; - const deltaS = uMax - uMin, deltaT = vMax - vMin; - const sRes = ceil(deltaS / uStep), tRes = ceil(deltaT / vStep); - const grid = new Array(sRes * tRes).fill(0); - // const printGrid = () => - // console.log( - // arrayFromFunction(tRes, i => - // grid - // .slice(sRes * i, sRes * (i + 1)) - // .map(v => (v ? 'X' : '_')) - // .join(''), - // ).join('\n'), - // ) - const get = (i, j) => grid[j * sRes + i]; - const set = (i, j) => 0 <= i && i < sRes && 0 <= j && j < tRes && (grid[j * sRes + i] = 1); - const result = []; - const logTable = []; - for (let i = 0; i < sRes; i++) { - search: for (let j = 0; j < tRes; j++) { - if (get(i, j)) - continue; - set(i, j); - let u = uMin + (i + 0.5) * uStep, v = vMin + (j + 0.5) * vStep; - const startS = u, startT = v; - // basically curvePoint - for (let k = 0; k < 8; k++) { - const fp = implicitCurve(u, v); - const dfpdx = implicitCurve.x(u, v), dfpdy = implicitCurve.y(u, v); - if (0 === Math.pow(dfpdx, 2) + Math.pow(dfpdy, 2)) { - // top of a hill, keep looking - continue search; - } - const scale = fp / (Math.pow(dfpdx, 2) + Math.pow(dfpdy, 2)); - u -= scale * dfpdx; - v -= scale * dfpdy; - } - const li = floor((u - uMin) / uStep), lj = floor((v - vMin) / vStep); - logTable.push({ - i, - j, - li, - lj, - startS, - startT, - u, - v, - "bounds(u, v)": uvInAABB2(bounds, u, v), - "ic(s,t)": implicitCurve(u, v), - }); - if (!(i == li && j == lj) && get(li, lj)) { - continue search; - } - set(li, lj); - // u, v are now good starting coordinates to use follow algorithm - if (uvInAABB2(bounds, u, v) && - validUV(u, v) && - eq0(implicitCurve(u, v))) { - const subResult = mkcurves(implicitCurve, u, v, stepSize, bounds, validUV); - for (const curveData of subResult) { - assert(curveData.points.length > 2); - for (const { x, y } of curveData.points) { - const lif = (x - uMin) / uStep, ljf = (y - vMin) / vStep; - set((lif - 0.5) | 0, (ljf - 0.5) | 0); - set((lif - 0.5) | 0, (ljf + 0.5) | 0); - set((lif + 0.5) | 0, (ljf - 0.5) | 0); - set((lif + 0.5) | 0, (ljf + 0.5) | 0); - } - } - //printGrid() - result.push(...subResult); - } - } - } - // console.table(logTable) - for (const { points } of result) { - for (let i = 0; i < points.length - 1; i++) { - assert(!points[i].equals(points[i + 1])); - } - } - return result; - } - toString() { - return this.toSource(); - } - toSource(rounder = (x) => x) { - return callsce.call(undefined, "new " + this.constructor.name, ...this.getConstructorParameters(), this.tMin, this.tMax); - } - withBounds(tMin = this.tMin, tMax = this.tMax) { - //assert(this.tMin <= tMin && tMin <= this.tMax) - //assert(this.tMin <= tMax && tMax <= this.tMax) - return new this.constructor(...this.getConstructorParameters(), tMin, tMax); - } - /** - * The point on the line that is closest to the given point. - */ - closestPointToPoint(p) { - return this.at(this.closestTToPoint(p)); - } - isValidT(t) { - return le(this.tMin, t) && le(t, this.tMax); - } - diff(t, eps) { - return this.at(t).to(this.at(t + eps)); - } - // TODO: tmin/tmax first - closestTToPoint(p, tStart, tMin = this.tMin, tMax = this.tMax) { - // this.at(t) has minimal distance to p when this.tangentAt(t) is perpendicular to - // the vector between this.at(t) and p. This is the case iff the dot product of the two is 0. - // f = (this.at(t) - p) . (this.tangentAt(t) - // df = this.tangentAt(t) . this.tangentAt(t) + (this.at(t) - p) . this.ddt(t) - // = this.tangentAt(t)² + (this.at(t) - p) . this.ddt(t) - const f = (t) => this.at(t).minus(p).dot(this.tangentAt(t)); // 5th degree polynomial - const df = (t) => this.tangentAt(t).squared() + this.at(t).minus(p).dot(this.ddt(t)); - //checkDerivate(f, df, tMin, tMax) - const STEPS = 32; - if (undefined === tStart) { - tStart = withMax(arrayFromFunction(STEPS, (i) => tMin + ((tMax - tMin) * i) / (STEPS - 1)), (t) => -this.at(t).distanceTo(p)); - } - return newtonIterateWithDerivative(f, tStart, 16, df); - } - /** - * So different edges on the same curve do not have different vertices, they are always generated - * on fixed points this.at(k * this.tIncrement), with k taking integer values - * - */ - calcSegmentPoints(aT, bT, a, b, reversed, includeFirst) { - assert(this.tIncrement, "tIncrement not defined on " + this); - const inc = this.tIncrement; - const result = []; - if (includeFirst) - result.push(a); - assert(reversed != aT < bT); - if (aT < bT) { - const start = Math.ceil((aT + NLA_PRECISION) / inc); - const end = Math.floor((bT - NLA_PRECISION) / inc); - for (let i = start; i <= end; i++) { - result.push(this.at(i * inc)); - } - } - else { - const start = Math.floor((aT - NLA_PRECISION) / inc); - const end = Math.ceil((bT + NLA_PRECISION) / inc); - for (let i = start; i >= end; i--) { - result.push(this.at(i * inc)); - } - } - result.push(b); - return result; - } - calcSegmentTs(aT, bT, reversed, includeFirst) { - assert(this.tIncrement, "tIncrement not defined on " + this); - const inc = this.tIncrement; - const result = []; - if (includeFirst) - result.push(aT); - assert(reversed != aT < bT); - if (aT < bT) { - const start = Math.ceil((aT + NLA_PRECISION) / inc); - const end = Math.floor((bT - NLA_PRECISION) / inc); - for (let i = start; i <= end; i++) { - result.push(i * inc); - } - } - else { - const start = Math.floor((aT - NLA_PRECISION) / inc); - const end = Math.ceil((bT + NLA_PRECISION) / inc); - for (let i = start; i >= end; i--) { - result.push(i * inc); - } - } - result.push(bT); - return result; - } - /** - * - * @param p - * @param tStart Defines interval with tEnd in which a start value for t will be searched. - * Result is not necessarily in this interval. - * @param tEnd - */ - distanceToPoint(p, tStart, tEnd) { - const closestT = this.closestTToPoint(p, tStart, tEnd); - return this.at(closestT).distanceTo(p); - } - asSegmentDistanceToPoint(p, tStart, tEnd) { - let t = this.closestTToPoint(p, tStart, tEnd); - t = clamp(t, tStart, tEnd); - return this.at(t).distanceTo(p); - } - /** - * Behavior when curves are colinear: self intersections - */ - isInfosWithCurve(curve) { - if (insideIsInfosWithCurve) { - return Curve.ispsRecursive(this, this.tMin, this.tMax, curve, curve.tMin, curve.tMax); - } - else { - try { - insideIsInfosWithCurve = true; - const infos = curve.isInfosWithCurve(this); - return infos.map((info) => { - assert(info); - const { tThis, tOther, p } = info; - return { tOther: tThis, tThis: tOther, p }; - }); - } - finally { - insideIsInfosWithCurve = false; - } - } - } - isTsWithSurface(surface) { - if (surface instanceof PlaneSurface) { - return this.isTsWithPlane(surface.plane); - } - if (surface instanceof ProjectedCurveSurface) { - const projPlane = new P3(surface.dir.unit(), 0); - const projThis = this.project(projPlane); - const projEllipse = surface.baseCurve.project(projPlane); - return projEllipse.isInfosWithCurve(projThis).map((info) => info.tOther); - } - if (surface instanceof EllipsoidSurface) { - const thisOC = this.transform(surface.matrixInverse); - if (!thisOC.getAABB().touchesAABBfuzzy(new AABB(V3.XYZ.negated(), V3.XYZ))) { - return []; - } - const f = (t) => thisOC.at(t).length() - 1; - const df = (t) => thisOC.at(t).unit().dot(thisOC.tangentAt(t)); - const stepSize = 1 / (1 << 11); - const result = []; - for (let startT = this.tMin; startT <= this.tMax; startT += stepSize) { - const dt = stepSize * thisOC.tangentAt(startT).length(); - if (abs(f(startT)) <= dt) { - //const t = newtonIterate1d(f, startT, 16) - let t = newtonIterateWithDerivative(f, startT, 16, df); - if (!eq0(f(t)) || eq0(df(t))) { - t = newtonIterate1d(df, startT, 16); - //if (f(a) * f(b) < 0) { - // t = bisect(f, a, b, 16) - //} else if (df(a) * df(b) < 0) { - // t = bisect(df, a, b, 16) - //} - } - if (eq0(f(t)) && !result.some((r) => eq(r, t))) { - result.push(t); - } - } - } - return result.filter((t) => surface.containsPoint(this.at(t))); - } - throw new Error(); - } - arcLength(startT, endT, steps = 1) { - assert(startT < endT, "startT < endT"); - return glqInSteps((t) => this.tangentAt(t).length(), startT, endT, steps); - } - equals(obj) { - if (this === obj) - return true; - return (hasConstructor(obj, this.constructor) && - arrayEquals(this.getConstructorParameters(), obj.getConstructorParameters())); - } - hashCode() { - return arrayHashCode(this.getConstructorParameters()); - } - getAABB(tMin = this.tMin, tMax = this.tMax) { - tMin = isFinite(tMin) ? tMin : this.tMin; - tMax = isFinite(tMax) ? tMax : this.tMax; - const tMinAt = this.at(tMin), tMaxAt = this.at(tMax); - const roots = this.roots(); - const mins = [0, 0, 0]; - const maxs = [0, 0, 0]; - for (let dim = 0; dim < 3; dim++) { - const tRoots = roots[dim]; - mins[dim] = Math.min(tMinAt.e(dim), tMaxAt.e(dim)); - maxs[dim] = Math.max(tMinAt.e(dim), tMaxAt.e(dim)); - for (const tRoot of tRoots) { - if (tMin < tRoot && tRoot < tMax) { - mins[dim] = Math.min(mins[dim], this.at(tRoot).e(dim)); - maxs[dim] = Math.max(maxs[dim], this.at(tRoot).e(dim)); - } - } - } - return new AABB(V3.fromArray(mins), V3.fromArray(maxs)); - } - reversed() { - throw new Error(); - } - clipPlane(plane) { - const ists = this.isTsWithPlane(plane).filter((ist) => this.tMin <= ist && ist <= this.tMax); - return mapFilter(getIntervals(ists, this.tMin, this.tMax), ([a, b]) => { - const midT = (a + b) / 2; - return (!eq(a, b) && - plane.distanceToPointSigned(this.at(midT)) < 0 && - this.withBounds(a, b)); - }); - } -} -Curve.hlol = 0; -function mkcurves(implicitCurve, sStart, tStart, stepSize, bounds, validUV) { - const start = V(sStart, tStart); - assert(stepSize > 0); - // checkDerivate(s => implicitCurve(s, 0), s => didu(s, 0), -1, 1, 0) - // checkDerivate(t => implicitCurve(0, t), t => didv(0, t), -1, 1, 0) - const { points, tangents } = followAlgorithm2d(implicitCurve, start, stepSize, bounds, validUV); - if (points.length > 4 && - points[0].distanceTo(getLast(points)) <= abs(stepSize)) { - // this is a loop: split it - for (let i = 0; i < points.length - 1; i++) { - assert(!points[i].equals(points[i + 1])); - } - const half = floor(points.length / 2); - const points1 = points.slice(0, half), points2 = points.slice(half - 1, points.length); - const tangents1 = tangents.slice(0, half), tangents2 = tangents.slice(half - 1, tangents.length); - //tangents2[tangents2.length - 1] = tangents1[0] - //points2[tangents2.length - 1] = points1[0] - for (let i = 0; i < points1.length - 1; i++) { - assert(!points1[i].equals(points1[i + 1])); - } - for (let i = 0; i < points2.length - 1; i++) { - assert(!points2[i].equals(points2[i + 1])); - } - return [ - { points: points1, tangents: tangents1 }, - { points: points2, tangents: tangents2 }, - ]; - } - else { - // not a loop: check in the other direction - const { points: reversePoints, tangents: reverseTangents, } = followAlgorithm2d(implicitCurve, start, -stepSize, bounds, validUV); - const result = followAlgorithm2d(implicitCurve, getLast(reversePoints), stepSize, bounds, validUV, undefined, getLast(reverseTangents).negated()); - assert(result.points.length > 2); - return [result]; - } -} -function breakDownPPCurves(ps1, ps2, uStep, vStep, stepSize) { - const { uMin, uMax, vMin, vMax } = ps1; - const bounds = uvInAABB2.bind(undefined, ps1); - const bounds2 = uvInAABB2.bind(undefined, ps2); - const deltaU = uMax - uMin, deltaV = vMax - vMin; - const sRes = ceil(deltaU / uStep), tRes = ceil(deltaV / vStep); - const grid = new Array(sRes * tRes).fill(0); - //const printGrid = () => console.log(arrayFromFunction(tRes, i => grid.slice(sRes * i, sRes * (i + 1)).map(v => v ? 'X' : '_').join('')).join('\n')) - const at = (i, j) => grid[j * sRes + i]; - const set = (i, j) => 0 <= i && i < sRes && 0 <= j && j < tRes && (grid[j * sRes + i] = 1); - const result = []; - const logTable = []; - for (let i = 0; i < sRes; i++) { - search: for (let j = 0; j < tRes; j++) { - if (at(i, j)) - continue; - set(i, j); - const startU = uMin + (i + 0.5) * uStep, startV = vMin + (j + 0.5) * vStep; - // assume point is valid, currently (TODO) - const curvePointPPResult = curvePointPP(ps1, ps2, ps1.pUV(startU, startV)); - if (undefined === curvePointPPResult) { - continue search; - } - const { p: startP, st1: { x: u, y: v }, st2: { x: u2, y: v2 }, } = curvePointPPResult; - const li = floor((u - uMin) / uStep), lj = floor((v - vMin) / vStep); - logTable.push({ - i, - j, - li, - lj, - startU, - startV, - u, - v, - "bounds(u, v)": bounds(u, v), - }); - if (!(i == li && j == lj) && at(li, lj)) { - continue search; - } - set(li, lj); - // u, v are now good starting coordinates to use follow algorithm - if (bounds(u, v) && bounds2(u2, v2)) { - console.log(V(u, v).sce); - const subResult = mkPPCurves(ps1, ps2, startP, stepSize, bounds, bounds2); - for (const curveData of subResult) { - assert(curveData.st1s.length > 2); - for (const { x, y } of curveData.st1s) { - const lif = (x - uMin) / uStep, ljf = (y - vMin) / vStep; - set((lif - 0.5) | 0, (ljf - 0.5) | 0); - set((lif - 0.5) | 0, (ljf + 0.5) | 0); - set((lif + 0.5) | 0, (ljf - 0.5) | 0); - set((lif + 0.5) | 0, (ljf + 0.5) | 0); - } - } - //printGrid() - result.push(...subResult); - } - } - } - console.table(logTable); - for (const { points } of result) { - for (let i = 0; i < points.length - 1; i++) { - assert(!points[i].equals(points[i + 1])); - } - } - return result.map(({ points, tangents, st1s }) => { - return new PPCurve(points, tangents, ps1, ps2, st1s, undefined, stepSize, 1); - }); -} -function mkPPCurves(ps1, ps2, startPoint, stepSize, bounds1, bounds2) { - // checkDerivate(s => implicitCurve(s, 0), s => didu(s, 0), -1, 1, 0) - // checkDerivate(t => implicitCurve(0, t), t => didv(0, t), -1, 1, 0) - const { points, tangents, st1s } = followAlgorithmPP(ps1, ps2, startPoint, stepSize, bounds1, bounds2); - if (points[0].distanceTo(getLast(points)) < stepSize && points.length > 2) { - // this is a loop: split it - for (let i = 0; i < points.length - 1; i++) { - assert(!points[i].equals(points[i + 1])); - } - const half = floor(points.length / 2); - const points1 = points.slice(0, half), points2 = points.slice(half - 1, points.length); - const tangents1 = tangents.slice(0, half), tangents2 = tangents.slice(half - 1, tangents.length); - const st1s1 = st1s.slice(0, half), st1s2 = st1s.slice(half - 1, tangents.length); - tangents2[tangents2.length - 1] = tangents1[0]; - points2[tangents2.length - 1] = points1[0]; - st1s2[tangents2.length - 1] = st1s1[0]; - for (let i = 0; i < points1.length - 1; i++) { - assert(!points1[i].equals(points1[i + 1])); - } - for (let i = 0; i < points2.length - 1; i++) { - assert(!points2[i].equals(points2[i + 1])); - } - return [ - { points: points1, tangents: tangents1, st1s: st1s1 }, - { points: points2, tangents: tangents2, st1s: st1s2 }, - ]; - } - else { - // not a loop: check in the other direction - const { points: reversePoints } = followAlgorithmPP(ps1, ps2, startPoint, -stepSize, bounds1, bounds2); - const result = followAlgorithmPP(ps1, ps2, getLast(reversePoints), stepSize, bounds1, bounds2); - assert(result.points.length > 2); - return [result]; - } -} -function AABB2(uMin, uMax, vMin, vMax) { - return { uMin, uMax, vMin, vMax }; -} -function uvInAABB2(aabb2, u, v) { - return (aabb2.uMin <= u && u <= aabb2.uMax && aabb2.vMin <= v && v <= aabb2.vMax); -} -/** - * Finds a point on a 2D implicit curve. - * - * @param implicitCurve The curve follows the path where implicitCurve(u, v) is zero. - * @param startPoint The point from which to start looking (only .x = u and .y = v will be read). - * @param didu Derivative of implicitCurve in the first parameter. - * @param didv Derivative of implicitCurve in the second parameter. - */ -function curvePoint(implicitCurve, startPoint, didu, didv) { - let p = startPoint; - for (let i = 0; i < 8; i++) { - const fp = implicitCurve(p.x, p.y); - const dfpdx = didu(p.x, p.y); - const dfpdy = didv(p.x, p.y); - const scale = fp / (dfpdx * dfpdx + dfpdy * dfpdy); - p = p.minus(new V3(scale * dfpdx, scale * dfpdy, 0)); - } - return p; -} -function curvePointMF(mf, startPoint, steps = 8, eps = 1 / (1 << 30)) { - let p = startPoint; - for (let i = 0; i < steps; i++) { - const fp = mf(p.x, p.y); - const dfpdx = mf.x(p.x, p.y); - const dfpdy = mf.y(p.x, p.y); - const scale = fp / (dfpdx * dfpdx + dfpdy * dfpdy); - p = p.minus(new V3(scale * dfpdx, scale * dfpdy, 0)); - if (abs(fp) <= eps) - break; - } - return p; -} - -class XiEtaCurve extends Curve { - constructor(center, f1, f2, tMin, tMax) { - super(tMin, tMax); - this.center = center; - this.f1 = f1; - this.f2 = f2; - this.tMin = tMin; - this.tMax = tMax; - assertVectors(center, f1, f2); - this.normal = f1.cross(f2); - if (!this.normal.likeO()) { - this.normal = this.normal.unit(); - this.matrix = M4.forSys(f1, f2, this.normal, center); - this.matrixInverse = this.matrix.inversed(); - } - else { - this.matrix = M4.forSys(f1, f2, f1.unit(), center); - const f1p = f1.getPerpendicular(); - // prettier-ignore - this.matrixInverse = new M4(1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1).times(M4.forSys(f1, f1p, f1.cross(f1p), center).inversed()); - } - } - /** - * Intersection of the unit curve with the line ax + by = c. - */ - static intersectionUnitLine(a, b, c, tMin, tMax) { - throw new Error("abstract"); - } - /** - * Returns a new EllipseCurve representing an ellipse parallel to the XY-plane - * with semi-major/minor axes parallel t the X and Y axes. - * - * @param a length of the axis parallel to X axis. - * @param b length of the axis parallel to Y axis. - * @param center center of the ellipse. - */ - static forAB(a, b, center = V3.O) { - return new this(center, V(a, 0, 0), V(0, b, 0)); - } - static XYLCValid(pLC) { - throw new Error("abstract"); - } - static XYLCPointT(pLC, tMin, tMax) { - throw new Error("abstract"); - } - static unitIsInfosWithLine(anchorLC, dirLC, anchorWC, dirWC, tMin, tMax) { - throw new Error("abstract"); - } - addToMesh(mesh, res = 4, radius = 0, pointStep = 1) { - const baseNormals = arrayFromFunction(res, (i) => V3.polar(1, (TAU * i) / res)); - const baseVertices = arrayFromFunction(res, (i) => V3.polar(radius, (TAU * i) / res)); - const inc = this.tIncrement; - const start = Math.ceil((this.tMin + NLA_PRECISION) / inc); - const end = Math.floor((this.tMax - NLA_PRECISION) / inc); - for (let i = start; i <= end; i += pointStep) { - const t = i * inc; - const start = mesh.vertices.length; - if (0 !== i) { - for (let j = 0; j < res; j++) { - pushQuad(mesh.TRIANGLES, true, start - res + j, start + j, start - res + ((j + 1) % res), start + ((j + 1) % res)); - } - } - const point = this.at(t), tangent = this.tangentAt(t); - const matrix = M4.forSys(this.normal, tangent.cross(this.normal), tangent, point); - mesh.normals.push(...matrix.transformedVectors(baseNormals)); - mesh.vertices.push(...matrix.transformedPoints(baseVertices)); - } - } - getConstructorParameters() { - return [this.center, this.f1, this.f2]; - } - isInfosWithCurve(curve) { - if (curve instanceof L3) { - return this.isInfosWithLine(curve.anchor, curve.dir1, this.tMin, this.tMax, curve.tMin, curve.tMax); - } - if (curve instanceof BezierCurve) { - return this.isInfosWithBezier(curve); - } - if (curve instanceof XiEtaCurve) { - if (!this.normal.isParallelTo(curve.normal)) { - return mapFilter(this.isTsWithPlane(curve.getPlane()), (tThis) => { - const p = this.at(tThis); - if (curve.containsPoint(p)) { - return { tThis, tOther: curve.pointT(p), p }; - } - return undefined; - }); - } - } - return super.isInfosWithCurve(curve); - } - transform(m4) { - return new this.constructor(m4.transformPoint(this.center), m4.transformVector(this.f1), m4.transformVector(this.f2), this.tMin, this.tMax); - } - equals(obj) { - return (this == obj || - (undefined != obj && - this.constructor == obj.constructor && - this.center.equals(obj.center) && - this.f1.equals(obj.f1) && - this.f2.equals(obj.f2))); - } - hashCode() { - let hashCode = 0; - hashCode = hashCode * 31 + this.center.hashCode(); - hashCode = hashCode * 31 + this.f1.hashCode(); - hashCode = hashCode * 31 + this.f2.hashCode(); - return hashCode | 0; - } - likeCurve(curve) { - return (hasConstructor(curve, this.constructor) && - this.center.like(curve.center) && - this.f1.like(curve.f1) && - this.f2.like(curve.f2)); - } - normalP(t) { - return this.tangentAt(t).cross(this.normal); - } - getPlane() { - return P3.normalOnAnchor(this.normal, this.center); - } - isTsWithPlane(planeWC) { - assertInst(P3, planeWC); - /* - this: x = center + f1 * cos t + f2 * sin t (1) - plane: - n := plane.normal1 - n DOT x == plane.w (2) - plane defined by f1/f2 - x = center + f1 * xi + f2 * eta (3) - intersection plane and planef1/f2: - insert (3) into (2): - n DOT center + n DOT f1 * xi + n DOT f2 * eta = plane.w | -n DOT center - n DOT f1 * xi + n DOT f2 * eta = plane.w - n DOT center (4) - points on ellipse have additional condition - eta * eta + xi * xi = 1 (5) - g1 := n DOT f1 - g2 := n DOT f2 - g3 := w - n DOT center - solve system (5)/(6) - g1 * xi + g2 * eta = g3 (6) - */ - if (planeWC.normal1.isParallelTo(this.normal)) { - return []; - } - const n = planeWC.normal1, w = planeWC.w, center = this.center, f1 = this.f1, f2 = this.f2, g1 = n.dot(f1), g2 = n.dot(f2), g3 = w - n.dot(center); - return this.constructor.intersectionUnitLine(g1, g2, g3, this.tMin, this.tMax); - } - pointT(p) { - assertVectors(p); - const pLC = this.matrixInverse.transformPoint(p); - return this.constructor.XYLCPointT(pLC); - } - containsPoint(p) { - const pLC = this.matrixInverse.transformPoint(p); - return (eq0(pLC.z) && - this.isValidT(this.constructor.XYLCPointT(pLC, this.tMin, this.tMax))); - } - isInfosWithLine(anchorWC, dirWC, tMin = this.tMin, tMax = this.tMax, lineMin = -100000, lineMax = 100000) { - const anchorLC = this.matrixInverse.transformPoint(anchorWC); - const dirLC = this.matrixInverse.transformVector(dirWC); - if (eq0(dirLC.z)) { - // local line parallel to XY-plane - if (eq0(anchorLC.z)) { - // local line lies in XY-plane - return this.constructor.unitIsInfosWithLine(anchorLC, dirLC, anchorWC, dirWC, tMin, tMax); - } - } - else { - // if the line intersects the XY-plane in a single point, there can be an intersection there - // find point, then check if distance from circle = 1 - const otherTAtZ0 = anchorLC.z / dirLC.z; - const isp = dirLC.times(otherTAtZ0).plus(anchorLC); - if (this.constructor.XYLCValid(isp)) { - // point lies on unit circle - return [ - { - tThis: this.constructor.XYLCPointT(isp), - tOther: otherTAtZ0, - p: anchorWC.plus(dirWC.times(otherTAtZ0)), - }, - ]; - } - } - return []; - } - isTsWithSurface(surface) { - if (surface instanceof PlaneSurface) { - return this.isTsWithPlane(surface.plane); - } - else if (surface instanceof EllipsoidSurface) { - const isEllipses = surface.isCurvesWithPlane(this.getPlane()); - return isEllipses - .flatMap((isEllipse) => this.isInfosWithCurve(isEllipse)) - .filter((info) => surface.containsPoint(info.p)) - .map((info) => info.tThis); - } - else if (surface instanceof ProjectedCurveSurface || - surface instanceof ConicSurface) { - return surface - .isCurvesWithPlane(this.getPlane()) - .flatMap((curve) => this.isInfosWithCurve(curve)) - .map((info) => info.tThis); - } - else { - throw new Error(); - } - } - isInfosWithBezier(bezierWC) { - const bezierLC = bezierWC.transform(this.matrixInverse); - if (new PlaneSurface(P3.XY).containsCurve(bezierLC)) { - return this.isInfosWithBezier2D(bezierWC); - } - else { - const infos = mapFilter(bezierLC.isTsWithPlane(P3.XY), (tOther) => { - const pLC = bezierLC.at(tOther); - if (this.constructor.XYLCValid(pLC)) { - return { - tOther: tOther, - p: bezierWC.at(tOther), - tThis: this.constructor.XYLCPointT(pLC), - }; - } - return undefined; - }); - return infos; - } - } - isInfosWithBezier2D(bezierWC, sMin = bezierWC.tMin, sMax = bezierWC.tMax) { - return Curve.ispsRecursive(this, this.tMin, this.tMax, bezierWC, sMin, sMax); - } - isOrthogonal() { - return this.f1.isPerpendicularTo(this.f2); - } - at2(xi, eta) { - assertNumbers(xi, eta); - // center + f1 xi + f2 eta - return this.center.plus(this.f1.times(xi)).plus(this.f2.times(eta)); - } - debugInfo() { - return { - points: [ - this.center, - this.at2(0.5, 0), - this.at2(0, 1 / 3), - this.at2(0, 2 / 3), - ], - lines: [this.center, this.at2(0, 1), this.center, this.at2(1, 0)], - }; - } -} -/** - * Transforms the unit 4d parabola - * P(t) = t² (0, 1, 0, 0) + t (1, 0, 0, 0) + (0, 0, 0, 1) using m and projects - * the result into 3d. This is used for the transform4 implementation of conics. - * The parabola may not cross the vanishing plane of m in the interval - * [tMin, tMax], as that would result in discontinuities. - */ -function parabola4Projection(m, tMin, tMax) { - const w1 = m.m[12]; - const w2 = m.m[13]; - const wc = m.m[15]; - // if the 4d parabola crosses the vanishing plane, it will lead to multiple/infinite hyperbolas, both of which we - // want to avoid. Hence, we must check that the entire interval [tMin, tMax] is on one side of the vanishing plane. - // Checking tMax, tMin and the extremas is enough. - const extremas = solveCubicReal2(0, w2, w1, wc); - const wx0 = (x) => Number.isFinite(x) ? snap0(Math.pow(x, 2) * w2 + x * w1 + wc) : sign(w2) * Infinity; - if (wx0(tMin) * wx0(tMax) < 0 || - extremas.some((x) => wx0(x) * (wx0(tMin) + wx0(tMax)) < 0)) { - console.log(m.str); - throw new Error("The entire interval must be on one side of the vanishing plane. P=" + - toSource(P3.vanishingPlane(m))); - } - if (eq0(wc)) { - // the following matrix maps a curve C onto itself, with the parameter being inverted: - // C2(t) = C(-1/t). This makes C(0) a real value, which is necessary for the projection calculation. - // the sign inversion is so the tangent direction does not change. - // prettier-ignore - const mm = new M4(-1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0); - if (!eq0(w2)) { - return parabola4Projection(m.times(mm), -1 / tMin, -1 / tMax); - } - // wc == w2 == 0 => degenerates to a line: - // C(t) = (t² f2 + t f1 + c) / (t w1) - // C(t) = (t f2 + f1 + c) / (t w2 + w1) - // substitute t = (1/s - w1) / w2 - // C(s) = f2 / w2 + s (f1 - f2 w1 / w2), which is a line - // we can multiply the direction vector by w2 to avoid divisions: - // C(t) = f2 / w2 + s (f1 w2 - f2 w1) - const f1 = m.col(0); - const f2 = m.col(1); - return L3.anchorDirection(f2.p3(), f1.V3().times(f2.w).minus(f2.V3().times(f1.w))); - } - { - // ensure that the bottom-right value = 1. this does not change the 3d result. - m.m[15] !== 1 && (m = m.divScalar(m.m[15])); - const w2 = m.m[13]; - const w1 = m.m[12]; - const wc = m.m[15]; - // we want to split m into X * P, such that X is a transformation with no projective component (first three - // values of the bottom row = 0), which can be handled by the usual .transform() method, and P which has only a - // projective component (only the last row differs from the identity matrix). This simplifies the following - // calculation. X * P = m => X * P * P^-1 = m * P^-1 => X = m * P^-1 - // prettier-ignore - const Pinv = new M4(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -m.m[12], -m.m[13], -m.m[14], 1); - const X = m.times(Pinv); - // P'(t) = 0 is true for t = 0 and t1. The center is in between P(0) and P(t1), or P(t1) / 2, as P(0) = O - const delta = 4 * w2 * wc - Math.pow(w1, 2); - const center = new V3((-w1 * wc) / delta, (2 * Math.pow(wc, 2)) / delta, 0); - // f2 is parallel to P'(0), i.e. horizontal. Solve Py(t2) = Cy = Py(t1) / 2 for t2 and simplify - // f2x = Px(t2) - Cx = Px(t2) - Px(t1) / 2 to get the x-component of f2: - const f2x = 1 / sqrt(abs(delta)) / wc; - const f2 = new V3(f2x, 0, 0); - let result; - if (eq0(delta)) { - result = new ParabolaCurve(V3.O, V3.X, V3.Y, tMin, tMax); - } - else if (0 < delta) { - const tMapInv = (t) => { - const wt = Math.pow(t, 2) * w2 + t * w1 + wc; - const xi = 1 - - (delta / 2 / Math.pow(wc, 2)) * (Number.isFinite(t) ? Math.pow(t, 2) / wt : 1 / w2); - const xx = acos(xi); - const p = Number.isFinite(t) - ? new V3(t, Math.pow(t, 2), 0).div(wt) - : new V3(0, 1 / w2, 0); - const pLC = M4.forSys(center.negated(), f2, V3.Z, center) - .inversed() - .transformPoint(p); - const angle = pLC.angleXY(); - if (t > 0 && pLC.y < 0) { - return angle + TAU; - } - else if (t < 0 && pLC.y > 0) { - return angle - TAU; - } - return angle; - }; - result = EllipseCurve.andFixTs(center, center.negated(), f2, tMapInv(tMin), tMapInv(tMax)); - } - else { - const tMapInv = (t) => sign(t) * - acosh(1 - - (delta / 2 / Math.pow(wc, 2)) * - (Number.isFinite(t) - ? Math.pow(t, 2) / (Math.pow(t, 2) * w2 + t * w1 + wc) - : 1 / w2)); - result = new HyperbolaCurve(center, center.negated(), f2, tMapInv(tMin), tMapInv(tMax)); - } - return result.transform(X); - } -} - -class ImplicitCurve extends Curve { - constructor(points, tangents, dir = 1, generator, tMin = 1 == dir ? 0 : -(points.length - 1), tMax = 1 == dir ? points.length - 1 : 0) { - super(tMin, tMax); - this.points = points; - this.tangents = tangents; - this.dir = dir; - this.generator = generator; - assert(points.length > 2); - assert(0 <= tMin && tMin <= points.length - 1, tMin, points.length); - assert(0 <= tMax && tMax <= points.length - 1, tMax, points.length); - } - likeCurve(curve) { - throw new Error("Method not implemented."); - } - toSource(rounder = (x) => x) { - return this.generator || super.toSource(rounder); - } - containsPoint(p) { - assertVectors(p); - return !isNaN(this.pointT(p)); - } - equals(obj) { - return (this == obj || - (Object.getPrototypeOf(obj) == PICurve.prototype && - this.points[0].equals(obj.points[0]) && - this.tangents[0].equals(obj.tangents[0]))); - } - hashCode() { - return arrayHashCode([this.points[0], this.tangents[0]]); - } - tangentP(pWC) { - assertVectors(pWC); - assert(this.containsPoint(pWC), "this.containsPoint(pWC)" + this.containsPoint(pWC)); - const t = this.pointT(pWC); - return this.tangentAt(t); - } - tangentAt(t) { - t = clamp(t, this.tMin, this.tMax); - return V3.lerp(this.tangents[floor(t)], this.tangents[ceil(t)], t % 1); - } - at(t) { - assert(isFinite(t)); - return V3.lerp(this.points[floor(t)], this.points[ceil(t)], t % 1); - } - getConstructorParameters() { - throw new Error(); - } - roots() { - const allTs = arrayRange(0, this.points.length); - return [allTs, allTs, allTs]; - } - /** - * @param mesh - * @param res - * @param radius default to 0. Use the shader to achieve dynamic scaling. - * @param pointStep - */ - addToMesh(mesh, res = 4, radius = 0, pointStep = 1) { - const baseNormals = arrayFromFunction(res, (i) => V3.polar(1, (TAU * i) / res)); - const baseVertices = arrayFromFunction(res, (i) => V3.polar(radius, (TAU * i) / res)); - let prevTangent = V3.Z, prevMatrix = M4.IDENTITY; - for (let i = 0; i < this.points.length; i += pointStep) { - const start = mesh.vertices.length; - if (0 !== i) { - for (let j = 0; j < res; j++) { - pushQuad(mesh.TRIANGLES, true, start - res + j, start + j, start - res + ((j + 1) % res), start + ((j + 1) % res)); - } - } - const point = this.points[i], tangent = this.tangents[i]; - const tangentMatrix = M4.rotateAB(prevTangent, tangent).times(prevMatrix); - mesh.normals.push(...tangentMatrix.transformedVectors(baseNormals)); - const baseMatrix = M4.translate(point).times(tangentMatrix); - mesh.vertices.push(...baseMatrix.transformedPoints(baseVertices)); - prevTangent = tangent; - prevMatrix = tangentMatrix; - } - } - rootsApprox() { - const roots = [[], [], []]; - const points = this.points; - let lastDiff = points[1].minus(points[0]); - for (let i = 2; i < points.length; i++) { - const diff = points[i].minus(points[i - 1]); - for (let dim = 0; dim < 3; dim++) { - if (Math.sign(lastDiff.e(dim)) != Math.sign(diff.e(dim))) { - roots[dim].push(i); - } - } - lastDiff = diff; - } - return roots; - } - pointT(pWC) { - const startT = withMax(arrayRange(floor(this.tMin), ceil(this.tMax), 1), (t) => -pWC.distanceTo(this.points[t])); - if (undefined === startT) - throw new Error(); - if (this.points[startT].like(pWC)) - return startT; - const a = max(0, startT - 1), b = min(this.points.length - 1, startT + 1); - const tangent = this.tangentAt(startT); - const f = (t) => this.at(t).to(pWC).dot(tangent); - // const df = (t: number) => -this.tangentAt(clamp(t, 0, this.points.length - 1)).dot(tangent) - //checkDerivate(f, df, 0, this.points.length - 2, 3) - const t = bisect(f, a, b, 32); - if (!isFinite(t) || !eq0(this.at(t).distanceTo(pWC))) { - return NaN; - } - return t; - } -} -ImplicitCurve.prototype.tIncrement = 1; -/** - * isInfosWithLine for an ImplicitCurve defined as the intersection of two surfaces. - */ -function surfaceIsICurveIsInfosWithLine(surface1, surface2, anchorWC, dirWC, tMin, tMax, lineMin, lineMax) { - const line = new L3(anchorWC, dirWC.unit()); - const psTs = surface1.isTsForLine(line); - const isTs = surface2.isTsForLine(line); - const commonTs = psTs.filter((psT) => isTs.some((isT) => eq(psT, isT))); - const commonTInfos = commonTs.map((t) => ({ - tThis: 0, - tOther: t / dirWC.length(), - p: line.at(t), - })); - const result = commonTInfos.filter((info) => this.containsPoint(info.p)); - result.forEach((info) => (info.tThis = this.pointT(info.p))); - return result; -} - -/** - * Bezier curve with degree 3. - */ -class BezierCurve extends Curve { - constructor(p0, p1, p2, p3, tMin = -0.1, tMax = 1.1) { - super(tMin, tMax); - assertVectors(p0, p1, p2, p3); - assert(isFinite(tMin) && isFinite(tMax)); - //assert(!L3.throughPoints(p0, p3).containsPoint(p1) || !L3.throughPoints(p0, p3).containsPoint(p2)) - this.p0 = p0; - this.p1 = p1; - this.p2 = p2; - this.p3 = p3; - } - get points() { - return [this.p0, this.p1, this.p2, this.p3]; - } - /** - * Returns a new BezierCurve with curve.at(x) == V(x, ax³ + bx² + cx + d, 0). - */ - static graphXY(a, b, c, d, tMin, tMax) { - // d = p0y - // c = -3 p0y + 3 p1y => p1y = c/3 + p0y - // b = 3 p0y - 6 p1y + 3 p2y => p2y = b/3 - p0y + 2 p1y - // a = -p0y + 3 p1y -3 p2y + p3y => p3y = a + p0y - 3 p1y + 3 p2y - const p0y = d; - const p1y = c / 3 + p0y; - const p2y = b / 3 - p0y + 2 * p1y; - const p3y = a + p0y - 3 * p1y + 3 * p2y; - return new BezierCurve(V(0, p0y), V(1 / 3, p1y), V(2 / 3, p2y), V(1, p3y), tMin, tMax); - } - static quadratic(a, b, c, tMin = 0, tMax = 1) { - const line = L3.throughPoints(a, c); - if (line.containsPoint(b)) { - return line; - } - else { - // p1 = 1/3 a + 2/3 b - // p2 = 1/3 c + 2/3 b - return new BezierCurve(a, b.times(2).plus(a).div(3), b.times(2).plus(c).div(3), c, tMin, tMax); - } - } - /** - * Returns a bezier curve which approximates a CCW unit circle arc starting at V3.X of angle phi - * phi <= PI / 2 is recommended - * - * Formula from here: https://pomax.github.io/bezierinfo/#circles_cubic - */ - static approximateUnitArc(phi) { - const f = (4 / 3) * Math.tan(phi / 4); - return new BezierCurve(V3.X, new V3(1, f, 0), new V3(cos(phi) + f * sin(phi), sin(phi) - f * cos(phi), 0), V3.sphere(phi, 0), 0, 1); - } - getConstructorParameters() { - return [this.p0, this.p1, this.p2, this.p3]; - } - at(t) { - // = s^3 p0 + 3 s^2 t p1 + 3 s t^2 p2 + t^3 p3 - assertNumbers(t); - const p0 = this.p0, p1 = this.p1, p2 = this.p2, p3 = this.p3; - const s = 1 - t, c0 = s * s * s, c1 = 3 * s * s * t, c2 = 3 * s * t * t, c3 = t * t * t; - return new V3(p0.x * c0 + p1.x * c1 + p2.x * c2 + p3.x * c3, p0.y * c0 + p1.y * c1 + p2.y * c2 + p3.y * c3, p0.z * c0 + p1.z * c1 + p2.z * c2 + p3.z * c3); - } - /** - * s := (1 - t) - * at(t) := s³ p0 + 3 s² t p1 + 3 s t² p2 + t³ p3 - * tangent(t) := 3 s² (p1 - p0) + 6 s t (p2 - p1) + 3 t² (p3 - p2) - * := 3 (1 - t)² (p1 - p0) + 6 (1 - t) t (p2 - p1) + 3 t² (p3 - p2) - * := 3 (1 - 2 t + t²) (p1 - p0) + 6 (t - t²) (p2 - p1) + 3 t² (p3 - p2) - * := (3 (p3 - p2) - 6 (p2 - p1) + 3 (p1 - p0)) t²* - * + (-6 (p1 - p0) + (p2 - p1)) t - * + 3 (p1 - p0) - */ - tangentAt(t) { - assertNumbers(t); - const p0 = this.p0, p1 = this.p1, p2 = this.p2, p3 = this.p3; - const s = 1 - t, c01 = 3 * s * s, c12 = 6 * s * t, c23 = 3 * t * t; - return new V3((p1.x - p0.x) * c01 + (p2.x - p1.x) * c12 + (p3.x - p2.x) * c23, (p1.y - p0.y) * c01 + (p2.y - p1.y) * c12 + (p3.y - p2.y) * c23, (p1.z - p0.z) * c01 + (p2.z - p1.z) * c12 + (p3.z - p2.z) * c23); - } - ddt(t) { - assertNumbers(t); - const p0 = this.p0, p1 = this.p1, p2 = this.p2, p3 = this.p3; - const c012 = 6 * (1 - t), c123 = 6 * t; - return new V3((p2.x - 2 * p1.x + p0.x) * c012 + (p3.x - 2 * p2.x + p1.x) * c123, (p2.y - 2 * p1.y + p0.y) * c012 + (p3.y - 2 * p2.y + p1.y) * c123, (p2.z - 2 * p1.z + p0.z) * c012 + (p3.z - 2 * p2.z + p1.z) * c123); - } - normalP(t) { - const tangent = this.tangentAt(t); - const rot = tangent.cross(this.ddt(t)); - return rot.cross(tangent); - } - isTsWithPlane(planeWC) { - assertInst(P3, planeWC); - /* - We are solving for t: - n := plane.normal1 - this.at(t) DOT n == plane.w // according to plane definition - (a t³ + b t² + c t + d) DOT n == plane.w // bezier curve as cubic equation - (a DOT n) t³ + (b DOT n) t³ + (c DOT n) t + d DOT n - plane.w == 0 // multiply out DOT n, minus plane.w - */ - const { p0, p1, p2, p3 } = this; - const n = planeWC.normal1; - const a = p1.minus(p2).times(3).minus(p0).plus(p3); - const b = p0.plus(p2).times(3).minus(p1.times(6)); - const c = p1.minus(p0).times(3); - const d = p0; - return solveCubicReal2(a.dot(n), b.dot(n), c.dot(n), d.dot(n) - planeWC.w).filter((t) => between(t, this.tMin, this.tMax)); - } - isTsWithSurface(surfaceWC) { - if (surfaceWC instanceof CylinderSurface) { - const projPlane = new P3(surfaceWC.dir.unit(), 0); - const projThis = this.project(projPlane); - const projEllipse = surfaceWC.baseCurve.project(projPlane); - return projEllipse - .isInfosWithBezier2D(projThis) - .map((info) => info.tOther); - } - return super.isTsWithSurface(surfaceWC); - } - likeCurve(curve) { - return (this == curve || - (hasConstructor(curve, BezierCurve) && - this.p0.like(curve.p0) && - this.p1.like(curve.p1) && - this.p2.like(curve.p2) && - this.p3.like(curve.p3))); - } - equals(obj) { - return (this == obj || - (hasConstructor(obj, BezierCurve) && - this.p0.equals(obj.p0) && - this.p1.equals(obj.p1) && - this.p2.equals(obj.p2) && - this.p3.equals(obj.p3))); - } - hashCode() { - let hashCode = 0; - hashCode = hashCode * 31 + this.p0.hashCode(); - hashCode = hashCode * 31 + this.p1.hashCode(); - hashCode = hashCode * 31 + this.p2.hashCode(); - hashCode = hashCode * 31 + this.p3.hashCode(); - return hashCode | 0; - } - /** - * Checks if this curve is colinear to the passed curve, i.e. - * for every t:number there exists a s:number with this.at(t) = curve.at(s) - */ - isColinearTo(curve) { - if (this === curve || this.likeCurve(curve)) - return true; - if (!(curve instanceof BezierCurve)) - return false; - // first, find out where/if curve.p0 and curve.p3 are on this - // then split this at curve.p0 --> curve.p3 to compare points p1 and p2 - let curveP0T, curveP3T; - // assign in if condition to exploit short-circuit - if (isNaN((curveP0T = this.pointT(curve.p0))) || - isNaN((curveP3T = this.pointT(curve.p3)))) { - return false; - } - let thisSplit; - if (eq(1, curveP0T)) { - // this.split(curveP0T).right is degenerate in this case, so we need to handle it separately - // this.split(curveP3T): 0 --> curveP3T --> 1 - // .right: curveP3T --> 1 - // .reversed(): 1 --> curveP3T - thisSplit = this.split(curveP3T)[1].reversed(); - } - else { - // curveP3T describes the point on this - // adjust it so it describes the same point on this.split(curveP0T).right - // this: 0 p0t p3t 1 - // | | | | - // this.split(curveP0T).right: 0 p3tad 1 - const curveP3Tadjusted = (curveP3T - curveP0T) / (1 - curveP0T); - thisSplit = this.split(curveP0T)[1].split(curveP3Tadjusted)[0]; - } - return curve.likeCurve(thisSplit); - } - selectPart(t0, t1) { - const t1Adjusted = (t1 - t0) / (1 - t0); - return this.split(t0)[1].split(t1Adjusted)[0]; - } - reversed() { - return new BezierCurve(this.p3, this.p2, this.p1, this.p0, 1 - this.tMax, 1 - this.tMin); - } - getCoefficients() { - const { p0, p1, p2, p3 } = this; - // calculate cubic equation coefficients - // a t³ + b t² + c t + d = 0 - // multiplying out the cubic Bézier curve equation gives: - // a = -p0 + 3 p1 - 3 p2 + p3 - // b = 3 p0 - 6 p1 + 3 p2 - // c = -3 p0 + 3 p1 - // d = p0 - p - const a = p1.minus(p2).times(3).minus(p0).plus(p3); - const b = p0.plus(p2).times(3).minus(p1.times(6)); - const c = p1.minus(p0).times(3); - const d = p0; - return [a, b, c, d]; - } - tangentCoefficients() { - const { p0, p1, p2, p3 } = this; - const p01 = p1.minus(p0), p12 = p2.minus(p1), p23 = p3.minus(p2); - const a = p01.plus(p23).times(3).minus(p12.times(6)); - const b = p12.minus(p01).times(6); - const c = p01.times(3); - return [V3.O, a, b, c]; - } - pointT2(p, tMin = this.tMin, tMax = this.tMax) { - const t = this.closestTToPoint(p, undefined, tMin, tMax); - assert(this.at(t).like(p)); - return t; - } - pointT(p) { - const { p0, p1, p2, p3 } = this; - // calculate cubic equation coefficients - // a t³ + b t² + c t + d = 0 - // multiplying out the cubic Bézier curve equation gives: - // a = -p0 + 3 p1 - 3 p2 + p3 - // b = 3 p0 - 6 p1 + 3 p2 - // c = -3 p0 + 3 p1 - // d = p0 - p - const a = p1.minus(p2).times(3).minus(p0).plus(p3); - const b = p0.plus(p2).times(3).minus(p1.times(6)); - const c = p1.minus(p0).times(3); - const d = p0.minus(p); - // a t³ + b t² + c t + d = 0 is 3 cubic equations, some of which can be degenerate - const maxDim = NLA_PRECISION < a.maxAbsElement() - ? a.maxAbsDim() - : NLA_PRECISION < b.maxAbsElement() - ? b.maxAbsDim() - : NLA_PRECISION < c.maxAbsElement() - ? c.maxAbsDim() - : assertNever(); - const results = solveCubicReal2(a.e(maxDim), b.e(maxDim), c.e(maxDim), d.e(maxDim)).filter((t) => this.at(t).like(p)); - if (0 == results.length) - return NaN; - if (1 == results.length) - return results[0]; - throw new Error("multiple intersection " + this.toString() + p.sce); - } - pointT3(p) { - const { p0, p1, p2, p3 } = this; - // calculate cubic equation coefficients - // a t³ + b t² + c t + d = 0 - // multiplying out the cubic Bézier curve equation gives: - // a = -p0 + 3 p1 - 3 p2 + p3 - // b = 3 p0 - 6 p1 + 3 p2 - // c = -3 p0 + 3 p1 - // d = p0 - p - const a = p1.minus(p2).times(3).minus(p0).plus(p3).els(); - const b = p0.plus(p2).times(3).minus(p1.times(6)).els(); - const c = p1.minus(p0).times(3).els(); - const d = p0.minus(p).els(); - let results = undefined; - // assume passed point is on curve and that curve does not self-intersect, - // i.e. there is exactly one correct result for t - // try to find a single result in the x-dimension, if multiple are found, - // filter them by checking the other dimensions - for (let dim = 0; dim < 3; dim++) { - if (eq0(a[dim]) && eq0(b[dim]) && eq0(c[dim])) { - // for case x: - // ax == bx == cx == 0 => x(t) = dx - // x value is constant - // if x == 0 for all t, this does not limit the result, otherwise, there is no result, i.e - // the passed point is not on the curve - if (!eq0(d[dim])) - return NaN; - } - else { - const newResults = solveCubicReal2(a[dim], b[dim], c[dim], d[dim]); - if (0 == newResults.length) - return NaN; - if (1 == newResults.length) - return newResults[0]; - if (results) { - results = results.filter((t) => newResults.some((t2) => eq(t, t2))); - if (0 == results.length) - return NaN; - if (1 == results.length) - return results[0]; - } - else { - results = newResults; - } - } - } - throw new Error("multiple intersection " + results + this.toString() + p.sce); - } - transform(m4) { - // perspective projection turn bezier curve into rational spline - assert(m4.isNoProj(), m4.str); - return new BezierCurve(m4.transformPoint(this.p0), m4.transformPoint(this.p1), m4.transformPoint(this.p2), m4.transformPoint(this.p3), this.tMin, this.tMax); - } - transform4(m4) { - if (m4.isNoProj()) { - return this.transform(m4); - } - else { - return this.toNURBS().transform4(m4); - } - } - isClosed() { - return this.p0.like(this.p3); - } - isQuadratic() { - return this.p0.lerp(this.p1, 1.5).like(this.p3.lerp(this.p2, 1.5)); - } - debugInfo() { - return { - lines: [0, 1, 1, 2, 2, 3].map((i) => this.points[i]), - points: this.points, - }; - } - split(t) { - // do de Casteljau's algorithm at t, the resulting points are the points needed to create 2 new curves - const s = 1 - t; - const { p0, p1, p2, p3 } = this; - /* - p3 // n3 - b01 = s p0 + t p1 - b11 = s p1 + t p2 - b21 = s p2 + t p3 // n2 - b02 = s b01 + t b11 - b12 = s b11 + t b21 // n1 - b03 = s b02 + t b12 // n0 - - c01 = - */ - const b01 = p0.times(s).plus(p1.times(t)), b11 = p1.times(s).plus(p2.times(t)), b21 = p2.times(s).plus(p3.times(t)); - const b02 = b01.times(s).plus(b11.times(t)), b12 = b11.times(s).plus(b21.times(t)); - const b03 = b02.times(s).plus(b12.times(t)); - return [ - new BezierCurve(p0, b01, b02, b03), - new BezierCurve(b03, b12, b21, p3), - ]; - } - containsPoint(p) { - return isFinite(this.pointT(p)); - } - roots() { - /** - * := (3 (p3 - p2) - 6 (p2 - p1) + 3 (p1 - p0)) t²* - * + (-6 (p1 - p0) + 6 (p2 - p1)) t - * + 3 (p1 - p0) - * */ - const { p0, p1, p2, p3 } = this; - const p01 = p1.minus(p0), p12 = p2.minus(p1), p23 = p3.minus(p2); - const a = p01.plus(p23).times(3).minus(p12.times(6)); - const b = p12.minus(p01).times(6); - const c = p01.times(3); - return arrayFromFunction(3, (dim) => solveCubicReal2(0, a.e(dim), b.e(dim), c.e(dim))); - } - isInfosWithLine(anchorWC, dirWC, tMin, tMax, lineMin = -100000, lineMax = 100000) { - // const dirLength = dirWC.length() - // // TODO: no: - // let result = Curve.ispsRecursive(this, this.tMin, this.tMax, new L3(anchorWC, dirWC.unit()), lineMin, lineMax) - // result = fuzzyUniquesF(result, info => info.tOther) - // result.forEach(info => (info.tOther /= dirLength)) - // return result - // looking for this.at(t) == line.at(s) - // this.at(t).x == anchorWC.x + dirWC.x * s - // (this.at(t).x - anchorWC.x) / dirWC.x == s (analogue for y and z) (1x, 1y, 1z) - // (1x) - (1y): - // (this.at(t).x - anchorWC.x) / dirWC.x - (this.at(t).y - anchorWC.y) / dirWC.y == 0 - // (this.at(t).x - anchorWC.x) * dirWC.y - (this.at(t).y - anchorWC.y) * dirWC.x == 0 (2) - // cubic equation params (see #pointT): - const { p0, p1, p2, p3 } = this; - const a = p1.minus(p2).times(3).minus(p0).plus(p3); - const v1 = V3.UNITS[a.minAbsDim()]; - const testPlane = P3.forAnchorAndPlaneVectors(anchorWC, dirWC, v1.isParallelTo(dirWC) ? a : v1); - return this.isTsWithPlane(testPlane) - .map((tThis) => { - const p = this.at(tThis); - return { tThis, tOther: L3.pointT(anchorWC, dirWC, p), p }; - }) - .filter((info) => L3.containsPoint(anchorWC, dirWC, info.p)); - } - closestPointToLine(line, tMin, tMax) { - // (this(t)-line(s)) * line.dir == 0 (1) - // (this(t)-line(s)) * this.tangentAt(t) == 0 (2) - // this(t) * line.dir - line(s) * line.dir == 0 - // this(t) * line.dir - line.anchor * line.dir - s line.dir * line.dir == 0 - // this(t) * line.dir - line.anchor * line.dir == s (3) - // insert (3) in (2) - // (this(t)-line(this(t) * line.dir - line.anchor * line.dir)) * this.tangentAt(t) == 0 (4) - // (4) is a 5th degree polynomial, solve numerically - tMin = isFinite(tMin) ? tMin : this.tMin; - tMax = isFinite(tMax) ? tMax : this.tMax; - const anchorDotDir1 = line.anchor.dot(line.dir1); - const f = (t) => { - const atT = this.at(t); - return atT - .minus(line.at(atT.dot(line.dir1) - anchorDotDir1)) - .dot(this.tangentAt(t)); - }; - const STEPS = 32; - const startT = withMax(arrayFromFunction(STEPS, (i) => tMin + ((tMax - tMin) * i) / STEPS), (t) => -f(t)); - return newtonIterate1d(f, startT, 8); - } - /** - * - * @param bezier - * @param tMin - * @param tMax - * @param sMin - * @param {number=} sMax - * @returns - */ - isInfosWithBezier3(bezier, tMin, tMax, sMin, sMax) { - const handleStartTS = (startT, startS) => { - if (!result.some((info) => eq(info.tThis, startT) && eq(info.tOther, startS))) { - const f1 = (t, s) => this.tangentAt(t).dot(this.at(t).minus(bezier.at(s))); - const f2 = (t, s) => bezier.tangentAt(s).dot(this.at(t).minus(bezier.at(s))); - // f = (b1, b2, t1, t2) = b1.tangentAt(t1).dot(b1.at(t1).minus(b2.at(t2))) - const fdt1 = (b1, b2, t1, t2) => b1.ddt(t1).dot(b1.at(t1).minus(b2.at(t2))) + - b1.tangentAt(t1).squared(); - const fdt2 = (b1, b2, t1, t2) => -b1.tangentAt(t1).dot(b2.tangentAt(t2)); - const ni = newtonIterate2dWithDerivatives(f1, f2, startT, startS, 16, fdt1.bind(undefined, this, bezier), fdt2.bind(undefined, this, bezier), (t, s) => -fdt2(bezier, this, s, t), (t, s) => -fdt1(bezier, this, s, t)); - result.push({ tThis: ni.x, tOther: ni.y, p: this.at(ni.x) }); - } - }; - tMin = undefined !== tMin ? tMin : this.tMin; - tMax = undefined !== tMax ? tMax : this.tMax; - sMin = undefined !== sMin ? sMin : bezier.tMin; - sMax = undefined !== sMax ? sMax : bezier.tMax; - // stack of indices: - const indices = [tMin, tMax, sMin, sMax]; - const result = []; - while (indices.length) { - const i = indices.length - 4; - const tMin = indices[i], tMax = indices[i + 1], sMin = indices[i + 2], sMax = indices[i + 3]; - indices.length -= 4; - const thisAABB = this.getAABB(tMin, tMax); - const otherAABB = bezier.getAABB(sMin, sMax); - // console.log(tMin, tMax, sMin, sMax, thisAABB.sce, otherAABB.sce) - if (thisAABB && otherAABB && thisAABB.intersectsAABB2d(otherAABB)) { - const tMid = (tMin + tMax) / 2; - const sMid = (sMin + sMax) / 2; - const EPS = 0.00001; - if (tMax - tMin < EPS || sMax - sMin < EPS) { - console.log(tMin, tMax, sMin, sMax); - console.log(thisAABB.sce); - console.log(otherAABB.sce); - console.log(tMid, sMid); - handleStartTS(tMid, sMid); - } - else { - indices.push(tMin, tMid, sMin, sMid, tMin, tMid, sMid, sMax, tMid, tMax, sMin, sMid, tMid, tMax, sMid, sMax); - } - } - } - return result; - } - isInfosWithBezier(bezier, tMin, tMax, sMin, sMax) { - tMin = undefined !== tMin ? tMin : this.tMin; - tMax = undefined !== tMax ? tMax : this.tMax; - sMin = undefined !== sMin ? sMin : bezier.tMin; - sMax = undefined !== sMax ? sMax : bezier.tMax; - assertf(() => tMin < tMax); - assertf(() => sMin < sMax); - const result = []; - const likeCurves = this.likeCurve(bezier), colinearCurves = this.isColinearTo(bezier); - if (likeCurves || colinearCurves) { - if (!likeCurves) { - // only colinear - // recalculate sMin and sMax so they are valid on this, from then on we can ignore bezier - sMin = this.pointT(bezier.at(sMin)); - sMax = this.pointT(bezier.at(sMax)); - } - tMin = Math.min(tMin, sMin); - tMax = Math.max(tMax, sMax); - const splits = fuzzyUniques(concatenated(this.roots()).filter(isFinite).concat([tMin, tMax])).sort(MINUS); - //const aabbs = arrayFromFunction(splits.length - 1, i => this.getAABB(splits[i], splits[i + 1])) - Array.from(combinations(splits.length - 1)).forEach(({ i, j }) => { - // adjacent curves can't intersect - if (Math.abs(i - j) > 2) { - // console.log(splits[i], splits[i + 1], splits[j], splits[j + 1], aabbs[i], aabbs[j]) - //findRecursive(splits[i], splits[i + 1], splits[j], splits[j + 1], aabbs[i], aabbs[j]) - result.push(...Curve.ispsRecursive(this, splits[i], splits[i + 1], bezier, splits[j], splits[j + 1])); - } - }); - } - else { - return Curve.ispsRecursive(this, tMin, tMax, bezier, sMin, sMax); - } - return result; - } - selfIntersectionsInfo() { - return this.isInfosWithBezier(this); - } - isInfosWithCurve(curve) { - if (curve instanceof L3) { - return this.isInfosWithLine(curve.anchor, curve.dir1, curve.tMin, curve.tMax); - } - if (curve instanceof BezierCurve) { - return this.isInfosWithBezier(curve); - } - return curve - .isInfosWithCurve(this) - .map(({ tThis, tOther, p }) => ({ tThis: tOther, tOther: tThis, p })); - } - /** - * Approximate this bezier curve with a number of circular segments. This curve is recursively split in half until - * segments are close enough (relative error < REL_ERR in two test points) to an arc which goes through the start, - * end and mid points of the segment. - * @returns each EllipseCurve is circular and their tMin and tMax respectively define their start and end points. - * @param t0 Start parameter of segment which should be approximated. - * @param t1 End parameter of segment which should be approximated. - * @param REL_ERROR max allowable relative error. - * @param result Resulting circle arcs are stored in this array. Mainly used by the recursion. - */ - circleApprox(t0 = this.tMin, t1 = this.tMax, REL_ERROR = 1 / 1024, result = []) { - const a = this.at(t0), b = this.at(t1), tMid = (t0 + t1) / 2, pMid = this.at(tMid), abLine = L3.throughPoints(a, b); - if (!abLine.containsPoint(pMid) && - between(abLine.pointT(pMid), 0, abLine.pointT(b))) { - const arc = EllipseCurve.circleThroughPoints(a, pMid, b), arcRadius = arc.f1.length(), pTest1 = this.at(lerp(t0, t1, 0.25)), pTest2 = this.at(lerp(t0, t1, 0.75)); - if (abs(arc.center.distanceTo(pTest1) / arcRadius - 1) <= REL_ERROR && - abs(arc.center.distanceTo(pTest2) / arcRadius - 1) <= REL_ERROR) { - result.push(arc); - return result; - } - } - this.circleApprox(t0, tMid, REL_ERROR, result); - this.circleApprox(tMid, t1, REL_ERROR, result); - return result; - } - toNURBS() { - return NURBS.fromBezier(this); - } -} -/** - * https://en.wikipedia.org/wiki/Cubic_function#/media/File:Graph_of_cubic_polynomial.svg - */ -BezierCurve.EX2D = BezierCurve.graphXY(2, -3, -3, 2); -BezierCurve.EX3D = new BezierCurve(V3.O, V(-0.1, -1, 1), V(1.1, 1, 1), V3.X); -BezierCurve.QUARTER_CIRCLE = BezierCurve.approximateUnitArc(PI / 2); -BezierCurve.prototype.hlol = Curve.hlol++; -BezierCurve.prototype.tIncrement = 1 / 80; - -/** - * x² - y² = 1 - * C(t) = center + f1 * cosh(t) + f2 * sinh(t) - */ -class HyperbolaCurve extends XiEtaCurve { - constructor(center, f1, f2, tMin = -7, tMax = 7) { - super(center, f1, f2, tMin, tMax); - } - static XYLCValid(pLC) { - return pLC.x > 0 && eq(1, pLC.x * pLC.x - pLC.y * pLC.y); - } - static XYLCPointT(pLC) { - return Math.asinh(pLC.y); - } - /** - * http://www.wolframalpha.com/input/?i=x%C2%BRep-y%C2%BRep%3D1,ax%2Bby%3Dc - * Minor empiric test shows asinh(eta) consistently gets more accurate results than atanh(eta/xi) - */ - static intersectionUnitLine(a, b, c) { - if (eq0(b)) { - const sqrtVal = snap0(Math.pow(c, 2) / Math.pow(a, 2) - 1); - if (sqrtVal < 0 || c * a < 0) { - return []; - } - else if (sqrtVal == 0) { - return [0]; - } - const eta1 = Math.sqrt(sqrtVal); - return [-Math.asinh(eta1), Math.asinh(eta1)]; - } - else if (eq(abs(a), abs(b))) { - if (le(c * a, 0)) { - return []; - } - const eta = (sign(a * b) * (Math.pow(c, 2) - Math.pow(a, 2))) / 2 / a / c; - return [Math.asinh(eta)]; - } - else { - const sqrtVal = snap0(Math.pow(b, 2) * (-(Math.pow(a, 2)) + Math.pow(b, 2) + Math.pow(c, 2))); - if (sqrtVal < 0) { - return []; - } - const xi1 = (a * c - Math.sqrt(sqrtVal)) / (Math.pow(a, 2) - Math.pow(b, 2)); - const xi2 = (a * c + Math.sqrt(sqrtVal)) / (Math.pow(a, 2) - Math.pow(b, 2)); - const eta1 = (Math.pow(b, 2) * c - a * Math.sqrt(sqrtVal)) / (b * (Math.pow(b, 2) - Math.pow(a, 2))); - const eta2 = (Math.pow(b, 2) * c + a * Math.sqrt(sqrtVal)) / (b * (Math.pow(b, 2) - Math.pow(a, 2))); - return [xi1 > 0 && Math.asinh(eta1), xi2 > 0 && Math.asinh(eta2)].filter((x) => x !== false); - } - } - at(t) { - assertNumbers(t); - // = center + f1 cosh t + f2 sinh t - return this.center - .plus(this.f1.times(Math.cosh(t))) - .plus(this.f2.times(Math.sinh(t))); - } - toString() { - return `${this.center} + ${this.f1} * cosh(t) + ${this.f2} * sinh(t)`; - } - tangentAt(t) { - assertNumbers(t); - // = f1 sinh t + f2 cosh t - return this.f1.times(Math.sinh(t)).plus(this.f2.times(Math.cosh(t))); - } - tangentAt2(xi, eta) { - assertNumbers(xi, eta); - // = f1 eta + f2 xi - return this.f1.times(eta).plus(this.f2.times(xi)); - } - ddt(t) { - assertNumbers(t); - return this.f1.times(Math.cosh(t)).plus(this.f2.times(Math.sinh(t))); - } - isColinearTo(curve) { - if (!hasConstructor(curve, HyperbolaCurve)) - return false; - if (!curve.center || !this.center.like(curve.center)) { - return false; - } - if (this === curve) { - return true; - } - const { f1: f1, f2: f2 } = this.rightAngled(), { f1: c1, f2: c2 } = curve.rightAngled(); - return (eq(f1.squared(), Math.abs(f1.dot(c1))) && - eq(f2.squared(), Math.abs(f2.dot(c2)))); - } - reversed() { - return new HyperbolaCurve(this.center, this.f1, this.f2.negated(), -this.tMax, -this.tMin); - } - rightAngled() { - const f1 = this.f1, f2 = this.f2, a = f1.dot(f2), b = f2.squared() + f1.squared(); - if (eq0(a)) { - return this; - } - const g1 = 2 * a, g2 = b + Math.sqrt(b * b - 4 * a * a); - const { x1: xi, y1: eta } = intersectionUnitHyperbolaLine(g1, g2, 0); - return new HyperbolaCurve(this.center, f1.times(xi).plus(f2.times(eta)), f1.times(eta).plus(f2.times(xi))); - } - eccentricity() { - const mainAxes = this.rightAngled(); - const f1length = mainAxes.f1.length(), f2length = mainAxes.f1.length(); - const [a, b] = f1length > f2length ? [f1length, f2length] : [f2length, f1length]; - return Math.sqrt(1 + (b * b) / a / a); - } - roots() { - // tangent(t) = f1 sinh t + f2 cosh t = 0 - // tangentAt2(xi, eta) = f1 eta + f2 xi = V3.O - // xi² - eta² = 1 (by def for hyperbola) - return arrayFromFunction(3, (dim) => { - const a = this.f2.e(dim), b = this.f1.e(dim); - return HyperbolaCurve.intersectionUnitLine(a, b, 0); - }); - } - transform4(m4) { - const tMap = (t) => sign(t) * min(10, sqrt(-(1 - cosh(t)) / (1 + cosh(t)))); - // prettier-ignore - const parabolaToUnitHyperbola = new M4(0, 1, 0, 1, 2, 0, 0, 0, 0, 0, 1, 0, 0, -1, 0, 1); - return parabola4Projection(M4.product(m4, this.matrix, parabolaToUnitHyperbola), tMap(this.tMin), tMap(this.tMax)); - } -} -HyperbolaCurve.XY = new HyperbolaCurve(V3.O, V3.X, V3.Y); -HyperbolaCurve.prototype.tIncrement = PI / 16; - -/** - * A 3-dimensional line. Defined by an anchor and a normalized direction vector. - */ -class L3 extends Curve { - constructor(anchor, // line anchor - dir1, // normalized line dir - tMin = -4096, tMax = 4096) { - super(tMin, tMax); - this.anchor = anchor; - this.dir1 = dir1; - assertVectors(anchor, dir1); - assert(dir1.hasLength(1), "dir must be unit" + dir1); - assertf(() => !Number.isNaN(anchor.x)); - } - isTsWithSurface(surface) { - return surface.isTsForLine(this); - } - static throughPoints(anchor, b, tMin = 0, tMax) { - const dir = b.minus(anchor); - return new L3(anchor, dir.unit(), tMin, undefined !== tMax ? tMax : dir.length()); - } - static anchorDirection(anchor, dir, min = 0, max = dir.length()) { - const dir1 = dir.unit(); - return new L3(anchor, dir1, "number" == typeof min ? min : min.minus(anchor).dot(dir1), "number" == typeof max ? max : max.minus(anchor).dot(dir1)); - } - static pointT(anchor, dir, x) { - assertVectors(anchor, dir, x); - return x.minus(anchor).dot(dir) / dir.squared(); - } - static at(anchor, dir, t) { - return anchor.plus(dir.times(t)); - } - /** - * Create new line which is the intersection of two planes. Throws error if planes are parallel. - * @param plane1 - * @param plane2 - */ - static fromPlanes(plane1, plane2) { - assertInst(P3, plane1, plane2); - const dir = plane1.normal1.cross(plane2.normal1); - const length = dir.length(); - if (length < 1e-10) { - throw new Error("Parallel planes"); - } - return plane1.intersectionWithPlane(plane2); - } - static containsPoint(anchor, dir, p) { - const closestT = L3.pointT(anchor, dir, p); - const distance = L3.at(anchor, dir, closestT).distanceTo(p); - return eq0(distance); - } - roots() { - return [[], [], []]; - } - containsPoint(p) { - assertVectors(p); - const dist = this.distanceToPoint(p); - assertNumbers(dist); - return eq0(dist); - } - likeCurve(curve) { - return (this == curve || - (hasConstructor(curve, L3) && - this.anchor.like(curve.anchor) && - this.dir1.like(curve.dir1))); - } - equals(obj) { - return (this == obj || - (Object.getPrototypeOf(obj) == L3.prototype && - this.anchor.equals(obj.anchor) && - this.dir1.equals(obj.dir1))); - } - isColinearTo(obj) { - return (obj instanceof L3 && - this.containsPoint(obj.anchor) && - eq(1, Math.abs(this.dir1.dot(obj.dir1)))); - } - distanceToLine(line) { - assertInst(L3, line); - if (this.isParallelToLine(line)) { - return this.distanceToPoint(line.anchor); - } - const dirCross1 = this.dir1.cross(line.dir1).unit(); - const anchorDiff = this.anchor.minus(line.anchor); - return Math.abs(anchorDiff.dot(dirCross1)); - } - distanceToPoint(x) { - assertVectors(x); - // See http://mathworld.wolfram.com/Point-LineDistance3-Dimensional.html - const t = x.minus(this.anchor).dot(this.dir1); - return this.at(t).distanceTo(x); - //return x.minus(this.anchor).cross(x.minus(this.anchor.plus(this.dir1))).length() - } - asSegmentDistanceToPoint(x, sStart, sEnd) { - let t = x.minus(this.anchor).dot(this.dir1); - t = clamp(t, sStart, sEnd); - return this.at(t).minus(x).length(); - } - asSegmentDistanceToLine(line, sStart, sEnd) { - assertInst(L3, line); - const dirCross = this.dir1.cross(line.dir1); - const div = dirCross.squared(); - if (eq0(div)) { - return undefined; - } // lines parallel - const anchorDiff = line.anchor.minus(this.anchor); - // check if distance is zero (see also L3.distanceToLine) - if (!eq0(anchorDiff.dot(dirCross.unit()))) { - return undefined; - } - let t = this.infoClosestToLine(line).t; - t = clamp(t, sStart, sEnd); - return this.at(clamp(t, sStart, sEnd)); - } - at(t) { - assertNumbers(t); - return this.anchor.plus(this.dir1.times(t)); - } - /** - * This function returns lambda for a given point x - * - * Every point x on this line is described by the equation - * x = this.anchor + lambda * this.dir1 | - this.anchor - * x - this.anchor = lambda * this.dir1 | DOT this.dir1 - * (x - this.anchor) DOT this.dir1 = lambda (dir1² is 1 as |dir1| == 1) - * - * @param x - * @returns - */ - pointT(x) { - assertVectors(x); - const t = x.minus(this.anchor).dot(this.dir1); - return t; - } - /** - * Returns true if the line is parallel (this.dir = line.dir || this.dir = -line.dir) to the argument. - */ - isParallelToLine(line) { - assertInst(L3, line); - // we know that 1 == this.dir1.length() == line.dir1.length(), we can check for parallelity simpler than - // isParallelTo() - return eq(1, Math.abs(this.dir1.dot(line.dir1))); - } - angleToLine(line) { - assertInst(L3, line); - return this.dir1.angleTo(line.dir1); - } - /** - * - * @param line - * @returns {boolean} If the distance between the lines is zero - */ - intersectsLine(line) { - return eq0(this.distanceToLine(line)); - } - isInfosWithCurve(curve) { - if (curve instanceof L3) { - return this.isInfosWithLine(curve.anchor, curve.dir1); - } - return super.isInfosWithCurve(curve); - } - isInfosWithLine(anchorWC, dirWC) { - const dirCross = this.dir1.cross(dirWC); - const div = dirCross.squared(); - if (eq0(div)) { - // lines are parallel - return []; - } - const anchorDiff = anchorWC.minus(this.anchor); - if (eq0(anchorDiff.dot(dirCross))) { - const tThis = anchorDiff.cross(dirWC).dot(dirCross) / div; - const tOther = anchorDiff.cross(this.dir1).dot(dirCross) / div; - const p = this.at(tThis); - return [{ tThis: tThis, tOther: tOther, p: p }]; - } - return []; - } - isInfoWithLine(line) { - // todo infos? - assertInst(L3, line); - const dirCross = this.dir1.cross(line.dir1); - const div = dirCross.squared(); - if (eq0(div)) { - return undefined; - } // lines parallel - const anchorDiff = line.anchor.minus(this.anchor); - // check if distance is zero (see also L3.distanceToLine) - if (!eq0(anchorDiff.dot(dirCross.unit()))) { - return undefined; - } - const t = anchorDiff.cross(line.dir1).dot(dirCross) / div; - return this.at(t); - } - /** - * returns s and t with this.at(s) == line.at(t) - */ - intersectionLineST(line) { - // the two points on two lines the closest two each other are the ones whose - // connecting - // TODO Where does this come from? - // TODO: return value when no IS? - assertInst(L3, line); - const dirCross = this.dir1.cross(line.dir1); - const div = dirCross.squared(); - const anchorDiff = line.anchor.minus(this.anchor); - const s = anchorDiff.cross(this.dir1).dot(dirCross) / div; - const t = anchorDiff.cross(line.dir1).dot(dirCross) / div; - return { s: s, t: t }; - // console.log(segmentIntersectsRay, a, b, "ab", ab, "p", p, "dir", dir, s > 0 && t / div >= 0 && t / div <= 1, - // "s", s, "t", t, "div", div) - } - ddt() { - return V3.O; - } - getConstructorParameters() { - return [this.anchor, this.dir1]; - } - closestTToPoint(p) { - // similar logic as pointT; we project the vector (anchor -> p) onto dir1, then add anchor back to it - const nearestT = p.minus(this.anchor).dot(this.dir1); - return nearestT; - } - infoClosestToLine(line) { - /* - line = a + s*b - this = c + t*d - - (this - line) * b = 0 - (this - line) * d = 0 - - (a + s*b - c - t*d) * b = 0 - (a + s*b - c - t*d) * d = 0 - - (a - c + s*b - t*d) * b = 0 - (a - c + s*b - t*d) * d = 0 - - (a - c)*b + (s*b - t*d)*b = 0 - (a - c)*d + (s*b - t*d)*d = 0 - - (a - c)*b + s*(b*b) - t*(d*b) = 0 - (a - c)*d + s*(b*d) - t*(d*d) = 0 - - s = (t*(d*b) - (a - c)*b) / (b*b) - => - (a - c)*d + (t*(d*b) - (a - c)*b) / (b*b)*(b*d) - t*(d*d) = 0 | * (b*b) - (a - c)*d * (b*b) + (t*(d*b) - (a - c)*b)*(b*d) - t*(d*d) * (b*b) = 0 - (a - c)*d * (b*b) + t*(d*b)*(b*d) - (a - c)*b*(b*d) - t*(d*d) * (b*b) = 0 - t = ((a - c)*b*(b*d) - (a - c)*d * (b*b)) / ((d*b)*(b*d) - (d*d) * (b*b)) - */ - if (this.isParallelToLine(line)) { - return { t: NaN, s: NaN, distance: this.distanceToLine(line) }; - } - const a = line.anchor, b = line.dir1, c = this.anchor, d = this.dir1; - const bd = b.dot(d), bb = b.squared(), dd = d.squared(), ca = a.minus(c), divisor = bd * bd - dd * bb; - const t = (ca.dot(b) * bd - ca.dot(d) * bb) / divisor; - const s = (ca.dot(b) * dd - ca.dot(d) * bd) / divisor; - return { - t: t, - s: s, - closest: this.at(t), - closest2: line.at(s), - distance: this.at(t).distanceTo(line.at(s)), - }; - } - intersectionWithPlane(plane) { - // plane: plane.normal1 * p = plane.w - // line: p=line.point + lambda * line.dir1 - const lambda = (plane.w - plane.normal1.dot(this.anchor)) / plane.normal1.dot(this.dir1); - const point = this.anchor.plus(this.dir1.times(lambda)); - return point; - } - tangentAt() { - return this.dir1; - } - isTWithPlane(plane) { - // plane: plane.normal1 * p = plane.w - // line: p=line.point + lambda * line.dir1 - const div = plane.normal1.dot(this.dir1); - if (eq0(div)) - return NaN; - const lambda = (plane.w - plane.normal1.dot(this.anchor)) / div; - return lambda; - } - reversed() { - return new L3(this.anchor, this.dir1.negated(), -this.tMax, -this.tMin); - } - isTsWithPlane(planeWC) { - const t = this.isTWithPlane(planeWC); - return isNaN(t) ? [] : [t]; - } - flipped() { - return new L3(this.anchor, this.dir1.negated()); - } - transform(m4) { - const newAnchor = m4.transformPoint(this.anchor); - const newDir = m4.transformVector(this.dir1); - return new L3(newAnchor, newDir.unit(), this.tMin * newDir.length(), this.tMax * newDir.length()); - } - transform4(m4) { - const vanishingPlane = P3.vanishingPlane(m4); - if (!vanishingPlane) - return this.transform(m4); - const pMin = this.at(this.tMin); - const pMax = this.at(this.tMax); - if (le(vanishingPlane.distanceToPointSigned(pMin), 0) || - le(vanishingPlane.distanceToPointSigned(pMax), 0)) { - throw new Error("line must be in front of vanishingPlane in [tMin, tMax]"); - } - const anchor = lt(0, vanishingPlane.distanceToPointSigned(this.anchor)) - ? this.anchor - : this.at((this.tMin + this.tMax) / 2); - const transformedAnchor = m4.timesVector(VV(anchor.x, anchor.y, anchor.z, 1)); - const transformedVector = m4.timesVector(VV(this.dir1.x, this.dir1.y, this.dir1.z, 0)); - const newDir = transformedVector - .times(transformedAnchor.w) - .minus(transformedAnchor.times(transformedVector.w)) - .V3(); - const newAnchor = transformedAnchor.p3(); - return L3.anchorDirection(newAnchor, newDir, m4.transformPoint(pMin), m4.transformPoint(pMax)); - } - hashCode() { - return this.anchor.hashCode() * 31 + this.dir1.hashCode(); - } -} -L3.X = new L3(V3.O, V3.X); -L3.Y = new L3(V3.O, V3.Y); -L3.Z = new L3(V3.O, V3.Z); -L3.prototype.hlol = Curve.hlol++; -L3.prototype.tIncrement = 256; - -class PICurve extends ImplicitCurve { - constructor(points, tangents, parametricSurface, implicitSurface, pmPoints, pmTangents, stepSize, dir = 1, generator, tMin, tMax) { - super(points, tangents, dir, generator, tMin, tMax); - this.parametricSurface = parametricSurface; - this.implicitSurface = implicitSurface; - this.pmPoints = pmPoints; - this.pmTangents = pmTangents; - this.stepSize = stepSize; - assert(Array.isArray(pmPoints)); - assert(dir == 1); - assert(stepSize <= 1); - const pf = parametricSurface.pUVFunc(); - const dpdu = parametricSurface.dpdu(); - const dpdv = parametricSurface.dpdv(); - const didp = implicitSurface.didp.bind(implicitSurface); - this.didu = (u, v) => didp(pf(u, v)).dot(dpdu(u, v)); - this.didv = (u, v) => didp(pf(u, v)).dot(dpdv(u, v)); - for (let i = 0; i < points.length - 1; i++) { - assert(!points[i].equals(points[i + 1])); - //assert(parametricSurface.pUV(pmPoints[i].x, pmPoints[i].y).equals(points[i])) - } - { - const ps = this.parametricSurface; - const is = implicitSurface; - const pFunc = ps.pUVFunc(), iFunc = is.implicitFunction(); - const dpdu = ps.dpdu(); - const dpdv = ps.dpdv(); - const didp = is.didp.bind(is); - const mf = MathFunctionR2R.forFFxFy((x, y) => iFunc(pFunc(x, y)), (u, v) => didp(pFunc(u, v)).dot(dpdu(u, v)), (u, v) => didp(pFunc(u, v)).dot(dpdv(u, v))); - const { points } = followAlgorithm2d(mf, this.pmPoints[0], stepSize, ps, (u, v) => is.containsPoint(pFunc(u, v)), getLast(this.pmPoints), this.pmTangents[0]); - if (points.length !== this.points.length) { - followAlgorithm2d(mf, this.pmPoints[0], stepSize, ps, (u, v) => is.containsPoint(pFunc(u, v)), getLast(this.pmPoints), this.pmTangents[0]); - } - assert(points.length == this.points.length, points.length, this.points.length); - } - } - static forParametricStartEnd(ps, is, pmStart, pmEnd, stepSize = 0.02, startPMTangent, tMin, tMax) { - const pFunc = ps.pUVFunc(), iFunc = is.implicitFunction(); - const dpdu = ps.dpdu(); - const dpdv = ps.dpdv(); - const didp = is.didp.bind(is); - const mf = MathFunctionR2R.forFFxFy((x, y) => iFunc(pFunc(x, y)), (u, v) => didp(pFunc(u, v)).dot(dpdu(u, v)), (u, v) => didp(pFunc(u, v)).dot(dpdv(u, v))); - const { points, tangents } = followAlgorithm2d(mf, pmStart, stepSize, ps, (u, v) => is.containsPoint(pFunc(u, v)), pmEnd, startPMTangent); - return PICurve.forParametricPointsTangents(ps, is, points, tangents, stepSize, 1, tMin, tMax); - } - static forStartEnd(ps, is, start, end, stepSize = 0.02, startTangent, min, max) { - const startPM = ps.uvP(start); - const dpdu = ps.dpdu()(startPM.x, startPM.y), dpdv = ps.dpdv()(startPM.x, startPM.y); - const startPMTangent = startTangent && - M4.forSys(dpdu, dpdv).inversed().transformVector(startTangent); - // assert(dpdu.times(startPMTangent.x).plus(dpdv.times(startPMTangent.y)).like(startTangent)) - const curve = PICurve.forParametricStartEnd(ps, is, startPM, ps.uvP(end), stepSize, startPMTangent); - return curve.withBounds(min && curve.pointT(min), max && curve.pointT(max)); - } - static forParametricPointsTangents(ps, is, pmPoints, pmTangents, stepSize, dir = 1, tMin, tMax) { - const pFunc = ps.pUVFunc(), dpdu = ps.dpdu(); - const dpdv = ps.dpdv(); - const points = pmPoints.map(({ x, y }) => pFunc(x, y)); - const tangents = pmPoints.map(({ x: u, y: v }, i) => { - const ds = dpdu(u, v); - const dt = dpdv(u, v); - return ds.times(pmTangents[i].x).plus(dt.times(pmTangents[i].y)); - //const p = points[i] - //return cs.normalP(p).cross(ses.normalP(p)) - // .toLength(ds.times(pmTangents[i].x).plus(dt.times(pmTangents[i].y)).length()) - }); - return new PICurve(points, tangents, ps, is, pmPoints, pmTangents, stepSize, dir, undefined, tMin, tMax); - } - getConstructorParameters() { - return [ - this.points, - this.tangents, - this.parametricSurface, - this.implicitSurface, - this.pmPoints, - this.pmTangents, - this.stepSize, - this.dir, - this.generator, - ]; - } - implicitCurve() { - const pF = this.parametricSurface.pUVFunc(); - const iF = this.implicitSurface.implicitFunction(); - return (u, v) => iF(pF(u, v)); - } - isColinearTo(curve) { - if (curve instanceof PICurve) { - if (this.equals(curve)) { - return true; - } - if (this.parametricSurface.isCoplanarTo(curve.parametricSurface) && - this.implicitSurface.isCoplanarTo(curve.implicitSurface)) ; - return false; - } - else { - return false; - } - } - containsPoint(p) { - assertVectors(p); - const t = this.pointT(p); - return !isNaN(t) && this.isValidT(t); - } - equals(obj) { - return (Object.getPrototypeOf(obj) == PICurve.prototype && - this.parametricSurface.equals(obj.parametricSurface) && - this.implicitSurface.equals(obj.implicitSurface) && - this.points[0].equals(obj.points[0]) && - this.tangents[0].equals(obj.tangents[0]) && - this.dir === obj.dir); - } - hashCode() { - let hashCode = 0; - hashCode = hashCode * 31 + this.parametricSurface.hashCode(); - hashCode = hashCode * 31 + this.implicitSurface.hashCode(); - hashCode = hashCode * 31 + this.points[0].hashCode(); - hashCode = hashCode * 31 + this.tangents[0].hashCode(); - return hashCode | 0; - } - tangentP(point) { - assertVectors(point); - assert(this.containsPoint(point), "this.containsPoint(point)"); - const t = this.pointT(point); - return this.tangentAt(t); - } - tangentAt(t) { - assert(!isNaN(t)); - if (0 === t % 1) - return this.tangents[t]; - const uv = this.uvT(t); - const uvTangent = new V3(-this.didv(uv.x, uv.y), this.didu(uv.x, uv.y), 0).toLength(this.stepSize); - const du = this.parametricSurface.dpdu()(uv.x, uv.y); - const dv = this.parametricSurface.dpdv()(uv.x, uv.y); - return du.times(uvTangent.x).plus(dv.times(uvTangent.y)); - } - at(t) { - assert(!isNaN(t)); - if (0 === t % 1) - return this.points[t]; - const startParams = V3.lerp(this.pmPoints[floor(t)], this.pmPoints[ceil(t)], t % 1); - return this.closestPointToParams(startParams); - } - uvT(t) { - assert(!isNaN(t)); - //TODO: use elerp - if (0 === t % 1) - return this.pmPoints[t]; - const startParams = V3.lerp(this.pmPoints[floor(t)], this.pmPoints[ceil(t)], t % 1); - return curvePoint(this.implicitCurve(), startParams, this.didu, this.didv); - } - closestTToPoint(p, tStart) { - // TODO - return 0; - } - closestPointToParams(startUV) { - const pointParams = curvePoint(this.implicitCurve(), startUV, this.didu, this.didv); - return this.parametricSurface.pUVFunc()(pointParams.x, pointParams.y); - } - isTsWithSurface(surface) { - if (surface instanceof EllipsoidSurface) { - const pS = this.parametricSurface, iS = this.implicitSurface; - if (pS instanceof ProjectedCurveSurface && - iS instanceof EllipsoidSurface) { - const iscs = iS.isCurvesWithSurface(surface); - const points = iscs.flatMap((isc) => isc.isTsWithSurface(pS).map((t) => isc.at(t))); - const ts = fuzzyUniques(points.map((p) => this.pointT(p))); - return ts.filter((t) => !isNaN(t) && this.isValidT(t)); - } - } - else if (ImplicitSurface.is(surface)) { - const result = []; - const iF = surface.implicitFunction(); - let prevSignedDistance = iF(this.points[0]); - for (let i = 1; i < this.points.length; i++) { - const point = this.points[i]; - const signedDistance = iF(point); - if (prevSignedDistance * signedDistance <= 0) { - const pF = this.parametricSurface.pUVFunc(); - const dpdu = this.parametricSurface.dpdu(); - const dpdv = this.parametricSurface.dpdv(); - const startUV = this.pmPoints[abs(prevSignedDistance) < abs(signedDistance) ? i - 1 : i]; - const isUV = newtonIterate2dWithDerivatives(this.implicitCurve(), (u, v) => iF(pF(u, v)), startUV.x, startUV.y, 4, this.didu, this.didv, (u, v) => dpdu(u, v).dot(surface.didp(pF(u, v))), (u, v) => dpdv(u, v).dot(surface.didp(pF(u, v)))); - result.push(this.pointT(this.parametricSurface.pUV(isUV.x, isUV.y))); - } - prevSignedDistance = signedDistance; - } - return result; - } - throw new Error(); - } - isTsWithPlane(planeWC) { - return this.isTsWithSurface(new PlaneSurface(planeWC)); - // version which intersects the plane with the defining surfaces of this PICurve, but this causes - // issues when they are PICurves too: - // assertInst(P3, planeWC) - // const ps = this.parametricSurface, - // is = this.implicitSurface - // const pscs = ps.isCurvesWithPlane(planeWC) - // const iscs = is.isCurvesWithPlane(planeWC) - // const infos = iscs.flatMap(isc => pscs.flatMap(psc => isc.isInfosWithCurve(psc))) - // const ts = fuzzyUniques(infos.map(info => this.pointT(info.p))) - // return ts.filter(t => !isNaN(t) && this.isValidT(t)) - } - pointT(p) { - assertVectors(p); - if (!this.parametricSurface.containsPoint(p) || - !this.implicitSurface.containsPoint(p)) { - return NaN; - } - const pmPoint = this.parametricSurface.uvPFunc()(p); - const ps = this.points, pmps = this.pmPoints; - let t = 0, pmDistance = pmPoint.distanceTo(pmps[0]); - while (pmDistance > abs(this.stepSize) && t < ps.length - 1) { - // TODO -1? - //console.log(t, pmps[t].$, pmDistance) - t = min(pmps.length - 1, t + max(1, Math.round(pmDistance / abs(this.stepSize) / 2 / 2))); - pmDistance = pmPoint.distanceTo(pmps[t]); - } - // if (t < this.pmPoints.length - 1 && pmDistance > pmPoint.distanceTo(pmps[t + 1])) { - // t++ - // } - if (pmDistance > abs(this.stepSize) * 1.1) { - // p is not on this curve - return NaN; - } - if (t == ps.length - 1) { - t--; - } - if (ps[t].like(p)) - return t; - if (ps[t + 1].like(p)) - return t + 1; - const startT = withMax(arrayRange(floor(this.tMin), ceil(this.tMax), 1), (t) => -pmPoint.distanceTo(pmps[t])); - if (undefined === startT) - throw new Error(); - if (ps[startT].like(p)) - return startT; - //const [a, b] = 0 === startT - // ? [0, 1] - // : this.points.length - 1 === startT - // ? [startT - 1, startT] - // : pmPoint.distanceTo(pmps[startT - 1]) < pmPoint.distanceTo(pmps[startT + 1]) - // ? [startT - 1, startT] - // : [startT, startT + 1] - const a = max(0, startT - 1), b = min(this.points.length - 1, startT + 1); - const tangent = this.tangentAt(startT); - const f = (t) => this.at(clamp(t, 0, this.points.length - 1)) - .to(p) - .dot(tangent); - // const df = (t: number) => -this.tangentAt(clamp(t, 0, this.points.length - 1)).dot(tangent) - //checkDerivate(f, df, 0, this.points.length - 2, 3) - // 8 steps necessary because df can currently be way off - t = bisect(f, a, b, 32); - if (!isFinite(t) || this.at(t).distanceTo(p) > abs(this.stepSize)) { - return NaN; - } - return t; - } - transform(m4) { - const dirFactor = m4.isMirroring() ? -1 : 1; - return PICurve.forStartEnd(this.parametricSurface.transform(m4), this.implicitSurface.transform(m4), m4.transformPoint(this.points[0]), m4.transformPoint(getLast(this.points)), this.stepSize * dirFactor, m4.transformVector(this.tangents[0]), m4.transformPoint(this.at(this.tMin)), m4.transformPoint(this.at(this.tMax))); - //return PICurve.forParametricStartEnd( - // this.parametricSurface.transform(m4), - // this.implicitSurface.transform(m4), - // this.pmPoints[0], - // getLast(this.pmPoints), - // this.stepSize, - // this.dir, - // this.tMin, - // this.tMax) - // TODO: pass transformed points? - //return new PICurve( - // m4.transformedPoints(this.points), - // m4.transformedVectors(this.tangents), - // this.parametricSurface.transform(m4), - // this.implicitSurface.transform(m4), - // this.pmPoints, - // this.pmTangents, - //this.stepSize, - // this.dir, - //this.generator, - //this.tMin, this.tMax) - } - roots() { - const allTs = arrayRange(0, this.points.length); - return [allTs, allTs, allTs]; - } - isInfosWithLine(anchorWC, dirWC, tMin, tMax, lineMin, lineMax) { - return surfaceIsICurveIsInfosWithLine.call(this, this.implicitSurface, this.parametricSurface, anchorWC, dirWC, tMin, tMax, lineMin, lineMax); - } - toSource(rounder = (x) => x) { - const result = callsce("PICurve.forParametricStartEnd", this.parametricSurface, this.implicitSurface, this.pmPoints[0], getLast(this.pmPoints), this.stepSize, this.pmTangents[0], this.tMin, this.tMax); - return result; - } -} -PICurve.prototype.tIncrement = 1; - -class PPCurve extends ImplicitCurve { - constructor(points, tangents, parametricSurface1, parametricSurface2, st1s, pmTangents, stepSize, dir = 1, generator, tMin, tMax) { - super(points, tangents, dir, generator, tMin, tMax); - this.parametricSurface1 = parametricSurface1; - this.parametricSurface2 = parametricSurface2; - this.st1s = st1s; - this.pmTangents = pmTangents; - this.stepSize = stepSize; - assert(ParametricSurface.is(parametricSurface1)); - assert(ParametricSurface.is(parametricSurface2)); - assert(Array.isArray(st1s)); - assert(dir == 1); - assert(stepSize <= 1); - } - at(t) { - assert(!isNaN(t)); - if (0 === t % 1) - return this.points[t]; - const startPoint = V3.lerp(this.points[floor(t)], this.points[ceil(t)], t % 1); - return curvePointPP(this.parametricSurface1, this.parametricSurface2, startPoint).p; - } - isColinearTo(curve) { - if (curve instanceof PPCurve) { - if (this.equals(curve)) { - return true; - } - if (this.parametricSurface1.isCoplanarTo(curve.parametricSurface1) && - this.parametricSurface1.isCoplanarTo(curve.parametricSurface2)) ; - return false; - } - else { - return false; - } - } - containsPoint(p) { - assertVectors(p); - // TODO: wrong, as there could be another curve - return (this.parametricSurface1.containsPoint(p) && - this.parametricSurface2.containsPoint(p) && - !isNaN(this.pointT(p))); - } - rootPoints() { - const pF1 = this.parametricSurface1.pUVFunc(); - const pF2 = this.parametricSurface2.pUVFunc(); - const pN1 = this.parametricSurface1.normalUVFunc(); - const pN2 = this.parametricSurface2.normalUVFunc(); - const rootsApprox = this.rootsApprox(); - const results = [[], [], []]; - for (let dim = 0; dim < 3; dim++) { - for (let i = 0; i < rootsApprox[dim].length; i++) { - const lambda = rootsApprox[dim][i]; - const p = this.at(lambda); - assert(this.parametricSurface1.containsPoint(p)); - const pp1 = this.parametricSurface1.uvP(p); - const { x: u, y: v } = this.parametricSurface2.uvP(p); - const startValues = [pp1.x, pp1.y, u, v]; - function f(vals) { - const [u1, v1, u2, v2] = vals; - const diff = pF1(u1, v1).minus(pF2(u2, v2)); - const n1 = pN1(u1, v1); - const n2 = pN2(u2, v2); - const tangent = n1.cross(n2); - return [diff.x, diff.y, diff.z, tangent.e(dim)]; - } - const pps = newtonIterate(f, startValues, 8); - // assert(pF1(pps[0], pps[1]).like(pF2(pps[2], pps[3])), - // pF1(pps[0], pps[1]).sce + pF2(pps[2], pps[3]).sce) - const result = pF1(pps[0], pps[1]); - results[dim].push(result); - } - } - return results; - } - roots() { - return this.rootPoints().map((ps) => ps.map((p) => this.pointT(p))); - } - pointTangent(pWC) { - assertVectors(pWC); - assert(this.containsPoint(pWC), "this.containsPoint(pWC)"); - const n1 = this.parametricSurface1.normalP(pWC); - const n2 = this.parametricSurface2.normalP(pWC); - return n1.cross(n2); - } - transform(m4) { - return new PPCurve(m4.transformedPoints(this.points), m4.transformedVectors(this.tangents), this.parametricSurface1.transform(m4), this.parametricSurface2.transform(m4), this.st1s, undefined, this.stepSize, this.dir, undefined); - } - toSource() { - return callsce("PPCurve.forStartEnd", this.parametricSurface1, this.parametricSurface2, this.points[0], getLast(this.points), this.stepSize); - } - static forStartEnd(ps1, ps2, startPoint, end, stepSize = 0.02) { - const { points, tangents, st1s } = followAlgorithmPP(ps1, ps2, startPoint, stepSize); - return new PPCurve(points, tangents, ps1, ps2, st1s, undefined, stepSize, 1); - } - isInfosWithLine(anchorWC, dirWC, tMin, tMax, lineMin, lineMax) { - return surfaceIsICurveIsInfosWithLine.call(this, this.parametricSurface1, this.parametricSurface2, anchorWC, dirWC, tMin, tMax, lineMin, lineMax); - } - isTsWithSurface(surface) { - if (ImplicitSurface.is(surface)) { - const result = []; - const iF = surface.implicitFunction(); - const pUV1 = this.parametricSurface1.pUVFunc(); - const pUV2 = this.parametricSurface2.pUVFunc(); - let prevSignedDistance = iF(this.points[0]); - for (let i = 1; i < this.points.length; i++) { - const point = this.points[i]; - const signedDistance = iF(point); - if (prevSignedDistance * signedDistance <= 0) { - const startIndex = abs(prevSignedDistance) < abs(signedDistance) ? i - 1 : i; - const startPoint = this.points[startIndex]; - const startUV1 = this.st1s[startIndex]; - const startUV2 = this.parametricSurface2.uvP(startPoint); - const isSTUV = newtonIterate(([u1, v1, u2, v2]) => { - const ps1p = pUV1(u1, v1); - const ps2p = pUV2(u2, v2); - return [...ps1p.to(ps2p), iF(ps1p)]; - }, [startUV1.x, startUV1.y, startUV2.x, startUV2.y]); - result.push(this.pointT(this.parametricSurface1.pUV(isSTUV[0], isSTUV[1]))); - } - prevSignedDistance = signedDistance; - } - return result; - } - throw new Error("Method not implemented."); - } - isTsWithPlane(planeWC) { - return this.isTsWithSurface(new PlaneSurface(planeWC)); - } -} - -/** - * eta = xi² - */ -class ParabolaCurve extends XiEtaCurve { - constructor(center, f1, f2, tMin = -10, tMax = 10) { - super(center, f1, f2, tMin, tMax); - } - static eccentricity() { - return 1; - } - static unitIsInfosWithLine(anchorLC, dirLC, anchorWC, dirWC) { - // para: x² = y - // line(t) = anchor + t dir - // (ax + t dx)² = ay + t dy - // ax² + t ax dx + t² dx² = ay + t dy - // t² dx² + t (ax dx + dy) + ay² + ay = 0 - const pqDiv = Math.pow(dirLC.x, 2); - const lineTs = pqFormula((anchorLC.x * dirLC.x + dirLC.y) / pqDiv, (Math.pow(anchorLC.x, 2) + anchorLC.y) / pqDiv); - return lineTs - .filter((tOther) => le(0, anchorLC.y + tOther * dirLC.y)) - .map((tOther) => ({ - tThis: dirLC.x * tOther + anchorLC.x, - tOther: tOther, - p: L3.at(anchorWC, dirWC, tOther), - })); - } - static intersectionUnitLine(a, b, c) { - /* - solve system (5)/(6) - g1 * xi + g2 * eta = g3 (6) - g1 * xi + g2 * xi * xi = g3 - xi² + xi * g1/g2 - g3/g2 = 0 - */ - return pqFormula(a / b, -c / b); - } - static XYLCValid(pLC) { - return eq(Math.pow(pLC.x, 2), pLC.y); - } - static XYLCPointT(pLC) { - return pLC.x; - } - static quadratic(a, b, c) { - // (1 - t)² a + 2 * t * (1 - t) b + t² c - // (1 -2t +t²)a + (2t -2t²) b + t² c - // = t²(a - 2b + c) + t (-2a + 2b) + a - // (2t - 2) a + (1 - 2t) b + 2t c = t(2a + 2b - 2c) - 2a + b - // 2 a + -2 b + 2 c - const f2 = a.plus(c).minus(b.times(2)); - const f1 = b.minus(a).times(2); - const center = a; - return new ParabolaCurve(center, f1, f2, 0, 1); - } - at(t) { - // center + f1 t + f2 t² - return this.center.plus(this.f1.times(t)).plus(this.f2.times(t * t)); - } - tangentAt(t) { - assertNumbers(t); - // f1 + f2 2 t - return this.f1.plus(this.f2.times(2 * t)); - } - ddt(t) { - assertNumbers(t); - return this.f2.times(2); - } - tangentAt2(xi, eta) { - assertNumbers(xi, eta); - return this.f1.plus(this.f2.times(2 * eta)); - } - reversed() { - return new this.constructor(this.center, this.f1.negated(), this.f2, -this.tMax, -this.tMin); - } - /** - * tangent: f1 + 2 * t * f2 = 0 - * t = -f1 / 2 / f2 (for individual dimensions) - */ - roots() { - const dimRoots = (dim) => eq0(this.f2.e(dim)) ? [] : [-this.f1.e(dim) / 2 / this.f2.e(dim)]; - return arrayFromFunction(3, dimRoots); - } - isColinearTo(curve) { - if (!hasConstructor(curve, ParabolaCurve)) - return false; - const thisRA = this.rightAngled(), curveRA = curve.rightAngled(); - return (thisRA.center.like(curveRA.center) && - thisRA.f2.like(curveRA.f2) && - thisRA.f1.likeOrReversed(curveRA.f1)); - } - rightAngled() { - // looking for vertex of parabola - // this is the point where the tangent is perpendicular to the main axis (f2) - // tangent = f1 + f2 * 2 * t0 - // f2 DOT (f1 + f2 * 2 * t0) == 0 - // f1 DOT f2 + f2 DOT f2 * 2 * t0 == 0 - // t0 == -(f1 DOT f2) / (f2 DOT f2 * 2) - const f1 = this.f1, f2 = this.f2; - const f1DOTf2 = f1.dot(f2); - if (eq0(f1DOTf2) && f1.hasLength(1)) { - return this; - } - const t0 = -f1DOTf2 / f2.squared() / 2; - // we need to rearange tMin/tMax - // tMin' = pointT(at(tMin)) = - const raCenter = this.at(t0); - const raF1 = this.tangentAt(t0), raF1Length = raF1.length(), raF11 = raF1.unit(); - const repos = (t) => this.at(t).minus(raCenter).dot(raF11); - return new ParabolaCurve(raCenter, raF11, f2.div(Math.pow(raF1Length, 2)), repos(this.tMin), repos(this.tMax)); - } - arcLength(startT, endT) { - let f1 = this.f1; - const f2 = this.f2; - const f1DOTf2 = f1.dot(f2); - let t0 = 0; - if (!eq0(f1DOTf2)) { - t0 = -f1DOTf2 / f2.squared() / 2; - f1 = f1.plus(f2.times(2 * t0)); - } - const f1Length = f1.length(); - const a = f2.length() / f1Length; - function F(x) { - return (Math.asinh(a * 2 * x) / 4 / a + - (x * Math.sqrt(1 + a * a * 4 * x * x)) / 2); - } - return f1Length * (F(endT - t0) - F(startT - t0)); - } - transform4(m4) { - return parabola4Projection(this.matrix.transform(m4), this.tMin, this.tMax); - } - asBezier() { - return BezierCurve.quadratic(this.at(-1), new L3(this.at(-1), this.tangentAt(-1).unit()).isInfoWithLine(new L3(this.at(1), this.tangentAt(1).unit())), this.at(1)); - } - /** - * Returns new ParabolaCurve that has its center point at this.at(t0) - * @param t0 - */ - recenter(t0) { - // this.at(t) = f2 t² + f1 t + center - // c2.at(t) = f2 (t + t0)² + f1 (t + t0) + center - // c2.at(t) = f2 (t² + 2 t0 t + t0²) + f1 (t + t0) + center - // c2.at(t) = f2 t² + (f1 + 2 f2 t0) t + center + f2 t0² + f1 t0 - return new ParabolaCurve(this.at(t0), this.f1.plus(this.f2.times(2 * t0)), this.f2); - } -} -ParabolaCurve.XY = new ParabolaCurve(V3.O, V3.X, V3.Y); -ParabolaCurve.YZ = new ParabolaCurve(V3.O, V3.Y, V3.Z); -ParabolaCurve.ZX = new ParabolaCurve(V3.O, V3.Z, V3.X); -ParabolaCurve.prototype.tIncrement = 1 / 32; - -class EllipseCurve extends XiEtaCurve { - constructor(center, f1, f2, tMin = 0, tMax = PI) { - super(center, f1, f2, tMin, tMax); - assert(-PI <= this.tMin && this.tMin < PI); - assert(-PI < this.tMax && this.tMax <= PI); - } - static andFixTs(center, f1, f2, tMin = 0, tMax = PI) { - if (-PI <= tMin && tMax <= PI) { - return new EllipseCurve(center, f1, f2, tMin, tMax); - } - if (0 <= tMin && tMax <= TAU) { - return new EllipseCurve(center, f1.negated(), f2.negated(), tMin - PI, tMax - PI); - } - if (-TAU <= tMin && tMax <= 0) { - return new EllipseCurve(center, f1.negated(), f2.negated(), tMin + PI, tMax + PI); - } - throw new Error("Method not implemented."); - } - static XYLCValid(pLC) { - const { x, y } = pLC; - return eq0(Math.pow(x, 2) + Math.pow(y, 2) - 1); - } - static XYLCPointT(pLC, tMin, tMax) { - assertNumbers(tMin, tMax); - const t = atan2(pLC.y, pLC.x); - const lowSplitter = lerp(tMin, tMax - TAU, 0.5); - if (t < lowSplitter) { - return t + TAU; - } - const highSplitter = lerp(tMax, tMin + TAU, 0.5); - if (t > highSplitter) { - return t - TAU; - } - return t; - } - static intersectionUnitLine(a, b, c, tMin, tMax) { - const isLC = intersectionUnitCircleLine2(a, b, c); - const result = []; - for (const [xi, eta] of isLC) { - const t = EllipseCurve.XYLCPointT(new V3(xi, eta, 0), tMin, tMax); - fuzzyBetween(t, tMin, tMax) && result.push(t); - } - return result; - } - static unitIsInfosWithLine(anchorLC, dirLC, anchorWC, dirWC, tMin, tMax) { - // ell: x² + y² = 1 = p² - // line(t) = anchor + t dir - // anchor² - 1 + 2 t dir anchor + t² dir² = 0 - const pqDiv = dirLC.squared(); - const lineTs = pqFormula((2 * dirLC.dot(anchorLC)) / pqDiv, (anchorLC.squared() - 1) / pqDiv); - return lineTs - .filter((tOther) => le(0, anchorLC.y + tOther * dirLC.y)) - .map((tOther) => ({ - tThis: EllipseCurve.XYLCPointT(dirLC.times(tOther).plus(anchorLC), tMin, tMax), - tOther: tOther, - p: L3.at(anchorWC, dirWC, tOther), - })); - } - /** - * Returns a new EllipseCurve representing a circle parallel to the XY-plane.` - */ - static semicircle(radius, center = V3.O, tMin, tMax) { - return new EllipseCurve(center, new V3(radius, 0, 0), new V3(0, radius, 0), tMin, tMax); - } - static circleForCenter2P(center, a, b, radius, tMin, tMax) { - const f1 = center.to(a); - const normal = f1.cross(center.to(b)); - const f2 = normal.cross(f1).toLength(f1.length()); - return new EllipseCurve(center, f1, f2, undefined !== tMin ? tMin : 0, undefined !== tMax ? tMax : f1.angleTo(center.to(b))); - } - split(tMin = this.tMin, tMax = this.tMax) { - const result = []; - tMin < 0 && - result.push(new EllipseCurve(this.center, this.f1.negated(), this.f2.negated(), tMin + PI, min(0, tMax) + PI)); - tMax > 0 && - result.push(new EllipseCurve(this.center, this.f1, this.f2, max(0, tMin), tMax)); - return result; - } - static forAB(a, b, center = V3.O) { - return super.forAB(a, b, center); - } - /** - * Create a circle curve which has a, b and c on it. a, b, c can't be on a straight line. - * tMin defaults to 0, tMax defaults to the value for c - */ - static circleThroughPoints(a, b, c, tMin = 0, tMax) { - assertf(() => !L3.throughPoints(a, c).containsPoint(b)); - const normal = a.to(b).cross(b.to(c)); - const center = new L3(a.lerp(b, 0.5), normal.cross(a.to(b)).unit()).isInfoWithLine(new L3(b.lerp(c, 0.5), normal.cross(b.to(c)).unit())); - const f1 = center.to(a).negated(); - return new EllipseCurve(center, f1, normal.unit().cross(f1), -PI, undefined === tMax - ? f1.angleRelativeNormal(center.to(c), normal.unit()) - : tMax); - } - getAreaInDir(right, up, tStart, tEnd) { - //assertf(() => tStart < tEnd) - assertf(() => right.isPerpendicularTo(this.normal)); - assertf(() => up.isPerpendicularTo(this.normal)); - //assertf(() => EllipseCurve.isValidT(tStart), tStart) - //assertf(() => EllipseCurve.isValidT(tEnd), tEnd) - const upLC = this.matrixInverse.transformVector(up); - const rightLC = upLC.cross(V3.Z); - const normTStart = tStart - rightLC.angleXY(); - const normTEnd = tEnd - rightLC.angleXY(); - const transformedOriginY = this.matrixInverse - .getTranslation() - .dot(upLC.unit()); - // integral of sqrt(1 - x²) from 0 to cos(t) - // Basically, we want - // INTEGRAL[cos(t); PI/2] sqrt(1 - x²) dx - // INTEGRAL[PI/2: cos(t)] -sqrt(1 - x²) dx - // = INTEGRAL[cos(0); cos(t)] -sqrt(1 - x²) dx - // = INTEGRAL[0; t] -sqrt(1 - cos²(t)) * -sin(t) dt - // = INTEGRAL[0; t] -sin(t) * -sin(t) dt - // = INTEGRAL[0; t] sin²(t) dt (partial integration / wolfram alpha) - // = (1/2 * (t - sin(t) * cos(t)))[0; t] (this form has the distinct advantage of being defined everywhere) - function fArea(t) { - return (t - Math.sin(t) * Math.cos(t)) / 2; - } - // for the centroid, we want - // cx = 1 / area * INTEGRAL[cos(t); PI/2] x * f(x) dx - // cx = 1 / area * INTEGRAL[cos(t); PI/2] x * sqrt(1 - x²) dx - // cx = 1 / area * INTEGRAL[cos(0); cos(t)] x * -sqrt(1 - x²) dx - // ... - // cx = 1 / area * INTEGRAL[0; t] cos(t) * sin²(t) dt // WA - // cx = 1 / area * (sin^3(t) / 3)[0; t] - function cxTimesArea(t) { - return Math.pow(Math.sin(t), 3) / 3; - } - // cy = 1 / area * INTEGRAL[cos(t); PI/2] f²(x) / 2 dx - // cy = 1 / area * INTEGRAL[cos(0); cos(t)] -(1 - x²) / 2 dx - // cy = 1 / area * INTEGRAL[0; t] (cos²(t) - 1) * -sin(t) / 2 dt - // cy = 1 / area * (cos (3 * t) - 9 * cos(t)) / 24 )[0; t] - function cyTimesArea(t) { - return (Math.cos(3 * t) - 9 * Math.cos(t)) / 24; - } - const restArea = -transformedOriginY * (-Math.cos(normTEnd) + Math.cos(normTStart)); - const area = fArea(normTEnd) - fArea(normTStart) + restArea; - const cxt = (cxTimesArea(normTEnd) - - cxTimesArea(normTStart) + - ((-transformedOriginY * (-Math.cos(normTEnd) - Math.cos(normTStart))) / - 2) * - restArea) / - area; - const cyt = (cyTimesArea(normTEnd) - - cyTimesArea(normTStart) - - (-transformedOriginY / 2) * restArea) / - area; - const factor = this.matrix.xyAreaFactor(); // * upLC.length() - //console.log('fctor', factor, 'area', area, 'resultarea', area* factor) - assert(!eq0(factor)); - return { - area: area * factor, - centroid: this.matrix.transformPoint(M4.rotateZ(rightLC.angleXY()).transformPoint(new V3(cxt, cyt, 0))), - }; - } - at(t) { - assertNumbers(t); - //assert(this.isValidT(t)) - // = center + f1 cos t + f2 sin t - return this.center - .plus(this.f1.times(Math.cos(t))) - .plus(this.f2.times(Math.sin(t))); - } - tangentAt(t) { - assertNumbers(t); - //assert(this.isValidT(t)) - // ) f2 cos(t) - f1 sin(t) - return this.f2.times(Math.cos(t)).minus(this.f1.times(Math.sin(t))); - } - ddt(t) { - assertNumbers(t); - assert(this.isValidT(t)); - return this.f2.times(-Math.sin(t)).minus(this.f1.times(Math.cos(t))); - } - tangentAt2(xi, eta) { - return this.f2.times(xi).minus(this.f1.times(eta)); - } - isCircular() { - return (eq(this.f1.length(), this.f2.length()) && - this.f1.isPerpendicularTo(this.f2)); - } - isColinearTo(curve) { - if (!hasConstructor(curve, EllipseCurve)) - return false; - if (!this.center.like(curve.center)) { - return false; - } - if (this == curve) { - return true; - } - if (this.isCircular()) { - return (curve.isCircular() && - eq(this.f1.length(), curve.f1.length()) && - this.normal.isParallelTo(curve.normal)); - } - else { - let { f1: f1, f2: f2 } = this.rightAngled(), { f1: c1, f2: c2 } = curve.rightAngled(); - if (f1.length() > f2.length()) { - [f1, f2] = [f2, f1]; - } - if (c1.length() > c2.length()) { - [c1, c2] = [c2, c1]; - } - return (eq(f1.squared(), Math.abs(f1.dot(c1))) && - eq(f2.squared(), Math.abs(f2.dot(c2)))); - } - } - pointT(pWC) { - assertVectors(pWC); - assert(this.containsPoint(pWC)); - const pLC = this.matrixInverse.transformPoint(pWC); - const t = EllipseCurve.XYLCPointT(pLC, this.tMin, this.tMax); - assert(this.isValidT(t)); - return t; - } - reversed() { - return new EllipseCurve(this.center, this.f1.negated(), this.f2, PI - this.tMax, PI - this.tMin); - } - eccentricity() { - const mainAxes = this.rightAngled(); - const f1length = mainAxes.f1.length(), f2length = mainAxes.f1.length(); - const [a, b] = f1length > f2length ? [f1length, f2length] : [f2length, f1length]; - return Math.sqrt(1 - (b * b) / a / a); - } - circumference() { - return this.arcLength(-Math.PI, Math.PI); - } - arcLength(tStart = this.tMin, tEnd = this.tMax, steps = 2) { - assert(tStart < tEnd, "startT < endT"); - const f1Length = this.f1.length(); - if (eq(f1Length, this.f2.length())) { - return f1Length * (tEnd - tStart); - } - return super.arcLength(tStart, tEnd, steps); - } - circumferenceApproximate() { - // approximate circumference by Ramanujan - // https://en.wikipedia.org/wiki/Ellipse#Circumference - const { f1, f2 } = this.rightAngled(), a = f1.length(), b = f2.length(); - const h = Math.pow((a - b), 2) / Math.pow((a + b), 2); - return Math.PI * (a + b) * (1 + (3 * h) / (10 + Math.sqrt(4 - 3 * h))); - } - /** - * Radii of the ellipse are described by - * q(phi) = f1 * cos(phi) + f2 * sin(phi) - * or q(xi, eta) = f1 * xi + f2 * eta (1) with the added condition - * xi² + eta² = 1 (2) - * we want to find the radius where the corresponding tangent is perpendicular - * tangent: q'(phi) = f1 * -sin(phi) + f2 * cos(phi) - * tangent: q'(xi, eta) = f1 * -eta + f2 * xi - * perpendicular when: q'(xi, eta) DOT q(xi, eta) = 0 - * (f1 * -eta + f2 * xi) DOT (f1 * xi + f2 * eta) = 0 - * DOT is distributive: - * f1² * (-eta * xi) + f1 * f2 * (-eta² + xi²) + f2² * (xi * eta) = 0 - * (f2² - f1²) * (eta * xi) + f1 * f2 * (-eta² + xi²) = 0 - * a * (xi² - eta²) + b * xi * eta = 0 (2) - * with a = f1 * f2, b = f2² - f1² - * => (xi/eta)² + xi/eta * b/a + 1 = 0 (divide by a * eta²) - * xi/eta = b/a/2 +- sqrt(b²/a²/4 - 1) | * 2*a*eta - * 2 * a * xi = eta * (b +- sqrt(b² - 4 * a²)) - * g1 * xi - g2 * eta = 0 (3) - * with g1 = 2 * a, g2 = b +- sqrt(b² - 4 * a²) - * Solve (3), (2) with intersectionUnitCircleLine - */ - rightAngled() { - const f1 = this.f1, f2 = this.f2, a = f1.dot(f2), b = f2.squared() - f1.squared(); - if (eq0(a)) { - return this; - } - const g1 = 2 * a, g2 = b + Math.sqrt(b * b + 4 * a * a); - const { x1: xi, y1: eta } = intersectionUnitCircleLine(g1, g2, 0); - const f1RA = f1.times(xi).plus(f2.times(eta)); - const f2RA = f1.times(-eta).plus(f2.times(xi)); - return new EllipseCurve(this.center, f1RA, f2RA, -PI, PI); - } - isInfosWithEllipse(ellipse) { - if (this.normal.isParallelTo(ellipse.normal) && - eq0(this.center.minus(ellipse.center).dot(ellipse.normal))) { - // ellipses are coplanar - const ellipseLCRA = ellipse.transform(this.matrixInverse).rightAngled(); - const r1 = ellipseLCRA.f1.lengthXY(), r2 = ellipseLCRA.f2.lengthXY(), centerDist = ellipseLCRA.center.lengthXY(); - const rMin = min(r1, r2), rMax = max(r1, r2); - if (lt(centerDist + rMax, 1) || // entirely inside unit circle - lt(1, centerDist - rMax) || // entirely outside unit circle - lt(1, rMin - centerDist) || // contains unit circle - (eq(1, r1) && eq(1, r2) && eq0(centerDist)) // also unit circle, return no IS - ) { - return []; - } - const f = (t) => ellipseLCRA.at(t).lengthXY() - 1; - const df = (t) => ellipseLCRA.at(t).xy().dot(ellipseLCRA.tangentAt(t)) / - ellipseLCRA.at(t).lengthXY(); - checkDerivate(f, df, -PI, PI, 1); - const ellipseLCRATs = []; - for (let startT = (-4 / 5) * PI; startT < PI; startT += PI / 4) { - let t = newtonIterateSmart(f, startT, 16, df, 1e-4); - le(t, -PI) && (t += TAU); - assert(!isNaN(t)); - if (between(t, -PI, PI) && - eq0(f(t)) && - !ellipseLCRATs.some((r) => eq(t, r))) { - ellipseLCRATs.push(t); - } - } - const result = []; - for (const ellipseLCRAT of ellipseLCRATs) { - const p = this.matrix.transformPoint(ellipseLCRA.at(ellipseLCRAT)); - if (this.containsPoint(p) && ellipse.containsPoint(p)) { - result.push({ tThis: this.pointT(p), tOther: ellipse.pointT(p), p }); - } - } - return result; - //const angle = ellipseLCRA.f1.angleXY() - //const aSqr = ellipseLCRA.f1.squared(), bSqr = ellipseLCRA.f2.squared() - //const a = Math.sqrt(aSqr), b = Math.sqrt(bSqr) - //const {x: centerX, y: centerY} = ellipseLCRA.center - //const rotCenterX = centerX * Math.cos(-angle) + centerY * -Math.sin(-angle) - //const rotCenterY = centerX * Math.sin(-angle) + centerY * Math.cos(-angle) - //const rotCenter = V(rotCenterX, rotCenterY) - //const f = t => { - // const lex = Math.cos(t) - rotCenterX, ley = Math.sin(t) - rotCenterY - // return lex * lex / aSqr + ley * ley / bSqr - 1 - //} - //const f2 = (x, y) => (x * x + y * y - 1) - //const f3 = (x, y) => ((x - rotCenterX) * (x - rotCenterX) / aSqr + (y - rotCenterY) * (y - rotCenterY) / - // bSqr - 1) const results = [] const resetMatrix = this.matrix.times(M4.rotateZ(angle)) for (let startT = - // Math.PI / 4; startT < 2 * Math.PI; startT += Math.PI / 2) { const startP = EllipseCurve.XY.at(startT) - // const p = newtonIterate2d(f3, f2, startP.x, startP.y, 10) if (p && !results.some(r => r.like(p))) { - // results.push(p) } } const rotEl = new EllipseCurve(rotCenter, V(a, 0, 0), V(0, b, 0)) return - // results.map(pLC => { const p = resetMatrix.transformPoint(pLC) return {tThis: this.pointT(p, PI), - // tOther: ellipse.pointT(p, PI), p} }) - } - else { - return mapFilter(this.isTsWithPlane(P3.normalOnAnchor(ellipse.normal.unit(), ellipse.center)), (t) => { - const p = this.at(t); - if (ellipse.containsPoint(p)) { - return { tThis: t, tOther: ellipse.pointT(p), p }; - } - return undefined; - }); - } - } - isInfosWithCurve(curve) { - if (curve instanceof EllipseCurve) { - return this.isInfosWithEllipse(curve); - } - return super.isInfosWithCurve(curve); - } - transform4(m4) { - const tMap = (t) => sign(t) * sqrt((1 - cos(t)) / (1 + cos(t))); - // prettier-ignore - const parabolaToUnitEllipse = new M4(0, -1, 0, 1, 2, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 1); - return parabola4Projection(M4.product(m4, this.matrix, parabolaToUnitEllipse), tMap(this.tMin), tMap(this.tMax)); - } - roots() { - // tangent(t) = f2 cos t - f1 sin t - // solve for each dimension separately - // tangent(eta, xi) = f2 eta - f1 xi - return arrayFromFunction(3, (dim) => { - const a = this.f2.e(dim); - const b = -this.f1.e(dim); - return intersectionUnitCircleLine2(a, b, 0) - .map(([xi, eta]) => Math.atan2(eta, xi)) - .filter((t) => this.isValidT(t)); - }); - } - closestTToPoint(p, tStart) { - // (at(t) - p) * tangentAt(t) = 0 - // (xi f1 + eta f2 + q) * (xi f2 - eta f1) = 0 - // xi eta (f2^2-f1^2) + xi f2 q - eta² f1 f2 + xi² f1 f2 - eta f1 q = 0 - // (xi² - eta²) f1 f2 + xi eta (f2^2-f1^2) + xi f2 q - eta f1 q = 0 - // atan2 of p is a good first approximation for the searched t - tStart = tStart || this.matrixInverse.transformPoint(p).angleXY(); - const pRelCenter = p.minus(this.center); - const f = (t) => this.tangentAt(t).dot(this.f1 - .times(Math.cos(t)) - .plus(this.f2.times(Math.sin(t))) - .minus(pRelCenter)); - return newtonIterate1d(f, tStart, 8); - } - area() { - // see - // https://upload.wikimedia.org/wikipedia/commons/thumb/4/4e/Cross_product_parallelogram.svg/220px-Cross_product_parallelogram.svg.png - return Math.PI * this.f1.cross(this.f2).length(); - } - angleToT(phi) { - // atan2(y, x) = phi - const phiDir = this.f1 - .unit() - .times(Math.cos(phi)) - .plus(this.f2.rejectedFrom(this.f1).unit().times(Math.sin(phi))); - const dirLC = this.matrixInverse.transformVector(phiDir); - return dirLC.angleXY(); - } -} -EllipseCurve.UNIT = new EllipseCurve(V3.O, V3.X, V3.Y); -EllipseCurve.prototype.hlol = Curve.hlol++; -EllipseCurve.prototype.tIncrement = (2 * Math.PI) / (4 * 32); - -/** - * Non-Uniform Rational B-Spline implementation. - * - * See https://pages.mtu.edu/~shene/COURSES/cs3621/NOTES/ for a good reference. - * - * - */ -class NURBS extends Curve { - constructor( - /** - * The control points of the NURBS curve, as 4D homogeneous coordinates. - */ - points, - /** - * The degree of the NURBS curve. Must be at least 1 (linear). - */ - degree, knots = NURBS.openUniformKnots(points.length, degree), tMin = knots[degree], tMax = knots[knots.length - degree - 1]) { - super(tMin, tMax); - this.points = points; - this.degree = degree; - this.knots = knots; - const knotsLength = points.length + degree + 1; - NLA_DEBUG && Object.freeze(points); - NLA_DEBUG && Object.freeze(knots); - assert(knots.length === knotsLength, "bad knot vector length: expected " + - knotsLength + - " (degree = " + - degree + - " pcount = " + - points.length + - "), but was " + - knots.length); - assert(knots[degree] <= tMin); - assert(tMax <= knots[knots.length - degree - 1]); - for (let i = 0; i < points.length; i++) { - assert(points[i].dim() == 4); - } - assert(degree >= 1, "degree must be at least 1 (linear)"); - assert(degree % 1 == 0); - assert(-1 == firstUnsorted(knots, MINUS), "knot values must be in ascending order"); - } - getConstructorParameters() { - return [this.points, this.degree, this.knots]; - } - at4(t) { - NLA_DEBUG && - assert(between(t, this.tMin, this.tMax), t + " " + this.tMin + " " + this.tMax); - const { points, degree, knots } = this; - // find s (the spline segment) for the [t] value provided - const s = this.tInterval(t); - const v = Vector.pack(points, new Float64Array((degree + 1) * 4), s - degree, 0, degree + 1); - for (let level = 0; level < degree; level++) { - // build level l of the pyramid - for (let i = degree; i > level; i--) { - const alpha = (t - knots[i + s - degree]) / - (knots[i + s - level] - knots[i + s - degree]); - // interpolate each component - for (let dim = 0; dim < 4; dim++) { - v[i * 4 + dim] = - (1 - alpha) * v[(i - 1) * 4 + dim] + alpha * v[i * 4 + dim]; - } - } - } - return new Vector(v.slice(degree * 4, (degree + 1) * 4)); - } - at(t) { - return this.at4(t).p3(); - } - /** - d(k, i, t) = a(i, k, t) * d(k - 1, i, t) + (1 - a(i, k, t)) * d(k - 1, i - 1, t) - a(i, k, t) = (t - knots[i]) / (knots[i + 1 + n - k] - knots[i]) - a'(i, k, t) = 1 / (knots[i + 1 + n - k] - knots[i]) - - d/dt = a(i, k, t) * d'(k - 1, i, t) + a'(i, k, t) * d(k - 1, i, t) - + (1 - a(i, k, t)) * d'(k - 1, i - 1, t) + a'(i, k, t) * d(k - 1, i - 1, t) - */ - ptDtDdt4(t) { - const { points, degree, knots } = this; - // find s (the spline segment) for the [t] value provided - const s = this.tInterval(t); - const v = Vector.pack(points, new Float64Array((degree + 1) * 4), s - degree, 0, degree + 1); - let ddt = Vector.Zero(4); - let derivative; - for (let level = 0; level < degree; level++) { - if (level == degree - 2) { - // see https://www.globalspec.com/reference/61012/203279/10-8-derivatives - const a = new Vector(v.slice(degree * 4, (degree + 1) * 4)); - const b = new Vector(v.slice((degree - 1) * 4, degree * 4)); - const c = new Vector(v.slice((degree - 2) * 4, (degree - 1) * 4)); - function step(k, i, dkMinus1iMinus1, dkMinus1i) { - return dkMinus1i - .minus(dkMinus1iMinus1) - .times(k / (knots[i + degree - k] - knots[i - 1])); - } - ddt = step(degree, s + 1, step(degree - 1, s + 1, a, b), step(degree - 1, s, b, c)); - } - if (level == degree - 1) { - const a = new Vector(v.slice(degree * 4, (degree + 1) * 4)); - const b = new Vector(v.slice((degree - 1) * 4, degree * 4)); - derivative = b.minus(a).times(degree / (knots[s] - knots[s + 1])); - } - for (let i = degree; i > level; i--) { - const alpha = (t - knots[i + s - degree]) / - (knots[i + s - level] - knots[i + s - degree]); - // interpolate each component - for (let dim = 0; dim < 4; dim++) { - v[i * 4 + dim] = - (1 - alpha) * v[(i - 1) * 4 + dim] + alpha * v[i * 4 + dim]; - } - } - } - const p = new Vector(v.slice(degree * 4, degree * 4 + 4)); - return [p, derivative, ddt]; - } - tangentAt(t) { - // x(t) = xw(t) / w(t) - // quotient rule - const [p, derivative] = this.ptDtDdt4(t); - const expected = derivative - .times(p.w) - .minus(p.times(derivative.w)) - .div(Math.pow(p.w, 2)) - .V3(); - return expected; - } - ddt(t) { - const [p, dt, ddt] = this.ptDtDdt4(t); - // =(-w(t) x(t) w''(t) - 2 w(t) w'(t) x'(t) + 2 x(t) w'(t)^2 + w(t)^2 x''(t))/w(t)^3 - // =(x(t) ((-w(t)) w''(t) + 2 w'(t)^2) - x'(t) 2 w(t) w'(t) + x''(t) w(t)^2 )/w(t)^3 - // prettier-ignore - return Vector.add(p.times(-p.w * ddt.w + 2 * Math.pow(dt.w, 2)), dt.times(-2 * p.w * dt.w), ddt.times(Math.pow(p.w, 2))).div(Math.pow(p.w, 3)).V3(); - } - ptDtDdt(t) { - const [pt, dt4, ddt4] = this.ptDtDdt4(t); - return [ - pt.p3(), - dt4 - .times(pt.w) - .minus(pt.times(dt4.w)) - .div(Math.pow(pt.w, 2)) - .V3(), - Vector.add(pt.times(-pt.w * ddt4.w + 2 * Math.pow(dt4.w, 2)), // - dt4.times(-2 * pt.w * dt4.w), ddt4.times(Math.pow(pt.w, 2))) - .div(Math.pow(pt.w, 3)) - .V3(), - ]; - } - pointT(pWC) { - return this.closestTToPoint(pWC); - } - closestTToPoint(p, tStart, tMin = this.tMin, tMax = this.tMax) { - // this.at(t) has minimal distance to p when this.tangentAt(t) is perpendicular to - // the vector between this.at(t) and p. This is the case iff the dot product of the two is 0. - // f = (this.at(t) - p) . (this.tangentAt(t) - // df = this.tangentAt(t) . this.tangentAt(t) + (this.at(t) - p) . this.ddt(t) - // = this.tangentAt(t)² + (this.at(t) - p) . this.ddt(t) - const f = (t) => { - const [pt, dt, ddt] = this.ptDtDdt(t); - return [pt.minus(p).dot(dt), dt.squared() + pt.minus(p).dot(ddt)]; - }; - //checkDerivate(f, df, tMin, tMax) - const STEPS = 32; - if (undefined === tStart) { - tStart = withMax(arraySamples(tMin, tMax, STEPS), (t) => -this.at(t).distanceTo(p)); - } - const result = newtonIterateWithDerivative2(f, tStart, 8, this.tMin, this.tMax); - //assert(undefined !== result) - return result; - } - containsPoint(pWC) { - const tGuess = this.closestTToPoint(pWC); - return undefined === tGuess ? false : this.at(tGuess).like(pWC); - } - derivate() { - const k = this.degree; - const ps = arrayFromFunction(this.points.length - 1, (i) => this.points[i] - .to(this.points[i + 1]) - .times(k / (this.knots[i + k + 1] - this.knots[i + 1]))); - return new NURBS(ps, this.degree - 1, this.knots.slice(1, -1), this.tMin, this.tMax); - } - /** - * Create a new NURBS of equal degree with the added knot [newKnot]. New NURBS will have one additional control - * point. - */ - withKnot(newKnot) { - assert(between(newKnot, this.tMin, this.tMax)); - const k = this.tInterval(newKnot); - const { knots, points, degree } = this; - const insertPoints = arrayFromFunction(this.degree, (j) => { - const i = k - degree + 1 + j; - const aiNumerator = newKnot - knots[i]; - // 0/0 defined as 0: - const ai = aiNumerator == 0 ? 0 : aiNumerator / (knots[i + degree] - knots[i]); - assert(between(ai, 0, 1)); - return Vector.lerp(points[i - 1], points[i], ai); - }); - const newPoints = points.slice(); - newPoints.splice(k - degree + 1, degree - 1, ...insertPoints); - const newKnots = knots.slice(); - newKnots.splice(k + 1, 0, newKnot); - return new NURBS(newPoints, degree, newKnots, this.tMin, this.tMax); - } - removeKnot(t) { - const { knots, points, degree } = this; - let k = this.tInterval(t), s = 0; // s = multiplicity of the knot - while (knots[k + 1] == t) { - k++; - s++; - } - if (s == 0) - throw new Error("There is no knot " + t + "!"); - // the points which were relevant when inserting were (k - p - 1) to (k - 1). (- 1) because the current k has - // been increased by one due to the insertion. - // p - 1 points were replaced by p points, hence we need to generate the original p - 1 point, + 1 to check if - // this transformation is valid. - const insertPoints = [points[k - degree - 1]]; - const oldKnots = knots.slice(); - oldKnots.splice(k, 1); - for (let i = k - degree; i <= k - s; i++) { - const alphaInv = (oldKnots[i + degree] - oldKnots[i]) / (t - oldKnots[i]); - const oldPoint = Vector.lerp(getLast(insertPoints), points[i], alphaInv); - insertPoints.push(oldPoint); - } - if (getLast(insertPoints).like(points[k + 1 - s])) { - const oldPoints = points.slice(); - oldPoints.splice(k - degree - 1, degree - s + 3, ...insertPoints); - return new NURBS(oldPoints, degree, oldKnots); - } - return undefined; - } - static openUniformKnots(pointCount, degree, tMin = 0, tMax = 1) { - const knotsLength = pointCount + degree + 1; - return arrayFromFunction(knotsLength, (i) => { - if (i <= degree) { - return tMin; - } - else if (i >= knotsLength - degree - 1) { - return tMax; - } - else { - return lerp(tMin, tMax, (i - degree) / (knotsLength - degree * 2 - 1)); - } - }); - } - static bezierKnots(degree, tMin = 0, tMax = 1) { - const result = new Array((degree + 1) * 2); - for (let i = 0; i < degree + 1; i++) { - result[i] = tMin; - result[degree + 1 + i] = tMax; - } - return result; - } - static fromBezier(bezier) { - const bezier01 = bezier.selectPart(bezier.tMin, bezier.tMax); - return NURBS.Bezier(bezier01.points); - } - static Bezier(points, tMin = 0, tMax = 1) { - return new NURBS(points.map((p) => p instanceof V3 ? new Vector(new Float64Array([p.x, p.y, p.z, 1])) : p), points.length - 1, arrayFromFunction(points.length * 2, (i) => (i < points.length ? 0 : 1)), tMin, tMax); - } - static fromHyperbola(hyperbola, tMin = hyperbola.tMin, tMax = hyperbola.tMax) { - const p0 = HyperbolaCurve.XY.at(tMin); - const p2 = HyperbolaCurve.XY.at(tMax); - const p1 = new V3((sinh(tMin) - sinh(tMax)) / sinh(tMin - tMax), (cosh(tMin) - cosh(tMax)) / sinh(tMin - tMax), 0); - // M: midpoint between p0 and p2 - // X: intersection of line through p1 and M and unit hyperbola - // result.at(1/2) = X - // result.at(1/2) = (1/4 p0 + 1/2 p1 w + 1/4 p2) / (1/4 + 1/ 2 w + 1/4) - // result.at(1/2) = (1/2 p0 + p1 w + 1/2 p2) / (1 + w) - // result.at(1/2) = (M + p1 w) / (1 + w) = X - // => w * (p1 - X) = (X - M) - // as p1, X and M are all on the same line, we can solve this equation with only the x - const M = p0.lerp(p2, 0.5); - const Xx = 1 / sqrt(1 - Math.pow((M.y / M.x), 2)); - const w = (Xx - M.x) / (p1.x - Xx); - return NURBS.fromV3s([p0, p1, p2], 2, undefined, [1, w, 1]).transform(hyperbola.matrix); - } - static fromParabola(parabola) { - return NURBS.fromBezier(parabola.asBezier()); - } - static fromEllipse(ellipse) { - const unitSemiEllipse = new NURBS([ - VV(1, 0, 0, 1), - VV(1, 1, 0, 1).times(SQRT1_2), - VV(0, 1, 0, 1), - VV(-1, 1, 0, 1).times(SQRT1_2), - VV(-1, 0, 0, 1), - VV(-1, -1, 0, 1).times(SQRT1_2), - VV(0, -1, 0, 1), - ], 2, [0, 0, 0, PI / 2, PI / 2, PI, PI, (3 * PI) / 2, (3 * PI) / 2, 2 * PI]); - return unitSemiEllipse.transform(ellipse.matrix); - } - /** - * Create a new NURBS from V3s, with optional weights. - * @param points - * @param degree - * @param knots - * @param weights - */ - static fromV3s(points, degree, knots, weights = arrayFromFunction(points.length, () => 1)) { - assert(points.length == weights.length); - return new NURBS(points.map((p, i) => Vector.fromV3AndWeight(p, weights[i])), degree, knots); - } - isUniform(precision = 0) { - const intervals = arrayFromFunction(this.knots.length - 1, (i) => this.knots[i + 1] - this.knots[i]); - const [min, max] = minAndMax(intervals); - return eq(min, max, precision); - } - /** - * NURBS is a B spline if control points all have the same weight. - */ - isBSpline(precision = 0) { - const [minWeight, maxWeight] = minAndMax(this.points.map((p) => p.w)); - return eq(minWeight, maxWeight, precision); - } - /** - * Whether this is a (rational) bezier curve. - */ - isBezier(precision = 0) { - if (this.degree + 1 != this.points.length) - return false; - const [min0, max0] = minAndMax(this.knots, 0, this.degree + 1); - if (!eq(min0, max0, precision)) - return false; - const [min1, max1] = minAndMax(this.knots, this.degree + 1); - if (!eq(min1, max1, precision)) - return false; - return true; - } - /** - * Splits NURBS curve into rational bezier curves. - * See https://pages.mtu.edu/~shene/COURSES/cs3621/NOTES/spline/B-spline/subdivision.html - */ - getSegments() { - const { knots, points, degree } = this; - const result = []; - const v = Vector.pack(points, new Float64Array(points.length * 4)); - const vectorFromV = (i) => new Vector(v.slice(i * 4, (i + 1) * 4)); - let k = degree + 1; // k = knot index we are duplicating - while (k < knots.length - degree - 1) { - const t = knots[k]; - const prevKnot = knots[k - 1]; - let s = 1; // s = multiplicity of the knot - while (knots[k + 1] == t) { - k++; - s++; - } - const newNURBSPoints = new Array(degree + 1); - // the first s + 1 points are identical to the current curve - for (let i = 0; i < s + 1; i++) { - newNURBSPoints[i] = vectorFromV(k - degree - s + i); - } - // we need to have multiplicity degree, so insert (degree - s) times - for (let level = 1; level <= degree - s; level++) { - for (let i = k - degree; i <= k - s - level; i++) { - const alpha = (t - prevKnot) / (knots[i + degree + 1] - prevKnot); - for (let dim = 0; dim < 4; dim++) { - v[i * 4 + dim] = - (1 - alpha) * v[i * 4 + dim] + alpha * v[(i + 1) * 4 + dim]; - } - } - newNURBSPoints[s + level] = vectorFromV(k - degree); - } - const newNURBSKnots = arrayFromFunction((degree + 1) * 2, (i) => i < degree + 1 ? knots[k - s] : t); - result.push(new NURBS(newNURBSPoints, degree, newNURBSKnots)); - k++; - } - // last curve - const newNURBSPoints = arrayFromFunction(degree + 1, (i) => vectorFromV(points.length - degree - 1 + i)); - const newNURBSKnots = arrayFromFunction((degree + 1) * 2, (i) => i < degree + 1 ? knots[k - 1] : knots[k]); - result.push(new NURBS(newNURBSPoints, degree, newNURBSKnots)); - return result; - } - split(t) { - const { knots, points, degree } = this; - assert(le(this.tMin, t) && le(t, this.tMax)); - let k = this.tInterval(t), s = 0; // s = multiplicity of the knot - while (knots[k + 1] == t) { - k++; - s++; - } - const vectorFromV = (i) => new Vector(v.slice(i * 4, (i + 1) * 4)); - const leftPoints = new Array(k + 1 - s); - // the first k + s + 1 points are identical to the current curve - for (let i = 0; i < k + s - degree + 1; i++) { - leftPoints[i] = this.points[i]; - } - const rightPointsLength = points.length - (k - degree); - const v = Vector.pack(points, new Float64Array(rightPointsLength * 4), k - degree); - // we need to have multiplicity degree, so insert (degree - s) times - for (let level = 1; level <= degree - s; level++) { - for (let i = k - degree; i <= k - s - level; i++) { - const alpha = (t - knots[i + level]) / (knots[i + degree + 1] - knots[i + level]); - const j = i - (k - degree); - for (let dim = 0; dim < 4; dim++) { - v[j * 4 + dim] = - (1 - alpha) * v[j * 4 + dim] + alpha * v[(j + 1) * 4 + dim]; - } - } - leftPoints[k - degree + level] = vectorFromV(0); - } - const leftKnots = knots.slice(0, k + degree + 2 - s); - for (let i = 0; i < degree - s + 1; i++) { - leftKnots[k - s + 1 + i] = t; - } - const rightKnots = knots.slice(k - degree); - for (let i = 0; i < degree + 1; i++) { - rightKnots[i] = t; - } - const rightPoints = arrayFromFunction(rightPointsLength, (i) => vArrGet(v, 4, i)); - return [ - new NURBS(leftPoints, degree, leftKnots), - new NURBS(rightPoints, degree, rightKnots), - ]; - } - simplify() { - assert(this.isBezier()); - if (3 == this.degree && this.isBSpline()) { - return new BezierCurve(this.points[0].p3(), this.points[1].p3(), this.points[2].p3(), this.points[3].p3(), this.tMin, this.tMax); - } - else if (2 == this.degree) { - const [P0, P1, P2] = this.points; - const [p0, p1, p2] = this.points.map((p) => p.p3()); - const c = NURBS.simplifyUnit2(P0.w, P1.w, P2.w).transform(M4.forSys(p1.to(p0), p1.to(p2), undefined, p1)); - const [tMin, tMax] = [c.pointT(p0), c.pointT(p2)].sort(); - return c.withBounds(snap(tMin, c.tMin), snap(tMax, c.tMax)); - } - else if (1 == this.degree) { - return L3.throughPoints(this.points[0].p3(), this.points[1].p3()); - } - else { - return this; - } - } - static simplifyUnit2(w0, w1, w2) { - // see https://math.stackexchange.com/a/2794874/230980 - const delta = w0 * w2 - Math.pow(w1, 2); - const cxy = (w0 * w2) / 2 / delta; - const center = new V3(cxy, cxy, 0); - const k = (Math.pow(w1, 2) + delta - 2 * w1 * sqrt(abs(delta))) / 2 / delta; - const p = V3.X; - const q = new V3(k, cxy, 0); - // const q = new V3(cxy, k, 0) - if (eq0(delta)) { - return new ParabolaCurve(new V3(1 / 4, 1 / 4, 0), new V3(1, -1, 0), new V3(1, 1, 0), -0.5, 0.5); - } - else if (delta < 0) { - // hyperbola - return new HyperbolaCurve(center, center.to(p), center.to(q)); - } - else { - // ellipse - return new EllipseCurve(center, center.to(p), center.to(q), 0); - } - } - elevateDegreeBezier() { - assert(this.isBezier()); - const newPoints = new Array(this.points.length + 1); - newPoints[0] = this.points[0]; - newPoints[this.points.length] = this.points[this.points.length - 1]; - for (let i = 1; i < this.points.length; i++) { - newPoints[i] = Vector.lerp(this.points[i], this.points[i - 1], i / (this.degree + 1)); - } - const newKnots = NURBS.bezierKnots(this.degree + 1, this.knots[0], this.knots[this.degree + 1]); - return new NURBS(newPoints, this.degree + 1, newKnots, this.tMin, this.tMax); - } - elevateDegree() { - const segmentsElevated = this.getSegments().map((b) => b.elevateDegreeBezier()); - // stitch together the segments - const newPoints = new Array(2 + segmentsElevated.length * this.degree); - newPoints[0] = segmentsElevated[0].points[0]; - setLast(newPoints, getLast(getLast(segmentsElevated).points)); - for (let i = 0; i < segmentsElevated.length; i++) { - for (let pi = 1; pi < segmentsElevated[i].points.length - 1; pi++) { - newPoints[i * (segmentsElevated[0].points.length - 2) + pi] = - segmentsElevated[i].points[pi]; - } - } - const newKnots = new Array(newPoints.length + this.degree + 2); - for (let i = 0; i < this.degree + 2; i++) { - newKnots[i] = this.knots[0]; - } - for (let i = 0; i < segmentsElevated.length; i++) { - for (let pi = 1; pi < segmentsElevated[i].points.length - 1; pi++) { - newKnots[i * (segmentsElevated[0].points.length - 2) + pi + this.degree + 1] = getLast(segmentsElevated[i].knots); - } - } - newKnots[newKnots.length - 1] = getLast(this.knots); - newKnots[newKnots.length - 2] = getLast(this.knots); - let result = new NURBS(newPoints, this.degree + 1, newKnots, this.tMin, this.tMax); - for (let i = 0; i < segmentsElevated.length - 1; i++) { - let optimization; - while ((optimization = result.removeKnot(getLast(segmentsElevated[i].knots)))) { - result = optimization; - } - } - return result; - } - transform(m4) { - return this.transform4(m4); - } - transform4(m4) { - return new NURBS(this.points.map((p) => m4.timesVector(p)), this.degree, this.knots, this.tMin, this.tMax); - } - /** - * Returns the index of the interval which contains the value t. - */ - tInterval(t) { - const { degree, knots } = this; - for (let s = degree; s < knots.length - 1 - degree; s++) { - if (t >= knots[s] && t <= knots[s + 1]) { - return s; - } - } - throw new Error(t + " " + knots); - } - static UnitCircle(sections = 2, tMin = 0, tMax = PI) { - const dt = tMax - tMin; - const tStep = dt / sections; - const w = sin(PI / 2 - tStep / 2); - // cos - const r = 1 / cos(tStep / 2); - const points = arrayFromFunction(sections * 2 + 1, (i) => { - const t = lerp(tMin, tMax, i / 2 / sections); - if (i % 2 == 0) { - // control point on circle - return VV(cos(t), sin(t), 0, 1); - } - else { - return VV(r * w * cos(t), r * w * sin(t), 0, w); - } - }); - const knots = []; - knots.push(tMin, tMin, tMin); - for (let i = 0; i < sections - 1; i++) { - const knot = lerp(tMin, tMax, (i + 1) / sections); - knots.push(knot, knot); - } - knots.push(tMax, tMax, tMax); - return new NURBS(points, 2, knots); - } - debugInfo() { - return { - points: [ - ...this.knots.slice(this.degree, -this.degree).map((t) => this.at(t)), - ...this.points.map((p) => p.p3()), - ], - lines: this.points.flatMap((p, i, ps) => ps[i + 1] ? [p.p3(), ps[i + 1].p3()] : []), - }; - } - isTsWithPlane(planeWC) { - const { knots, degree, points } = this; - const controlPointTs = [ - knots[degree], - ...points - .slice(1, -1) - .map((p, i) => this.closestTToPoint(p.p3(), undefined, knots[i + 3], knots[i + degree])), - knots[knots.length - degree - 1], - ]; - const result = []; - for (let i = 0; i < this.points.length - 1; i++) { - const findClosest = (startT) => { - console.log("startT", startT); - // try { - const f = (t) => { - const [p, dt] = this.ptDtDdt(t); - return [planeWC.distanceToPointSigned(p), planeWC.normal1.dot(dt)]; - }; - let t = newtonIterateWithDerivative2(f, startT, 8, this.tMin, this.tMax); - let [distanceAtT, distanceDtAtT] = undefined === t ? [undefined, undefined] : f(t); - if (t === undefined || !eq0(distanceAtT) || eq0(distanceDtAtT)) { - t = newtonIterateWithDerivative2((t) => { - const [, dt, ddt] = this.ptDtDdt(t); - return [planeWC.normal1.dot(dt), planeWC.normal1.dot(ddt)]; - }, startT, 8, this.tMin, this.tMax); - } - [distanceAtT, distanceDtAtT] = undefined === t ? [] : f(t); - if (undefined !== t && - eq0(distanceAtT) && - !result.some((r) => eq(r, t))) { - result.push(t); - } - }; - const a = this.points[i].p3(); - const b = this.points[i + 1].p3(); - const ad = snap0(planeWC.distanceToPointSigned(a)); - const bd = snap0(planeWC.distanceToPointSigned(b)); - if (ad * bd < 0) { - const startT = lerp(controlPointTs[i], controlPointTs[i + 1], ad / (ad - bd)); - findClosest(startT); - } - else if (0 == bd) { - findClosest(this.closestTToPoint(b, controlPointTs[i + 1])); - } - } - return result; - } - isInfosWithCurve(curveWC) { - if (curveWC instanceof L3) { - return this.isInfosWithLine(curveWC.anchor, curveWC.dir1); - } - return super.isInfosWithCurve(curveWC); - } - isInfosWithLine(anchor, dir) { - const thisPlane = P3.fromPoints(this.points.map((p) => p.p3())); - const l = L3.anchorDirection(anchor, dir); - const maxDistanceToPlane = max$1(this.points.map((p) => thisPlane.distanceToPoint(p.p3()))); - const thisIsPlanar = eq0(maxDistanceToPlane); - if (thisIsPlanar && !thisPlane.containsLine(l)) { - const [t] = l.isTsWithPlane(thisPlane); - if (undefined === t) - return []; - const p = l.at(t); - return this.containsPoint(p) - ? [{ tThis: this.pointT(p), tOther: L3.pointT(anchor, dir, p), p }] - : []; - } - else { - const thisTs = this.isTsWithPlane(P3.normalOnAnchor(thisPlane.normal1.cross(dir), anchor)); - const infos = thisTs.map((tThis) => { - const p = this.at(tThis); - return { tThis, tOther: L3.pointT(anchor, dir, p), p }; - }); - return thisIsPlanar - ? infos - : infos.filter((info) => L3.containsPoint(anchor, dir, info.p)); - } - } - roots() { - console.log(this.tMin, this.tMax); - arraySamples(this.tMin, this.tMax, 30).forEach((t) => { - console.log(t + "," + this.tangentAt(t).z); - }); - const result = [[], [], []]; - for (let i = 0; i < this.points.length - 1; i++) { - const findClosest = (startT, d) => { - console.log("d", d, "startT", startT); - // try { - const root = newtonIterateWithDerivative2((t) => { - const [, dt, ddt] = this.ptDtDdt(t); - return [dt.e(d), ddt.e(d)]; - }, startT, 8, this.tMin, this.tMax); - if (undefined !== root) { - result[d].push(root); - } - console.log("d", d, "startT", startT, "root", root); - }; - const a = this.points[i].p3(); - const b = this.points[i + 1].p3(); - const ab = a.to(b); - for (let d = 0; d < 3; d++) { - if (0 !== i && eq0(ab.e(d))) { - const startT = lerp(this.knots[i], this.knots[i + this.degree + 2], 0.5); - findClosest(startT, d); - } - else if (i < this.points.length - 2) { - const bc = b.to(this.points[i + 2].p3()); - if (!eq0(bc.e(d)) && ab.e(d) * bc.e(d) < 0) { - findClosest(this.closestTToPoint(b, this.guessTClosestToControlPoint(i + 1)), d); - } - } - } - } - console.log(result); - return result; - } - //getAABB() { - // return new AABB().addPoints(this.points.map(p => p.p3())) - //} - /** - * Rough approximation of t param for points closest to control point. - */ - guessTClosestToControlPoint(pointIndex) { - return lerp(this.knots[pointIndex], this.knots[pointIndex + this.degree + 1], 0.5); - } - likeCurve(curve) { - return (this == curve || - (hasConstructor(curve, NURBS) && - this.degree === curve.degree && - this.points.every((p, i) => p.like(curve.points[i])) && - this.knots.every((k, i) => eq(k, curve.knots[i])))); - } - isColinearTo(curve) { - throw new Error("This doesn't even make sense."); - } -} -NURBS.EX2D = NURBS.fromV3s([ - V(51, 141), - V(11, 76), - V(29, 32), - V(46, 102), - V(74, 148), - V(189, 107), - V(56, 10), - V(206, 10), - V(211, 98), - V(195, 141), - V(139, 148), -], 4); -NURBS.EX3D = new NURBS([ - VV(94, 0, -34, 1), - VV(69, 57, 45, 0.5), - VV(-20, 44, 91, 1), - VV(-89, -13, 47, 0.5), - VV(-56, -97, -7, 1), - VV(34, -83, -54, 0.5), - VV(112, -53, 16, 1), - VV(79, 30, 70, 0.5), - VV(-2, -9, 141, 1), - VV(-80, -40, 72, 0.5), - VV(-38, -150, 43, 1), - VV(43, -110, -29, 0.5), - VV(130, -106, 65, 1), -], 2, [-12, -12, -12, -8, -8, -4, -4, 0, 0, 4, 4, 8, 8, 12, 12, 12]); -NURBS.prototype.tIncrement = 1 / 128; -function minAndMax(arr, start = 0, end = arr.length) { - let min = Infinity, max = -Infinity; - for (let i = start; i < end; i++) { - if (min > arr[i]) - min = arr[i]; - if (max < arr[i]) - max = arr[i]; - } - return [min, max]; -} - -/** - * Plane x DOT this.normal1 = this.w - */ -class P3 extends Transformable { - /** - * Oriented plane, i.e. splits R^3 in half, with one half being "in front" of the plane. - * Leads to multiple comparisons: isCoplanarToPlane returns if the plane occupies the same space, - * like returns if the plane occupies the same space and has the same orientation - * - * Points x on the plane fulfill the equation: normal1 DOT x = w - * - * @param normal1 unit plane normal1 - * @param w signed (rel to normal1) distance from the origin - */ - constructor(normal1, w = 0) { - super(); - this.normal1 = normal1; - this.w = w; - assertVectors(normal1); - assertNumbers(w); - assert(normal1.hasLength(1), "normal1.hasLength(1)" + normal1); - } - get anchor() { - return this.normal1.times(this.w); - } - static throughPoints(a, b, c) { - assertVectors(a, b, c); - const n1 = b.minus(a).cross(c.minus(a)).unit(); - return new P3(n1, n1.dot(a)); - } - static normalOnAnchor(normal, anchor) { - assertVectors(normal, anchor); - const n1 = normal.unit(); - return new this(n1, n1.dot(anchor)); - } - /** - * Create a plane which intersects the X, Y and Z axes at the specified offsets. - * x/x0 + y/y0 + y/y0 = 1 - */ - static forAxisIntercepts(x0, y0, z0) { - assertNumbers(x0, y0, z0); - const normal = new V3(1 / x0, 1 / y0, 1 / z0); - return new P3(normal.unit(), normal.length()); - } - /** - * Create a plane containing `anchor` and extending in directions `v0` and `v1`. - * `v0` and `v1` may not be parallel. - * @param anchor - * @param v0 - * @param v1 - */ - static forAnchorAndPlaneVectors(anchor, v0, v1) { - assertVectors(anchor, v0, v1); - assert(!v0.isParallelTo(v1)); - return this.normalOnAnchor(v0.cross(v1), anchor); - } - /** - * Create a plane which contains botha point and a line. The point may not lie on the line. - * @param p - * @param line - */ - static forPointAndLine(p, line) { - return this.forAnchorAndPlaneVectors(line.anchor, line.dir1, line.anchor.to(p)); - } - /** - * ax + by + cz + d = 0 - */ - static forABCD(a, b, c, d) { - const normalLength = Math.hypot(a, b, c); - if (eq0(normalLength)) - return undefined; - return new P3(new V3(a / normalLength, b / normalLength, c / normalLength), -d / normalLength); - } - static vanishingPlane(m4) { - return P3.forABCD(m4.m[12], m4.m[13], m4.m[14], m4.m[15]); - } - static forAABB(aabb, distance = 0) { - return [ - new P3(V3.X, aabb.max.x + distance), - new P3(V3.X.negated(), -aabb.min.x - distance), - new P3(V3.Y, aabb.max.y + distance), - new P3(V3.Y.negated(), -aabb.min.y - distance), - new P3(V3.Z, aabb.max.z + distance), - new P3(V3.Z.negated(), -aabb.min.z - distance), - ]; - } - // Fit a plane to a collection of points. - // Fast, and accurate to within a few degrees. - // Returns None if the points do not span a plane. - static fromPoints(points) { - const n = points.length; - if (n < 3) { - return undefined; - } - const centroid = V3.add(...points).div(n); - // Calculate full 3x3 covariance matrix, excluding symmetries: - let xx = 0.0; - let xy = 0.0; - let xz = 0.0; - let yy = 0.0; - let yz = 0.0; - let zz = 0.0; - for (const p of points) { - const r = p.minus(centroid); - xx += r.x * r.x; - xy += r.x * r.y; - xz += r.x * r.z; - yy += r.y * r.y; - yz += r.y * r.z; - zz += r.z * r.z; - } - xx /= n; - xy /= n; - xz /= n; - yy /= n; - yz /= n; - zz /= n; - let weighted_dir = V3.O; - { - const det_x = yy * zz - yz * yz; - const axis_dir = new V3(det_x, xz * yz - xy * zz, xy * yz - xz * yy); - let weight = det_x * det_x; - if (weighted_dir.dot(axis_dir) < 0.0) { - weight = -weight; - } - weighted_dir = weighted_dir.plus(axis_dir.times(weight)); - } - { - const det_y = xx * zz - xz * xz; - const axis_dir = new V3(xz * yz - xy * zz, det_y, xy * xz - yz * xx); - let weight = det_y * det_y; - if (weighted_dir.dot(axis_dir) < 0.0) { - weight = -weight; - } - weighted_dir = weighted_dir.plus(axis_dir.times(weight)); - } - { - const det_z = xx * yy - xy * xy; - const axis_dir = new V3(xy * yz - xz * yy, xy * xz - yz * xx, det_z); - let weight = det_z * det_z; - if (weighted_dir.dot(axis_dir) < 0.0) { - weight = -weight; - } - weighted_dir = weighted_dir.plus(axis_dir.times(weight)); - } - const normal = weighted_dir.unit(); - return P3.normalOnAnchor(normal, centroid); - } - axisIntercepts() { - const w = this.w, n = this.normal1; - return new V3(w / n.x, w / n.y, w / n.z); - } - isCoplanarToPlane(plane) { - assertInst(P3, plane); - return this.like(plane) || this.likeFlipped(plane); - } - like(plane) { - assertInst(P3, plane); - return eq(this.w, plane.w) && this.normal1.like(plane.normal1); - } - likeFlipped(plane) { - assertInst(P3, plane); - return eq(this.w, -plane.w) && this.normal1.like(plane.normal1.negated()); - } - /** - * True iff plane.normal1 is equal to this.normal1 or it's negation. - * - */ - isParallelToPlane(plane) { - assertInst(P3, plane); - return eq(1, Math.abs(this.normal1.dot(plane.normal1))); - } - isParallelToLine(line) { - assertInst(L3$1, line); - return eq0(this.normal1.dot(line.dir1)); - } - isPerpendicularToLine(line) { - assertInst(L3$1, line); - // this.normal1 || line.dir1 - return eq(1, Math.abs(this.normal1.dot(line.dir1))); - } - isPerpendicularToPlane(plane) { - assertInst(P3, plane); - return eq0(this.normal1.dot(plane.normal1)); - } - toSource() { - return callsce("new P3", this.normal1, this.w); - } - translated(offset) { - return new P3(this.normal1, this.w + offset.dot(this.normal1)); - } - transform(m4) { - // See https://stackoverflow.com/questions/7685495/transforming-a-3d-plane-using-a-4x4-matrix - // See http://www.songho.ca/opengl/gl_normaltransform.html - // with homogeneous coordinates, the hessian normal form of this plane is - // (p, 1) * (normal1, -w) = 0 - // transformation: (m4^-1 * (p, 1)) DOT (normal1, -w) = 0 - // => (p, 1) DOT ((m4^-T) * (normal1, -w)) = 0 - // (validity of the above transformation is easily seen by expanding the matrix multiplication and dot product) - // hence, (newNormal, newW) = (m4^-T) * (normal1, -w) - // we divide both newNormal and newW by newNormal.length() to normalize the normal vector - const m4InversedTransposed = M4.transpose(M4.inverse(m4, M4.temp0), M4.temp1); - const [nx, ny, nz] = this.normal1; - const newNormal = m4InversedTransposed.timesVector(VV(nx, ny, nz, -this.w)); - return P3.forABCD(newNormal.x, newNormal.y, newNormal.z, newNormal.w); - } - distanceToLine(line) { - assertInst(L3$1, line); - if (!this.isParallelToLine(line)) { - return this.distanceToPoint(line.anchor); - } - else { - return 0; - } - } - containsPoint(x) { - assertVectors(x); - return eq(this.w, this.normal1.dot(x)); - } - containsLine(line) { - assertInst(L3$1, line); - return this.containsPoint(line.anchor) && this.isParallelToLine(line); - } - distanceToPointSigned(point) { - assertInst(V3, point); - return this.normal1.dot(point) - this.w; - } - distanceToPoint(point) { - assertInst(V3, point); - return Math.abs(this.normal1.dot(point) - this.w); - } - intersectionWithLine(line) { - return line.intersectionWithPlane(this); - } - intersectionWithPlane(plane) { - assertInst(P3, plane); - /* - - this: n0 * x = w0 - plane: n1 * x = w1 - plane perpendicular to both which goes through origin: - n2 := n0 X x1 - n2 * x = 0 - */ - if (this.isParallelToPlane(plane)) { - return undefined; - } - /* - var n0 = this.normal1, n1 = plane.normal1, n2 = n0.cross(n1).unit(), m = M4.forSys(n0, n1, n2) - var x0 = this.anchor, x1 = plane.anchor, x2 = V3.O - var p = n2.times(x2.dot(n2)) - .plus(n1.cross(n2).times(x0.dot(n0))) - .plus(n2.cross(n0).times(x1.dot(n1))) - .div(m.determinant()) - */ - const n0 = this.normal1, n1 = plane.normal1, n2 = n0.cross(n1).unit(); - const p = M4.forRows(n0, n1, n2) - .inversed() - .transformVector(new V3(this.w, plane.w, 0)); - return new L3$1(p, n2); - } - /** - * Returns the point in the plane closest to the given point - * - */ - projectedPoint(x) { - // See http://math.stackexchange.com/questions/444968/project-a-point-in-3d-on-a-given-plane - // p = x - ((x - planeAnchor) * normal1) * normal1 - return x.minus(this.normal1.times(x.minus(this.anchor).dot(this.normal1))); - } - projectedVector(x) { - // See V3.rejectedFrom. Simplified, as this.normal1.length() == 1 - return x.minus(this.normal1.times(x.dot(this.normal1))); - } - flipped() { - return new P3(this.normal1.negated(), -this.w); - } - containsCurve(curve) { - if (curve instanceof L3$1) { - return this.containsLine(curve); - } - else if (curve instanceof EllipseCurve$1 || - curve instanceof HyperbolaCurve$1 || - curve instanceof ParabolaCurve$1) { - return (this.containsPoint(curve.center) && - this.normal1.isParallelTo(curve.normal)); - } - else if (curve instanceof BezierCurve$1) { - return curve.points.every((p) => this.containsPoint(p)); - } - else { - throw new Error("" + curve); - } - } - equals(obj) { - return (hasConstructor(obj, P3) && - this.normal1.equals(obj.normal1) && - this.w == obj.w); - } - hashCode() { - return (this.normal1.hashCode() * 31) | (0 + floatHashCode(this.w)); - } -} -P3.YZ = new P3(V3.X, 0); -P3.ZX = new P3(V3.Y, 0); -P3.XY = new P3(V3.Z, 0); - -class Surface extends Transformable { - static loopContainsPointGeneral(loop, pWC, testLine, lineOut) { - const testPlane = P3$1.normalOnAnchor(lineOut, pWC); - // edges colinear to the testing line; these will always be counted as "inside" relative to the testing line - const colinearEdges = loop.map((edge) => edge.colinearToLine(testLine)); - let inside = false; - function logIS(isP) { - const isT = testLine.pointT(isP); - if (eq0(isT)) { - return true; - } - else if (isT > 0) { - inside = !inside; - } - return false; - } - for (let edgeIndex = 0; edgeIndex < loop.length; edgeIndex++) { - const edge = loop[edgeIndex]; - const nextEdgeIndex = (edgeIndex + 1) % loop.length, nextEdge = loop[nextEdgeIndex]; - //console.log(edge.toSource()) {p:V(2, -2.102, 0), - if (colinearEdges[edgeIndex]) { - const lineAT = testLine.pointT(edge.a), lineBT = testLine.pointT(edge.b); - if (Math.min(lineAT, lineBT) <= NLA_PRECISION && - -NLA_PRECISION <= Math.max(lineAT, lineBT)) { - return PointVsFace.ON_EDGE; - } - // edge colinear to intersection - const nextInside = colinearEdges[nextEdgeIndex] || - dotCurve2$1(nextEdge.curve, nextEdge.aT, lineOut, sign(nextEdge.deltaT())) < 0; - if (!nextInside) { - if (logIS(edge.b)) - return PointVsFace.ON_EDGE; - } - } - else { - for (const edgeT of edge.edgeISTsWithPlane(testPlane)) { - if (edgeT == edge.bT) { - if (!testLine.containsPoint(edge.b)) - continue; - // endpoint lies on intersection line - if (edge.b.like(pWC)) { - // TODO: refactor, dont check for different sides, just logIs everything - return PointVsFace.ON_EDGE; - } - const edgeInside = dotCurve2$1(edge.curve, edge.bT, lineOut, -sign(edge.deltaT())) < 0; - const nextInside = colinearEdges[nextEdgeIndex] || - dotCurve2$1(nextEdge.curve, nextEdge.aT, lineOut, sign(nextEdge.deltaT())) < 0; - if (edgeInside != nextInside) { - if (logIS(edge.b)) - return PointVsFace.ON_EDGE; - } - } - else if (edgeT != edge.aT) { - const p = edge.curve.at(edgeT); - if (!testLine.containsPoint(p)) - continue; - // edge crosses line, neither starts nor ends on it - if (logIS(p)) - return PointVsFace.ON_EDGE; - // TODO: tangents? - } - } - } - } - return inside ? PointVsFace.INSIDE : PointVsFace.OUTSIDE; - } - static loopContainsPointEllipse(loop, pWC, testLine, pWCT) { - const lineOut = testLine.normal; - const testPlane = P3$1.normalOnAnchor(testLine.normal, pWC); - const colinearEdges = loop.map((edge) => testLine.isColinearTo(edge.curve)); - let inside = false; - if (undefined === pWCT) { - pWCT = testLine.pointT(pWC); - } - const pT = pWCT; - function logIS(isP) { - const isT = testLine.pointT(isP); - if (eq(pT, isT)) { - return true; - } - else if (pT < isT && le(isT, PI)) { - inside = !inside; - } - return false; - } - for (let edgeIndex = 0; edgeIndex < loop.length; edgeIndex++) { - const edge = loop[edgeIndex]; - const nextEdgeIndex = (edgeIndex + 1) % loop.length, nextEdge = loop[nextEdgeIndex]; - //console.log(edge.toSource()) {p:V(2, -2.102, 0), - if (colinearEdges[edgeIndex]) { - let edgeT; - if (edge.curve.containsPoint(pWC) && - le(edge.minT, (edgeT = edge.curve.pointT(pWC))) && - le(edgeT, edge.maxT)) { - return PointVsFace.ON_EDGE; - } - // edge colinear to intersection - const nextInside = colinearEdges[nextEdgeIndex] || - dotCurve2$1(nextEdge.curve, nextEdge.aT, lineOut, sign(nextEdge.deltaT())) < 0; - if (!nextInside && testLine.containsPoint(edge.b)) { - if (logIS(edge.b)) - return PointVsFace.ON_EDGE; - } - } - else { - for (const edgeT of edge.edgeISTsWithPlane(testPlane)) { - if (edgeT == edge.bT) { - if (!testLine.containsPoint(edge.b)) - continue; - // endpoint lies on intersection testLine - const edgeInside = dotCurve2$1(edge.curve, edge.bT, lineOut, -sign(edge.deltaT())) < 0; - const nextInside = colinearEdges[nextEdgeIndex] || - dotCurve2$1(nextEdge.curve, nextEdge.aT, lineOut, sign(nextEdge.deltaT())) < 0; - if (edgeInside != nextInside) { - if (logIS(edge.b)) - return PointVsFace.ON_EDGE; - } - } - else if (edgeT != edge.aT) { - const p = edge.curve.at(edgeT); - if (!testLine.containsPoint(p)) - continue; - // edge crosses testLine, neither starts nor ends on it - if (logIS(p)) - return PointVsFace.ON_EDGE; - // TODO: tangents? - } - } - } - } - return inside ? PointVsFace.INSIDE : PointVsFace.OUTSIDE; - } - toString() { - return this.toSource(); - } - toSource(rounder = (x) => x) { - return callsce.call(undefined, "new " + this.constructor.name, ...this.getConstructorParameters()); - } - /** - * Return points which would touch AABB. Doesnt include borders due to parametric bounds, for example. - */ - getExtremePoints() { - return []; - } - isCurvesWithSurface(surface) { - return surface.isCurvesWithSurface(this); //.map(curve => curve.reversed()) - } - containsCurve(curve) { - if (curve instanceof PPCurve$1) { - if (this.equals(curve.parametricSurface1) || - this.equals(curve.parametricSurface2)) { - return true; - } - } - if (curve instanceof ImplicitCurve$1) { - for (let i = ceil(curve.tMin) + 1; i <= floor(curve.tMax) - 1; i++) { - if (!this.containsPoint(curve.points[i])) { - return false; - } - } - return true; - } - return false; - } - flipped2(doFlip) { - return doFlip ? this.flipped() : this; - } - clipCurves(curves) { - return curves; - } - equals(obj) { - return (this === obj || - (this.constructor === obj.constructor && - arrayEquals(this.getConstructorParameters(), obj.getConstructorParameters()))); - } - hashCode() { - return arrayHashCode(this.getConstructorParameters()); - } - zDirVolume(allEdges) { - return this.visit(ZDirVolumeVisitor$1, allEdges); - } - calculateArea(allEdges) { - return this.visit(CalculateAreaVisitor$1, allEdges); - } -} -var PointVsFace; -(function (PointVsFace) { - PointVsFace[PointVsFace["INSIDE"] = 0] = "INSIDE"; - PointVsFace[PointVsFace["OUTSIDE"] = 1] = "OUTSIDE"; - PointVsFace[PointVsFace["ON_EDGE"] = 2] = "ON_EDGE"; -})(PointVsFace || (PointVsFace = {})); - -class ParametricSurface extends Surface$1 { - constructor(uMin, uMax, vMin, vMax) { - super(); - this.uMin = uMin; - this.uMax = uMax; - this.vMin = vMin; - this.vMax = vMax; - assertNumbers(uMin, uMax, vMin, vMax); - assert(uMin < uMax); - assert(vMin < vMax); - assert(emod(this.getConstructorParameters(), -4) == this.uMin, this.getConstructorParameters(), this.uMin); - } - static isCurvesParametricImplicitSurface(ps, is, uStep, vStep = uStep, curveStepSize) { - const pf = ps.pUVFunc(), icc = is.implicitFunction(); - const dpdu = ps.dpdu(); - const dpdv = ps.dpdv(); - const didp = is.didp.bind(is); - const ist = (x, y) => icc(pf(x, y)); - const didu = (u, v) => didp(pf(u, v)).dot(dpdu(u, v)); - const didv = (u, v) => didp(pf(u, v)).dot(dpdv(u, v)); - const mf = MathFunctionR2R$1.forFFxFy(ist, didu, didv); - const curves = Curve$1.breakDownIC(mf, ps, uStep, vStep, curveStepSize, (u, v) => is.containsPoint(pf(u, v))).map(({ points, tangents }, _i) => PICurve$1.forParametricPointsTangents(ps, is, points, tangents, curveStepSize)); - return curves; - } - static isCurvesParametricParametricSurface(ps1, ps2, s1Step, t1Step = s1Step, curveStepSize) { - return breakDownPPCurves$1(ps1, ps2, s1Step, t1Step, curveStepSize); - } - static is(obj) { - return obj.pUVFunc; - } - pUV(u, v) { - return this.pUVFunc()(u, v); - } - pUVFunc() { - return this.pUV.bind(this); - } - uvP(pWC) { - return this.uvPFunc()(pWC); - } - uvPFunc() { - return this.uvP.bind(this); - } - bounds(u, v) { - return this.uMin <= u && u <= this.uMax && this.vMin <= v && v <= this.vMax; - } - /** - * Positive values are inside bounds. - */ - boundsSigned(u, v) { - return min(u - this.uMin, this.uMax - u, v - this.vMin, this.vMax - v); - } - normalP(p) { - const pmPoint = this.uvPFunc()(p); - return this.normalUV(pmPoint.x, pmPoint.y); - } - normalUVFunc() { - return this.normalUV.bind(this); - } - normalUV(u, v) { - return this.normalUVFunc()(u, v); - } - parametersValid(u, v) { - return between(u, this.uMin, this.uMax) && between(v, this.vMin, this.vMax); - } - toMesh(uStep = this.uStep, vStep = this.vStep) { - assert(isFinite(this.vMin) && - isFinite(this.vMax) && - isFinite(this.uMin) && - isFinite(this.uMax)); - assert(isFinite(uStep) && isFinite(vStep)); - return Mesh.parametric(this.pUVFunc(), this.normalUVFunc(), this.uMin, this.uMax, this.vMin, this.vMax, ceil((this.uMax - this.uMin) / uStep), ceil((this.vMax - this.vMin) / vStep)); - } - isCurvesWithImplicitSurface(is, uStep, vStep, stepSize) { - return ParametricSurface.isCurvesParametricImplicitSurface(this, is, uStep, vStep, stepSize); - } - edgeLoopCCW(contour) { - const ptpF = this.uvPFunc(); - return isCCW(contour.flatMap((e) => e.getVerticesNo0()).map((v) => ptpF(v)), V3.Z); - } - like(object) { - if (!this.isCoplanarTo(object)) - return false; - // normals need to point in the same direction (outwards or inwards) for both - const pSMinTMin = this.pUVFunc()(this.uMin, this.vMin); - const thisNormal = this.normalUVFunc()(this.uMin, this.vMin); - const otherNormal = object.normalP(pSMinTMin); - return 0 < thisNormal.dot(otherNormal); - } - getApproxAABB() { - const result = new AABB(); - result.addPoints(this.getExtremePoints()); - const ps = [V(0, 0), V(0, 1), V(1, 0), V(1, 1), V(0.5, 0.5)].map((p) => this.pUV(lerp(this.uMin, this.uMax, p.x), lerp(this.vMin, this.vMax, p.y))); - result.addPoints(ps); - return result; - } -} - -class ConicSurface extends ParametricSurface$1 { - /** - * returns new cone C = {apex + f1 * v * cos(u) + f2 * v * sin(u) + f3 * v | - * -PI <= u <= PI, 0 <= v} - * - * If the coordinate system [f1 f2 dir] is right-handed, the normals will - * point outwards, otherwise inwards. - * - * @param f1 - * @param f2 - * @param dir Direction in which the cone opens. The ellipse spanned by f1, - * f2 is contained at (apex + dir). - */ - constructor(center, f1, f2, dir, uMin = 0, uMax = PI, vMin = 0, vMax = 16) { - super(uMin, uMax, vMin, vMax); - this.center = center; - this.f1 = f1; - this.f2 = f2; - this.dir = dir; - assertVectors(center, f1, f2, dir); - assert(-PI <= uMin && uMax <= PI); - assert(0 <= vMin, vMin); - this.matrix = M4.forSys(f1, f2, dir, center); - this.matrixInverse = this.matrix.inversed(); - this.normalDir = sign(this.f1.cross(this.f2).dot(this.dir)); - this.pLCNormalWCMatrix = this.matrix - .as3x3() - .inversed() - .transposed() - .scale(this.normalDir); - } - getConstructorParameters() { - return [ - this.center, - this.f1, - this.f2, - this.dir, - this.uMin, - this.uMax, - this.vMin, - this.vMax, - ]; - } - pointFoot(pWC, startU, startV) { - if (undefined === startU || undefined === startV) { - // similar to uvP - const pLC = this.matrixInverse.transformPoint(pWC); - const angle = pLC.angleXY(); - if (undefined === startU) { - startU = angle < -PI / 2 ? angle + TAU : angle; - } - if (undefined === startV) { - startV = pLC.z + (pLC.lengthXY() - pLC.z) * SQRT1_2; - } - } - const f = ([u, v]) => { - const pUVToPWC = this.pUV(u, v).to(pWC); - return [this.dpdu()(u, v).dot(pUVToPWC), this.dpdv()(u).dot(pUVToPWC)]; - }; - const { 0: x, 1: y } = newtonIterate(f, [startU, startV]); - return new V3(x, y, 0); - } - get apex() { - return this.center; - } - static atApexThroughEllipse(apex, ellipse, uMin, uMax, vMin, vMax) { - assertVectors(apex); - assertInst(EllipseCurve$2, ellipse); - return new ConicSurface(apex, ellipse.f1, ellipse.f2, apex.to(ellipse.center), uMin, uMax, vMin, vMax); - } - static unitISLineTs(anchor, dir) { - const { x: ax, y: ay, z: az } = anchor; - const { x: dx, y: dy, z: dz } = dir; - // this cone: x² + y² = z² - // line: p = anchor + t * dir1 - // split line equation into 3 component equations, insert into cone equation - // transform to form (a t² + b t + c = 0) and solve with pqFormula - const a = dx * dx + dy * dy - dz * dz; - const b = 2 * (ax * dx + ay * dy - az * dz); - const c = ax * ax + ay * ay - az * az; - // cone only defined for 0 <= z, so filter invalid values - return pqFormula(b / a, c / a).filter((t) => 0 < az + t * dz); - } - // calculate intersection of plane ax + cz = d and cone x² + y² = z² - static unitISPlane(a, c, d) { - if (eq0(c)) { - // plane is "vertical", i.e. parallel to Y and Z axes - assert(!eq0(a)); // normal would be zero, which is invalid - // z² - y² = d²/a² - if (eq0(d)) { - // d = 0 => z² - y² = 0 => z² = y² => z = y - // plane goes through origin/V3.O - return [ - new L3$2(V3.O, new V3(0, -SQRT1_2, -SQRT1_2), undefined, 0), - new L3$2(V3.O, new V3(0, -SQRT1_2, SQRT1_2), 0), - ]; - } - else { - // hyperbola - const center = new V3(d / a, 0, 0); - const f1 = new V3(0, 0, abs(d / a)); // abs, because we always want the - // hyperbola to be pointing up - const f2 = new V3(0, d / a, 0); - return [new HyperbolaCurve$2(center, f1, f2)]; - } - } - else { - // c != 0 - const aa = a * a, cc = c * c; - if (eq0(d)) { - // ax + cz = d => x = d - cz / a => x² = d² - 2cdz/a + c²z²/a² - // x² + y² = z² - // => d² - 2cdz/a + c²z²/a² + y² = z² - if (eq(aa, cc)) { - return [new L3$2(V3.O, new V3(c, 0, -a).unit())]; - } - else if (aa < cc) { - throw new Error("intersection is single point V3.O"); - } - else if (aa > cc) { - return [ - new L3$2(V3.O, new V3(c, sqrt(aa - cc), -a).unit()), - new L3$2(V3.O, new V3(c, -sqrt(aa - cc), -a).unit()), - ]; - } - } - else { - if (eq(aa, cc)) { - // parabola - const parabolaVertex = new V3(d / 2 / a, 0, d / 2 / c); - const parabolaVertexTangentPoint = new V3(d / 2 / a, d / c, d / 2 / c); - const p2 = new V3(0, 0, d / c); - const f2 = p2.minus(parabolaVertex); - return [ - new ParabolaCurve$2(parabolaVertex, parabolaVertexTangentPoint.minus(parabolaVertex), f2.z < 0 ? f2.negated() : f2), - ]; - } - else if (aa < cc) { - // ellipse - const center = new V3((-a * d) / (cc - aa), 0, (d * c) / (cc - aa)); - if (center.z < 0) { - return []; - } - const p1 = new V3(d / (a - c), 0, -d / (a - c)); - const p2 = new V3((-a * d) / (cc - aa), d / sqrt(cc - aa), (d * c) / (cc - aa)); - return [ - new EllipseCurve$2(center, center.to(p1), center.to(p2), -PI, PI), - ]; - } - else if (aa > cc) { - // hyperbola - const center = new V3((-a * d) / (cc - aa), 0, (d * c) / (cc - aa)); - // const p1 = new V3(d / (a - c), 0, -d / (a - c)) - // const p2 = new V3(-a * d / (cc - aa), d / sqrt(aa - cc), d * c / - // (cc - aa)) const f1 = center.to(p1) - const f1 = new V3((d * c) / (aa - cc), 0, (-d * a) / (aa - cc)); - const f2 = new V3(0, d / sqrt(aa - cc), 0); - return [new HyperbolaCurve$2(center, f1.z > 0 ? f1 : f1.negated(), f2)]; - } - } - } - throw new Error("???"); - } - equals(obj) { - return (this == obj || - (Object.getPrototypeOf(this) == Object.getPrototypeOf(obj) && - this.center.equals(obj.center) && - this.f1.equals(obj.f1) && - this.f2.equals(obj.f2) && - this.dir.equals(obj.dir))); - } - like(object) { - if (!this.isCoplanarTo(object)) - return false; - // normals need to point in the same direction (outwards or inwards) for - // both - return this.normalDir == object.normalDir; - } - getVectors() { - return [ - { anchor: this.center, dir1: this.dir }, - { anchor: this.center.plus(this.dir), dir1: this.f1 }, - { anchor: this.center.plus(this.dir), dir1: this.f2 }, - ]; - } - getSeamPlane() { - return P3$1.forAnchorAndPlaneVectors(this.center, this.f1, this.dir); - } - loopContainsPoint(contour, p) { - assertVectors(p); - const line = this.center.like(p) - ? new L3$2(p, this.matrix.transformVector(new V3(0, 1, 1)).unit()) - : L3$2.throughPoints(p, this.apex); - const lineOut = line.dir1.cross(this.dir); - return Surface$1.loopContainsPointGeneral(contour, p, line, lineOut); - } - isTsForLine(line) { - // transforming line manually has advantage that dir1 will not be - // renormalized, meaning that calculated values t for lineLC are directly - // transferable to line - const anchorLC = this.matrixInverse.transformPoint(line.anchor); - const dirLC = this.matrixInverse.transformVector(line.dir1); - return ConicSurface.unitISLineTs(anchorLC, dirLC); - } - /** - * Interestingly, two cones don't need to have parallel dirs to be coplanar. - */ - isCoplanarTo(surface) { - if (this === surface) - return true; - if (!(surface instanceof ConicSurface) || !this.apex.like(surface.apex)) - return false; - // at this point apexes are equal - return this.containsEllipse(new EllipseCurve$2(surface.center.plus(surface.dir), surface.f1, surface.f2)); - } - containsEllipse(ellipse) { - const ellipseLC = ellipse.transform(this.matrixInverse); - if (ellipseLC.center.z < 0) { - return false; - } - const { f1, f2 } = ellipseLC.rightAngled(); - const p1 = ellipseLC.center.plus(f1), p2 = ellipseLC.center.plus(f2); - // check if both endpoints are on the cone's surface - // and that one main axis is perpendicular to the Z-axis - return (eq(Math.pow(p1.x, 2) + Math.pow(p1.y, 2), Math.pow(p1.z, 2)) && - eq(Math.pow(p2.x, 2) + Math.pow(p2.y, 2), Math.pow(p2.z, 2)) && - (eq0(f1.z) || eq0(f2.z))); - } - containsLine(line) { - const lineLC = line.transform(this.matrixInverse); - const d = lineLC.dir1; - return lineLC.containsPoint(V3.O) && eq(d.x * d.x + d.y * d.y, d.z * d.z); - } - containsParabola(curve) { - assertInst(ParabolaCurve$2, curve); - const curveLC = curve.transform(this.matrixInverse); - if (curveLC.center.z < 0 || curveLC.f2.z < 0) { - return false; - } - const { center, f1, f2 } = curveLC.rightAngled(); - // check if center is on the surface, - // that tangent is perpendicular to the Z-axis - // and that "y" axis is parallel to surface - return (eq(center.x * center.x + center.y * center.y, center.z * center.z) && - eq0(f1.z) && - eq(f2.x * f2.x + f2.y * f2.y, f2.z * f2.z)); - } - containsHyperbola(curve) { - // calculate intersection of plane ax + cz = 1 and cone x² + y² = z² - // const center = new V3(-a / (cc - aa), 0, 1 / (cc - aa)) - // const p1 = new V3(1 / (a - c), 0, -1 / (a - c)) - // const p2 = new V3(-a / (cc - aa), 1 / sqrt(aa - cc), 1 / (cc - aa)) - // const f1 = new V3(1 * c / (aa - cc), 0, -a / (aa - cc) ) - // const f2 = new V3(0, 1 / sqrt(aa - cc), 0) - assertInst(HyperbolaCurve$2, curve); - const curveLC = curve.transform(this.matrixInverse).rightAngled(); - const centerXY = curveLC.center.xy(); - if (centerXY.likeO()) { - return false; - } - const rot = centerXY.angleXY(); - const { center, f1, f2 } = curveLC.rotateZ(-rot); - // s = a / (aa - cc) - // t = -c / (aa - cc) - // s + t = 1 / (a + c) - // s - t = 1 / (a - c) - // (s + t)(s - t) = (ss - tt) = 1 / (aa - cc) - // u = 1 / sqrt(aa - cc) = sqrt(ss - tt) - // check if center is on the surface, - // that tangent is perpendicular to the Z-axis - return (f1.z > 0 && - eq(center.x, f1.z) && - eq(center.z, f1.x) && - eq0(center.y) && - eq0(f1.y) && - eq(sqrt(abs(Math.pow(center.x, 2) - Math.pow(center.z, 2))), abs(f2.y)) && - eq0(f2.x) && - eq0(f2.z)); - } - containsCurve(curve) { - if (curve instanceof EllipseCurve$2) { - return this.containsEllipse(curve); - } - else if (curve instanceof L3$2) { - return this.containsLine(curve); - } - else if (curve instanceof HyperbolaCurve$2) { - return this.containsHyperbola(curve); - } - else if (curve instanceof ParabolaCurve$2) { - return this.containsParabola(curve); - } - else { - return super.containsCurve(curve); - } - } - transform(m4) { - return new ConicSurface(m4.transformPoint(this.center), m4.transformVector(this.f1).times(m4.isMirroring() ? -1 : 1), m4.transformVector(this.f2), m4.transformVector(this.dir), this.uMin, this.uMax, this.vMin, this.vMax); - } - transform4(m4) { - const transformedApex = m4.timesVector(Vector.fromV3AndWeight(this.center, 1)); - const isometricV = (z) => new EllipseCurve$2(new V3(0, 0, z), new V3(z, 0, 0), new V3(0, z, 0)); - if (!eq0(transformedApex.w)) { - // sMin doesn't change, but tMin does... - const c = m4.transformPoint(this.center), f1 = m4 - .transformVector2(this.f1, this.center) - .times(m4.isMirroring() ? -1 : 1), f2 = m4.transformVector2(this.f2, this.center), dir = m4.transformVector2(this.dir, this.center); - const matrixInv = M4.forSys(f1, f2, dir, c).inversed(); - const x = isometricV(this.vMin).transform4(matrixInv.times(m4).times(this.matrix)); - const y = isometricV(this.vMax).transform4(matrixInv.times(m4).times(this.matrix)); - const aabb = AABB.forAABBs([x.getAABB(), y.getAABB()]); - console.log("aabb", aabb); - console.log(matrixInv.str); - console.log(x.str, y.str); - return new ConicSurface(c, f1, f2, dir, this.uMin, this.uMax, aabb.min.z, aabb.max.z); - } - else { - const dir = transformedApex.V3(); - const baseCurve = isometricV(this.vMin).transform4(m4.times(this.matrix)); - const matrixInv = M4.forSys(baseCurve.f1, baseCurve.f2, dir.unit(), baseCurve.center).inversed(); - const aabb = isometricV(this.vMax) - .transform4(matrixInv.times(m4.times(this.matrix))) - .getAABB(); - return new CylinderSurface$1(baseCurve, dir.unit(), this.uMin, this.uMax, min(0, aabb.min.z, aabb.max.z), max(0, aabb.min.z, aabb.max.z)); - } - } - flipped() { - return new ConicSurface(this.center, this.f1.negated(), this.f2, this.dir); - } - normalUVFunc() { - const { f1, f2 } = this, f3 = this.dir; - return (d, _z) => { - return f2 - .cross(f1) - .plus(f2.cross(f3.times(Math.cos(d)))) - .plus(f3.cross(f1.times(Math.sin(d)))) - .unit(); - }; - } - normalP(p) { - //TODO assert(!p.like(this.center)) - const pLC = this.matrixInverse.transformPoint(p); - return this.normalUVFunc()(pLC.angleXY(), pLC.z); - } - pUVFunc() { - return (u, v) => { - // center + f1 v cos u + f2 v sin u + v dir - const resultLC = new V3(v * cos(u), v * sin(u), v); - return this.matrix.transformPoint(resultLC); - }; - } - dpdu() { - return (u, v) => { - const resultLC = new V3(v * -sin(u), v * cos(u), 0); - return this.matrix.transformVector(resultLC); - }; - } - dpdv() { - return (s) => { - const resultLC = new V3(cos(s), sin(s), 1); - return this.matrix.transformVector(resultLC); - }; - } - implicitFunction() { - return (pWC) => { - const pLC = this.matrixInverse.transformPoint(pWC); - const radiusLC = pLC.lengthXY(); - return this.normalDir * (radiusLC - pLC.z); - }; - } - didp(pWC) { - const pLC = this.matrixInverse.transformPoint(pWC); - return this.pLCNormalWCMatrix.transformVector(pLC.xy().unit().withElement("z", -1).times(this.normalDir)); - } - containsPoint(p) { - return eq0(this.implicitFunction()(p)); - } - uvP(pWC) { - const pLC = this.matrixInverse.transformPoint(pWC); - const angle = pLC.angleXY(); - return new V3(angle < -PI / 2 ? angle + TAU : angle, pLC.z, 0); - } - isCurvesWithSurface(surface) { - if (surface instanceof PlaneSurface$1) { - return this.isCurvesWithPlane(surface.plane); - } - else if (ImplicitSurface$1.is(surface)) { - return ParametricSurface$1.isCurvesParametricImplicitSurface(this, surface, 0.1, 0.1 / this.dir.length(), 0.02); - } - return super.isCurvesWithSurface(surface); - } - getCenterLine() { - return new L3$2(this.center, this.dir); - } - isCurvesWithPlane(plane) { - assertInst(P3$1, plane); - const planeLC = plane.transform(this.matrixInverse); - const planeNormal = planeLC.normal1; - const c = planeNormal.z; - /** "rotate" plane normal1 when passing to {@link ConicSurface.unitISPlane} so that - * y-component of normal1 is 0 */ - const a = planeNormal.lengthXY(); - const d = planeLC.w; - // generated curves need to be rotated back before transforming to world - // coordinates - const rotationMatrix = M4.rotateZ(planeNormal.angleXY()); - const wcMatrix = eq0(planeNormal.lengthXY()) - ? this.matrix - : this.matrix.times(rotationMatrix); - return ConicSurface.unitISPlane(a, c, d).flatMap((curve) => { - const curveWC = curve.transform(wcMatrix); - if (curve instanceof EllipseCurve$2) { - const curveLC = curve.transform(rotationMatrix); - const ts = curveLC.isTsWithPlane(P3$1.ZX); - const intervals = getIntervals(ts, -PI, PI).filter(([a, b]) => curveLC.at((a + b) / 2).y > 0); - return intervals.flatMap(([a, b]) => curveWC.split(a, b)); - } - const p = curveWC.at(0.2); - return this.normalP(p).cross(plane.normal1).dot(curveWC.tangentAt(0.2)) > - 0 - ? curveWC - : curveWC.reversed(); - }); - } - debugInfo() { - return { - ps: [this.center], - lines: [ - this.center, - this.center.plus(this.f1), - this.center.plus(this.f2), - this.center.plus(this.dir), - ], - }; - } -} -/** - * Unit cone. x² + y² = z², 0 <= z - */ -ConicSurface.UNIT = new ConicSurface(V3.O, V3.X, V3.Y, V3.Z); -ConicSurface.prototype.uStep = PI / 16; -ConicSurface.prototype.vStep = 256; - -/** - * Surface normal1 is (t, z) => this.baseCurve.tangentAt(t) X this.dir - * Choose dir appropriately to select surface orientation. - */ -class ProjectedCurveSurface extends ParametricSurface { - constructor(baseCurve, dir, uMin = baseCurve.tMin, uMax = baseCurve.tMax, vMin = -100, vMax = 100) { - super(uMin, uMax, vMin, vMax); - this.baseCurve = baseCurve; - this.dir = dir; - assertInst(Curve, baseCurve); - assertInst(V3, dir); - assert(uMin < uMax); - assert(vMin < vMax); - } - getConstructorParameters() { - return [ - this.baseCurve, - this.dir, - this.uMin, - this.uMax, - this.vMin, - this.vMax, - ]; - } - equals(obj) { - return (this == obj || - (Object.getPrototypeOf(this) == Object.getPrototypeOf(obj) && - this.dir.equals(obj.dir) && - this.baseCurve.equals(obj.baseCurve))); - } - hashCode() { - return arrayHashCode([this.dir, this.baseCurve]); - } - containsLine(line) { - return this.dir.isParallelTo(line.dir1) && this.containsPoint(line.anchor); - } - dpdu() { - return (u, v) => this.baseCurve.tangentAt(u); - } - dpdv() { - return (u, v) => this.dir; - } - normalUV(u, v) { - return this.baseCurve.tangentAt(u).cross(this.dir).unit(); - } - pUV(u, v) { - return this.baseCurve.at(u).plus(this.dir.times(v)); - } - pointFoot(pWC, ss) { - const basePlane = new P3(this.dir.unit(), 0); - const projCurve = this.baseCurve.project(basePlane); - const projPoint = basePlane.projectedPoint(pWC); - const t = projCurve.closestTToPoint(projPoint, ss, this.uMin, this.uMax); - const z = L3.pointT(this.baseCurve.at(t), this.dir, pWC); - return new V3(t, z, 0); - } - uvPFunc() { - const projPlane = new P3(this.dir.unit(), 0); - const projBaseCurve = this.baseCurve.project(projPlane); - return (pWC) => { - const projPoint = projPlane.projectedPoint(pWC); - assertNumbers(this.uMin); - const t = projBaseCurve.pointT(projPoint, this.uMin, this.uMax); - const z = L3.pointT(this.baseCurve.at(t), this.dir, pWC); - return new V3(t, z, 0); - }; - } - isCurvesWithPlane(plane) { - assertInst(P3, plane); - if (this.dir.isPerpendicularTo(plane.normal1)) { - const ts = this.baseCurve.isTsWithPlane(plane); - return ts.map((t) => { - const l3dir = 0 < this.baseCurve.tangentAt(t).dot(plane.normal1) - ? this.dir - : this.dir.negated(); - return new L3(this.baseCurve.at(t), l3dir.unit()); - }); - } - else { - let projCurve = this.baseCurve.transform(M4.project(plane, this.dir)); - if (this.dir.dot(plane.normal1) > 0) { - // we need to flip the ellipse so the tangent is correct - projCurve = projCurve.reversed(); - } - return [projCurve]; - } - } - isCurvesWithSurface(surface) { - if (surface instanceof PlaneSurface) { - return this.isCurvesWithPlane(surface.plane); - } - if (surface instanceof ProjectedCurveSurface) { - const dir1 = surface.dir; - if (this.dir.isParallelTo(dir1)) { - const ts = surface.baseCurve.isTsWithSurface(this); - return ts.map((t) => { - const p = surface.baseCurve.at(t); - const correctDir = this.normalP(p).cross(surface.normalP(p)); - return new L3(p, dir1.times(sign(correctDir.dot(dir1)))); - }); - } - else if (ImplicitSurface.is(surface)) { - let curves2 = ParametricSurface.isCurvesParametricImplicitSurface(this, surface, 0.1, 0.1 / surface.dir.length(), 0.05); - curves2 = surface.clipCurves(curves2); - return curves2; - } - else { - let curves2 = ParametricSurface.isCurvesParametricParametricSurface(this, surface, 0.05, 0.1 / surface.dir.length(), 0.05); - curves2 = this.clipCurves(curves2); - curves2 = surface.clipCurves(curves2); - return curves2; - } - } - if (surface instanceof EllipsoidSurface) { - return surface.isCurvesWithSurface(this); - } - return super.isCurvesWithSurface(surface); - } - containsPoint(pWC) { - const uv = this.uvPFunc()(pWC); - return this.pUVFunc()(uv.x, uv.y).like(pWC); - } - containsCurve(curve) { - if (curve instanceof L3) { - return (this.dir.isParallelTo(curve.dir1) && this.containsPoint(curve.anchor)); - } - if (curve instanceof ImplicitCurve) { - return super.containsCurve(curve); - } - // project baseCurve and test curve onto a common plane and check if the curves are alike - const projPlane = new P3(this.dir.unit(), 0); - const projBaseCurve = this.baseCurve.project(projPlane); - const projCurve = curve.project(projPlane); - return projBaseCurve.isColinearTo(projCurve); - } - isCoplanarTo(surface) { - return (this == surface || - (hasConstructor(surface, ProjectedCurveSurface) && - this.dir.isParallelTo(surface.dir) && - this.containsCurve(surface.baseCurve))); - } - like(object) { - if (!this.isCoplanarTo(object)) - return false; - // normals need to point in the same direction (outwards or inwards) for both - const p00 = this.pUVFunc()(0, 0); - const thisNormal = this.normalUVFunc()(0, 0); - const otherNormal = object.normalP(p00); - return 0 < thisNormal.dot(otherNormal); - } - loopContainsPoint(loop, p) { - assertVectors(p); - assert(isFinite(p.x), p.y, p.z); - const line = new L3(p, this.dir.unit()); - const ptpf = this.uvPFunc(); - const pp = ptpf(p); - if (isNaN(pp.x)) { - console.log(this.sce, p.sce); - assert(false); - } - const lineOut = this.baseCurve.tangentAt(pp.x).rejectedFrom(this.dir); - return Surface.loopContainsPointGeneral(loop, p, line, lineOut); - } - transform(m4) { - const f = m4.isMirroring() ? -1 : 1; - return new this.constructor(this.baseCurve.transform(m4), m4.transformVector(this.dir).times(f), this.uMin, this.uMax, 1 == f ? this.vMin : -this.vMax, 1 == f ? this.vMax : -this.vMin); - } - transform4(m4) { - const vp = m4.vanishingPoint(this.dir); - if (!vp) { - const f = m4.isMirroring() ? -1 : 1; - return new this.constructor(this.baseCurve.transform4(m4), m4.normalized().transformVector(this.dir).times(f), undefined, undefined, 1 == f ? this.vMin : -this.vMax, 1 == f ? this.vMax : -this.vMin); - } - const curveT = this.baseCurve.transform4(m4); - if (curveT instanceof EllipseCurve) { - console.log(vp.sce, curveT.sce); - return ConicSurface.atApexThroughEllipse(vp, m4.isMirroring() ? curveT : curveT.reversed(), this.uMin, this.uMax, 1, 2); - } - return new PointProjectedSurface(curveT, vp, P3.throughPoints(curveT.at(curveT.tMin), curveT.at((curveT.tMin + curveT.tMax) / 2), curveT.at(curveT.tMax)), 1, this.uMin, this.uMax, 1, 2); - } - isTsForLine(line) { - assertInst(L3, line); - const projPlane = new P3(this.dir.unit(), 0); - const projDir = projPlane.projectedVector(line.dir1); - if (projDir.likeO()) { - // line is parallel to this.dir - return []; - } - const projAnchor = projPlane.projectedPoint(line.anchor); - const projBaseCurve = this.baseCurve.project(projPlane); - return projBaseCurve - .isInfosWithLine(projAnchor, projDir, this.uMin, this.uMax, line.tMin, line.tMax) - .map((info) => info.tOther); - } - flipped() { - return new this.constructor(this.baseCurve, this.dir.negated(), this.uMin, this.uMax, -this.vMax, -this.vMin); - } -} -ProjectedCurveSurface.prototype.uStep = 1 / 128; -ProjectedCurveSurface.prototype.vStep = 256; - -/** - * Rotation surface with r = f(z) - */ -class RotatedCurveSurface extends ParametricSurface$1 { - constructor(curve, matrix = M4.IDENTITY, uMin = 0, uMax = PI, vMin = curve.tMin, vMax = curve.tMax) { - // d/dz (r(z)) - super(uMin, uMax, vMin, vMax); - this.curve = curve; - this.matrix = matrix; - assertInst(M4, matrix); - assert(matrix.isNoProj()); - assert(eq0(curve.at(vMin).y)); - this.matrixInverse = matrix.inversed(); - this.vStep = this.curve.tIncrement; - } - getConstructorParameters() { - return [this.curve, this.matrix, this.uMin, this.uMax, this.vMin, this.vMax]; - } - flipped() { - return new RotatedCurveSurface(this.curve, this.matrix.times(M4.mirror(P3$1.YZ)), this.uMin, this.uMax, this.vMin, this.vMax); - } - transform(m4) { - return new RotatedCurveSurface(this.curve, m4.isMirroring() - ? m4.times(this.matrix).times(M4.mirror(P3$1.YZ)) - : m4.times(this.matrix), this.uMin, this.uMax, this.vMin, this.vMax); - } - containsPoint(pWC) { - const pLC = this.matrixInverse.transformPoint(pWC); - const radius = pLC.lengthXY(); - return this.curve.containsPoint(new V3(radius, 0, pLC.z)); - } - pUVFunc() { - return (u, v) => { - const { x: radius, z: z } = this.curve.at(v); - return this.matrix.transformPoint(V3.polar(radius, u, z)); - }; - } - dpdu() { - return (u, v) => { - const radius = this.curve.at(v).x; - const resultLC = new V3(radius * -sin(u), radius * cos(u), 0); - return this.matrix.transformVector(resultLC); - }; - } - dpdv() { - return (u, v) => { - const { x: drdt, z: dzdt } = this.curve.tangentAt(v); - return this.matrix.transformVector(V3.polar(drdt, u, dzdt)); - }; - } - normalUVFunc() { - const matrix = this.matrix.inversed().transposed().as3x3(); - const normalLength = this.matrix.isMirroring() ? -1 : 1; - return (u, v) => { - const { x: drdt, z: dzdt } = this.curve.tangentAt(v); - return matrix - .transformVector(V3.polar(dzdt, u, -drdt)) - .toLength(normalLength); - }; - } - uvPFunc() { - return (pWC) => { - const pLC = this.matrixInverse.transformPoint(pWC); - const angle = EllipseCurve$2.XYLCPointT(pLC, this.uMin, this.uMax); - const radius = pLC.lengthXY(); - return new V3(angle, this.curve.pointT(new V3(radius, 0, pLC.z)), 0); - }; - } - pointFoot(pWC, startS, startT) { - const pLC = this.matrixInverse.transformPoint(pWC); - const angle = abs(pLC.angleXY()); - const radius = pLC.lengthXY(); - return new V3(angle, this.curve.closestTToPoint(new V3(radius, 0, pLC.z)), 0); - } - isTsForLine(line) { - const anchorLC = this.matrixInverse.transformPoint(line.anchor); - const dirLC = this.matrixInverse.transformVector(line.dir1); - if (dirLC.isParallelTo(V3.Z)) { - if (!fuzzyBetween(anchorLC.angleXY(), this.uMin, this.uMax)) - return []; - return this.curve - .isInfosWithLine(new V3(anchorLC.lengthXY(), 0, anchorLC.z), dirLC) - .map((info) => info.tOther); - } - else if (L3$2.containsPoint(anchorLC.xy(), dirLC.xy(), V3.O)) { - // line goes through Z axis - const dotter = dirLC.xy().unit(); - return [ - ...this.curve.isInfosWithLine(new V3(dotter.dot(anchorLC), 0, anchorLC.z), new V3(dotter.dot(dirLC), 0, dirLC.z)), - ...this.curve.isInfosWithLine(new V3(-dotter.dot(anchorLC), 0, anchorLC.z), new V3(-dotter.dot(dirLC), 0, dirLC.z)), - ] - .map((info) => info.tOther) - .filter((t) => fuzzyBetween(L3$2.at(anchorLC, dirLC, t).angleXY(), this.uMin, this.uMax)); - } - else if (dirLC.isPerpendicularTo(V3.Z)) { - const secs = this.isCurvesWithPlaneLC(new P3$1(V3.Z, anchorLC.z)); - if (!secs) - return []; - return secs.flatMap((sec) => sec.isInfosWithLine(anchorLC, dirLC).map((info) => info.tOther)); - } - else { - // transform into hyperbola - // f(t) = V(((ax + t dx)² + (ay + t dy)²) ** 1/2, 0, az + t dz) - // f(t) = V((ax² + 2 ax t dx + t² dx² + ay² + 2 ay t dy + t² dy²) ** 1/2, 0, az + t dz) - // f(t) = V((t² (dx² + dy²) + 2 t (ax dx + ay dy) + ax² + ay²) ** 1/2, 0, az + t * dz) - // (anchorLC.xy + t * dirLC.xy) * dir.xy = 0 - // t * dirLC.xy² = -anchorLC.xy * dirLC.xy - const closestTToZ = -anchorLC.xy().dot(dirLC.xy()) / dirLC.xy().squared(); - const closestPointToZ = L3$2.at(anchorLC, dirLC, closestTToZ); - const scaleX = closestPointToZ.lengthXY(); - const lineGradientWC = dirLC.z / dirLC.lengthXY(); - const scaleZ = scaleX * lineGradientWC; - const hc = HyperbolaCurve$2.XY.transform(M4.rotateX(90 * DEG) - .scale(scaleX, 0, scaleZ) - .translate(0, 0, closestPointToZ.z)); - const infos = hc.isInfosWithCurve(this.curve); - return infos - .map((info) => (info.p.z - anchorLC.z) / dirLC.z) - .filter((t) => fuzzyBetween(L3$2.at(anchorLC, dirLC, t).angleXY(), this.uMin, this.uMax)); - } - } - isCurvesWithPlaneLC(planeLC) { - if (planeLC.normal1.isParallelTo(V3.Z)) { - return this.curve.isTsWithPlane(planeLC).map((t) => { - const { x: radius } = this.curve.at(t); - return new EllipseCurve$2(new V3(0, 0, planeLC.w), new V3(radius, 0, 0), new V3(0, radius, 0), this.uMin, this.uMax).transform(this.matrix); - }); - } - else if (planeLC.normal1.isPerpendicularTo(V3.Z) && - planeLC.containsPoint(V3.O)) { - return [ - this.curve - .rotateZ(V3.Y.angleRelativeNormal(planeLC.normal1, V3.Z)) - .transform(this.matrix), - ]; - } - return undefined; - } - isCurvesWithPlane(plane) { - const planeLC = plane.transform(this.matrixInverse); - const planeLCCurves = this.isCurvesWithPlaneLC(planeLC); - if (planeLCCurves) { - return planeLCCurves.map((curve) => curve.transform(this.matrix)); - } - else { - return ParametricSurface$1.isCurvesParametricImplicitSurface(this, new PlaneSurface$1(plane), 0.05, 0.05, 0.02); - } - } - loopContainsPoint(loop, pWC) { - const pLC = this.matrixInverse.transformPoint(pWC); - const angle = EllipseCurve$2.XYLCPointT(pLC, this.uMin, this.uMax); - const testCurveLC = EllipseCurve$2.semicircle(pLC.lengthXY(), new V3(0, 0, pLC.z)); - const testCurveWC = testCurveLC.transform(this.matrix); - return Surface$1.loopContainsPointEllipse(loop, pWC, testCurveWC, angle); - } - isCoplanarTo(surface) { - if (this === surface) - return true; - if (!hasConstructor(surface, RotatedCurveSurface)) - return false; - const surfaceLCToThisLC = this.matrixInverse.times(surface.matrix); - assert(!surfaceLCToThisLC.X.xy().likeO()); - const zRotation = surfaceLCToThisLC.X.angleXY(); - return surface.curve - .transform(M4.rotateZ(-zRotation).times(surfaceLCToThisLC)) - .isColinearTo(this.curve); - } - isCurvesWithSurface(surface) { - if (surface instanceof PlaneSurface$1) { - return this.isCurvesWithPlane(surface.plane); - } - return super.isCurvesWithSurface(surface); - } - containsCurve(curve) { - if (curve.constructor == this.curve.constructor) { - const curveLC = curve.transform(this.matrixInverse); - // find a point on curveLC which isn't on the Z-axis - const t = withMax([0, 0.5, 1].map((x) => lerp(curveLC.tMin, curveLC.tMax, x)), (t) => curveLC.at(t).lengthXY()); - const angle = curveLC.at(t).angleXY(); - const curveLCRotated = curveLC.rotateZ(-angle); - if (this.curve.isColinearTo(curveLCRotated)) { - return true; - } - } - if (curve instanceof EllipseCurve$2) { - const curveLC = curve.transform(this.matrixInverse); - if (curveLC.normal.isParallelTo(V3.Z)) { - return (curveLC.isCircular() && - this.curve.containsPoint(new V3(curveLC.f1.length(), 0, curveLC.center.z))); - } - return false; - } - return super.containsCurve(curve); - } - getExtremePoints() { - return getExtremePointsHelper.call(this, this.curve); - } - asNURBSSurface() { - // y = 0 for baseNURBS - const baseNURBS = NURBS$1.fromEllipse(this.curve); - const rotationNURBS = NURBS$1.UnitCircle(2, this.vMin, this.vMax); - return new NURBSSurface$1(rotationNURBS.points.flatMap((rv) => baseNURBS.points.map((b) => this.matrix.timesVector(VV(rv.x * b.x, rv.y * b.x, b.z * rv.w, rv.w * b.w)))), baseNURBS.knots, rotationNURBS.knots, baseNURBS.degree, rotationNURBS.degree, baseNURBS.tMin, baseNURBS.tMax, rotationNURBS.tMin, rotationNURBS.tMax); - } -} -RotatedCurveSurface.prototype.uStep = EllipseCurve$2.prototype.tIncrement; -function getExtremePointsHelper(curve) { - // this logic comes from EllipseCurve.roots - const f1 = this.matrix.X; - const f2 = this.matrix.Y; - return [0, 1, 2].flatMap((dim) => { - const a = f2.e(dim); - const b = -f1.e(dim); - const xiEtas = eq0(a) && eq0(b) ? [[1, 0]] : intersectionUnitCircleLine2$1(a, b, 0); - return xiEtas.flatMap(([xi, eta]) => { - const u = Math.atan2(eta, xi); - if (!(lt(this.uMin, u) && lt(u, this.uMax))) - return []; - const testCurve = curve.transform(this.matrix.times(M4.rotateZ(u))); - return testCurve.roots()[dim].map((v) => this.pUV(u, v)); - }); - }); -} - -class CylinderSurface extends ProjectedCurveSurface$1 { - // @ts-ignore - // readonly baseCurve: EllipseCurve - constructor(baseCurve, dir1, uMin = baseCurve.tMin, uMax = baseCurve.tMax, zMin = -Infinity, zMax = Infinity) { - super(baseCurve, dir1, uMin, uMax, zMin, zMax); - this.baseCurve = baseCurve; - assertInst(EllipseCurve$2, baseCurve); - //assert(!baseCurve.normal1.isPerpendicularTo(dir1), !baseCurve.normal1.isPerpendicularTo(dir1)) - this.matrix = M4.forSys(baseCurve.f1, baseCurve.f2, dir1, baseCurve.center); - this.matrixInverse = this.matrix.inversed(); - this.normalDir = sign(this.baseCurve.normal.dot(this.dir)); - this.pLCNormalWCMatrix = this.matrix - .as3x3() - .inversed() - .transposed() - .scale(this.normalDir); - this.pWCNormalWCMatrix = this.pLCNormalWCMatrix.times(this.matrixInverse); - } - static semicylinder(radius, sMin, sMax, tMin, tMax) { - return new CylinderSurface(new EllipseCurve$2(V3.O, new V3(radius, 0, 0), new V3(0, radius, 0)), V3.Z, sMin, sMax, tMin, tMax); - } - /** - * - * @param anchorLC - * @param dirLC not necessarily unit - */ - static unitISLineTs(anchorLC, dirLC) { - const { x: ax, y: ay } = anchorLC; - const { x: dx, y: dy } = dirLC; - // this cylinder: x² + y² = 1 - // line: p = anchorLC + t * dirLC - // split line equation into 3 component equations, insert into cylinder equation - // x = ax + t * dx - // y = ay + t * dy - // (ax² + 2 ax t dx + t²dx²) + (ay² + 2 ay t dy + t²dy²) = 1 - // transform to form (a t² + b t + c = 0) and solve with pqFormula - const a = Math.pow(dx, 2) + Math.pow(dy, 2); - const b = 2 * (ax * dx + ay * dy); - const c = Math.pow(ax, 2) + Math.pow(ay, 2) - 1; - return pqFormula(b / a, c / a).filter((t) => EllipseCurve$2.XYLCValid(new V3(ax + dx * t, ay + dy * t, 0))); - } - normalP(p) { - return this.pLCNormalWCMatrix - .transformVector(this.matrixInverse.transformPoint(p).xy()) - .unit(); - } - loopContainsPoint(loop, p) { - assertVectors(p); - if (!this.containsPoint(p)) - return OUTSIDE$1; - const line = new L3$2(p, this.dir.unit()); - const lineOut = this.dir.cross(this.normalP(p)); - return Surface$1.loopContainsPointGeneral(loop, p, line, lineOut); - } - isTsForLine(line) { - assertInst(L3$2, line); - // transforming line manually has advantage that dir1 will not be renormalized, - // meaning that calculated values t for localLine are directly transferable to line - const dirLC = this.matrixInverse.transformVector(line.dir1); - if (dirLC.isParallelTo(V3.Z)) { - // line is parallel to this.dir - return []; - } - const anchorLC = this.matrixInverse.transformPoint(line.anchor); - assert(!CylinderSurface.unitISLineTs(anchorLC, dirLC).length || - !isNaN(CylinderSurface.unitISLineTs(anchorLC, dirLC)[0]), "sad " + dirLC); - return CylinderSurface.unitISLineTs(anchorLC, dirLC); - } - isCoplanarTo(surface) { - return (this == surface || - (hasConstructor(surface, CylinderSurface) && - this.dir.isParallelTo(surface.dir) && - this.containsEllipse(surface.baseCurve, false))); - } - like(surface) { - if (!this.isCoplanarTo(surface)) - return false; - // normals need to point in the same direction (outwards or inwards) for both - const thisFacesOut = 0 < this.baseCurve.normal.dot(this.dir); - const objectFacesOut = 0 < surface.baseCurve.normal.dot(surface.dir); - return thisFacesOut == objectFacesOut; - } - containsEllipse(ellipse, checkAABB = true) { - const projEllipse = ellipse.transform(M4.project(this.baseCurve.getPlane(), this.dir)); - return this.baseCurve == ellipse || this.baseCurve.isColinearTo(projEllipse); - } - containsCurve(curve) { - if (curve instanceof L3$2) { - return this.containsLine(curve); - } - else if (curve instanceof EllipseCurve$2) { - return this.containsEllipse(curve); - } - else if (curve instanceof BezierCurve$2) { - return false; - } - else { - return super.containsCurve(curve); - } - } - implicitFunction() { - return (pWC) => { - const pLC = this.matrixInverse.transformPoint(pWC); - return (pLC.lengthXY() - 1) * this.normalDir; - }; - } - didp(pWC) { - const pLC = this.matrixInverse.transformPoint(pWC); - const pLCLengthXY = pLC.lengthXY(); - const didpLC = new V3(pLC.x / pLCLengthXY, pLC.y / pLCLengthXY, 0); - return this.pLCNormalWCMatrix.transformVector(didpLC); - } - containsPoint(pWC) { - const pLC = this.matrixInverse.transformPoint(pWC); - return this.baseCurve.isValidT(EllipseCurve$2.XYLCPointT(pLC, this.uMin, this.uMax)); - } - uvP(pWC) { - assert(arguments.length == 1); - const pLC = this.matrixInverse.transformPoint(pWC); - const u = EllipseCurve$2.XYLCPointT(pLC, this.vMin, this.vMax); - return new V3(u, pLC.z, 0); - } - isCurvesWithSurface(surface2) { - if (surface2 instanceof ProjectedCurveSurface$1) { - if (surface2.dir.isParallelTo(this.dir)) { - const projectedCurve = surface2.baseCurve.transform(M4.project(this.baseCurve.getPlane(), this.dir)); - return this.baseCurve.isInfosWithCurve(projectedCurve).map((info) => { - const lineDir = sign(this.normalP(info.p) - .cross(surface2.normalP(info.p)) - .dot(this.dir)) || 1; - return new L3$2(info.p, this.dir.times(lineDir)); - }); - } - } - if (surface2 instanceof CylinderSurface) { - if (eq0(this.getCenterLine().distanceToLine(surface2.getCenterLine()))) { - throw new Error(); - } - } - return super.isCurvesWithSurface(surface2); - } - getCenterLine() { - return new L3$2(this.baseCurve.center, this.dir); - } - facesOutwards() { - return this.baseCurve.normal.dot(this.dir) > 0; - } - getSeamPlane() { - let normal = this.baseCurve.f1.cross(this.dir); - normal = normal.times(-sign(normal.dot(this.baseCurve.f2))); - return P3$1.normalOnAnchor(normal, this.baseCurve.center); - } - clipCurves(curves) { - return curves.flatMap((curve) => curve.clipPlane(this.getSeamPlane())); - } -} -CylinderSurface.UNIT = new CylinderSurface(EllipseCurve$2.UNIT, V3.Z, undefined, undefined, 0, 1); -CylinderSurface.prototype.uStep = TAU / 32; -CylinderSurface.prototype.vStep = 256; - -class EllipsoidSurface extends ParametricSurface$1 { - constructor(center, f1, f2, f3, uMin = 0, uMax = PI, vMin = -PI / 2, vMax = PI / 2) { - super(uMin, uMax, vMin, vMax); - this.center = center; - this.f1 = f1; - this.f2 = f2; - this.f3 = f3; - assert(0 <= uMin && uMin <= PI, uMin); - assert(0 <= uMax && uMax <= PI, uMax); - assert(-PI / 2 <= vMin && vMin <= PI / 2); - assert(-PI / 2 <= vMax && vMax <= PI / 2); - assertVectors(center, f1, f2, f3); - this.matrix = M4.forSys(f1, f2, f3, center); - this.matrixInverse = this.matrix.inversed(); - this.normalDir = sign(this.f1.cross(this.f2).dot(this.f3)); - this.pLCNormalWCMatrix = this.matrix - .as3x3() - .inversed() - .transposed() - .scale(this.normalDir); - this.pWCNormalWCMatrix = this.pLCNormalWCMatrix.times(this.matrixInverse); - } - static unitArea(contour) { - const totalArea = sum(contour.map((edge) => { - if (edge.curve instanceof PICurve$1) { - const points = edge.curve.calcSegmentPoints(edge.aT, edge.bT, edge.a, edge.b, edge.aT > edge.bT, true); - let sum = 0; - for (let i = 0; i < points.length - 1; i++) { - const p = points[i], ppp = points[i + 1]; - sum += ((abs(p.angleXY()) + abs(ppp.angleXY())) / 2) * (ppp.z - p.z); - } - return sum; - } - else if (edge.curve instanceof EllipseCurve$2) { - const f = (t) => { - const at = edge.curve.at(t), tangent = edge.curve.tangentAt(t); - const angleXY = abs(at.angleXY()); - //const arcLength = angleXY * Math.sqrt(1 - at.z ** 2) ( == at.lengthXY()) - //const scaling = tangent.z / at.lengthXY() - return angleXY * tangent.z; - }; - const val = glqInSteps(f, edge.aT, edge.bT, 1); - return val; - } - else { - throw new Error(); - } - })); - return totalArea; - } - /** - * unit sphere: x² + y² + z² = 1 - * line: p = anchor + t * dir |^2 - * p² = (anchor + t * dir)^2 - * 1 == (anchor + t * dir)^2 - * 1 == anchor DOT anchor + 2 * anchor * t * dir + t² * dir DOT dir - */ - static unitISTsWithLine(anchor, dir) { - // for 0 = a t² + b t + c - const a = dir.dot(dir); - const b = 2 * anchor.dot(dir); - const c = anchor.dot(anchor) - 1; - return pqFormula(b / a, c / a).filter((t) => le(0, anchor.y + t * dir.y)); - } - /** - * unit sphere: x² + y² + z² = 1 - * plane: normal1 DOT p = w - */ - static unitISCurvesWithPlane(plane) { - const distPlaneCenter = Math.abs(plane.w); - if (lt(distPlaneCenter, 1)) { - // result is a circle - // radius of circle: imagine right angled triangle (origin -> center of intersection circle -> point on - // intersection circle) pythagoras: 1² == distPlaneCenter² + isCircleRadius² => isCircleRadius == sqrt(1 - - // distPlaneCenter²) - const isCircleRadius = Math.sqrt(1 - Math.pow(distPlaneCenter, 2)); - const anchorY = plane.normal1.y * plane.w; - const d = abs(distPlaneCenter * isCircleRadius); - if (le(anchorY, -d) && !eq0(distPlaneCenter)) { - return []; - } - else if (le(anchorY, 0) && !plane.normal1.isParallelTo(V3.Y)) { - const f1 = plane.normal1.isParallelTo(V3.Y) - ? V3.Z - : plane.normal1.cross(V3.Y).toLength(isCircleRadius); - const f2 = f1.cross(plane.normal1); - const minEta = -anchorY / f2.y, minT = max(0, Math.asin(minEta)); - return [new EllipseCurve$2(plane.anchor, f1, f2, minT, PI - minT)]; - } - else { - const f2 = (plane.normal1.isParallelTo(V3.Y) - ? V3.X - : plane.normal1.cross(V3.Y)).toLength(isCircleRadius); - const f1 = f2.cross(plane.normal1); - const minXi = eq0(f1.y) ? -1 : -anchorY / f1.y, maxT = Math.acos(max(-1, minXi - NLA_PRECISION)); - return [ - new EllipseCurve$2(plane.anchor, f1.negated(), f2, PI - maxT, PI), - new EllipseCurve$2(plane.anchor, f1, f2.negated(), 0, maxT), - ]; - } - } - else { - return []; - } - } - static unitISCurvesWithEllipsoidSurface(surface) { - if (surface.isSphere()) { - const surfaceRadius = surface.f1.length(); - const surfaceCenterDist = surface.center.length(); - if (le(1, surfaceCenterDist - surfaceRadius) || - le(surfaceCenterDist + surfaceRadius, 1) || - le(surfaceCenterDist - surfaceRadius, -1)) { - return []; - } - else { - // origin, surface.center and points on the intersection curves form a triangle. - // the height on the segment origin - surface.center is the radius of the is curves - // the distance from the origin to the lot point is the distance to the intersection plane - function heron(a, b, c) { - const p = (a + b + c) / 2; - return sqrt(p * (p - a) * (p - b) * (p - c)); - } - const triangleArea = heron(1, surfaceRadius, surfaceCenterDist); - const radius = (triangleArea * 2) / surfaceCenterDist; - const isCurvesCenterDist = sign(1 + Math.pow(surfaceCenterDist, 2) - Math.pow(surfaceRadius, 2)) * - sqrt(1 - Math.pow(radius, 2)); - const plane = new P3$1(surface.center.unit(), isCurvesCenterDist); - return EllipsoidSurface.unitISCurvesWithPlane(plane.flipped()); - } - } - throw new Error(); - } - static unitISCurvesWithCylinderSurface(surface) { - if (new L3$2(surface.baseCurve.center, surface.dir).containsPoint(V3.O)) { - const projEllipse = surface.baseCurve.transform(M4.project(new P3$1(surface.dir, 0))); - const f1Length = projEllipse.f1.length(), f2Length = projEllipse.f2.length(); - if (lt(1, min(f1Length, f2Length))) - return []; - if (projEllipse.isCircular()) { - const distISCurveCenter = Math.sqrt(1 - Math.pow(min(1, f1Length), 2)); - const isCurveCenter = (surface.dir.y < 0 - ? surface.dir.negated() - : surface.dir).times(distISCurveCenter); - // isCurve.at(t).y = isCurveCenter.y + projEllipse.f1.y * cos(t) + projEllipse.f2.y * sin(t) = 0 - return [new EllipseCurve$2(isCurveCenter, projEllipse.f1, projEllipse.f2)]; - } - } - throw new Error(); - } - static sphere(radius, center = V3.O) { - assertNumbers(radius); - return new EllipsoidSurface(center, new V3(radius, 0, 0), new V3(0, radius, 0), new V3(0, 0, radius)); - } - /** - * x²/a² + y²/b² + z²/c² = 1 - */ - static forABC(a, b, c, center = V3.O) { - return new EllipsoidSurface(center, new V3(a, 0, 0), new V3(0, b, 0), new V3(0, 0, c)); - } - static calculateAreaSpheroid(a, b, c, edges) { - assertf(() => a.isPerpendicularTo(b)); - assertf(() => b.isPerpendicularTo(c)); - assertf(() => c.isPerpendicularTo(a)); - // handling discontinuities: - // option 1: check for intersections with baseline, if there are any integrate parts separetely - // "rotate" the edge so that there are no overlaps - const matrix = M4.forSys(a, b, c), matrixInverse = matrix.inversed(); - const circleRadius = a.length(); - const c1 = c.unit(); - const totalArea = sum(edges.map((edge) => { - if (edge.curve instanceof EllipseCurve$2) { - const f = (t) => { - const at = edge.curve.at(t), tangent = edge.tangentAt(t); - const localAt = matrixInverse.transformPoint(at); - const angleXY = localAt.angleXY(); - const arcLength = angleXY * circleRadius * Math.sqrt(1 + Math.pow(localAt.z, 2)); - const scaling = Math.sqrt(1 + Math.pow(c1.dot(tangent), 2)); - return arcLength * scaling; - }; - const val = glqInSteps(f, edge.aT, edge.bT, 1); - return val; - } - else { - throw new Error(); - } - })); - return totalArea; - } - getConstructorParameters() { - return [ - this.center, - this.f1, - this.f2, - this.f3, - this.uMin, - this.uMax, - this.vMin, - this.vMax, - ]; - } - equals(obj) { - return (this == obj || - (Object.getPrototypeOf(obj) == this.constructor.prototype && - this.matrix.equals(obj.matrix))); - } - edgeLoopCCW(loop) { - return (EllipsoidSurface.unitArea(loop.map((edge) => edge.transform(this.matrixInverse))) > 0); - //let totalAngle = 0 - //for (let i = 0; i < contour.length; i++) { - // const ipp = (i + 1) % contour.length - // const edge = contour[i], nextEdge = contour[ipp] - // totalAngle += edge.bDir.angleRelativeNormal(nextEdge.aDir, this.normalP(edge.b)) - //} - //return le(0, totalAngle) - } - like(object) { - if (!this.isCoplanarTo(object)) - return false; - // normals need to point in the same direction (outwards or inwards) for both - return this.matrix.determinant3() * object.matrix.determinant3() > 0; - } - rootPoints() { } - toMesh() { - return ParametricSurface$1.prototype.toMesh.call(this); - } - clipCurves(curves) { - return curves.flatMap((curve) => curve.clipPlane(this.getSeamPlane())); - } - dpdu() { - // dp(u, v) = new V3(cos(t) * cos(s), cos(t) * sin(s), sin(t) - return (u, v) => this.matrix.transformVector(new V3(cos(v) * -sin(u), cos(v) * cos(u), 0)); - } - dpdv() { - return (u, v) => this.matrix.transformVector(new V3(-sin(v) * cos(u), -sin(v) * sin(u), cos(v))); - } - isCurvesWithPCS(surface) { - let curves2 = ParametricSurface$1.isCurvesParametricImplicitSurface(surface, this, 0.1, 0.1 / surface.dir.length(), 0.05); - curves2 = this.clipCurves(curves2); - return curves2; - } - isCurvesWithPCSSmart(surface) { - const surfaceLC = surface.transform(this.matrixInverse); - //const lcMinZ0RelO = - const baseCurveLC = surfaceLC.baseCurve.project(new P3$1(surfaceLC.dir, 0)); - const ists = baseCurveLC.isTsWithSurface(EllipsoidSurface.UNIT); - const insideIntervals = getIntervals(ists, baseCurveLC.tMin, baseCurveLC.tMax).filter(([a, b]) => baseCurveLC.at((a + b) / 2).length() < 1); - const projectedCurves = [0, 1].map((id) => { - return (t) => { - const atSqr = snap(baseCurveLC.at(t).squared(), 1); - const lineISTs = /* +- */ sqrt(1 - atSqr); - //assert(!isNaN(lineISTs)) - return eq0(lineISTs) - ? baseCurveLC.at(t) - : baseCurveLC - .at(t) - .plus(surfaceLC.dir.times(sign(id - 0.5) * lineISTs)); - }; - }); - const dProjectedCurves = [0, 1].map((id) => { - return (t) => { - // d/dt sqrt(1 - baseCurveLC.at(t).squared()) - // = -1/2 * 1/sqrt(1 - baseCurveLC.at(t).squared()) * -2*baseCurveLC.at(t) * baseCurveLC.tangentAt(t) - const atSqr = snap(baseCurveLC.at(t).squared(), 1); - const lineISTs = /* +- */ baseCurveLC - .at(t) - .times(-1 / sqrt(1 - atSqr)) - .dot(baseCurveLC.tangentAt(t)); - //assert(!isNaN(lineISTs)) - return baseCurveLC - .tangentAt(t) - .plus(surfaceLC.dir.times(sign(id - 0.5) * lineISTs)); - }; - }); - //const f2 = t => sqrt(1 - baseCurveLC.at(t).squared()) - //const df2 = t => baseCurveLC.at(t).times(-1 / sqrt(1 - - // baseCurveLC.at(t).squared())).dot(baseCurveLC.tangentAt(t)) checkDerivate(f2, df2, 0.31, 0.60) - const curves = []; - for (const [aT, bT] of insideIntervals) { - //const aLine = new L3(baseCurveLC.at(aT), surfaceLC.dir1) - //const a = EllipsoidSurface.UNIT.isTsForLine(aLine).map(t => aLine.at(t)) - //const bLine = new L3(baseCurveLC.at(bT), surfaceLC.dir1) - //const b = EllipsoidSurface.UNIT.isTsForLine(bLine).map(t => bLine.at(t)) - for (const i of [0, 1]) { - const f = (t) => projectedCurves[i](t).y; - const df = (t) => dProjectedCurves[i](t).y; - checkDerivate(f, df, aT + 0.1, bT - 0.1); - const tsAtY0 = getRoots(f, aT + NLA_PRECISION, bT - NLA_PRECISION, 1 / (1 << 11), df); - const ii2 = getIntervals(tsAtY0, aT, bT).filter(([a, b]) => f((a + b) / 2) > 0); - for (const [aT2, bT2] of ii2) { - let aP = projectedCurves[i](aT2), bP = projectedCurves[i](bT2); - 0 === i && ([aP, bP] = [bP, aP]); - assert(EllipsoidSurface.UNIT.containsPoint(aP)); - assert(EllipsoidSurface.UNIT.containsPoint(bP)); - curves.push(PICurve$1.forStartEnd(surface, this, this.matrix.transformPoint(bP), this.matrix.transformPoint(aP), undefined)); - } - } - } - return surface.clipCurves(curves); - } - isCurvesWithSurface(surface) { - if (surface instanceof PlaneSurface$1) { - return this.isCurvesWithPlane(surface.plane); - } - else if (surface instanceof CylinderSurface$1) { - return this.isCurvesWithCylinderSurface(surface); - } - else if (surface instanceof EllipsoidSurface) { - const surfaceLC = surface.transform(this.matrixInverse); - const curves = EllipsoidSurface.unitISCurvesWithEllipsoidSurface(surfaceLC).map((c) => c.transform(this.matrix)); - return surface.clipCurves(curves); - } - else if (surface instanceof ProjectedCurveSurface$1) { - return this.isCurvesWithPCS(surface); - } - else if (surface instanceof ParametricSurface$1) { - let curves2 = ParametricSurface$1.isCurvesParametricImplicitSurface(surface, this, 0.1, 0.1, 0.05); - curves2 = this.clipCurves(curves2); - curves2 = surface.clipCurves(curves2); - return curves2; - } - else { - throw new Error(); - } - } - isCurvesWithPlane(plane) { - const planeLC = plane.transform(this.matrixInverse); - return EllipsoidSurface.unitISCurvesWithPlane(planeLC).map((c) => c.transform(this.matrix)); - } - isCurvesWithCylinderSurface(surface) { - if (L3$2.containsPoint(surface.baseCurve.center, surface.dir, this.center)) { - assert(this.isSphere()); - const ellipseProjected = surface.baseCurve.transform(M4.project(surface.baseCurve.getPlane(), surface.dir)); - if (ellipseProjected.isCircular()) { - const thisRadius = this.f1.length(); - const surfaceRadius = ellipseProjected.f1.length(); - // sphereRadius² = distanceISFromCenter² + isRadius² - if (eq(thisRadius, surfaceRadius)) ; - assert(false); - } - } - return this.isCurvesWithPCS(surface); - } - isTsForLine(line) { - assertInst(L3$2, line); - // transforming line manually has advantage that dir1 will not be renormalized, - // meaning that calculated values t for localLine are directly transferable to line - const anchorLC = this.matrixInverse.transformPoint(line.anchor); - const dirLC = this.matrixInverse.transformVector(line.dir1); - return EllipsoidSurface.unitISTsWithLine(anchorLC, dirLC); - } - isCoplanarTo(surface) { - if (this === surface) - return true; - if (!hasConstructor(surface, EllipsoidSurface)) - return false; - if (!this.center.like(surface.center)) - return false; - if (this.isSphere()) - return surface.isSphere() && eq(this.f1.length(), this.f2.length()); - const otherMatrixLC = this.matrixInverse.times(surface.matrix); - // Ellipsoid with matrix otherMatrixLC is unit sphere iff otherMatrixLC is orthogonal - return otherMatrixLC.like3x3() && otherMatrixLC.isOrthogonal(); - } - containsEllipse(ellipse) { - const ellipseLC = ellipse.transform(this.matrixInverse); - const distEllipseLCCenter = ellipseLC.center.length(); - const correctRadius = Math.sqrt(1 - Math.pow(distEllipseLCCenter, 2)); - return (lt(distEllipseLCCenter, 1) && - ellipseLC.isCircular() && - ellipseLC.f1.hasLength(correctRadius)); - //&& le(0, ellipseLC.getAABB().min.y) - } - containsCurve(curve) { - if (curve instanceof EllipseCurve$2) { - return this.containsEllipse(curve); - } - else { - return super.containsCurve(curve); - } - } - transform(m4) { - assert(m4.isNoProj(), () => m4.sce); - return new EllipsoidSurface(m4.transformPoint(this.center), m4.transformVector(this.f1), m4.transformVector(this.f2), m4.transformVector(this.f3).times(m4.isMirroring() ? -1 : 1)); - } - transform4(m4) { - console.log("transform4"); - const resultMatrix = m4.times(this.matrix); - console.log(resultMatrix.toString()); - const scaleDir = V(resultMatrix.m[12], resultMatrix.m[13], resultMatrix.m[14]); - // need to find parameters where scaleDir is parallel to the normal - const pLC = this.pLCNormalWCMatrix.inversed().transformPoint(scaleDir); - const s = pLC.angleXY(); - const t = Math.asin(clamp(pLC.z, -1, 1)); - const fa = resultMatrix.transformPoint(scaleDir.unit()); - const fb = resultMatrix.transformPoint(scaleDir.unit().negated()); - const newCenter = V3.lerp(fa, fb, 0.5); - console.log(scaleDir.sce, s, t, fa, fb, "newCenter", newCenter.sce); - return new EllipsoidSurface(newCenter, m4.transformVector2(this.f1, this.center), m4.transformVector2(this.f2, this.center), m4 - .transformVector2(this.f3, this.center) - .times(m4.isMirroring() ? -1 : 1)); - } - isInsideOut() { - return this.f1.cross(this.f2).dot(this.f3) < 0; - } - flipped() { - return new EllipsoidSurface(this.center, this.f1, this.f2, this.f3.negated(), this.uMin, this.uMax, -this.vMax, -this.vMin); - } - normalUVFunc() { - // ugh - // paramtric ellipsoid point q(a, b) - // normal1 == (dq(a, b) / da) X (dq(a, b) / db) (cross product of partial derivatives) - // normal1 == cos b * (f2 X f3 * cos b * cos a + f3 X f1 * cos b * sin a + f1 X f2 * sin b) - return (a, b) => { - const { f1, f2, f3 } = this; - const normal = f2 - .cross(f3) - .times(Math.cos(b) * Math.cos(a)) - .plus(f3.cross(f1).times(Math.cos(b) * Math.sin(a))) - .plus(f1.cross(f2).times(Math.sin(b))) - //.times(Math.cos(b)) - .unit(); - return normal; - }; - } - normalP(p) { - return this.pLCNormalWCMatrix - .transformVector(this.matrixInverse.transformPoint(p)) - .unit(); - } - normalUV(u, v) { - return this.pLCNormalWCMatrix.transformVector(V3.sphere(u, v)).unit(); - } - uvPFunc() { - return (pWC) => { - const pLC = this.matrixInverse.transformPoint(pWC); - const alpha = abs(pLC.angleXY()); - const beta = Math.asin(clamp(pLC.z, -1, 1)); - assert(isFinite(alpha)); - assert(isFinite(beta)); - return new V3(alpha, beta, 0); - }; - } - pUVFunc() { - // this(a, b) = f1 cos a cos b + f2 sin a cos b + f2 sin b - return (alpha, beta) => { - return this.matrix.transformPoint(V3.sphere(alpha, beta)); - }; - } - isSphere() { - return (eq(this.f1.length(), this.f2.length()) && - eq(this.f2.length(), this.f3.length()) && - eq(this.f3.length(), this.f1.length()) && - this.f1.isPerpendicularTo(this.f2) && - this.f2.isPerpendicularTo(this.f3) && - this.f3.isPerpendicularTo(this.f1)); - } - isVerticalSpheroid() { - return (eq(this.f1.length(), this.f2.length()) && - this.f1.isPerpendicularTo(this.f2) && - this.f2.isPerpendicularTo(this.f3) && - this.f3.isPerpendicularTo(this.f1)); - } - mainAxes() { - // q(a, b) = f1 cos a cos b + f2 sin a cos b + f3 sin b - // q(s, t, u) = s * f1 + t * f2 + u * f3 with s² + t² + u² = 1 - // (del q(a, b) / del a) = f1 (-sin a) cos b + f2 cos a cos b - // (del q(a, b) / del b) = f1 cos a (-sin b) + f2 sin a (-sin b) + f2 cos b - // del q(s, t, u) / del a = -t f1 + s f2 - // (del q(a, b) / del a) DOT q(a, b) == 0 - // (f1 (-sin a) cos b + f2 cos a cos b) DOT (f1 cos a cos b + f2 sin a cos b + f2 sin b) == 0 - // (del q(a, b) / del b) DOT q(a, b) == 0 - // (f1 cos a (-sin b) + f2 sin a (-sin b) + f2 cos b) DOT (f1 cos a cos b + f2 sin a cos b + f2 sin b) == 0 - // Solve[ - // (f1 (-sin a) cos b + f2 cos a cos b) * (f1 cos a cos b + f2 sin a cos b + f2 sin b) = 0, - // (f1 cos a (-sin b) + f2 sin a (-sin b) + f2 cos b) * (f1 cos a cos b + f2 sin a cos b + f2 sin b) = 0}, a, b] - const { f1, f2, f3 } = this; - if (eq0(f1.dot(f2)) && eq0(f2.dot(f3)) && eq0(f3.dot(f1))) { - return this; - } - //const f = ([a, b], x?) => { - // const sinA = Math.sin(a), cosA = Math.cos(a), sinB = Math.sin(b), cosB = Math.cos(b) - // const centerToP = V3.add(f1.times(cosA * cosB), f2.times(sinA * cosB), f3.times(sinB)) - // const centerToPdelA = f1.times(-sinA * cosB).plus(f2.times(cosA * cosB)) - // const centerToPdelB = V3.add(f1.times(cosA * -sinB), f2.times(sinA * -sinB), f3.times(cosB)) - // x && console.log(centerToP.sce, centerToPdelA.sce, centerToPdelB.sce) - // return [centerToP.dot(centerToPdelA), centerToP.dot(centerToPdelB)] - //} - //const mainF1Params = newtonIterate(f, [0, 0], 8), mainF1 = this.pUVFunc()(mainF1Params[0], mainF1Params[1]) - //console.log(f(mainF1Params, 1).sce) - //const mainF2Params = newtonIterate(f, this.uvPFunc()(f2.rejectedFrom(mainF1)).toArray(2), 8), - // mainF2 = this.pUVFunc()(mainF2Params[0], mainF2Params[1]) - //console.log(this.normalUVFunc()(mainF2Params[0], mainF2Params[1]).sce) - //assert(mainF1.isPerpendicularTo(mainF2), mainF1, mainF2, mainF1.dot(mainF2), mainF1Params) - //const mainF3Params = this.uvPFunc()(mainF1.cross(mainF2)), mainF3 = this.pUVFunc()(mainF3Params[0], - // mainF3Params[1]) return new EllipsoidSurface(this.center, mainF1, mainF2, mainF3) - const { U, SIGMA } = this.matrix.svd3(); - assert(SIGMA.isDiagonal()); - assert(U.isOrthogonal()); - const U_SIGMA = U.times(SIGMA); - // column vectors of U_SIGMA - const [mainF1, mainF2, mainF3] = arrayFromFunction(3, (i) => new V3(U_SIGMA.m[i], U_SIGMA.m[i + 4], U_SIGMA.m[i + 8])); - return new EllipsoidSurface(this.center, mainF1, mainF2, mainF3); - } - containsPoint(p) { - return eq0(this.implicitFunction()(p)); - } - boundsFunction() { - return (a, b) => between(a, 0, PI) && between(b, -PI, PI); - } - volume() { - return (4 / 3) * Math.PI * this.f1.dot(this.f2.cross(this.f3)); - } - loopContainsPoint(loop, pWC) { - if (!this.containsPoint(pWC)) - return PointVsFace$1.OUTSIDE; - assertVectors(pWC); - assert(Edge$1.isLoop(loop)); - const pLCXY = this.matrixInverse.transformPoint(pWC).xy(); - const testLine = new EllipseCurve$2(this.center, this.f3, pLCXY.likeO() ? this.f2 : this.matrix.transformVector(pLCXY.unit())); - if (P3$1.normalOnAnchor(this.f2.unit(), this.center).containsPoint(pWC)) { - return loop.some((edge) => edge.curve.containsPoint(pWC) && - fuzzyBetween(edge.curve.pointT(pWC), edge.minT, edge.maxT)) - ? PointVsFace$1.ON_EDGE - : PointVsFace$1.OUTSIDE; - } - return Surface$1.loopContainsPointEllipse(loop, pWC, testLine); - } - surfaceAreaApprox() { - // See https://en.wikipedia.org/wiki/Ellipsoid#Surface_area - const mainAxes = this.mainAxes(), a = mainAxes.f1.length(), b = mainAxes.f2.length(), c = mainAxes.f3.length(); - const p = 1.6075; - return (4 * - PI * - Math.pow((Math.pow(a * b, p) + Math.pow(b * c, p) + Math.pow(c * a, p)) / 3, 1 / p)); - } - surfaceArea() { - // See https://en.wikipedia.org/wiki/Ellipsoid#Surface_area - const mainAxes = this.mainAxes(), f1l = mainAxes.f1.length(), f2l = mainAxes.f2.length(), f3l = mainAxes.f3.length(), [c, b, a] = [f1l, f2l, f3l].sort(MINUS); - // https://en.wikipedia.org/w/index.php?title=Spheroid&oldid=761246800#Area - function spheroidArea(a, c) { - if (c < a) { - const eccentricity2 = 1 - Math.pow(c, 2) / Math.pow(a, 2); - const eccentricity = Math.sqrt(eccentricity2); - return (2 * - PI * - Math.pow(a, 2) * - (1 + - ((1 - eccentricity2) / Math.sqrt(eccentricity)) * - Math.atanh(eccentricity))); - } - else { - const eccentricity = Math.sqrt(1 - Math.pow(a, 2) / Math.pow(c, 2)); - return (2 * - PI * - Math.pow(a, 2) * - (1 + (c / a / eccentricity) * Math.asin(eccentricity))); - } - } - if (eq(a, b)) { - return spheroidArea(a, c); - } - else if (eq(b, c)) { - return spheroidArea(b, a); - } - else if (eq(c, a)) { - return spheroidArea(c, b); - } - const phi = Math.acos(c / a); - const kk = (Math.pow(a, 2) * (Math.pow(b, 2) - Math.pow(c, 2))) / (Math.pow(b, 2) * (Math.pow(a, 2) - Math.pow(c, 2))); - const incompleteEllipticInt1 = gaussLegendreQuadrature24((phi) => Math.pow(1 - kk * Math.pow(Math.sin(phi), 2), -0.5), 0, phi); - const incompleteEllipticInt2 = gaussLegendreQuadrature24((phi) => Math.pow(1 - kk * Math.pow(Math.sin(phi), 2), 0.5), 0, phi); - return ((2 * PI * Math.pow(c, 2) + (2 * PI * a * b) / Math.sin(phi)) * - (incompleteEllipticInt2 * Math.pow(Math.sin(phi), 2) + - incompleteEllipticInt1 * Math.pow(Math.cos(phi), 2))); - } - getSeamPlane() { - const plane = P3$1.forAnchorAndPlaneVectors(this.center, this.f1, this.f3); - return plane.normal1.dot(this.f2) < 0 ? plane : plane.flipped(); - } - getExtremePoints() { - return getExtremePointsHelper$1.call(this, new EllipseCurve$2(V3.O, V3.X, V3.Z, -PI / 2, PI / 2)); - } - pointFoot(pWC, startS, startT) { - console.log(pWC.sce); - if (undefined === startS || undefined === startT) { - let pLC1 = this.matrixInverse.transformPoint(pWC).unit(); - if (pLC1.y < 0) - pLC1 = pLC1.negated(); - ({ x: startS, y: startT } = EllipsoidSurface.UNIT.uvP(pLC1)); - } - const dpdu = this.dpdu(); - const dpdv = this.dpdv(); - const [u, v] = newtonIterate(([u, v]) => { - const p = this.pUV(u, v); - console.log([p, p.plus(dpdu(u, v)), p, p.plus(dpdv(u, v))].map(toSource).join() + - ","); - const pUVToPWC = this.pUV(u, v).to(pWC); - return [pUVToPWC.dot(dpdu(u, v)), pUVToPWC.dot(dpdv(u, v))]; - }, [startS, startT], 8, undefined, 0.1); - return new V3(u, v, 0); - } - implicitFunction() { - return (pWC) => { - const pLC = this.matrixInverse.transformPoint(pWC); - return (pLC.length() - 1) * this.normalDir; - }; - } - // = this.inverseMatrix.transformPoint(this.inverseMatrix.transformPoint(pWC).unit()) - didp(pWC) { - // i(pWC) = this.inverseMatrix.transformPoint(pWC).length() - 1 - // chain diff rule - const pLC = this.matrixInverse.transformPoint(pWC); - return this.pLCNormalWCMatrix.transformVector(pLC.unit()); //.times(this.normalDir) - } - /*+ - * An ellipsoid remains an ellipsoid after a perspective transform (as long as it does not intersect the vanishing - * plane. This transforms a matrix with a perspective component into one which would return an identical ellipsoid, - * but with no perspective component. - */ - static unitTransform4(m) { - m.m[15] !== 1 && (m = m.divScalar(m.m[15])); - // X * P = m => X = m * P^-1 - // prettier-ignore - const Pinv = new M4(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -m.m[12], -m.m[13], -m.m[14], 1); - const pn = new V3(m.m[12], m.m[13], m.m[14]), pw = m.m[15]; - const pwSqrMinusPnSqr = Math.pow(pw, 2) - pn.squared(); - if (lt(pwSqrMinusPnSqr, 0)) { - throw new Error("vanishing plane intersects unit sphere"); - } - const c = pn.div(-pwSqrMinusPnSqr); - const scale = pn.times((pw * pn.length()) / (pn.squared() * -pwSqrMinusPnSqr)); - const scale1 = pw / -pwSqrMinusPnSqr; - const scale2 = 1 / sqrt(pwSqrMinusPnSqr); - const rotNX = M4.forSys(pn.unit(), pn.getPerpendicular().unit()); - return M4.product(m, Pinv, M4.translate(c), rotNX, M4.scale(scale1, scale2, scale2), rotNX.transposed()); - } -} -EllipsoidSurface.UNIT = new EllipsoidSurface(V3.O, V3.X, V3.Y, V3.Z); -EllipsoidSurface.prototype.uStep = PI / 32; -EllipsoidSurface.prototype.vStep = PI / 32; - -class PlaneSurface extends ParametricSurface$1 { - constructor(plane, right = plane.normal1.getPerpendicular().unit(), up = plane.normal1.cross(right).unit(), uMin = -100, uMax = 100, vMin = -100, vMax = 100) { - super(uMin, uMax, vMin, vMax); - this.plane = plane; - this.right = right; - this.up = up; - assertInst(P3$1, plane); - assert(this.right.cross(this.up).like(this.plane.normal1)); - this.matrix = M4.forSys(right, up, plane.normal1, plane.anchor); - } - toSource(rounder = (x) => x) { - return callsce.call(undefined, "new PlaneSurface", ...this.getConstructorParameters()); - } - static throughPoints(a, b, c) { - return new PlaneSurface(P3$1.throughPoints(a, b, c)); - } - static forAnchorAndPlaneVectors(anchor, v0, v1, uMin, uMax, vMin, vMax) { - return new PlaneSurface(P3$1.forAnchorAndPlaneVectors(anchor, v0, v1), v0, v1, uMin, uMax, vMin, vMax); - } - isCoplanarTo(surface) { - return (hasConstructor(surface, PlaneSurface) && - this.plane.isCoplanarToPlane(surface.plane)); - } - isTsForLine(line) { - return line.isTsWithPlane(this.plane); - } - like(surface) { - return (hasConstructor(surface, PlaneSurface) && this.plane.like(surface.plane)); - } - pUV(u, v) { - return this.matrix.transformPoint(new V3(u, v, 0)); - } - implicitFunction() { - return (p) => this.plane.distanceToPointSigned(p); - } - isCurvesWithSurface(surface2) { - if (surface2 instanceof PlaneSurface) { - return this.isCurvesWithPlane(surface2.plane); - } - return super.isCurvesWithSurface(surface2); - } - isCurvesWithPlane(plane) { - const result = this.plane.intersectionWithPlane(plane); - return result ? [result] : []; - } - edgeLoopCCW(contour) { - assert(Edge$1.isLoop(contour), "isLoop"); - return isCCW(contour.flatMap((edge) => edge.points()), this.plane.normal1); - } - loopContainsPoint(loop, p) { - const dir = this.right.plus(this.up.times(0.123)).unit(); - const line = new L3$2(p, dir); - const lineOut = dir.cross(this.plane.normal1); - return Surface$1.loopContainsPointGeneral(loop, p, line, lineOut); - } - uvPFunc() { - const matrixInverse = this.matrix.inversed(); - return function (pWC) { - return matrixInverse.transformPoint(pWC); - }; - } - pointFoot(pWC) { - return this.uvP(pWC); - } - normalP(pWC) { - return this.plane.normal1; - } - containsPoint(p) { - return this.plane.containsPoint(p); - } - containsCurve(curve) { - return curve instanceof ImplicitCurve$1 - ? super.containsCurve(curve) - : this.plane.containsCurve(curve); - } - transform(m4) { - return new PlaneSurface(this.plane.transform(m4)); - } - transform4(m4) { - return new PlaneSurface(this.plane.transform(m4)); - } - flipped() { - return new PlaneSurface(this.plane.flipped(), this.right, this.up.negated()); - } - getConstructorParameters() { - return [ - this.plane, - this.right, - this.up, - this.uMin, - this.uMax, - this.vMin, - this.vMax, - ]; - } - dpdu() { - return () => this.right; - } - dpdv() { - return () => this.up; - } - didp(pWC) { - return this.plane.normal1; - } - normalUV() { - return this.plane.normal1; - } -} -PlaneSurface.prototype.uStep = 1e6; -PlaneSurface.prototype.vStep = 1e6; - -class PointProjectedSurface extends ParametricSurface$1 { - constructor(curve, apex, curvePlane, normalDir = 1, uMin = curve.tMin, uMax = curve.tMax, vMin = 0, vMax = 16) { - super(uMin, uMax, vMin, vMax); - this.curve = curve; - this.apex = apex; - this.curvePlane = curvePlane; - this.normalDir = normalDir; - assertInst(Curve$1, curve); - assert(!(curve instanceof L3$2), "use PlaneSurface instead"); - assert(!(curve instanceof EllipseCurve$2), "use ConicSurface instead"); - assert(!(curve instanceof ImplicitCurve$1), "this just seems like a terrible idea"); - assert(new PlaneSurface$1(curvePlane).containsCurve(curve)); - assertVectors(apex); - assert(0 <= vMin); - this.planeProjectionMatrix = M4.projectPlanePoint(apex, curvePlane); - this.uStep = curve.tIncrement; - } - pointFoot(pWC, startU, startV) { - if (undefined === startU || undefined === startV) { - // similar to stP - if (undefined === startU) { - startU = pWC.like(this.apex) - ? 0 - : this.curve.closestTToPoint(this.planeProjectionMatrix.transformPoint(pWC)) * this.normalDir; - } - if (undefined === startV) { - startV = V3.inverseLerp(this.apex, this.curve.at(startU), pWC); - } - } - const f = ([u, v]) => { - const pUVToPWC = this.pUV(u, v).to(pWC); - return [this.dpdu()(u, v).dot(pUVToPWC), this.dpdv()(u).dot(pUVToPWC)]; - }; - const { 0: x, 1: y } = newtonIterate(f, [startU, startV]); - return new V3(x, y, 0); - } - getConstructorParameters() { - return [ - this.curve, - this.apex, - this.curvePlane, - this.normalDir, - this.uMin, - this.uMax, - this.vMin, - this.vMax, - ]; - } - static unitISLineTs(anchor, dir) { - const { x: ax, y: ay, z: az } = anchor; - const { x: dx, y: dy, z: dz } = dir; - // this cone: x² + y² = z² - // line: p = anchor + t * dir1 - // split line equation into 3 component equations, insert into cone equation - // transform to form (a t² + b t + c = 0) and solve with pqFormula - const a = dx * dx + dy * dy - dz * dz; - const b = 2 * (ax * dx + ay * dy - az * dz); - const c = ax * ax + ay * ay - az * az; - // cone only defined for 0 <= z, so filter invalid values - return pqFormula(b / a, c / a).filter((t) => 0 < az + t * dz); - } - equals(obj) { - return (this == obj || - (hasConstructor(obj, PointProjectedSurface) && - this.curve.equals(obj.curve) && - this.apex.equals(this.apex))); - } - like(object) { - if (!this.isCoplanarTo(object)) - return false; - // normals need to point in the same direction (outwards or inwards) for both - return this.normalDir == object.normalDir; - } - loopContainsPoint(contour, p) { - assertVectors(p); - const line = this.apex.like(p) - ? new L3$2(p, this.apex.to(this.curve.at(this.curve.tMin)).unit()) - : L3$2.throughPoints(p, this.apex); - const lineOut = line.dir1.cross(this.curvePlane.normal1); - return Surface$1.loopContainsPointGeneral(contour, p, line, lineOut); - } - isTsForLine(line) { - // transforming line manually has advantage that dir1 will not be renormalized, - // meaning that calculated values t for lineLC are directly transferable to line - const anchorPlane = this.planeProjectionMatrix.transformPoint(line.anchor); - const anchor2Plane = this.planeProjectionMatrix.transformPoint(line.anchor.plus(line.dir1)); - if (anchorPlane.like(anchor2Plane)) { - // line projects onto a point in plane. - // there are either no or infinite intersection points - return []; - } - return this.curve - .isInfosWithLine(anchorPlane, anchorPlane.to(anchor2Plane), undefined, undefined, line.tMin, line.tMax) - .map((info) => info.tOther); - } - /** - * Interestingly, two cones don't need to have parallel dirs to be coplanar. - */ - isCoplanarTo(surface) { - if (this === surface) - return true; - if (!(surface instanceof PointProjectedSurface) || - !this.apex.like(surface.apex)) - return false; - // at this point apexes are equal - return this.containsCurve(surface.curve); - } - containsLine(line) { - if (this.curvePlane.isParallelToLine(line)) { - return false; - } - if (!line.containsPoint(this.apex)) { - return false; - } - const p = this.curvePlane.intersectionWithLine(line); - return this.curve.containsPoint(p); - } - containsCurve(curve) { - if (curve instanceof L3$2) { - return this.containsLine(curve); - } - else if (!(curve instanceof ImplicitCurve$1)) { - const otherCurveOnThisPlane = curve.transform(this.planeProjectionMatrix); - return this.curve.isColinearTo(otherCurveOnThisPlane); - } - else { - return super.containsCurve(curve); - } - } - transform(m4) { - return new PointProjectedSurface(this.curve.transform(m4), m4.transformPoint(this.apex), this.curvePlane.transform(m4), (m4.isMirroring() ? -1 : 1) * this.normalDir, this.uMin, this.uMax, this.vMin, this.vMax); - } - flipped() { - return new PointProjectedSurface(this.curve, this.apex, this.curvePlane, -this.normalDir, -this.uMax, -this.uMin, this.vMin, this.vMax); - } - normalUVFunc() { - const dpdv = this.dpdv(); - return (u) => this.curve - .tangentAt(u * this.normalDir) - .times(this.normalDir) - .cross(dpdv(u)) - .unit(); - } - pUVFunc() { - return (u, v) => { - return this.apex.lerp(this.curve.at(u * this.normalDir), v); - }; - } - dpdu() { - return (u, v) => { - return this.curve.tangentAt(u * this.normalDir).times(v * this.normalDir); - }; - } - dpdv() { - return (u) => { - return this.apex.to(this.curve.at(u * this.normalDir)); - }; - } - containsPoint(pWC) { - return (this.apex.like(pWC) || - this.curve.containsPoint(this.planeProjectionMatrix.transformPoint(pWC))); - } - uvP(pWC) { - const u = pWC.like(this.apex) - ? 0 - : this.curve.pointT(this.planeProjectionMatrix.transformPoint(pWC)); - const v = V3.inverseLerp(this.apex, this.curve.at(u), pWC); - return new V3(u * this.normalDir, v, 0); - } - isCurvesWithSurface(surface) { - if (surface instanceof PlaneSurface$1) { - return this.isCurvesWithPlane(surface.plane); - } - else if (ImplicitSurface$1.is(surface)) { - return ParametricSurface$1.isCurvesParametricImplicitSurface(this, surface, 0.1, 0.1 / this.curvePlane.distanceToPoint(this.apex), 0.02); - } - return super.isCurvesWithSurface(surface); - } - isCurvesWithPlane(plane) { - if (plane.containsPoint(this.apex)) { - if (plane.isParallelToPlane(this.curvePlane)) { - return []; - } - return this.curve - .isTsWithPlane(plane) - .map((t) => L3$2.throughPoints(this.apex, this.curve.at(t))); - } - return [this.curve.transform(M4.projectPlanePoint(this.apex, plane))]; - } -} -PointProjectedSurface.prototype.vStep = 256; - -class NURBSSurface extends ParametricSurface$1 { - constructor( - /** - * Control points in u-major order. I.e. the first pointCountU points are a NURBS. - */ - points, knotsU, knotsV, degreeU, degreeV, uMin = knotsU[degreeU], uMax = knotsU[knotsU.length - degreeU - 1], vMin = knotsV[degreeV], vMax = knotsV[knotsV.length - degreeV - 1]) { - super(uMin, uMax, vMin, vMax); - this.points = points; - this.knotsU = knotsU; - this.knotsV = knotsV; - this.degreeU = degreeU; - this.degreeV = degreeV; - const pointCountU = knotsU.length - 1 - degreeU; - const pointCountV = knotsV.length - 1 - degreeV; - assert(pointCountU * pointCountV == points.length); - assert(degreeU <= degreeV, "degreeU <= degreeV"); - assert(-1 === firstUnsorted(knotsU, MINUS), "knot values must be in ascending order"); - assert(-1 === firstUnsorted(knotsV, MINUS), "knot values must be in ascending order"); - } - getConstructorParameters() { - return [ - this.points, - this.knotsU, - this.knotsV, - this.degreeU, - this.degreeV, - this.uMin, - this.uMax, - this.vMin, - this.vMax, - ]; - } - transform(m4) { - return this.transform4(m4); - } - transform4(m4) { - return new NURBSSurface(this.points.map((p) => m4.timesVector(p)), this.knotsU, this.knotsV, this.degreeU, this.degreeV, this.uMin, this.uMax, this.vMin, this.vMax); - } - pUV(u, v) { - return this.isoparametricU(u).at(v); - } - dpdu() { - return (u, v) => this.isoparametricV(v).tangentAt(u); - } - dpdv() { - return (u, v) => this.isoparametricU(u).tangentAt(v); - } - normalUV(u, v) { - const normal = this.dpdu()(u, v).cross(this.dpdv()(u, v)); - return normal.likeO() ? V3.X : normal.unit(); - } - isoparametricU(u) { - const pointCountU = this.knotsU.length - 1 - this.degreeU; - const pointCountV = this.knotsV.length - 1 - this.degreeV; - return new NURBS$1(arrayFromFunction(pointCountV, (i) => { - return deBoor(this.points.slice(i * pointCountU, (i + 1) * pointCountU), this.degreeU, this.knotsU, u); - }), this.degreeV, this.knotsV, this.vMin, this.vMax); - } - isoparametricV(v) { - const pointCountU = this.knotsU.length - 1 - this.degreeU; - return new NURBS$1(arrayFromFunction(pointCountU, (i) => { - return deBoor(sliceStep(this.points, i, this.points.length, pointCountU, 1), this.degreeV, this.knotsV, v); - }), this.degreeU, this.knotsU, this.uMin, this.uMax); - } - debugInfo() { - const pointCountU = this.knotsU.length - 1 - this.degreeU; - const pointCountV = this.knotsV.length - 1 - this.degreeV; - const grid = []; - for (let u = 0; u < pointCountU; u++) { - for (let v = 0; v < pointCountV; v++) { - const i = v * pointCountU + u; - if (u < pointCountU - 1) { - const j = v * pointCountU + u + 1; - grid.push(this.points[i].p3(), this.points[j].p3()); - } - if (v < pointCountV - 1) { - const j = (v + 1) * pointCountU + u; - grid.push(this.points[i].p3(), this.points[j].p3()); - } - } - } - return { points: this.points.map((p) => p.p3()), lines: grid }; - } - flipped() { - const pointCountU = this.knotsU.length - 1 - this.degreeU; - return new NURBSSurface(arrayFromFunction(this.points.length, (i) => { - const u = i % pointCountU; - return this.points[i - u + (pointCountU - u - 1)]; - }), this.knotsU.map((x) => -x).reverse(), this.knotsV, this.degreeU, this.degreeV, -this.uMax, -this.uMin, this.vMin, this.vMax); - } - isCoplanarTo(surface) { - throw new Error("not implemented"); - } - isTsForLine(line) { - // intersect line with - const startT = 4; - // Once we have a starting t param, there are two options: - // 1. 1-D Newton iterate on (t) -> (distanceFromSurface) - // 2. 3-D Newton iterate on (u, v, t) -> this.pUV(u, v).to(line.at(t)) - // Let's go with 2, because 1 will require doing a nested newton iteration. - const [startU, startV] = this.pointFoot(line.at(startT)); - const [, , t] = newtonIterate(([u, v, t]) => { - console.log("uvt", u, v, t); - const lineP = line.at(t); - return ilog(this.pUV(u, v).to(lineP).toArray()); - }, [startU, startV, startT], 8); - return [t]; - } - pointFoot(pWC, startU, startV) { - const closestPointIndex = indexWithMax(this.points, (p) => -p.p3().distanceTo(pWC)); - const pointCountU = this.knotsU.length - this.degreeU - 1; - const closestPointPos = V(closestPointIndex % pointCountU, (closestPointIndex / pointCountU) | 0); - const start = this.guessUVForMeshPos(closestPointPos.x, closestPointPos.y); - const dpdu = this.dpdu(); - const dpdv = this.dpdv(); - try { - const [u, v] = newtonIterate(([u, v]) => { - // console.log("u,v", u, v) - const pUV = this.pUV(u, v); - const pUVToPWC = pUV.to(pWC); - return [pUVToPWC.dot(dpdu(u, v)), pUVToPWC.dot(dpdv(u, v))]; - }, [start.x, start.y], 16); - return new V3(u, v, 0); - } - catch (e) { - return undefined; - } - } - isCurvesWithPlane(plane) { - throw new Error("Method not implemented."); - } - containsPoint(pWC) { - const foot = this.pointFoot(pWC); - return foot && this.pUV(foot.x, foot.y).like(pWC); - } - loopContainsPoint(contour, point) { - throw new Error("Method not implemented."); - } - guessUVForMeshPos(x, y) { - function eLerp(arr, t, lerp) { - if (0 === t % 1) - return arr[t]; - return lerp(arr[floor(t)], arr[ceil(t)], t % 1); - } - return new V3(clamp(eLerp(this.knotsU, x + (this.degreeU + 1) / 2, lerp), this.uMin, this.uMax), clamp(eLerp(this.knotsV, y + (this.degreeV + 1) / 2, lerp), this.vMin, this.vMax), 0); - } -} -NURBSSurface.prototype.uStep = 1 / 8; -NURBSSurface.prototype.vStep = 1 / 8; -function getInterval(degree, knots, t) { - for (let s = degree; s < knots.length - 1 - degree; s++) { - if (t >= knots[s] && t <= knots[s + 1]) { - return s; - } - } - throw new Error(t + " " + knots); -} -function deBoor(points, degree, knots, t) { - // find s (the spline segment) for the [t] value provided - const s = getInterval(degree, knots, t); - const v = Vector.pack(points, new Float64Array(points.length * 4)); - // l (level) goes from 1 to the curve degree + 1 - for (let l = 1; l <= degree; l++) { - // build level l of the pyramid - for (let i = s; i > s - degree - 1 + l; i--) { - const alpha = (t - knots[i]) / (knots[i + degree + 1 - l] - knots[i]); - // interpolate each component - for (let d = 0; d < 4; d++) { - v[i * 4 + d] = (1 - alpha) * v[(i - 1) * 4 + d] + alpha * v[i * 4 + d]; - } - } - } - return new Vector(v.slice(s * 4, s * 4 + 4)); -} - -/** - * In general: the z-dir shadow volume of a face is the integral: SURFACE_INTEGRAL[p in face] (normal(p).z * p.z) dp - * In general: the centroid of the z-dir shadow volume of a face is the integral: - * SURFACE_INTEGRAL[p in face] ((p schur (1, 1, 0.5)) * normal(p).z * p.z) dp - * dividing the z component by 2 is usually done at the very end - */ -const ZDirVolumeVisitor = { - [ConicSurface.name](edges) { - console.log(this); - const dpdu = this.dpdu(); - const dpdv = this.dpdv(); - // INT[edge.at; edge.bT] (at(t) DOT dir) * (at(t) - at(t).projectedOn(dir) / 2).z dt - const totalVolume = sum(edges.map((edgeWC) => { - const curveWC = edgeWC.curve; - if (curveWC instanceof EllipseCurve || - curveWC instanceof HyperbolaCurve || - curveWC instanceof ParabolaCurve) { - const f = (curveT) => { - const at = curveWC.at(curveT), tangentWC = curveWC.tangentAt(curveT); - const uvOfPWC = this.uvP(at); - // INTEGRATE [0; atUV.y] (dpdu(atUV.x, t) X dpdv(atUV.x)).z * pUV(atUV.x, t).z dt - // dpdu(u, v) === t * dpdu(s, 1) - // => INTEGRATE [0; atUV.y] (t * dpdu(atUV.x, 1) X dpdv(atUV.x)).z * pUV(atUV.x, t).z dt - // => (dpdu(atUV.x, 1) X dpdv(atUV.x)).z * INTEGRATE [0; atUV.y] t * pUV(atUV.x, t).z dt - // pUV(u, v) === t * (pUV(s, 1) - center) + center - // => (dpdu(atUV.x, 1) X dpdv(atUV.x)).z - // * INTEGRATE [0; atUV.y] t² * (pUV(atUV.x, t) - center).z + t * center.z dt - // => (dpdu(atUV.x, 1) X dpdv(atUV.x)).z - // * INTEGRATE [0; atUV.y] t² * (pUV(atUV.x, t) - center).z + t * center.z dt - // => (dpdu(atUV.x, 1) X dpdv(atUV.x)).z - // * (1/3 t³ pUV(atUV.x, 1).z + 1/2 t² center.z)[0; atUV.y] - const du = -M4.forSys(dpdu(uvOfPWC.x, uvOfPWC.y), dpdv(uvOfPWC.x)) - .inversed() - .transformVector(tangentWC).x; - const factor = (Math.pow(uvOfPWC.y, 3) / 3) * - (this.pUV(uvOfPWC.x, 1).z - this.center.z) + - (Math.pow(uvOfPWC.y, 2) / 2) * this.center.z; - const actual = dpdu(uvOfPWC.x, factor).cross(dpdv(uvOfPWC.x)).z; - return actual * du; - }; - const val = glqInSteps(f, edgeWC.aT, edgeWC.bT, 1); - return val; - } - else if (curveWC instanceof L3) { - return 0; - } - else { - throw new Error(); - } - })); - const centroidZX2Parts = edges.map((edgeWC) => { - const curveWC = edgeWC.curve; - if (curveWC instanceof EllipseCurve || - curveWC instanceof HyperbolaCurve || - curveWC instanceof ParabolaCurve) { - const f = (curveT) => { - const at = curveWC.at(curveT), tangentWC = curveWC.tangentAt(curveT); - const uvOfPWC = this.uvP(at); - // INTEGRATE [0; atUV.y] dpdu(atUV.x, t) X dpdv(atUV.x, t) * pUV(atUV.x, t).z dt - // dpdv is constant with respect to t - // => (dpdu(atUV.x, t) X dpdv(atUV.x, t)).z - // * (INTEGRATE [0; atUV.y] t * pUV(atUV.x, t) * pUV(atUV.x, t).z dt) - // dpdu(u, v) === t * dpdu(s, 1) - // pUV(u, v) === t * (pUV(s, 1) - center) + center - // INTEGRATE [0; atUV.y] t * pUV(atUV.x, t) * pUV(atUV.x, t).z dt - // = INTEGRATE [0; atUV.y] t * - // (t * (pUV(s, 1) - center) + center) * - // (t (pUV(s, 1) - center).z + center.z) dt - // = INTEGRATE [0; atUV.y] t³ (pUV(s, 1) - center) * (pUV(s, 1) - center).z - // + t² ((pUV(s, 1) - center) * center.z + (pUV(s, 1) - center).z * center) - // + t center center.z dt - // = (1/4 t^4 (pUV(s, 1) - center) * (pUV(s, 1) - center).z - // (1/3 t³ ((pUV(s, 1) - center) * center.z + (pUV(s, 1) - center).z * center) - // (1/2 t² center center.z dt)[0; atUV.y] - const pUVS1V = this.pUV(uvOfPWC.x, 1).minus(this.center); - const factor = V3.add(pUVS1V.times((1 / 4) * Math.pow(uvOfPWC.y, 4) * pUVS1V.z + - (1 / 3) * Math.pow(uvOfPWC.y, 3) * this.center.z), this.center.times((1 / 3) * Math.pow(uvOfPWC.y, 3) * pUVS1V.z + - (1 / 2) * Math.pow(uvOfPWC.y, 2) * this.center.z)); - const partialCentroid = factor.times(dpdu(uvOfPWC.x, 1).cross(dpdv(uvOfPWC.x)).z); - const ds = -M4.forSys(dpdu(uvOfPWC.x, uvOfPWC.y), dpdv(uvOfPWC.x)) - .inversed() - .transformVector(tangentWC).x; - return partialCentroid.times(ds); - }; - return glqV3(f, edgeWC.aT, edgeWC.bT); - } - else if (curveWC instanceof L3) { - return V3.O; - } - else { - throw new Error(); - } - }); - const centroid = V3.add(...centroidZX2Parts) - .schur(new V3(1, 1, 0.5)) - .div(totalVolume); - return { volume: totalVolume, centroid: centroid }; - }, - [PlaneSurface.name](edges) { - const r1 = this.right; - const u1 = this.up; - const c = this.plane.anchor; - assert(r1.hasLength(1)); - assert(u1.hasLength(1)); - assert(r1.isPerpendicularTo(u1)); - const volumeAndCentroidZX2Parts = edges.map((edgeWC) => { - const curveWC = edgeWC.curve; - if (curveWC instanceof L3) { - // split shadow volume into two triangle shadow volumes and use the same logic as for mesh triangles: - function triangleShadowVolumeAndCentroid(a, b, c) { - const ab = b.minus(a), ac = c.minus(a); - const normal = ab.cross(ac); - const faceCentroid = V3.add(a, b, c).div(3); - return [ - (faceCentroid.z * normal.z) / 2, - V3.add(a.times(2 * a.z + b.z + c.z), b.times(a.z + 2 * b.z + c.z), c.times(a.z + b.z + 2 * c.z)).times(normal.z), - ]; - } - const a = edgeWC.a, b = edgeWC.b; - const as = a.dot(r1); - const bs = b.dot(r1); - const aBase = this.pUV(as, 0); - const bBase = this.pUV(bs, 0); - const [v1, c1] = triangleShadowVolumeAndCentroid(a, b, aBase); - const [v2, c2] = triangleShadowVolumeAndCentroid(bBase, aBase, b); - return [v1 + v2, c1.plus(c2).div(24)]; - } - else if (curveWC instanceof ImplicitCurve) { - throw new Error(); - } - else { - const sliceAreaAndCentroidZX2TimesDs = (curveT) => { - const p = curveWC.at(curveT); - const s = p.dot(r1); - const t = p.dot(u1); - const area = t * c.z + s * t * r1.z + (1 / 2) * Math.pow(t, 2) * u1.z; - const ds = -curveWC.tangentAt(curveT).dot(r1); - return [ - area * ds, - ...V3.add(c.times(area), r1.times(c.z * s * t + r1.z * Math.pow(s, 2) * t + (1 / 2) * s * Math.pow(t, 2) * u1.z), u1.times((1 / 2) * c.z * Math.pow(t, 2) + - (1 / 2) * r1.z * s * Math.pow(t, 2) + - (1 / 3) * Math.pow(t, 3) * u1.z)).times(ds), - ]; - }; - const [vol, cx, cy, cz] = glqArray(sliceAreaAndCentroidZX2TimesDs, edgeWC.aT, edgeWC.bT, 4); - return [ - vol * this.plane.normal1.z, - new V3(cx, cy, cz).times(this.plane.normal1.z), - ]; - } - }); - return mergeVolumeAndCentroidZX2Parts(volumeAndCentroidZX2Parts); - }, - /** - * Generic implementation. - */ - [ParametricSurface.name](edges) { - const dpdu = this.dpdu(); - const dpdv = this.dpdv(); - const volume = edges.map((edgeWC) => { - const curveWC = edgeWC.curve; - if (curveWC instanceof ImplicitCurve) { - throw new Error(); - } - else { - const sliceAreaAndCentroidZX2TimesDs = (curveT) => { - // use curve.tangent not edge.tangent, reverse edges are handled by the integration boundaries - const pWC = curveWC.at(curveT), tangentWC = curveWC.tangentAt(curveT); - const uvOfPWC = this.uvP(pWC); - const slice = (t) => { - const p = this.pUV(uvOfPWC.x, t); - const normal = dpdu(uvOfPWC.x, t).cross(dpdv(uvOfPWC.x, t)); - return p.z * normal.z; - }; - const sliceIntegral0ToPWCT = glqInSteps(slice, 0, uvOfPWC.y, 1); - // const dt = tangentWC.dot(scalingVector) - const dt = -M4.forSys(dpdu(uvOfPWC.x, uvOfPWC.y), dpdv(uvOfPWC.x, uvOfPWC.y)) - .inversed() - .transformVector(tangentWC).x; - const sliceAreaTimesDs = sliceIntegral0ToPWCT * dt; - const slice2 = (t) => { - const p = this.pUV(uvOfPWC.x, t); - const normal = dpdu(uvOfPWC.x, t).cross(dpdv(uvOfPWC.x, t)); - return p.times(p.z * normal.z); - }; - const sliceIntegral0ToPWCT2 = glqV3(slice2, 0, uvOfPWC.y); - // const dt = tangentWC.dot(scalingVector) - const sliceCentroidZX2TimesDs = sliceIntegral0ToPWCT2.times(dt); - return [sliceAreaTimesDs, ...sliceCentroidZX2TimesDs.toArray()]; - }; - const [vol, cx, cy, cz] = glqArray(sliceAreaAndCentroidZX2TimesDs, edgeWC.aT, edgeWC.bT, 4); - return [vol, new V3(cx, cy, cz)]; - } - }); - return mergeVolumeAndCentroidZX2Parts(volume); - }, - /** - * at(t) - * |\ ^ - * | \ at(t).projectedOn(dir1) \ dir1 - * | \ \ - * | \ at(t).rejectedFrom(dir1) = b - * | | - * |___| - * z = 0 - * - * - * A = ((at(t) + at(t).rejectedFrom(dir1)) / 2).z * at(t).projectedOn(dir1).lengthXY() - * scaling = tangentAt(t) DOT dir1.cross(V3.Z).unit() - */ - [ProjectedCurveSurface.name](edges) { - if (V3.Z.cross(this.dir).likeO()) - return { volume: 0, centroid: V3.O }; - // normalize this.dir so it always points up - const upDir1 = this.dir.toLength(Math.sign(this.dir.z) || 1); - const scalingVector = V3.Z.cross(upDir1).unit(); - // the length of the base of the trapezoid is calculated by dotting with the baseVector - const baseVector = upDir1.rejectedFrom(V3.Z).unit(); - // INT[edge.at; edge.bT] (at(t) DOT dir1) * (at(t) - at(t).projectedOn(dir) / 2).z - const volume = edges.map((edgeWC) => { - if (edgeWC.curve instanceof L3) { - return [0, V3.O]; - } - else if (edgeWC.curve instanceof ImplicitCurve) { - return [0, V3.O]; - // const { points, tangents } = edgeWC.curve - // const minT = edgeWC.minT, - // maxT = edgeWC.maxT - // let sum = 0 - // const start = Math.ceil(minT + NLA_PRECISION) - // const end = Math.floor(maxT - NLA_PRECISION) - // for (let i = start; i <= end; i++) { - // const at = points[i], - // tangent = tangents[i] - // const area = (at.z + at.rejectedFrom1(upDir1).z) / 2 * at.projectedOn(upDir1).dot(baseVector) - // const scale = tangent.dot(scalingVector) - // sum += area * scale - // } - // const f = (t: number) => { - // const at = edgeWC.curve.at(t), - // tangent = edgeWC.curve.tangentAt(t) - // const area = (at.z + at.rejectedFrom1(upDir1).z) / 2 * at.projectedOn(upDir1).dot(baseVector) - // const scale = tangent.dot(scalingVector) - // return area * scale - // } - // sum += f(minT) * (start - minT - 0.5) - // sum += f(maxT) * (maxT - end - 0.5) - // return sum * Math.sign(edgeWC.deltaT()) - } - else { - const f = (curveT) => { - // use curve.tangent not edge.tangent, reverse edges are handled by the integration boundaries - const at = edgeWC.curve.at(curveT), tangent = edgeWC.curve.tangentAt(curveT); - const b = at.rejectedFrom1(upDir1); - const area = (at.z * b.to(at).dot(baseVector)) / 2 + - (b.z * b.to(at).dot(baseVector)) / 2; - const areaCentroidA = V3.add(at.xy(), b, at).times((at.z * b.to(at).dot(baseVector)) / 2 / 3); - const areaCentroidB = V3.add(at.xy(), b, b.xy()).times((b.z * b.to(at).dot(baseVector)) / 2 / 3); - const scale = tangent.dot(scalingVector); - return [ - area * scale, - ...areaCentroidA.plus(areaCentroidB).times(scale).schur(V(1, 1, 2)), - ]; - }; - const [vol, cx, cy, cz] = glqArray(f, edgeWC.aT, edgeWC.bT, 4); - return [vol, new V3(cx, cy, cz)]; - } - }); - return mergeVolumeAndCentroidZX2Parts(volume); - }, - // volume does scale linearly, so this could be done in the local coordinate system - // however, shear matrices lead to point-to-plane distances having to be calculated along a vector other than - // the plane normal - [RotatedCurveSurface.name](edges) { - const dpdu = this.dpdu(); - const dpdv = this.dpdv(); - const totalVolume = sum(edges.map((edgeWC) => { - const curveWC = edgeWC.curve; - const f = (curveT) => { - const pWC = curveWC.at(curveT), tangentWC = curveWC.tangentAt(curveT); - const uvOfPWC = this.uvP(pWC); - const pLC = this.matrixInverse.transformPoint(pWC); - const dpdvAtS0 = this instanceof RotatedCurveSurface - ? this.curve.tangentAt(uvOfPWC.y) - : V(-pLC.z, 0, pLC.lengthXY()); - // const slice = (phi: number) => { - // const p = this.pUV(phi, uvOfPWC.y) - // const normal = dpdu(phi, uvOfPWC.y).cross(dpdv(phi, uvOfPWC.y)) - // return p.z * normal.z - // } - // const z = this.curve.at(uvOfPWC.y).z - // const r = this.curve.at(uvOfPWC.y).lengthXY() - // const pz = - // this.f1.z * r * cos(s) + - // this.f2.z * r * sin(s) + - // this.f3.z * z + - // this.center.z - // const dpdux = this.f1.x * r * -sin(s) + this.f2.x * r * cos(s) - // const dpduy = this.f1.y * r * -sin(s) + this.f2.y * r * cos(s) - // const dpdvx = this.f1.x * dr * cos(s) + this.f2.x * dr * sin(s) + this.f3.x * dz - // const dpdvy = this.f1.y * dr * cos(s) + this.f2.y * dr * sin(s) + this.f3.y * dz - // const normalz = dpdux * dpdvy - dpduy * dpdvx - // result = pz * normalz - const r = pLC.lengthXY(), z = pLC.z; - const dr = dpdvAtS0.x; - const dz = dpdvAtS0.z; - const a = this.matrix.X.z * r, b = this.matrix.Y.z * r, c = this.matrix.Z.z * z + this.matrix.O.z; - const t0 = (this.matrix.X.x * this.matrix.Y.y - - this.matrix.X.y * this.matrix.Y.x) * - r * - dr; - const t1 = (this.matrix.Y.x * this.matrix.X.y - - this.matrix.Y.y * this.matrix.X.x) * - r * - dr; - const t2 = (this.matrix.X.x * this.matrix.X.y - - this.matrix.X.y * this.matrix.X.x) * - r * - dr; - const t3 = (this.matrix.Y.x * this.matrix.Y.y - - this.matrix.Y.y * this.matrix.Y.x) * - r * - dr; - const t4 = (this.matrix.Y.x * this.matrix.Z.y - - this.matrix.Y.y * this.matrix.Z.x) * - r * - dz; - const t5 = (this.matrix.X.x * this.matrix.Z.y - - this.matrix.X.y * this.matrix.Z.x) * - r * - dz; - const sliceIntegral = (p) => { - return ((6 * (c * (-t0 + t1) + a * t4 - b * t5) * p + - 3 * - (3 * b * t0 - b * t1 + a * (t2 - t3) + 4 * c * t5) * - cos(p) + - 3 * - (3 * a * t1 - a * t0 - b * (t2 - t3) + 4 * c * t4) * - sin(p) + - 3 * (a * t5 - b * t4 + c * (t2 - t3)) * cos(2 * p) + - 3 * (a * t4 + b * t5 + c * (t0 + t1)) * sin(2 * p) + - (a * (t2 - t3) - b * (t0 + t1)) * cos(3 * p) + - (a * (t0 + t1) + b * (t2 - t3)) * sin(3 * p)) / - 12); - }; - const dt = M4.forSys(dpdu(uvOfPWC.x, uvOfPWC.y), dpdv(uvOfPWC.x, uvOfPWC.y)) - .inversed() - .transformVector(tangentWC).y; - const sliceIntegral0ToPWCS = sliceIntegral(uvOfPWC.x); //- sliceIntegral(0) //(always 0) - const result = sliceIntegral0ToPWCS * dt; - return result; - }; - return gaussLegendreQuadrature24(f, edgeWC.aT, edgeWC.bT); - })); - // calc centroid: - const centroidZX2Parts = edges.map((edgeWC) => { - const f = (curveT) => { - const curveWC = edgeWC.curve; - const pWC = curveWC.at(curveT), tangentWC = curveWC.tangentAt(curveT); - const uvOfPWC = this.uvP(pWC); - const slice = (phi) => { - const p = this.pUV(phi, uvOfPWC.y); - const normal = dpdu(phi, uvOfPWC.y).cross(dpdv(phi, uvOfPWC.y)); - return p.times(p.z * normal.z); - }; - const sliceIntegral0ToPWCS = glqV3(slice, 0, uvOfPWC.x); - const dt = M4.forSys(dpdu(uvOfPWC.x, uvOfPWC.y), dpdv(uvOfPWC.x, uvOfPWC.y)) - .inversed() - .transformVector(tangentWC).y; - const result = sliceIntegral0ToPWCS.times(dt); - return result; - }; - return glqV3(f, edgeWC.aT, edgeWC.bT); - }); - const centroid = V3.add(...centroidZX2Parts) - .schur(new V3(1, 1, 0.5)) - .div(totalVolume); - return { volume: totalVolume, centroid: centroid }; - }, -}; -ZDirVolumeVisitor[EllipsoidSurface.name] = - ZDirVolumeVisitor[RotatedCurveSurface.name]; -function glqV3(f, startT, endT) { - return gaussLegendre24Xs - .reduce((val, currVal, index) => { - const x = startT + ((currVal + 1) / 2) * (endT - startT); - return val.plus(f(x).times(gaussLegendre24Weights[index])); - }, V3.O) - .times((endT - startT) / 2); -} -function glqArray(f, startT, endT, numEls = 3) { - const result = new Array(numEls).fill(0); - for (let i = 0; i < 24; i++) { - const x = startT + ((gaussLegendre24Xs[i] + 1) / 2) * (endT - startT); - const fx = f(x); - for (let j = 0; j < numEls; j++) { - result[j] += fx[j] * gaussLegendre24Weights[i]; - } - } - for (let j = 0; j < numEls; j++) { - result[j] *= (endT - startT) / 2; - } - return result; -} -function mergeVolumeAndCentroidZX2Parts(volumeAndCentroidZX2Parts) { - const volume = volumeAndCentroidZX2Parts.reduce((result, [volume]) => result + volume, 0); - const weightedCentroid = V3.add(...volumeAndCentroidZX2Parts.map(([, centroidZX2]) => centroidZX2)).schur(new V3(1, 1, 0.5)); - return { volume, centroid: weightedCentroid.div(volume) }; -} - -const CalculateAreaVisitor = { - [ConicSurface.name](edges) { - const dpdu = this.dpdu(); - const dpdv = this.dpdv(); - // calculation cannot be done in local coordinate system, as the area doesnt scale proportionally - const totalArea = sum(edges.map((edge) => { - if (edge.curve instanceof EllipseCurve || - edge.curve instanceof HyperbolaCurve || - edge.curve instanceof ParabolaCurve) { - const f = (t) => { - const at = edge.curve.at(t), tangentWC = edge.tangentAt(t); - const uvOfPWC = this.uvP(at); - // INTEGRATE [0; atUV.y] - // dpdu(atUV.x, t) X dpdv(atUV.x, t) - // dt - // dpdv is constant with respect to t - // => dpdv(atUV.x, 0) X (INTEGRATE [0; atUV.y] dpdu(atUV.x, t) dt) - // dpdu(u, v) === v * dpdu(u, 1) - // => dpdv(atUV.x, 0) X (1/2 t² dpdu(atUV.x, 1))[0; atUV.y] - // => dpdv(atUV.x, 0) X dpdu(atUV.x, atUV.y² / 2) - const du = -M4.forSys(dpdu(uvOfPWC.x, uvOfPWC.y), dpdv(uvOfPWC.x)) - .inversed() - .transformVector(tangentWC).x; - return (dpdu(uvOfPWC.x, Math.pow(uvOfPWC.y, 2) / 2) - .cross(dpdv(uvOfPWC.x)) - .length() * du); - }; - return glqInSteps(f, edge.aT, edge.bT, 1); - } - else if (edge.curve instanceof L3) { - return 0; - } - else { - throw new Error(); - } - })); - return totalArea * this.normalDir; - }, - [PlaneSurface.name](edges) { - let totalArea = 0; - const r1 = this.right, u1 = this.up; - for (const edge of edges) { - let edgeArea; - const curve = edge.curve; - if (curve instanceof L3) { - edgeArea = - ((edge.a.dot(u1) + edge.b.dot(u1)) / 2) * edge.b.to(edge.a).dot(r1); - } - else if (curve instanceof EllipseCurve) { - // INTEGRATE[aT; bT] (curve.at(t) * u1) * (tangent(t) * r1) dt - // INTEGRATE[aT; bT] (u1 f1 cos t + u1 f2 sin t + u1 c) * (r1 f1 (-sin t) + r1 f2 cos t) dt - const { f1, f2, center } = curve; - const a = u1.dot(f1), b = u1.dot(f2), c = u1.dot(center), d = r1.dot(f1), e = r1.dot(f2); - function fArea(t) { - return (0.25 * - (2 * (-b * d + a * e) * t + - 4 * c * d * cos(t) + - 4 * c * e * sin(t) + - (a * d - b * e) * cos(2 * t) + - (b * d + a * e) * sin(2 * t))); - } - edgeArea = -(fArea(edge.bT) - fArea(edge.aT)); - } - else if (curve instanceof ImplicitCurve) { - throw new Error("implement for implicitCurve"); - } - else { - const dir1 = u1; - assertf(() => dir1.hasLength(1)); - // INT[aT; bT] at(t) * dir1 * tangentAt(t).rejectedFrom(dir1) dt - const f = (curveT) => { - const at = curve.at(curveT); - const tangent = curve.tangentAt(curveT); - const ds = r1.dot(tangent); - const t = u1.dot(at); - return ds * t; - }; - edgeArea = glqInSteps(f, edge.aT, edge.bT, 3); - } - totalArea += edgeArea; - } - assert(isFinite(totalArea)); - return totalArea; - }, - [RotatedCurveSurface.name](edges, canApproximate = true) { - const f1 = this.matrix.X, f2 = this.matrix.Y, f3 = this.matrix.Z; - const likeVerticalSpheroid = eq(f1.length(), f2.length()) && - f1.isPerpendicularTo(f2) && - f2.isPerpendicularTo(f3) && - f3.isPerpendicularTo(f1); - const areaParts = edges.map((edgeWC, ei) => { - console.log("edge", ei, edgeWC.sce); - const curveWC = edgeWC.curve; - if (edgeWC.curve instanceof ImplicitCurve) { - throw new Error(); - } - else { - if (likeVerticalSpheroid) { - const f = (curveT) => { - const pWC = curveWC.at(curveT), tangent = curveWC.tangentAt(curveT); - const pLC = this.matrixInverse.transformPoint(pWC); - const { x: angleXY, y: t } = this.uvP(pWC); - const arcRadius = this.matrix.transformVector(pLC.xy()).length(); - const arcLength = angleXY * arcRadius; - const dpdv = this.dpdv()(angleXY, t).unit(); - const scaling = dpdv.dot(tangent); - return arcLength * scaling; - }; - return glqInSteps(f, edgeWC.aT, edgeWC.bT, 1); - } - else { - const dpdu = this.dpdu(), dpdv = this.dpdv(); - const f2 = (curveT) => { - const pWC = curveWC.at(curveT), tangentWC = curveWC.tangentAt(curveT); - const uvPWC = this.uvP(pWC); - const slice = (phi) => { - //return this.dpdu()(phi, st.y).length() * this.dpdv()(phi, st.y).length() - return dpdu(phi, uvPWC.y).cross(dpdv(phi, uvPWC.y)).length(); - }; - // we need to do a coordinate transform from curveT to dt, as that is what we are integrating - const dt = M4.forSys(dpdu(uvPWC.x, uvPWC.y), dpdv(uvPWC.x, uvPWC.y)) - .inversed() - .transformVector(tangentWC).y; - return glqInSteps(slice, 0, uvPWC.x, 1) * dt; - }; - return glqInSteps(f2, edgeWC.aT, edgeWC.bT, 1); - } - } - }); - return sum(areaParts); - }, - [ProjectedCurveSurface.name](edges) { - // calculation cannot be done in local coordinate system, as the area doesn't scale proportionally - const thisDir1 = this.dir.unit(); - const totalArea = sum(edges.map((edge) => { - if (edge.curve instanceof L3) { - return 0; - } - else if (edge.curve instanceof ImplicitCurve) { - const { points, tangents } = edge.curve; - const minT = edge.minT, maxT = edge.maxT; - let sum = 0; - const start = ceil(minT + NLA_PRECISION); - const end = floor(maxT - NLA_PRECISION); - for (let i = start; i <= end; i++) { - const at = points[i], tangent = tangents[i]; //.toLength(edge.curve.stepSize) - const scaling = this.normalP(at).cross(thisDir1).unit().dot(tangent); - sum += at.dot(thisDir1) * scaling; - } - const f = (t) => { - const at = edge.curve.at(t), tangent = edge.curve.tangentAt(t); - const scaling = this.normalP(at).cross(thisDir1).unit().dot(tangent); - return at.dot(thisDir1) * scaling; - }; - sum += f(minT) * (start - minT - 0.5); - sum += f(maxT) * (maxT - end - 0.5); - return sum * sign(edge.deltaT()); - } - else { - const f = (t) => { - const at = edge.curve.at(t); - const tangent = edge.tangentAt(t); - const scaling = tangent.rejected1Length(thisDir1); - return at.dot(thisDir1) * scaling; - }; - const val = glqInSteps(f, edge.aT, edge.bT, 1); - const sign = Math.sign(this.normalP(edge.a) - .cross(this.dir) - .dot(edge.curve.tangentAt(edge.aT))); - assert(0 !== sign); - return val * sign; - } - })); - console.log("totalArea", totalArea); - return totalArea; - }, -}; -CalculateAreaVisitor[EllipsoidSurface.name] = - CalculateAreaVisitor[RotatedCurveSurface.name]; - -/** - * Create a surface by projecting a curve in a direction. - * - * @param curve The curve to project. - * @param offset The direction and distance to project curve. - * @param flipped Whether the surface's default orientation (normal = curve tangent cross offset) should be flipped. - */ -function projectCurve(curve, offset, flipped) { - if (curve instanceof L3$1) { - const surfaceNormal = offset.cross(curve.dir1).toLength(flipped ? -1 : 1); - return new PlaneSurface$2(P3$2.normalOnAnchor(surfaceNormal, curve.anchor)); - } - if (curve instanceof EllipseCurve$1) { - const curveDir = flipped ? offset : offset.negated(); - return new CylinderSurface$2(curve, curveDir.unit(), undefined, undefined); - } - if (curve instanceof BezierCurve$1 || curve instanceof XiEtaCurve$1) { - const curveDir = offset.times(flipped ? 1 : -1); - return new ProjectedCurveSurface$2(curve, curveDir, undefined, undefined, flipped ? 0 : -1, flipped ? 1 : 0); - } - throw new Error(); -} -/** - * Create a surface by projecting a curve onto a point. - */ -function projectPointCurve(curve, tMin = curve.tMin, tMax = curve.tMax, p, flipped) { - if (curve instanceof L3$1) { - const up = curve.anchor.to(p).rejectedFrom(curve.dir1); - return PlaneSurface$2.forAnchorAndPlaneVectors(curve.anchor, curve.dir1, up.unit(), tMin, tMax, 0, up.length()); - } - else if (curve instanceof EllipseCurve$1) { - // flip f2 by default - const factor = -1 * (flipped ? -1 : 1); - return new ConicSurface$1(p, curve.f1.times(factor), curve.f2, p.to(curve.center), tMin, tMax, 0, 1); - } - else { - throw new Error("projectPointCurve not implemented for " + curve.constructor.name); - } -} -/** - * Create a surface by rotating a curve in the XZ-plane, with X > 0, around the Z-axis according to the right-hand rule. - * @param curve The curve to rotate. - * @param tMin The minimum value for t for which the surface should be defined. - * @param tMax The maximum value for t for which the surface should be defined. - * @param angle How much the curve should be rotated. sMin/sMax will be be 0/angle. - * @param flipped Whether the surface's default orientation (normal = curve tangent cross rotation tangent) should be - * flipped. - */ -function rotateCurve(curve, tMin = curve.tMin, tMax = curve.tMax, angle, flipped) { - assertf(() => new PlaneSurface$2(P3$2.ZX).containsCurve(curve)); - if (curve instanceof L3$1) { - if (curve.dir1.isParallelTo(V3.Z)) { - if (eq0(curve.anchor.x)) { - return undefined; - //throw new Error('Cannot rotate curve colinear to Z axis.') - } - const baseEllipse = new EllipseCurve$1(V3.O, curve.anchor.xy(), curve.anchor.xy().getPerpendicular(), 0, angle); - // if curve.dir1 is going up (+Z), it the cylinder surface should face inwards - const factor = (curve.dir1.z > 0 ? -1 : 1) * (flipped ? -1 : 1); - const [zMin, zMax] = [ - curve.at(tMin).z * factor, - curve.at(tMax).z * factor, - ].sort(MINUS); - return new CylinderSurface$2(baseEllipse, V3.Z.times(factor), 0, angle, zMin, zMax); - } - if (curve.at(tMin).xy().dot(curve.dir1) * - curve.at(tMax).xy().dot(curve.dir1) < - 0) { - throw new Error("line cannot cross the Z axis in the [tMin, tMax] interval, as conic surfaces cannot have an hourglass shape."); - } - if (curve.dir1.isPerpendicularTo(V3.Z)) { - // if line.dir1 is pointing aways from V3.Z, then the surface should face up - const factor = (curve.at(lerp(tMin, tMax, 0.5)).dot(curve.dir1) > 0 ? 1 : -1) * - (flipped ? -1 : 1); - return new PlaneSurface$2(new P3$2(V3.Z.times(factor), curve.anchor.z * factor)); - } - else { - // apex is intersection of segment with Z-axis - const a = curve.at(tMin), b = curve.at(tMax); - const apexZ = a.z - (a.x * (b.z - a.z)) / (b.x - a.x); - const apex = new V3(0, 0, apexZ); - const factor = -(a.x > b.x ? -1 : 1) * (flipped ? -1 : 1); - const s = new ConicSurface$1(apex, new V3(curve.dir1.lengthXY(), 0, 0), new V3(0, curve.dir1.lengthXY(), 0), new V3(0, 0, (a.x > b.x ? -1 : 1) * curve.dir1.z), 0, angle, 0, 1); - return factor > 0 ? s : s.flipped(); - } - } - if (curve instanceof EllipseCurve$1) { - const a = curve.at(tMin), b = curve.at(tMax); - const ell = curve.rightAngled(); - const f1Perp = ell.f1.isPerpendicularTo(V3.Z), f2Perp = ell.f2.isPerpendicularTo(V3.Z); - if (L3$1.Z.containsPoint(ell.center) && (f1Perp || f2Perp)) { - flipped = flipped == a.z > b.z; - let width = ell.f1.length(), height = ell.f2.length(); - if (ell.f1.isParallelTo(V3.Z)) { - [width, height] = [height, width]; - } - return EllipsoidSurface$1.forABC(width, (!flipped ? 1 : -1) * width, height, ell.center); - } - else { - const s = new RotatedCurveSurface$1(curve, M4.IDENTITY, tMin, tMax); - return s; - } - } - throw new Error(); -} -var B2T; -(function (B2T) { - /** - * Create a [BRep] of an axis-aligned box width starting at the origin and extending into +XYZ space. - * @param width x-direction size. - * @param height y-direction size. - * @param depth z-direction size. - * @param name - */ - function box(width = 1, height = 1, depth = 1, name = "box" + getGlobalId$1()) { - assertNumbers(width, height, depth); - assert("string" === typeof name); - const baseVertices = [ - new V3(0, 0, 0), - new V3(0, height, 0), - new V3(width, height, 0), - new V3(width, 0, 0), - ]; - const generator = callsce("B2T.box", width, height, depth, name); - return B2T.extrudeVertices(baseVertices, P3$2.XY.flipped(), new V3(0, 0, depth), name, generator); - } - B2T.box = box; - function puckman(radius, rads, height, name = "puckman" + getGlobalId$1()) { - assertf(() => lt(0, radius)); - assertf(() => lt(0, rads) && le(rads, TAU)); - assertf(() => lt(0, height)); - const edges = StraightEdge$1.chain([ - V3.O, - new V3(radius, 0, 0), - new V3(radius, 0, height), - new V3(0, 0, height), - ], true); - return B2T.rotateEdges(edges, rads, name); - } - B2T.puckman = puckman; - function registerVertexName(map, name, p) { - // TODO - if (!Array.from(map.keys()).some((p2) => p2.like(p))) { - map.set(p, name); - } - } - B2T.registerVertexName = registerVertexName; - /** - * Create a [BRep] by projecting a number of edges in a direction. - * @param baseFaceEdges - * @param baseFacePlane - * @param offset - * @param name - * @param gen - * @param infoFactory - */ - function extrudeEdges(baseFaceEdges, baseFacePlane = P3$2.XY, offset = V3.Z, name = "extrude" + getGlobalId$1(), gen, infoFactory) { - baseFaceEdges = fixEdges(baseFaceEdges); - //Array.from(combinations(baseFaceEdges.length)).forEach(({i, j}) => { - // assertf(() => !Edge.edgesIntersect(baseFaceEdges[i], baseFaceEdges[j]), baseFaceEdges[i].sce + - // baseFaceEdges[j].sce) }) - assertf(() => Edge$2.isLoop(baseFaceEdges)); - // TODO checks.. - //if (offset.dot(baseFacePlane.normal1) > 0) { - // baseFacePlane = baseFacePlane.flipped() - //} - const vertexNames = new Map(); - const basePlaneSurface = new PlaneSurface$2(baseFacePlane); - //assert(basePlaneSurface.edgeLoopCCW(baseFaceEdges), 'edges not CCW on baseFacePlane') - const translationMatrix = M4.translate(offset); - const topEdges = baseFaceEdges.map((edge) => edge.transform(translationMatrix, "top")); - const edgeCount = baseFaceEdges.length; - const bottomInfo = infoFactory && infoFactory.extrudeBottom(basePlaneSurface, baseFaceEdges); - const bottomFace = new PlaneFace$1(basePlaneSurface, baseFaceEdges, [], name + "Bottom", bottomInfo); - const topFaceEdges = topEdges.map((edge) => edge.flipped()).reverse(); - const topSurface = new PlaneSurface$2(baseFacePlane.flipped().translated(offset)); - const topInfo = infoFactory && infoFactory.extrudeBottom(topSurface, topFaceEdges); - const topFace = new PlaneFace$1(topSurface, topFaceEdges, [], name + "Top", topInfo); - baseFaceEdges.forEach((edge) => B2T.registerVertexName(vertexNames, edge.name + "A", edge.a)); - topFaceEdges.forEach((edge) => B2T.registerVertexName(vertexNames, edge.name + "A", edge.a)); - const ribs = arrayFromFunction(edgeCount, (i) => StraightEdge$1.throughPoints(baseFaceEdges[i].a, topEdges[i].a, name + "Rib" + i)); - const faces = baseFaceEdges.map((edge, i) => { - const faceName = name + "Wall" + i; - const j = (i + 1) % edgeCount; - const faceEdges = [ - baseFaceEdges[i].flipped(), - ribs[i], - topEdges[i], - ribs[j].flipped(), - ]; - const surface = projectCurve(edge.curve, offset, edge.reversed); - const info = infoFactory && infoFactory.extrudeWall(i, surface, faceEdges); - return Face$1.create(surface, faceEdges, undefined, faceName, info); - }); - faces.push(bottomFace, topFace); - gen = - gen || - callsce("B2T.extrudeEdges", baseFaceEdges, baseFacePlane, offset, name); - return new BRep$1(faces, baseFacePlane.normal1.dot(offset) > 0, gen, vertexNames); - } - B2T.extrudeEdges = extrudeEdges; - function cylinder(radius = 1, height = 1, rads = TAU, name = "cylinder" + getGlobalId$1()) { - const vertices = [ - new V3(0, 0, 0), - new V3(radius, 0, 0), - new V3(radius, 0, height), - new V3(0, 0, height), - ]; - return rotateEdges(StraightEdge$1.chain(vertices, true), rads, name); - } - B2T.cylinder = cylinder; - function cone(radius = 1, height = 1, rads = TAU, name = "cone" + getGlobalId$1()) { - const vertices = [ - new V3(0, 0, 0), - new V3(radius, 0, height), - new V3(0, 0, height), - ]; - return rotateEdges(StraightEdge$1.chain(vertices, true), rads, name); - } - B2T.cone = cone; - function sphere(radius = 1, name = "sphere" + getGlobalId$1(), rot = TAU) { - const ee = new PCurveEdge$1(new EllipseCurve$1(V3.O, new V3(0, 0, -radius), new V3(radius, 0, 0)), new V3(0, 0, -radius), new V3(0, 0, radius), 0, PI, undefined, new V3(radius, 0, 0), new V3(-radius, 0, 0)); - const generator = callsce("B2T.sphere", radius, name, rot); - return rotateEdges([StraightEdge$1.throughPoints(ee.b, ee.a), ee], rot, name, generator); - } - B2T.sphere = sphere; - /** - * Create a [[BRep]] of a menger sponge. - * @param res 0: just a cube, 1: every cube face has one hole, 2: 9 holes, etc - * @param name - */ - function menger(res = 2, name = "menger" + getGlobalId$1()) { - let result = B2T.box(1, 1, 1); - if (0 == res) - return result; - const punch = B2T.box(1 / 3, 1 / 3, 2) - .translate(1 / 3, 1 / 3, -1 / 2) - .flipped(); - function recurse(steps, m4) { - result = result.and(punch.transform(m4)); - if (steps > 1) { - const scaled = m4.times(M4.scale(1 / 3, 1 / 3, 1)); - for (let i = 0; i < 9; i++) { - if (4 == i) - continue; - recurse(steps - 1, scaled.times(M4.translate(i % 3, (i / 3) | 0, 0))); - } - } - } - recurse(res, M4.IDENTITY); - recurse(res, M4.YZX); - recurse(res, M4.ZXY); - return result; - } - B2T.menger = menger; - function menger2(res = 2, name = "menger" + getGlobalId$1()) { - if (0 == res) - return B2T.box(1, 1, 1); - const punch = B2T.box(1 / 3, 1 / 3, 2) - .translate(1 / 3, 1 / 3, -1 / 2) - .flipped(); - const stencilFaces = []; - function recurse(steps, m4) { - stencilFaces.push(...punch.transform(m4).faces); - if (steps > 1) { - const scaled = m4.times(M4.scale(1 / 3, 1 / 3, 1)); - for (let i = 0; i < 9; i++) { - if (4 == i) - continue; - recurse(steps - 1, scaled.times(M4.translate(i % 3, (i / 3) | 0, 0))); - } - } - } - recurse(res, M4.IDENTITY); - const stencil = new BRep$1(stencilFaces, true); - return B2T.box(1, 1, 1, name) - .and(stencil) - .and(stencil.transform(M4.YZX)) - .and(stencil.transform(M4.ZXY)); - } - B2T.menger2 = menger2; - /** - * Create a [BRep] of a torus. - * @param rSmall The radius to the surface of the torus. - * @param rLarge The radius from the origin to the inside of the torus. - * @param rads - * @param name - */ - function torus(rSmall, rLarge, rads = TAU, name = "torus" + getGlobalId$1()) { - assertNumbers(rSmall, rLarge, rads); - assertf(() => rLarge > rSmall); - const curves = [ - EllipseCurve$1.semicircle(rSmall, new V3(rLarge, 0, 0)), - EllipseCurve$1.semicircle(-rSmall, new V3(rLarge, 0, 0)), - ]; - const baseEdges = curves.map((c) => PCurveEdge$1.forCurveAndTs(c, 0, Math.PI).rotateX(PI / 2)); - return B2T.rotateEdges(baseEdges, rads, name); - } - B2T.torus = torus; - /** - * Create a [BRep] by smoothly rotating edges around Z. - * baseLoop should be CCW on XZ plane for a bounded BRep - */ - function rotateEdges(baseLoop, totalRads, name = "rotateEdges" + getGlobalId$1(), generator, infoFactory) { - assert(baseLoop.every((e) => new PlaneSurface$2(P3$2.ZX).containsCurve(e.curve))); - assert(!eq(PI, totalRads) || PI == totalRads); // URHGJ - assertf(() => lt(0, totalRads) && le(totalRads, TAU)); - totalRads = snap(totalRads, TAU); - assertf(() => Edge$2.isLoop(baseLoop)); - const basePlane = new PlaneSurface$2(P3$2.ZX.flipped()).edgeLoopCCW(baseLoop) - ? new PlaneSurface$2(P3$2.ZX.flipped()) - : new PlaneSurface$2(P3$2.ZX); - // const rotationSteps = ceil((totalRads - NLA_PRECISION) / PI) - // const angles = rotationSteps == 1 ? [-PI, -PI + totalRads] : [-PI, 0, totalRads - PI] - const open = !eq(totalRads, 2 * PI); - const baseRibCurves = baseLoop.map((edge) => { - const a = edge.a, radius = a.lengthXY(); - if (!eq0(radius)) { - return new EllipseCurve$1(V(0, 0, a.z), V(radius, 0, 0), V(0, radius, 0)); - } - return undefined; - }); - const baseSurfaces = baseLoop.map((edge) => { - const s = rotateCurve(edge.curve, edge.minT, edge.maxT, PI, edge.deltaT() > 0); - const t = lerp(edge.aT, edge.bT, 0.5); - s && - assert(edge - .tangentAt(t) - .cross(V3.Y) - .dot(s.normalP(edge.curve.at(t))) < 0); - return s; - }); - let stepStartEdges = baseLoop, stepEndEdges; - const faces = []; - for (let rot = 0; rot < totalRads; rot += PI) { - const aT = 0, bT = min(totalRads - rot, PI); - const rotation = M4.rotateZ(rot + bT); - stepEndEdges = - rot + bT == TAU - ? baseLoop - : baseLoop.map((edge) => edge.transform(rotation)); - const ribs = arrayFromFunction(baseLoop.length, (i) => { - const a = stepStartEdges[i].a, radius = a.lengthXY(); - const b = stepEndEdges[i].a; - if (!eq0(radius)) { - const curve = 0 === rot ? baseRibCurves[i] : baseRibCurves[i].rotateZ(rot); - return new PCurveEdge$1(curve, a, b, aT, bT, undefined, curve.tangentAt(aT), curve.tangentAt(bT), name + "rib" + i); - } - return undefined; - }); - for (let edgeIndex = 0; edgeIndex < baseLoop.length; edgeIndex++) { - if (baseSurfaces[edgeIndex]) { - const edge = stepStartEdges[edgeIndex]; - const ipp = (edgeIndex + 1) % baseLoop.length; - const faceEdges = [ - stepStartEdges[edgeIndex].flipped(), - !eq0(edge.a.x) && ribs[edgeIndex], - stepEndEdges[edgeIndex], - !eq0(edge.b.x) && ribs[ipp].flipped(), - ].filter((x) => x); - const surface = 0 === rot - ? baseSurfaces[edgeIndex] - : baseSurfaces[edgeIndex].rotateZ(rot); - const info = infoFactory && - infoFactory.extrudeWall(edgeIndex, surface, faceEdges, undefined); - faces.push(Face$1.create(surface, faceEdges, undefined, name + "Wall" + edgeIndex, info)); - } - } - stepStartEdges = stepEndEdges; - } - if (open) { - const endFaceEdges = Edge$2.reversePath(stepEndEdges); - const infoStart = infoFactory && infoFactory.rotationStart(basePlane, baseLoop, undefined); - const infoEnd = infoFactory && - infoFactory.rotationEnd(basePlane.flipped().rotateZ(totalRads), endFaceEdges, undefined); - faces.push(new PlaneFace$1(basePlane, baseLoop, undefined, name + "start", infoStart), new PlaneFace$1(basePlane.flipped().rotateZ(totalRads), endFaceEdges, undefined, name + "end", infoEnd)); - } - const infiniteVolume = new PlaneSurface$2(P3$2.ZX).edgeLoopCCW(baseLoop); - return new BRep$1(faces, infiniteVolume, generator); - } - B2T.rotateEdges = rotateEdges; - /** - * loop should be CCW on XZ plane for a bounded BRep - */ - //export function rotateEdgesUnsplit(loop: Edge[], rads: raddd, name: string): BRep { - // assert(Edge.isLoop(loop)) - // const rotationMatrix = M4.rotateZ(rads) - // const open = !eq(rads, 2 * PI) - // const endEdges = open ? loop.map(edge => edge.transform(rotationMatrix)) : loop - // const edgeCount = loop.length - // const ribs = arrayFromFunction(edgeCount, i => { - // const a = loop[i].a, radius = a.lengthXY() - // const b = endEdges[i].a - // if (!eq0(radius)) { - // const curve = new EllipseCurve(V(0, 0, a.z), V(-radius, 0, 0), V(0, -radius, 0)) - // const aT = -PI, bT = -PI + rads - // return new PCurveEdge(curve, a, b, aT, bT, undefined, curve.tangentAt(aT), curve.tangentAt(bT), name - // + 'rib' + i) } }) const faces = loop.map((edge, i) => { const ipp = (i + 1) % edgeCount console.log('ljl', i, - // ipp, ribs) const faceEdges = [ edge.flipped(), !eq0(edge.a.x) && ribs[i], endEdges[i], !eq0(edge.b.x) && - // ribs[ipp].flipped()].filter(x => x) if (edge instanceof StraightEdge) { const line = edge.curve let surface if - // (line.dir1.isParallelTo(V3.Z)) { if (eq0(edge.a.x)) { return } let flipped = edge.a.z > edge.b.z surface = new - // CylinderSurface(ribs[i].curve, !flipped ? V3.Z : V3.Z.negated()) } else if - // (line.dir1.isPerpendicularTo(V3.Z)) { let flipped = edge.a.x > edge.b.x let surface = new PlaneSurface(new - // P3(V3.Z, edge.a.z)) if (!flipped) surface = surface.flipped() if (!open) { const hole = flipped ? !eq0(edge.b.x) - // && ribs[ipp].flipped() : !eq0(edge.a.x) && ribs[i] return new PlaneFace(surface, [flipped ? ribs[i] : - // ribs[ipp].flipped()], hole && [[hole]]) } return new PlaneFace(surface, faceEdges) } else { // apex is - // intersection of segment with Z-axis let a = edge.a, b = edge.b let apexZ = a.z - a.x * (b.z - a.z) / (b.x - a.x) - // let apex = new V3(0, 0, apexZ) let flipped = edge.a.z > edge.b.z surface = - // ConicSurface.atApexThroughEllipse(apex, ribs[a.x > b.x ? i : ipp].curve as EllipseCurve, !flipped ? 1 : -1) - // } return Face.create(surface, faceEdges) } if (edge.curve instanceof EllipseCurve) { let flipped = undefined - // let ell = edge.curve.rightAngled() let f1Perp = ell.f1.isPerpendicularTo(V3.Z), f2Perp = - // ell.f2.isPerpendicularTo(V3.Z) if (L3.Z.containsPoint(ell.center) && (f1Perp || f2Perp)) { let f3length = f1Perp - // ? ell.f1.length() : ell.f2.length() if (flipped) { f3length *= -1 } let surface = new - // EllipsoidSurface(ell.center, ell.f1, ell.f2, ell.f1.cross(ell.f2).toLength(f3length)) return new - // RotationFace(surface, faceEdges) } } else { assert(false, edge) } }).filter(x => x) if (open) { const - // endFaceEdges = endEdges.map(edge => edge.flipped()).reverse() faces.push( new PlaneFace(new - // PlaneSurface(P3.ZX.flipped()), loop), new PlaneFace(new PlaneSurface(P3.ZX.rotateZ(rads)), endFaceEdges)) } - // return new BRep(faces, undefined) } - function quaffle() { - const baseK = B2T.sphere(1).translate(0, 1.7).flipped(); - //const baseK = B2T.box().scale(0.2).translate(0, 0.95).flipped() - // const vs = B2T.DODECAHEDRON_VERTICES.concat( - // B2T.DODECAHEDRON_FACE_VERTICES.map(fis => fis - // .map(vi => B2T.DODECAHEDRON_VERTICES[vi]) - // .reduce((a,b) => a.plus(b), V3.O) - // .unit())) - const ss = new BRep$1(B2T.TETRAHEDRON_VERTICES.flatMap((v) => baseK.rotateAB(V3.Y, v).faces), false); - //return ss - return B2T.sphere().and(ss); - } - B2T.quaffle = quaffle; - function extrudeFace(face, dir) { - return new BRep$1(extrudeEdges(face.contour, face.surface.plane, dir) - .faces.slice(0, -2) - .concat(face, face.translate(dir.x, dir.y, dir.z).flipped(), face.holes.flatMap((hole) => extrudeEdges(hole, face.surface.plane.flipped(), dir).faces.slice(0, -2))), false); - } - B2T.extrudeFace = extrudeFace; - function loadFonts() { - return loadFont("fonts/FiraSansMedium.woff").then((font) => (B2T.defaultFont = font)); - } - B2T.loadFonts = loadFonts; - const loadedFonts = new Map(); - function loadFont(fontPath) { - return new Promise(function (resolve, reject) { - const font = loadedFonts.get(fontPath); - if (font) { - resolve(font); - } - else { - load(fontPath, function (err, f) { - if (err) { - reject(err); - } - else { - loadedFonts.set(fontPath, f); - resolve(f); - } - }); - } - }); - } - B2T.loadFont = loadFont; - function loadFontsAsync(callback) { - if (B2T.defaultFont) { - callback(); - } - else { - load("fonts/FiraSansMedium.woff", function (err, font) { - if (err) { - throw new Error("Could not load font: " + err); - } - else { - B2T.defaultFont = font; - callback(); - } - }); - } - } - B2T.loadFontsAsync = loadFontsAsync; - /** - * Create the [BRep] of a string rendered in a font. - * @param text - * @param size - * @param depth - * @param font An opentype.js font. - */ - function text(text, size, depth = 1, font = B2T.defaultFont) { - const path = font.getPath(text, 0, 0, size); - const subpaths = []; - path.commands.forEach((c) => { - if (c.type == "M") { - subpaths.push([]); - } - getLast(subpaths).push(c); - }); - const loops = subpaths.map((sp) => { - const path = new Path(); - path.commands = sp; - const loop = Edge$2.reversePath(edgePathFromSVG$1(path.toPathData(13))).map((e) => e.mirrorY()); - assert(Edge$2.isLoop(loop)); - return loop; - }); - const faces = Face$1.assembleFacesFromLoops(loops, new PlaneSurface$2(P3$2.XY), PlaneFace$1); - const generator = callsce("B2T.text", text, size, depth); - return BRep$1.join(faces.map((face) => B2T.extrudeFace(face, V(0, 0, -depth))), generator); - } - B2T.text = text; - function minorityReport() { - const a = B2T.sphere(); - const b = B2T.text("LEO CROW", 64, 128) - .scale(0.1 / 32) - .translate(-0.5, -0.05, 1.2) - .flipped(); - const c = B2T.sphere(0.98); - return a.and(b).plus(c); - } - B2T.minorityReport = minorityReport; - function whatever() { - const iso = icosahedron(); - const numbersBRep = BRep$1.join(iso.faces.map((face, i) => { - const numberBRep = text("" + (i + 1), 0.4, -2); - const centroid = face.contour - .map((edge) => edge.a) - .reduce((a, b) => a.plus(b), V3.O) - .div(3); - const sys = M4.forSys(face.contour[0].aDir, centroid.cross(face.contour[0].aDir), centroid.unit(), centroid); - return numberBRep.transform(sys.times(M4.translate(-numberBRep.getAABB().size().x / 2, -0.1, -0.04))); - })); - const s = sphere(0.9); - //return iso.and(numbersBRep) - return iso.and(s).and(numbersBRep); - //return numbersBRep - } - B2T.whatever = whatever; - function whatever3() { - const t = B2T.torus(1, 2); - return B2T.box(5, 5, 2).translate(-2.5, -2.5).minus(t); - } - B2T.whatever3 = whatever3; - function d20() { - const iso = icosahedron(); - const numbersBRep = BRep$1.join(iso.faces.map((face, i) => { - const numberBRep = text("" + (i + 1), 0.4, -2); - const centroid = face.contour - .map((edge) => edge.a) - .reduce((a, b) => a.plus(b), V3.O) - .div(3); - const sys = M4.forSys(face.contour[0].aDir, centroid.cross(face.contour[0].aDir), centroid.unit(), centroid); - return numberBRep.transform(sys.times(M4.translate(-numberBRep.getAABB().size().x / 2, -0.1, -0.04))); - })); - const s = sphere(0.9); - //return iso.and(numbersBRep) - return iso.and(s).and(numbersBRep); - //return numbersBRep - } - B2T.d20 = d20; - function rotStep(edges, totalRadsOrAngles, countO) { - const angles = "number" === typeof totalRadsOrAngles - ? arrayFromFunction(countO, (i) => ((i + 1) / countO) * totalRadsOrAngles) - : totalRadsOrAngles; - const count = angles.length; - const open = !eq(TAU, getLast(angles)); - const ribs = [ - edges, - ...angles.map((phi) => { - if (eq(TAU, phi)) { - return edges; - } - const matrix = M4.rotateZ(phi); - return edges.map((edge) => edge.transform(matrix)); - }), - ]; - const horizontalEdges = arrayFromFunction(count, (i) => { - const ipp = (i + 1) % (count + 1); - return arrayFromFunction(edges.length, (j) => { - if (!eq0(edges[j].a.lengthXY())) { - return StraightEdge$1.throughPoints(ribs[i][j].a, ribs[ipp][j].a); - } - return undefined; - }); - }); - const faces = []; - let face; - edges.forEach((edge, i) => { - const ipp = (i + 1) % edges.length; - // for straight edges perpendicular to the Z-axis, we only create one face. - if (edge instanceof StraightEdge$1 && - edge.curve.dir1.isPerpendicularTo(V3.Z)) { - const flipped = edge.a.x > edge.b.x; - const surface = new PlaneSurface$2(flipped ? new P3$2(V3.Z, edge.a.z) : new P3$2(V3.Z.negated(), -edge.a.z)); - if (open) { - const faceEdges = []; - if (!eq0(edge.a.x)) { - faceEdges.push(...arrayFromFunction(count, (j) => horizontalEdges[j][i])); - } - faceEdges.push(ribs[count][i]); - if (!eq0(edge.b.x)) { - faceEdges.push(...arrayFromFunction(count, (j) => horizontalEdges[count - j - 1][ipp].flipped())); - } - faceEdges.push(edge.flipped()); - face = new PlaneFace$1(surface, faceEdges); - } - else { - const contour = flipped - ? arrayFromFunction(count, (j) => horizontalEdges[j][i]) - : arrayFromFunction(count, (j) => horizontalEdges[count - j - 1][ipp].flipped()); - let hole; - if (flipped && !eq0(edge.b.x)) { - hole = arrayFromFunction(count, (j) => horizontalEdges[count - j - 1][ipp].flipped()); - } - else if (!flipped && !eq0(edge.a.x)) { - hole = arrayFromFunction(count, (j) => horizontalEdges[j][i]); - } - face = new PlaneFace$1(surface, contour, hole ? [hole] : []); - } - faces.push(face); - return; - } - else if (edge instanceof StraightEdge$1) { - if (eq0(edge.a.lengthXY()) && eq0(edge.b.lengthXY())) { - return; - } - } - for (let r = 0; r < count; r++) { - const rpp = (r + 1) % (count + 1); - const faceEdges = [ - ribs[r][i].flipped(), - horizontalEdges[r][i], - ribs[rpp][i], - horizontalEdges[r][ipp] && horizontalEdges[r][ipp].flipped(), - ].filter((x) => x); - let surface; - if (edge instanceof StraightEdge$1) { - surface = new PlaneSurface$2(P3$2.throughPoints(faceEdges[0].a, faceEdges[1].a, faceEdges[2].a)); - } - else { - const maxX = edges[i].getAABB().max.x; - const phi = angles[r], prevPhi = 0 == r ? 0 : angles[r - 1]; - const offset = V3.polar(maxX, prevPhi).to(V3.polar(maxX, phi)); - surface = projectCurve(ribs[r][i].curve, offset, false); - } - faces.push(Face$1.create(surface, faceEdges)); - } - }); - if (open) { - const endFaceEdges = ribs[count].map((edge) => edge.flipped()).reverse(); - const endFace = new PlaneFace$1(new PlaneSurface$2(P3$2.ZX.rotateZ(getLast(angles))), endFaceEdges); - faces.push(new PlaneFace$1(new PlaneSurface$2(P3$2.ZX.flipped()), edges), endFace); - } - return new BRep$1(faces, new PlaneSurface$2(P3$2.ZX).edgeLoopCCW(edges)); - } - B2T.rotStep = rotStep; - function fixEdges(edges) { - return edges.flatMap((edge) => { - const c = edge.curve; - if (c instanceof EllipseCurve$1 && c.tMin === -PI && c.tMax === PI) { - const splitEdges = edge.minT < 0 && edge.maxT > 0 ? edge.split(0) : [edge]; - return splitEdges.map((edge) => { - if (edge.minT >= 0) { - return createEdge$1(new EllipseCurve$1(c.center, c.f1, c.f2, max(0, c.tMin), c.tMax), edge.a, edge.b, edge.aT, edge.bT, undefined, edge.aDir, edge.bDir, edge.name); - } - else { - // "rotate" the curve - return createEdge$1(new EllipseCurve$1(c.center, c.f1.negated(), c.f2.negated(), c.tMin + PI, min(PI, c.tMax + PI)), edge.a, edge.b, edge.aT + PI, edge.bT + PI, undefined, edge.aDir, edge.bDir, edge.name); - } - }); - } - if (c instanceof BezierCurve$1) { - if (edge.a.like(edge.b)) { - return edge.split(lerp(edge.aT, edge.bT, 0.5)); - } - } - return edge; - }); - } - B2T.fixEdges = fixEdges; - /** - * Create a [BRep] by projecting edges created by joining vertices with straight edges. - * @param baseVertices - * @param baseFacePlane - * @param offset - * @param name - * @param generator - */ - function extrudeVertices(baseVertices, baseFacePlane, offset, name, generator) { - assert(baseVertices.every((v) => v instanceof V3), "baseVertices.every(v => v instanceof V3)"); - assertInst(P3$2, baseFacePlane); - assertVectors(offset); - if (baseFacePlane.normal1.dot(offset) > 0) - baseFacePlane = baseFacePlane.flipped(); - const edges = StraightEdge$1.chain(baseVertices, true); - generator = - generator || - callsce("B2T.extrudeVertices", baseVertices, baseFacePlane, offset, name); - return B2T.extrudeEdges(edges, baseFacePlane, offset, name, generator); - } - B2T.extrudeVertices = extrudeVertices; - /** - * Create a tetrahedron (3 sided pyramid) [BRep]. - * `a`, `b`, `c` and `d` can be in any order. The only constraint is that they cannot be on a common plane. - * The resulting tetrahedron will always have outwards facing faces. - * @param a - * @param b - * @param c - * @param d - * @param name - */ - function tetrahedron(a, b, c, d, name = "tetra" + getGlobalId$1()) { - assertVectors(a, b, c, d); - const dDistance = P3$2.throughPoints(a, b, c).distanceToPointSigned(d); - if (eq0(dDistance)) { - throw new Error("four points are coplanar"); - } - if (dDistance > 0) { - [c, d] = [d, c]; - } - const ab = StraightEdge$1.throughPoints(a, b); - const ac = StraightEdge$1.throughPoints(a, c); - const ad = StraightEdge$1.throughPoints(a, d); - const bc = StraightEdge$1.throughPoints(b, c); - const bd = StraightEdge$1.throughPoints(b, d); - const cd = StraightEdge$1.throughPoints(c, d); - const faces = [ - new PlaneFace$1(PlaneSurface$2.throughPoints(a, b, c), [ab, bc, ac.flipped()], [], name + "abc"), - new PlaneFace$1(PlaneSurface$2.throughPoints(a, d, b), [ad, bd.flipped(), ab.flipped()], [], name + "adb"), - new PlaneFace$1(PlaneSurface$2.throughPoints(b, d, c), [bd, cd.flipped(), bc.flipped()], [], name + "bdc"), - new PlaneFace$1(PlaneSurface$2.throughPoints(c, d, a), [cd, ad.flipped(), ac], [], name + "cda"), - ]; - const gen = callsce("B2T.tetrahedron", a, b, c, d); - return new BRep$1(faces, false, gen); - } - B2T.tetrahedron = tetrahedron; - const b = 1 / GOLDEN_RATIO, c = 2 - GOLDEN_RATIO; - B2T.TETRAHEDRON_VERTICES = [ - new V3(1, 0, -SQRT1_2), - new V3(-1, 0, -SQRT1_2), - new V3(0, -1, SQRT1_2), - new V3(0, 1, SQRT1_2), - ].map((v) => v.unit()); - B2T.DODECAHEDRON_VERTICES = [ - new V3(c, 0, 1), - new V3(-c, 0, 1), - new V3(-b, b, b), - new V3(0, 1, c), - new V3(b, b, b), - new V3(b, -b, b), - new V3(0, -1, c), - new V3(-b, -b, b), - new V3(c, 0, -1), - new V3(-c, 0, -1), - new V3(-b, -b, -b), - new V3(0, -1, -c), - new V3(b, -b, -b), - new V3(b, b, -b), - new V3(0, 1, -c), - new V3(-b, b, -b), - new V3(1, c, 0), - new V3(-1, c, 0), - new V3(-1, -c, 0), - new V3(1, -c, 0), - ].map((v) => v.unit()); - B2T.DODECAHEDRON_FACE_VERTICES = [ - [4, 3, 2, 1, 0], - [7, 6, 5, 0, 1], - [12, 11, 10, 9, 8], - [15, 14, 13, 8, 9], - [14, 3, 4, 16, 13], - [3, 14, 15, 17, 2], - [11, 6, 7, 18, 10], - [6, 11, 12, 19, 5], - [4, 0, 5, 19, 16], - [12, 8, 13, 16, 19], - [15, 9, 10, 18, 17], - [7, 1, 2, 17, 18], - ]; - B2T.OCTAHEDRON_VERTICES = [ - new V3(1, 0, 0), - new V3(-1, 0, 0), - new V3(0, 1, 0), - new V3(0, -1, 0), - new V3(0, 0, 1), - new V3(0, 0, -1), - ]; - B2T.OCTAHEDRON_FACE_VERTICES = [ - [0, 2, 4], - [2, 1, 4], - [1, 3, 4], - [3, 0, 4], - [2, 0, 5], - [1, 2, 5], - [3, 1, 5], - [0, 3, 5], - ]; - const { x: s, y: t } = new V3(1, GOLDEN_RATIO, 0).unit(); - B2T.ICOSAHEDRON_VERTICES = [ - new V3(-s, t, 0), - new V3(s, t, 0), - new V3(-s, -t, 0), - new V3(s, -t, 0), - new V3(0, -s, t), - new V3(0, s, t), - new V3(0, -s, -t), - new V3(0, s, -t), - new V3(t, 0, -s), - new V3(t, 0, s), - new V3(-t, 0, -s), - new V3(-t, 0, s), - ]; - B2T.ICOSAHEDRON_FACE_VERTICES = [ - // 5 faces around point 0 - [0, 11, 5], - [0, 5, 1], - [0, 1, 7], - [0, 7, 10], - [0, 10, 11], - // 5 adjacent faces - [1, 5, 9], - [5, 11, 4], - [11, 10, 2], - [10, 7, 6], - [7, 1, 8], - // 5 faces around point 3 - [3, 9, 4], - [3, 4, 2], - [3, 2, 6], - [3, 6, 8], - [3, 8, 9], - // 5 adjacent faces - [4, 9, 5], - [2, 4, 11], - [6, 2, 10], - [8, 6, 7], - [9, 8, 1], - ]; - /** - * Create a dodecahedron [BRep]. The vertices are on the unit sphere. - */ - function dodecahedron() { - return makePlatonic(B2T.DODECAHEDRON_VERTICES, B2T.DODECAHEDRON_FACE_VERTICES, "B2T.dodecahedron()"); - } - B2T.dodecahedron = dodecahedron; - /** - * Create an octahedron [BRep]. The vertices are on the unit sphere. - */ - function octahedron() { - return makePlatonic(B2T.OCTAHEDRON_VERTICES, B2T.OCTAHEDRON_FACE_VERTICES, "B2T.octahedron()"); - } - B2T.octahedron = octahedron; - /** - * Create an icosahedron [BRep]. The vertices are on the unit sphere. - */ - function icosahedron() { - return makePlatonic(B2T.ICOSAHEDRON_VERTICES, B2T.ICOSAHEDRON_FACE_VERTICES, "B2T.icosahedron()"); - } - B2T.icosahedron = icosahedron; - function makePlatonic(VS, FVIS, generator) { - const edgeMap = new Map(); - const faces = FVIS.map((faceIndexes) => { - const surface = PlaneSurface$2.throughPoints(VS[faceIndexes[0]], VS[faceIndexes[1]], VS[faceIndexes[2]]); - const contour = arrayFromFunction(faceIndexes.length, (i) => { - const ipp = (i + 1) % faceIndexes.length; - const iA = faceIndexes[i], iB = faceIndexes[ipp]; - const iMin = min(iA, iB), iMax = max(iA, iB), edgeID = iMin * VS.length + iMax; - let edge = edgeMap.get(edgeID); - !edge && - edgeMap.set(edgeID, (edge = StraightEdge$1.throughPoints(VS[iMin], VS[iMax]))); - return iA < iB ? edge : edge.flipped(); - }); - return new PlaneFace$1(surface, contour); - }); - return new BRep$1(faces, false, generator); - } - /** - * Create a [BRep] by projecting a number of edges onto a point. - * @param baseEdges The edges forming the base of the pyramid. - * @param apex The tip of the pyramid. - * @param name - */ - function pyramidEdges(baseEdges, apex, name = "pyramid" + getGlobalId$1()) { - assertInst(Edge$2, ...baseEdges); - assertVectors(apex); - const ribs = baseEdges.map((baseEdge) => StraightEdge$1.throughPoints(apex, baseEdge.a)); - const faces = baseEdges.map((baseEdge, i) => { - const faceName = name + "Wall" + i; - const ipp = (i + 1) % baseEdges.length; - const faceEdges = [ribs[i], baseEdge, ribs[ipp].flipped()]; - const surface = projectPointCurve(baseEdge.curve, baseEdge.minT, baseEdge.maxT, apex, baseEdge.deltaT() < 0); - return Face$1.create(surface, faceEdges, undefined, faceName); - }); - const baseSurface = new PlaneSurface$2(P3$2.XY).flipped(); - const bottomFace = Face$1.create(baseSurface, Edge$2.reversePath(baseEdges)); - faces.push(bottomFace); - const generator = callsce("B2T.pyramidEdges", baseEdges, apex, name); - return new BRep$1(faces, false, generator); - } - B2T.pyramidEdges = pyramidEdges; - function fromBPT(bpt) { - const lineRegex = /.+/g; - const readLine = () => lineRegex.exec(bpt)[0]; - const readLineNumbers = () => readLine() - .trim() - .split(/\s+/) - .map((s) => parseFloat(s)); - const numOfPatches = parseInt(readLine()); - const faces = arrayFromFunction(numOfPatches, () => { - const [pointsUCount, pointsVCount] = readLineNumbers(); - const points = Array.from({ length: (pointsUCount + 1) * (pointsVCount + 1) }, () => VV(...readLineNumbers(), 1)); - const surface = new NURBSSurface(points, NURBS$2.bezierKnots(pointsUCount), NURBS$2.bezierKnots(pointsVCount), pointsUCount, pointsVCount, 0, 1, 0, 1); - const edges = [ - edgeForCurveAndTs$1(surface.isoparametricV(0)), - edgeForCurveAndTs$1(surface.isoparametricU(1)), - edgeForCurveAndTs$1(surface.isoparametricV(1)).flipped(), - edgeForCurveAndTs$1(surface.isoparametricU(0)).flipped(), - ]; - return Face$1.create(surface, edges); - }); - return new BRep$1(faces, false); - } - B2T.fromBPT = fromBPT; -})(B2T || (B2T = {})); - -class CustomPlane extends P3$2 { - constructor(anchor, right, up, name = "CustomPlane" + getGlobalId$1(), color = random$1().gl(), uMin = -500, uMax = 500, vMin = -500, vMax = 500) { - const { normal1, w } = P3$2.forAnchorAndPlaneVectors(anchor, right, up); - super(normal1, w); - this.up = up; - this.right = right; - this.uMin = uMin; - this.uMax = uMax; - this.vMin = vMin; - this.vMax = vMax; - this.name = name; - this.color = color; - } - get plane() { - return this; - } - toPlaneSurface() { - return new PlaneSurface$2(this, this.right, this.up); - } - toSource() { - return callsce("new CustomPlane", this.anchor, this.right, this.up, this.name, this.color, this.uMin, this.uMax, this.vMin, this.vMax); - } - static forPlane(plane, color = GL_COLOR_BLACK, name) { - //assert(!name) - const up = plane.normal1.getPerpendicular().unit(), right = up.cross(plane.normal1); - return new CustomPlane(plane.anchor, right, up, name, color); - } - static fromPlaneSurface(surface) { - return new CustomPlane(surface.plane.anchor, surface.right, surface.up, "genCustomPlane" + getGlobalId$1()); - } - distanceTo(line, mindist) { - return min$1([ - new L3$1(this.anchor.plus(this.right.times(this.uMin)), this.up), - new L3$1(this.anchor.plus(this.right.times(this.uMax)), this.up), - new L3$1(this.anchor.plus(this.up.times(this.vMin)), this.right), - new L3$1(this.anchor.plus(this.up.times(this.vMax)), this.right), - ].map((line2, line2Index) => { - const info = line2.infoClosestToLine(line); - if ((isNaN(info.t) || // parallel LINES - (line2Index < 2 && this.vMin <= info.t && info.t <= this.vMax) || - (line2Index >= 2 && this.uMin <= info.t && info.t <= this.uMax)) && - info.distance <= mindist) { - return info.s; - } - else { - return Infinity; - } - })); - } - distanceTo2(line, mindist) { - return min$1([ - new L3$1(this.anchor.plus(this.right.times(this.uMin)), this.up), - new L3$1(this.anchor.plus(this.right.times(this.uMax)), this.up), - new L3$1(this.anchor.plus(this.up.times(this.vMin)), this.right), - new L3$1(this.anchor.plus(this.up.times(this.vMax)), this.right), - ].map((line2, line2Index) => { - const info = line2.infoClosestToLine(line); - if ((isNaN(info.t) || // parallel LINES - (line2Index < 2 && this.vMin <= info.t && info.t <= this.vMax) || - (line2Index >= 2 && this.uMin <= info.t && info.t <= this.uMax)) && - info.distance <= mindist) { - return info.distance; - } - else { - return Infinity; - } - })); - } -} - -class Edge extends Transformable { - constructor(curve, a, b, aT, bT, flippedOf, name) { - super(); - this.curve = curve; - this.a = a; - this.b = b; - this.aT = aT; - this.bT = bT; - this.flippedOf = flippedOf; - this.name = name; - assertNumbers(aT, bT); - assert(!eq(aT, bT)); - assertVectors(a, b); - assertf(() => curve instanceof Curve$2, curve); - assertf(() => !curve.isValidT || (curve.isValidT(aT) && curve.isValidT(bT)), aT, bT, curve); - //if (curve instanceof PICurve) { - // assertf(() => curve.at(aT).to(a).length() < 0.1, ''+curve.at(aT)+a) - // assertf(() => curve.at(bT).to(b).length() < 0.1, '' + curve.at(bT) + b) - //} else { - assertf(() => curve.at(aT).like(a), () => "" + curve.at(aT) + a + " aT should have been " + curve.pointT(a)); - assertf(() => curve.at(bT).like(b), () => "" + curve.at(bT) + b + " bT should have been " + curve.pointT(b)); - //} - assertf(() => fuzzyBetween(aT, curve.tMin, curve.tMax), aT, curve.tMin, curve.tMax); - assertf(() => fuzzyBetween(bT, curve.tMin, curve.tMax), bT, curve.tMin, curve.tMax); - assert(!a.like(b), "!a.like(b)" + a + b); - this.aT = clamp(aT, curve.tMin, curve.tMax); - this.bT = clamp(bT, curve.tMin, curve.tMax); - this.reversed = this.aT > this.bT; - } - get minT() { - return Math.min(this.aT, this.bT); - } - get maxT() { - return Math.max(this.aT, this.bT); - } - static isLoop(loop) { - return loop.every((edge, i) => edge.b.like(loop[(i + 1) % loop.length].a)); - } - static edgesIntersect(e1, e2) { - // TODO: still getting some NaNs here.. - assertNumbers(e1.curve.hlol, e2.curve.hlol); - assertInst(Edge, e1, e2); - if (e1.curve.hlol < e2.curve.hlol) { - [e2, e1] = [e1, e2]; - } - const sts = e1.curve.isInfosWithCurve(e2.curve); - if (sts.some((info) => isNaN(info.tThis) || isNaN(info.tOther))) { - console.log(e1.sce); - console.log(e2.sce); - assert(false); - } - return sts.some( - /// ( e1.aT < tThis < e1.bT ) && ( e2.aT < tOther < e2.bT ) - ({ tThis, tOther }) => { - return e1.tValueInside(tThis) && e2.tValueInside(tOther); - }); - } - static assertLoop(edges) { - edges.forEach((edge, i) => { - const j = (i + 1) % edges.length; - assert(edge.b.like(edges[j].a), `edges[${i}].b != edges[${j}].a (${edges[i].b.sce} != ${edges[j].a.sce})`); - }); - } - static reversePath(path, doReverse = true) { - return doReverse - ? arrayFromFunction(path.length, (i) => path[path.length - 1 - i].flipped()) - : path; - } - toString() { - return callsce("new " + this.constructor.name, this.curve, this.a, this.b, this.aT, this.bT, undefined, this.aDir, this.bDir); - } - colinearToLine(line) { - return this.curve instanceof L3$1 && this.curve.isColinearTo(line); - } - tValueInside(t) { - return this.aT < this.bT - ? lt(this.aT, t) && lt(t, this.bT) - : lt(this.bT, t) && lt(t, this.aT); - } - isValidT(t) { - return this.aT < this.bT - ? le(this.aT, t) && le(t, this.bT) - : le(this.bT, t) && le(t, this.aT); - } - clampedT(t) { - return this.aT < this.bT - ? clamp(t, this.aT, this.bT) - : clamp(t, this.bT, this.aT); - } - /** - * this is equals-equals. "isColinearTo" might make more sense but can't be used, because you can't get a - * consistent hashCode for colinear curves - * @param obj - * @returns - */ - equals(obj) { - return (this === obj || - (this.constructor == obj.constructor && - this.a.equals(obj.a) && - this.b.equals(obj.b) && - this.curve.equals(obj.curve))); - } - hashCode() { - let hashCode = 0; - hashCode = hashCode * 31 + this.a.hashCode(); - hashCode = hashCode * 31 + this.b.hashCode(); - hashCode = hashCode * 31 + this.curve.hashCode(); - return hashCode | 0; - } - like(edge) { - // TODO this breaks on colinear edges, - // TODO: what, where? - return (this === edge || - (this.curve.isColinearTo(edge.curve) && - this.a.like(edge.a) && - this.b.like(edge.b) && - this.aDir.isParallelTo(edge.aDir) && - this.aDir.dot(edge.aDir) > 0)); - } - isCanon() { - return !this.reversed; - } - getCanon() { - return this.reversed ? this.flipped() : this; - } - overlaps(edge, noback) { - assert(this.curve.isColinearTo(edge.curve)); - const edgeAT = this.curve.containsPoint(edge.a) && this.curve.pointT(edge.a); - const edgeBT = this.curve.containsPoint(edge.b) && this.curve.pointT(edge.b); - if (false === edgeAT && false === edgeBT) { - return noback ? false : edge.overlaps(this, true); - } - return !(le(edge.maxT, this.minT) || le(this.maxT, edge.minT)); - } - getAABB() { - const min = [Infinity, Infinity, Infinity], max = [-Infinity, -Infinity, -Infinity]; - this.curve.roots().forEach((ts, dim) => { - ts.forEach((t) => { - if (lt(this.minT, t) && lt(t, this.maxT)) { - min[dim] = Math.min(min[dim], this.curve.at(t).e(dim)); - max[dim] = Math.max(max[dim], this.curve.at(t).e(dim)); - } - }); - }); - const aabb = new AABB(V(min), V(max)); - aabb.addPoint(this.a); - aabb.addPoint(this.b); - return aabb; - } - length(steps = 1) { - return this.curve.arcLength(this.minT, this.maxT, steps); - } - deltaT() { - return this.bT - this.aT; - } - deltaTSign() { - return sign(this.bT - this.aT); - } - atAvgT() { - return this.curve.at((this.minT + this.maxT) / 2); - } - /** - * Whether two edge loops are equal. Takes into account that two loops need not start with the same edge. - * @param loop1 - * @param loop2 - */ - static loopsEqual(loop1, loop2) { - return (loop1.length == loop2.length && - arrayRange(0, loop1.length, 1).some((offset) => loop1.every((edge, i) => edge.equals(loop2[(offset + i) % loop1.length])))); - } -} - -class StraightEdge extends Edge$2 { - constructor(line, a, b, aT, bT, flippedOf, name) { - super(line, a, b, aT, bT, flippedOf, name); - this.flippedOf = flippedOf; - assertInst(L3$1, line); - !flippedOf || assertInst(StraightEdge, flippedOf); - !name || assertf(() => "string" === typeof name, name); - this.tangent = - this.aT < this.bT ? this.curve.dir1 : this.curve.dir1.negated(); - } - get aDir() { - return this.tangent; - } - get bDir() { - return this.tangent; - } - static throughPoints(a, b, name) { - return new StraightEdge(L3$1.throughPoints(a, b, 0, a.to(b).length()), a, b, 0, a.to(b).length(), undefined, name); - } - /** - * Create a list of StraightEdges from a list of vertices. - * @param vertices - * @param closed Whether to connect the first and last vertices. Defaults to true. - * @returns - */ - static chain(vertices, closed = true) { - const vc = vertices.length; - return arrayFromFunction(closed ? vc : vc - 1, (i) => StraightEdge.throughPoints(vertices[i], vertices[(i + 1) % vc])); - } - toSource() { - return callsce("new StraightEdge", this.curve, this.a, this.b, this.aT, this.bT); - } - getVerticesNo0() { - return [this.b]; - } - pointsCount() { - return 2; - } - points() { - return [this.a, this.b]; - } - edgeISTsWithPlane(plane) { - const edgeT = snap2(this.curve.isTWithPlane(plane), this.aT, this.bT); - return this.minT <= edgeT && edgeT <= this.maxT ? [edgeT] : []; - } - edgeISTsWithSurface(surface) { - if (surface instanceof PlaneSurface$2) { - return this.edgeISTsWithPlane(surface.plane); - } - else { - return surface - .isTsForLine(this.curve) - .map((edgeT) => snap2(edgeT, this.aT, this.bT)) - .filter((edgeT) => this.minT <= edgeT && edgeT <= this.maxT); - } - } - tangentAt() { - return this.tangent; - } - flipped() { - return (this.flippedOf || - (this.flippedOf = new StraightEdge(this.curve, this.b, this.a, this.bT, this.aT, this, this.name))); - } - transform(m4, desc) { - const lineDir1TransLength = m4 - .transformVector2(this.curve.dir1, this.curve.anchor) - .length(); - const curve = this.curve.transform(m4); - const a = m4.transformPoint(this.a); - const b = m4.transformPoint(this.b); - return new StraightEdge(curve, a, b, m4.isNoProj() ? this.aT * lineDir1TransLength : curve.pointT(a), m4.isNoProj() ? this.bT * lineDir1TransLength : curve.pointT(b), undefined, "" + this.name + desc); - } - transform4(m4, desc) { - const lineDir1TransLength = m4 - .transformVector2(this.curve.dir1, this.curve.anchor) - .length(); - const curve = this.curve.transform4(m4); - const a = m4.transformPoint(this.a); - const b = m4.transformPoint(this.b); - return new StraightEdge(curve, a, b, m4.isNoProj() ? this.aT * lineDir1TransLength : curve.pointT(a), m4.isNoProj() ? this.bT * lineDir1TransLength : curve.pointT(b), undefined, "" + this.name + desc); - } - isCoEdge(edge) { - return (this === edge || - this === edge.flippedOf || - (edge.constructor instanceof StraightEdge && - ((this.a.like(edge.a) && this.b.like(edge.b)) || - (this.a.like(edge.b) && this.b.like(edge.a))))); - } - getEdgeT(p) { - assertVectors(p); - let edgeT = p.minus(this.curve.anchor).dot(this.curve.dir1); - if (!eq0(this.curve.at(edgeT).distanceTo(p))) { - return; - } - edgeT = snap2(edgeT, this.aT, this.bT); - return this.minT <= edgeT && edgeT <= this.maxT ? edgeT : undefined; - } - split(t) { - const p = this.curve.at(t); - return [ - new StraightEdge(this.curve, this.a, p, this.aT, t, undefined, this.name + "left"), - new StraightEdge(this.curve, p, this.b, t, this.bT, undefined, this.name + "right"), - ]; - } -} - -class PCurveEdge extends Edge$2 { - constructor(curve, a, b, aT, bT, flippedOf, aDir, bDir, name) { - super(curve, a, b, aT, bT, flippedOf, name); - this.flippedOf = flippedOf; - this.aDir = aDir; - this.bDir = bDir; - assertVectors(aDir, bDir); - assertf(() => !aDir.likeO(), curve); - assertf(() => !bDir.likeO(), curve); - if (!(curve instanceof PICurve$2)) { - // TODO - assertf(() => curve.tangentAt(aT).likeOrReversed(aDir), "" + aT + curve.tangentAt(aT).sce + " " + aDir.sce); - assertf(() => curve.tangentAt(bT).likeOrReversed(bDir), "" + bT + curve.tangentAt(bT).sce + " " + bDir.sce); - } - assert(this.reversed === this.aDir.dot(curve.tangentAt(aT)) < 0, aT + - " " + - bT + - " " + - curve.constructor.name + - " " + - this.aDir.sce + - " " + - this.bDir.sce + - " " + - curve.tangentAt(aT)); - assert(this.reversed === this.bDir.dot(curve.tangentAt(bT)) < 0, aT + - " " + - bT + - " " + - curve.constructor.name + - " " + - this.aDir.sce + - " " + - this.bDir.sce + - " " + - curve.tangentAt(aT)); - } - static forCurveAndTs(curve, aT, bT, name) { - return new PCurveEdge(curve, curve.at(aT), curve.at(bT), aT, bT, undefined, aT < bT ? curve.tangentAt(aT) : curve.tangentAt(aT).negated(), aT < bT ? curve.tangentAt(bT) : curve.tangentAt(bT).negated(), name); - } - toSource() { - return callsce("new PCurveEdge", this.curve, this.a, this.b, this.aT, this.bT, undefined, this.aDir, this.bDir, this.name); - } - getVerticesNo0() { - return this.curve.calcSegmentPoints(this.aT, this.bT, this.a, this.b, this.reversed, false); - } - pointsCount() { - return this.points().length; - } - points() { - return this.curve.calcSegmentPoints(this.aT, this.bT, this.a, this.b, this.reversed, true); - } - edgeISTsWithSurface(surface) { - return this.curve - .isTsWithSurface(surface) - .map((edgeT) => snap2(edgeT, this.aT, this.bT)) - .filter((edgeT) => this.minT <= edgeT && edgeT <= this.maxT); - } - edgeISTsWithPlane(surface) { - return this.curve - .isTsWithPlane(surface) - .map((edgeT) => snap2(edgeT, this.aT, this.bT)) - .filter((edgeT) => this.minT <= edgeT && edgeT <= this.maxT); - } - tangentAt(t) { - return !this.reversed - ? this.curve.tangentAt(t) - : this.curve.tangentAt(t).negated(); - } - flipped() { - return (this.flippedOf || - (this.flippedOf = new PCurveEdge(this.curve, this.b, this.a, this.bT, this.aT, this, this.bDir.negated(), this.aDir.negated(), this.name))); - } - transform(m4, desc) { - return new PCurveEdge(this.curve.transform(m4), m4.transformPoint(this.a), m4.transformPoint(this.b), this.aT, this.bT, undefined, m4.transformVector(this.aDir), m4.transformVector(this.bDir), "" + this.name + desc); - } - transform4(m4, desc) { - const a_ = m4.transformPoint(this.a); - const b_ = m4.transformPoint(this.b); - const curve_ = this.curve.transform4(m4); - return new PCurveEdge(curve_, a_, b_, snap(curve_.pointT(a_), this.aT), snap(curve_.pointT(b_), this.bT), undefined, m4.transformVector(this.aDir), m4.transformVector(this.bDir), "" + this.name + desc); - } - isCoEdge(edge) { - return (this === edge || - this === edge.flippedOf || - (this.curve.isColinearTo(edge.curve) && - ((this.a.like(edge.a) && this.b.like(edge.b)) || - (this.a.like(edge.b) && this.b.like(edge.a))))); - } - split(t) { - const p = this.curve.at(t); - const dir = this.tangentAt(t); - return [ - new PCurveEdge(this.curve, this.a, p, this.aT, t, undefined, this.aDir, dir, this.name + "left"), - new PCurveEdge(this.curve, p, this.b, t, this.bT, undefined, this.aDir, dir, this.name + "right"), - ]; - } -} - -function edgePathFromSVG(pathString) { - let currentPos = undefined; - const parsed = new SVGPathData(pathString) - .toAbs() - .normalizeHVZ() - .sanitize(NLA_PRECISION) - .annotateArcs().commands; - const path = []; - for (const c of parsed) { - assert("x" in c && "y" in c); - const endPos = new V3(c.x, c.y, 0); - switch (c.type) { - case SVGPathData.LINE_TO: - path.push(StraightEdge$1.throughPoints(currentPos, endPos)); - break; - case SVGPathData.CURVE_TO: { - const c1 = new V3(c.x1, c.y1, 0); - const c2 = new V3(c.x2, c.y2, 0); - const curve = new BezierCurve$1(currentPos, c1, c2, endPos, 0, 1); - const edge = new PCurveEdge$1(curve, currentPos, endPos, 0, 1, undefined, curve.tangentAt(0), curve.tangentAt(1)); - path.push(edge); - break; - } - case SVGPathData.QUAD_TO: { - const c1 = new V3(c.x1, c.y1, 0); - const curve = ParabolaCurve$1.quadratic(currentPos, c1, endPos).rightAngled(); - const edge = new PCurveEdge$1(curve, currentPos, endPos, curve.tMin, curve.tMax, undefined, curve.tangentAt(curve.tMin), curve.tangentAt(curve.tMax)); - path.push(edge); - break; - } - case SVGPathData.ARC: { - const phi1 = c.phi1 * DEG, phi2 = c.phi2 * DEG, [phiMin, phiMax] = [phi1, phi2].sort(MINUS); - const stops = arrayRange(-3, 4, 1) - .map((n) => n * PI$1) - .filter((stop) => phiMin <= stop && stop <= phiMax); - const center = V(c.cX, c.cY); - const f1 = V3.polar(c.rX, c.xRot * DEG); - const f2 = V3.polar(c.rY, c.xRot * DEG + Math.PI / 2); - const edges = getIntervals(stops, phiMin, phiMax).map(([t1, t2]) => { - const deltaT = t2 - t1; - const t1_ = mod(t1, TAU); - const t2_ = t1_ + deltaT; - assert(t1_ >= 0 == t2_ >= 0); - const gtPI = t1_ > PI$1 || t2_ > PI$1; - const aT = gtPI ? t1_ - PI$1 : t1_; - const bT = gtPI ? t2_ - PI$1 : t2_; - const curve = new EllipseCurve$1(center, gtPI ? f1.negated() : f1, gtPI ? f2.negated() : f2); - const a = phi1 == t1 ? currentPos : phi2 == t1 ? endPos : curve.at(aT); - const b = phi1 == t2 ? currentPos : phi2 == t2 ? endPos : curve.at(bT); - return new PCurveEdge$1(curve, a, b, aT, bT, undefined, curve.tangentAt(aT), curve.tangentAt(bT)); - }); - path.push(...(c.phiDelta > 0 ? edges : Edge$2.reversePath(edges))); - break; - } - } - currentPos = endPos; - } - return path; -} -/** - * Create an axis-aligned rectangle of edges on the XY-plane with the bottom-left corner on the origin. - * @param width - * @param height - */ -function edgeRect(width = 1, height = width) { - const vertices = [ - new V3(0, 0, 0), - new V3(width, 0, 0), - new V3(width, height, 0), - new V3(0, height, 0), - ]; - return StraightEdge$1.chain(vertices); -} -function edgeNgon(n = 3, radius = 1) { - return StraightEdge$1.chain(arrayFromFunction(n, (i) => V3.polar(radius, (TAU * i) / n))); -} -function edgeStar(pointCount = 5, r0 = 1, r1 = 0.5) { - const vertices = arrayFromFunction(pointCount * 2, (i) => V3.polar(0 == i % 2 ? r0 : r1, (TAU * i) / pointCount / 2)); - return StraightEdge$1.chain(vertices); -} -function createEdge(curve, a, b, aT, bT, flippedOf, aDir, bDir, name) { - if (curve instanceof L3$1) { - return new StraightEdge$1(curve, a, b, aT, bT, flippedOf, name); - } - else { - return new PCurveEdge$1(curve, a, b, aT, bT, flippedOf, aDir, bDir, name); - } -} -function edgeForCurveAndTs(curve, aT = curve.tMin, bT = curve.tMax) { - return createEdge(curve, curve.at(aT), curve.at(bT), aT, bT, undefined, aT < bT ? curve.tangentAt(aT) : curve.tangentAt(aT).negated(), aT < bT ? curve.tangentAt(bT) : curve.tangentAt(bT).negated()); -} -function reuleaux(n = 3, radius = 1) { - assert(3 <= n); - assert(1 == n % 2); - const corners = arrayFromFunction(n, (i) => V3.polar(radius, (TAU * i) / n)); - return arrayFromFunction(n, (i) => { - const aI = (i + floor(n / 2)) % n, bI = (i + ceil(n / 2)) % n; - const a = corners[aI], b = corners[bI]; - const center = corners[i]; - const f1 = center.to(a), curve = new EllipseCurve$1(center, f1, V3.Z.cross(f1)); - return createEdge(curve, a, b, 0, curve.pointT(b), undefined, V3.Z.cross(f1), V3.Z.cross(center.to(b))); - }); -} -function round$1(edges, radius) { - if (eq0(radius)) { - return edges; - } - const corners = edges.map((edge, i) => { - const j = (i + 1) % edges.length, nextEdge = edges[j]; - if (!edge.b.like(nextEdge.a)) - return undefined; - const angleToNext = edge.bDir.angleTo(nextEdge.aDir); - const c1 = edge.curve, c2 = nextEdge.curve; - if (c1 instanceof L3$1 && c2 instanceof L3$1) { - const normal = c1.dir1.cross(c2.dir1); - if (eq0(angleToNext)) - return undefined; - const l1inside = normal.cross(c1.dir1), l2inside = normal.cross(c2.dir1); - const l1offset = c1.transform(M4.translate(l1inside.toLength(radius))); - const l2offset = c2.transform(M4.translate(l2inside.toLength(radius))); - const center = l1offset.isInfoWithLine(l2offset); - if (!center) - throw new Error("tangential curves"); - const cornerA = center.plus(l1inside.toLength(-radius)); - const cornerB = center.plus(l2inside.toLength(-radius)); - const f1 = l1inside.toLength(-radius); - const curve = new EllipseCurve$1(center, f1, normal.cross(f1).toLength(radius)); - const cornerEdge = createEdge(curve, cornerA, cornerB, 0, curve.pointT(cornerB), undefined, c1.dir1, c2.dir1); - return cornerEdge; - } - else { - return arbitraryCorner(edge, nextEdge, radius); - } - }); - const result = edges.flatMap((edge, i) => { - const h = (i + edges.length - 1) % edges.length; - const prevCorner = corners[h], nextCorner = corners[i]; - if (!prevCorner && !nextCorner) { - return edge; - } - const [aT, a, aDir] = !prevCorner - ? [edge.aT, edge.a, edge.aDir] - : [edge.curve.pointT(prevCorner.b), prevCorner.b, prevCorner.bDir]; - const [bT, b, bDir] = !nextCorner - ? [edge.bT, edge.b, edge.bDir] - : [edge.curve.pointT(nextCorner.a), nextCorner.a, nextCorner.aDir]; - const newEdge = createEdge(edge.curve, a, b, aT, bT, undefined, aDir, bDir); - return !nextCorner ? newEdge : [newEdge, nextCorner]; - }); - return result; -} -function arbitraryCorner(e1, e2, radius) { - const c1 = e1.curve, c2 = e2.curve; - function f([t1, t2]) { - const p1 = c1.at(t1), p2 = c2.at(t2); - const dp1 = c1.tangentAt(t1), dp2 = c2.tangentAt(t2); - const virtualPlaneNormal = dp1.cross(dp2); - const normal1 = virtualPlaneNormal.cross(dp1).unit(), normal2 = virtualPlaneNormal.cross(dp2).unit(); - const dirCross = normal1.cross(normal2); - if (virtualPlaneNormal.likeO()) { - assert(false); - } // lines parallel - const p1p2 = p1.to(p2); - // check if distance is zero (see also L3.distanceToLine) - if (!eq0(p1p2.dot(virtualPlaneNormal))) { - assert(false); - } - const dist1 = p1p2.cross(normal2).dot(dirCross) / dirCross.squared(); - const dist2 = p1p2.cross(normal1).dot(dirCross) / dirCross.squared(); - const g1 = p1.plus(normal1.times(dist1)); - const g2 = p2.plus(normal2.times(dist2)); - assert(g1.like(g2)); - return [abs(dist1) - radius, abs(dist2) - radius]; - } - const startT1 = e1.bT - (radius * sign(e1.deltaT())) / e1.bDir.length(); - const startT2 = e2.aT + (radius * sign(e2.deltaT())) / e2.aDir.length(); - const [t1, t2] = newtonIterate(f, [startT1, startT2]); - const cornerA = e1.curve.at(t1); - const cornerB = e2.curve.at(t2); - const dp1 = c1.tangentAt(t1), dp2 = c2.tangentAt(t2); - const virtualPlaneNormal = dp1.cross(dp2); - const normal1 = virtualPlaneNormal.cross(dp1).unit(); - const f1 = normal1.toLength(-radius); - const center = cornerA.minus(f1); - const curve = new EllipseCurve$1(center, f1, virtualPlaneNormal.cross(f1).toLength(radius)); - const cornerEdge = createEdge(curve, cornerA, cornerB, 0, curve.pointT(cornerB), undefined, c1.tangentAt(t1), c2.tangentAt(t2)); - return cornerEdge; -} - -/** - * Created by aval on 19.04.2017. - */ -class FaceInfoFactory { - static makeStatic(staticInfo) { - return new (class extends FaceInfoFactory { - constructor() { - super(); - } - info(surface, contour, holes) { - return staticInfo; - } - })(); - } - info(surface, contour, holes) { - throw new Error("no default implementation"); - } - extrudeBottom(surface, contour, holes = []) { - return this.info(surface, contour, holes); - } - extrudeTop(surface, contour, holes = []) { - return this.info(surface, contour, holes); - } - extrudeWall(index, surface, contour, holes = []) { - return this.info(surface, contour, holes); - } - rotationWall(index, surface, contour, holes = []) { - return this.info(surface, contour, holes); - } - rotationStart(surface, contour, holes = []) { - return this.info(surface, contour, holes); - } - rotationEnd(surface, contour, holes = []) { - return this.info(surface, contour, holes); - } - newSubFace(original, surface, contour, holes = []) { - return original.info; - } - transform(original, m4, desc, surface, contour, holes = []) { - return original.info; - } -} - -class Face extends Transformable { - constructor(surface, contour, holes = [], name, info) { - super(); - this.surface = surface; - this.contour = contour; - this.holes = holes; - this.name = name; - this.info = info; - this.aabb = undefined; - //assert(name) - Edge$2.assertLoop(contour); - assert(contour.every((f) => f instanceof Edge$2), () => "contour.every(f => f instanceof Edge)" + contour); - // contour.forEach(e => !surface.containsCurve(e.curve) && - // console.log('FAIL:'+surface.distanceToPoint(e.curve.anchor))) - //contour.forEach(e => { - // assert(surface.containsCurve(e.curve), 'edge not in surface ' + e + surface) - //}) - //assert(surface.edgeLoopCCW(contour), surface.toString() + contour.join('\n')) - holes && holes.forEach((hole) => Edge$2.assertLoop(hole)); - holes && holes.forEach((hole) => assert(!surface.edgeLoopCCW(hole))); - assert(!holes || holes.constructor == Array, holes && holes.toString()); - this.allEdges = Array.prototype.concat.apply(this.contour, this.holes); - } - static assembleFacesFromLoops(loops, surface, faceConstructor) { - function placeRecursively(newLoopInfo, loopInfos) { - if (loopInfos.length == 0) { - loopInfos.push(newLoopInfo); - } - else { - const subLoopInfo = loopInfos.find((loopInfo) => BRep$1.loop1ContainsLoop2(loopInfo.loop, loopInfo.ccw, newLoopInfo.loop, newLoopInfo.ccw, surface)); - if (subLoopInfo) { - placeRecursively(newLoopInfo, subLoopInfo.subloops); - } - else { - // newLoopInfo isnt contained by any other subLoopInfo - for (let i = loopInfos.length; --i >= 0;) { - const subLoopInfo = loopInfos[i]; - //console.log('cheving subLoopInfo', surface.loopContainsPoint(newLoopInfo.edges, - // subLoopInfo.edges[0].a)) - if (BRep$1.loop1ContainsLoop2(newLoopInfo.loop, newLoopInfo.ccw, subLoopInfo.loop, subLoopInfo.ccw, surface)) { - newLoopInfo.subloops.push(subLoopInfo); - loopInfos.splice(i, 1); // remove it - } - } - loopInfos.push(newLoopInfo); - } - } - } - function newFacesRecursive(loopInfo) { - newFaces.push(new faceConstructor(surface, loopInfo.ccw ? loopInfo.loop : Edge$2.reversePath(loopInfo.loop), loopInfo.subloops.map((sl) => sl.ccw ? Edge$2.reversePath(sl.loop) : sl.loop))); - loopInfo.subloops.forEach((sl) => sl.subloops.forEach((sl2) => newFacesRecursive(sl2))); - } - const newFaces = []; - const topLevelLoops = []; - loops.forEach((loop) => placeRecursively({ - loop: loop, - ccw: surface.edgeLoopCCW(loop), - subloops: [], - }, topLevelLoops)); - topLevelLoops.forEach((tll) => newFacesRecursive(tll)); - return newFaces; - } - //fromLoops(loops: Edge[][], surface: Surface) { - // type LoopInfo = {loop: Edge[], ccw: boolean, subloops: LoopInfo[]} - // function placeRecursively(newLoopInfo: LoopInfo, loopInfos: LoopInfo[]) { - // if (loopInfos.length == 0) { - // loopInfos.push(newLoopInfo) - // } else { - // const subLoopInfo = loopInfos.find(loopInfo => BRep.loop1ContainsLoop2(loopInfo.loop, loopInfo.ccw, - // newLoopInfo.loop, newLoopInfo.ccw, surface)) if (subLoopInfo) { placeRecursively(newLoopInfo, - // subLoopInfo.subloops) } else { // newLoopInfo isnt contained by any other subLoopInfo for (let i = - // loopInfos.length; --i >= 0;) { const subLoopInfo = loopInfos[i] //console.log('cheving subLoopInfo', - // surface.loopContainsPoint(newLoopInfo.edges, subLoopInfo.edges[0].a)) if - // (BRep.loop1ContainsLoop2(newLoopInfo.loop, subLoopInfo.loop, surface)) { newLoopInfo.subloops.push(subLoopInfo) - // loopInfos.splice(i, 1) // remove it } } loopInfos.push(newLoopInfo) } } } function newFacesRecursive(loopInfo: - // LoopInfo): void { // CW loops can be top level, if they are holes in the original face not contained in the new - // face if (loopInfo.ccw) { if (loopInfo.subloops.every(sl => !sl.ccw)) { const newFace = new - // faceConstructor(surface, loopInfo.loop, loopInfo.subloops.map(sl => sl.loop)) newFaces.push(newFace) - // loopInfo.subloops.forEach(sl => sl.subloops.forEach(slsl => slsl.ccw && newFacesRecursive(slsl))) } else { - // loopInfo.subloops.forEach(sl => sl.ccw && newFacesRecursive(sl)) } } } const newFaces: Face[] = [] const - // topLevelLoops:LoopInfo[] = [] loops.forEach(loop => placeRecursively({loop: loop, ccw: - // surface.edgeLoopCCW(loop), subloops: []}, topLevelLoops)) topLevelLoops.forEach(tll => newFacesRecursive(tll)) - // return newFaces } - static create(surface, faceEdges, holes, faceName, info) { - return surface instanceof PlaneSurface$2 - ? new PlaneFace(surface, faceEdges, holes, faceName, info) - : new RotationFace(surface, faceEdges, holes, faceName, info); - } - intersectFace(face2, thisBrep, face2Brep, faceMap, thisEdgePoints, otherEdgePoints, checkedPairs) { - //thisEdgePoints = { - // get(key) { - // return _thisEdgePoints.get(key) - // }, - // set(key, value) { - // assert(thisBrep.edgeFaces.get(key)) - // _thisEdgePoints.set(key, value) - // } - //} - function hasPair(a, b) { - return checkedPairs.has(new Pair(a, b)); - } - function addPair(a, b) { - return checkedPairs.add(new Pair(a, b)); - } - /** - * @param newEdge generated segment - * @param col1 if newEdge is colinear to an edge of this, the edge in question - * @param col2 same for face2 - * @return whether new edge was added. - */ - function handleNewEdge(newEdge, col1, col2) { - if (!col1 && !col2) { - let correctDir = face.surface - .normalP(newEdge.a) - .cross(face2.surface.normalP(newEdge.a)); - if (correctDir.likeO()) { - const t = lerp(newEdge.aT, newEdge.bT, 1 / GOLDEN_RATIO), p = newEdge.curve.at(t); - correctDir = face.surface.normalP(p).cross(face2.surface.normalP(p)); - } - if (!correctDir.likeO()) { - if (correctDir.dot(newEdge.aDir) < 0) { - newEdge = newEdge.flipped(); - } - mapPush(faceMap, face, newEdge); - mapPush(faceMap, face2, newEdge.flipped()); - } - else { - const p = newEdge.a; - const plane = P3$2.normalOnAnchor(newEdge.aDir, p); - const up = face.surface.normalP(p); - const sameDir = up.dot(face2.surface.normalP(p)) > 0; - const canonDir = plane.normal1.cross(up); - const curve = face.surface.isCurvesWithPlane(plane)[0], curveT = curve.pointT(p), curveDir = sign(canonDir.dot(curve.tangentAt(curveT))); - const curve2 = face2.surface.isCurvesWithPlane(plane)[0], curve2T = curve2.pointT(p), curve2Dir = sign(canonDir.dot(curve.tangentAt(curve2T))); - const foo = curve.diff(curveT, EPS$1 * curveDir).dot(up); - const foo2 = curve2.diff(curve2T, EPS$1 * curve2Dir).dot(up); - if (foo2 < foo) { - mapPush(faceMap, face2, sameDir ? newEdge.flipped() : newEdge); - } - if (up.dot(face2.surface.normalP(p)) < 0 == foo2 < foo) { - mapPush(faceMap, face, newEdge.flipped()); - } - const bar = curve.diff(curveT, EPS$1 * curveDir).dot(up); - const bar2 = curve2.diff(curve2T, EPS$1 * curve2Dir).dot(up); - if (bar2 < bar) { - mapPush(faceMap, face2, sameDir ? newEdge : newEdge.flipped()); - } - if (sameDir != bar2 < bar) { - mapPush(faceMap, face, newEdge); - } - } - return true; - } - function handleEdgeInFace(col1, col2, face, face2, thisBrep, face2Brep, coplanarSameIsInside, has, add) { - if (col1 && !col2) { - if (hasPair(col1.getCanon(), face2)) - return false; - //add(col1.getCanon(), face2) - const surface2 = face2.surface; - // NB: a new edge is inserted even though it may be the same as an old one - // however it indicates that it intersects the other volume here, i.e. the old edge cannot - // be counted as 'inside' for purposes of reconstitution - thisBrep.edgeFaces.get(col1.getCanon()).forEach((faceInfo) => { - //const dot = snap0(surface2.normal1.dot(faceInfo.inside)) - //if (dot == 0 ? !coplanarSameIsInside : dot < 0) { - const pointsInsideFace = fff$1(faceInfo, face2.surface); - const edgeInside = pointsInsideFace == INSIDE$1 || - (!coplanarSameIsInside && pointsInsideFace == COPLANAR_SAME$1); - const pushEdge = faceInfo.edge - .tangentAt(faceInfo.edge.curve.pointT(newEdge.a)) - .like(newEdge.aDir) - ? newEdge - : newEdge.flipped(); - assert(faceInfo.edge - .tangentAt(faceInfo.edge.curve.pointT(pushEdge.a)) - .like(pushEdge.aDir)); - edgeInside && mapPush(faceMap, faceInfo.face, pushEdge); - }); - const surface2NormalAtNewEdgeA = surface2.normalP(newEdge.a); - const newEdgeInside = surface2NormalAtNewEdgeA.cross(newEdge.aDir); - const sVEF1 = splitsVolumeEnclosingFacesP$1(thisBrep, col1.getCanon(), newEdge.a, newEdgeInside, surface2NormalAtNewEdgeA); - let addNewEdge, addNewEdgeFlipped; - if ((addNewEdge = - sVEF1 == INSIDE$1 || - (coplanarSameIsInside && sVEF1 == COPLANAR_SAME$1))) { - mapPush(faceMap, face2, newEdge); - } - const sVEF2 = splitsVolumeEnclosingFacesP$1(thisBrep, col1.getCanon(), newEdge.a, newEdgeInside.negated(), surface2NormalAtNewEdgeA); - if ((addNewEdgeFlipped = - sVEF2 == INSIDE$1 || - (coplanarSameIsInside && sVEF2 == COPLANAR_SAME$1))) { - mapPush(faceMap, face2, newEdge.flipped()); - } - if (addNewEdge || - addNewEdgeFlipped || - (sVEF1 == COPLANAR_SAME$1 && sVEF2 == INSIDE$1) || - (sVEF2 == COPLANAR_SAME$1 && sVEF1 == INSIDE$1)) { - return true; - } - } - return false; - } - const c1 = handleEdgeInFace(col1, col2, face, face2, thisBrep, face2Brep, false); - const c2 = handleEdgeInFace(col2, col1, face2, face, face2Brep, thisBrep, true); - if (c1 || c2) - return true; - if (col1 && col2) { - if (hasPair(col1.getCanon(), col2.getCanon())) - return false; - addPair(col1.getCanon(), col2.getCanon()); - function handleColinearEdgeFaces(col1, col2, thisBrep, face2Brep, coplanarSameIsInside, thisEdgePoints, has, add) { - // not entirely sure for what i had the dirInsides in? - //const aDirNegatedInside = (newEdge.a.like(col2.a) || newEdge.a.like(col2.b)) && - // splitsVolumeEnclosingCone(face2Brep, newEdge.a, newEdge.aDir.negated()) == INSIDE const - // bDirInside = (newEdge.b.like(col2.a) || newEdge.b.like(col2.b)) && - // splitsVolumeEnclosingCone(face2Brep, newEdge.b, newEdge.bDir) == INSIDE - for (const faceInfo of thisBrep.edgeFaces.get(col1.getCanon())) { - const sVEF = splitsVolumeEnclosingFaces$1(face2Brep, col2.getCanon(), faceInfo.inside, faceInfo.normalAtCanonA); - const edgeInside = sVEF == INSIDE$1 || (coplanarSameIsInside && sVEF == COPLANAR_SAME$1); - const pushEdge = faceInfo.edge.aDir.like(newEdge.aDir) - ? newEdge - : newEdge.flipped(); - if (edgeInside) { - mapPush(faceMap, faceInfo.face, pushEdge); - const aT = col1.getCanon().curve.pointT(newEdge.a); - if (!eq(aT, col1.aT) && !eq(aT, col1.bT)) { - // newEdge.a is in center of col1 - if (splitsVolumeEnclosingCone2$1(face2Brep, newEdge.a, newEdge.curve, newEdge.aT, -Math.sign(newEdge.deltaT())) == INSIDE$1) { - mapPush(thisEdgePoints, col1.getCanon(), { - p: newEdge.a, - edgeT: aT, - }); - } - } - const bT = col1.getCanon().curve.pointT(newEdge.b); - if (!eq(bT, col1.aT) && !eq(bT, col1.bT)) { - if (splitsVolumeEnclosingCone2$1(face2Brep, newEdge.b, newEdge.curve, newEdge.bT, Math.sign(newEdge.deltaT())) == INSIDE$1) { - mapPush(thisEdgePoints, col1.getCanon(), { - p: newEdge.b, - edgeT: bT, - }); - } - } - } - } - } - handleColinearEdgeFaces(col1, col2, thisBrep, face2Brep, true, thisEdgePoints); - handleColinearEdgeFaces(col2, col1, face2Brep, thisBrep, false, otherEdgePoints); - return false; - } - return false; - } - // what needs to be generated: new edges on face - // points on edges where they are cut by faces so that sub edges will be generated for loops - // points on ends of edges where the edge will be an edge in the new volume where it goes from A to B - // you don't want those to be marked as 'inside', otherwise invalid faces will be added - // if a face cuts a corner, nothing needs to be done, as that alone does not limit what adjacent faces will be - function handleEndPoint(a, b, newEdge) { - // ends in the middle of b's face - if (a && !b) { - if (!a.colinear && a.edgeT != a.edge.aT && a.edgeT != a.edge.bT) { - mapPush(thisEdgePoints, a.edge.getCanon(), a); - assert(a.edge.isValidT(a.edgeT)); - } - // else colinear segment ends in middle of other face, do nothing - } - // ends in the middle of a's face - if (b && !a) { - if (!b.colinear && b.edgeT != b.edge.aT && b.edgeT != b.edge.bT) { - mapPush(otherEdgePoints, b.edge.getCanon(), b); - assert(b.edge.isValidT(b.edgeT)); - } - // else colinear segment ends in middle of other face, do nothing - } - if (a && b) { - assert(a.colinear || b.colinear || eq(a.t, b.t)); - // if a or b is colinear the correct points will already have been added to the edge by handleNewEdge - // segment starts/ends on edge/edge intersection - function handleAB(a, b, face, face2, thisPlane, face2Plane, thisBrep, face2Brep, first, thisEdgePoints) { - if (!a.colinear && a.edgeT != a.edge.aT && a.edgeT != a.edge.bT) { - //if (!hasPair(a.edge.getCanon(), b.edge.getCanon())) { - addPair(a.edge.getCanon(), b.edge.getCanon()); - // ends on a, on colinear segment b bT != a.edge.bT && - // b can be colinear, so edgeT == aT is possible - if (a.p.like(b.edge.a) || a.p.like(b.edge.b)) { - const corner = a.p.like(b.edge.a) ? b.edge.a : b.edge.b; - // face2brep corner on edge - const sVEC1 = splitsVolumeEnclosingCone2$1(face2Brep, corner, a.edge.curve, a.edgeT, 1); - const sVEC2 = splitsVolumeEnclosingCone2$1(face2Brep, corner, a.edge.curve, a.edgeT, -1); - // if either of these return ALONG_EDGE_OR_PLANE, then the breps share a colinear edge - if (INSIDE$1 == sVEC1 || INSIDE$1 == sVEC2) { - mapPush(thisEdgePoints, a.edge.getCanon(), a); - assert(a.edge.isValidT(a.edgeT)); - } - } - else { - // edge / edge center intersection - // todo: is this even necessary considering we add edges anyway? i think so... - // const testVector = - // a.edge.tangentAt(a.edgeT).rejectedFrom(b.edge.tangentAt(b.edge.curve.pointT(a.p))) - // assert(!testVector.likeO()) - const sVEF1 = splitsVolumeEnclosingFacesP2$1(face2Brep, b.edge.getCanon(), a.p, a.edge.curve, a.edgeT, 1, thisPlane.normalP(a.p)); - const sVEF2 = splitsVolumeEnclosingFacesP2$1(face2Brep, b.edge.getCanon(), a.p, a.edge.curve, a.edgeT, -1, thisPlane.normalP(a.p)); - if (INSIDE$1 == sVEF1 || - (first && COPLANAR_SAME$1 == sVEF1) || - INSIDE$1 == sVEF2 || - (first && COPLANAR_SAME$1 == sVEF2)) { - mapPush(thisEdgePoints, a.edge.getCanon(), a); - assert(a.edge.isValidT(a.edgeT)); - } - } - //} - } - } - handleAB(a, b, face, face2, surface, surface2, thisBrep, face2Brep, true, thisEdgePoints); - handleAB(b, a, face2, face, surface2, surface, face2Brep, thisBrep, false, otherEdgePoints); - } - } - assertInst(Face, face2); - const face = this; - const surface = face.surface, surface2 = face2.surface; - if (!this.getAABB().touchesAABBfuzzy(face2.getAABB())) { - return; - } - if (surface.isCoplanarTo(surface2)) { - return; - } - const isCurves = surface.isCurvesWithSurface(surface2); - if (0 == isCurves.length) { - return; - } - for (const isCurve of isCurves) { - assert(surface.containsCurve(isCurve)); - assert(surface2.containsCurve(isCurve)); - } - for (let isCurveIndex = 0; isCurveIndex < isCurves.length; isCurveIndex++) { - // get intersections of newCurve with other edges of face and face2 - const isCurve = isCurves[isCurveIndex]; - const ps1 = face.edgeISPsWithSurface(isCurve, face2.surface); - const ps2 = face2.edgeISPsWithSurface(isCurve, face.surface); - // for non-endless curves, e.g. ellipses, the intersections of the faces can be non-zero, even if one of - // the faces doesn't register any points on the curve. For example, if a cylinder is cut entirely by a - // plane face (all its edges around the cylinder), then the face will contain the entire curve and - // 'ps' for the plane face will be empty - // TODO: behavior when curves touch face? - // !! start in does depend on insideDir... TODO - assertf(() => 0 == ps1.length || - !eq0(ps1[0].insideDir.dot(isCurve.tangentAt(ps1[0].t))), () => ps1[0].insideDir.dot(isCurve.tangentAt(ps1[0].t))); - assertf(() => 0 == ps2.length || - !eq0(ps2[0].insideDir.dot(isCurve.tangentAt(ps2[0].t))), () => ps2[0].insideDir.dot(isCurve.tangentAt(ps2[0].t))); - function startsInside(ps, face) { - if (0 == ps.length) { - return (isFinite(isCurve.tMin) && - face.containsPoint2(isCurve.at(isCurve.tMin)) == PointVsFace$2.INSIDE); - } - else { - return ps[0].insideDir.dot(isCurve.tangentAt(ps[0].t)) < 0; - } - } - // they can't both be empty currently - // they can't both start 'inside' - let in1 = startsInside(ps1, face); - let in2 = startsInside(ps2, face2); - if ((0 == ps1.length && !in1) || (0 == ps2.length && !in2)) { - continue; - } - //assert(!in1 || !in2) - let col1, col2; - let i = 0, j = 0, last; - let startP = in1 && in2 ? isCurve.at(isCurve.tMin) : undefined, startDir, startT = isCurve.tMin, startA, startB; - while (i < ps1.length || j < ps2.length) { - assert(i <= ps1.length); - assert(j <= ps2.length); - const a = ps1[i], b = ps2[j]; - assert(a || b); - if (j == ps2.length || (i < ps1.length && lt(a.t, b.t))) { - last = a; - in1 = !in1; - a.used = true; - col1 = a.colinear ? a : undefined; - i++; - } - else if (i == ps1.length || gt(a.t, b.t)) { - last = b; - b.used = true; - in2 = !in2; - col2 = b.colinear ? b : undefined; - j++; - } - else { - last = a; - a.used = true; - b.used = true; - in1 = !in1; - in2 = !in2; - //if (in1 == in2) { - col1 = a.colinear ? a : undefined; - col2 = b.colinear ? b : undefined; - //} - i++; - j++; - } - if (startP && !(in1 && in2)) { - // segment end - startDir = isCurve.tangentAt(startT); - if (eq(startT, last.t)) { - startP = undefined; - continue; - } - assert(lt(startT, last.t)); - startT > last.t && (startDir = startDir.negated()); - let endDir = isCurve.tangentAt(last.t); - startT > last.t && (endDir = endDir.negated()); - const newEdge = createEdge$1(isCurve, startP, last.p, startT, last.t, undefined, startDir, endDir, "genseg" + getGlobalId$1()); - startP = undefined; - if (handleNewEdge(newEdge, col1 && col1.edge, col2 && col2.edge)) { - handleEndPoint(startA || col1, startB || col2); - handleEndPoint((a && a.used && a) || col1, (b && b.used && b) || col2); - } - } - else if (in1 && in2) { - // new segment just started - startP = last.p; - startDir = last.insideDir; - startT = last.t; - startA = a && a.used ? a : undefined; - startB = b && b.used ? b : undefined; - } - } - if (in1 && in2 && startT !== isCurve.tMax) { - const endT = isCurve.tMax; - startDir = isCurve.tangentAt(startT); - startT > endT && (startDir = startDir.negated()); - let endDir = isCurve.tangentAt(endT); - startT > endT && (endDir = endDir.negated()); - const newEdge = createEdge$1(isCurve, startP, isCurve.at(endT), startT, endT, undefined, startDir, endDir, "genseg" + getGlobalId$1()); - if (handleNewEdge(newEdge, col1 && col1.edge, col2 && col2.edge)) { - handleEndPoint(startA || col1, startB || col2); - } - } - } - face.getAllEdges().forEach((edge) => { - checkedPairs.add(new Pair(edge.getCanon(), face2)); - }); - face2.getAllEdges().forEach((edge) => { - checkedPairs.add(new Pair(edge.getCanon(), face)); - }); - } - edgeISPsWithSurface(isCurve, surface2) { - const face = this; - const surface = face.surface; - const loops = face.holes.concat([face.contour]); - const ps = []; - for (const loop of loops) { - const colinearEdges = loop.map((edge) => edge.curve.isColinearTo(isCurve)); - //const colinearSides = loop.map((edge, edgeIndex) => -1 != colinearEdges[edgeIndex] - // && -sign(isCurves[colinearEdges[edgeIndex]].tangentAt(edge.aT).dot(edge.aDir))) - for (let edgeIndex = 0; edgeIndex < loop.length; edgeIndex++) { - const edge = loop[edgeIndex]; - const nextEdgeIndex = (edgeIndex + 1) % loop.length, nextEdge = loop[nextEdgeIndex]; - //console.log(edge.toSource()) {p:V3(2, -2.102, 0), - if (colinearEdges[edgeIndex]) { - if (isCurve.containsPoint(edge.a)) { - const prevEdgeIndex = (edgeIndex - 1 + loop.length) % loop.length, prevEdge = loop[prevEdgeIndex]; - const curveAT = isCurve.pointT(edge.a); - const colinearOutA = edge.aDir.cross(surface.normalP(edge.a)); - if (!colinearEdges[prevEdgeIndex] && - dotCurve2$2(prevEdge.curve, prevEdge.bT, colinearOutA, -sign(prevEdge.deltaT())) > 0) { - ps.push({ - p: prevEdge.b, - insideDir: edge.aDir.negated(), - t: curveAT, - edge: prevEdge, - edgeT: prevEdge.bT, - colinear: false, - }); - } - ps.push({ - p: edge.a, - insideDir: edge.aDir, - t: curveAT, - edge: edge, - edgeT: edge.aT, - colinear: true, - }); - } - if (isCurve.containsPoint(edge.b)) { - const curveBT = isCurve.pointT(edge.b); - const colinearOutB = edge.bDir.cross(surface.normalP(edge.b)); - if (!colinearEdges[nextEdgeIndex] && - dotCurve2$2(nextEdge.curve, nextEdge.aT, colinearOutB, sign(nextEdge.deltaT())) > 0) { - ps.push({ - p: edge.b, - insideDir: edge.bDir, - t: curveBT, - edge: nextEdge, - edgeT: nextEdge.aT, - colinear: false, - }); - } - ps.push({ - p: edge.b, - insideDir: edge.bDir.negated(), - t: curveBT, - edge: edge, - edgeT: edge.bT, - colinear: true, - }); - } - } - else { - const edgeTs = edge.edgeISTsWithSurface(surface2); - for (const edgeT of edgeTs) { - const p = edge.curve.at(edgeT); - if (!isCurve.containsPoint(p)) - continue; - const curveT = isCurve.pointT(p); - assert(!isNaN(curveT)); - const insideDir = edge - .tangentAt(edgeT) - .cross(surface.normalP(p)) - .negated(); - const isTangent = isCurve.tangentAt(curveT); - //if(!eq0(insideDir.dot(isTangent))) { - // Edge.edgeISTsWithSurface returns snapped values, so comparison with == is ok: - if (edgeT == edge.bT) { - // endpoint lies on intersection line - if (!colinearEdges[nextEdgeIndex]) { - if (!eq(curveT, isCurve.tMax)) { - const pointsToInside = this.pointsToInside3(edge.b, isCurve, curveT, 1); - assert(pointsToInside != PointVsFace$2.ON_EDGE); - if (PointVsFace$2.INSIDE == pointsToInside) { - ps.push({ - p: edge.b, - insideDir: isTangent, - t: curveT, - edge: edge, - edgeT: edge.bT, - colinear: false, - }); - } - } - if (!eq(curveT, isCurve.tMin)) { - const pointsToInside = this.pointsToInside3(edge.b, isCurve, curveT, -1); - assert(pointsToInside != PointVsFace$2.ON_EDGE); - if (PointVsFace$2.INSIDE == pointsToInside) { - ps.push({ - p: edge.b, - insideDir: isTangent.negated(), - t: curveT, - edge: edge, - edgeT: edge.bT, - colinear: false, - }); - } - } - //let thisSide = -normVector.dot(edge.bDir) - //if (eq0(thisSide)) { - // // advanced test - // const dir = -sign(edge.deltaT()) - // const iscd = isCurve.at(curveT).to(isCurve.at(curveT + dir * dirFactor * - // eps)).dot(normVector) const ecd = edge.curve.at(edgeT).to(edge.curve.at(edgeT + dir - // * eps)).dot(normVector) thisSide = sign(ecd - iscd) } let nextSide = - // normVector.dot(nextEdge.aDir) if (eq0(nextSide)) { // advanced test const dirFactor - // = sign(snap0(isTangent.dot(nextEdge.curve.tangentAt(nextEdge.aT)))) assert(dirFactor - // !== 0) const dir = sign(nextEdge.deltaT()) const iscd = - // isCurve.at(curveT).to(isCurve.at(curveT + dir * dirFactor * eps)).dot(normVector) - // const ecd = nextEdge.curve.at(nextEdge.aT).to(nextEdge.curve.at(nextEdge.aT + dir * - // eps)).dot(normVector) nextSide = sign(ecd - iscd) } if (nextSide < 0 || thisSide < - // 0) { assert(!eq0(insideDir.dot(isTangent))) // next segment is not colinear and ends - // on different side ps.push({ p: edge.b, insideDir: insideDir, t: curveT, edge: edge, - // edgeT: edge.bT, colinear: false}) } - } - } - else if (edgeT != edge.aT) { - // edge crosses/touches an intersection curve, neither starts nor ends on it - if (eq0(insideDir.dot(isTangent))) { - const dirFactor = sign(isTangent.dot(edge.curve.tangentAt(edgeT))); - const eps = 1e-4; - for (const dir of [-1, 1]) { - if ((-1 == dir * dirFactor && edgeT == edge.minT) || - (1 == dir * dirFactor && edgeT == edge.maxT) || - (-1 == dir && curveT == isCurve.tMin) || - (1 == dir && curveT == isCurve.tMax)) - continue; - const iscd = isCurve - .at(curveT) - .to(isCurve.at(curveT + dir * eps)) - .dot(insideDir); - const ecd = edge.curve - .at(edgeT) - .to(edge.curve.at(edgeT + dir * dirFactor * eps)) - .dot(insideDir); - if (iscd - ecd > 0) { - ps.push({ - p, - insideDir: isTangent.times(dir), - t: curveT, - edge: edge, - edgeT: edgeT, - colinear: false, - }); - } - } - } - else { - ps.push({ - p: p, - insideDir: insideDir, - t: curveT, - edge: edge, - edgeT: edgeT, - colinear: false, - }); - } - } - //} else { - // - // const dirFactor = sign(isTangent.dot(edge.curve.tangentAt(edgeT))) - // const eps = 1e-4 - // const normVector = surface2.normalP(p) - // for (const dir of [-1, 1]) { - // if (-1 == dir * dirFactor && edgeT == edge.minT || - // 1 == dir * dirFactor && edgeT == edge.maxT || - // -1 == dir && curveT == isCurve.tMin || - // 1 == dir && curveT == isCurve.tMax) continue - // const iscd = isCurve.at(curveT).to(isCurve.at(curveT + dir * eps)).dot(normVector) - // const ecd = edge.curve.at(edgeT).to(edge.curve.at(edgeT + dir * dirFactor * - // eps)).dot(normVector) if (iscd > ecd) { ps.push({p, insideDir: isTangent.times(dir * - // dirFactor), t: curveT, edge: edge, edgeT: edgeT, colinear: false}) } } - // curveVsSurface(isCurve, curveT, p, surface2) } - } - } - } - } - // duplicate 't's are ok, as sometimes a segment needs to stop and start again - // should be sorted so that back facing ones are first - ps.sort((a, b) => a.t - b.t || a.insideDir.dot(isCurve.tangentAt(a.t))); - return ps; - } - transform(m4) { - const mirroring = m4.isMirroring(); - const newEdges = Edge$2.reversePath(this.contour.map((e) => e.transform(m4)), mirroring); - const newHoles = this.holes.map((hole) => Edge$2.reversePath(hole.map((e) => e.transform(m4)), mirroring)); - return new this.constructor(this.surface.transform(m4), newEdges, newHoles, this.name, this.info); - } - transform4(m4) { - const mirroring = m4.isMirroring(); - const newEdges = Edge$2.reversePath(this.contour.map((e) => e.transform4(m4)), mirroring); - const newHoles = this.holes.map((hole) => Edge$2.reversePath(hole.map((e) => e.transform4(m4)), mirroring)); - return new this.constructor(this.surface.transform4(m4), newEdges, newHoles, this.name, this.info); - } - flipped() { - const newEdges = this.contour.map((e) => e.flipped()).reverse(); - const newHoles = this.holes.map((hole) => hole.map((e) => e.flipped()).reverse()); - return new this.constructor(this.surface.flipped(), newEdges, newHoles, this.name, this.info); - } - toString() { - return ("new " + - this.constructor.name + - "(" + - this.surface + - ", [" + - this.contour.map((e) => "\n\t" + e).join() + - "]" + - this.holes.map((hole) => "\n\t\thole: " + hole.join()) + - ")"); - } - toSource() { - return ("new " + - this.constructor.name + - "(" + - this.surface.toSource() + - ", [" + - this.contour.map((e) => "\n\t" + e.toSource() + ",").join("") + - "], [" + - this.holes - .map((hole) => "[" + hole.map((e) => "\n\t" + e.toSource() + ",").join("") + "]") - .join(",") + - "])"); - } - equals(obj) { - return (this == obj || - (Object.getPrototypeOf(this) == Object.getPrototypeOf(obj) && - this.holes.length == obj.holes.length && - Edge$2.loopsEqual(this.contour, obj.contour) && - this.holes.every((hole) => obj.holes.some((hole2) => Edge$2.loopsEqual(hole, hole2))))); - } - hashCode() { - function arrayHashCode(array) { - let hashCode = 0; - for (const val of array) { - hashCode = (hashCode * 31 + val) | 0; - } - return hashCode; - } - function loopHashCode(loop) { - return arrayHashCode(loop.map((edge) => edge.hashCode()).sort(MINUS)); - } - let hashCode = 0; - hashCode = - (hashCode * 31 + - arrayHashCode(this.holes.map((loop) => loopHashCode(loop)).sort(MINUS))) | - 0; - hashCode = (hashCode * 31 + loopHashCode(this.contour)) | 0; - hashCode = (hashCode * 31 + this.surface.hashCode()) | 0; - return hashCode; - } - likeFace(face2) { - function loopsLike(a, b) { - return (a.length == b.length && - arrayRange(0, a.length, 1).some((offset) => a.every((edge, i) => edge.like(b[(offset + i) % a.length])))); - } - assertInst(Face, face2); - return (this.surface.like(face2.surface) && - this.holes.length == face2.holes.length && - loopsLike(this.contour, face2.contour) && - this.holes.every((hole) => face2.holes.some((hole2) => loopsLike(hole, hole2)))); - } - getAllEdges() { - return this.allEdges; - } - addEdgeLines(mesh) { - assert(false, "buggy, fix"); - const vertices = this.contour.flatMap((edge) => edge.getVerticesNo0()), mvl = mesh.vertices.length; - for (let i = 0; i < vertices.length; i++) { - mesh.vertices.push(vertices[i]); - mesh.LINES.push(mvl + i, mvl + ((i + 1) % vertices.length)); - } - } - containsPoint(p) { - assertVectors(p); - return (this.surface.loopContainsPoint(this.contour, p) != PointVsFace$2.OUTSIDE && - !this.holes.some((hole) => this.surface.loopContainsPoint(hole, p) != PointVsFace$2.OUTSIDE)); - } - containsPoint2(p) { - assertVectors(p); - const contourContainsPoint = this.surface.loopContainsPoint(this.contour, p); - if (contourContainsPoint != PointVsFace$2.INSIDE) - return contourContainsPoint; - for (const hole of this.holes) { - const loopContainsPoint = this.surface.loopContainsPoint(hole, p); - if (loopContainsPoint != PointVsFace$2.OUTSIDE) { - return loopContainsPoint == PointVsFace$2.ON_EDGE - ? PointVsFace$2.ON_EDGE - : PointVsFace$2.OUTSIDE; - } - } - return PointVsFace$2.INSIDE; - } - /** - * - * @param line - * @returns t param of the line if there is an intersection, NaN otherwise - */ - intersectsLine(line) { - assertInst(L3$1, line); - if (!this.getAABB().intersectsLine(line)) - return NaN; - const containedIntersectionsTs = this.surface - .isTsForLine(line) - .filter((t) => this.containsPoint(line.at(t))); - const nearestPointT = min$1(containedIntersectionsTs); - return undefined != nearestPointT ? nearestPointT : NaN; - } - toMesh() { - const mesh = new Mesh() - .addIndexBuffer("TRIANGLES") - .addIndexBuffer("LINES") - .addVertexBuffer("normals", "ts_Normal"); - this.addToMesh(mesh); - //mesh.compile() - return mesh; - } - zDirVolume() { - return this.surface.zDirVolume(this.getAllEdges()); - } - calcArea() { - return this.surface.calculateArea(this.getAllEdges()); - } - getLoops() { - return [this.contour, ...this.holes]; - } - getAABB() { - return (this.aabb || - (this.aabb = AABB.forAABBs(this.contour.map((e) => e.getAABB())))); - } - pointsToInside3(p, curve, curveT, dir) { - const eps = 1e-6; - const normal = this.surface.normalP(p); - const curveTangent = curve.tangentAt(curveT).times(dir); - const up = normal.cross(curveTangent); - const ecd = curve - .at(curveT) - .to(curve.at(curveT + dir * eps)) - .dot(up); - let minValue = Infinity, result, advanced = false; - for (const edge of this.getAllEdges()) { - const aEqP = edge.a.like(p), bEqP = edge.b.like(p); - assert(aEqP == edge.a.like(p)); - assert(bEqP == edge.b.like(p)); - if (!aEqP && !bEqP) - continue; - const edgeTangent = aEqP ? edge.aDir : edge.bDir.negated(); - const angle = curveTangent.angleRelativeNormal(edgeTangent, normal); - if (eq0(angle)) { - if (curve.isColinearTo(edge.curve)) { - return PointVsFace$2.ON_EDGE; - } - const edgeT = aEqP ? edge.aT : edge.bT; - const edgeDir = (aEqP ? 1 : -1) * sign(edge.deltaT()); - const iscd = edge.curve.diff(edgeT, edgeDir * eps).dot(up); - //const iscd = edge.curve.at(edgeT).to(curve.at(edgeT + edgeDir * eps)).dot(up) - const diff = iscd - ecd; - if (diff > 0 && (!advanced || diff < minValue)) { - advanced = true; - minValue = diff; - result = aEqP ? PointVsFace$2.OUTSIDE : PointVsFace$2.INSIDE; - } - } - else if (!advanced) { - const angle2 = (angle + TAU) % TAU; - if (angle2 < minValue) { - minValue = angle2; - result = aEqP ? PointVsFace$2.OUTSIDE : PointVsFace$2.INSIDE; - } - } - } - if (result == undefined) - throw new Error(); - return result; - } - pointsToInside2(p, dir) { - return this.pointsToInside3(p, L3$1.anchorDirection(p, dir), 0, 1); - //const normal = this.surface.normalP(p) - //let minAngle = Infinity, inOut = false - //function test(v, b) { - // const angle = (dir.angleRelativeNormal(v, normal) + TAU + NLA_PRECISION / 2) % TAU - // if (angle <= 2 * NLA_PRECISION) { - // return true - // } - // if (angle < minAngle) { - // minAngle = angle - // inOut = b - // } - //} - //for (const edge of this.getAllEdges()) { - // assert(edge.a.equals(p) || !edge.a.like(p)) - // assert(edge.b.equals(p) || !edge.b.like(p)) - // if (edge.a.equals(p) && test(edge.aDir, false)) return PointVsFace.ON_EDGE - // if (edge.b.equals(p) && test(edge.bDir.negated(), true)) return PointVsFace.ON_EDGE - //} - //return inOut ? PointVsFace.INSIDE : PointVsFace.OUTSIDE - } -} -class PlaneFace extends Face { - constructor(p, contour, holes, name, info) { - assert(p instanceof P3$2 || p instanceof PlaneSurface$2); - super(p instanceof P3$2 ? new PlaneSurface$2(p) : p, contour, holes, name, info); - } - static forVertices(planeSurface, vs, ...holeVss) { - const _planeSurface = planeSurface instanceof P3$2 ? new PlaneSurface$2(planeSurface) : planeSurface; - assert(isCCW(vs, _planeSurface.plane.normal1), "isCCW(vs, planeSurface.plane.normal1)"); - const edges = StraightEdge$1.chain(vs); - holeVss.forEach((vs) => assert(doubleSignedArea(vs, _planeSurface.plane.normal1) >= 0, "doubleSignedArea(vs, planeSurface.plane.normal1) >= 0")); - const holes = holeVss.map((hvs) => StraightEdge$1.chain(hvs)); - return new PlaneFace(planeSurface, edges, holes); - } - addToMesh(mesh) { - const mvl = mesh.vertices.length; - const normal = this.surface.plane.normal1; - const vertices = this.contour.flatMap((edge) => edge.getVerticesNo0()); - for (let i = 0; i < vertices.length; i++) { - mesh.LINES.push(mvl + i, mvl + ((i + 1) % vertices.length)); - } - const holeStarts = []; - this.holes.forEach((hole) => { - holeStarts.push(vertices.length); - vertices.push(...hole.flatMap((edge) => edge.getVerticesNo0())); - }); - const triangles = triangulateVertices$1(normal, vertices, holeStarts).map((index) => index + mvl); - Array.prototype.push.apply(mesh.vertices, vertices); - Array.prototype.push.apply(mesh.TRIANGLES, triangles); - Array.prototype.push.apply(mesh.normals, arrayFromFunction(vertices.length, () => normal)); - } - intersectsLine(line) { - assertInst(L3$1, line); - const lambda = line.isTWithPlane(this.surface.plane); - if (!Number.isFinite(lambda)) { - return NaN; - } - const inside = this.containsPoint(line.at(lambda)); - return inside ? lambda : NaN; - } - //intersectPlaneFace(face2: PlaneFace, - // thisBrep: BRep, - // face2Brep: BRep, - // faceMap: Map, - // thisEdgePoints: CustomMap, - // otherEdgePoints: CustomMap, - // checkedPairs: CustomSet>) { - // assertInst(CustomMap, thisEdgePoints, otherEdgePoints) - // - // function hasPair(a: Equalable, b: Equalable) { - // return checkedPairs.has(new Pair(a, b)) - // } - // function addPair(a: Equalable, b: Equalable) { - // return checkedPairs.add(new Pair(a, b)) - // } - // - // /** - // * @param newEdge generated segment - // * @param col1 if newEdge is colinear to an edge of this, the edge in question - // * @param col2 same for face2 - // */ - // function handleNewEdge(newEdge: StraightEdge, col1: Edge, col2: Edge) { - // if (!col1 && !col2) { - // mapPush(faceMap, face, newEdge) - // mapPush(faceMap, face2, newEdge.flipped()) - // return true - // } - // function handleEdgeInFace(col1, col2, face, face2, thisBrep, face2Brep, coplanarSameIsInside: boolean, - // has, add) { if (col1 && !col2) { if (hasPair(col1.getCanon(), face2)) return //add(col1.getCanon(), face2) - // const face2Plane = face2.surface.plane // NB: a new edge is inserted even though it may be the same as an old - // one // however it indicates that it intersects the other volume here, i.e. the old edge cannot // be counted as - // 'inside' for purposes of reconstitution thisBrep.edgeFaces.get(col1.getCanon()).forEach(faceInfo => { //const - // dot = snap0(face2Plane.normal1.dot(faceInfo.inside)) //if (dot == 0 ? !coplanarSameIsInside : dot < 0) { const - // pointsInsideFace = fff(faceInfo, face2.surface) const edgeInside = pointsInsideFace == INSIDE || - // !coplanarSameIsInside && pointsInsideFace == COPLANAR_SAME const pushEdge = - // (faceInfo.edge.aDir.like(newEdge.aDir)) ? newEdge : newEdge.flipped() - // assert(faceInfo.edge.aDir.like(pushEdge.aDir)) edgeInside && mapPush(faceMap, faceInfo.face, pushEdge) }) const - // newEdgeInside = face2Plane.normal1.cross(newEdge.aDir) const sVEF1 = splitsVolumeEnclosingFaces(thisBrep, - // col1.getCanon(), newEdgeInside, face2Plane.normal1) let addNewEdge, addNewEdgeFlipped if (addNewEdge = sVEF1 == - // INSIDE || coplanarSameIsInside && sVEF1 == COPLANAR_SAME) { mapPush(faceMap, face2, newEdge) } const sVEF2 = - // splitsVolumeEnclosingFaces(thisBrep, col1.getCanon(), newEdgeInside.negated(), face2Plane.normal1) if - // (addNewEdgeFlipped = sVEF2 == INSIDE || coplanarSameIsInside && sVEF2 == COPLANAR_SAME) { mapPush(faceMap, - // face2, newEdge.flipped()) } if (addNewEdge || addNewEdgeFlipped || sVEF1 == COPLANAR_SAME && sVEF2 == INSIDE || - // sVEF2 == COPLANAR_SAME && sVEF1 == INSIDE) { return true } } } const c1 = handleEdgeInFace(col1, col2, face, - // face2, thisBrep, face2Brep, false, hasPair, addPair) const c2 = handleEdgeInFace(col2, col1, face2, face, - // face2Brep, thisBrep, true, (a, b) => hasPair(b, a), (a, b) => addPair(b, a)) if (c1 || c2) return true if (col1 - // && col2) { if (hasPair(col1.getCanon(), col2.getCanon())) return addPair(col1.getCanon(), col2.getCanon()) - // function handleColinearEdgeFaces(col1, col2, thisBrep, face2Brep, coplanarSameIsInside: boolean, thisEdgePoints, - // has, add) { // not entirely sure for what i had the dirInsides in? //const aDirNegatedInside = - // (newEdge.a.like(col2.a) || newEdge.a.like(col2.b)) && splitsVolumeEnclosingCone(face2Brep, newEdge.a, - // newEdge.aDir.negated()) == INSIDE //const bDirInside = (newEdge.b.like(col2.a) || newEdge.b.like(col2.b)) && - // splitsVolumeEnclosingCone(face2Brep, newEdge.b, newEdge.bDir) == INSIDE - // thisBrep.edgeFaces.get(col1.getCanon()).forEach(faceInfo => { const sVEF = splitsVolumeEnclosingFaces(face2Brep, - // col2.getCanon(), faceInfo.inside, faceInfo.normalAtCanonA) const edgeInside = sVEF == INSIDE || - // coplanarSameIsInside && sVEF == COPLANAR_SAME const pushEdge = (faceInfo.edge.aDir.like(newEdge.aDir)) ? newEdge - // : newEdge.flipped() edgeInside && mapPush(faceMap, faceInfo.face, pushEdge) }) } handleColinearEdgeFaces(col1, - // col2, thisBrep, face2Brep, true, thisEdgePoints, hasPair, addPair) handleColinearEdgeFaces(col2, col1, - // face2Brep, thisBrep, false, otherEdgePoints, (a, b) => hasPair(b, a), (a, b) => addPair(b, a)) } } // what - // needs to be generated: new edges on face // points on edges where they are cut by faces so that sub edges will - // be generated for loops // points on ends of edges where the edge will be an edge in the new volume where it goes - // from A to B // you don't want thos to be marked as 'inside', otherwise invalid faces will be added // if - // a face cuts a corner, nothings needs to be done, as that alone does not limit what adjacent faces will be - // function handleEndPoint(a: IntersectionPointInfo, b: IntersectionPointInfo, newEdge: Edge) { // ends in the - // middle of b's face if (a && !b) { if (!a.colinear && a.edgeT != a.edge.aT && a.edgeT != a.edge.bT) { - // mapPush(thisEdgePoints, a.edge.getCanon(), a) assert(a.edge.isValidT(a.edgeT)) } // else colinear segment ends - // in middle of other face, do nothing } // ends in the middle of a's face if (b && !a) { if (!b.colinear && - // b.edgeT != b.edge.aT && b.edgeT != b.edge.bT) { mapPush(otherEdgePoints, b.edge.getCanon(), b) - // assert(b.edge.isValidT(b.edgeT)) } // else colinear segment ends in middle of other face, do nothing } if (a && - // b) { // if a or b is colinear the correct points will already have been added to the edge by handleNewEdge // - // segment starts/ends on edge/edge intersection function foo(a, b, face, face2, thisPlane, face2Plane, thisBrep, - // face2Brep, first, thisEdgePoints) { if (!a.colinear && a.edgeT != a.edge.aT && a.edgeT != a.edge.bT) { if - // (!hasPair(a.edge.getCanon(), b.edge.getCanon())) { addPair(a.edge.getCanon(), b.edge.getCanon()) // ends on a, - // on colinear segment b bT != a.edge.bT && // b can be colinear, so edgeT == aT is possible if (a.p.like(b.edge.a) - // || a.p.like(b.edge.b)) { const corner = a.p.like(b.edge.a) ? b.edge.a : b.edge.b // face2brep corner on edge - // const sVEC1 = splitsVolumeEnclosingCone(face2Brep, corner, a.edge.aDir) const sVEC2 = - // splitsVolumeEnclosingCone(face2Brep, corner, a.edge.aDir.negated()) // if either of these return - // ALONG_EDGE_OR_PLANE, then the breps share a colinear edge if (INSIDE == sVEC1 || INSIDE == sVEC2) { - // mapPush(thisEdgePoints, a.edge.getCanon(), a) assert(a.edge.isValidT(a.edgeT)) } } else { // edge / edge center - // intersection const aEdgeDir = a.edge.tangentAt(a.edgeT) const bEdgeDir = b.edge.tangentAt(b.edgeT) const - // testVector = aEdgeDir.rejectedFrom(bEdgeDir) assert(!testVector.likeO()) const sVEF1 = - // splitsVolumeEnclosingFaces(face2Brep, b.edge.getCanon()Vector, thisPlane.normal1) const sVEF2 = - // splitsVolumeEnclosingFaces(face2Brep, b.edge.getCanon()Vector.negated(), thisPlane.normal1) if (INSIDE == - // sVEF1 || INSIDE == sVEF2) { mapPush(thisEdgePoints, a.edge.getCanon(), a) assert(a.edge.isValidT(a.edgeT)) } } } - // } } foo(a, b, face, face2, thisPlane, face2Plane, thisBrep, face2Brep, true, thisEdgePoints) foo(b, a, face2, - // face, face2Plane, thisPlane, face2Brep, thisBrep, false, otherEdgePoints) } } assertInst(PlaneFace, face2) - // const face: PlaneFace = this // get intersection const thisPlane = this.surface.plane, face2Plane = - // face2.surface.plane if (thisPlane.isParallelToPlane(face2Plane)) { if (thisPlane.like(face2Plane)) { // normal1 - // same and same location in space // addLikeSurfaceFaces(likeSurfaceFaces, this, face2) } return } const isLine = - // L3.fromPlanes(thisPlane, face2Plane) // get intersections of newCurve with other edges of face and face2 const - // ps1 = planeFaceEdgeISPsWithPlane(face, isLine, face2Plane) const ps2 = planeFaceEdgeISPsWithPlane(face2, isLine, - // thisPlane) if (ps1.length == 0 || ps2.length == 0) { // faces to not intersect return } let col1: - // IntersectionPointInfo, col2: IntersectionPointInfo let in1 = false, in2 = false let i = 0, j = 0, last let - // startP, startDir, startT, startA, startB while (i < ps1.length || j < ps2.length) { assert(i <= ps1.length) - // assert(j <= ps2.length) const a = ps1[i], b = ps2[j] assert(a || b) if (j == ps2.length || i < ps1.length && - // lt(a.t, b.t)) { last = a in1 = !in1 a.used = true in1 && (col1 = a.colinear && a) i++ } else if (i == ps1.length - // || gt(a.t, b.t)) { last = b in2 = !in2 b.used = true in2 && (col2 = b.colinear && b) j++ } else { // TODO: this - // will break if 3 points on the same t last = a in1 = !in1 in2 = !in2 //if (in1 == in2) { a.used = true b.used = - // true in1 && (col1 = a.colinear && a) in2 && (col2 = b.colinear && b) //} i++ j++ } if (startP && !(in1 && in2)) - // { // segment end const newEdge = new StraightEdge(isLine, startP, last.p, startT, last.t, undefined, 'genseg' + - // getGlobalId()) startP = undefined last.used = true if (handleNewEdge(newEdge, col1 && col1.edge, col2 && - // col2.edge)) { handleEndPoint(startA || col1, startB || col2, newEdge) handleEndPoint(a && a.used && a || col1, b - // && b.used && b || col2, newEdge) } } else if (in1 && in2) { // new segment just started startP = last.p startDir - // = last.insideDir startT = last.t startA = a && a.used && a startB = b && b.used && b } if (!in1 && a && last == - // a && a.colinear) { checkedPairs.add(new Pair(a.edge.getCanon(), face2)) } if (!in2 && b && (last == b || b.used) - // && b.colinear) { checkedPairs.add(new Pair(b.edge.getCanon(), face)) } } } - withHole(holeEdges) { - return new PlaneFace(this.surface, this.contour, [holeEdges]); - } - pointsToInside(p, dir) { - return this.containsPoint2(p.plus(dir.times(NLA_PRECISION * 8))); - } - edgeISPsWithPlane(isLine, plane2) { - const face = this; - assert(face.surface.plane.containsLine(isLine)); - assert(plane2.containsLine(isLine)); - const plane = face.surface.plane; - const ps = []; - const loops = [face.contour].concat(face.holes); - loops.forEach((loop) => { - const colinearEdges = loop.map((edge) => edge.colinearToLine(isLine) && -sign(edge.aDir.dot(isLine.dir1))); - const isLineOut = isLine.dir1.cross(plane.normal1); - loop.forEach((edge, edgeIndex, edges) => { - const nextEdgeIndex = (edgeIndex + 1) % edges.length, nextEdge = edges[nextEdgeIndex], colinearEdge = colinearEdges[edgeIndex]; - //console.log(edge.toSource()) {p:V3(2, -2.102, 0), - if (colinearEdge) { - // edge colinear to intersection line - const curveAT = isLine.pointT(edge.a), curveBT = isLine.pointT(edge.b); - // add interval for colinear segment - ps.push({ - p: edge.a, - insideDir: edge.aDir, - t: curveAT, - edge: edge, - edgeT: edge.aT, - colinear: true, - }, { - p: edge.b, - insideDir: edge.bDir.negated(), - t: curveBT, - edge: edge, - edgeT: edge.bT, - colinear: true, - }); - // open next interval if necessary - const nextSide = colinearEdges[nextEdgeIndex] || - dotCurve2$2(nextEdge.curve, nextEdge.aT, isLineOut, nextEdge.deltaTSign()); - if (colinearEdge * nextSide < 0) { - // side changes - ps.push({ - p: nextEdge.a, - insideDir: edge.bDir, - t: curveBT, - edge: nextEdge, - edgeT: nextEdge.aT, - colinear: false, - }); - } - } - else { - // not necessarily a straight edge, so multiple intersections are possible - const edgeTs = edge.edgeISTsWithPlane(plane2); - assert(edgeTs.every((t) => plane2.containsPoint(edge.curve.at(t))), edgeTs); - for (const edgeT of edgeTs) { - if (edgeT == edge.bT) { - // endpoint lies on intersection line - const side = dotCurve2$2(edge.curve, edge.bT, isLineOut, -edge.deltaTSign()); - const nextSide = colinearEdges[nextEdgeIndex] || - dotCurve2$2(nextEdge.curve, nextEdge.aT, isLineOut, nextEdge.deltaTSign()); - if (side * nextSide < 0) { - // next segment is not colinear and ends on different side - ps.push({ - p: edge.b, - insideDir: plane2.normal1.negated(), - t: isLine.pointT(edge.b), - edge: edge, - edgeT: edge.bT, - colinear: false, - }); - } - } - else if (edgeT != edge.aT) { - // edge crosses intersection line, neither starts nor ends on it - const p = edge.curve.at(edgeT); - assert(plane2.containsPoint(p), edge.toString(), p, edgeT, plane2.distanceToPoint(p)); - assert(isLine.containsPoint(p), edge.toString(), p, edgeT, isLine.distanceToPoint(p)); - const insideDir = plane2.normal1.negated(); - ps.push({ - p: p, - insideDir: insideDir, - t: isLine.pointT(p), - edge: edge, - edgeT: edgeT, - colinear: false, - }); - } - } - } - }); - }); - // duplicate 't's are ok, as sometimes a segment needs to stop and start again - // should be sorted so that back facing ones are first - ps.sort((a, b) => a.t - b.t || a.insideDir.dot(isLine.dir1)); - return ps; - } -} -class RotationFace extends Face { - constructor(rot, contour, holes, name, info) { - super(rot, contour, holes, name, info); - } - static loopDoesNotCrossPlane(loop, seamPlane) { - let side = 0; - // returns true if d is on the other side as previous calls - function checkSide(d) { - if (side == 0) { - side = d; - } - else { - return !side || side * d < 0; - } - return false; - } - for (const edge of loop) { - const ts = edge.edgeISTsWithPlane(seamPlane); - if (ts.length == 0) { - if (!(edge.curve instanceof L3$1) && - checkSide(seamPlane.distanceToPointSigned(edge.a))) - return false; - } - else { - for (const t of ts) { - // TODO: this part probably should be in a separate function - // check 'backwards' only if if aT != t - if (edge.aT != t) { - if (checkSide(dotCurve2$2(edge.curve, t, seamPlane.normal1, -edge.deltaTSign()))) - return false; - } - if (edge.bT != t) { - if (checkSide(dotCurve2$2(edge.curve, t, seamPlane.normal1, edge.deltaTSign()))) - return false; - } - } - } - } - return true; - } - getAABB() { - if (this.aabb) - return this.aabb; - this.aabb = AABB.forAABBs(this.contour.map((e) => e.getAABB())); - this.aabb.addPoints(this.surface.getExtremePoints().filter((p) => this.containsPoint(p))); - return this.aabb; - } - unrollLoop(edgeLoop) { - const vs = []; - const uvP = this.surface.uvPFunc(); - const verticesNo0s = edgeLoop.map((edge) => edge.getVerticesNo0()); - const startEdgeIndex = verticesNo0s.findIndex((edgeVertices) => !eq(uvP(edgeVertices[0]).x, Math.PI)); - assert(-1 != startEdgeIndex); - // console.log(startEdgeIndex) - for (let i = 0; i < edgeLoop.length; i++) { - const edgeIndex = (i + startEdgeIndex) % edgeLoop.length; - for (let j = 0; j < verticesNo0s[edgeIndex].length; j++) { - const p = verticesNo0s[edgeIndex][j]; - const localP = uvP(p); - // console.log(hint, p.sce, localP.sce) - vs.push(localP); - } - } - edgeLoop.forEach((edge) => { - edge.getVerticesNo0().forEach((p) => { - vs.push(uvP(p)); - }); - }); - console.log("vs\n", vs.join("\n"), vs.length); - return vs; - } - /** - * f1 cos t + f2 sin t - * tan(phi) = sin / cos - * = (f1x cos t + f2x sin t) / (f1y cos t + f2y sin t) - * - * = (-f1x sin t + f2x cos t) / (-f1y sin t + f2y cos t) - */ - unrollEllipsoidLoops(edgeLoops) { - const verticesUV = [], vertices = [], loopStarts = []; - const ellipsoid = this.surface; - const ptpf = ellipsoid.uvPFunc(); - const testDegeneratePoint = ellipsoid instanceof EllipsoidSurface$1 - ? (nextStart) => nextStart.like(ellipsoid.center.plus(ellipsoid.f3)) || - nextStart.like(ellipsoid.center.minus(ellipsoid.f3)) - : (nextStart) => nextStart.like(this.surface.center); - for (const edgeLoop of edgeLoops) { - loopStarts.push(verticesUV.length); - // console.log(startEdgeIndex) - for (let i = 0; i < edgeLoop.length; i++) { - const ipp = (i + 1) % edgeLoop.length; - const verticesNo0 = edgeLoop[i].getVerticesNo0(); - vertices.push(...verticesNo0); - verticesUV.push(...verticesNo0.map((v) => ptpf(v))); - const nextStart = edgeLoop[ipp].a; - //console.log('BLAH', nextStart.str, ellipsoid.center.plus(ellipsoid.f3).str) - if (testDegeneratePoint(nextStart)) { - const bDirLC = ellipsoid.matrixInverse.transformVector(edgeLoop[i].bDir), aDirLC = ellipsoid.matrixInverse.transformVector(edgeLoop[ipp].aDir); - const inAngle = Math.atan2(-bDirLC.y, -bDirLC.x); - const outAngle = Math.atan2(aDirLC.y, aDirLC.x); - const stLast = verticesUV.pop(); - verticesUV.push(new V3(inAngle, stLast.y, 0), new V3(outAngle, stLast.y, 0)); - vertices.push(getLast(vertices)); - } - verticesUV.forEach(({ u, v }) => { - assert(isFinite(u)); - assert(isFinite(v)); - }); - } - } - let normals; - if (this.surface instanceof EllipsoidSurface$1) { - normals = vertices.map((v) => ellipsoid.normalP(v)); - } - else { - const normalUV = ellipsoid.normalUVFunc(); - normals = verticesUV.map(({ u, v }) => normalUV(u, v)); - } - assert(vertices.length == vertices.length); - //console.log(verticesUV.map(v => v.str).join('\n')) - return { - verticesUV: verticesUV, - vertices: vertices, - normals: normals, - loopStarts: loopStarts, - }; - } - unrollCylinderLoops(loops) { - const vertexLoops = loops.map((loop) => loop.flatMap((edge) => edge.getVerticesNo0())); - const surface = this.surface; - const vertices = concatenated(vertexLoops); - // this.unrollLoop(loop).map(v => new V3(v.x / uStep, v.y / vStep, 0))) - const loopStarts = vertexLoops.reduce((arr, loop) => (arr.push(getLast(arr) + loop.length), arr), [0]); - const uvPFunc = surface.uvPFunc(); - const verticesUV = vertices.map((v) => uvPFunc(v)); - const uvN = surface.normalUVFunc(); - const normals = verticesUV.map(({ u, v }) => uvN(u, v)); - return { - verticesUV: verticesUV, - vertices: vertices, - normals: normals, - loopStarts: loopStarts, - }; - } - /** - * at(s, t) = new V3(s cos t, s sin t, t + ) - * - * x = 0 - * - * s cos t = 0 - * ==> s = 0 || cos t = 0 - * ==> L3.Z || V3(0, +-s, k * 2 pi) - * - * x = c - * s cos t = c - * ==> V3(c, c sin t / cos t = c tan t, t) - * ==> V3(c, c t, arctan t) - * - * - * x . n = w - * s cos t nx + s sin t ny + t nz = w - * s = (w - t nz) / (cos t nx + sub t ny) - * ==> V3( - * cos t (w - t nz) / (cos t nx + sin t ny) - * sin t (w - t nz) / (cos t nx + sin t ny) - * t) - * - * ==> V3( - * (w - z arctan t) / (x + t y) - * (w - z arctan t) / (y + x / t) - * arctan t) - * - * - * - */ - addToMesh(mesh, uStep = this.surface.uStep, vStep = this.surface.vStep) { - assertf(() => uStep > 0 && vStep > 0, uStep, vStep, "Surface: " + this.surface); - const triangles = []; - const pMN = (m, n) => this.surface.pUVFunc()(m * uStep, n * vStep); - const normalMN = (m, n) => this.surface.normalUVFunc()(m * uStep, n * vStep); - const loops = this.getLoops(); - const { vertices, verticesUV, normals, loopStarts } = this.surface instanceof EllipsoidSurface$1 || - this.surface instanceof ConicSurface$1 - ? this.unrollEllipsoidLoops(loops) - : this.unrollCylinderLoops(loops); - loopStarts.push(vertices.length); - const verticesMN = verticesUV.map(({ u, v }) => new V3(u / uStep, v / vStep, 0)); - for (let vertexLoopIndex = 0; vertexLoopIndex < loops.length; vertexLoopIndex++) { - const vertexLoopStart = loopStarts[vertexLoopIndex]; - const vertexLoopLength = loopStarts[vertexLoopIndex + 1] - vertexLoopStart; - const base = mesh.vertices.length + loopStarts[vertexLoopIndex]; - for (let i = 0; i < vertexLoopLength; i++) { - mesh.LINES.push(base + i, base + ((i + 1) % vertexLoopLength)); - } - } - disableConsole(); - let minM = Infinity, maxM = -Infinity, minN = Infinity, maxN = -Infinity; - //console.log('surface', this.surface.str) - //console.log(verticesMN) - //drPs.push(...verticesMN.map((v, i) => ({p: vertices[i], text: `${i} uv: ${v.toString(x => round10(x, - // -4))}`}))) - verticesMN.forEach(([m, n]) => { - assert(isFinite(m)); - assert(isFinite(n)); - minM = min(minM, m); - maxM = max(maxM, m); - minN = min(minN, n); - maxN = max(maxN, n); - }); - if (ParametricSurface$2.is(this.surface)) ; - const mOffset = floor(minM + NLA_PRECISION), nOffset = floor(minN + NLA_PRECISION); - const mRes = ceil(maxM - NLA_PRECISION) - mOffset, nRes = ceil(maxN - NLA_PRECISION) - nOffset; - console.log(uStep, vStep, mRes, nRes); - if (mRes == 1 && nRes == 1) { - // triangulate this face as if it were a plane - const polyTriangles = triangulateVertices$1(V3.Z, verticesMN, loopStarts.slice(1, 1 + this.holes.length)); - triangles.push(...polyTriangles); - } - else { - const partss = new Array(mRes * nRes); - function fixUpPart(part, baseM, baseN) { - assert(baseM < mRes && baseN < nRes, `${baseM}, ${baseN}, ${mRes}, ${nRes}`); - console.log("complete part", part, baseM, baseN); - //console.trace() - assert(part.length); - const cellM = baseM + mOffset, cellN = baseN + nOffset; - for (const index of part) { - assert(le(cellM, verticesMN[index].x) && - le(verticesMN[index].x, cellM + 1), `${index} ${verticesMN[index].str} ${cellM} ${cellM}`); - assert(le(cellN, verticesMN[index].y) && - le(verticesMN[index].y, cellN + 1)); - } - const pos = baseN * mRes + baseM; - (partss[pos] || (partss[pos] = [])).push(part); - //const outline = partss[pos] || (partss[pos] = [minM + baseM * uStep, minN + baseN * vStep, minM + - // (baseM + 1) * uStep, minN + (baseN + 1) * vStep]) - } - // 'some' instead of forEach so we can return out of the entire function if this.edges crosses no borders - // and - for (let vertexLoopIndex = 0; vertexLoopIndex < loops.length; vertexLoopIndex++) { - let part = undefined; - let firstPart = undefined; - let firstPartBaseM = -1; - let firstPartBaseN = -1; - let lastBaseM = -1, lastBaseN = -1; - let partCount = 0; - const vertexLoopStart = loopStarts[vertexLoopIndex]; - const vertexLoopLength = loopStarts[vertexLoopIndex + 1] - vertexLoopStart; - for (let vlvi = 0; vlvi < vertexLoopLength; vlvi++) { - const vx0index = vertexLoopStart + vlvi, vx0 = verticesMN[vx0index]; - const vx1index = vertexLoopStart + ((vlvi + 1) % vertexLoopLength), vx1 = verticesMN[vx1index]; - //console.log('dask', vx0index, vx1index) - const vx01 = vx0.to(vx1); - assert(vx0); - const di = vx01.x, dj = vx01.y; - let vxIndex = vx0index, vx = vx0, currentT = 0; - let whileLimit = 400; - while (--whileLimit) { - // points which are on a grid line are assigned to the cell into which they are going (+ - // NLA_PRECISION * sign(di)) if they are parallel to the gridline (eq0(di)), they belong the - // the cell for which they are a CCW boundary - const baseM = floor(vx.u + (!eq0(di) ? sign(di) : -sign(dj)) * NLA_PRECISION) - - mOffset; - const baseN = floor(vx.v + (!eq0(dj) ? sign(dj) : sign(di)) * NLA_PRECISION) - - nOffset; - assert(baseM < mRes && baseN < nRes, `${baseM}, ${baseN}, ${mRes}, ${nRes}`); - // figure out the next intersection with a gridline: - // iNext is the positive horizontal distance to the next vertical gridline - const iNext = ceil(sign(di) * vx.u + NLA_PRECISION) - sign(di) * vx.u; - const jNext = ceil(sign(dj) * vx.v + NLA_PRECISION) - sign(dj) * vx.v; - const iNextT = currentT + iNext / abs(di); - const jNextT = currentT + jNext / abs(dj); - //console.log(vxIndex, vx.str, 'vij', vx.u, vx.v, 'd', di, dj, 'ijNext', iNext, jNext, 'nextT', - // iNextT, jNextT) - if (lastBaseM != baseM || lastBaseN != baseN) { - if (part) { - if (!firstPart) { - firstPart = part; - firstPartBaseM = lastBaseM; - firstPartBaseN = lastBaseN; - } - else { - partCount++; - fixUpPart(part, lastBaseM, lastBaseN); - } - } - part = [vxIndex]; - } - lastBaseM = baseM; - lastBaseN = baseN; - currentT = min(iNextT, jNextT); - if (ge(currentT, 1)) { - //console.log('breaking ', vx1index) - part.push(vx1index); - break; - } - else { - const nextPoint = vx0.lerp(vx1, currentT); - const nextPointIndex = addVertex(nextPoint.x, nextPoint.y); - //console.log('pushing ', nextPointIndex) - part.push(nextPointIndex); - vx = nextPoint; - vxIndex = nextPointIndex; - } - } - assert(whileLimit, "whileLimit"); - } - if (0 == partCount) { - // complete loop - assert(false, "found a hole, try increasing resolution"); - } - // at this point, the firstPart hasn't been added, and the last part also hasn't been added - // either they belong to the same cell, or not - if (firstPartBaseM == lastBaseM && firstPartBaseN == lastBaseN) { - part.pop(); - fixUpPart(part.concat(firstPart), lastBaseM, lastBaseN); - } - else { - fixUpPart(firstPart, firstPartBaseM, firstPartBaseN); - fixUpPart(part, lastBaseM, lastBaseN); - } - console.log("firstPart", firstPart); - } - console.log("calculated parts", partss); - const fieldVertexIndices = new Array((mRes + 1) * (nRes + 1)); - function addVertex(m, n) { - verticesMN.push(new V3(m, n, 0)); - normals.push(normalMN(m, n)); - return vertices.push(pMN(m, n)) - 1; - } - function getGridVertexIndex(i, j) { - const index = j * (mRes + 1) + i; - return (fieldVertexIndices[index] || - (fieldVertexIndices[index] = addVertex(i + mOffset, j + nOffset))); - } - for (let col = 0; col < mRes; col++) { - let inside = false; - for (let row = 0; row < nRes; row++) { - const pos = row * mRes + col; - const fieldU = mOffset + col, fieldV = nOffset + row; - const parts = partss[pos]; - if (!parts) { - if (inside) { - pushQuad(triangles, false, getGridVertexIndex(col, row), getGridVertexIndex(col + 1, row), getGridVertexIndex(col, row + 1), getGridVertexIndex(col + 1, row + 1)); - } - } - else { - // assemble the field with segments in in - function opos(index) { - const p = verticesMN[index], u1 = p.x - fieldU, v1 = p.y - fieldV; - assert(-NLA_PRECISION < u1 && - u1 < 1 + NLA_PRECISION && - -NLA_PRECISION < v1 && - v1 < 1 + NLA_PRECISION, "oob u1 v1 " + - u1 + - " " + - v1 + - " " + - index + - " " + - p.str + - "IF THIS FAILS check canonSeamU is correct"); - return v1 < u1 ? u1 + v1 : 4 - u1 - v1; - } - while (parts.length) { - const outline = []; - const startPart = parts[0]; - assert(startPart.length > 0); - let currentPart = startPart; - do { - outline.push(...currentPart); - const currentPartEndOpos = opos(getLast(currentPart)); - const nextPartIndex = indexWithMax(parts, (part) => -mod(opos(part[0]) - currentPartEndOpos, 4)); - const nextPart = bagRemoveIndex(parts, nextPartIndex); - let currentOpos = currentPartEndOpos; - const nextPartStartOpos = opos(nextPart[0]) > currentOpos - ? opos(nextPart[0]) - : opos(nextPart[0]) + 4; - let nextOpos = ceil(currentOpos + NLA_PRECISION); - let flipping = eq0(((currentOpos + NLA_PRECISION) % 1) - NLA_PRECISION); - //inside = inside != (!eq0(currentOpos % 1) && currentOpos % 2 < 1) - while (lt(nextOpos, nextPartStartOpos)) { - switch (nextOpos % 4) { - case 0: - outline.push(getGridVertexIndex(col, row)); - break; - case 1: - inside = inside != flipping; - outline.push(getGridVertexIndex(col + 1, row)); - break; - case 2: - outline.push(getGridVertexIndex(col + 1, row + 1)); - break; - case 3: - inside = inside != flipping; - outline.push(getGridVertexIndex(col, row + 1)); - break; - } - flipping = true; - nextOpos++; - } - // if the next loop would have completed a top or bottom segment - inside = - inside != - (flipping && - nextOpos % 2 == 1 && - eq(nextOpos, nextPartStartOpos)); - currentOpos = nextOpos; - currentPart = nextPart; - } while (currentPart != startPart); - // triangulate outline - if (outline.length == 3) { - // its just a triangle - triangles.push(...outline); - } - else { - const polyTriangles = triangulateVertices$1(V3.Z, outline.map((i) => verticesMN[i]), []).map((i) => outline[i]); - triangles.push(...polyTriangles); - } - //console.log('outline', col, row, outline) - } - } - } - } - } - //console.log('trinagle', triangles.max(), vertices.length, triangles.length, triangles.toSource(), - // triangles.map(col => vertices[col].$).toSource() ) assert(normals.every(n => n.hasLength(1)), normals.find(n - // => !n.hasLength(1)).length() +' '+normals.findIndex(n => !n.hasLength(1))) - Array.prototype.push.apply(mesh.TRIANGLES, triangles.map((index) => index + mesh.vertices.length)); - Array.prototype.push.apply(mesh.vertices, vertices); - Array.prototype.push.apply(mesh.normals, normals); - //this.addEdgeLines(mesh) - enableConsole(); - } - addToMesh2(mesh) { - const zSplit = 8; - const ribs = []; - let minZ = Infinity, maxZ = -Infinity; - //let cmp = (a, b) => a.value - b.value - const f = this.surface.pUVFunc(); - const normalF = this.surface.normalUVFunc(); - const vertexLoops = this.holes - .concat([this.contour]) - .map((loop) => this.unrollLoop(loop)); - vertexLoops.forEach((vertexLoop) => { - vertexLoop.forEach(({ x: d, y: z }) => { - const index0 = binaryIndexOf(ribs, d, (a, b) => snap(a.value - b, 0)); - if (index0 < 0) { - ribs.splice(-index0 - 1, 0, { value: d, left: [], right: [] }); - } - minZ = min(minZ, z); - maxZ = max(maxZ, z); - }); - }); - console.log("zzzs", minZ, maxZ, vertexLoops[0].toSource().replace(/\), /g, ",\n")); - const correction = 1; - vertexLoops.forEach((vertexLoop) => { - vertexLoop.forEach((v0, i, vs) => { - let v1 = vs[(i + 1) % vs.length], dDiff = v1.x - v0.x; - //console.log(v0.sce, v1.sce) - if (eq0(dDiff)) { - return; - } - if (dDiff < 0) { - [v0, v1] = [v1, v0]; - dDiff = -dDiff; - } - const index0 = binaryIndexOf(ribs, v0.x, (a, b) => snap(a.value - b, 0)); - const index1 = binaryIndexOf(ribs, v1.x, (a, b) => snap(a.value - b, 0)); - binaryInsert(ribs[index0].right, v0.y); - for (let j = (index0 + correction) % ribs.length; j != index1; j = (j + correction) % ribs.length) { - const x = ribs[j].value; - const part = (x - v0.x) / dDiff; - const interpolated = v1.y * part + v0.y * (1 - part); - binaryInsert(ribs[j].left, interpolated); - binaryInsert(ribs[j].right, interpolated); - } - binaryInsert(ribs[index1].left, v1.y); - // console.log(ribs.map(r=>r.toSource()).join('\n')) - }); - }); - const vertices = [], triangles0 = [], normals = []; - for (let i = 0; i < ribs.length; i++) { - const ribLeft = ribs[i], ribRight = ribs[(i + 1) % ribs.length]; - assert(ribLeft.right.length == ribRight.left.length); - for (let j = 0; j < ribLeft.right.length; j++) { - vertices.push(f(ribLeft.value, ribLeft.right[j]), f(ribRight.value, ribRight.left[j])); - normals.push(normalF(ribLeft.value, ribLeft.right[j]), normalF(ribRight.value, ribRight.left[j])); - } - } - //console.log(ribs.map(r=>r.toSource()).join('\n')) - const vss = vertices.length, detailVerticesStart = vss; - const zInterval = maxZ - minZ, zStep = zInterval / zSplit; - const detailZs = arrayFromFunction(zSplit - 1, (i) => minZ + (1 + i) * zStep); - console.log("detailsZs", detailZs); - for (let i = 0; i < ribs.length; i++) { - const d = ribs[i].value; - for (let j = 0; j < detailZs.length; j++) { - vertices.push(f(d, detailZs[j])); - normals.push(normalF(d, detailZs[j])); - } - } - // console.log('detailVerticesStart', detailVerticesStart, 'vl', vertices.length, vertices.length - - // detailVerticesStart, ribs.length) finally, fill in the ribs - let vsStart = 0; - const flipped2 = true; - //for (var i = 0; i < 1; i++) { - const end = ribs.length - 1; - for (let i = 0; i < end; i++) { - const ipp = (i + 1) % ribs.length; - let inside = false, colPos = 0; - const ribLeft = ribs[i], ribRight = ribs[(i + 1) % ribs.length]; - for (let j = 0; j < detailZs.length + 1; j++) { - const detailZ = detailZs[j] || 100000; - if (!inside) { - if (ribLeft.right[colPos] < detailZ && - ribRight.left[colPos] < detailZ) { - if (ribLeft.right[colPos + 1] < detailZ || - ribRight.left[colPos + 1] < detailZ) { - pushQuad(triangles0, flipped2, vsStart + colPos * 2, vsStart + (colPos + 1) * 2, vsStart + colPos * 2 + 1, vsStart + (colPos + 1) * 2 + 1); - colPos += 2; - if (ribLeft.right[colPos] < detailZ || - ribRight.left[colPos] < detailZ) { - j--; - } - } - else { - pushQuad(triangles0, flipped2, vsStart + colPos * 2, vsStart + colPos * 2 + 1, detailVerticesStart + i * detailZs.length + j, detailVerticesStart + ipp * detailZs.length + j); - inside = true; - colPos++; - } - } - } - else { - if (ribLeft.right[colPos] < detailZ || - ribRight.left[colPos] < detailZ) { - pushQuad(triangles0, flipped2, detailVerticesStart + i * detailZs.length + j - 1, detailVerticesStart + ipp * detailZs.length + j - 1, vsStart + colPos * 2, vsStart + colPos * 2 + 1); - inside = false; - colPos++; - if (ribLeft.right[colPos] < detailZ || - ribRight.left[colPos] < detailZ) { - j--; - } - } - else { - pushQuad(triangles0, flipped2, detailVerticesStart + i * detailZs.length + j, detailVerticesStart + i * detailZs.length + j - 1, detailVerticesStart + ipp * detailZs.length + j, detailVerticesStart + ipp * detailZs.length + j - 1); - } - } - } - vsStart += ribLeft.right.length * 2; - } - //console.log('trinagle', triangles0.max(), vertices.length, triangles0.length, triangles0.toSource(), - // triangles0.map(i => vertices[i].$).toSource() ) - const triangles = triangles0.map((index) => index + mesh.vertices.length); - //assert(normals.every(n => n.hasLength(1)), normals.find(n => !n.hasLength(1)).length() +' - // '+normals.findIndex(n => !n.hasLength(1))) - Array.prototype.push.apply(mesh.vertices, vertices); - Array.prototype.push.apply(mesh.TRIANGLES, triangles); - Array.prototype.push.apply(mesh.normals, normals); - //this.addEdgeLines(mesh) - } -} - -const EPS = 1e-5; -let globalId = 0; -function getGlobalId() { - return globalId++; -} -function addLikeSurfaceFaces(likeSurfaceFaces, face1, face2) { - // There cannot be two subgroups which will later be connected, as the "graph" of like surface faces is fully - // connected - for (let i = 0; i < likeSurfaceFaces.length; i++) { - const faceGroup = likeSurfaceFaces[i]; - let foundFace1 = false, foundFace2 = false; - for (let j = 0; j < faceGroup.length; j++) { - const face = faceGroup[j]; - if (face == face1) { - foundFace1 = true; - } - if (face == face2) { - foundFace2 = true; - } - } - if (foundFace1 != foundFace2) { - faceGroup.push(foundFace1 ? face2 : face1); - return; - } - else if (foundFace1) { - // found both - return; - } - } - // nothing found, add a new group - likeSurfaceFaces.push([face1, face2]); -} -function assembleFaceFromLooseEdges(edges, surface, originalFace) { - const visited = new Set(); - function nextStart() { - return edges.find((edge) => !visited.has(edge)); - } - const loops = []; - let startEdge, currentEdge = undefined; - while ((startEdge = nextStart())) { - currentEdge = startEdge; - const loop = []; - let total = 0; - do { - visited.add(currentEdge); - loop.push(currentEdge); - const possibleEdges = edges.filter((edge) => currentEdge.b.like(edge.a)); - const normalAtCurrentB = surface.normalP(currentEdge.b); - const nextEdgeIndex = indexWithMax(possibleEdges, (edge) => currentEdge.bDir.angleRelativeNormal(edge.aDir, normalAtCurrentB)); - currentEdge = possibleEdges[nextEdgeIndex]; - } while (startEdge != currentEdge && total++ < 200); - assert(total != 201); - loops.push(loop); - } - const assembledFaces = BRep.assembleFacesFromLoops(loops, surface, originalFace); - assertf(() => 1 == assembledFaces.length); - return assembledFaces[0]; -} -/** - * ## Markdown header - * ![foo](screenshots/Capture.PNG) - * {@link ../screenshots/Capture.PNG} - * find the next edge with the MAXIMUM angle - */ -function calcNextEdgeIndex(currentEdge, possibleEdges, faceNormalAtCurrentB) { - let maxValue = -20, advanced = false, result = Number.MAX_SAFE_INTEGER; - const normVector = currentEdge.bDir.cross(faceNormalAtCurrentB); - const eps = 1e-4; - const dir = sign(currentEdge.deltaT()); - const ecd = currentEdge.curve.diff(currentEdge.bT, -dir * eps).dot(normVector); - for (let i = possibleEdges.length; i--;) { - const edge = possibleEdges[i]; - const angle1 = currentEdge.bDir - .negated() - .angleRelativeNormal(edge.aDir, faceNormalAtCurrentB); - const angle = ((angle1 + TAU + NLA_PRECISION) % TAU) - NLA_PRECISION; - if (eq0(angle)) { - // do advanced analysis - if (currentEdge.curve.isColinearTo(edge.curve)) { - continue; - } - const edgeDir = sign(edge.deltaT()); - const iscd = edge.curve.diff(edge.aT, edgeDir * eps).dot(normVector); - const diff = iscd - ecd; - // if diff > 0, the angle is actually ~= 0 - if (diff < 0 && (!advanced || diff > maxValue)) { - advanced = true; - maxValue = diff; - result = i; - } - } - else if (!advanced) { - if (gt(angle, maxValue)) { - maxValue = angle; - result = i; - } - } - } - return result == Number.MAX_SAFE_INTEGER ? 0 : result; -} -class BRep extends Transformable { - constructor(faces, infiniteVolume, generator, vertexNames) { - super(); - this.faces = faces; - assertInst(Face$1, ...faces); - this.infiniteVolume = infiniteVolume; - assert(!this.infiniteVolume || true === this.infiniteVolume); - this.generator = generator; - this.vertexNames = vertexNames; - this.edgeFaces = undefined; - //this.assertSanity() - } - static loop1ContainsLoop2(loop1, ccw1, loop2, ccw2, surface) { - for (const edge of loop2) { - const loop1ContainsPoint = surface.loopContainsPoint(loop1, edge.a); - if (PointVsFace$2.ON_EDGE != loop1ContainsPoint) - return PointVsFace$2.INSIDE == loop1ContainsPoint; - } - for (const edge of loop2) { - const edgePoint = edge.curve.at(edge.aT * 0.2 + edge.bT * 0.8); - const loop1ContainsPoint = surface.loopContainsPoint(loop1, edgePoint); - if (PointVsFace$2.ON_EDGE != loop1ContainsPoint) - return PointVsFace$2.INSIDE == loop1ContainsPoint; - } - if (ccw1 != ccw2) { - return ccw2; - } - throw new Error(loop1.sce + loop2.sce); - } - static assembleFacesFromLoops(loops, surface, originalFace, infoFactory) { - function placeRecursively(newLoopInfo, loopInfos) { - if (loopInfos.length == 0) { - loopInfos.push(newLoopInfo); - } - else { - const subLoopInfo = loopInfos.find((loopInfo) => BRep.loop1ContainsLoop2(loopInfo.loop, loopInfo.ccw, newLoopInfo.loop, newLoopInfo.ccw, surface)); - if (subLoopInfo) { - placeRecursively(newLoopInfo, subLoopInfo.subloops); - } - else { - // newLoopInfo isnt contained by any other subLoopInfo - for (let i = loopInfos.length; --i >= 0;) { - const subLoopInfo = loopInfos[i]; - //console.log("cheving subLoopInfo", surface.loopContainsPoint(newLoopInfo.edges, - // subLoopInfo.edges[0].a)) - if (BRep.loop1ContainsLoop2(newLoopInfo.loop, newLoopInfo.ccw, subLoopInfo.loop, subLoopInfo.ccw, surface)) { - newLoopInfo.subloops.push(subLoopInfo); - loopInfos.splice(i, 1); // remove it - } - } - loopInfos.push(newLoopInfo); - } - } - } - function newFacesRecursive(loopInfo) { - // CW loops can be top level, if they are holes in the original face not contained in the new face - if (loopInfo.ccw) { - if (loopInfo.subloops.every((sl) => !sl.ccw)) { - const holes = loopInfo.subloops.map((sl) => sl.loop); - const info = infoFactory && - infoFactory.newSubFace(originalFace, surface, loopInfo.loop, holes); - const newFace = new originalFace.constructor(surface, loopInfo.loop, holes, "genface" + getGlobalId(), info); - newFaces.push(newFace); - loopInfo.subloops.forEach((sl) => sl.subloops.forEach((slsl) => slsl.ccw && newFacesRecursive(slsl))); - } - else { - loopInfo.subloops.forEach((sl) => sl.ccw && newFacesRecursive(sl)); - } - } - } - const newFaces = []; - const topLevelLoops = []; - loops.forEach((loop) => placeRecursively({ - loop: loop, - ccw: surface.edgeLoopCCW(loop), - subloops: [], - }, topLevelLoops)); - topLevelLoops.forEach((tll) => newFacesRecursive(tll)); - return newFaces; - } - /** - * Create a [BRep] by concatenating the faces of other BReps. Only use this if certain that the faces of the BReps do not intersect. - * Otherwise, use [BRep.plus]. - * @param bReps - * @param generator - */ - static join(bReps, generator) { - return new BRep(bReps.flatMap((b2) => b2.faces), false, generator); - } - containsPoint(p, forceInsideOutside = false) { - const dirs = [ - V(-0.3920414696448526, -0.12936136783391444, -0.9108068525164064), - V(0.6520650903544943, -0.07151288645511984, -0.7547827667692488), - V(0.9433494201061395, -0.2402757256238473, -0.22882186797013926), - V(0.13678704228501923, -0.04480387361087783, 0.9895867410047372), - V(0.0662057922721913, -0.5865836917435423, 0.8071780259955845), - V(-0.7322576567870621, -0.12953393611526787, 0.6685953061989045), - V(0.6579719127258273, -0.012300218400456116, 0.7529420075219719), - V(-0.5576497966736425, 0.8006695748324647, 0.2189861552871446), - ]; - dirLoop: for (const dir of dirs) { - const testLine = new L3$1(p, dir); - let inside = this.infiniteVolume; - for (const face of this.faces) { - assert(!face.surface.containsCurve(testLine)); - const ists = face.surface.isTsForLine(testLine); - for (const t of ists) { - const p = testLine.at(t); - const pvf = face.containsPoint2(p); - //assert(pvf != PointVsFace.ON_EDGE) - !forceInsideOutside && assert(!eq0(t)); - if (t > 0) { - if (pvf == PointVsFace$2.ON_EDGE) { - continue dirLoop; - } - if (pvf == PointVsFace$2.INSIDE) { - inside = !inside; - } - } - } - } - return inside; - } - return false; - } - withMergedFaces() { - const likeSurfaceFaces = []; - for (let i = 0; i < this.faces.length; i++) { - let addedToGroup = false; - for (let j = 0; j < i; j++) { - if (this.faces[i].surface.isCoplanarTo(this.faces[j].surface)) { - const faceGroup = likeSurfaceFaces.find((faceGroup) => faceGroup.includes(this.faces[j])); - if (faceGroup) { - faceGroup.push(this.faces[i]); - addedToGroup = true; - } - } - } - !addedToGroup && likeSurfaceFaces.push([this.faces[i]]); - } - console.log("likeSurfaceFaces", likeSurfaceFaces); - if (likeSurfaceFaces.every((group) => group.length == 1)) - return this; - const newFaces = []; - let total = 0; - for (const faceGroup of likeSurfaceFaces) { - console.log(faceGroup); - if (faceGroup.length == 1) { - newFaces.push(faceGroup[0]); - } - else { - const allEdges = faceGroup.flatMap((face) => face.getAllEdges()); - for (let i = allEdges.length; i-- > 0;) { - for (let j = 0; j < i; j++) { - console.log("blugh", total); - assert(i >= 0 && j >= 0 && total++ < 500, i + " " + j + " " + total); - if (allEdges[i].isCoEdge(allEdges[j])) { - // remove both - allEdges.splice(i, 1); - allEdges.splice(j, 1); - i--; - break; - } - } - } - const newFace = assembleFaceFromLooseEdges(allEdges, faceGroup[0].surface, faceGroup[0]); - newFaces.push(newFace); - } - } - return new BRep(newFaces, this.infiniteVolume, this.generator && this.generator + ".withMergedFaces()", this.vertexNames); - } - calculateVolume() { - return sum(this.faces.map((face) => face.zDirVolume().volume)); - } - toMesh() { - const mesh = new Mesh() - .addVertexBuffer("normals", "ts_Normal") - .addIndexBuffer("TRIANGLES") - .addIndexBuffer("LINES"); - mesh.faceIndexes = new Map(); - for (const face of this.faces) { - const triangleStart = mesh.TRIANGLES.length; - face.addToMesh(mesh); - mesh.faceIndexes.set(face, { - start: triangleStart, - count: mesh.TRIANGLES.length - triangleStart, - }); - } - //this.buildAdjacencies() - //for (const edge of this.edgeFaces.keys()) { - // - //} - return mesh; - } - minus(other, infoFactory) { - const generator = this.generator && - other.generator && - this.generator + ".minus(" + other.generator + ")"; - return this.intersection(other.flipped(), true, true, generator, infoFactory); - } - plus(other, infoFactory) { - const generator = this.generator && - other.generator && - this.generator + ".plus(" + other.generator + ")"; - return this.flipped() - .intersection(other.flipped(), true, true, generator, infoFactory) - .flipped(); - } - and(other, infoFactory) { - const generator = this.generator && - other.generator && - this.generator + ".and(" + other.generator + ")"; - return this.intersection(other, true, true, generator, infoFactory); - } - xor(other, infoFactory) { - const generator = this.generator && - other.generator && - this.generator + ".xor(" + other.generator + ")"; - return new BRep(this.minus(other, infoFactory).faces.concat(other.minus(this, infoFactory).faces), this.infiniteVolume != other.infiniteVolume, generator); - } - equals(obj) { - return (this.faces.length == obj.faces.length && - this.faces.every((face) => obj.faces.some((face2) => face.equals(face2)))); - } - like(brep) { - return (this.faces.length == brep.faces.length && - this.faces.every((face) => brep.faces.some((face2) => face.likeFace(face2)))); - } - //reconstituteCoplanarFaces(likeSurfacePlanes, edgeLooseSegments, faceMap, newFaces) { - // likeSurfacePlanes.forEach(faceGroup => { - // // calculate total contours - // let surface = faceGroup[0].surface, bag = [] - // faceGroup.forEach(face => { - // Array.prototype.push.apply(bag, faceMap(face)) - // face.getAllEdges().forEach(edge => { - // let edgeSubSegments - // if (edgeSubSegments = edgeLooseSegments.get(edge)) { - // Array.prototype.push.apply(bag, edgeSubSegments) - // } else { - // bag.push(edge) - // } - // }) - // }) - // let currentEdge, loops = [] - // while (currentEdge = bag.find(edge => !edge.visited)) { - // let path = [] - // do { - // currentEdge.visited = true - // path.push(currentEdge) - // let possibleNextEdges = bag.filter(edge => currentEdge.b.like(edge.a)) - // // lowest angle, i.e. the right-most next edge - // let nextEdgeIndex = possibleNextEdges.indexWithMax((edge, index) => - // -currentEdge.bDir.angleRelativeNormal(edge.aDir, surface.normalP(currentEdge.b))) currentEdge = - // possibleNextEdges[nextEdgeIndex] } while (!currentEdge.visited) let startIndex = path.find(currentEdge) if (-1 - // != startIndex) { loops.push(path.slice(startIndex)) } } }) } - toString() { - return `new BRep([\n${this.faces.join(",\n").replace(/^/gm, "\t")}], ${this.infiniteVolume})`; - } - getConstructorParameters() { - return [this.faces, this.infiniteVolume]; - } - toSource(useGenerator = true) { - return ((useGenerator && this.generator) || - `new BRep([\n${this.faces.map(SCE).join(",\n").replace(/^/gm, "\t")}], ${this.infiniteVolume})`); - } - /** - * Rightmost next segment doesn't work, as the correct next segment isn't obvious from the current corner - * alone. - * (at least, not without extensive pre-analysis on the face edges, which shouldn't be necessary, as the - * correct new faces are defined by the new edges already.) Leftmost edge should work. Holes which touch the - * edge of the face will be added to the face contour. - * - * New segments will always be part left-er than existing ones, so no special check is required. - * - */ - reconstituteFaces(oldFaces, edgeSubEdges, faceMap, newFaces, infoFactory) { - const oldFaceStatuses = new Map(); - // reconstitute faces - const insideEdges = []; - for (const face of oldFaces) { - const usableOldEdges = face - .getAllEdges() - .filter((edge) => !edgeSubEdges.get(edge)); - const subEdges = concatenated(mapFilter(face.getAllEdges(), (edge) => edgeSubEdges.get(edge))); - const newEdges = faceMap.get(face) || []; - if (newEdges.length || subEdges.length) { - oldFaceStatuses.set(face, "partial"); - const loops = []; - // new edges are definitely part of a resulting loop - // old edges (both contour and holes) can either be part of a new loop, in which case they will already - // have been visited when starting a loop search with a new edge, OR they can be stranded, OR they can - // remain in their old loop - function getNextStart() { - return (newEdges.find((edge) => !visitedEdges.has(edge)) || - subEdges.find((edge) => !visitedEdges.has(edge)) || - usableOldEdges.find((edge) => !visitedEdges.has(edge))); - } - const visitedEdges = new Set(); - // search for a loop: - let currentEdge; - while ((currentEdge = getNextStart())) { - const startEdge = currentEdge, edges = []; - let i = 0; - // wether only new edges are used (can include looseSegments) - do { - visitedEdges.add(currentEdge); - edges.push(currentEdge); - // find next edge - const possibleOldEdges = usableOldEdges.filter((edge) => currentEdge.b.like(edge.a)); - const possibleSubEdges = subEdges.filter((edge) => currentEdge.b.like(edge.a)); - const possibleNewEdges = newEdges.filter((edge) => currentEdge.b.like(edge.a)); - const possibleEdges = possibleOldEdges.concat(possibleSubEdges, possibleNewEdges); - if (0 == possibleEdges.length) - break; - assert(0 < possibleEdges.length, () => face.sce); - const faceNormalAtCurrentB = face.surface.normalP(currentEdge.b); - const nextEdgeIndex = calcNextEdgeIndex(currentEdge, possibleEdges, faceNormalAtCurrentB); - currentEdge = possibleEdges[nextEdgeIndex]; - if (visitedEdges.has(currentEdge)) { - break; - } - assert(currentEdge); - assert(currentEdge != startEdge); - } while (++i < 400); - if (400 == i) { - assert(false, "too many"); - } - // check if we found a loop - if (edges.length > 1 && currentEdge == startEdge) { - loops.push(edges); - } - } - const faceNewFaces = BRep.assembleFacesFromLoops(loops, face.surface, face, infoFactory); - newFaces.push(...faceNewFaces); - const faceNewFacesEdges = faceNewFaces.flatMap((face) => face.getAllEdges()); - insideEdges.push(...usableOldEdges.filter((edge) => faceNewFacesEdges.includes(edge))); - } - } - while (insideEdges.length != 0) { - const insideEdge = insideEdges.pop(); - const adjacentFaces = this.edgeFaces.get(insideEdge.getCanon()); - adjacentFaces.forEach((info) => { - if (!oldFaceStatuses.has(info.face)) { - oldFaceStatuses.set(info.face, "inside"); - insideEdges.push.apply(insideEdges, info.face.getAllEdges()); - } - }); - } - newFaces.push(...oldFaces.filter((face) => oldFaceStatuses.get(face) == "inside")); - } - static getLooseEdgeSegments(edgePointInfoss, edgeFaces) { - const result = new JavaMap(); - // if there are no point info, the original edge will be kept, so we should return nothing - // otherwise, something will be returned, even if it a new edge identical to the base edge - for (const [canonEdge, pointInfos] of edgePointInfoss) { - if (0 == pointInfos.length) - continue; - const allFaces = edgeFaces.get(canonEdge); - pointInfos.sort((a, b) => snap0(a.edgeT - b.edgeT) || +!!undefined); - let startP = canonEdge.a, startDir = canonEdge.aDir, startT = canonEdge.aT, startInfo; - function addNewEdge(startInfo, endInfo, newEdge) { - for (let i = 0; i < allFaces.length; i++) { - const faceInfo = allFaces[i]; - mapPush(result, !faceInfo.reversed ? canonEdge : canonEdge.flipped(), !faceInfo.reversed ? newEdge : newEdge.flipped()); - } - } - for (let i = 0; i < pointInfos.length; i++) { - const info = pointInfos[i]; - const pDir = canonEdge.tangentAt(info.edgeT); - if (!eq(info.edgeT, startT)) { - const newEdge = createEdge$1(canonEdge.curve, startP, info.p, startT, info.edgeT, undefined, startDir, pDir, "looseSegment" + getGlobalId()); - addNewEdge(startInfo, info, newEdge); - } - startP = info.p; - startT = info.edgeT; - startInfo = info; - startDir = pDir; - } - if (startInfo && !eq(startT, canonEdge.bT)) { - const newEdge = createEdge$1(canonEdge.curve, startP, canonEdge.b, startT, canonEdge.bT, undefined, startDir, canonEdge.bDir, "looseSegment" + getGlobalId()); - addNewEdge(startInfo, undefined, newEdge); - } - } - return result; - } - getIntersectionEdges(brep2) { - const faceMap = new Map(), thisEdgePoints = new JavaMap(), otherEdgePoints = new JavaMap(); - const checkedPairs = new JavaSet(); - this.faces.forEach((face) => { - //console.log('face', face.toString()) - brep2.faces.forEach((face2) => { - //console.log('face2', face2.toString()) - face.intersectFace(face2, this, brep2, faceMap, thisEdgePoints, otherEdgePoints, checkedPairs); - }); - }); - return concatenated(Array.from(faceMap.values())); - } - shellCount() { - const foundFaces = new Set(); - let face, result = 0; - while ((face = this.faces.find((face) => !foundFaces.has(face)))) { - result++; - const stack = [face]; - while ((face = stack.pop())) { - // @ts-ignore - for (const edge of face.getAllEdges()) { - // @ts-ignore - for (const { face: face2 } of this.edgeFaces.get(edge.getCanon())) { - if (face !== face2 && !foundFaces.has(face2)) { - foundFaces.add(face2); - stack.push(face2); - } - } - } - } - } - return result; - } - getAABB() { - return AABB.forAABBs(this.faces.map((face) => face.getAABB())); - } - assertSanity() { - if (!NLA_DEBUG) - return; - // const allFaceEdges = this.faces.flatMap(face => face.getAllEdges()) - // for (const { i, j } of combinations(allFaceEdges.length)) { - // const a = allFaceEdges[i], - // b = allFaceEdges[j] - // assert(i == j || !a.isCoEdge(b) || a == b || a.flippedOf == b, 'coedges not linked properly', a, b) - // assert( - // i == j || - // !a.curve.isColinearTo(b.curve) || - // (a.curve.equals(b.curve) && a.isCoEdge(b)) || - // !a.overlaps(b), - // 'colinear edges overlap', - // a, - // b, - // ) - // } - this.buildAdjacencies(); - for (const [canonEdge, edgeFaceInfos] of this.edgeFaces) { - // TODO handle curved faces - assert(edgeFaceInfos.length % 2 == 0, () => canonEdge + edgeFaceInfos.sce); - } - } - //intersection3(other: BRep, buildThis: boolean, buildOther: boolean, name?: string): BRep { - // this.assertSanity() - // other.assertSanity() - // this.buildAdjacencies() - // other.buildAdjacencies() - // - // // edge / edge - // for (const [edge1, edge1Faces] of this.edgeFaces) { - // for (const [edge2, edge2Faces] of other.edgeFaces) { - // const curve1 = edge1.curve, curve2 = edge2.curve - // if (curve1.isColinearTo(curve2)) { - // if (edge1.overlaps(edge2)) { - // // faces have a common edge - // const aT = curve1.pointT(edge2.a), bT = curve1.pointT(edge2.a) - // const minT = min(aT, bT), maxT = max(aT, bT) - // const commonEdge = createEdge(curve1, min(edge1.minT, minT), min(edge1.maxT, maxT), ) - // } - // } else if (x = curve1.isInfosWithCurve(edge2.curve)) { - // // edges intersect in a point - // } - // } - // } - // - // // point / edge - // function pointEdge(b1, b2, has, add) { - // for (const v1 of this.vertFaces.keys()) { - // for (const edge2 of other.edgeFaces.keys()) { - // if (edge2.curve.containsPoint(v1)) { - // const edge2T = edge2.curve.pointT(v1) - // if (eq(edge2.aT, edge2T) || eq(edge2.bT, edge2T)) { - // add(v1, eq(edge2.aT, edge2T) ? edge2.a : edge2.b) - // } - // } - // } - // } - // } - // const pairs: CustomSet<[Equalable, Equalable]> = new CustomSet<[Equalable, Equalable]>() - // pointEdge(this, other, (a, b) => pairs.has([a, b]), (a, b) => pairs.add([a, b])) - // pointEdge(other, this, (b, a) => pairs.has([a, b]), (b, a) => pairs.add([a, b])) - // - // - // // point / point - // for (const v1 of this.vertFaces.keys()) { - // for (const v2 of other.vertFaces.keys()) { - // if (v1.like(v2)) { - // - // } - // } - // } - // - // for (const face1 of this.faces) { - // for (const face2 of other.faces) { - // face1.intersectFace(face2) - // } - // } - // - //} - buildAdjacencies() { - if (this.edgeFaces) - return this; - this.edgeFaces = new JavaMap(); - for (const face of this.faces) { - for (const edge of face.getAllEdges()) { - const canon = edge.getCanon(); - const normalAtCanonA = face.surface.normalP(canon.a); - const inside = normalAtCanonA.cross(canon == edge ? edge.aDir : edge.bDir); - mapPush(this.edgeFaces, canon, { - face: face, - edge: edge, - normalAtCanonA: normalAtCanonA, - reversed: canon != edge, - inside: inside, - angle: 0, - }); - } - } - for (const [canonEdge, edgeFaceInfos] of this.edgeFaces) { - // TODO handle curved faces - //assert(edgeFaceInfos.length % 2 == 0, () => canonEdge + edgeFaceInfos.sce) - const faceInfo0 = edgeFaceInfos.find((faceInfo) => faceInfo.reversed); - if (!faceInfo0) { - console.warn("invalid brep"); - continue; - } - edgeFaceInfos.forEach((faceInfo) => { - if (faceInfo != faceInfo0) { - faceInfo.angle = faceInfo0.inside.angleRelativeNormal(faceInfo.inside, canonEdge.aDir.unit()); - if (faceInfo.angle < 0) - faceInfo.angle += 2 * Math.PI; - } - }); - edgeFaceInfos.sort((a, b) => snap(a.angle - b.angle, 0)); // TODO || assertNever() - } - return this; - } - /** - * Cases for volumes A and B - * - * 1. Volumes do not touch. - * 2. face/face Face surfaces intersect each other. - * implies edges going through faces. - * e.g. box(5, 5, 5) - box(5, 5, 5).translate(1, 1, 1) - * 3. face/edge Edge of A lies in a face of B - * implies vertices of A lying in face of B - * e.g. box(5, 5, 5) - box(3, 3, 3).rotateZ([0, 1, 2] * PI / 2).translate(0, 1, 1) - * 4. edge/edge Two edges are colinear. - * implies vertex of A lying in edge of B - * 5. vertex/edge Vertex of A lies on edge of B (but no edge/edge) - * 6. vertex/vertex with/without edge/edge, edge/face and face/face intersections - * 7. vertex lies in face - * - * - * - */ - intersection(other, buildThis, buildOther, generator, infoFactory) { - this.assertSanity(); - other.assertSanity(); - this.buildAdjacencies(); - other.buildAdjacencies(); - const faceMap = new Map(); - const thisEdgePoints = new JavaMap(), otherEdgePoints = new JavaMap(); - const checkedPairs = new JavaSet(); - for (const thisFace of this.faces) { - for (const otherFace of other.faces) { - thisFace.intersectFace(otherFace, this, other, faceMap, thisEdgePoints, otherEdgePoints, checkedPairs); - } - } - for (const edge of thisEdgePoints.keys()) { - assert(this.edgeFaces.get(edge)); - } - for (const edge of otherEdgePoints.keys()) { - assert(other.edgeFaces.get(edge)); - } - const newFaces = []; - if (0 == faceMap.size && - 0 == thisEdgePoints.size && - 0 == otherEdgePoints.size) { - const thisInOther = other.containsPoint(this.faces[0].contour[0].a, true) !== - other.infiniteVolume; - const otherInThis = !thisInOther && - this.containsPoint(other.faces[0].contour[0].a) !== this.infiniteVolume; - if (thisInOther || otherInThis) { - const [inside, outside] = thisInOther ? [this, other] : [other, this]; - if (inside.infiniteVolume) { - if (outside.infiniteVolume) { - return outside; - } - else { - return BRep.join([inside, outside]); - } - } - else { - if (outside.infiniteVolume) { - return BRep.EMPTY; - } - else { - return inside; - } - } - } - else { - if (this.infiniteVolume) { - if (other.infiniteVolume) { - return BRep.join([this, other]); - } - } - else { - if (other.infiniteVolume) { - return this; - } - else { - return BRep.EMPTY; - } - } - } - return BRep.EMPTY; - } - else { - if (buildThis) { - const edgeLooseSegments = BRep.getLooseEdgeSegments(thisEdgePoints, this.edgeFaces); - // @ts-ignore - const els = this.faces.map((face) => [ - face, - Array.from(edgeLooseSegments.entries()).flatMap(([edge, subs]) => face.getAllEdges().some((e) => e.equals(edge)) ? subs : []), - ]); - this.reconstituteFaces(this.faces, edgeLooseSegments, faceMap, newFaces, infoFactory); - } - if (buildOther) { - const edgeLooseSegments = BRep.getLooseEdgeSegments(otherEdgePoints, other.edgeFaces); - // @ts-ignore - const els = other.faces.map((face) => [ - face, - Array.from(edgeLooseSegments.entries()).flatMap(([edge, subs]) => face.getAllEdges().some((e) => e.equals(edge)) ? subs : []), - ]); - other.reconstituteFaces(other.faces, edgeLooseSegments, faceMap, newFaces, infoFactory); - } - } - //buildCoplanar && this.reconstituteCoplanarFaces(likeSurfaceFaces, edgeLooseSegments, faceMap, newFaces, - // this.infiniteVolume, other.infiniteVolume) - const result = new BRep(newFaces, this.infiniteVolume && other.infiniteVolume, generator); - //result.buildAdjacencies() - return result; - } - transform(m4, desc) { - let vertexNames; - if (this.vertexNames) { - vertexNames = new Map(); - this.vertexNames.forEach((name, vertex) => vertexNames.set(m4.transformPoint(vertex), name + desc)); - } - return new BRep(this.faces.map((f) => f.transform(m4)), this.infiniteVolume, this.generator && desc && this.generator + desc, // if desc isn't set, the generator will be invalid - vertexNames); - } - transform4(m4, desc) { - let vertexNames; - if (this.vertexNames) { - vertexNames = new Map(); - this.vertexNames.forEach((name, vertex) => vertexNames.set(m4.transformPoint(vertex), name + desc)); - } - return new BRep(this.faces.map((f) => f.transform4(m4)), this.infiniteVolume, this.generator && desc && this.generator + desc, // if desc isn't set, the generator will be invalid - vertexNames); - } - flipped() { - return new BRep(this.faces.map((f) => f.flipped()), !this.infiniteVolume, this.generator && this.generator + ".flipped()", this.vertexNames); - } -} -BRep.EMPTY = new BRep([], false, "BRep.EMPTY", new Map()).buildAdjacencies(); -BRep.R3 = new BRep([], true, "BRep.R3", new Map()).buildAdjacencies(); -function dotCurve(v, cDir, cDDT) { - let dot = v.dot(cDir); - if (eq0(dot)) { - dot = v.dot(cDDT); - } - assert(!eq0(dot)); - return dot; -} -function dotCurve2(curve, t, normal, sign) { - assert(sign == 1 || sign == -1, sign); - const tangentDot = curve.tangentAt(t).dot(normal); - // if tangentDot != 0 the curve simply crosses the plane - if (!eq0(tangentDot)) { - return sign * tangentDot; - } - if (curve.ddt) { - const ddtDot = curve.ddt(t).dot(normal); - // tangentDot == 0 ==> critical point at t, if ddtDot != 0, then it is a turning point, otherwise we can't be sure - // and must do a numeric test - if (!eq0(ddtDot)) { - return ddtDot; - } - } - const numericDot = curve - .at(t) - .to(curve.at(t + sign * 4 * NLA_PRECISION)) - .dot(normal); - assert(!(curve instanceof L3$1)); - return numericDot; -} -const INSIDE = 0, OUTSIDE = 1, COPLANAR_SAME = 2, COPLANAR_OPPOSITE = 3, ALONG_EDGE_OR_PLANE = 4; -/** - * - * @param brep BREP to check - * @param edge edge to check - * @param dirAtEdgeA the direction vector to check - * @param faceNormal If dirAtEdgeA doesn't split a volume, but is along a face, the returned value depends on - * wether that faces normal1 points in the same direction as faceNormal - * @returns INSIDE, OUTSIDE, COPLANAR_SAME or COPLANAR_OPPOSITE - */ -//function splitsVolumeEnclosingFaces(brep: BRep, edge: Edge, dirAtEdgeA: V3, faceNormal: V3): int { -// assert(arguments.length == 4) -// //assert(p.equals(edge.a)) -// const ab1 = edge.aDir.unit() -// const relFaces = facesWithEdge(edge, brep.faces) as any[] -// relFaces.forEach(faceInfo => { -// faceInfo.normalAtEdgeA = faceInfo.face.surface.normalP(edge.a) -// faceInfo.edgeDirAtEdgeA = !faceInfo.reversed -// ? faceInfo.edge.aDir -// : faceInfo.edge.bDir -// faceInfo.outsideVector = faceInfo.edgeDirAtEdgeA.cross(faceInfo.normalAtEdgeA) -// faceInfo.angle = (dirAtEdgeA.angleRelativeNormal(faceInfo.outsideVector.negated(), ab1) + 2 * Math.PI + -// NLA_PRECISION / 2) % (2 * Math.PI) }) assert(relFaces.length != 0, edge.toSource()) relFaces.sort((a, b) => a.angle -// - b.angle) // assert(relFaces.length % 2 == 0, edge.toSource()) // even number of touching faces if -// (eq0(relFaces[0].angle)) { //assert(false) todo const coplanarSame = relFaces[0].normalAtEdgeA.dot(faceNormal) > 0; -// return coplanarSame ? COPLANAR_SAME : COPLANAR_OPPOSITE } else { return !relFaces[0].reversed ? INSIDE : OUTSIDE } } -function splitsVolumeEnclosingFaces(brep, canonEdge, dirAtEdgeA, faceNormal) { - assert(arguments.length == 4); - assert(canonEdge == canonEdge.getCanon()); - //assert(p.equals(canonEdge.a)) - const edgeFaceInfos = brep.edgeFaces.get(canonEdge); - assertf(() => edgeFaceInfos.length % 2 == 0); - assertf(() => brep.edgeFaces); - const faceInfo0 = edgeFaceInfos[0]; - const aDir1 = canonEdge.aDir.unit(); - const angleToCanon = ((faceInfo0.inside.angleRelativeNormal(dirAtEdgeA, aDir1) + - 2 * Math.PI + - NLA_PRECISION) % - (2 * Math.PI)) - - NLA_PRECISION; - const nearestFaceInfoIndex = edgeFaceInfos.findIndex((faceInfo) => lt(angleToCanon, faceInfo.angle)); - const nearestFaceInfo = edgeFaceInfos[nearestFaceInfoIndex == -1 - ? edgeFaceInfos.length - 1 - : nearestFaceInfoIndex - 1]; - if (eq(nearestFaceInfo.angle, angleToCanon)) { - //assert(false) todo - const coplanarSame = nearestFaceInfo.normalAtCanonA.dot(faceNormal) > 0; - return coplanarSame ? COPLANAR_SAME : COPLANAR_OPPOSITE; - } - else { - return nearestFaceInfo.reversed ? INSIDE : OUTSIDE; - } -} -function splitsVolumeEnclosingFacesP(brep, canonEdge, p, pInside, pFaceNormal) { - assert(arguments.length == 5); - assert(canonEdge == canonEdge.getCanon()); - //assert(p.equals(canonEdge.a)) - assertf(() => brep.edgeFaces); - const edgeFaceInfos = brep.edgeFaces.get(canonEdge); - assertf(() => edgeFaceInfos.length % 2 == 0); - const pDir1 = canonEdge.tangentAt(canonEdge.curve.pointT(p)).unit(); - const faceInfoAngleFromPInsideNeg = (faceInfo) => { - const faceInfoPDir = faceInfo.edge.getCanon() == faceInfo.edge ? pDir1 : pDir1.negated(); - const faceInfoInsideAtP = faceInfo.face.surface - .normalP(p) - .cross(faceInfoPDir); - const faceInfoAngleAtP = pInside.angleRelativeNormal(faceInfoInsideAtP, pDir1); - return -(((faceInfoAngleAtP + TAU + NLA_PRECISION) % TAU) - NLA_PRECISION); - }; - const nearestFaceInfo = withMax(edgeFaceInfos, faceInfoAngleFromPInsideNeg); - if (eq0(faceInfoAngleFromPInsideNeg(nearestFaceInfo))) { - //assert(false) todo - const coplanarSame = nearestFaceInfo.face.surface.normalP(p).dot(pFaceNormal) > 0; - return coplanarSame ? COPLANAR_SAME : COPLANAR_OPPOSITE; - } - else { - return nearestFaceInfo.reversed ? OUTSIDE : INSIDE; - } -} -function splitsVolumeEnclosingFacesP2(brep, canonEdge, p, testCurve, curveT, dir, faceNormal) { - assert(canonEdge == canonEdge.getCanon()); - //assert(p.equals(canonEdge.a)) - assertf(() => brep.edgeFaces); - const edgeFaceInfos = brep.edgeFaces.get(canonEdge); - assertf(() => edgeFaceInfos.length % 2 == 0); - const pDir1 = canonEdge.tangentAt(canonEdge.curve.pointT(p)).unit(); - let pInside = testCurve.tangentAt(curveT).times(dir); - if (pInside.isParallelTo(pDir1)) { - pInside = testCurve - .diff(curveT, (1e-4 * dir) / testCurve.tangentAt(curveT).length()) - .rejectedFrom(pDir1); - pInside = pInside.div(pInside.length()); - } - let minValue = 20, advanced = false, result = OUTSIDE; - for (const faceInfo of edgeFaceInfos) { - const faceInfoPDir = faceInfo.edge.getCanon() == faceInfo.edge ? pDir1 : pDir1.negated(); - const faceInfoInsideAtP = faceInfo.face.surface - .normalP(p) - .cross(faceInfoPDir); - const faceInfoAngleAtP = pInside.angleRelativeNormal(faceInfoInsideAtP, pDir1); - const angle = ((faceInfoAngleAtP + TAU + NLA_PRECISION) % TAU) - NLA_PRECISION; - if (eq0(angle)) { - // do advanced analysis - const normVector = faceInfo.face.surface.normalP(p); - if (faceInfo.face.surface.containsCurve(testCurve)) { - const coplanarSame = normVector.dot(faceNormal) > 0; - return coplanarSame ? COPLANAR_SAME : COPLANAR_OPPOSITE; - } - const testPlane = P3$2.normalOnAnchor(pDir1, p); - const isCurve = faceInfo.face.surface.isCurvesWithPlane(testPlane)[0]; - const isCurvePT = isCurve.pointT(p); - const dirFactor = sign(isCurve.tangentAt(isCurvePT).dot(pInside)); - const eps = 1e-4; - const iscd = isCurve - .at(isCurvePT) - .to(isCurve.at(isCurvePT + dir * dirFactor * eps)) - .dot(normVector); - const ecd = testCurve - .at(curveT) - .to(testCurve.at(curveT + dir * eps)) - .dot(normVector); - const diff = (iscd - ecd) * (faceInfo.reversed ? -1 : 1); - if (diff > 0 && (!advanced || diff < minValue)) { - advanced = true; - minValue = diff; - result = faceInfo.reversed ? OUTSIDE : INSIDE; - } - } - else if (!advanced) { - if (angle < minValue) { - minValue = angle; - result = faceInfo.reversed ? OUTSIDE : INSIDE; - } - } - } - return result; -} -function splitsVolumeEnclosingCone(brep, p, dir) { - const testPlane = P3$2.forAnchorAndPlaneVectors(p, dir, dir.getPerpendicular()); - const rays = []; - for (let k = 0; k < brep.faces.length; k++) { - const planeFace = brep.faces[k]; - assertf(() => planeFace instanceof PlaneFace$1); - if (planeFace.getAllEdges().some((edge) => edge.a.like(p))) { - if (testPlane.isParallelToPlane(planeFace.surface.plane)) { - if (planeFace.pointsToInside(p, dir) != PointVsFace$2.OUTSIDE) { - return ALONG_EDGE_OR_PLANE; - } - } - else { - const isLine = L3$1.fromPlanes(testPlane, planeFace.surface.plane); - const ps = planeFace.edgeISPsWithPlane(isLine, testPlane); - let i = 0; - while (i < ps.length) { - const a = ps[i++], b = ps[i++]; - const out = a.p.like(p); - if (out || b.p.like(p)) { - const dir2 = out ? isLine.dir1 : isLine.dir1.negated(); - const angle = (dir.angleRelativeNormal(dir2, testPlane.normal1) + - 2 * Math.PI + - NLA_PRECISION / 2) % - (2 * Math.PI); - rays.push({ angle: angle, out: out }); - } - } - } - } - } - rays.sort((a, b) => a.angle - b.angle); - //console.log("testPlane"Plane.toSource(), "rays", rays.toSource()) - if (eq0(rays[0].angle)) { - return ALONG_EDGE_OR_PLANE; - } - else { - return rays[0].out ? OUTSIDE : INSIDE; - } -} -function splitsVolumeEnclosingCone2(brep, p, curve, curveT, fb) { - assert(curve.containsPoint(p)); - const pFaces = brep.faces.filter((face) => face.getAllEdges().some((edge) => edge.a.like(p))); - for (let k = 0; k < pFaces.length; k++) { - const face = pFaces[k]; - if (face.surface.containsCurve(curve)) { - //assert(false) - if (face.pointsToInside3(p, curve, curveT, fb) != PointVsFace$2.OUTSIDE) { - return ALONG_EDGE_OR_PLANE; - } - } - } - const EPS = 1e-6; - return brep.containsPoint(curve.at(curveT + fb * EPS), true) - ? INSIDE - : OUTSIDE; -} -function fff(info, surface) { - const canonA = info.edge.reversed ? info.edge.b : info.edge.a; - const surfaceNormalAtCanonA = surface.normalP(canonA); - const dot = snap0(info.inside.dot(surfaceNormalAtCanonA)); - if (0 !== dot) { - return 0 < dot ? OUTSIDE : INSIDE; - } - if (surface.isCoplanarTo(info.face.surface)) { - return 0 < info.normalAtCanonA.dot(surfaceNormalAtCanonA) - ? COPLANAR_SAME - : COPLANAR_OPPOSITE; - } - throw new Error(); -} -function triangulateVertices(normal, vertices, holeStarts) { - const absMaxDim = normal.maxAbsDim(), factor = sign(normal.e(absMaxDim)); - const contour = new Float64Array(vertices.length * 2); - let i = vertices.length; - /* - var [coord0, coord1] = [['y', 'z'], ['z', 'x'], ['x', 'y']][maxAbsDim] - while (i--) { - contour[i * 2 ] = vertices[i][coord0] * factor - contour[i * 2 + 1] = vertices[i][coord1] - } - */ - while (i--) { - // unroll disambiguation instead of accessing elements by string name ([coord0] etc) - // as it confuses google closure - switch (absMaxDim) { - case 0: - contour[i * 2] = vertices[i].y * factor; - contour[i * 2 + 1] = vertices[i].z; - break; - case 1: - contour[i * 2] = vertices[i].z * factor; - contour[i * 2 + 1] = vertices[i].x; - break; - case 2: - contour[i * 2] = vertices[i].x * factor; - contour[i * 2 + 1] = vertices[i].y; - break; - } - } - return earcut(contour, holeStarts); -} -/** - * Solves a quadratic system of equations of the form - * a * x + b * y = c - * x² + y² = 1 - * This can be understood as the intersection of the unit circle with a line. - * => y = (c - a x) / b - * => x² + (c - a x)² / b² = 1 - * => x² b² + c² - 2 c a x + a² x² = b² - * => (a² + b²) x² - 2 a c x + (c² - b²) = 0 - * - * a * b + (b -c) * (b + c) - */ -function intersectionUnitCircleLine(a, b, c) { - assertNumbers(a, b, c); - // TODO: disambiguate on a < b - const term = sqrt(a * a + b * b - c * c); - return { - x1: (a * c + b * term) / (a * a + b * b), - x2: (a * c - b * term) / (a * a + b * b), - y1: (b * c - a * term) / (a * a + b * b), - y2: (b * c + a * term) / (a * a + b * b), - }; -} -function intersectionUnitCircleLine2(a, b, c) { - assertNumbers(a, b, c); - // TODO: disambiguate on a < b - // cf. pqFormula - const termSqr = snap0(a * a + b * b - c * c); - if (termSqr < 0) { - return []; - } - else if (termSqr == 0) { - return [[(a * c) / (a * a + b * b), (b * c) / (a * a + b * b)]]; - } - else { - const term = sqrt(termSqr); - return [ - [ - (a * c + b * term) / (a * a + b * b), - (b * c - a * term) / (a * a + b * b), - ], - [ - (a * c - b * term) / (a * a + b * b), - (b * c + a * term) / (a * a + b * b), - ], - ]; - } -} -function intersectionCircleLine(a, b, c, r) { - assertNumbers(a, b, c, r); - const term = sqrt(r * r * (a * a + b * b) - c * c); - return { - x1: (a * c + b * term) / (a * a + b * b), - x2: (a * c - b * term) / (a * a + b * b), - y1: (b * c - a * term) / (a * a + b * b), - y2: (b * c + a * term) / (a * a + b * b), - }; -} -/** - * Solves a quadratic system of equations of the form - * a * x + b * y = c - * x^2 - y^2 = 1 - * This can be understood as the intersection of the unit hyperbola with a line. - * - * @returns with x1 >= x2 and y1 <= y2 - * a * b + (b -c) * (b + c) - */ -function intersectionUnitHyperbolaLine(a, b, c) { - assertNumbers(a, b, c); - const aa = a * a, bb = b * b, cc = c * c; - // TODO: disambiguate on a < b - //var xTerm = sqrt(4*cc*aa-4*(bb-aa)*(-cc-bb)) - const xTerm = 2 * sqrt(bb * cc + bb * bb - aa * bb); - const yTerm = sqrt(4 * cc * bb - 4 * (bb - aa) * (cc - aa)); - return { - x1: (-2 * a * c + xTerm) / 2 / (bb - aa), - x2: (-2 * a * c - xTerm) / 2 / (bb - aa), - y1: (2 * b * c - yTerm) / 2 / (bb - aa), - y2: (2 * b * c + yTerm) / 2 / (bb - aa), - }; -} -function curvePointPP(ps1, ps2, startPoint, dontCheck) { - const EPS = NLA_PRECISION / 4; - //if (!dontCheck) { - // const p = curvePointPP(ps1, ps2, startPoint, true).p - // if (!ps1.containsPoint(p)) { - // console.log("foo, startPoint was " + startPoint.sce) - // ps1.containsPoint(p) - // } - //} - let Q = startPoint; - let st1 = ps1.pointFoot(Q); - let st2 = ps2.pointFoot(Q); - let a, b, aNormal, bNormal, abNormalsCross; - //console.log("curvePointPP, startPoint was " + startPoint.sce) - //console.log(Q.sce+ ',') - let i = 16; - do { - a = ps1.pUV(st1.x, st1.y); - b = ps2.pUV(st2.x, st2.y); - if (eq0(a.distanceTo(b), EPS)) - break; - // drPs.push({p:a,text:'a'+j+' '+i}) - // drPs.push({p:b,text:'b'+j+' '+i}) - aNormal = ps1.normalUV(st1.x, st1.y); - bNormal = ps2.normalUV(st2.x, st2.y); - // next Q is the intersection of the planes - // (x - a) * aNormal, - // (x - b) * bNormal and - // (x - Q) * (aNormal X bNormal) - abNormalsCross = aNormal.cross(bNormal); - // drVs.push({anchor: Q, dir: aNormal}) - // drVs.push({anchor: Q, dir: bNormal}) - Q = V3.add(bNormal.cross(abNormalsCross).times(a.dot(aNormal)), abNormalsCross.cross(aNormal).times(b.dot(bNormal)), abNormalsCross.times(abNormalsCross.dot(Q))).div(abNormalsCross.squared()); - //console.log(Q.sce+ ',') - // feet of Q on ps1 and ps2 (closest points) - st1 = ps1.pointFoot(Q, st1.x, st1.y); - st2 = ps2.pointFoot(Q, st2.x, st2.y); - } while (--i); - //assert(ps1.containsPoint(Q), Q, ps1) - //assert(ps2.containsPoint(Q)) - if (!eq0(a.distanceTo(b), EPS)) { - return undefined; - } - return { p: Q, st1: st1, st2: st2 }; -} -/** - * Follow the intersection curve of two parametric surfaces starting from a given point. - * @param {ParametricSurface} ps1 - * @param {ParametricSurface} ps2 - * @param {number} s1Step - * @param {number} t1Step - * @param {number} s2Step - * @param {number} t2Step - * @param {number} curveStepSize - * @return {Curve[]} - */ -function followAlgorithmPP(ps1, ps2, startPoint, curveStepSize, bounds1 = uvInAABB2$1.bind(undefined, ps1), bounds2 = uvInAABB2$1.bind(undefined, ps2)) { - const points = []; - const tangents = []; - const st1s = []; - const st2s = []; - let Q = startPoint; - let st1 = ps1.uvP(Q); - let st2 = ps2.uvP(Q); - assert(ps1.pUV(st1.x, st1.y).like(Q)); - assert(st1.like(ps1.pointFoot(Q, st1.x, st1.y))); - assert(ps2.pUV(st2.x, st2.y).like(Q)); - assert(st2.like(ps2.pointFoot(Q, st2.x, st2.y))); - for (let i = 0; i < 1000; i++) { - ({ p: Q, st1, st2 } = curvePointPP(ps1, ps2, Q)); - assert(ps1.containsPoint(Q), Q, ps1); - assert(ps2.containsPoint(Q)); - const aNormal = ps1.normalUV(st1.x, st1.y); - const bNormal = ps2.normalUV(st2.x, st2.y); - const tangent = aNormal.cross(bNormal).toLength(curveStepSize); - tangents.push(tangent); - points.push(Q); - st1s.push(st1); - st2s.push(st2); - if (i > 4) { - if (!bounds1(st1.x, st1.y) || !bounds2(st2.x, st2.y)) { - break; - } - } - Q = Q.plus(tangent); - } - return { points, tangents, st1s, st2s }; -} -/** - * Iteratively calculate points on an implicit 2D curve. - * @param ic The curve in question. - * @param startP The point at which to start. - * @param stepLength The step the algorithm takes. Will be the approximate distance between points. - * @param bounds Bounds function. - * @param endP End point. If undefined, algorithm will continue until out of bounds or back at start point. - * @param startTangent TODO Ignore this. - * @returns Calculated points and tangents. points[0] and tangents[0] will be startP and startTangent. - */ -function followAlgorithm2d(ic, startP, stepLength = 0.5, bounds, validUV, endP, startTangent) { - assertNumbers(stepLength, ic(0, 0)); - assertVectors(startP); - if (!startTangent) { - startTangent = new V3(-ic.y(startP.x, startP.y), ic.x(startP.x, startP.y), 0).toLength(stepLength); - } - assertVectors(startTangent); - const points = []; - const tangents = []; - assert(eq0(ic(startP.x, startP.y), 0.01), "isZero(implicitCurve(startPoint.x, startPoint.y))", ic(startP.x, startP.y)); - let i = 0, p = startP, tangent = startTangent, fullLoop = false; - do { - points.push(p); - tangents.push(tangent); - const searchStart = p.plus(tangent); - assert(searchStart); - const newP = curvePointMF$1(ic, searchStart); - const dfpdx = ic.x(newP.x, newP.y), dfpdy = ic.y(newP.x, newP.y); - const newTangent = new V3(-dfpdy, dfpdx, 0).toLength(stepLength); - //const reversedDir = p.minus(prevp).dot(tangent) < 0 - assert(!p.equals(newP)); - // check if we passed a singularity - if (tangent.dot(newTangent) < 0) { - const singularity = newtonIterate2d(ic.x, ic.y, p.x, p.y); - if (eq0(ic(singularity.x, singularity.y)) && - singularity.distanceTo(p) < abs(stepLength)) { - // end on this point - points.push(singularity); - tangents.push(p.to(singularity)); - break; - } - else { - throw new Error(); - } - } - // check for endP - if (endP && p.equals(endP)) { - break; - } - // check if loop - if (fullLoop) { - if (p.distanceTo(startP) > abs(stepLength)) { - points.pop(); - tangents.pop(); - assert(getLast(points).distanceTo(startP) <= abs(stepLength)); - break; - } - } - else { - if (i > 4 && p.distanceTo(startP) <= abs(stepLength)) { - fullLoop = true; - } - } - // check if out of bounds - if (i > 1 && !uvInAABB2$1(bounds, p.x, p.y)) { - const endP = figureOutBorderPoint(bounds, p, ic); - points.pop(); - tangents.pop(); - if (getLast(points).distanceTo(endP) < abs(stepLength) / 2) { - points.pop(); - tangents.pop(); - } - const endTangent = new V3(-ic.y(endP.x, endP.y), ic.x(endP.x, endP.y), 0).toLength(stepLength); - points.push(endP); - tangents.push(endTangent); - break; - } - if (i > 4 && !validUV(p.x, p.y)) { - break; - } - assert(eq0(ic(newP.x, newP.y), NLA_PRECISION * 2), p, newP, searchStart, ic(newP.x, newP.y)); - tangent = newTangent; - p = newP; - } while (++i < 1000); - assert(i < 1000); - //assert(points.length > 6) - return { points, tangents }; -} -/** - * Given a point p just outside the bounds, figure out the nearby intersection of the bounds with the ic. - * @param bounds - * @param p - * @param ic - */ -function figureOutBorderPoint(bounds, p, ic) { - if (p.x < bounds.uMin || bounds.uMax < p.x) { - const u = bounds.uMax < p.x ? bounds.uMax : bounds.uMin; - const v = newtonIterateWithDerivative((t) => ic(u, t), p.y, 4, (t) => ic.y(u, t)); - if (uvInAABB2$1(bounds, u, v)) { - return new V3(u, v, 0); - } - } - if (p.y < bounds.vMin || bounds.vMax < p.y) { - const v = bounds.vMax < p.y ? bounds.vMax : bounds.vMin; - const u = newtonIterateWithDerivative((s) => ic(s, v), p.x, 4, (s) => ic.x(s, v)); - assert(uvInAABB2$1(bounds, u, v)); - return new V3(u, v, 0); - } - throw new Error(p + " " + bounds); -} -function followAlgorithm2dAdjustable(ic, start, stepLength = 0.5, bounds, endp = start) { - assertNumbers(stepLength, ic(0, 0)); - assertVectors(start); - //assert (!startDir || startDir instanceof V3) - const points = []; - const tangents = []; - assert(eq0(ic(start.x, start.y), 0.01), "isZero(implicitCurve(startPoint.x, startPoint.y))"); - let p = start, prevp = p; - let i = 0; - do { - const dfpdx = ic.x(p.x, p.y), dfpdy = ic.y(p.x, p.y); - const dfpdxx = ic.xx(p.x, p.y), dfpdyy = ic.yy(p.x, p.y), dfpdxy = ic.xy(p.x, p.y); - const c2factor = abs((Math.pow(dfpdy, 2) * dfpdxx - 2 * dfpdx * dfpdy * dfpdxy + Math.pow(dfpdx, 2) * dfpdyy) / - Math.pow((Math.pow(dfpdx, 2) + Math.pow(dfpdy, 2)), 2)); - const c2 = new V3(dfpdx, dfpdy, 0).times(c2factor); - const s = 1 / 16 / c2.length(); - const tangent = new V3(-dfpdy, dfpdx, 0).unit(); - const newPStart = p.plus(tangent.times(s).plus(c2.times(Math.pow(s, 2) / 2))); - points.push(p); - tangents.push(tangent); - prevp = p; - const newP = curvePointMF$1(ic, newPStart); - if (newP.equals(p)) { - assertNever(); - } - console.log(p.to(newP).length()); - p = newP; - assert(eq0(ic(p.x, p.y))); - } while (i++ < 1000 && - (i < 4 || prevp.distanceTo(endp) > stepLength) && - bounds(p.x, p.y)); - assert(i != 1000); - //assert(bounds(p.x, p.y)) - const end = i < 4 || prevp.distanceTo(endp) > stepLength ? p : endp; - const endTangent = new V3(-ic.y(end.x, end.y), ic.x(end.x, end.y), 0).toLength(stepLength); - points.push(end); - tangents.push(endTangent); - //assert(points.length > 6) - // TODO gleichmäßige Verteilung der Punkte - return { points, tangents }; -} -// both curves must be in the same s-t coordinates for this to make sense -function intersectionICurveICurve(iCurve1, startParams1, endParams1, startDir, stepLength, iCurve2) { - assertNumbers(stepLength, iCurve1(0, 0), iCurve2(0, 0)); - assertVectors(startParams1, endParams1); - assert(!startDir || startDir instanceof V3); - const vertices = []; - assert(eq0(iCurve1(startParams1.x, startParams1.y))); - stepLength = stepLength || 0.5; - const eps = 1e-5; - let p = startParams1, prevp = p; // startDir ? p.minus(startDir) : p - let i = 0; - while (i++ < 1000 && (i < 4 || p.distanceTo(endParams1) > 1.1 * stepLength)) { - const fp = iCurve1(p.x, p.y); - const dfpdx = (iCurve1(p.x + eps, p.y) - fp) / eps, dfpdy = (iCurve1(p.x, p.y + eps) - fp) / eps; - let tangent = new V3(-dfpdy, dfpdx, 0).toLength(stepLength); - if (p.minus(prevp).dot(tangent) < 0) - tangent = tangent.negated(); - prevp = p; - p = curvePointMF$1(iCurve1, p.plus(tangent)); - vertices.push(p); - } - // TODO gleichmäßige Verteilung der Punkte - return vertices; -} -function intersectionICurveICurve2(iCurve1, loopPoints1, iCurve2) { - let p = loopPoints1[0], val = iCurve2(p.x, p.y), lastVal; - const iss = []; - for (let i = 0; i < loopPoints1.length; i++) { - lastVal = val; - p = loopPoints1[i]; - val = iCurve2(p.x, p.y); - if (val * lastVal <= 0) { - // TODO < ? - iss.push(newtonIterate2d(iCurve1, iCurve2, p.x, p.y)); - } - } - return iss; -} -// export function intersectionPCurveISurface( -// parametricCurve: Curve, -// searchStart: number, -// searchEnd: number, -// searchStep: number, -// implicitSurface: ImplicitSurface, -// ) { -// assertNumbers(searchStart, searchEnd, searchStep) -// const iss = [] -// let val = implicitSurface(parametricCurve(searchStart)), -// lastVal -// for (let t = searchStart + searchStep; t <= searchEnd; t += searchStep) { -// lastVal = val -// val = implicitSurface(parametricCurve(t)) -// if (val * lastVal <= 0) { -// iss.push(newtonIterate1d(t => implicitSurface(parametricCurve(t)), t)) -// } -// } -// return iss -// } -function cassini(a, c) { - return (x, y) => (x * x + y * y) * (x * x + y * y) - - 2 * c * c * (x * x - y * y) - - (Math.pow(a, 4) - Math.pow(c, 4)); -} -var MathFunctionR2R; -(function (MathFunctionR2R) { - function forNerdamer(expression, args = ["x", "y"]) { - const ndf = nerdamer(expression); - const ndfs = nerdamer.diff(ndf, args[0]); - const ndft = nerdamer.diff(ndf, args[1]); - const f = ndf.buildFunction(args); - f.x = ndfs.buildFunction(args); - f.y = ndft.buildFunction(args); - f.xx = nerdamer.diff(ndfs, args[0]).buildFunction(args); - f.xy = nerdamer.diff(ndfs, args[1]).buildFunction(args); - f.yy = nerdamer.diff(ndft, args[1]).buildFunction(args); - return f; - } - MathFunctionR2R.forNerdamer = forNerdamer; - function nerdamerToR2_R(expression, args = ["x", "y"]) { - return expression.buildFunction(args); - } - MathFunctionR2R.nerdamerToR2_R = nerdamerToR2_R; - function forFFxFy(f, fx, fy) { - f.x = fx; - f.y = fy; - return f; - } - MathFunctionR2R.forFFxFy = forFFxFy; -})(MathFunctionR2R || (MathFunctionR2R = {})); -const cas2 = cassini(0.9, 1.02); -function arrayLerp(lerp, arr, t) { - if (0 === t % 1) - return arr[t]; - return lerp(arr[Math.floor(t)], arr[Math.ceil(t)], t % 1); -} - -function doNotSerialize(target, key) { - const map = target.__SERIALIZATION_BLACKLIST || (target.__SERIALIZATION_BLACKLIST = {}); - map[key] = "no"; -} -class ClassSerializer { - constructor() { - this.CLASS_NAMES = new Map(); - this.NAME_CLASSES = new Map(); - this.addClass("Object", Object); - } - addClass(name, clazz) { - if (this.NAME_CLASSES.has(name)) { - throw new Error(name); - } - this.NAME_CLASSES.set(name, clazz); - this.CLASS_NAMES.set(clazz, name); - return this; - } - addNamespace(namespace, namespaceName) { - Object.keys(namespace).forEach((symbol) => { - const o = namespace[symbol]; - if ("function" == typeof o && o.name) { - this.addClass((namespaceName ? namespaceName + "." : "") + symbol, o); - } - }); - return this; - } - setUpdater(f) { - this.updater = f; - return this; - } - serialize(v) { - return JSON.stringify(this.serializeObj(v)); - } - serializeObj(v) { - const gatherList = (v) => { - //console.log(path.toString()) - if (undefined !== v && - v.hasOwnProperty("constructor") && - this.CLASS_NAMES.has(v.constructor)) ; - else if (Array.isArray(v)) { - if (visited.has(v)) { - if (!listMap.has(v)) { - listMap.set(v, resultList.length); - resultList.push(v); - } - } - else { - visited.add(v); - for (let i = 0; i < v.length; i++) { - gatherList(v[i]); - } - } - } - else if (undefined !== v && "object" == typeof v) { - if (visited.has(v)) { - if (!listMap.has(v)) { - listMap.set(v, resultList.length); - resultList.push(v); - } - } - else { - assert(!v.__noxTarget || !visited.has(v.__noxTarget)); - assert(!v.__noxProxy || !visited.has(v.__noxProxy)); - visited.add(v); - if (!v.getConstructorParameters) { - for (const key of Object.keys(v).sort()) { - if (key == "__noxProxy" || key == "__noxTarget") - continue; - if (!v.__SERIALIZATION_BLACKLIST || - !v.__SERIALIZATION_BLACKLIST[key]) { - gatherList(v[key]); - } - } - } - gatherList(Object.getPrototypeOf(v)); - } - } - }; - const transform = (v, allowLinks, first) => { - if ("string" == typeof v || - "number" == typeof v || - "boolean" == typeof v || - null === v) { - return v; - } - if ("undefined" == typeof v) { - return { "#REF": -1 }; - } - if (v.hasOwnProperty("constructor") && - this.CLASS_NAMES.has(v.constructor)) { - return { "#REF": this.CLASS_NAMES.get(v.constructor) }; - } - let index; - if (allowLinks && !first && undefined !== (index = listMap.get(v))) { - return { "#REF": index }; - } - if (Array.isArray(v)) { - return v.map((x) => transform(x, allowLinks)); - } - //if (mobx && mobx.isObservableArray(v)) { - // const result = {'#PROTO': 'ObservableArray'} as any - // v.forEach((val, i) => result[i] = transform(val)) - // return result - //} - if ("object" == typeof v) { - if (v.getConstructorParameters) { - return { - "#CONSTRUCTOR": this.CLASS_NAMES.get(v.constructor), - "#ARGS": transform(v.getConstructorParameters(), false), - }; - } - const result = {}; - if (Object.prototype !== Object.getPrototypeOf(v)) { - result["#PROTO"] = transform(Object.getPrototypeOf(v), allowLinks); - } - for (const key of Object.keys(v)) { - if (key == "__noxProxy" || key == "__noxTarget") - continue; - if (!v.__SERIALIZATION_BLACKLIST || - !v.__SERIALIZATION_BLACKLIST[key]) { - result[key] = transform(v[key], allowLinks); - } - } - return result; - } - throw new Error("?" + typeof v + v.toString()); - }; - const visited = new Set(); - const listMap = new Map(); - let resultList = []; - listMap.set(v, 0); - resultList.push(v); - gatherList(v); - resultList = resultList.map((v) => transform(v, true, true)); - return resultList; - } - unserialize(string) { - let depth = 0; - const fixObject = (v, onReady) => { - depth++; - if (depth > 100) - throw new Error(); - if (v && v.constructor === Array) { - onReady(v); - for (let i = 0; i < v.length; i++) { - fixObject(v[i], (x) => (v[i] = x)); - } - } - else if ("object" == typeof v && undefined != v) { - if ("#CONSTRUCTOR" in v) { - const protoName = v["#CONSTRUCTOR"]; - const proto = this.NAME_CLASSES.get(protoName); - assert(proto, protoName + " Missing "); - let args = undefined; - fixObject(v["#ARGS"], (x) => (args = x)); - onReady(new proto(...args)); - } - else if ("#REF" in v) { - const ref = v["#REF"]; - if ("string" == typeof ref) { - onReady(this.NAME_CLASSES.get(ref).prototype); - } - else if ("number" == typeof ref) { - if (-1 == ref) { - onReady(undefined); - } - else if (fixedObjects[ref]) { - onReady(fixedObjects[ref]); - } - else { - fixObject(tree[ref], (x) => onReady((fixedObjects[ref] = x))); - } - } - } - else { - let result; - if ("#PROTO" in v) { - fixObject(v["#PROTO"], (x) => { - result = Object.create(x); - onReady(result); - }); - } - else { - onReady((result = v)); - } - const keys = Object.keys(v); - for (let i = 0; i < keys.length; i++) { - //if ('name' == keys[i]) console.log(result) - if ("#PROTO" != keys[i]) { - fixObject(v[keys[i]], (x) => (result[keys[i]] = x)); - //Object.defineProperty(result, keys[i], { - // value: fixObjects(v[keys[i]]), - // enumerable: true, - // writable: true, - // configurable: true - //}) - } - } - Object.defineProperty(result, "loadID", { - value: getGlobalId$1(), - enumerable: false, - writable: false, - }); - this.updater && this.updater(result); - } - } - else { - onReady(v); - } - depth--; - }; - // const linkReferences = (v: any) => { - // if (v && v.constructor === Array) { - // for (let i = 0; i < v.length; i++) { - // v[i] = linkReferences(v[i]) - // } - // return v - // } else if ('object' == typeof v && undefined != v) { - // if ('#REF' in v) { - // return tree[v['#REF']] - // } else { - // const keys = Object.keys(v) - // for (let i = 0; i < keys.length; i++) { - // v[keys[i]] = linkReferences(v[keys[i]]) - // } - // return v - // } - // } else { - // return v - // } - // } - const tree = JSON.parse(string); - // console.log(tree) - const fixedObjects = new Array(tree.length); - fixObject({ "#REF": 0 }, () => { }); - // console.log(tree) - // linkReferences(tree) - // console.log(tree) - return fixedObjects[0]; - } -} - -const fragmentShaderLighting = ` - precision highp float; - uniform vec4 color; - uniform vec3 camPos; - varying vec3 normal; - varying vec4 vPosition; - void main() { - vec3 normal1 = normalize(normal); - vec3 lightPos = vec3(1000, 2000, 4000); - vec3 lightDir = normalize(vPosition.xyz - lightPos); - vec3 reflectionDirection = reflect(lightDir, normal1); - vec3 eyeDirection = normalize(camPos.xyz-vPosition.xyz); - float uMaterialShininess = 256.0; - float specularLightWeighting = pow(max(dot(reflectionDirection, eyeDirection), 0.0), uMaterialShininess); - float lightIntensity = 0.6 + 0.2 * max(0.0, -dot(lightDir, normal1)) + 0.2*specularLightWeighting; - gl_FragColor = vec4(vec3(color) * lightIntensity, 1); - } -`; -const vertexShaderLighting = ` - uniform mat4 ts_ModelViewProjectionMatrix; - uniform mat4 ts_ModelViewMatrix; - attribute vec4 ts_Vertex; - uniform mat3 ts_NormalMatrix; - attribute vec3 ts_Normal; - uniform vec4 color; - varying vec3 normal; - varying vec4 vPosition; - void main() { - gl_Position = ts_ModelViewProjectionMatrix * ts_Vertex; - vPosition = ts_ModelViewMatrix * ts_Vertex; - normal = normalize(ts_NormalMatrix * ts_Normal); - } -`; -const vertexShaderWaves = ` - uniform mat4 ts_ModelViewProjectionMatrix; - uniform mat4 ts_ModelViewMatrix; - attribute vec4 ts_Vertex; - uniform mat3 ts_NormalMatrix; - attribute vec3 ts_Normal; - uniform vec4 color; - varying vec3 normal; - varying vec4 vPosition; - void main() { - normal = normalize(ts_NormalMatrix * ts_Normal); - float offset = mod (((ts_Vertex.x + ts_Vertex.y + ts_Vertex.z) * 31.0), 20.0) - 10.0; - vec4 modPos = ts_Vertex + vec4(normal * offset, 0); - gl_Position = ts_ModelViewProjectionMatrix * modPos; - vPosition = ts_ModelViewMatrix * modPos; - } -`; -const vertexShaderBasic = ` - uniform mat4 ts_ModelViewProjectionMatrix; - attribute vec4 ts_Vertex; - void main() { - gl_Position = ts_ModelViewProjectionMatrix * ts_Vertex; - } -`; -const vertexShaderColor = ` - uniform mat4 ts_ModelViewProjectionMatrix; - attribute vec4 ts_Vertex; - attribute vec4 ts_Color; - varying vec4 fragColor; - void main() { - gl_Position = ts_ModelViewProjectionMatrix * ts_Vertex; - fragColor = ts_Color; - } -`; -const vertexShaderArc = ` - uniform mat4 ts_ModelViewProjectionMatrix; - attribute vec4 ts_Vertex; - uniform float step, offset; - uniform float radius, width; - void main() { - float r = radius; - float t = offset + ts_Vertex.x * step; - float pRadius = r - ts_Vertex.y * width; - vec4 p = vec4(pRadius * cos(t), pRadius * sin(t), 0, 1); - gl_Position = ts_ModelViewProjectionMatrix * p; -} -`; -const vertexShaderConic3d = ` - uniform mat4 ts_ModelViewProjectionMatrix; - attribute vec4 ts_Vertex; - uniform float startT, endT, scale; - uniform vec3 center, f1, f2; - uniform int mode; - float sinh(float x) { return (exp(x) - exp(-x)) / 2.0; } - float cosh(float x) { return (exp(x) + exp(-x)) / 2.0; } - void main() { - float t = startT + ts_Vertex.x * (endT - startT); - - vec3 normal = normalize(cross(f1, f2)); - - vec3 p, tangent; - if (0 == mode) { // ellipse - p = center + f1 * cos(t) + f2 * sin(t); - tangent = f1 * -sin(t) + f2 * cos(t); - } - if (1 == mode) { // parabola - p = center + f1 * t + f2 * t * t; - tangent = f1 + 2.0 * f2 * t; - } - if (2 == mode) { // hyperbola - p = center + f1 * cosh(t) + f2 * sinh(t); - tangent = f1 * sinh(t) + f2 * cosh(t); - } - vec3 outDir = normalize(cross(normal, tangent)); - vec3 p2 = p + scale * (outDir * ts_Vertex.y + normal * ts_Vertex.z); - gl_Position = ts_ModelViewProjectionMatrix * vec4(p2, 1); - } -`; -const vertexShaderNURBS = `#version 300 es - uniform mat4 ts_ModelViewProjectionMatrix; - in vec4 ts_Vertex; - uniform float startT, endT, scale; - uniform vec4 points[32]; - uniform int pointCount, degree; - uniform float knots[40]; - uniform vec3 normal; - const int MIN_DEGREE = 1; - const int MAX_DEGREE = 6; - - int tInterval(float t) { - for (int s = degree; s < 40 - 1 - degree; s++) { - if (t >= knots[s] && t <= knots[s + 1]) { - return s; - } - } - } - - vec4 stepp(int k, int i, vec4 dkMinus1iMinus1, vec4 dkMinus1i) { - return dkMinus1i - dkMinus1iMinus1 * float(k) / (knots[i + degree - k] - knots[i - 1]); - } - - void main() { - // ts_Vertex.x is in [0, 1] - float t = startT + ts_Vertex.x * (endT - startT); - - int s = tInterval(t); - - vec4 v[MAX_DEGREE + 1]; - for (int i = 0; i < degree + 1; i++) { - v[i] = points[s - degree + i]; - } - - vec4 pTangent4, ddt4 = vec4(0, 0, 1, 0); - for (int level = 0; level < degree; level++) { - if (level == degree - 2) { - // see https://www.globalspec.com/reference/61012/203279/10-8-derivatives - vec4 a = v[degree]; - vec4 b = v[degree - 1]; - vec4 c = v[degree - 2]; - ddt4 = stepp(degree, s + 1, stepp(degree - 1, s + 1, a, b), stepp(degree - 1, s, b, c)); - } - if (level == degree - 1) { - vec4 a = v[degree]; - vec4 b = v[degree - 1]; - pTangent4 = (b - a) * (float(degree) / (knots[s] - knots[s + 1])); - } - for (int i = degree; i > level; i--) { - float alpha = (t - knots[i + s - degree]) / (knots[i + s - level] - knots[i + s - degree]); - - // interpolate each component - v[i] = (1.0 - alpha) * v[i - 1] + alpha * v[i]; - } - } - - vec4 p4 = v[degree]; - - vec3 p = p4.xyz / p4.w; - vec3 pTangent = ((pTangent4.xyz * p4.w) - (p4.xyz * pTangent4.w)) / (p4.w * p4.w); - vec3 ddt = ( - p4.xyz * (-p4.w * ddt4.w + 2.0 * pow(pTangent4.w, 2.0)) - + pTangent4.xyz * (-2.0 * p4.w * pTangent4.w) - + ddt4.xyz * pow(p4.w, 2.0) - ) / pow(p4.w, 3.0); - - vec3 outDir = normalize(cross(ddt, pTangent)); - vec3 correctNormal = normalize(cross(pTangent, outDir)); - vec3 p2 = p + scale * (outDir * ts_Vertex.y + correctNormal * ts_Vertex.z); - gl_Position = ts_ModelViewProjectionMatrix * vec4(p2, 1); - } -`; -const vertexShaderBezier = ` - // calculates a bezier curve using ts_Vertex.x as the (t) parameter of the curve - uniform mat4 ts_ModelViewProjectionMatrix; - attribute vec4 ts_Vertex; - uniform float width, startT, endT; - uniform vec3 p0, p1, p2, p3; - void main() { - // ts_Vertex.x is in [0, 1] - float t = startT + ts_Vertex.x * (endT - startT), s = 1.0 - t; - float c0 = s * s * s, c1 = 3.0 * s * s * t, c2 = 3.0 * s * t * t, c3 = t * t * t; - vec3 pPos = p0 * c0 + p1 * c1 + p2 * c2 + p3 * c3; - float c01 = 3.0 * s * s, c12 = 6.0 * s * t, c23 = 3.0 * t * t; - vec3 pTangent = (p1 - p0) * c01 + (p2 - p1) * c12 + (p3 - p2) * c23; - vec3 pNormal = normalize(vec3(pTangent.y, -pTangent.x, 0)); - vec4 p = vec4(pPos - ts_Vertex.y * width * pNormal, 1); - gl_Position = ts_ModelViewProjectionMatrix * p; - } -`; -const vertexShaderBezier3d = ` - precision highp float; - // calculates a bezier curve using ts_Vertex.x as the (t) parameter of the curve - uniform float scale, startT, endT; - uniform vec3 ps[4]; - uniform vec3 p0, p1, p2, p3, normal; - uniform mat4 ts_ModelViewProjectionMatrix; - attribute vec4 ts_Vertex; - void main() { - // ts_Vertex.y is in [0, 1] - vec3 p5 = ps[0]; - float t = startT * (1.0 - ts_Vertex.x) + endT * ts_Vertex.x, s = 1.0 - t; - float c0 = s * s * s, - c1 = 3.0 * s * s * t, - c2 = 3.0 * s * t * t, c3 = t * t * t; - vec3 p = (p0 * c0 + p1 * c1) + (p2 * c2 + p3 * c3); - float c01 = 3.0 * s * s, - c12 = 6.0 * s * t, - c23 = 3.0 * t * t; - vec3 pTangent = (p1 - p0) * c01 + (p2 - p1) * c12 + (p3 - p2) * c23; - vec3 outDir = normalize(cross(normal, pTangent)); - vec3 correctNormal = normalize(cross(pTangent, outDir)); - vec3 p2 = p + scale * (outDir * ts_Vertex.y + correctNormal * ts_Vertex.z); - gl_Position = ts_ModelViewProjectionMatrix * vec4(p2, 1); - } -`; -const vertexShaderGeneric = ` - uniform float scale; - uniform mat4 ts_ModelViewProjectionMatrix; - attribute vec4 ts_Vertex; - uniform mat3 ts_NormalMatrix; - attribute vec3 ts_Normal; - void main() { - vec3 normal = normalize(ts_NormalMatrix * ts_Normal); - vec4 vertexPos = ts_Vertex + vec4(normal * scale, 0); - gl_Position = ts_ModelViewProjectionMatrix * vertexPos; - } -`; -const vertexShaderRing = ` - #define M_PI 3.1415926535897932384626433832795 - uniform float step; - uniform float innerRadius, outerRadius; - attribute float index; - uniform mat4 ts_ModelViewProjectionMatrix; - attribute vec4 ts_Vertex; - void main() { - gl_Position = ts_ModelViewProjectionMatrix * vec4(index, index, index, 1); - float id = atan(ts_Vertex.x, ts_Vertex.y) / M_PI * 32.0; - float radius = mod(id, 2.0) < 1.0 ? outerRadius : innerRadius; - gl_Position = ts_ModelViewProjectionMatrix * vec4(radius * cos(index * step), radius * sin(index * step), 0, 1); - } -`; -const fragmentShaderColor = ` - precision highp float; - uniform vec4 color; - void main() { - gl_FragColor = color; - } -`; -const fragmentShaderColor3 = `#version 300 es - precision highp float; - uniform vec4 color; - out vec4 fragColor; - void main() { - fragColor = color; - } -`; -const fragmentShaderVaryingColor = ` - precision highp float; - varying vec4 fragColor; - void main() { - gl_FragColor = fragColor; - } -`; -const fragmentShaderColorHighlight = ` - precision highp float; - uniform vec4 color; - void main() { - float diagonal = (gl_FragCoord.x + 2.0 * gl_FragCoord.y); - if (mod(diagonal, 50.0) > 40.0) { // mod(diagonal, 2.0) > 1.0 - discard; - //gl_FragColor = color + vec4(0.2,0.2,0.2,0); - } else { - gl_FragColor = color - vec4(0.2,0.2,0.2,0); - } - } -`; -const vertexShaderTexture = ` - varying vec2 texturePos; - attribute vec4 ts_Vertex; - uniform mat4 ts_ModelViewProjectionMatrix; - void main() { - texturePos = ts_Vertex.xy; - gl_Position = ts_ModelViewProjectionMatrix * ts_Vertex; - } -`; -const fragmentShaderTextureColor = ` - precision highp float; - varying vec2 texturePos; - uniform vec4 color; - uniform sampler2D texture; - void main() { - gl_FragColor = texture2D(texture, texturePos) * color; - } -`; - -function parseGetParams(str) { - const result = {}; - str.split("&").forEach(function (item) { - const splitIndex = item.indexOf("="); - if (-1 == splitIndex) { - result[item] = item; - } - else { - result[item.substr(0, splitIndex)] = decodeURI(item.substr(splitIndex + 1)); - } - }); - return result; -} -const COLORS = { - RD_FILL: color("#9EDBF9"), - RD_STROKE: color("#77B0E0"), - TS_FILL: color("#D19FE3"), - TS_STROKE: color("#A76BC2"), - PP_FILL: color("#F3B6CF"), - PP_STROKE: color("#EB81B4"), -}; -class BREPGLContext { - constructor(gl) { - this.cachedMeshes = new WeakMap(); - this.shaders = initShaders(gl); - initMeshes((this.meshes = {}), gl); - } - static create(gl) { - addOwnProperties(gl, BREPGLContext.prototype); - addOwnProperties(gl, new BREPGLContext(gl)); - return gl; - } - drawPoint(p, color = GL_COLOR_BLACK, size = 5) { - this.pushMatrix(); - this.translate(p); - this.scale(size / 2, size / 2, size / 2); - this.shaders.singleColor - .uniforms({ color: color }) - .draw(this.meshes.sphere1); - this.popMatrix(); - } - drawEdge(edge, color = GL_COLOR_BLACK, width = 2) { - CURVE_PAINTERS[edge.curve.constructor.name](this, edge.curve, color, edge.minT, edge.maxT, width); - } - drawCurve(curve, color = GL_COLOR_BLACK, width = 2, tStart, tEnd) { - CURVE_PAINTERS[curve.constructor.name](this, curve, color, tStart, tEnd, width); - } - drawVector(vector, anchor, color = GL_COLOR_BLACK, size = 1) { - if (vector.likeO()) - return; - this.pushMatrix(); - const headLength = size * 4; - if (headLength > vector.length()) - return; - const vT = vector.getPerpendicular().unit(); - this.multMatrix(M4.forSys(vector.unit(), vT, vector.cross(vT).unit(), anchor)); - this.scale(vector.length() - headLength, size / 2, size / 2); - this.shaders.singleColor - .uniforms({ - color: color, - }) - .draw(this.meshes.vectorShaft); - this.scale(1 / (vector.length() - headLength), 1, 1); - this.translate(vector.length() - headLength, 0, 0); - this.scale(headLength / 2, 1, 1); - this.shaders.singleColor.draw(this.meshes.vectorHead); - this.popMatrix(); - } - drawVectors(drVs, size = undefined) { - this.drawVector(V3.X, V3.O, color("red").gl(), size); - this.drawVector(V3.Y, V3.O, color("green").gl(), size); - this.drawVector(V3.Z, V3.O, color("blue").gl(), size); - drVs.forEach((vi) => this.drawVector(vi.v, vi.anchor, vi.color, size)); - } - drawPlane(customPlane, color, dotted = false) { - this.pushMatrix(); - this.multMatrix(M4.forSys(customPlane.right, customPlane.up, customPlane.normal1, customPlane.anchor)); - this.translate(customPlane.uMin, customPlane.vMin, 0); - this.scale(customPlane.uMax - customPlane.uMin, customPlane.vMax - customPlane.vMin, 1); - const mesh = dotted - ? this.meshes.xyDottedLinePlane - : this.meshes.xyLinePlane; - this.shaders.singleColor.uniforms({ color: color }).draw(mesh, this.LINES); - this.popMatrix(); - } - drawBox(m4, color) { - this.pushMatrix(); - this.multMatrix(m4.m[15] >= 0 ? m4 : m4.mulScalar(-1)); - if (color) { - this.shaders.singleColor - .uniforms({ color: color }) - .draw(this.meshes.cube, this.LINES); - } - else { - this.shaders.multiColor.draw(this.meshes.cube, this.LINES); - } - this.popMatrix(); - } -} -function conicPainter(mode, gl, ellipse, color, startT, endT, width = 2) { - gl.shaders.ellipse3d - .uniforms({ - f1: ellipse.f1, - f2: ellipse.f2, - center: ellipse.center, - color: color, - startT: startT, - endT: endT, - scale: width, - mode: mode, - }) - .draw(gl.meshes.pipe); -} -const CURVE_PAINTERS = { - [EllipseCurve$1.name]: conicPainter.bind(undefined, 0), - [ParabolaCurve$1.name]: conicPainter.bind(undefined, 1), - [HyperbolaCurve$1.name]: conicPainter.bind(undefined, 2), - [ImplicitCurve$2.name](gl, curve, color, startT, endT, width = 2) { - let mesh = gl.cachedMeshes.get(curve); - const RES = 4; - if (!mesh) { - mesh = new Mesh() - .addIndexBuffer("TRIANGLES") - .addVertexBuffer("normals", "ts_Normal"); - curve.addToMesh(mesh, RES); - mesh.compile(); - gl.cachedMeshes.set(curve, mesh); - } - const startIndex = ceil(startT); - const endIndex = floor(endT); - if (startIndex <= endIndex) { - const indexFactor = 2 * // no of triangles per face - RES * // no of faces - 3; // no of indexes per triangle - gl.shaders.generic3d - .uniforms({ - color: color, - scale: width, - }) - .draw(mesh, gl.TRIANGLES, startIndex * indexFactor, (floor(endT) - startIndex) * indexFactor); - if (startT % 1 !== 0) { - const p = curve.at(startT); - gl.pushMatrix(); - const m = M4.forSys(p.to(curve.points[startIndex]), mesh.normals[startIndex * RES].toLength(width), mesh.normals[startIndex * RES + 1].toLength(width), p); - gl.multMatrix(m); - gl.shaders.singleColor - .uniforms({ color: color }) - .draw(gl.meshes.pipeSegmentForICurve); - console.log(gl.meshes.pipeSegmentForICurve); - gl.popMatrix(); - } - if (endT % 1 !== 0) { - const p = curve.at(endT); - gl.pushMatrix(); - const m = M4.forSys(curve.points[endIndex].to(p), mesh.normals[endIndex * RES].toLength(width), mesh.normals[endIndex * RES + 1].toLength(width), curve.points[endIndex]); - gl.multMatrix(m); - gl.shaders.singleColor - .uniforms({ color: color }) - .draw(gl.meshes.pipeSegmentForICurve); - gl.popMatrix(); - } - } - else { - const p1 = curve.at(startT); - const p2 = curve.at(endT); - gl.pushMatrix(); - const v0 = p1.to(p2), v1 = v0.getPerpendicular().toLength(width), v2 = v0.cross(v1).toLength(width); - const m = M4.forSys(v0, v1, v2, p1); - gl.multMatrix(m); - gl.shaders.singleColor - .uniforms({ color: color }) - .draw(gl.meshes.pipeSegmentForICurve); - gl.popMatrix(); - } - }, - [BezierCurve$1.name](gl, curve, color, startT, endT, width = 2, normal = V3.Z) { - gl.shaders.bezier3d - .uniforms({ - p0: curve.p0, - p1: curve.p1, - p2: curve.p2, - p3: curve.p3, - color: color, - startT: startT, - endT: endT, - scale: width, - normal: normal, - }) - .draw(gl.meshes.pipe); - }, - [NURBS$2.name](gl, curve, color, startT, endT, width = 2, normal = V3.Z) { - gl.shaders.nurbs - .uniforms({ - "points[0]": Vector.pack(curve.points), - degree: curve.degree, - "knots[0]": curve.knots, - color: color, - startT: startT, - endT: endT, - scale: width, - normal: normal, - }) - .draw(gl.meshes.pipe); - }, - [L3$1.name](gl, curve, color, startT, endT, width = 2, normal = V3.Z) { - gl.pushMatrix(); - const a = curve.at(startT), b = curve.at(endT); - const ab = b.minus(a), abT = ab.getPerpendicular().unit(); - const m = M4.forSys(ab, abT, ab.cross(abT).unit(), a); - gl.multMatrix(m); - gl.scale(1, width, width); - gl.shaders.singleColor - .uniforms({ - color: color, - }) - .draw(gl.meshes.pipe); - gl.popMatrix(); - }, -}; -CURVE_PAINTERS[PICurve$2.name] = CURVE_PAINTERS[ImplicitCurve$2.name]; -CURVE_PAINTERS[PPCurve$2.name] = CURVE_PAINTERS[ImplicitCurve$2.name]; -function initMeshes(_meshes, _gl) { - _gl.makeCurrent(); - _meshes.cube = (() => { - const cube = B2T$1.box().toMesh().addVertexBuffer("colors", "ts_Color"); - cube.colors = cube.vertices.map((p) => [p.x, p.y, p.z, 1].map((x) => x * 0.9)); - cube.compile(); - return cube; - })(); - _meshes.sphere1 = Mesh.sphere(2); - _meshes.segment = Mesh.plane({ startY: -0.5, height: 1, detailX: 128 }); - _meshes.text = Mesh.plane(); - _meshes.vector = Mesh.rotation([V3.O, V(0, 0.05, 0), V(0.8, 0.05), V(0.8, 0.1), V(1, 0)], L3$1.X, TAU, 16, true); - _meshes.vectorShaft = Mesh.rotation([V3.O, V3.Y, V3.XY], L3$1.X, TAU, 8, true); - _meshes.vectorHead = Mesh.rotation([V3.Y, V(0, 2, 0), V(2, 0, 0)], L3$1.X, TAU, 8, true); - _meshes.pipe = Mesh.rotation(arrayFromFunction(512, (i, l) => new V3(i / (l - 1), -0.5, 0)), L3$1.X, TAU, 8, true); - _meshes.xyLinePlane = Mesh.plane(); - _meshes.xyDottedLinePlane = makeDottedLinePlane(); - _meshes.pipeSegmentForICurve = Mesh.offsetVertices(M4.rotateY(90 * DEG).transformedPoints(arrayFromFunction(4, (i) => V3.polar(1, (TAU * i) / 4))), V3.X, true); -} -function initShaders(_gl) { - _gl.makeCurrent(); - return { - singleColor: Shader.create(vertexShaderBasic, fragmentShaderColor), - multiColor: Shader.create(vertexShaderColor, fragmentShaderVaryingColor), - singleColorHighlight: Shader.create(vertexShaderBasic, fragmentShaderColorHighlight), - textureColor: Shader.create(vertexShaderTexture, fragmentShaderTextureColor), - arc: Shader.create(vertexShaderRing, fragmentShaderColor), - arc2: Shader.create(vertexShaderArc, fragmentShaderColor), - ellipse3d: Shader.create(vertexShaderConic3d, fragmentShaderColor), - generic3d: Shader.create(vertexShaderGeneric, fragmentShaderColor), - bezier3d: Shader.create(vertexShaderBezier3d, fragmentShaderColor), - nurbs: Shader.create(vertexShaderNURBS, fragmentShaderColor3), - bezier: Shader.create(vertexShaderBezier, fragmentShaderColor), - lighting: Shader.create(vertexShaderLighting, fragmentShaderLighting), - waves: Shader.create(vertexShaderWaves, fragmentShaderLighting), - }; -} -function makeDottedLinePlane(count = 128) { - const mesh = new Mesh().addIndexBuffer("LINES"); - const OXvertices = arrayFromFunction(count, (i) => new V3(i / count, 0, 0)); - mesh.vertices.push(...OXvertices); - mesh.vertices.push(...M4.forSys(V3.Y, V3.O, V3.O, V3.X).transformedPoints(OXvertices)); - mesh.vertices.push(...M4.forSys(V3.X.negated(), V3.O, V3.O, new V3(1, 1, 0)).transformedPoints(OXvertices)); - mesh.vertices.push(...M4.forSys(V3.Y.negated(), V3.O, V3.O, V3.Y).transformedPoints(OXvertices)); - mesh.LINES = arrayFromFunction(count * 4, (i) => i - (i >= count * 2 ? 1 : 0)); - mesh.compile(); - return mesh; -} -function initNavigationEvents(_gl, eye, paintScreen) { - const canvas = _gl.canvas; - let lastPos = V3.O; - //_gl.onmousedown.push((e) => { - // e.preventDefault() - // e.stopPropagation() - //}) - //_gl.onmouseup.push((e) => { - // e.preventDefault() - // e.stopPropagation() - //}) - canvas.addEventListener("mousemove", (e) => { - const pagePos = V(e.pageX, e.pageY); - const delta = lastPos.to(pagePos); - //noinspection JSBitwiseOperatorUsage - if (e.buttons & 4) { - // pan - const moveCamera = V((-delta.x * 2) / _gl.canvas.width, (delta.y * 2) / _gl.canvas.height); - const inverseProjectionMatrix = _gl.projectionMatrix.inversed(); - const worldMoveCamera = inverseProjectionMatrix.transformVector(moveCamera); - eye.pos = eye.pos.plus(worldMoveCamera); - eye.focus = eye.focus.plus(worldMoveCamera); - setupCamera(eye, _gl); - paintScreen(); - } - // scene rotation - //noinspection JSBitwiseOperatorUsage - if (e.buttons & 2) { - const rotateLR = (-delta.x / 6.0) * DEG; - const rotateUD = (-delta.y / 6.0) * DEG; - // rotate - let matrix = M4.rotateLine(eye.focus, eye.up, rotateLR); - //let horizontalRotationAxis = focus.minus(pos).cross(up) - const horizontalRotationAxis = eye.up.cross(eye.pos.minus(eye.focus)); - matrix = matrix.times(M4.rotateLine(eye.focus, horizontalRotationAxis, rotateUD)); - eye.pos = matrix.transformPoint(eye.pos); - eye.up = matrix.transformVector(eye.up); - setupCamera(eye, _gl); - paintScreen(); - } - lastPos = pagePos; - }); - canvas.addEventListener("wheel", (e) => { - // zoom - const wheelY = -sign(e.deltaY) * 2; - // console.log(e.deltaY, e.deltaX) - eye.zoomFactor *= pow(0.9, -wheelY); - const mouseCoordsOnCanvas = getPosOnTarget(e); - const mousePosFrustrum = V((mouseCoordsOnCanvas.x * 2) / _gl.canvas.offsetWidth - 1, (-mouseCoordsOnCanvas.y * 2) / _gl.canvas.offsetHeight + 1, 0); - const moveCamera = mousePosFrustrum.times(1 - 1 / pow(0.9, -wheelY)); - const inverseProjectionMatrix = _gl.projectionMatrix.inversed(); - const worldMoveCamera = inverseProjectionMatrix.transformVector(moveCamera); - //console.log("moveCamera", moveCamera) - //console.log("worldMoveCamera", worldMoveCamera) - eye.pos = eye.pos.plus(worldMoveCamera); - eye.focus = eye.focus.plus(worldMoveCamera); - // tilt - const mousePosWC = inverseProjectionMatrix.transformPoint(mousePosFrustrum); - const tiltMatrix = M4.rotateLine(mousePosWC, eye.pos.to(eye.focus), -sign(e.deltaX) * 10 * DEG); - eye.up = tiltMatrix.transformVector(eye.up); - eye.pos = tiltMatrix.transformPoint(eye.pos); - eye.focus = tiltMatrix.transformPoint(eye.focus); - setupCamera(eye, _gl); - paintScreen(); - e.preventDefault(); - }); -} -/** - * Transforms position on the screen into a line in world coordinates. - */ -function getMouseLine(pos, _gl) { - const ndc1 = V((pos.x * 2) / _gl.canvas.width - 1, (-pos.y * 2) / _gl.canvas.height + 1, 0); - const ndc2 = V((pos.x * 2) / _gl.canvas.width - 1, (-pos.y * 2) / _gl.canvas.height + 1, 1); - //console.log(ndc) - const inverseProjectionMatrix = _gl.projectionMatrix.inversed(); - const s = inverseProjectionMatrix.transformPoint(ndc1); - const dir = inverseProjectionMatrix.transformPoint(ndc2).minus(s); - return L3$1.anchorDirection(s, dir); -} -function getPosOnTarget(e) { - const target = e.target; - const targetRect = target.getBoundingClientRect(); - const mouseCoordsOnElement = { - x: e.clientX - targetRect.left, - y: e.clientY - targetRect.top, - }; - return mouseCoordsOnElement; -} -function setupCamera(_eye, _gl, suppressEvents = false) { - const { pos, focus, up, zoomFactor } = _eye; - //console.log("pos", pos.$, "focus", focus.$, "up", up.$) - _gl.matrixMode(_gl.PROJECTION); - _gl.loadIdentity(); - //_gl.perspective(70, _gl.canvas.width / _gl.canvas.height, 0.1, 1000); - const lr = _gl.canvas.width / 2 / zoomFactor; - const bt = _gl.canvas.height / 2 / zoomFactor; - _gl.ortho(-lr, lr, -bt, bt, -1e4, 1e4); - _gl.lookAt(pos, focus, up); - _gl.matrixMode(_gl.MODELVIEW); - !suppressEvents && cameraChangeListeners.forEach((l) => l(_eye)); -} -const cameraChangeListeners = []; -const SHADERS_TYPE_VAR = false ; -// let shaders: typeof SHADERS_TYPE_VAR -// declare let a: BRep, b: BRep, c: BRep, d: BRep, edges: Edge[] = [], hovering: any, -// , normallines: boolean = false, b2s: BRep[] = [] -// const - -class Quaternion { - constructor(s, x, y, z) { - this.s = s; - this.x = x; - this.y = y; - this.z = z; - } - static axis(axis, rotation) { - assertf(() => axis.hasLength(1)); - return new Quaternion(cos(rotation / 2), sin(rotation / 2) * axis.x, sin(rotation / 2) * axis.y, sin(rotation / 2) * axis.z); - } - static of(s, x, y, z) { - return new Quaternion(s, x, y, z); - } - plus(q) { - return new Quaternion(this.s + q.s, this.x + q.x, this.y + q.y, this.z + q.z); - } - times(q) { - return "number" == typeof q - ? new Quaternion(q * this.s, q * this.x, q * this.y, q * this.z) - : new Quaternion(this.s * q.s - (this.x * q.x + this.y * q.y + this.z * q.z), this.y * q.z - this.z * q.y + this.s * q.x + q.s * this.x, this.z * q.x - this.x * q.z + this.s * q.y + q.s * this.y, this.x * q.y - this.y * q.x + this.s * q.z + q.s * this.z); - } - conjugated() { - return new Quaternion(this.s, -this.x, -this.y, -this.z); - } - length() { - return Math.hypot(this.s, this.x, this.y, this.z); - } - norm() { - return Math.pow(this.s, 2) + Math.pow(this.x, 2) + (Math.pow(this.y, 2) + Math.pow(this.z, 2)); - } - unit() { - const l = this.length(); - return new Quaternion(this.s / l, this.x / l, this.y / l, this.z / l); - } - inverse() { - return this.conjugated().times(1 / this.norm()); - } - toM4() { - assertf(() => eq(1, this.length())); - const { s, x, y, z } = this; - // prettier-ignore - return new M4([ - 1 - 2 * (y * y + z * z), 2 * (x * y - z * s), 2 * (x * z + y * s), 0, - 2 * (x * y + z * s), 1 - 2 * (x * x + z * z), 2 * (y * z - x * s), 0, - 2 * (x * z - y * s), 2 * (y * z + x * s), 1 - 2 * (x * x + y * y), 0, - 0, 0, 0, 1, - ]); - } - static fromRotation(m4) { - const sqrtTracePlus1 = Math.sqrt(m4.trace() + 1); - const f = 1 / (2 * sqrtTracePlus1); - return new Quaternion(sqrtTracePlus1 / 2, f * (m4.e(2, 1) - m4.e(1, 2)), f * (m4.e(0, 2) - m4.e(2, 0)), f * (m4.e(1, 0) - m4.e(0, 1))); - } - rotatePoint(p) { - const v = this.times(Quaternion.of(1, p.x, p.y, p.z)).times(this.conjugated()); - return new V3(v.x, v.y, v.z); - } - like(q, precision) { - return (eq(this.s, q.s, precision) && - eq(this.x, q.x, precision) && - eq(this.y, q.y, precision) && - eq(this.z, q.z, precision)); - } - equals(q) { - return (this == q || - (q instanceof Quaternion && - this.s == q.s && - this.x == q.x && - this.y == q.y && - this.z == q.z)); - } - hashCode() { - let hashCode = 0; - hashCode = (hashCode * 31 + floatHashCode(this.s)) | 0; - hashCode = (hashCode * 31 + floatHashCode(this.x)) | 0; - hashCode = (hashCode * 31 + floatHashCode(this.y)) | 0; - hashCode = (hashCode * 31 + floatHashCode(this.z)) | 0; - return hashCode; - } - slerp(b, f) { - assertf(() => eq(1, this.length())); - assertf(() => eq(1, b.length())); - const a = this; - let dot = a.s * b.s + a.x * b.x + a.y * b.y + a.z * b.z; - if (dot < 0) { - dot = -dot; - b = b.times(-1); - console.log("dot < 0"); - } - const DOT_THRESHOLD = 0.9995; - if (dot > DOT_THRESHOLD) { - // If the inputs are too close for comfort, linearly interpolate - // and normalize the result. - return a - .times(1 - f) - .plus(b.times(f)) - .unit(); - } - // Since dot is in range [0, DOT_THRESHOLD], acos is safe - const theta0 = acos(dot); // theta_0 = angle between input vectors - const theta = theta0 * f; // theta = angle between v0 and result - const s0 = cos(theta) - (dot * sin(theta)) / sin(theta0); // == sin(theta_0 - theta) / sin(theta_0) - const s1 = sin(theta) / sin(theta0); - console.log(s0, s1, a.times(s0), b.times(s1)); - return a.times(s0).plus(b.times(s1)); - } - toArray() { - return [this.s, this.x, this.y, this.z]; - } -} -Quaternion.O = new Quaternion(1, 0, 0, 0); - -class ImplicitSurface extends Surface$1 { - static is(obj) { - return obj.implicitFunction && obj.didp; - } -} - -export { AABB2, ALONG_EDGE_OR_PLANE, B2T, BREPGLContext, BRep, BezierCurve, COLORS, COPLANAR_OPPOSITE, COPLANAR_SAME, CURVE_PAINTERS, CalculateAreaVisitor, ClassSerializer, ConicSurface, Curve, CustomPlane, CylinderSurface, EPS, Edge, EllipseCurve, EllipsoidSurface, Face, FaceInfoFactory, HyperbolaCurve, INSIDE, ImplicitCurve, ImplicitSurface, L3, MathFunctionR2R, NURBS, NURBSSurface, OUTSIDE, P3, PCurveEdge, PICurve, PPCurve, ParabolaCurve, ParametricSurface, PlaneFace, PlaneSurface, PointProjectedSurface, PointVsFace, ProjectedCurveSurface, Quaternion, RotatedCurveSurface, RotationFace, SHADERS_TYPE_VAR, StraightEdge, Surface, XiEtaCurve, ZDirVolumeVisitor, addLikeSurfaceFaces, arbitraryCorner, arrayLerp, assembleFaceFromLooseEdges, breakDownPPCurves, calcNextEdgeIndex, cameraChangeListeners, cas2, cassini, createEdge, curvePoint, curvePointMF, curvePointPP, doNotSerialize, dotCurve, dotCurve2, edgeForCurveAndTs, edgeNgon, edgePathFromSVG, edgeRect, edgeStar, fff, followAlgorithm2d, followAlgorithm2dAdjustable, followAlgorithmPP, getExtremePointsHelper, getGlobalId, getMouseLine, getPosOnTarget, glqArray, glqV3, initMeshes, initNavigationEvents, initShaders, intersectionCircleLine, intersectionICurveICurve, intersectionICurveICurve2, intersectionUnitCircleLine, intersectionUnitCircleLine2, intersectionUnitHyperbolaLine, parabola4Projection, parseGetParams, projectCurve, projectPointCurve, reuleaux, rotateCurve, round$1 as round, setupCamera, splitsVolumeEnclosingCone, splitsVolumeEnclosingCone2, splitsVolumeEnclosingFaces, splitsVolumeEnclosingFacesP, splitsVolumeEnclosingFacesP2, surfaceIsICurveIsInfosWithLine, triangulateVertices, uvInAABB2 }; -//# sourceMappingURL=bundle.module.js.map diff --git a/dist/bundle.module.js.map b/dist/bundle.module.js.map deleted file mode 100644 index 59c05e3..0000000 --- a/dist/bundle.module.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"bundle.module.js","sources":["../out/math.js","../out/curve/Curve.js","../out/curve/XiEtaCurve.js","../out/curve/ImplicitCurve.js","../out/curve/BezierCurve.js","../out/curve/HyperbolaCurve.js","../out/curve/L3.js","../out/curve/PICurve.js","../out/curve/PPCurve.js","../out/curve/ParabolaCurve.js","../out/curve/EllipseCurve.js","../out/curve/NURBS.js","../out/P3.js","../out/surface/Surface.js","../out/surface/ParametricSurface.js","../out/surface/ConicSurface.js","../out/surface/ProjectedCurveSurface.js","../out/surface/RotatedCurveSurface.js","../out/surface/CylinderSurface.js","../out/surface/EllipsoidSurface.js","../out/surface/PlaneSurface.js","../out/surface/PointProjectedSurface.js","../out/surface/NURBSSurface.js","../out/surface/ZDirVolumeVisitor.js","../out/surface/CalculateAreaVisitor.js","../out/BRepGenerators.js","../out/CustomPlane.js","../out/Edge.js","../out/StraightEdge.js","../out/PCurveEdge.js","../out/edgeUtil.js","../out/FaceInfo.js","../out/Face.js","../out/BRep.js","../out/ClassSerializer.js","../out/shaders.js","../out/BREPGLContext.js","../out/Quaternion.js","../out/surface/ImplicitSurface.js"],"sourcesContent":["export const { abs, acos, acosh, asin, asinh, atan, atanh, atan2, ceil, cbrt, expm1, clz32, cos, cosh, exp, floor, fround, hypot, imul, log, log1p, log2, log10, max, min, pow, random, round, sign, sin, sinh, sqrt, tan, tanh, trunc, E, LN10, LN2, LOG10E, LOG2E, PI, SQRT1_2, SQRT2, } = Math;\r\n//# sourceMappingURL=math.js.map","import { AABB, arrayEquals, arrayFromFunction, arrayHashCode, assert, assertNumbers, callsce, clamp, eq, eq0, fuzzyUniquesF, getIntervals, getLast, glqInSteps, hasConstructor, le, mapFilter, newtonIterate1d, newtonIterate2dWithDerivatives, newtonIterateWithDerivative, NLA_PRECISION, Transformable, V, V3, withMax, } from \"ts3dutils\";\r\nimport { curvePointPP, EllipsoidSurface, followAlgorithm2d, followAlgorithmPP, P3, PlaneSurface, PPCurve, ProjectedCurveSurface, } from \"../index\";\r\nimport { abs, ceil, floor } from \"../math\";\r\nlet insideIsInfosWithCurve = false;\r\nexport class Curve extends Transformable {\r\n constructor(tMin, tMax) {\r\n super();\r\n this.tMin = tMin;\r\n this.tMax = tMax;\r\n assertNumbers(tMin, tMax);\r\n assert(\"number\" === typeof tMin && !isNaN(tMin));\r\n assert(\"number\" === typeof tMax && !isNaN(tMax));\r\n assert(tMin < tMax, \"tMin < tMax \" + tMin + \" < \" + tMax);\r\n }\r\n static integrate(curve, startT, endT, steps) {\r\n const step = (endT - startT) / steps;\r\n let length = 0;\r\n let p = curve.at(startT);\r\n let i = 0, t = startT + step;\r\n for (; i < steps; i++, t += step) {\r\n const next = curve.at(t);\r\n length += p.distanceTo(next);\r\n p = next;\r\n }\r\n return length;\r\n }\r\n static ispsRecursive(curve1, tMin, tMax, curve2, sMin, sMax) {\r\n // the recursive function finds good approximates for the intersection points\r\n // curve1 function uses newton iteration to improve the result as much as possible\r\n function handleStartTS(startT, startS) {\r\n if (!result.some((info) => eq(info.tThis, startT) && eq(info.tOther, startS))) {\r\n const f1 = (t, s) => curve1.tangentAt(t).dot(curve1.at(t).minus(curve2.at(s)));\r\n const f2 = (t, s) => curve2.tangentAt(s).dot(curve1.at(t).minus(curve2.at(s)));\r\n // f = (b1, b2, t1, t2) = b1.tangentAt(t1).dot(b1.at(t1).minus(b2.at(t2)))\r\n const dfdt1 = (b1, b2, t1, t2) => b1.ddt(t1).dot(b1.at(t1).minus(b2.at(t2))) +\r\n b1.tangentAt(t1).squared();\r\n const dfdt2 = (b1, b2, t1, t2) => -b1.tangentAt(t1).dot(b2.tangentAt(t2));\r\n const ni = newtonIterate2dWithDerivatives(f1, f2, startT, startS, 16, dfdt1.bind(undefined, curve1, curve2), dfdt2.bind(undefined, curve1, curve2), (t, s) => -dfdt2(curve2, curve1, s, t), (t, s) => -dfdt1(curve2, curve1, s, t));\r\n assert(isFinite(ni.x));\r\n assert(isFinite(ni.y));\r\n if (ni == undefined)\r\n console.log(startT, startS, curve1.sce, curve2.sce);\r\n result.push({ tThis: ni.x, tOther: ni.y, p: curve1.at(ni.x) });\r\n }\r\n }\r\n // returns whether an intersection was immediately found (i.e. without further recursion)\r\n function findRecursive(tMin, tMax, sMin, sMax, curve1AABB, curve2AABB, depth = 0) {\r\n const EPS = NLA_PRECISION;\r\n if (curve1AABB.touchesAABBfuzzy(curve2AABB)) {\r\n const tMid = (tMin + tMax) / 2;\r\n const sMid = (sMin + sMax) / 2;\r\n if (Math.abs(tMax - tMin) < EPS || Math.abs(sMax - sMin) < EPS) {\r\n handleStartTS(tMid, sMid);\r\n return true;\r\n }\r\n else {\r\n const curve1AABBleft = curve1.getAABB(tMin, tMid);\r\n const curve2AABBleft = curve2.getAABB(sMin, sMid);\r\n let curve1AABBright, curve2AABBright;\r\n // if one of the following calls immediately finds an intersection, we don't want to call the others\r\n // as that will lead to the same intersection being output multiple times\r\n findRecursive(tMin, tMid, sMin, sMid, curve1AABBleft, curve2AABBleft, depth + 1) ||\r\n findRecursive(tMin, tMid, sMid, sMax, curve1AABBleft, (curve2AABBright = curve2.getAABB(sMid, sMax)), depth + 1) ||\r\n findRecursive(tMid, tMax, sMin, sMid, (curve1AABBright = curve1.getAABB(tMid, tMax)), curve2AABBleft, depth + 1) ||\r\n findRecursive(tMid, tMax, sMid, sMax, curve1AABBright, curve2AABBright, depth + 1);\r\n }\r\n }\r\n return false;\r\n }\r\n const result = [];\r\n findRecursive(tMin, tMax, sMin, sMax, curve1.getAABB(tMin, tMax), curve2.getAABB(sMin, sMax));\r\n return fuzzyUniquesF(result, (info) => info.tThis);\r\n }\r\n /**\r\n * Searches a 2d area for (an) implicit curve(s).\r\n * @param implicitCurve\r\n * @param bounds Defines area to search.\r\n * @param uStep Granularity of search in s-direction.\r\n * @param vStep Granularity of search in t-direction.\r\n * @param stepSize step size to take along the curve\r\n * @return\r\n */\r\n static breakDownIC(implicitCurve, bounds, uStep, vStep, stepSize, validUV) {\r\n //undefined == didu && (didu = (u, v) => (implicitCurve(u + EPS, v) - implicitCurve(u, v)) / EPS)\r\n //undefined == didv && (didv = (u, v) => (implicitCurve(u, v + EPS) - implicitCurve(u, v)) / EPS)\r\n const { uMin, uMax, vMin, vMax } = bounds;\r\n const deltaS = uMax - uMin, deltaT = vMax - vMin;\r\n const sRes = ceil(deltaS / uStep), tRes = ceil(deltaT / vStep);\r\n const grid = new Array(sRes * tRes).fill(0);\r\n // const printGrid = () =>\r\n // \tconsole.log(\r\n // \t\tarrayFromFunction(tRes, i =>\r\n // \t\t\tgrid\r\n // \t\t\t\t.slice(sRes * i, sRes * (i + 1))\r\n // \t\t\t\t.map(v => (v ? 'X' : '_'))\r\n // \t\t\t\t.join(''),\r\n // \t\t).join('\\n'),\r\n // \t)\r\n const get = (i, j) => grid[j * sRes + i];\r\n const set = (i, j) => 0 <= i && i < sRes && 0 <= j && j < tRes && (grid[j * sRes + i] = 1);\r\n const result = [];\r\n const logTable = [];\r\n for (let i = 0; i < sRes; i++) {\r\n search: for (let j = 0; j < tRes; j++) {\r\n if (get(i, j))\r\n continue;\r\n set(i, j);\r\n let u = uMin + (i + 0.5) * uStep, v = vMin + (j + 0.5) * vStep;\r\n const startS = u, startT = v;\r\n // basically curvePoint\r\n for (let k = 0; k < 8; k++) {\r\n const fp = implicitCurve(u, v);\r\n const dfpdx = implicitCurve.x(u, v), dfpdy = implicitCurve.y(u, v);\r\n if (0 === Math.pow(dfpdx, 2) + Math.pow(dfpdy, 2)) {\r\n // top of a hill, keep looking\r\n continue search;\r\n }\r\n const scale = fp / (Math.pow(dfpdx, 2) + Math.pow(dfpdy, 2));\r\n u -= scale * dfpdx;\r\n v -= scale * dfpdy;\r\n }\r\n const li = floor((u - uMin) / uStep), lj = floor((v - vMin) / vStep);\r\n logTable.push({\r\n i,\r\n j,\r\n li,\r\n lj,\r\n startS,\r\n startT,\r\n u,\r\n v,\r\n \"bounds(u, v)\": uvInAABB2(bounds, u, v),\r\n \"ic(s,t)\": implicitCurve(u, v),\r\n });\r\n if (!(i == li && j == lj) && get(li, lj)) {\r\n continue search;\r\n }\r\n set(li, lj);\r\n // u, v are now good starting coordinates to use follow algorithm\r\n if (uvInAABB2(bounds, u, v) &&\r\n validUV(u, v) &&\r\n eq0(implicitCurve(u, v))) {\r\n const subResult = mkcurves(implicitCurve, u, v, stepSize, bounds, validUV);\r\n for (const curveData of subResult) {\r\n assert(curveData.points.length > 2);\r\n for (const { x, y } of curveData.points) {\r\n const lif = (x - uMin) / uStep, ljf = (y - vMin) / vStep;\r\n set((lif - 0.5) | 0, (ljf - 0.5) | 0);\r\n set((lif - 0.5) | 0, (ljf + 0.5) | 0);\r\n set((lif + 0.5) | 0, (ljf - 0.5) | 0);\r\n set((lif + 0.5) | 0, (ljf + 0.5) | 0);\r\n }\r\n }\r\n //printGrid()\r\n result.push(...subResult);\r\n }\r\n }\r\n }\r\n // console.table(logTable)\r\n for (const { points } of result) {\r\n for (let i = 0; i < points.length - 1; i++) {\r\n assert(!points[i].equals(points[i + 1]));\r\n }\r\n }\r\n return result;\r\n }\r\n toString() {\r\n return this.toSource();\r\n }\r\n toSource(rounder = (x) => x) {\r\n return callsce.call(undefined, \"new \" + this.constructor.name, ...this.getConstructorParameters(), this.tMin, this.tMax);\r\n }\r\n withBounds(tMin = this.tMin, tMax = this.tMax) {\r\n //assert(this.tMin <= tMin && tMin <= this.tMax)\r\n //assert(this.tMin <= tMax && tMax <= this.tMax)\r\n return new this.constructor(...this.getConstructorParameters(), tMin, tMax);\r\n }\r\n /**\r\n * The point on the line that is closest to the given point.\r\n */\r\n closestPointToPoint(p) {\r\n return this.at(this.closestTToPoint(p));\r\n }\r\n isValidT(t) {\r\n return le(this.tMin, t) && le(t, this.tMax);\r\n }\r\n diff(t, eps) {\r\n return this.at(t).to(this.at(t + eps));\r\n }\r\n // TODO: tmin/tmax first\r\n closestTToPoint(p, tStart, tMin = this.tMin, tMax = this.tMax) {\r\n // this.at(t) has minimal distance to p when this.tangentAt(t) is perpendicular to\r\n // the vector between this.at(t) and p. This is the case iff the dot product of the two is 0.\r\n // f = (this.at(t) - p) . (this.tangentAt(t)\r\n // df = this.tangentAt(t) . this.tangentAt(t) + (this.at(t) - p) . this.ddt(t)\r\n // = this.tangentAt(t)² + (this.at(t) - p) . this.ddt(t)\r\n const f = (t) => this.at(t).minus(p).dot(this.tangentAt(t)); // 5th degree polynomial\r\n const df = (t) => this.tangentAt(t).squared() + this.at(t).minus(p).dot(this.ddt(t));\r\n //checkDerivate(f, df, tMin, tMax)\r\n const STEPS = 32;\r\n if (undefined === tStart) {\r\n tStart = withMax(arrayFromFunction(STEPS, (i) => tMin + ((tMax - tMin) * i) / (STEPS - 1)), (t) => -this.at(t).distanceTo(p));\r\n }\r\n return newtonIterateWithDerivative(f, tStart, 16, df);\r\n }\r\n /**\r\n * So different edges on the same curve do not have different vertices, they are always generated\r\n * on fixed points this.at(k * this.tIncrement), with k taking integer values\r\n *\r\n */\r\n calcSegmentPoints(aT, bT, a, b, reversed, includeFirst) {\r\n assert(this.tIncrement, \"tIncrement not defined on \" + this);\r\n const inc = this.tIncrement;\r\n const result = [];\r\n if (includeFirst)\r\n result.push(a);\r\n assert(reversed != aT < bT);\r\n if (aT < bT) {\r\n const start = Math.ceil((aT + NLA_PRECISION) / inc);\r\n const end = Math.floor((bT - NLA_PRECISION) / inc);\r\n for (let i = start; i <= end; i++) {\r\n result.push(this.at(i * inc));\r\n }\r\n }\r\n else {\r\n const start = Math.floor((aT - NLA_PRECISION) / inc);\r\n const end = Math.ceil((bT + NLA_PRECISION) / inc);\r\n for (let i = start; i >= end; i--) {\r\n result.push(this.at(i * inc));\r\n }\r\n }\r\n result.push(b);\r\n return result;\r\n }\r\n calcSegmentTs(aT, bT, reversed, includeFirst) {\r\n assert(this.tIncrement, \"tIncrement not defined on \" + this);\r\n const inc = this.tIncrement;\r\n const result = [];\r\n if (includeFirst)\r\n result.push(aT);\r\n assert(reversed != aT < bT);\r\n if (aT < bT) {\r\n const start = Math.ceil((aT + NLA_PRECISION) / inc);\r\n const end = Math.floor((bT - NLA_PRECISION) / inc);\r\n for (let i = start; i <= end; i++) {\r\n result.push(i * inc);\r\n }\r\n }\r\n else {\r\n const start = Math.floor((aT - NLA_PRECISION) / inc);\r\n const end = Math.ceil((bT + NLA_PRECISION) / inc);\r\n for (let i = start; i >= end; i--) {\r\n result.push(i * inc);\r\n }\r\n }\r\n result.push(bT);\r\n return result;\r\n }\r\n /**\r\n *\r\n * @param p\r\n * @param tStart Defines interval with tEnd in which a start value for t will be searched.\r\n * Result is not necessarily in this interval.\r\n * @param tEnd\r\n */\r\n distanceToPoint(p, tStart, tEnd) {\r\n const closestT = this.closestTToPoint(p, tStart, tEnd);\r\n return this.at(closestT).distanceTo(p);\r\n }\r\n asSegmentDistanceToPoint(p, tStart, tEnd) {\r\n let t = this.closestTToPoint(p, tStart, tEnd);\r\n t = clamp(t, tStart, tEnd);\r\n return this.at(t).distanceTo(p);\r\n }\r\n /**\r\n * Behavior when curves are colinear: self intersections\r\n */\r\n isInfosWithCurve(curve) {\r\n if (insideIsInfosWithCurve) {\r\n return Curve.ispsRecursive(this, this.tMin, this.tMax, curve, curve.tMin, curve.tMax);\r\n }\r\n else {\r\n try {\r\n insideIsInfosWithCurve = true;\r\n const infos = curve.isInfosWithCurve(this);\r\n return infos.map((info) => {\r\n assert(info);\r\n const { tThis, tOther, p } = info;\r\n return { tOther: tThis, tThis: tOther, p };\r\n });\r\n }\r\n finally {\r\n insideIsInfosWithCurve = false;\r\n }\r\n }\r\n }\r\n isTsWithSurface(surface) {\r\n if (surface instanceof PlaneSurface) {\r\n return this.isTsWithPlane(surface.plane);\r\n }\r\n if (surface instanceof ProjectedCurveSurface) {\r\n const projPlane = new P3(surface.dir.unit(), 0);\r\n const projThis = this.project(projPlane);\r\n const projEllipse = surface.baseCurve.project(projPlane);\r\n return projEllipse.isInfosWithCurve(projThis).map((info) => info.tOther);\r\n }\r\n if (surface instanceof EllipsoidSurface) {\r\n const thisOC = this.transform(surface.matrixInverse);\r\n if (!thisOC.getAABB().touchesAABBfuzzy(new AABB(V3.XYZ.negated(), V3.XYZ))) {\r\n return [];\r\n }\r\n const f = (t) => thisOC.at(t).length() - 1;\r\n const df = (t) => thisOC.at(t).unit().dot(thisOC.tangentAt(t));\r\n const stepSize = 1 / (1 << 11);\r\n const result = [];\r\n for (let startT = this.tMin; startT <= this.tMax; startT += stepSize) {\r\n const dt = stepSize * thisOC.tangentAt(startT).length();\r\n if (abs(f(startT)) <= dt) {\r\n //const t = newtonIterate1d(f, startT, 16)\r\n let t = newtonIterateWithDerivative(f, startT, 16, df);\r\n if (!eq0(f(t)) || eq0(df(t))) {\r\n t = newtonIterate1d(df, startT, 16);\r\n //if (f(a) * f(b) < 0) {\r\n // t = bisect(f, a, b, 16)\r\n //} else if (df(a) * df(b) < 0) {\r\n // t = bisect(df, a, b, 16)\r\n //}\r\n }\r\n if (eq0(f(t)) && !result.some((r) => eq(r, t))) {\r\n result.push(t);\r\n }\r\n }\r\n }\r\n return result.filter((t) => surface.containsPoint(this.at(t)));\r\n }\r\n throw new Error();\r\n }\r\n arcLength(startT, endT, steps = 1) {\r\n assert(startT < endT, \"startT < endT\");\r\n return glqInSteps((t) => this.tangentAt(t).length(), startT, endT, steps);\r\n }\r\n equals(obj) {\r\n if (this === obj)\r\n return true;\r\n return (hasConstructor(obj, this.constructor) &&\r\n arrayEquals(this.getConstructorParameters(), obj.getConstructorParameters()));\r\n }\r\n hashCode() {\r\n return arrayHashCode(this.getConstructorParameters());\r\n }\r\n getAABB(tMin = this.tMin, tMax = this.tMax) {\r\n tMin = isFinite(tMin) ? tMin : this.tMin;\r\n tMax = isFinite(tMax) ? tMax : this.tMax;\r\n const tMinAt = this.at(tMin), tMaxAt = this.at(tMax);\r\n const roots = this.roots();\r\n const mins = [0, 0, 0];\r\n const maxs = [0, 0, 0];\r\n for (let dim = 0; dim < 3; dim++) {\r\n const tRoots = roots[dim];\r\n mins[dim] = Math.min(tMinAt.e(dim), tMaxAt.e(dim));\r\n maxs[dim] = Math.max(tMinAt.e(dim), tMaxAt.e(dim));\r\n for (const tRoot of tRoots) {\r\n if (tMin < tRoot && tRoot < tMax) {\r\n mins[dim] = Math.min(mins[dim], this.at(tRoot).e(dim));\r\n maxs[dim] = Math.max(maxs[dim], this.at(tRoot).e(dim));\r\n }\r\n }\r\n }\r\n return new AABB(V3.fromArray(mins), V3.fromArray(maxs));\r\n }\r\n reversed() {\r\n throw new Error();\r\n }\r\n clipPlane(plane) {\r\n const ists = this.isTsWithPlane(plane).filter((ist) => this.tMin <= ist && ist <= this.tMax);\r\n return mapFilter(getIntervals(ists, this.tMin, this.tMax), ([a, b]) => {\r\n const midT = (a + b) / 2;\r\n return (!eq(a, b) &&\r\n plane.distanceToPointSigned(this.at(midT)) < 0 &&\r\n this.withBounds(a, b));\r\n });\r\n }\r\n}\r\nCurve.hlol = 0;\r\nfunction mkcurves(implicitCurve, sStart, tStart, stepSize, bounds, validUV) {\r\n const start = V(sStart, tStart);\r\n assert(stepSize > 0);\r\n // checkDerivate(s => implicitCurve(s, 0), s => didu(s, 0), -1, 1, 0)\r\n // checkDerivate(t => implicitCurve(0, t), t => didv(0, t), -1, 1, 0)\r\n const { points, tangents } = followAlgorithm2d(implicitCurve, start, stepSize, bounds, validUV);\r\n if (points.length > 4 &&\r\n points[0].distanceTo(getLast(points)) <= abs(stepSize)) {\r\n // this is a loop: split it\r\n for (let i = 0; i < points.length - 1; i++) {\r\n assert(!points[i].equals(points[i + 1]));\r\n }\r\n const half = floor(points.length / 2);\r\n const points1 = points.slice(0, half), points2 = points.slice(half - 1, points.length);\r\n const tangents1 = tangents.slice(0, half), tangents2 = tangents.slice(half - 1, tangents.length);\r\n //tangents2[tangents2.length - 1] = tangents1[0]\r\n //points2[tangents2.length - 1] = points1[0]\r\n for (let i = 0; i < points1.length - 1; i++) {\r\n assert(!points1[i].equals(points1[i + 1]));\r\n }\r\n for (let i = 0; i < points2.length - 1; i++) {\r\n assert(!points2[i].equals(points2[i + 1]));\r\n }\r\n return [\r\n { points: points1, tangents: tangents1 },\r\n { points: points2, tangents: tangents2 },\r\n ];\r\n }\r\n else {\r\n // not a loop: check in the other direction\r\n const { points: reversePoints, tangents: reverseTangents, } = followAlgorithm2d(implicitCurve, start, -stepSize, bounds, validUV);\r\n const result = followAlgorithm2d(implicitCurve, getLast(reversePoints), stepSize, bounds, validUV, undefined, getLast(reverseTangents).negated());\r\n assert(result.points.length > 2);\r\n return [result];\r\n }\r\n}\r\nexport function breakDownPPCurves(ps1, ps2, uStep, vStep, stepSize) {\r\n const { uMin, uMax, vMin, vMax } = ps1;\r\n const bounds = uvInAABB2.bind(undefined, ps1);\r\n const bounds2 = uvInAABB2.bind(undefined, ps2);\r\n const deltaU = uMax - uMin, deltaV = vMax - vMin;\r\n const sRes = ceil(deltaU / uStep), tRes = ceil(deltaV / vStep);\r\n const grid = new Array(sRes * tRes).fill(0);\r\n //const printGrid = () => console.log(arrayFromFunction(tRes, i => grid.slice(sRes * i, sRes * (i + 1)).map(v => v ? 'X' : '_').join('')).join('\\n'))\r\n const at = (i, j) => grid[j * sRes + i];\r\n const set = (i, j) => 0 <= i && i < sRes && 0 <= j && j < tRes && (grid[j * sRes + i] = 1);\r\n const result = [];\r\n const logTable = [];\r\n for (let i = 0; i < sRes; i++) {\r\n search: for (let j = 0; j < tRes; j++) {\r\n if (at(i, j))\r\n continue;\r\n set(i, j);\r\n const startU = uMin + (i + 0.5) * uStep, startV = vMin + (j + 0.5) * vStep;\r\n // assume point is valid, currently (TODO)\r\n const curvePointPPResult = curvePointPP(ps1, ps2, ps1.pUV(startU, startV));\r\n if (undefined === curvePointPPResult) {\r\n continue search;\r\n }\r\n const { p: startP, st1: { x: u, y: v }, st2: { x: u2, y: v2 }, } = curvePointPPResult;\r\n const li = floor((u - uMin) / uStep), lj = floor((v - vMin) / vStep);\r\n logTable.push({\r\n i,\r\n j,\r\n li,\r\n lj,\r\n startU,\r\n startV,\r\n u,\r\n v,\r\n \"bounds(u, v)\": bounds(u, v),\r\n });\r\n if (!(i == li && j == lj) && at(li, lj)) {\r\n continue search;\r\n }\r\n set(li, lj);\r\n // u, v are now good starting coordinates to use follow algorithm\r\n if (bounds(u, v) && bounds2(u2, v2)) {\r\n console.log(V(u, v).sce);\r\n const subResult = mkPPCurves(ps1, ps2, startP, stepSize, bounds, bounds2);\r\n for (const curveData of subResult) {\r\n assert(curveData.st1s.length > 2);\r\n for (const { x, y } of curveData.st1s) {\r\n const lif = (x - uMin) / uStep, ljf = (y - vMin) / vStep;\r\n set((lif - 0.5) | 0, (ljf - 0.5) | 0);\r\n set((lif - 0.5) | 0, (ljf + 0.5) | 0);\r\n set((lif + 0.5) | 0, (ljf - 0.5) | 0);\r\n set((lif + 0.5) | 0, (ljf + 0.5) | 0);\r\n }\r\n }\r\n //printGrid()\r\n result.push(...subResult);\r\n }\r\n }\r\n }\r\n console.table(logTable);\r\n for (const { points } of result) {\r\n for (let i = 0; i < points.length - 1; i++) {\r\n assert(!points[i].equals(points[i + 1]));\r\n }\r\n }\r\n return result.map(({ points, tangents, st1s }) => {\r\n return new PPCurve(points, tangents, ps1, ps2, st1s, undefined, stepSize, 1);\r\n });\r\n}\r\nfunction mkPPCurves(ps1, ps2, startPoint, stepSize, bounds1, bounds2) {\r\n // checkDerivate(s => implicitCurve(s, 0), s => didu(s, 0), -1, 1, 0)\r\n // checkDerivate(t => implicitCurve(0, t), t => didv(0, t), -1, 1, 0)\r\n const { points, tangents, st1s } = followAlgorithmPP(ps1, ps2, startPoint, stepSize, bounds1, bounds2);\r\n if (points[0].distanceTo(getLast(points)) < stepSize && points.length > 2) {\r\n // this is a loop: split it\r\n for (let i = 0; i < points.length - 1; i++) {\r\n assert(!points[i].equals(points[i + 1]));\r\n }\r\n const half = floor(points.length / 2);\r\n const points1 = points.slice(0, half), points2 = points.slice(half - 1, points.length);\r\n const tangents1 = tangents.slice(0, half), tangents2 = tangents.slice(half - 1, tangents.length);\r\n const st1s1 = st1s.slice(0, half), st1s2 = st1s.slice(half - 1, tangents.length);\r\n tangents2[tangents2.length - 1] = tangents1[0];\r\n points2[tangents2.length - 1] = points1[0];\r\n st1s2[tangents2.length - 1] = st1s1[0];\r\n for (let i = 0; i < points1.length - 1; i++) {\r\n assert(!points1[i].equals(points1[i + 1]));\r\n }\r\n for (let i = 0; i < points2.length - 1; i++) {\r\n assert(!points2[i].equals(points2[i + 1]));\r\n }\r\n return [\r\n { points: points1, tangents: tangents1, st1s: st1s1 },\r\n { points: points2, tangents: tangents2, st1s: st1s2 },\r\n ];\r\n }\r\n else {\r\n // not a loop: check in the other direction\r\n const { points: reversePoints } = followAlgorithmPP(ps1, ps2, startPoint, -stepSize, bounds1, bounds2);\r\n const result = followAlgorithmPP(ps1, ps2, getLast(reversePoints), stepSize, bounds1, bounds2);\r\n assert(result.points.length > 2);\r\n return [result];\r\n }\r\n}\r\nexport function AABB2(uMin, uMax, vMin, vMax) {\r\n return { uMin, uMax, vMin, vMax };\r\n}\r\nexport function uvInAABB2(aabb2, u, v) {\r\n return (aabb2.uMin <= u && u <= aabb2.uMax && aabb2.vMin <= v && v <= aabb2.vMax);\r\n}\r\n/**\r\n * Finds a point on a 2D implicit curve.\r\n *\r\n * @param implicitCurve The curve follows the path where implicitCurve(u, v) is zero.\r\n * @param startPoint The point from which to start looking (only .x = u and .y = v will be read).\r\n * @param didu Derivative of implicitCurve in the first parameter.\r\n * @param didv Derivative of implicitCurve in the second parameter.\r\n */\r\nexport function curvePoint(implicitCurve, startPoint, didu, didv) {\r\n let p = startPoint;\r\n for (let i = 0; i < 8; i++) {\r\n const fp = implicitCurve(p.x, p.y);\r\n const dfpdx = didu(p.x, p.y);\r\n const dfpdy = didv(p.x, p.y);\r\n const scale = fp / (dfpdx * dfpdx + dfpdy * dfpdy);\r\n p = p.minus(new V3(scale * dfpdx, scale * dfpdy, 0));\r\n }\r\n return p;\r\n}\r\nexport function curvePointMF(mf, startPoint, steps = 8, eps = 1 / (1 << 30)) {\r\n let p = startPoint;\r\n for (let i = 0; i < steps; i++) {\r\n const fp = mf(p.x, p.y);\r\n const dfpdx = mf.x(p.x, p.y);\r\n const dfpdy = mf.y(p.x, p.y);\r\n const scale = fp / (dfpdx * dfpdx + dfpdy * dfpdy);\r\n p = p.minus(new V3(scale * dfpdx, scale * dfpdy, 0));\r\n if (abs(fp) <= eps)\r\n break;\r\n }\r\n return p;\r\n}\r\n//# sourceMappingURL=Curve.js.map","import { arrayFromFunction, assertInst, assertNumbers, assertVectors, eq0, hasConstructor, M4, mapFilter, NLA_PRECISION, snap0, solveCubicReal2, TAU, toSource, V, V3, } from \"ts3dutils\";\r\nimport { pushQuad } from \"tsgl\";\r\nimport { BezierCurve, ConicSurface, Curve, EllipseCurve, EllipsoidSurface, HyperbolaCurve, L3, P3, ParabolaCurve, PlaneSurface, ProjectedCurveSurface, } from \"../index\";\r\nimport { abs, acos, acosh, sign, sqrt } from \"../math\";\r\nexport class XiEtaCurve extends Curve {\r\n constructor(center, f1, f2, tMin, tMax) {\r\n super(tMin, tMax);\r\n this.center = center;\r\n this.f1 = f1;\r\n this.f2 = f2;\r\n this.tMin = tMin;\r\n this.tMax = tMax;\r\n assertVectors(center, f1, f2);\r\n this.normal = f1.cross(f2);\r\n if (!this.normal.likeO()) {\r\n this.normal = this.normal.unit();\r\n this.matrix = M4.forSys(f1, f2, this.normal, center);\r\n this.matrixInverse = this.matrix.inversed();\r\n }\r\n else {\r\n this.matrix = M4.forSys(f1, f2, f1.unit(), center);\r\n const f1p = f1.getPerpendicular();\r\n // prettier-ignore\r\n this.matrixInverse = new M4(1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1).times(M4.forSys(f1, f1p, f1.cross(f1p), center).inversed());\r\n }\r\n }\r\n /**\r\n * Intersection of the unit curve with the line ax + by = c.\r\n */\r\n static intersectionUnitLine(a, b, c, tMin, tMax) {\r\n throw new Error(\"abstract\");\r\n }\r\n /**\r\n * Returns a new EllipseCurve representing an ellipse parallel to the XY-plane\r\n * with semi-major/minor axes parallel t the X and Y axes.\r\n *\r\n * @param a length of the axis parallel to X axis.\r\n * @param b length of the axis parallel to Y axis.\r\n * @param center center of the ellipse.\r\n */\r\n static forAB(a, b, center = V3.O) {\r\n return new this(center, V(a, 0, 0), V(0, b, 0));\r\n }\r\n static XYLCValid(pLC) {\r\n throw new Error(\"abstract\");\r\n }\r\n static XYLCPointT(pLC, tMin, tMax) {\r\n throw new Error(\"abstract\");\r\n }\r\n static unitIsInfosWithLine(anchorLC, dirLC, anchorWC, dirWC, tMin, tMax) {\r\n throw new Error(\"abstract\");\r\n }\r\n addToMesh(mesh, res = 4, radius = 0, pointStep = 1) {\r\n const baseNormals = arrayFromFunction(res, (i) => V3.polar(1, (TAU * i) / res));\r\n const baseVertices = arrayFromFunction(res, (i) => V3.polar(radius, (TAU * i) / res));\r\n const inc = this.tIncrement;\r\n const start = Math.ceil((this.tMin + NLA_PRECISION) / inc);\r\n const end = Math.floor((this.tMax - NLA_PRECISION) / inc);\r\n for (let i = start; i <= end; i += pointStep) {\r\n const t = i * inc;\r\n const start = mesh.vertices.length;\r\n if (0 !== i) {\r\n for (let j = 0; j < res; j++) {\r\n pushQuad(mesh.TRIANGLES, true, start - res + j, start + j, start - res + ((j + 1) % res), start + ((j + 1) % res));\r\n }\r\n }\r\n const point = this.at(t), tangent = this.tangentAt(t);\r\n const matrix = M4.forSys(this.normal, tangent.cross(this.normal), tangent, point);\r\n mesh.normals.push(...matrix.transformedVectors(baseNormals));\r\n mesh.vertices.push(...matrix.transformedPoints(baseVertices));\r\n }\r\n }\r\n getConstructorParameters() {\r\n return [this.center, this.f1, this.f2];\r\n }\r\n isInfosWithCurve(curve) {\r\n if (curve instanceof L3) {\r\n return this.isInfosWithLine(curve.anchor, curve.dir1, this.tMin, this.tMax, curve.tMin, curve.tMax);\r\n }\r\n if (curve instanceof BezierCurve) {\r\n return this.isInfosWithBezier(curve);\r\n }\r\n if (curve instanceof XiEtaCurve) {\r\n if (!this.normal.isParallelTo(curve.normal)) {\r\n return mapFilter(this.isTsWithPlane(curve.getPlane()), (tThis) => {\r\n const p = this.at(tThis);\r\n if (curve.containsPoint(p)) {\r\n return { tThis, tOther: curve.pointT(p), p };\r\n }\r\n return undefined;\r\n });\r\n }\r\n }\r\n return super.isInfosWithCurve(curve);\r\n }\r\n transform(m4) {\r\n return new this.constructor(m4.transformPoint(this.center), m4.transformVector(this.f1), m4.transformVector(this.f2), this.tMin, this.tMax);\r\n }\r\n equals(obj) {\r\n return (this == obj ||\r\n (undefined != obj &&\r\n this.constructor == obj.constructor &&\r\n this.center.equals(obj.center) &&\r\n this.f1.equals(obj.f1) &&\r\n this.f2.equals(obj.f2)));\r\n }\r\n hashCode() {\r\n let hashCode = 0;\r\n hashCode = hashCode * 31 + this.center.hashCode();\r\n hashCode = hashCode * 31 + this.f1.hashCode();\r\n hashCode = hashCode * 31 + this.f2.hashCode();\r\n return hashCode | 0;\r\n }\r\n likeCurve(curve) {\r\n return (hasConstructor(curve, this.constructor) &&\r\n this.center.like(curve.center) &&\r\n this.f1.like(curve.f1) &&\r\n this.f2.like(curve.f2));\r\n }\r\n normalP(t) {\r\n return this.tangentAt(t).cross(this.normal);\r\n }\r\n getPlane() {\r\n return P3.normalOnAnchor(this.normal, this.center);\r\n }\r\n isTsWithPlane(planeWC) {\r\n assertInst(P3, planeWC);\r\n /*\r\n this: x = center + f1 * cos t + f2 * sin t (1)\r\n plane:\r\n n := plane.normal1\r\n n DOT x == plane.w (2)\r\n plane defined by f1/f2\r\n x = center + f1 * xi + f2 * eta (3)\r\n intersection plane and planef1/f2:\r\n insert (3) into (2):\r\n n DOT center + n DOT f1 * xi + n DOT f2 * eta = plane.w | -n DOT center\r\n n DOT f1 * xi + n DOT f2 * eta = plane.w - n DOT center (4)\r\n points on ellipse have additional condition\r\n eta * eta + xi * xi = 1 (5)\r\n g1 := n DOT f1\r\n g2 := n DOT f2\r\n g3 := w - n DOT center\r\n solve system (5)/(6)\r\n g1 * xi + g2 * eta = g3 (6)\r\n */\r\n if (planeWC.normal1.isParallelTo(this.normal)) {\r\n return [];\r\n }\r\n const n = planeWC.normal1, w = planeWC.w, center = this.center, f1 = this.f1, f2 = this.f2, g1 = n.dot(f1), g2 = n.dot(f2), g3 = w - n.dot(center);\r\n return this.constructor.intersectionUnitLine(g1, g2, g3, this.tMin, this.tMax);\r\n }\r\n pointT(p) {\r\n assertVectors(p);\r\n const pLC = this.matrixInverse.transformPoint(p);\r\n return this.constructor.XYLCPointT(pLC);\r\n }\r\n containsPoint(p) {\r\n const pLC = this.matrixInverse.transformPoint(p);\r\n return (eq0(pLC.z) &&\r\n this.isValidT(this.constructor.XYLCPointT(pLC, this.tMin, this.tMax)));\r\n }\r\n isInfosWithLine(anchorWC, dirWC, tMin = this.tMin, tMax = this.tMax, lineMin = -100000, lineMax = 100000) {\r\n const anchorLC = this.matrixInverse.transformPoint(anchorWC);\r\n const dirLC = this.matrixInverse.transformVector(dirWC);\r\n if (eq0(dirLC.z)) {\r\n // local line parallel to XY-plane\r\n if (eq0(anchorLC.z)) {\r\n // local line lies in XY-plane\r\n return this.constructor.unitIsInfosWithLine(anchorLC, dirLC, anchorWC, dirWC, tMin, tMax);\r\n }\r\n }\r\n else {\r\n // if the line intersects the XY-plane in a single point, there can be an intersection there\r\n // find point, then check if distance from circle = 1\r\n const otherTAtZ0 = anchorLC.z / dirLC.z;\r\n const isp = dirLC.times(otherTAtZ0).plus(anchorLC);\r\n if (this.constructor.XYLCValid(isp)) {\r\n // point lies on unit circle\r\n return [\r\n {\r\n tThis: this.constructor.XYLCPointT(isp),\r\n tOther: otherTAtZ0,\r\n p: anchorWC.plus(dirWC.times(otherTAtZ0)),\r\n },\r\n ];\r\n }\r\n }\r\n return [];\r\n }\r\n isTsWithSurface(surface) {\r\n if (surface instanceof PlaneSurface) {\r\n return this.isTsWithPlane(surface.plane);\r\n }\r\n else if (surface instanceof EllipsoidSurface) {\r\n const isEllipses = surface.isCurvesWithPlane(this.getPlane());\r\n return isEllipses\r\n .flatMap((isEllipse) => this.isInfosWithCurve(isEllipse))\r\n .filter((info) => surface.containsPoint(info.p))\r\n .map((info) => info.tThis);\r\n }\r\n else if (surface instanceof ProjectedCurveSurface ||\r\n surface instanceof ConicSurface) {\r\n return surface\r\n .isCurvesWithPlane(this.getPlane())\r\n .flatMap((curve) => this.isInfosWithCurve(curve))\r\n .map((info) => info.tThis);\r\n }\r\n else {\r\n throw new Error();\r\n }\r\n }\r\n isInfosWithBezier(bezierWC) {\r\n const bezierLC = bezierWC.transform(this.matrixInverse);\r\n if (new PlaneSurface(P3.XY).containsCurve(bezierLC)) {\r\n return this.isInfosWithBezier2D(bezierWC);\r\n }\r\n else {\r\n const infos = mapFilter(bezierLC.isTsWithPlane(P3.XY), (tOther) => {\r\n const pLC = bezierLC.at(tOther);\r\n if (this.constructor.XYLCValid(pLC)) {\r\n return {\r\n tOther: tOther,\r\n p: bezierWC.at(tOther),\r\n tThis: this.constructor.XYLCPointT(pLC),\r\n };\r\n }\r\n return undefined;\r\n });\r\n return infos;\r\n }\r\n }\r\n isInfosWithBezier2D(bezierWC, sMin = bezierWC.tMin, sMax = bezierWC.tMax) {\r\n return Curve.ispsRecursive(this, this.tMin, this.tMax, bezierWC, sMin, sMax);\r\n }\r\n isOrthogonal() {\r\n return this.f1.isPerpendicularTo(this.f2);\r\n }\r\n at2(xi, eta) {\r\n assertNumbers(xi, eta);\r\n // center + f1 xi + f2 eta\r\n return this.center.plus(this.f1.times(xi)).plus(this.f2.times(eta));\r\n }\r\n debugInfo() {\r\n return {\r\n points: [\r\n this.center,\r\n this.at2(0.5, 0),\r\n this.at2(0, 1 / 3),\r\n this.at2(0, 2 / 3),\r\n ],\r\n lines: [this.center, this.at2(0, 1), this.center, this.at2(1, 0)],\r\n };\r\n }\r\n}\r\n/**\r\n * Transforms the unit 4d parabola\r\n * P(t) = t² (0, 1, 0, 0) + t (1, 0, 0, 0) + (0, 0, 0, 1) using m and projects\r\n * the result into 3d. This is used for the transform4 implementation of conics.\r\n * The parabola may not cross the vanishing plane of m in the interval\r\n * [tMin, tMax], as that would result in discontinuities.\r\n */\r\nexport function parabola4Projection(m, tMin, tMax) {\r\n const w1 = m.m[12];\r\n const w2 = m.m[13];\r\n const wc = m.m[15];\r\n // if the 4d parabola crosses the vanishing plane, it will lead to multiple/infinite hyperbolas, both of which we\r\n // want to avoid. Hence, we must check that the entire interval [tMin, tMax] is on one side of the vanishing plane.\r\n // Checking tMax, tMin and the extremas is enough.\r\n const extremas = solveCubicReal2(0, w2, w1, wc);\r\n const wx0 = (x) => Number.isFinite(x) ? snap0(Math.pow(x, 2) * w2 + x * w1 + wc) : sign(w2) * Infinity;\r\n if (wx0(tMin) * wx0(tMax) < 0 ||\r\n extremas.some((x) => wx0(x) * (wx0(tMin) + wx0(tMax)) < 0)) {\r\n console.log(m.str);\r\n throw new Error(\"The entire interval must be on one side of the vanishing plane. P=\" +\r\n toSource(P3.vanishingPlane(m)));\r\n }\r\n if (eq0(wc)) {\r\n // the following matrix maps a curve C onto itself, with the parameter being inverted:\r\n // C2(t) = C(-1/t). This makes C(0) a real value, which is necessary for the projection calculation.\r\n // the sign inversion is so the tangent direction does not change.\r\n // prettier-ignore\r\n const mm = new M4(-1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0);\r\n if (!eq0(w2)) {\r\n return parabola4Projection(m.times(mm), -1 / tMin, -1 / tMax);\r\n }\r\n // wc == w2 == 0 => degenerates to a line:\r\n // C(t) = (t² f2 + t f1 + c) / (t w1)\r\n // C(t) = (t f2 + f1 + c) / (t w2 + w1)\r\n // substitute t = (1/s - w1) / w2\r\n // C(s) = f2 / w2 + s (f1 - f2 w1 / w2), which is a line\r\n // we can multiply the direction vector by w2 to avoid divisions:\r\n // C(t) = f2 / w2 + s (f1 w2 - f2 w1)\r\n const f1 = m.col(0);\r\n const f2 = m.col(1);\r\n return L3.anchorDirection(f2.p3(), f1.V3().times(f2.w).minus(f2.V3().times(f1.w)));\r\n }\r\n {\r\n // ensure that the bottom-right value = 1. this does not change the 3d result.\r\n m.m[15] !== 1 && (m = m.divScalar(m.m[15]));\r\n const w2 = m.m[13];\r\n const w1 = m.m[12];\r\n const wc = m.m[15];\r\n // we want to split m into X * P, such that X is a transformation with no projective component (first three\r\n // values of the bottom row = 0), which can be handled by the usual .transform() method, and P which has only a\r\n // projective component (only the last row differs from the identity matrix). This simplifies the following\r\n // calculation. X * P = m => X * P * P^-1 = m * P^-1 => X = m * P^-1\r\n // prettier-ignore\r\n const Pinv = new M4(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -m.m[12], -m.m[13], -m.m[14], 1);\r\n const X = m.times(Pinv);\r\n // P'(t) = 0 is true for t = 0 and t1. The center is in between P(0) and P(t1), or P(t1) / 2, as P(0) = O\r\n const delta = 4 * w2 * wc - Math.pow(w1, 2);\r\n const center = new V3((-w1 * wc) / delta, (2 * Math.pow(wc, 2)) / delta, 0);\r\n // f2 is parallel to P'(0), i.e. horizontal. Solve Py(t2) = Cy = Py(t1) / 2 for t2 and simplify\r\n // f2x = Px(t2) - Cx = Px(t2) - Px(t1) / 2 to get the x-component of f2:\r\n const f2x = 1 / sqrt(abs(delta)) / wc;\r\n const f2 = new V3(f2x, 0, 0);\r\n let result;\r\n if (eq0(delta)) {\r\n result = new ParabolaCurve(V3.O, V3.X, V3.Y, tMin, tMax);\r\n }\r\n else if (0 < delta) {\r\n const tMapInv = (t) => {\r\n const wt = Math.pow(t, 2) * w2 + t * w1 + wc;\r\n const xi = 1 -\r\n (delta / 2 / Math.pow(wc, 2)) * (Number.isFinite(t) ? Math.pow(t, 2) / wt : 1 / w2);\r\n const eta = (t * 2 * Math.pow(wc, 2) - Math.pow(t, 2) * delta) / wt / 2 / Math.pow(wc, 2) -\r\n (2 * w1 * wc) / delta;\r\n const xx = acos(xi);\r\n const p = Number.isFinite(t)\r\n ? new V3(t, Math.pow(t, 2), 0).div(wt)\r\n : new V3(0, 1 / w2, 0);\r\n const pLC = M4.forSys(center.negated(), f2, V3.Z, center)\r\n .inversed()\r\n .transformPoint(p);\r\n const angle = pLC.angleXY();\r\n if (t > 0 && pLC.y < 0) {\r\n return angle + TAU;\r\n }\r\n else if (t < 0 && pLC.y > 0) {\r\n return angle - TAU;\r\n }\r\n return angle;\r\n };\r\n result = EllipseCurve.andFixTs(center, center.negated(), f2, tMapInv(tMin), tMapInv(tMax));\r\n }\r\n else {\r\n const tMapInv = (t) => sign(t) *\r\n acosh(1 -\r\n (delta / 2 / Math.pow(wc, 2)) *\r\n (Number.isFinite(t)\r\n ? Math.pow(t, 2) / (Math.pow(t, 2) * w2 + t * w1 + wc)\r\n : 1 / w2));\r\n result = new HyperbolaCurve(center, center.negated(), f2, tMapInv(tMin), tMapInv(tMax));\r\n }\r\n return result.transform(X);\r\n }\r\n}\r\n//# sourceMappingURL=XiEtaCurve.js.map","import { arrayFromFunction, arrayHashCode, arrayRange, assert, assertVectors, bisect, clamp, eq, eq0, M4, TAU, V3, withMax, } from \"ts3dutils\";\r\nimport { pushQuad } from \"tsgl\";\r\nimport { Curve, L3, PICurve } from \"../index\";\r\nimport { ceil, floor, max, min } from \"../math\";\r\nexport class ImplicitCurve extends Curve {\r\n constructor(points, tangents, dir = 1, generator, tMin = 1 == dir ? 0 : -(points.length - 1), tMax = 1 == dir ? points.length - 1 : 0) {\r\n super(tMin, tMax);\r\n this.points = points;\r\n this.tangents = tangents;\r\n this.dir = dir;\r\n this.generator = generator;\r\n assert(points.length > 2);\r\n assert(0 <= tMin && tMin <= points.length - 1, tMin, points.length);\r\n assert(0 <= tMax && tMax <= points.length - 1, tMax, points.length);\r\n }\r\n likeCurve(curve) {\r\n throw new Error(\"Method not implemented.\");\r\n }\r\n toSource(rounder = (x) => x) {\r\n return this.generator || super.toSource(rounder);\r\n }\r\n containsPoint(p) {\r\n assertVectors(p);\r\n return !isNaN(this.pointT(p));\r\n }\r\n equals(obj) {\r\n return (this == obj ||\r\n (Object.getPrototypeOf(obj) == PICurve.prototype &&\r\n this.points[0].equals(obj.points[0]) &&\r\n this.tangents[0].equals(obj.tangents[0])));\r\n }\r\n hashCode() {\r\n return arrayHashCode([this.points[0], this.tangents[0]]);\r\n }\r\n tangentP(pWC) {\r\n assertVectors(pWC);\r\n assert(this.containsPoint(pWC), \"this.containsPoint(pWC)\" + this.containsPoint(pWC));\r\n const t = this.pointT(pWC);\r\n return this.tangentAt(t);\r\n }\r\n tangentAt(t) {\r\n t = clamp(t, this.tMin, this.tMax);\r\n return V3.lerp(this.tangents[floor(t)], this.tangents[ceil(t)], t % 1);\r\n }\r\n at(t) {\r\n assert(isFinite(t));\r\n return V3.lerp(this.points[floor(t)], this.points[ceil(t)], t % 1);\r\n }\r\n getConstructorParameters() {\r\n throw new Error();\r\n }\r\n roots() {\r\n const allTs = arrayRange(0, this.points.length);\r\n return [allTs, allTs, allTs];\r\n }\r\n /**\r\n * @param mesh\r\n * @param res\r\n * @param radius default to 0. Use the shader to achieve dynamic scaling.\r\n * @param pointStep\r\n */\r\n addToMesh(mesh, res = 4, radius = 0, pointStep = 1) {\r\n const baseNormals = arrayFromFunction(res, (i) => V3.polar(1, (TAU * i) / res));\r\n const baseVertices = arrayFromFunction(res, (i) => V3.polar(radius, (TAU * i) / res));\r\n let prevTangent = V3.Z, prevMatrix = M4.IDENTITY;\r\n for (let i = 0; i < this.points.length; i += pointStep) {\r\n const start = mesh.vertices.length;\r\n if (0 !== i) {\r\n for (let j = 0; j < res; j++) {\r\n pushQuad(mesh.TRIANGLES, true, start - res + j, start + j, start - res + ((j + 1) % res), start + ((j + 1) % res));\r\n }\r\n }\r\n const point = this.points[i], tangent = this.tangents[i];\r\n const tangentMatrix = M4.rotateAB(prevTangent, tangent).times(prevMatrix);\r\n mesh.normals.push(...tangentMatrix.transformedVectors(baseNormals));\r\n const baseMatrix = M4.translate(point).times(tangentMatrix);\r\n mesh.vertices.push(...baseMatrix.transformedPoints(baseVertices));\r\n prevTangent = tangent;\r\n prevMatrix = tangentMatrix;\r\n }\r\n }\r\n rootsApprox() {\r\n const roots = [[], [], []];\r\n const points = this.points;\r\n let lastDiff = points[1].minus(points[0]);\r\n for (let i = 2; i < points.length; i++) {\r\n const diff = points[i].minus(points[i - 1]);\r\n for (let dim = 0; dim < 3; dim++) {\r\n if (Math.sign(lastDiff.e(dim)) != Math.sign(diff.e(dim))) {\r\n roots[dim].push(i);\r\n }\r\n }\r\n lastDiff = diff;\r\n }\r\n return roots;\r\n }\r\n pointT(pWC) {\r\n const startT = withMax(arrayRange(floor(this.tMin), ceil(this.tMax), 1), (t) => -pWC.distanceTo(this.points[t]));\r\n if (undefined === startT)\r\n throw new Error();\r\n if (this.points[startT].like(pWC))\r\n return startT;\r\n const a = max(0, startT - 1), b = min(this.points.length - 1, startT + 1);\r\n const tangent = this.tangentAt(startT);\r\n const f = (t) => this.at(t).to(pWC).dot(tangent);\r\n // const df = (t: number) => -this.tangentAt(clamp(t, 0, this.points.length - 1)).dot(tangent)\r\n //checkDerivate(f, df, 0, this.points.length - 2, 3)\r\n const t = bisect(f, a, b, 32);\r\n if (!isFinite(t) || !eq0(this.at(t).distanceTo(pWC))) {\r\n return NaN;\r\n }\r\n return t;\r\n }\r\n}\r\nImplicitCurve.prototype.tIncrement = 1;\r\n/**\r\n * isInfosWithLine for an ImplicitCurve defined as the intersection of two surfaces.\r\n */\r\nexport function surfaceIsICurveIsInfosWithLine(surface1, surface2, anchorWC, dirWC, tMin, tMax, lineMin, lineMax) {\r\n const line = new L3(anchorWC, dirWC.unit());\r\n const psTs = surface1.isTsForLine(line);\r\n const isTs = surface2.isTsForLine(line);\r\n const commonTs = psTs.filter((psT) => isTs.some((isT) => eq(psT, isT)));\r\n const commonTInfos = commonTs.map((t) => ({\r\n tThis: 0,\r\n tOther: t / dirWC.length(),\r\n p: line.at(t),\r\n }));\r\n const result = commonTInfos.filter((info) => this.containsPoint(info.p));\r\n result.forEach((info) => (info.tThis = this.pointT(info.p)));\r\n return result;\r\n}\r\n//# sourceMappingURL=ImplicitCurve.js.map","import { arrayFromFunction, assert, assertf, assertInst, assertNever, assertNumbers, assertVectors, between, combinations, concatenated, eq, eq0, fuzzyUniques, hasConstructor, lerp, MINUS, newtonIterate1d, newtonIterate2dWithDerivatives, NLA_PRECISION, solveCubicReal2, V, V3, withMax, } from \"ts3dutils\";\r\nimport { Curve, CylinderSurface, EllipseCurve, L3, NURBS, P3, } from \"../index\";\r\nimport { abs, cos, PI, sin } from \"../math\";\r\n/**\r\n * Bezier curve with degree 3.\r\n */\r\nexport class BezierCurve extends Curve {\r\n constructor(p0, p1, p2, p3, tMin = -0.1, tMax = 1.1) {\r\n super(tMin, tMax);\r\n assertVectors(p0, p1, p2, p3);\r\n assert(isFinite(tMin) && isFinite(tMax));\r\n //assert(!L3.throughPoints(p0, p3).containsPoint(p1) || !L3.throughPoints(p0, p3).containsPoint(p2))\r\n this.p0 = p0;\r\n this.p1 = p1;\r\n this.p2 = p2;\r\n this.p3 = p3;\r\n }\r\n get points() {\r\n return [this.p0, this.p1, this.p2, this.p3];\r\n }\r\n /**\r\n * Returns a new BezierCurve with curve.at(x) == V(x, ax³ + bx² + cx + d, 0).\r\n */\r\n static graphXY(a, b, c, d, tMin, tMax) {\r\n // d = p0y\r\n // c = -3 p0y + 3 p1y => p1y = c/3 + p0y\r\n // b = 3 p0y - 6 p1y + 3 p2y => p2y = b/3 - p0y + 2 p1y\r\n // a = -p0y + 3 p1y -3 p2y + p3y => p3y = a + p0y - 3 p1y + 3 p2y\r\n const p0y = d;\r\n const p1y = c / 3 + p0y;\r\n const p2y = b / 3 - p0y + 2 * p1y;\r\n const p3y = a + p0y - 3 * p1y + 3 * p2y;\r\n return new BezierCurve(V(0, p0y), V(1 / 3, p1y), V(2 / 3, p2y), V(1, p3y), tMin, tMax);\r\n }\r\n static quadratic(a, b, c, tMin = 0, tMax = 1) {\r\n const line = L3.throughPoints(a, c);\r\n if (line.containsPoint(b)) {\r\n return line;\r\n }\r\n else {\r\n // p1 = 1/3 a + 2/3 b\r\n // p2 = 1/3 c + 2/3 b\r\n return new BezierCurve(a, b.times(2).plus(a).div(3), b.times(2).plus(c).div(3), c, tMin, tMax);\r\n }\r\n }\r\n /**\r\n * Returns a bezier curve which approximates a CCW unit circle arc starting at V3.X of angle phi\r\n * phi <= PI / 2 is recommended\r\n *\r\n * Formula from here: https://pomax.github.io/bezierinfo/#circles_cubic\r\n */\r\n static approximateUnitArc(phi) {\r\n const f = (4 / 3) * Math.tan(phi / 4);\r\n return new BezierCurve(V3.X, new V3(1, f, 0), new V3(cos(phi) + f * sin(phi), sin(phi) - f * cos(phi), 0), V3.sphere(phi, 0), 0, 1);\r\n }\r\n getConstructorParameters() {\r\n return [this.p0, this.p1, this.p2, this.p3];\r\n }\r\n at(t) {\r\n // = s^3 p0 + 3 s^2 t p1 + 3 s t^2 p2 + t^3 p3\r\n assertNumbers(t);\r\n const p0 = this.p0, p1 = this.p1, p2 = this.p2, p3 = this.p3;\r\n const s = 1 - t, c0 = s * s * s, c1 = 3 * s * s * t, c2 = 3 * s * t * t, c3 = t * t * t;\r\n return new V3(p0.x * c0 + p1.x * c1 + p2.x * c2 + p3.x * c3, p0.y * c0 + p1.y * c1 + p2.y * c2 + p3.y * c3, p0.z * c0 + p1.z * c1 + p2.z * c2 + p3.z * c3);\r\n }\r\n /**\r\n * s := (1 - t)\r\n * at(t) := s³ p0 + 3 s² t p1 + 3 s t² p2 + t³ p3\r\n * tangent(t) := 3 s² (p1 - p0) + 6 s t (p2 - p1) + 3 t² (p3 - p2)\r\n * := 3 (1 - t)² (p1 - p0) + 6 (1 - t) t (p2 - p1) + 3 t² (p3 - p2)\r\n * := 3 (1 - 2 t + t²) (p1 - p0) + 6 (t - t²) (p2 - p1) + 3 t² (p3 - p2)\r\n * := (3 (p3 - p2) - 6 (p2 - p1) + 3 (p1 - p0)) t²*\r\n * + (-6 (p1 - p0) + (p2 - p1)) t\r\n * + 3 (p1 - p0)\r\n */\r\n tangentAt(t) {\r\n assertNumbers(t);\r\n const p0 = this.p0, p1 = this.p1, p2 = this.p2, p3 = this.p3;\r\n const s = 1 - t, c01 = 3 * s * s, c12 = 6 * s * t, c23 = 3 * t * t;\r\n return new V3((p1.x - p0.x) * c01 + (p2.x - p1.x) * c12 + (p3.x - p2.x) * c23, (p1.y - p0.y) * c01 + (p2.y - p1.y) * c12 + (p3.y - p2.y) * c23, (p1.z - p0.z) * c01 + (p2.z - p1.z) * c12 + (p3.z - p2.z) * c23);\r\n }\r\n ddt(t) {\r\n assertNumbers(t);\r\n const p0 = this.p0, p1 = this.p1, p2 = this.p2, p3 = this.p3;\r\n const c012 = 6 * (1 - t), c123 = 6 * t;\r\n return new V3((p2.x - 2 * p1.x + p0.x) * c012 + (p3.x - 2 * p2.x + p1.x) * c123, (p2.y - 2 * p1.y + p0.y) * c012 + (p3.y - 2 * p2.y + p1.y) * c123, (p2.z - 2 * p1.z + p0.z) * c012 + (p3.z - 2 * p2.z + p1.z) * c123);\r\n }\r\n normalP(t) {\r\n const tangent = this.tangentAt(t);\r\n const rot = tangent.cross(this.ddt(t));\r\n return rot.cross(tangent);\r\n }\r\n isTsWithPlane(planeWC) {\r\n assertInst(P3, planeWC);\r\n /*\r\n We are solving for t:\r\n n := plane.normal1\r\n this.at(t) DOT n == plane.w // according to plane definition\r\n (a t³ + b t² + c t + d) DOT n == plane.w // bezier curve as cubic equation\r\n (a DOT n) t³ + (b DOT n) t³ + (c DOT n) t + d DOT n - plane.w == 0 // multiply out DOT n, minus plane.w\r\n */\r\n const { p0, p1, p2, p3 } = this;\r\n const n = planeWC.normal1;\r\n const a = p1.minus(p2).times(3).minus(p0).plus(p3);\r\n const b = p0.plus(p2).times(3).minus(p1.times(6));\r\n const c = p1.minus(p0).times(3);\r\n const d = p0;\r\n return solveCubicReal2(a.dot(n), b.dot(n), c.dot(n), d.dot(n) - planeWC.w).filter((t) => between(t, this.tMin, this.tMax));\r\n }\r\n isTsWithSurface(surfaceWC) {\r\n if (surfaceWC instanceof CylinderSurface) {\r\n const projPlane = new P3(surfaceWC.dir.unit(), 0);\r\n const projThis = this.project(projPlane);\r\n const projEllipse = surfaceWC.baseCurve.project(projPlane);\r\n return projEllipse\r\n .isInfosWithBezier2D(projThis)\r\n .map((info) => info.tOther);\r\n }\r\n return super.isTsWithSurface(surfaceWC);\r\n }\r\n likeCurve(curve) {\r\n return (this == curve ||\r\n (hasConstructor(curve, BezierCurve) &&\r\n this.p0.like(curve.p0) &&\r\n this.p1.like(curve.p1) &&\r\n this.p2.like(curve.p2) &&\r\n this.p3.like(curve.p3)));\r\n }\r\n equals(obj) {\r\n return (this == obj ||\r\n (hasConstructor(obj, BezierCurve) &&\r\n this.p0.equals(obj.p0) &&\r\n this.p1.equals(obj.p1) &&\r\n this.p2.equals(obj.p2) &&\r\n this.p3.equals(obj.p3)));\r\n }\r\n hashCode() {\r\n let hashCode = 0;\r\n hashCode = hashCode * 31 + this.p0.hashCode();\r\n hashCode = hashCode * 31 + this.p1.hashCode();\r\n hashCode = hashCode * 31 + this.p2.hashCode();\r\n hashCode = hashCode * 31 + this.p3.hashCode();\r\n return hashCode | 0;\r\n }\r\n /**\r\n * Checks if this curve is colinear to the passed curve, i.e.\r\n * for every t:number there exists a s:number with this.at(t) = curve.at(s)\r\n */\r\n isColinearTo(curve) {\r\n if (this === curve || this.likeCurve(curve))\r\n return true;\r\n if (!(curve instanceof BezierCurve))\r\n return false;\r\n // first, find out where/if curve.p0 and curve.p3 are on this\r\n // then split this at curve.p0 --> curve.p3 to compare points p1 and p2\r\n let curveP0T, curveP3T;\r\n // assign in if condition to exploit short-circuit\r\n if (isNaN((curveP0T = this.pointT(curve.p0))) ||\r\n isNaN((curveP3T = this.pointT(curve.p3)))) {\r\n return false;\r\n }\r\n let thisSplit;\r\n if (eq(1, curveP0T)) {\r\n // this.split(curveP0T).right is degenerate in this case, so we need to handle it separately\r\n // this.split(curveP3T): 0 --> curveP3T --> 1\r\n // .right: curveP3T --> 1\r\n // .reversed(): 1 --> curveP3T\r\n thisSplit = this.split(curveP3T)[1].reversed();\r\n }\r\n else {\r\n // curveP3T describes the point on this\r\n // adjust it so it describes the same point on this.split(curveP0T).right\r\n // this: 0 p0t p3t 1\r\n // | | | |\r\n // this.split(curveP0T).right: 0 p3tad 1\r\n const curveP3Tadjusted = (curveP3T - curveP0T) / (1 - curveP0T);\r\n thisSplit = this.split(curveP0T)[1].split(curveP3Tadjusted)[0];\r\n }\r\n return curve.likeCurve(thisSplit);\r\n }\r\n selectPart(t0, t1) {\r\n const t1Adjusted = (t1 - t0) / (1 - t0);\r\n return this.split(t0)[1].split(t1Adjusted)[0];\r\n }\r\n reversed() {\r\n return new BezierCurve(this.p3, this.p2, this.p1, this.p0, 1 - this.tMax, 1 - this.tMin);\r\n }\r\n getCoefficients() {\r\n const { p0, p1, p2, p3 } = this;\r\n // calculate cubic equation coefficients\r\n // a t³ + b t² + c t + d = 0\r\n // multiplying out the cubic Bézier curve equation gives:\r\n // a = -p0 + 3 p1 - 3 p2 + p3\r\n // b = 3 p0 - 6 p1 + 3 p2\r\n // c = -3 p0 + 3 p1\r\n // d = p0 - p\r\n const a = p1.minus(p2).times(3).minus(p0).plus(p3);\r\n const b = p0.plus(p2).times(3).minus(p1.times(6));\r\n const c = p1.minus(p0).times(3);\r\n const d = p0;\r\n return [a, b, c, d];\r\n }\r\n tangentCoefficients() {\r\n const { p0, p1, p2, p3 } = this;\r\n const p01 = p1.minus(p0), p12 = p2.minus(p1), p23 = p3.minus(p2);\r\n const a = p01.plus(p23).times(3).minus(p12.times(6));\r\n const b = p12.minus(p01).times(6);\r\n const c = p01.times(3);\r\n return [V3.O, a, b, c];\r\n }\r\n pointT2(p, tMin = this.tMin, tMax = this.tMax) {\r\n const t = this.closestTToPoint(p, undefined, tMin, tMax);\r\n assert(this.at(t).like(p));\r\n return t;\r\n }\r\n pointT(p) {\r\n const { p0, p1, p2, p3 } = this;\r\n // calculate cubic equation coefficients\r\n // a t³ + b t² + c t + d = 0\r\n // multiplying out the cubic Bézier curve equation gives:\r\n // a = -p0 + 3 p1 - 3 p2 + p3\r\n // b = 3 p0 - 6 p1 + 3 p2\r\n // c = -3 p0 + 3 p1\r\n // d = p0 - p\r\n const a = p1.minus(p2).times(3).minus(p0).plus(p3);\r\n const b = p0.plus(p2).times(3).minus(p1.times(6));\r\n const c = p1.minus(p0).times(3);\r\n const d = p0.minus(p);\r\n // a t³ + b t² + c t + d = 0 is 3 cubic equations, some of which can be degenerate\r\n const maxDim = NLA_PRECISION < a.maxAbsElement()\r\n ? a.maxAbsDim()\r\n : NLA_PRECISION < b.maxAbsElement()\r\n ? b.maxAbsDim()\r\n : NLA_PRECISION < c.maxAbsElement()\r\n ? c.maxAbsDim()\r\n : assertNever();\r\n const results = solveCubicReal2(a.e(maxDim), b.e(maxDim), c.e(maxDim), d.e(maxDim)).filter((t) => this.at(t).like(p));\r\n if (0 == results.length)\r\n return NaN;\r\n if (1 == results.length)\r\n return results[0];\r\n throw new Error(\"multiple intersection \" + this.toString() + p.sce);\r\n }\r\n pointT3(p) {\r\n const { p0, p1, p2, p3 } = this;\r\n // calculate cubic equation coefficients\r\n // a t³ + b t² + c t + d = 0\r\n // multiplying out the cubic Bézier curve equation gives:\r\n // a = -p0 + 3 p1 - 3 p2 + p3\r\n // b = 3 p0 - 6 p1 + 3 p2\r\n // c = -3 p0 + 3 p1\r\n // d = p0 - p\r\n const a = p1.minus(p2).times(3).minus(p0).plus(p3).els();\r\n const b = p0.plus(p2).times(3).minus(p1.times(6)).els();\r\n const c = p1.minus(p0).times(3).els();\r\n const d = p0.minus(p).els();\r\n let results = undefined;\r\n // assume passed point is on curve and that curve does not self-intersect,\r\n // i.e. there is exactly one correct result for t\r\n // try to find a single result in the x-dimension, if multiple are found,\r\n // filter them by checking the other dimensions\r\n for (let dim = 0; dim < 3; dim++) {\r\n if (eq0(a[dim]) && eq0(b[dim]) && eq0(c[dim])) {\r\n // for case x:\r\n // ax == bx == cx == 0 => x(t) = dx\r\n // x value is constant\r\n // if x == 0 for all t, this does not limit the result, otherwise, there is no result, i.e\r\n // the passed point is not on the curve\r\n if (!eq0(d[dim]))\r\n return NaN;\r\n }\r\n else {\r\n const newResults = solveCubicReal2(a[dim], b[dim], c[dim], d[dim]);\r\n if (0 == newResults.length)\r\n return NaN;\r\n if (1 == newResults.length)\r\n return newResults[0];\r\n if (results) {\r\n results = results.filter((t) => newResults.some((t2) => eq(t, t2)));\r\n if (0 == results.length)\r\n return NaN;\r\n if (1 == results.length)\r\n return results[0];\r\n }\r\n else {\r\n results = newResults;\r\n }\r\n }\r\n }\r\n throw new Error(\"multiple intersection \" + results + this.toString() + p.sce);\r\n }\r\n transform(m4) {\r\n // perspective projection turn bezier curve into rational spline\r\n assert(m4.isNoProj(), m4.str);\r\n return new BezierCurve(m4.transformPoint(this.p0), m4.transformPoint(this.p1), m4.transformPoint(this.p2), m4.transformPoint(this.p3), this.tMin, this.tMax);\r\n }\r\n transform4(m4) {\r\n if (m4.isNoProj()) {\r\n return this.transform(m4);\r\n }\r\n else {\r\n return this.toNURBS().transform4(m4);\r\n }\r\n }\r\n isClosed() {\r\n return this.p0.like(this.p3);\r\n }\r\n isQuadratic() {\r\n return this.p0.lerp(this.p1, 1.5).like(this.p3.lerp(this.p2, 1.5));\r\n }\r\n debugInfo() {\r\n return {\r\n lines: [0, 1, 1, 2, 2, 3].map((i) => this.points[i]),\r\n points: this.points,\r\n };\r\n }\r\n split(t) {\r\n // do de Casteljau's algorithm at t, the resulting points are the points needed to create 2 new curves\r\n const s = 1 - t;\r\n const { p0, p1, p2, p3 } = this;\r\n /*\r\n p3 // n3\r\n b01 = s p0 + t p1\r\n b11 = s p1 + t p2\r\n b21 = s p2 + t p3 // n2\r\n b02 = s b01 + t b11\r\n b12 = s b11 + t b21 // n1\r\n b03 = s b02 + t b12 // n0\r\n \r\n c01 =\r\n */\r\n const b01 = p0.times(s).plus(p1.times(t)), b11 = p1.times(s).plus(p2.times(t)), b21 = p2.times(s).plus(p3.times(t));\r\n const b02 = b01.times(s).plus(b11.times(t)), b12 = b11.times(s).plus(b21.times(t));\r\n const b03 = b02.times(s).plus(b12.times(t));\r\n return [\r\n new BezierCurve(p0, b01, b02, b03),\r\n new BezierCurve(b03, b12, b21, p3),\r\n ];\r\n }\r\n containsPoint(p) {\r\n return isFinite(this.pointT(p));\r\n }\r\n roots() {\r\n /**\r\n * := (3 (p3 - p2) - 6 (p2 - p1) + 3 (p1 - p0)) t²*\r\n * + (-6 (p1 - p0) + 6 (p2 - p1)) t\r\n * + 3 (p1 - p0)\r\n * */\r\n const { p0, p1, p2, p3 } = this;\r\n const p01 = p1.minus(p0), p12 = p2.minus(p1), p23 = p3.minus(p2);\r\n const a = p01.plus(p23).times(3).minus(p12.times(6));\r\n const b = p12.minus(p01).times(6);\r\n const c = p01.times(3);\r\n return arrayFromFunction(3, (dim) => solveCubicReal2(0, a.e(dim), b.e(dim), c.e(dim)));\r\n }\r\n isInfosWithLine(anchorWC, dirWC, tMin, tMax, lineMin = -100000, lineMax = 100000) {\r\n // const dirLength = dirWC.length()\r\n // // TODO: no:\r\n // let result = Curve.ispsRecursive(this, this.tMin, this.tMax, new L3(anchorWC, dirWC.unit()), lineMin, lineMax)\r\n // result = fuzzyUniquesF(result, info => info.tOther)\r\n // result.forEach(info => (info.tOther /= dirLength))\r\n // return result\r\n // looking for this.at(t) == line.at(s)\r\n // this.at(t).x == anchorWC.x + dirWC.x * s\r\n // (this.at(t).x - anchorWC.x) / dirWC.x == s (analogue for y and z) (1x, 1y, 1z)\r\n // (1x) - (1y):\r\n // (this.at(t).x - anchorWC.x) / dirWC.x - (this.at(t).y - anchorWC.y) / dirWC.y == 0\r\n // (this.at(t).x - anchorWC.x) * dirWC.y - (this.at(t).y - anchorWC.y) * dirWC.x == 0 (2)\r\n // cubic equation params (see #pointT):\r\n const { p0, p1, p2, p3 } = this;\r\n const a = p1.minus(p2).times(3).minus(p0).plus(p3);\r\n const v1 = V3.UNITS[a.minAbsDim()];\r\n const testPlane = P3.forAnchorAndPlaneVectors(anchorWC, dirWC, v1.isParallelTo(dirWC) ? a : v1);\r\n return this.isTsWithPlane(testPlane)\r\n .map((tThis) => {\r\n const p = this.at(tThis);\r\n return { tThis, tOther: L3.pointT(anchorWC, dirWC, p), p };\r\n })\r\n .filter((info) => L3.containsPoint(anchorWC, dirWC, info.p));\r\n }\r\n closestPointToLine(line, tMin, tMax) {\r\n // (this(t)-line(s)) * line.dir == 0 (1)\r\n // (this(t)-line(s)) * this.tangentAt(t) == 0 (2)\r\n // this(t) * line.dir - line(s) * line.dir == 0\r\n // this(t) * line.dir - line.anchor * line.dir - s line.dir * line.dir == 0\r\n // this(t) * line.dir - line.anchor * line.dir == s (3)\r\n // insert (3) in (2)\r\n // (this(t)-line(this(t) * line.dir - line.anchor * line.dir)) * this.tangentAt(t) == 0 (4)\r\n // (4) is a 5th degree polynomial, solve numerically\r\n tMin = isFinite(tMin) ? tMin : this.tMin;\r\n tMax = isFinite(tMax) ? tMax : this.tMax;\r\n const anchorDotDir1 = line.anchor.dot(line.dir1);\r\n const f = (t) => {\r\n const atT = this.at(t);\r\n return atT\r\n .minus(line.at(atT.dot(line.dir1) - anchorDotDir1))\r\n .dot(this.tangentAt(t));\r\n };\r\n const STEPS = 32;\r\n const startT = withMax(arrayFromFunction(STEPS, (i) => tMin + ((tMax - tMin) * i) / STEPS), (t) => -f(t));\r\n return newtonIterate1d(f, startT, 8);\r\n }\r\n /**\r\n *\r\n * @param bezier\r\n * @param tMin\r\n * @param tMax\r\n * @param sMin\r\n * @param {number=} sMax\r\n * @returns\r\n */\r\n isInfosWithBezier3(bezier, tMin, tMax, sMin, sMax) {\r\n const handleStartTS = (startT, startS) => {\r\n if (!result.some((info) => eq(info.tThis, startT) && eq(info.tOther, startS))) {\r\n const f1 = (t, s) => this.tangentAt(t).dot(this.at(t).minus(bezier.at(s)));\r\n const f2 = (t, s) => bezier.tangentAt(s).dot(this.at(t).minus(bezier.at(s)));\r\n // f = (b1, b2, t1, t2) = b1.tangentAt(t1).dot(b1.at(t1).minus(b2.at(t2)))\r\n const fdt1 = (b1, b2, t1, t2) => b1.ddt(t1).dot(b1.at(t1).minus(b2.at(t2))) +\r\n b1.tangentAt(t1).squared();\r\n const fdt2 = (b1, b2, t1, t2) => -b1.tangentAt(t1).dot(b2.tangentAt(t2));\r\n const ni = newtonIterate2dWithDerivatives(f1, f2, startT, startS, 16, fdt1.bind(undefined, this, bezier), fdt2.bind(undefined, this, bezier), (t, s) => -fdt2(bezier, this, s, t), (t, s) => -fdt1(bezier, this, s, t));\r\n result.push({ tThis: ni.x, tOther: ni.y, p: this.at(ni.x) });\r\n }\r\n };\r\n tMin = undefined !== tMin ? tMin : this.tMin;\r\n tMax = undefined !== tMax ? tMax : this.tMax;\r\n sMin = undefined !== sMin ? sMin : bezier.tMin;\r\n sMax = undefined !== sMax ? sMax : bezier.tMax;\r\n // stack of indices:\r\n const indices = [tMin, tMax, sMin, sMax];\r\n const result = [];\r\n while (indices.length) {\r\n const i = indices.length - 4;\r\n const tMin = indices[i], tMax = indices[i + 1], sMin = indices[i + 2], sMax = indices[i + 3];\r\n indices.length -= 4;\r\n const thisAABB = this.getAABB(tMin, tMax);\r\n const otherAABB = bezier.getAABB(sMin, sMax);\r\n // console.log(tMin, tMax, sMin, sMax, thisAABB.sce, otherAABB.sce)\r\n if (thisAABB && otherAABB && thisAABB.intersectsAABB2d(otherAABB)) {\r\n const tMid = (tMin + tMax) / 2;\r\n const sMid = (sMin + sMax) / 2;\r\n const EPS = 0.00001;\r\n if (tMax - tMin < EPS || sMax - sMin < EPS) {\r\n console.log(tMin, tMax, sMin, sMax);\r\n console.log(thisAABB.sce);\r\n console.log(otherAABB.sce);\r\n console.log(tMid, sMid);\r\n handleStartTS(tMid, sMid);\r\n }\r\n else {\r\n indices.push(tMin, tMid, sMin, sMid, tMin, tMid, sMid, sMax, tMid, tMax, sMin, sMid, tMid, tMax, sMid, sMax);\r\n }\r\n }\r\n }\r\n return result;\r\n }\r\n isInfosWithBezier(bezier, tMin, tMax, sMin, sMax) {\r\n tMin = undefined !== tMin ? tMin : this.tMin;\r\n tMax = undefined !== tMax ? tMax : this.tMax;\r\n sMin = undefined !== sMin ? sMin : bezier.tMin;\r\n sMax = undefined !== sMax ? sMax : bezier.tMax;\r\n assertf(() => tMin < tMax);\r\n assertf(() => sMin < sMax);\r\n const result = [];\r\n const likeCurves = this.likeCurve(bezier), colinearCurves = this.isColinearTo(bezier);\r\n if (likeCurves || colinearCurves) {\r\n if (!likeCurves) {\r\n // only colinear\r\n // recalculate sMin and sMax so they are valid on this, from then on we can ignore bezier\r\n sMin = this.pointT(bezier.at(sMin));\r\n sMax = this.pointT(bezier.at(sMax));\r\n }\r\n tMin = Math.min(tMin, sMin);\r\n tMax = Math.max(tMax, sMax);\r\n const splits = fuzzyUniques(concatenated(this.roots()).filter(isFinite).concat([tMin, tMax])).sort(MINUS);\r\n //const aabbs = arrayFromFunction(splits.length - 1, i => this.getAABB(splits[i], splits[i + 1]))\r\n Array.from(combinations(splits.length - 1)).forEach(({ i, j }) => {\r\n // adjacent curves can't intersect\r\n if (Math.abs(i - j) > 2) {\r\n // console.log(splits[i], splits[i + 1], splits[j], splits[j + 1], aabbs[i], aabbs[j])\r\n //findRecursive(splits[i], splits[i + 1], splits[j], splits[j + 1], aabbs[i], aabbs[j])\r\n result.push(...Curve.ispsRecursive(this, splits[i], splits[i + 1], bezier, splits[j], splits[j + 1]));\r\n }\r\n });\r\n }\r\n else {\r\n return Curve.ispsRecursive(this, tMin, tMax, bezier, sMin, sMax);\r\n }\r\n return result;\r\n }\r\n selfIntersectionsInfo() {\r\n return this.isInfosWithBezier(this);\r\n }\r\n isInfosWithCurve(curve) {\r\n if (curve instanceof L3) {\r\n return this.isInfosWithLine(curve.anchor, curve.dir1, curve.tMin, curve.tMax);\r\n }\r\n if (curve instanceof BezierCurve) {\r\n return this.isInfosWithBezier(curve);\r\n }\r\n return curve\r\n .isInfosWithCurve(this)\r\n .map(({ tThis, tOther, p }) => ({ tThis: tOther, tOther: tThis, p }));\r\n }\r\n /**\r\n * Approximate this bezier curve with a number of circular segments. This curve is recursively split in half until\r\n * segments are close enough (relative error < REL_ERR in two test points) to an arc which goes through the start,\r\n * end and mid points of the segment.\r\n * @returns each EllipseCurve is circular and their tMin and tMax respectively define their start and end points.\r\n * @param t0 Start parameter of segment which should be approximated.\r\n * @param t1 End parameter of segment which should be approximated.\r\n * @param REL_ERROR max allowable relative error.\r\n * @param result Resulting circle arcs are stored in this array. Mainly used by the recursion.\r\n */\r\n circleApprox(t0 = this.tMin, t1 = this.tMax, REL_ERROR = 1 / 1024, result = []) {\r\n const a = this.at(t0), b = this.at(t1), tMid = (t0 + t1) / 2, pMid = this.at(tMid), abLine = L3.throughPoints(a, b);\r\n if (!abLine.containsPoint(pMid) &&\r\n between(abLine.pointT(pMid), 0, abLine.pointT(b))) {\r\n const arc = EllipseCurve.circleThroughPoints(a, pMid, b), arcRadius = arc.f1.length(), pTest1 = this.at(lerp(t0, t1, 0.25)), pTest2 = this.at(lerp(t0, t1, 0.75));\r\n if (abs(arc.center.distanceTo(pTest1) / arcRadius - 1) <= REL_ERROR &&\r\n abs(arc.center.distanceTo(pTest2) / arcRadius - 1) <= REL_ERROR) {\r\n result.push(arc);\r\n return result;\r\n }\r\n }\r\n this.circleApprox(t0, tMid, REL_ERROR, result);\r\n this.circleApprox(tMid, t1, REL_ERROR, result);\r\n return result;\r\n }\r\n toNURBS() {\r\n return NURBS.fromBezier(this);\r\n }\r\n}\r\n/**\r\n * https://en.wikipedia.org/wiki/Cubic_function#/media/File:Graph_of_cubic_polynomial.svg\r\n */\r\nBezierCurve.EX2D = BezierCurve.graphXY(2, -3, -3, 2);\r\nBezierCurve.EX3D = new BezierCurve(V3.O, V(-0.1, -1, 1), V(1.1, 1, 1), V3.X);\r\nBezierCurve.QUARTER_CIRCLE = BezierCurve.approximateUnitArc(PI / 2);\r\nBezierCurve.prototype.hlol = Curve.hlol++;\r\nBezierCurve.prototype.tIncrement = 1 / 80;\r\n//# sourceMappingURL=BezierCurve.js.map","import { arrayFromFunction, assertNumbers, eq, eq0, hasConstructor, le, M4, snap0, V3, } from \"ts3dutils\";\r\nimport { intersectionUnitHyperbolaLine, parabola4Projection, XiEtaCurve, } from \"../index\";\r\nimport { abs, cosh, min, PI, sign, sqrt } from \"../math\";\r\n/**\r\n * x² - y² = 1\r\n * C(t) = center + f1 * cosh(t) + f2 * sinh(t)\r\n */\r\nexport class HyperbolaCurve extends XiEtaCurve {\r\n constructor(center, f1, f2, tMin = -7, tMax = 7) {\r\n super(center, f1, f2, tMin, tMax);\r\n }\r\n static XYLCValid(pLC) {\r\n return pLC.x > 0 && eq(1, pLC.x * pLC.x - pLC.y * pLC.y);\r\n }\r\n static XYLCPointT(pLC) {\r\n return Math.asinh(pLC.y);\r\n }\r\n /**\r\n * http://www.wolframalpha.com/input/?i=x%C2%BRep-y%C2%BRep%3D1,ax%2Bby%3Dc\r\n * Minor empiric test shows asinh(eta) consistently gets more accurate results than atanh(eta/xi)\r\n */\r\n static intersectionUnitLine(a, b, c) {\r\n if (eq0(b)) {\r\n const sqrtVal = snap0(Math.pow(c, 2) / Math.pow(a, 2) - 1);\r\n if (sqrtVal < 0 || c * a < 0) {\r\n return [];\r\n }\r\n else if (sqrtVal == 0) {\r\n return [0];\r\n }\r\n const eta1 = Math.sqrt(sqrtVal);\r\n return [-Math.asinh(eta1), Math.asinh(eta1)];\r\n }\r\n else if (eq(abs(a), abs(b))) {\r\n if (le(c * a, 0)) {\r\n return [];\r\n }\r\n const eta = (sign(a * b) * (Math.pow(c, 2) - Math.pow(a, 2))) / 2 / a / c;\r\n return [Math.asinh(eta)];\r\n }\r\n else {\r\n const sqrtVal = snap0(Math.pow(b, 2) * (-(Math.pow(a, 2)) + Math.pow(b, 2) + Math.pow(c, 2)));\r\n if (sqrtVal < 0) {\r\n return [];\r\n }\r\n const xi1 = (a * c - Math.sqrt(sqrtVal)) / (Math.pow(a, 2) - Math.pow(b, 2));\r\n const xi2 = (a * c + Math.sqrt(sqrtVal)) / (Math.pow(a, 2) - Math.pow(b, 2));\r\n const eta1 = (Math.pow(b, 2) * c - a * Math.sqrt(sqrtVal)) / (b * (Math.pow(b, 2) - Math.pow(a, 2)));\r\n const eta2 = (Math.pow(b, 2) * c + a * Math.sqrt(sqrtVal)) / (b * (Math.pow(b, 2) - Math.pow(a, 2)));\r\n return [xi1 > 0 && Math.asinh(eta1), xi2 > 0 && Math.asinh(eta2)].filter((x) => x !== false);\r\n }\r\n }\r\n at(t) {\r\n assertNumbers(t);\r\n // = center + f1 cosh t + f2 sinh t\r\n return this.center\r\n .plus(this.f1.times(Math.cosh(t)))\r\n .plus(this.f2.times(Math.sinh(t)));\r\n }\r\n toString() {\r\n return `${this.center} + ${this.f1} * cosh(t) + ${this.f2} * sinh(t)`;\r\n }\r\n tangentAt(t) {\r\n assertNumbers(t);\r\n // = f1 sinh t + f2 cosh t\r\n return this.f1.times(Math.sinh(t)).plus(this.f2.times(Math.cosh(t)));\r\n }\r\n tangentAt2(xi, eta) {\r\n assertNumbers(xi, eta);\r\n // = f1 eta + f2 xi\r\n return this.f1.times(eta).plus(this.f2.times(xi));\r\n }\r\n ddt(t) {\r\n assertNumbers(t);\r\n return this.f1.times(Math.cosh(t)).plus(this.f2.times(Math.sinh(t)));\r\n }\r\n isColinearTo(curve) {\r\n if (!hasConstructor(curve, HyperbolaCurve))\r\n return false;\r\n if (!curve.center || !this.center.like(curve.center)) {\r\n return false;\r\n }\r\n if (this === curve) {\r\n return true;\r\n }\r\n const { f1: f1, f2: f2 } = this.rightAngled(), { f1: c1, f2: c2 } = curve.rightAngled();\r\n return (eq(f1.squared(), Math.abs(f1.dot(c1))) &&\r\n eq(f2.squared(), Math.abs(f2.dot(c2))));\r\n }\r\n reversed() {\r\n return new HyperbolaCurve(this.center, this.f1, this.f2.negated(), -this.tMax, -this.tMin);\r\n }\r\n rightAngled() {\r\n const f1 = this.f1, f2 = this.f2, a = f1.dot(f2), b = f2.squared() + f1.squared();\r\n if (eq0(a)) {\r\n return this;\r\n }\r\n const g1 = 2 * a, g2 = b + Math.sqrt(b * b - 4 * a * a);\r\n const { x1: xi, y1: eta } = intersectionUnitHyperbolaLine(g1, g2, 0);\r\n return new HyperbolaCurve(this.center, f1.times(xi).plus(f2.times(eta)), f1.times(eta).plus(f2.times(xi)));\r\n }\r\n eccentricity() {\r\n const mainAxes = this.rightAngled();\r\n const f1length = mainAxes.f1.length(), f2length = mainAxes.f1.length();\r\n const [a, b] = f1length > f2length ? [f1length, f2length] : [f2length, f1length];\r\n return Math.sqrt(1 + (b * b) / a / a);\r\n }\r\n roots() {\r\n // tangent(t) = f1 sinh t + f2 cosh t = 0\r\n // tangentAt2(xi, eta) = f1 eta + f2 xi = V3.O\r\n // xi² - eta² = 1 (by def for hyperbola)\r\n return arrayFromFunction(3, (dim) => {\r\n const a = this.f2.e(dim), b = this.f1.e(dim);\r\n return HyperbolaCurve.intersectionUnitLine(a, b, 0);\r\n });\r\n }\r\n transform4(m4) {\r\n const tMap = (t) => sign(t) * min(10, sqrt(-(1 - cosh(t)) / (1 + cosh(t))));\r\n // prettier-ignore\r\n const parabolaToUnitHyperbola = new M4(0, 1, 0, 1, 2, 0, 0, 0, 0, 0, 1, 0, 0, -1, 0, 1);\r\n return parabola4Projection(M4.product(m4, this.matrix, parabolaToUnitHyperbola), tMap(this.tMin), tMap(this.tMax));\r\n }\r\n}\r\nHyperbolaCurve.XY = new HyperbolaCurve(V3.O, V3.X, V3.Y);\r\nHyperbolaCurve.prototype.tIncrement = PI / 16;\r\n//# sourceMappingURL=HyperbolaCurve.js.map","import { assert, assertf, assertInst, assertNumbers, assertVectors, clamp, eq, eq0, hasConstructor, le, lt, V3, VV, } from \"ts3dutils\";\r\nimport { Curve, P3 } from \"../index\";\r\n/**\r\n * A 3-dimensional line. Defined by an anchor and a normalized direction vector.\r\n */\r\nexport class L3 extends Curve {\r\n constructor(anchor, // line anchor\r\n dir1, // normalized line dir\r\n tMin = -4096, tMax = 4096) {\r\n super(tMin, tMax);\r\n this.anchor = anchor;\r\n this.dir1 = dir1;\r\n assertVectors(anchor, dir1);\r\n assert(dir1.hasLength(1), \"dir must be unit\" + dir1);\r\n assertf(() => !Number.isNaN(anchor.x));\r\n }\r\n isTsWithSurface(surface) {\r\n return surface.isTsForLine(this);\r\n }\r\n static throughPoints(anchor, b, tMin = 0, tMax) {\r\n const dir = b.minus(anchor);\r\n return new L3(anchor, dir.unit(), tMin, undefined !== tMax ? tMax : dir.length());\r\n }\r\n static anchorDirection(anchor, dir, min = 0, max = dir.length()) {\r\n const dir1 = dir.unit();\r\n return new L3(anchor, dir1, \"number\" == typeof min ? min : min.minus(anchor).dot(dir1), \"number\" == typeof max ? max : max.minus(anchor).dot(dir1));\r\n }\r\n static pointT(anchor, dir, x) {\r\n assertVectors(anchor, dir, x);\r\n return x.minus(anchor).dot(dir) / dir.squared();\r\n }\r\n static at(anchor, dir, t) {\r\n return anchor.plus(dir.times(t));\r\n }\r\n /**\r\n * Create new line which is the intersection of two planes. Throws error if planes are parallel.\r\n * @param plane1\r\n * @param plane2\r\n */\r\n static fromPlanes(plane1, plane2) {\r\n assertInst(P3, plane1, plane2);\r\n const dir = plane1.normal1.cross(plane2.normal1);\r\n const length = dir.length();\r\n if (length < 1e-10) {\r\n throw new Error(\"Parallel planes\");\r\n }\r\n return plane1.intersectionWithPlane(plane2);\r\n }\r\n static containsPoint(anchor, dir, p) {\r\n const closestT = L3.pointT(anchor, dir, p);\r\n const distance = L3.at(anchor, dir, closestT).distanceTo(p);\r\n return eq0(distance);\r\n }\r\n roots() {\r\n return [[], [], []];\r\n }\r\n containsPoint(p) {\r\n assertVectors(p);\r\n const dist = this.distanceToPoint(p);\r\n assertNumbers(dist);\r\n return eq0(dist);\r\n }\r\n likeCurve(curve) {\r\n return (this == curve ||\r\n (hasConstructor(curve, L3) &&\r\n this.anchor.like(curve.anchor) &&\r\n this.dir1.like(curve.dir1)));\r\n }\r\n equals(obj) {\r\n return (this == obj ||\r\n (Object.getPrototypeOf(obj) == L3.prototype &&\r\n this.anchor.equals(obj.anchor) &&\r\n this.dir1.equals(obj.dir1)));\r\n }\r\n isColinearTo(obj) {\r\n return (obj instanceof L3 &&\r\n this.containsPoint(obj.anchor) &&\r\n eq(1, Math.abs(this.dir1.dot(obj.dir1))));\r\n }\r\n distanceToLine(line) {\r\n assertInst(L3, line);\r\n if (this.isParallelToLine(line)) {\r\n return this.distanceToPoint(line.anchor);\r\n }\r\n const dirCross1 = this.dir1.cross(line.dir1).unit();\r\n const anchorDiff = this.anchor.minus(line.anchor);\r\n return Math.abs(anchorDiff.dot(dirCross1));\r\n }\r\n distanceToPoint(x) {\r\n assertVectors(x);\r\n // See http://mathworld.wolfram.com/Point-LineDistance3-Dimensional.html\r\n const t = x.minus(this.anchor).dot(this.dir1);\r\n return this.at(t).distanceTo(x);\r\n //return x.minus(this.anchor).cross(x.minus(this.anchor.plus(this.dir1))).length()\r\n }\r\n asSegmentDistanceToPoint(x, sStart, sEnd) {\r\n let t = x.minus(this.anchor).dot(this.dir1);\r\n t = clamp(t, sStart, sEnd);\r\n return this.at(t).minus(x).length();\r\n }\r\n asSegmentDistanceToLine(line, sStart, sEnd) {\r\n assertInst(L3, line);\r\n const dirCross = this.dir1.cross(line.dir1);\r\n const div = dirCross.squared();\r\n if (eq0(div)) {\r\n return undefined;\r\n } // lines parallel\r\n const anchorDiff = line.anchor.minus(this.anchor);\r\n // check if distance is zero (see also L3.distanceToLine)\r\n if (!eq0(anchorDiff.dot(dirCross.unit()))) {\r\n return undefined;\r\n }\r\n let t = this.infoClosestToLine(line).t;\r\n t = clamp(t, sStart, sEnd);\r\n return this.at(clamp(t, sStart, sEnd));\r\n }\r\n at(t) {\r\n assertNumbers(t);\r\n return this.anchor.plus(this.dir1.times(t));\r\n }\r\n /**\r\n * This function returns lambda for a given point x\r\n *\r\n * Every point x on this line is described by the equation\r\n * x = this.anchor + lambda * this.dir1 | - this.anchor\r\n * x - this.anchor = lambda * this.dir1 | DOT this.dir1\r\n * (x - this.anchor) DOT this.dir1 = lambda (dir1² is 1 as |dir1| == 1)\r\n *\r\n * @param x\r\n * @returns\r\n */\r\n pointT(x) {\r\n assertVectors(x);\r\n const t = x.minus(this.anchor).dot(this.dir1);\r\n return t;\r\n }\r\n /**\r\n * Returns true if the line is parallel (this.dir = line.dir || this.dir = -line.dir) to the argument.\r\n */\r\n isParallelToLine(line) {\r\n assertInst(L3, line);\r\n // we know that 1 == this.dir1.length() == line.dir1.length(), we can check for parallelity simpler than\r\n // isParallelTo()\r\n return eq(1, Math.abs(this.dir1.dot(line.dir1)));\r\n }\r\n angleToLine(line) {\r\n assertInst(L3, line);\r\n return this.dir1.angleTo(line.dir1);\r\n }\r\n /**\r\n *\r\n * @param line\r\n * @returns {boolean} If the distance between the lines is zero\r\n */\r\n intersectsLine(line) {\r\n return eq0(this.distanceToLine(line));\r\n }\r\n isInfosWithCurve(curve) {\r\n if (curve instanceof L3) {\r\n return this.isInfosWithLine(curve.anchor, curve.dir1);\r\n }\r\n return super.isInfosWithCurve(curve);\r\n }\r\n isInfosWithLine(anchorWC, dirWC) {\r\n const dirCross = this.dir1.cross(dirWC);\r\n const div = dirCross.squared();\r\n if (eq0(div)) {\r\n // lines are parallel\r\n return [];\r\n }\r\n const anchorDiff = anchorWC.minus(this.anchor);\r\n if (eq0(anchorDiff.dot(dirCross))) {\r\n const tThis = anchorDiff.cross(dirWC).dot(dirCross) / div;\r\n const tOther = anchorDiff.cross(this.dir1).dot(dirCross) / div;\r\n const p = this.at(tThis);\r\n return [{ tThis: tThis, tOther: tOther, p: p }];\r\n }\r\n return [];\r\n }\r\n isInfoWithLine(line) {\r\n // todo infos?\r\n assertInst(L3, line);\r\n const dirCross = this.dir1.cross(line.dir1);\r\n const div = dirCross.squared();\r\n if (eq0(div)) {\r\n return undefined;\r\n } // lines parallel\r\n const anchorDiff = line.anchor.minus(this.anchor);\r\n // check if distance is zero (see also L3.distanceToLine)\r\n if (!eq0(anchorDiff.dot(dirCross.unit()))) {\r\n return undefined;\r\n }\r\n const t = anchorDiff.cross(line.dir1).dot(dirCross) / div;\r\n return this.at(t);\r\n }\r\n /**\r\n * returns s and t with this.at(s) == line.at(t)\r\n */\r\n intersectionLineST(line) {\r\n // the two points on two lines the closest two each other are the ones whose\r\n // connecting\r\n // TODO Where does this come from?\r\n // TODO: return value when no IS?\r\n assertInst(L3, line);\r\n const dirCross = this.dir1.cross(line.dir1);\r\n const div = dirCross.squared();\r\n const anchorDiff = line.anchor.minus(this.anchor);\r\n const s = anchorDiff.cross(this.dir1).dot(dirCross) / div;\r\n const t = anchorDiff.cross(line.dir1).dot(dirCross) / div;\r\n return { s: s, t: t };\r\n // console.log(segmentIntersectsRay, a, b, \"ab\", ab, \"p\", p, \"dir\", dir, s > 0 && t / div >= 0 && t / div <= 1,\r\n // \"s\", s, \"t\", t, \"div\", div)\r\n }\r\n ddt() {\r\n return V3.O;\r\n }\r\n getConstructorParameters() {\r\n return [this.anchor, this.dir1];\r\n }\r\n closestTToPoint(p) {\r\n // similar logic as pointT; we project the vector (anchor -> p) onto dir1, then add anchor back to it\r\n const nearestT = p.minus(this.anchor).dot(this.dir1);\r\n return nearestT;\r\n }\r\n infoClosestToLine(line) {\r\n /*\r\n line = a + s*b\r\n this = c + t*d\r\n \r\n (this - line) * b = 0\r\n (this - line) * d = 0\r\n \r\n (a + s*b - c - t*d) * b = 0\r\n (a + s*b - c - t*d) * d = 0\r\n \r\n (a - c + s*b - t*d) * b = 0\r\n (a - c + s*b - t*d) * d = 0\r\n \r\n (a - c)*b + (s*b - t*d)*b = 0\r\n (a - c)*d + (s*b - t*d)*d = 0\r\n \r\n (a - c)*b + s*(b*b) - t*(d*b) = 0\r\n (a - c)*d + s*(b*d) - t*(d*d) = 0\r\n \r\n s = (t*(d*b) - (a - c)*b) / (b*b)\r\n =>\r\n (a - c)*d + (t*(d*b) - (a - c)*b) / (b*b)*(b*d) - t*(d*d) = 0 | * (b*b)\r\n (a - c)*d * (b*b) + (t*(d*b) - (a - c)*b)*(b*d) - t*(d*d) * (b*b) = 0\r\n (a - c)*d * (b*b) + t*(d*b)*(b*d) - (a - c)*b*(b*d) - t*(d*d) * (b*b) = 0\r\n t = ((a - c)*b*(b*d) - (a - c)*d * (b*b)) / ((d*b)*(b*d) - (d*d) * (b*b))\r\n */\r\n if (this.isParallelToLine(line)) {\r\n return { t: NaN, s: NaN, distance: this.distanceToLine(line) };\r\n }\r\n const a = line.anchor, b = line.dir1, c = this.anchor, d = this.dir1;\r\n const bd = b.dot(d), bb = b.squared(), dd = d.squared(), ca = a.minus(c), divisor = bd * bd - dd * bb;\r\n const t = (ca.dot(b) * bd - ca.dot(d) * bb) / divisor;\r\n const s = (ca.dot(b) * dd - ca.dot(d) * bd) / divisor;\r\n return {\r\n t: t,\r\n s: s,\r\n closest: this.at(t),\r\n closest2: line.at(s),\r\n distance: this.at(t).distanceTo(line.at(s)),\r\n };\r\n }\r\n intersectionWithPlane(plane) {\r\n // plane: plane.normal1 * p = plane.w\r\n // line: p=line.point + lambda * line.dir1\r\n const lambda = (plane.w - plane.normal1.dot(this.anchor)) / plane.normal1.dot(this.dir1);\r\n const point = this.anchor.plus(this.dir1.times(lambda));\r\n return point;\r\n }\r\n tangentAt() {\r\n return this.dir1;\r\n }\r\n isTWithPlane(plane) {\r\n // plane: plane.normal1 * p = plane.w\r\n // line: p=line.point + lambda * line.dir1\r\n const div = plane.normal1.dot(this.dir1);\r\n if (eq0(div))\r\n return NaN;\r\n const lambda = (plane.w - plane.normal1.dot(this.anchor)) / div;\r\n return lambda;\r\n }\r\n reversed() {\r\n return new L3(this.anchor, this.dir1.negated(), -this.tMax, -this.tMin);\r\n }\r\n isTsWithPlane(planeWC) {\r\n const t = this.isTWithPlane(planeWC);\r\n return isNaN(t) ? [] : [t];\r\n }\r\n flipped() {\r\n return new L3(this.anchor, this.dir1.negated());\r\n }\r\n transform(m4) {\r\n const newAnchor = m4.transformPoint(this.anchor);\r\n const newDir = m4.transformVector(this.dir1);\r\n return new L3(newAnchor, newDir.unit(), this.tMin * newDir.length(), this.tMax * newDir.length());\r\n }\r\n transform4(m4) {\r\n const vanishingPlane = P3.vanishingPlane(m4);\r\n if (!vanishingPlane)\r\n return this.transform(m4);\r\n const pMin = this.at(this.tMin);\r\n const pMax = this.at(this.tMax);\r\n if (le(vanishingPlane.distanceToPointSigned(pMin), 0) ||\r\n le(vanishingPlane.distanceToPointSigned(pMax), 0)) {\r\n throw new Error(\"line must be in front of vanishingPlane in [tMin, tMax]\");\r\n }\r\n const anchor = lt(0, vanishingPlane.distanceToPointSigned(this.anchor))\r\n ? this.anchor\r\n : this.at((this.tMin + this.tMax) / 2);\r\n const transformedAnchor = m4.timesVector(VV(anchor.x, anchor.y, anchor.z, 1));\r\n const transformedVector = m4.timesVector(VV(this.dir1.x, this.dir1.y, this.dir1.z, 0));\r\n const newDir = transformedVector\r\n .times(transformedAnchor.w)\r\n .minus(transformedAnchor.times(transformedVector.w))\r\n .V3();\r\n const newAnchor = transformedAnchor.p3();\r\n return L3.anchorDirection(newAnchor, newDir, m4.transformPoint(pMin), m4.transformPoint(pMax));\r\n }\r\n hashCode() {\r\n return this.anchor.hashCode() * 31 + this.dir1.hashCode();\r\n }\r\n}\r\nL3.X = new L3(V3.O, V3.X);\r\nL3.Y = new L3(V3.O, V3.Y);\r\nL3.Z = new L3(V3.O, V3.Z);\r\nL3.prototype.hlol = Curve.hlol++;\r\nL3.prototype.tIncrement = 256;\r\n//# sourceMappingURL=L3.js.map","import { arrayRange, assert, assertVectors, bisect, callsce, clamp, fuzzyUniques, getLast, M4, newtonIterate2dWithDerivatives, V3, withMax, } from \"ts3dutils\";\r\nimport { curvePoint, EllipsoidSurface, followAlgorithm2d, ImplicitCurve, ImplicitSurface, MathFunctionR2R, PlaneSurface, ProjectedCurveSurface, surfaceIsICurveIsInfosWithLine, } from \"../index\";\r\nimport { abs, ceil, floor, max, min } from \"../math\";\r\nexport class PICurve extends ImplicitCurve {\r\n constructor(points, tangents, parametricSurface, implicitSurface, pmPoints, pmTangents, stepSize, dir = 1, generator, tMin, tMax) {\r\n super(points, tangents, dir, generator, tMin, tMax);\r\n this.parametricSurface = parametricSurface;\r\n this.implicitSurface = implicitSurface;\r\n this.pmPoints = pmPoints;\r\n this.pmTangents = pmTangents;\r\n this.stepSize = stepSize;\r\n assert(Array.isArray(pmPoints));\r\n assert(dir == 1);\r\n assert(stepSize <= 1);\r\n const pf = parametricSurface.pUVFunc();\r\n const dpdu = parametricSurface.dpdu();\r\n const dpdv = parametricSurface.dpdv();\r\n const didp = implicitSurface.didp.bind(implicitSurface);\r\n this.didu = (u, v) => didp(pf(u, v)).dot(dpdu(u, v));\r\n this.didv = (u, v) => didp(pf(u, v)).dot(dpdv(u, v));\r\n for (let i = 0; i < points.length - 1; i++) {\r\n assert(!points[i].equals(points[i + 1]));\r\n //assert(parametricSurface.pUV(pmPoints[i].x, pmPoints[i].y).equals(points[i]))\r\n }\r\n {\r\n const ps = this.parametricSurface;\r\n const is = implicitSurface;\r\n const pFunc = ps.pUVFunc(), iFunc = is.implicitFunction();\r\n const dpdu = ps.dpdu();\r\n const dpdv = ps.dpdv();\r\n const didp = is.didp.bind(is);\r\n const mf = MathFunctionR2R.forFFxFy((x, y) => iFunc(pFunc(x, y)), (u, v) => didp(pFunc(u, v)).dot(dpdu(u, v)), (u, v) => didp(pFunc(u, v)).dot(dpdv(u, v)));\r\n const { points } = followAlgorithm2d(mf, this.pmPoints[0], stepSize, ps, (u, v) => is.containsPoint(pFunc(u, v)), getLast(this.pmPoints), this.pmTangents[0]);\r\n if (points.length !== this.points.length) {\r\n followAlgorithm2d(mf, this.pmPoints[0], stepSize, ps, (u, v) => is.containsPoint(pFunc(u, v)), getLast(this.pmPoints), this.pmTangents[0]);\r\n }\r\n assert(points.length == this.points.length, points.length, this.points.length);\r\n }\r\n }\r\n static forParametricStartEnd(ps, is, pmStart, pmEnd, stepSize = 0.02, startPMTangent, tMin, tMax) {\r\n const pFunc = ps.pUVFunc(), iFunc = is.implicitFunction();\r\n const dpdu = ps.dpdu();\r\n const dpdv = ps.dpdv();\r\n const didp = is.didp.bind(is);\r\n const mf = MathFunctionR2R.forFFxFy((x, y) => iFunc(pFunc(x, y)), (u, v) => didp(pFunc(u, v)).dot(dpdu(u, v)), (u, v) => didp(pFunc(u, v)).dot(dpdv(u, v)));\r\n const { points, tangents } = followAlgorithm2d(mf, pmStart, stepSize, ps, (u, v) => is.containsPoint(pFunc(u, v)), pmEnd, startPMTangent);\r\n return PICurve.forParametricPointsTangents(ps, is, points, tangents, stepSize, 1, tMin, tMax);\r\n }\r\n static forStartEnd(ps, is, start, end, stepSize = 0.02, startTangent, min, max) {\r\n const startPM = ps.uvP(start);\r\n const dpdu = ps.dpdu()(startPM.x, startPM.y), dpdv = ps.dpdv()(startPM.x, startPM.y);\r\n const startPMTangent = startTangent &&\r\n M4.forSys(dpdu, dpdv).inversed().transformVector(startTangent);\r\n // assert(dpdu.times(startPMTangent.x).plus(dpdv.times(startPMTangent.y)).like(startTangent))\r\n const curve = PICurve.forParametricStartEnd(ps, is, startPM, ps.uvP(end), stepSize, startPMTangent);\r\n return curve.withBounds(min && curve.pointT(min), max && curve.pointT(max));\r\n }\r\n static forParametricPointsTangents(ps, is, pmPoints, pmTangents, stepSize, dir = 1, tMin, tMax) {\r\n const pFunc = ps.pUVFunc(), dpdu = ps.dpdu();\r\n const dpdv = ps.dpdv();\r\n const points = pmPoints.map(({ x, y }) => pFunc(x, y));\r\n const tangents = pmPoints.map(({ x: u, y: v }, i) => {\r\n const ds = dpdu(u, v);\r\n const dt = dpdv(u, v);\r\n return ds.times(pmTangents[i].x).plus(dt.times(pmTangents[i].y));\r\n //const p = points[i]\r\n //return cs.normalP(p).cross(ses.normalP(p))\r\n //\t.toLength(ds.times(pmTangents[i].x).plus(dt.times(pmTangents[i].y)).length())\r\n });\r\n return new PICurve(points, tangents, ps, is, pmPoints, pmTangents, stepSize, dir, undefined, tMin, tMax);\r\n }\r\n getConstructorParameters() {\r\n return [\r\n this.points,\r\n this.tangents,\r\n this.parametricSurface,\r\n this.implicitSurface,\r\n this.pmPoints,\r\n this.pmTangents,\r\n this.stepSize,\r\n this.dir,\r\n this.generator,\r\n ];\r\n }\r\n implicitCurve() {\r\n const pF = this.parametricSurface.pUVFunc();\r\n const iF = this.implicitSurface.implicitFunction();\r\n return (u, v) => iF(pF(u, v));\r\n }\r\n isColinearTo(curve) {\r\n if (curve instanceof PICurve) {\r\n if (this.equals(curve)) {\r\n return true;\r\n }\r\n if (this.parametricSurface.isCoplanarTo(curve.parametricSurface) &&\r\n this.implicitSurface.isCoplanarTo(curve.implicitSurface)) {\r\n // TODO\r\n }\r\n return false;\r\n }\r\n else {\r\n return false;\r\n }\r\n }\r\n containsPoint(p) {\r\n assertVectors(p);\r\n const t = this.pointT(p);\r\n return !isNaN(t) && this.isValidT(t);\r\n }\r\n equals(obj) {\r\n return (Object.getPrototypeOf(obj) == PICurve.prototype &&\r\n this.parametricSurface.equals(obj.parametricSurface) &&\r\n this.implicitSurface.equals(obj.implicitSurface) &&\r\n this.points[0].equals(obj.points[0]) &&\r\n this.tangents[0].equals(obj.tangents[0]) &&\r\n this.dir === obj.dir);\r\n }\r\n hashCode() {\r\n let hashCode = 0;\r\n hashCode = hashCode * 31 + this.parametricSurface.hashCode();\r\n hashCode = hashCode * 31 + this.implicitSurface.hashCode();\r\n hashCode = hashCode * 31 + this.points[0].hashCode();\r\n hashCode = hashCode * 31 + this.tangents[0].hashCode();\r\n return hashCode | 0;\r\n }\r\n tangentP(point) {\r\n assertVectors(point);\r\n assert(this.containsPoint(point), \"this.containsPoint(point)\");\r\n const t = this.pointT(point);\r\n return this.tangentAt(t);\r\n }\r\n tangentAt(t) {\r\n assert(!isNaN(t));\r\n if (0 === t % 1)\r\n return this.tangents[t];\r\n const uv = this.uvT(t);\r\n const uvTangent = new V3(-this.didv(uv.x, uv.y), this.didu(uv.x, uv.y), 0).toLength(this.stepSize);\r\n const du = this.parametricSurface.dpdu()(uv.x, uv.y);\r\n const dv = this.parametricSurface.dpdv()(uv.x, uv.y);\r\n return du.times(uvTangent.x).plus(dv.times(uvTangent.y));\r\n }\r\n at(t) {\r\n assert(!isNaN(t));\r\n if (0 === t % 1)\r\n return this.points[t];\r\n const startParams = V3.lerp(this.pmPoints[floor(t)], this.pmPoints[ceil(t)], t % 1);\r\n return this.closestPointToParams(startParams);\r\n }\r\n uvT(t) {\r\n assert(!isNaN(t));\r\n //TODO: use elerp\r\n if (0 === t % 1)\r\n return this.pmPoints[t];\r\n const startParams = V3.lerp(this.pmPoints[floor(t)], this.pmPoints[ceil(t)], t % 1);\r\n return curvePoint(this.implicitCurve(), startParams, this.didu, this.didv);\r\n }\r\n closestTToPoint(p, tStart) {\r\n // TODO\r\n return 0;\r\n }\r\n closestPointToParams(startUV) {\r\n const pointParams = curvePoint(this.implicitCurve(), startUV, this.didu, this.didv);\r\n return this.parametricSurface.pUVFunc()(pointParams.x, pointParams.y);\r\n }\r\n isTsWithSurface(surface) {\r\n if (surface instanceof EllipsoidSurface) {\r\n const pS = this.parametricSurface, iS = this.implicitSurface;\r\n if (pS instanceof ProjectedCurveSurface &&\r\n iS instanceof EllipsoidSurface) {\r\n const iscs = iS.isCurvesWithSurface(surface);\r\n const points = iscs.flatMap((isc) => isc.isTsWithSurface(pS).map((t) => isc.at(t)));\r\n const ts = fuzzyUniques(points.map((p) => this.pointT(p)));\r\n return ts.filter((t) => !isNaN(t) && this.isValidT(t));\r\n }\r\n }\r\n else if (ImplicitSurface.is(surface)) {\r\n const result = [];\r\n const iF = surface.implicitFunction();\r\n let prevSignedDistance = iF(this.points[0]);\r\n for (let i = 1; i < this.points.length; i++) {\r\n const point = this.points[i];\r\n const signedDistance = iF(point);\r\n if (prevSignedDistance * signedDistance <= 0) {\r\n const pF = this.parametricSurface.pUVFunc();\r\n const dpdu = this.parametricSurface.dpdu();\r\n const dpdv = this.parametricSurface.dpdv();\r\n const startUV = this.pmPoints[abs(prevSignedDistance) < abs(signedDistance) ? i - 1 : i];\r\n const isUV = newtonIterate2dWithDerivatives(this.implicitCurve(), (u, v) => iF(pF(u, v)), startUV.x, startUV.y, 4, this.didu, this.didv, (u, v) => dpdu(u, v).dot(surface.didp(pF(u, v))), (u, v) => dpdv(u, v).dot(surface.didp(pF(u, v))));\r\n result.push(this.pointT(this.parametricSurface.pUV(isUV.x, isUV.y)));\r\n }\r\n prevSignedDistance = signedDistance;\r\n }\r\n return result;\r\n }\r\n throw new Error();\r\n }\r\n isTsWithPlane(planeWC) {\r\n return this.isTsWithSurface(new PlaneSurface(planeWC));\r\n // version which intersects the plane with the defining surfaces of this PICurve, but this causes\r\n // issues when they are PICurves too:\r\n // assertInst(P3, planeWC)\r\n // const ps = this.parametricSurface,\r\n // \tis = this.implicitSurface\r\n // const pscs = ps.isCurvesWithPlane(planeWC)\r\n // const iscs = is.isCurvesWithPlane(planeWC)\r\n // const infos = iscs.flatMap(isc => pscs.flatMap(psc => isc.isInfosWithCurve(psc)))\r\n // const ts = fuzzyUniques(infos.map(info => this.pointT(info.p)))\r\n // return ts.filter(t => !isNaN(t) && this.isValidT(t))\r\n }\r\n pointT(p) {\r\n assertVectors(p);\r\n if (!this.parametricSurface.containsPoint(p) ||\r\n !this.implicitSurface.containsPoint(p)) {\r\n return NaN;\r\n }\r\n const pmPoint = this.parametricSurface.uvPFunc()(p);\r\n const ps = this.points, pmps = this.pmPoints;\r\n let t = 0, pmDistance = pmPoint.distanceTo(pmps[0]);\r\n while (pmDistance > abs(this.stepSize) && t < ps.length - 1) {\r\n // TODO -1?\r\n //console.log(t, pmps[t].$, pmDistance)\r\n t = min(pmps.length - 1, t + max(1, Math.round(pmDistance / abs(this.stepSize) / 2 / 2)));\r\n pmDistance = pmPoint.distanceTo(pmps[t]);\r\n }\r\n // if (t < this.pmPoints.length - 1 && pmDistance > pmPoint.distanceTo(pmps[t + 1])) {\r\n // t++\r\n // }\r\n if (pmDistance > abs(this.stepSize) * 1.1) {\r\n // p is not on this curve\r\n return NaN;\r\n }\r\n if (t == ps.length - 1) {\r\n t--;\r\n }\r\n if (ps[t].like(p))\r\n return t;\r\n if (ps[t + 1].like(p))\r\n return t + 1;\r\n const startT = withMax(arrayRange(floor(this.tMin), ceil(this.tMax), 1), (t) => -pmPoint.distanceTo(pmps[t]));\r\n if (undefined === startT)\r\n throw new Error();\r\n if (ps[startT].like(p))\r\n return startT;\r\n //const [a, b] = 0 === startT\r\n // ? [0, 1]\r\n // : this.points.length - 1 === startT\r\n // ? [startT - 1, startT]\r\n // : pmPoint.distanceTo(pmps[startT - 1]) < pmPoint.distanceTo(pmps[startT + 1])\r\n // ? [startT - 1, startT]\r\n // : [startT, startT + 1]\r\n const a = max(0, startT - 1), b = min(this.points.length - 1, startT + 1);\r\n const tangent = this.tangentAt(startT);\r\n const f = (t) => this.at(clamp(t, 0, this.points.length - 1))\r\n .to(p)\r\n .dot(tangent);\r\n // const df = (t: number) => -this.tangentAt(clamp(t, 0, this.points.length - 1)).dot(tangent)\r\n //checkDerivate(f, df, 0, this.points.length - 2, 3)\r\n // 8 steps necessary because df can currently be way off\r\n t = bisect(f, a, b, 32);\r\n if (!isFinite(t) || this.at(t).distanceTo(p) > abs(this.stepSize)) {\r\n return NaN;\r\n }\r\n return t;\r\n }\r\n transform(m4) {\r\n const dirFactor = m4.isMirroring() ? -1 : 1;\r\n return PICurve.forStartEnd(this.parametricSurface.transform(m4), this.implicitSurface.transform(m4), m4.transformPoint(this.points[0]), m4.transformPoint(getLast(this.points)), this.stepSize * dirFactor, m4.transformVector(this.tangents[0]), m4.transformPoint(this.at(this.tMin)), m4.transformPoint(this.at(this.tMax)));\r\n //return PICurve.forParametricStartEnd(\r\n //\tthis.parametricSurface.transform(m4),\r\n //\tthis.implicitSurface.transform(m4),\r\n //\tthis.pmPoints[0],\r\n //\tgetLast(this.pmPoints),\r\n //\tthis.stepSize,\r\n //\tthis.dir,\r\n //\tthis.tMin,\r\n //\tthis.tMax)\r\n // TODO: pass transformed points?\r\n //return new PICurve(\r\n //\tm4.transformedPoints(this.points),\r\n //\tm4.transformedVectors(this.tangents),\r\n // this.parametricSurface.transform(m4),\r\n // this.implicitSurface.transform(m4),\r\n // this.pmPoints,\r\n // this.pmTangents,\r\n //this.stepSize,\r\n // this.dir,\r\n //this.generator,\r\n //this.tMin, this.tMax)\r\n }\r\n roots() {\r\n const allTs = arrayRange(0, this.points.length);\r\n return [allTs, allTs, allTs];\r\n }\r\n isInfosWithLine(anchorWC, dirWC, tMin, tMax, lineMin, lineMax) {\r\n return surfaceIsICurveIsInfosWithLine.call(this, this.implicitSurface, this.parametricSurface, anchorWC, dirWC, tMin, tMax, lineMin, lineMax);\r\n }\r\n toSource(rounder = (x) => x) {\r\n const result = callsce(\"PICurve.forParametricStartEnd\", this.parametricSurface, this.implicitSurface, this.pmPoints[0], getLast(this.pmPoints), this.stepSize, this.pmTangents[0], this.tMin, this.tMax);\r\n return result;\r\n }\r\n}\r\nPICurve.prototype.tIncrement = 1;\r\n//# sourceMappingURL=PICurve.js.map","import { assert, assertVectors, callsce, getLast, newtonIterate, V3, } from \"ts3dutils\";\r\nimport { curvePointPP, followAlgorithmPP, ImplicitCurve, ImplicitSurface, ParametricSurface, PlaneSurface, surfaceIsICurveIsInfosWithLine, } from \"../index\";\r\nimport { abs, ceil, floor } from \"../math\";\r\nexport class PPCurve extends ImplicitCurve {\r\n constructor(points, tangents, parametricSurface1, parametricSurface2, st1s, pmTangents, stepSize, dir = 1, generator, tMin, tMax) {\r\n super(points, tangents, dir, generator, tMin, tMax);\r\n this.parametricSurface1 = parametricSurface1;\r\n this.parametricSurface2 = parametricSurface2;\r\n this.st1s = st1s;\r\n this.pmTangents = pmTangents;\r\n this.stepSize = stepSize;\r\n assert(ParametricSurface.is(parametricSurface1));\r\n assert(ParametricSurface.is(parametricSurface2));\r\n assert(Array.isArray(st1s));\r\n assert(dir == 1);\r\n assert(stepSize <= 1);\r\n }\r\n at(t) {\r\n assert(!isNaN(t));\r\n if (0 === t % 1)\r\n return this.points[t];\r\n const startPoint = V3.lerp(this.points[floor(t)], this.points[ceil(t)], t % 1);\r\n return curvePointPP(this.parametricSurface1, this.parametricSurface2, startPoint).p;\r\n }\r\n isColinearTo(curve) {\r\n if (curve instanceof PPCurve) {\r\n if (this.equals(curve)) {\r\n return true;\r\n }\r\n if (this.parametricSurface1.isCoplanarTo(curve.parametricSurface1) &&\r\n this.parametricSurface1.isCoplanarTo(curve.parametricSurface2)) {\r\n // TODO\r\n }\r\n return false;\r\n }\r\n else {\r\n return false;\r\n }\r\n }\r\n containsPoint(p) {\r\n assertVectors(p);\r\n // TODO: wrong, as there could be another curve\r\n return (this.parametricSurface1.containsPoint(p) &&\r\n this.parametricSurface2.containsPoint(p) &&\r\n !isNaN(this.pointT(p)));\r\n }\r\n rootPoints() {\r\n const pF1 = this.parametricSurface1.pUVFunc();\r\n const pF2 = this.parametricSurface2.pUVFunc();\r\n const pN1 = this.parametricSurface1.normalUVFunc();\r\n const pN2 = this.parametricSurface2.normalUVFunc();\r\n const rootsApprox = this.rootsApprox();\r\n const results = [[], [], []];\r\n for (let dim = 0; dim < 3; dim++) {\r\n for (let i = 0; i < rootsApprox[dim].length; i++) {\r\n const lambda = rootsApprox[dim][i];\r\n const p = this.at(lambda);\r\n assert(this.parametricSurface1.containsPoint(p));\r\n const pp1 = this.parametricSurface1.uvP(p);\r\n const { x: u, y: v } = this.parametricSurface2.uvP(p);\r\n const startValues = [pp1.x, pp1.y, u, v];\r\n function f(vals) {\r\n const [u1, v1, u2, v2] = vals;\r\n const diff = pF1(u1, v1).minus(pF2(u2, v2));\r\n const n1 = pN1(u1, v1);\r\n const n2 = pN2(u2, v2);\r\n const tangent = n1.cross(n2);\r\n return [diff.x, diff.y, diff.z, tangent.e(dim)];\r\n }\r\n const pps = newtonIterate(f, startValues, 8);\r\n // assert(pF1(pps[0], pps[1]).like(pF2(pps[2], pps[3])),\r\n // \tpF1(pps[0], pps[1]).sce + pF2(pps[2], pps[3]).sce)\r\n const result = pF1(pps[0], pps[1]);\r\n results[dim].push(result);\r\n }\r\n }\r\n return results;\r\n }\r\n roots() {\r\n return this.rootPoints().map((ps) => ps.map((p) => this.pointT(p)));\r\n }\r\n pointTangent(pWC) {\r\n assertVectors(pWC);\r\n assert(this.containsPoint(pWC), \"this.containsPoint(pWC)\");\r\n const n1 = this.parametricSurface1.normalP(pWC);\r\n const n2 = this.parametricSurface2.normalP(pWC);\r\n return n1.cross(n2);\r\n }\r\n transform(m4) {\r\n return new PPCurve(m4.transformedPoints(this.points), m4.transformedVectors(this.tangents), this.parametricSurface1.transform(m4), this.parametricSurface2.transform(m4), this.st1s, undefined, this.stepSize, this.dir, undefined);\r\n }\r\n toSource() {\r\n return callsce(\"PPCurve.forStartEnd\", this.parametricSurface1, this.parametricSurface2, this.points[0], getLast(this.points), this.stepSize);\r\n }\r\n static forStartEnd(ps1, ps2, startPoint, end, stepSize = 0.02) {\r\n const { points, tangents, st1s } = followAlgorithmPP(ps1, ps2, startPoint, stepSize);\r\n return new PPCurve(points, tangents, ps1, ps2, st1s, undefined, stepSize, 1);\r\n }\r\n isInfosWithLine(anchorWC, dirWC, tMin, tMax, lineMin, lineMax) {\r\n return surfaceIsICurveIsInfosWithLine.call(this, this.parametricSurface1, this.parametricSurface2, anchorWC, dirWC, tMin, tMax, lineMin, lineMax);\r\n }\r\n isTsWithSurface(surface) {\r\n if (ImplicitSurface.is(surface)) {\r\n const result = [];\r\n const iF = surface.implicitFunction();\r\n const pUV1 = this.parametricSurface1.pUVFunc();\r\n const pUV2 = this.parametricSurface2.pUVFunc();\r\n let prevSignedDistance = iF(this.points[0]);\r\n for (let i = 1; i < this.points.length; i++) {\r\n const point = this.points[i];\r\n const signedDistance = iF(point);\r\n if (prevSignedDistance * signedDistance <= 0) {\r\n const startIndex = abs(prevSignedDistance) < abs(signedDistance) ? i - 1 : i;\r\n const startPoint = this.points[startIndex];\r\n const startUV1 = this.st1s[startIndex];\r\n const startUV2 = this.parametricSurface2.uvP(startPoint);\r\n const isSTUV = newtonIterate(([u1, v1, u2, v2]) => {\r\n const ps1p = pUV1(u1, v1);\r\n const ps2p = pUV2(u2, v2);\r\n return [...ps1p.to(ps2p), iF(ps1p)];\r\n }, [startUV1.x, startUV1.y, startUV2.x, startUV2.y]);\r\n result.push(this.pointT(this.parametricSurface1.pUV(isSTUV[0], isSTUV[1])));\r\n }\r\n prevSignedDistance = signedDistance;\r\n }\r\n return result;\r\n }\r\n throw new Error(\"Method not implemented.\");\r\n }\r\n isTsWithPlane(planeWC) {\r\n return this.isTsWithSurface(new PlaneSurface(planeWC));\r\n }\r\n}\r\n//# sourceMappingURL=PPCurve.js.map","import { arrayFromFunction, assertNumbers, eq, eq0, hasConstructor, le, pqFormula, V3, } from \"ts3dutils\";\r\nimport { BezierCurve, L3, XiEtaCurve, } from \"../index\";\r\nimport { parabola4Projection } from \"./XiEtaCurve\";\r\n/**\r\n * eta = xi²\r\n */\r\nexport class ParabolaCurve extends XiEtaCurve {\r\n constructor(center, f1, f2, tMin = -10, tMax = 10) {\r\n super(center, f1, f2, tMin, tMax);\r\n }\r\n static eccentricity() {\r\n return 1;\r\n }\r\n static unitIsInfosWithLine(anchorLC, dirLC, anchorWC, dirWC) {\r\n // para: x² = y\r\n // line(t) = anchor + t dir\r\n // (ax + t dx)² = ay + t dy\r\n // ax² + t ax dx + t² dx² = ay + t dy\r\n // t² dx² + t (ax dx + dy) + ay² + ay = 0\r\n const pqDiv = Math.pow(dirLC.x, 2);\r\n const lineTs = pqFormula((anchorLC.x * dirLC.x + dirLC.y) / pqDiv, (Math.pow(anchorLC.x, 2) + anchorLC.y) / pqDiv);\r\n return lineTs\r\n .filter((tOther) => le(0, anchorLC.y + tOther * dirLC.y))\r\n .map((tOther) => ({\r\n tThis: dirLC.x * tOther + anchorLC.x,\r\n tOther: tOther,\r\n p: L3.at(anchorWC, dirWC, tOther),\r\n }));\r\n }\r\n static intersectionUnitLine(a, b, c) {\r\n /*\r\n solve system (5)/(6)\r\n g1 * xi + g2 * eta = g3 (6)\r\n g1 * xi + g2 * xi * xi = g3\r\n xi² + xi * g1/g2 - g3/g2 = 0\r\n */\r\n return pqFormula(a / b, -c / b);\r\n }\r\n static XYLCValid(pLC) {\r\n return eq(Math.pow(pLC.x, 2), pLC.y);\r\n }\r\n static XYLCPointT(pLC) {\r\n return pLC.x;\r\n }\r\n static quadratic(a, b, c) {\r\n // (1 - t)² a + 2 * t * (1 - t) b + t² c\r\n // (1 -2t +t²)a + (2t -2t²) b + t² c\r\n // = t²(a - 2b + c) + t (-2a + 2b) + a\r\n // (2t - 2) a + (1 - 2t) b + 2t c = t(2a + 2b - 2c) - 2a + b\r\n // 2 a + -2 b + 2 c\r\n const f2 = a.plus(c).minus(b.times(2));\r\n const f1 = b.minus(a).times(2);\r\n const center = a;\r\n return new ParabolaCurve(center, f1, f2, 0, 1);\r\n }\r\n at(t) {\r\n // center + f1 t + f2 t²\r\n return this.center.plus(this.f1.times(t)).plus(this.f2.times(t * t));\r\n }\r\n tangentAt(t) {\r\n assertNumbers(t);\r\n // f1 + f2 2 t\r\n return this.f1.plus(this.f2.times(2 * t));\r\n }\r\n ddt(t) {\r\n assertNumbers(t);\r\n return this.f2.times(2);\r\n }\r\n tangentAt2(xi, eta) {\r\n assertNumbers(xi, eta);\r\n return this.f1.plus(this.f2.times(2 * eta));\r\n }\r\n reversed() {\r\n return new this.constructor(this.center, this.f1.negated(), this.f2, -this.tMax, -this.tMin);\r\n }\r\n /**\r\n * tangent: f1 + 2 * t * f2 = 0\r\n * t = -f1 / 2 / f2 (for individual dimensions)\r\n */\r\n roots() {\r\n const dimRoots = (dim) => eq0(this.f2.e(dim)) ? [] : [-this.f1.e(dim) / 2 / this.f2.e(dim)];\r\n return arrayFromFunction(3, dimRoots);\r\n }\r\n isColinearTo(curve) {\r\n if (!hasConstructor(curve, ParabolaCurve))\r\n return false;\r\n const thisRA = this.rightAngled(), curveRA = curve.rightAngled();\r\n return (thisRA.center.like(curveRA.center) &&\r\n thisRA.f2.like(curveRA.f2) &&\r\n thisRA.f1.likeOrReversed(curveRA.f1));\r\n }\r\n rightAngled() {\r\n // looking for vertex of parabola\r\n // this is the point where the tangent is perpendicular to the main axis (f2)\r\n // tangent = f1 + f2 * 2 * t0\r\n // f2 DOT (f1 + f2 * 2 * t0) == 0\r\n // f1 DOT f2 + f2 DOT f2 * 2 * t0 == 0\r\n // t0 == -(f1 DOT f2) / (f2 DOT f2 * 2)\r\n const f1 = this.f1, f2 = this.f2;\r\n const f1DOTf2 = f1.dot(f2);\r\n if (eq0(f1DOTf2) && f1.hasLength(1)) {\r\n return this;\r\n }\r\n const t0 = -f1DOTf2 / f2.squared() / 2;\r\n // we need to rearange tMin/tMax\r\n // tMin' = pointT(at(tMin)) =\r\n const raCenter = this.at(t0);\r\n const raF1 = this.tangentAt(t0), raF1Length = raF1.length(), raF11 = raF1.unit();\r\n const repos = (t) => this.at(t).minus(raCenter).dot(raF11);\r\n return new ParabolaCurve(raCenter, raF11, f2.div(Math.pow(raF1Length, 2)), repos(this.tMin), repos(this.tMax));\r\n }\r\n arcLength(startT, endT) {\r\n let f1 = this.f1;\r\n const f2 = this.f2;\r\n const f1DOTf2 = f1.dot(f2);\r\n let t0 = 0;\r\n if (!eq0(f1DOTf2)) {\r\n t0 = -f1DOTf2 / f2.squared() / 2;\r\n f1 = f1.plus(f2.times(2 * t0));\r\n }\r\n const f1Length = f1.length();\r\n const a = f2.length() / f1Length;\r\n function F(x) {\r\n return (Math.asinh(a * 2 * x) / 4 / a +\r\n (x * Math.sqrt(1 + a * a * 4 * x * x)) / 2);\r\n }\r\n return f1Length * (F(endT - t0) - F(startT - t0));\r\n }\r\n transform4(m4) {\r\n return parabola4Projection(this.matrix.transform(m4), this.tMin, this.tMax);\r\n }\r\n asBezier() {\r\n return BezierCurve.quadratic(this.at(-1), new L3(this.at(-1), this.tangentAt(-1).unit()).isInfoWithLine(new L3(this.at(1), this.tangentAt(1).unit())), this.at(1));\r\n }\r\n /**\r\n * Returns new ParabolaCurve that has its center point at this.at(t0)\r\n * @param t0\r\n */\r\n recenter(t0) {\r\n // this.at(t) = f2 t² + f1 t + center\r\n // c2.at(t) = f2 (t + t0)² + f1 (t + t0) + center\r\n // c2.at(t) = f2 (t² + 2 t0 t + t0²) + f1 (t + t0) + center\r\n // c2.at(t) = f2 t² + (f1 + 2 f2 t0) t + center + f2 t0² + f1 t0\r\n return new ParabolaCurve(this.at(t0), this.f1.plus(this.f2.times(2 * t0)), this.f2);\r\n }\r\n}\r\nParabolaCurve.XY = new ParabolaCurve(V3.O, V3.X, V3.Y);\r\nParabolaCurve.YZ = new ParabolaCurve(V3.O, V3.Y, V3.Z);\r\nParabolaCurve.ZX = new ParabolaCurve(V3.O, V3.Z, V3.X);\r\nParabolaCurve.prototype.tIncrement = 1 / 32;\r\n//# sourceMappingURL=ParabolaCurve.js.map","import { arrayFromFunction, assert, assertf, assertNumbers, assertVectors, between, checkDerivate, eq, eq0, fuzzyBetween, hasConstructor, le, lerp, lt, M4, mapFilter, newtonIterate1d, newtonIterateSmart, pqFormula, TAU, V3, } from \"ts3dutils\";\r\nimport { Curve, intersectionUnitCircleLine, intersectionUnitCircleLine2, L3, P3, XiEtaCurve, } from \"../index\";\r\nimport { atan2, cos, max, min, PI, sign, sqrt } from \"../math\";\r\nimport { parabola4Projection } from \"./XiEtaCurve\";\r\nexport class EllipseCurve extends XiEtaCurve {\r\n constructor(center, f1, f2, tMin = 0, tMax = PI) {\r\n super(center, f1, f2, tMin, tMax);\r\n assert(-PI <= this.tMin && this.tMin < PI);\r\n assert(-PI < this.tMax && this.tMax <= PI);\r\n }\r\n static andFixTs(center, f1, f2, tMin = 0, tMax = PI) {\r\n if (-PI <= tMin && tMax <= PI) {\r\n return new EllipseCurve(center, f1, f2, tMin, tMax);\r\n }\r\n if (0 <= tMin && tMax <= TAU) {\r\n return new EllipseCurve(center, f1.negated(), f2.negated(), tMin - PI, tMax - PI);\r\n }\r\n if (-TAU <= tMin && tMax <= 0) {\r\n return new EllipseCurve(center, f1.negated(), f2.negated(), tMin + PI, tMax + PI);\r\n }\r\n throw new Error(\"Method not implemented.\");\r\n }\r\n static XYLCValid(pLC) {\r\n const { x, y } = pLC;\r\n return eq0(Math.pow(x, 2) + Math.pow(y, 2) - 1);\r\n }\r\n static XYLCPointT(pLC, tMin, tMax) {\r\n assertNumbers(tMin, tMax);\r\n const t = atan2(pLC.y, pLC.x);\r\n const lowSplitter = lerp(tMin, tMax - TAU, 0.5);\r\n if (t < lowSplitter) {\r\n return t + TAU;\r\n }\r\n const highSplitter = lerp(tMax, tMin + TAU, 0.5);\r\n if (t > highSplitter) {\r\n return t - TAU;\r\n }\r\n return t;\r\n }\r\n static intersectionUnitLine(a, b, c, tMin, tMax) {\r\n const isLC = intersectionUnitCircleLine2(a, b, c);\r\n const result = [];\r\n for (const [xi, eta] of isLC) {\r\n const t = EllipseCurve.XYLCPointT(new V3(xi, eta, 0), tMin, tMax);\r\n fuzzyBetween(t, tMin, tMax) && result.push(t);\r\n }\r\n return result;\r\n }\r\n static unitIsInfosWithLine(anchorLC, dirLC, anchorWC, dirWC, tMin, tMax) {\r\n // ell: x² + y² = 1 = p²\r\n // line(t) = anchor + t dir\r\n // anchor² - 1 + 2 t dir anchor + t² dir² = 0\r\n const pqDiv = dirLC.squared();\r\n const lineTs = pqFormula((2 * dirLC.dot(anchorLC)) / pqDiv, (anchorLC.squared() - 1) / pqDiv);\r\n return lineTs\r\n .filter((tOther) => le(0, anchorLC.y + tOther * dirLC.y))\r\n .map((tOther) => ({\r\n tThis: EllipseCurve.XYLCPointT(dirLC.times(tOther).plus(anchorLC), tMin, tMax),\r\n tOther: tOther,\r\n p: L3.at(anchorWC, dirWC, tOther),\r\n }));\r\n }\r\n /**\r\n * Returns a new EllipseCurve representing a circle parallel to the XY-plane.`\r\n */\r\n static semicircle(radius, center = V3.O, tMin, tMax) {\r\n return new EllipseCurve(center, new V3(radius, 0, 0), new V3(0, radius, 0), tMin, tMax);\r\n }\r\n static circleForCenter2P(center, a, b, radius, tMin, tMax) {\r\n const f1 = center.to(a);\r\n const normal = f1.cross(center.to(b));\r\n const f2 = normal.cross(f1).toLength(f1.length());\r\n return new EllipseCurve(center, f1, f2, undefined !== tMin ? tMin : 0, undefined !== tMax ? tMax : f1.angleTo(center.to(b)));\r\n }\r\n split(tMin = this.tMin, tMax = this.tMax) {\r\n const result = [];\r\n tMin < 0 &&\r\n result.push(new EllipseCurve(this.center, this.f1.negated(), this.f2.negated(), tMin + PI, min(0, tMax) + PI));\r\n tMax > 0 &&\r\n result.push(new EllipseCurve(this.center, this.f1, this.f2, max(0, tMin), tMax));\r\n return result;\r\n }\r\n static forAB(a, b, center = V3.O) {\r\n return super.forAB(a, b, center);\r\n }\r\n /**\r\n * Create a circle curve which has a, b and c on it. a, b, c can't be on a straight line.\r\n * tMin defaults to 0, tMax defaults to the value for c\r\n */\r\n static circleThroughPoints(a, b, c, tMin = 0, tMax) {\r\n assertf(() => !L3.throughPoints(a, c).containsPoint(b));\r\n const normal = a.to(b).cross(b.to(c));\r\n const center = new L3(a.lerp(b, 0.5), normal.cross(a.to(b)).unit()).isInfoWithLine(new L3(b.lerp(c, 0.5), normal.cross(b.to(c)).unit()));\r\n const f1 = center.to(a).negated();\r\n return new EllipseCurve(center, f1, normal.unit().cross(f1), -PI, undefined === tMax\r\n ? f1.angleRelativeNormal(center.to(c), normal.unit())\r\n : tMax);\r\n }\r\n getAreaInDir(right, up, tStart, tEnd) {\r\n //assertf(() => tStart < tEnd)\r\n assertf(() => right.isPerpendicularTo(this.normal));\r\n assertf(() => up.isPerpendicularTo(this.normal));\r\n //assertf(() => EllipseCurve.isValidT(tStart), tStart)\r\n //assertf(() => EllipseCurve.isValidT(tEnd), tEnd)\r\n const upLC = this.matrixInverse.transformVector(up);\r\n const rightLC = upLC.cross(V3.Z);\r\n const normTStart = tStart - rightLC.angleXY();\r\n const normTEnd = tEnd - rightLC.angleXY();\r\n const transformedOriginY = this.matrixInverse\r\n .getTranslation()\r\n .dot(upLC.unit());\r\n // integral of sqrt(1 - x²) from 0 to cos(t)\r\n // Basically, we want\r\n // INTEGRAL[cos(t); PI/2] sqrt(1 - x²) dx\r\n // INTEGRAL[PI/2: cos(t)] -sqrt(1 - x²) dx\r\n // = INTEGRAL[cos(0); cos(t)] -sqrt(1 - x²) dx\r\n // = INTEGRAL[0; t] -sqrt(1 - cos²(t)) * -sin(t) dt\r\n // = INTEGRAL[0; t] -sin(t) * -sin(t) dt\r\n // = INTEGRAL[0; t] sin²(t) dt (partial integration / wolfram alpha)\r\n // = (1/2 * (t - sin(t) * cos(t)))[0; t] (this form has the distinct advantage of being defined everywhere)\r\n function fArea(t) {\r\n return (t - Math.sin(t) * Math.cos(t)) / 2;\r\n }\r\n // for the centroid, we want\r\n // cx = 1 / area * INTEGRAL[cos(t); PI/2] x * f(x) dx\r\n // cx = 1 / area * INTEGRAL[cos(t); PI/2] x * sqrt(1 - x²) dx\r\n // cx = 1 / area * INTEGRAL[cos(0); cos(t)] x * -sqrt(1 - x²) dx\r\n // ...\r\n // cx = 1 / area * INTEGRAL[0; t] cos(t) * sin²(t) dt // WA\r\n // cx = 1 / area * (sin^3(t) / 3)[0; t]\r\n function cxTimesArea(t) {\r\n return Math.pow(Math.sin(t), 3) / 3;\r\n }\r\n // cy = 1 / area * INTEGRAL[cos(t); PI/2] f²(x) / 2 dx\r\n // cy = 1 / area * INTEGRAL[cos(0); cos(t)] -(1 - x²) / 2 dx\r\n // cy = 1 / area * INTEGRAL[0; t] (cos²(t) - 1) * -sin(t) / 2 dt\r\n // cy = 1 / area * (cos (3 * t) - 9 * cos(t)) / 24 )[0; t]\r\n function cyTimesArea(t) {\r\n return (Math.cos(3 * t) - 9 * Math.cos(t)) / 24;\r\n }\r\n const restArea = -transformedOriginY * (-Math.cos(normTEnd) + Math.cos(normTStart));\r\n const area = fArea(normTEnd) - fArea(normTStart) + restArea;\r\n const cxt = (cxTimesArea(normTEnd) -\r\n cxTimesArea(normTStart) +\r\n ((-transformedOriginY * (-Math.cos(normTEnd) - Math.cos(normTStart))) /\r\n 2) *\r\n restArea) /\r\n area;\r\n const cyt = (cyTimesArea(normTEnd) -\r\n cyTimesArea(normTStart) -\r\n (-transformedOriginY / 2) * restArea) /\r\n area;\r\n const factor = this.matrix.xyAreaFactor(); // * upLC.length()\r\n //console.log('fctor', factor, 'area', area, 'resultarea', area* factor)\r\n assert(!eq0(factor));\r\n return {\r\n area: area * factor,\r\n centroid: this.matrix.transformPoint(M4.rotateZ(rightLC.angleXY()).transformPoint(new V3(cxt, cyt, 0))),\r\n };\r\n }\r\n at(t) {\r\n assertNumbers(t);\r\n //assert(this.isValidT(t))\r\n // = center + f1 cos t + f2 sin t\r\n return this.center\r\n .plus(this.f1.times(Math.cos(t)))\r\n .plus(this.f2.times(Math.sin(t)));\r\n }\r\n tangentAt(t) {\r\n assertNumbers(t);\r\n //assert(this.isValidT(t))\r\n // ) f2 cos(t) - f1 sin(t)\r\n return this.f2.times(Math.cos(t)).minus(this.f1.times(Math.sin(t)));\r\n }\r\n ddt(t) {\r\n assertNumbers(t);\r\n assert(this.isValidT(t));\r\n return this.f2.times(-Math.sin(t)).minus(this.f1.times(Math.cos(t)));\r\n }\r\n tangentAt2(xi, eta) {\r\n return this.f2.times(xi).minus(this.f1.times(eta));\r\n }\r\n isCircular() {\r\n return (eq(this.f1.length(), this.f2.length()) &&\r\n this.f1.isPerpendicularTo(this.f2));\r\n }\r\n isColinearTo(curve) {\r\n if (!hasConstructor(curve, EllipseCurve))\r\n return false;\r\n if (!this.center.like(curve.center)) {\r\n return false;\r\n }\r\n if (this == curve) {\r\n return true;\r\n }\r\n if (this.isCircular()) {\r\n return (curve.isCircular() &&\r\n eq(this.f1.length(), curve.f1.length()) &&\r\n this.normal.isParallelTo(curve.normal));\r\n }\r\n else {\r\n let { f1: f1, f2: f2 } = this.rightAngled(), { f1: c1, f2: c2 } = curve.rightAngled();\r\n if (f1.length() > f2.length()) {\r\n ;\r\n [f1, f2] = [f2, f1];\r\n }\r\n if (c1.length() > c2.length()) {\r\n ;\r\n [c1, c2] = [c2, c1];\r\n }\r\n return (eq(f1.squared(), Math.abs(f1.dot(c1))) &&\r\n eq(f2.squared(), Math.abs(f2.dot(c2))));\r\n }\r\n }\r\n pointT(pWC) {\r\n assertVectors(pWC);\r\n assert(this.containsPoint(pWC));\r\n const pLC = this.matrixInverse.transformPoint(pWC);\r\n const t = EllipseCurve.XYLCPointT(pLC, this.tMin, this.tMax);\r\n assert(this.isValidT(t));\r\n return t;\r\n }\r\n reversed() {\r\n return new EllipseCurve(this.center, this.f1.negated(), this.f2, PI - this.tMax, PI - this.tMin);\r\n }\r\n eccentricity() {\r\n const mainAxes = this.rightAngled();\r\n const f1length = mainAxes.f1.length(), f2length = mainAxes.f1.length();\r\n const [a, b] = f1length > f2length ? [f1length, f2length] : [f2length, f1length];\r\n return Math.sqrt(1 - (b * b) / a / a);\r\n }\r\n circumference() {\r\n return this.arcLength(-Math.PI, Math.PI);\r\n }\r\n arcLength(tStart = this.tMin, tEnd = this.tMax, steps = 2) {\r\n assert(tStart < tEnd, \"startT < endT\");\r\n const f1Length = this.f1.length();\r\n if (eq(f1Length, this.f2.length())) {\r\n return f1Length * (tEnd - tStart);\r\n }\r\n return super.arcLength(tStart, tEnd, steps);\r\n }\r\n circumferenceApproximate() {\r\n // approximate circumference by Ramanujan\r\n // https://en.wikipedia.org/wiki/Ellipse#Circumference\r\n const { f1, f2 } = this.rightAngled(), a = f1.length(), b = f2.length();\r\n const h = Math.pow((a - b), 2) / Math.pow((a + b), 2);\r\n return Math.PI * (a + b) * (1 + (3 * h) / (10 + Math.sqrt(4 - 3 * h)));\r\n }\r\n /**\r\n * Radii of the ellipse are described by\r\n * q(phi) = f1 * cos(phi) + f2 * sin(phi)\r\n * or q(xi, eta) = f1 * xi + f2 * eta (1) with the added condition\r\n * xi² + eta² = 1 (2)\r\n * we want to find the radius where the corresponding tangent is perpendicular\r\n * tangent: q'(phi) = f1 * -sin(phi) + f2 * cos(phi)\r\n * tangent: q'(xi, eta) = f1 * -eta + f2 * xi\r\n * perpendicular when: q'(xi, eta) DOT q(xi, eta) = 0\r\n * (f1 * -eta + f2 * xi) DOT (f1 * xi + f2 * eta) = 0\r\n * DOT is distributive:\r\n * f1² * (-eta * xi) + f1 * f2 * (-eta² + xi²) + f2² * (xi * eta) = 0\r\n * (f2² - f1²) * (eta * xi) + f1 * f2 * (-eta² + xi²) = 0\r\n * a * (xi² - eta²) + b * xi * eta = 0 (2)\r\n * with a = f1 * f2, b = f2² - f1²\r\n * => (xi/eta)² + xi/eta * b/a + 1 = 0 (divide by a * eta²)\r\n * xi/eta = b/a/2 +- sqrt(b²/a²/4 - 1) | * 2*a*eta\r\n * 2 * a * xi = eta * (b +- sqrt(b² - 4 * a²))\r\n * g1 * xi - g2 * eta = 0 (3)\r\n * with g1 = 2 * a, g2 = b +- sqrt(b² - 4 * a²)\r\n * Solve (3), (2) with intersectionUnitCircleLine\r\n */\r\n rightAngled() {\r\n const f1 = this.f1, f2 = this.f2, a = f1.dot(f2), b = f2.squared() - f1.squared();\r\n if (eq0(a)) {\r\n return this;\r\n }\r\n const g1 = 2 * a, g2 = b + Math.sqrt(b * b + 4 * a * a);\r\n const { x1: xi, y1: eta } = intersectionUnitCircleLine(g1, g2, 0);\r\n const f1RA = f1.times(xi).plus(f2.times(eta));\r\n const f2RA = f1.times(-eta).plus(f2.times(xi));\r\n return new EllipseCurve(this.center, f1RA, f2RA, -PI, PI);\r\n }\r\n isInfosWithEllipse(ellipse) {\r\n if (this.normal.isParallelTo(ellipse.normal) &&\r\n eq0(this.center.minus(ellipse.center).dot(ellipse.normal))) {\r\n // ellipses are coplanar\r\n const ellipseLCRA = ellipse.transform(this.matrixInverse).rightAngled();\r\n const r1 = ellipseLCRA.f1.lengthXY(), r2 = ellipseLCRA.f2.lengthXY(), centerDist = ellipseLCRA.center.lengthXY();\r\n const rMin = min(r1, r2), rMax = max(r1, r2);\r\n if (lt(centerDist + rMax, 1) || // entirely inside unit circle\r\n lt(1, centerDist - rMax) || // entirely outside unit circle\r\n lt(1, rMin - centerDist) || // contains unit circle\r\n (eq(1, r1) && eq(1, r2) && eq0(centerDist)) // also unit circle, return no IS\r\n ) {\r\n return [];\r\n }\r\n const f = (t) => ellipseLCRA.at(t).lengthXY() - 1;\r\n const df = (t) => ellipseLCRA.at(t).xy().dot(ellipseLCRA.tangentAt(t)) /\r\n ellipseLCRA.at(t).lengthXY();\r\n checkDerivate(f, df, -PI, PI, 1);\r\n const ellipseLCRATs = [];\r\n for (let startT = (-4 / 5) * PI; startT < PI; startT += PI / 4) {\r\n let t = newtonIterateSmart(f, startT, 16, df, 1e-4);\r\n le(t, -PI) && (t += TAU);\r\n assert(!isNaN(t));\r\n if (between(t, -PI, PI) &&\r\n eq0(f(t)) &&\r\n !ellipseLCRATs.some((r) => eq(t, r))) {\r\n ellipseLCRATs.push(t);\r\n }\r\n }\r\n const result = [];\r\n for (const ellipseLCRAT of ellipseLCRATs) {\r\n const p = this.matrix.transformPoint(ellipseLCRA.at(ellipseLCRAT));\r\n if (this.containsPoint(p) && ellipse.containsPoint(p)) {\r\n result.push({ tThis: this.pointT(p), tOther: ellipse.pointT(p), p });\r\n }\r\n }\r\n return result;\r\n //const angle = ellipseLCRA.f1.angleXY()\r\n //const aSqr = ellipseLCRA.f1.squared(), bSqr = ellipseLCRA.f2.squared()\r\n //const a = Math.sqrt(aSqr), b = Math.sqrt(bSqr)\r\n //const {x: centerX, y: centerY} = ellipseLCRA.center\r\n //const rotCenterX = centerX * Math.cos(-angle) + centerY * -Math.sin(-angle)\r\n //const rotCenterY = centerX * Math.sin(-angle) + centerY * Math.cos(-angle)\r\n //const rotCenter = V(rotCenterX, rotCenterY)\r\n //const f = t => {\r\n //\tconst lex = Math.cos(t) - rotCenterX, ley = Math.sin(t) - rotCenterY\r\n //\treturn lex * lex / aSqr + ley * ley / bSqr - 1\r\n //}\r\n //const f2 = (x, y) => (x * x + y * y - 1)\r\n //const f3 = (x, y) => ((x - rotCenterX) * (x - rotCenterX) / aSqr + (y - rotCenterY) * (y - rotCenterY) /\r\n // bSqr - 1) const results = [] const resetMatrix = this.matrix.times(M4.rotateZ(angle)) for (let startT =\r\n // Math.PI / 4; startT < 2 * Math.PI; startT += Math.PI / 2) { const startP = EllipseCurve.XY.at(startT)\r\n // const p = newtonIterate2d(f3, f2, startP.x, startP.y, 10) if (p && !results.some(r => r.like(p))) {\r\n // results.push(p) } } const rotEl = new EllipseCurve(rotCenter, V(a, 0, 0), V(0, b, 0)) return\r\n // results.map(pLC => { const p = resetMatrix.transformPoint(pLC) return {tThis: this.pointT(p, PI),\r\n // tOther: ellipse.pointT(p, PI), p} })\r\n }\r\n else {\r\n return mapFilter(this.isTsWithPlane(P3.normalOnAnchor(ellipse.normal.unit(), ellipse.center)), (t) => {\r\n const p = this.at(t);\r\n if (ellipse.containsPoint(p)) {\r\n return { tThis: t, tOther: ellipse.pointT(p), p };\r\n }\r\n return undefined;\r\n });\r\n }\r\n }\r\n isInfosWithCurve(curve) {\r\n if (curve instanceof EllipseCurve) {\r\n return this.isInfosWithEllipse(curve);\r\n }\r\n return super.isInfosWithCurve(curve);\r\n }\r\n transform4(m4) {\r\n const tMap = (t) => sign(t) * sqrt((1 - cos(t)) / (1 + cos(t)));\r\n // prettier-ignore\r\n const parabolaToUnitEllipse = new M4(0, -1, 0, 1, 2, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 1);\r\n return parabola4Projection(M4.product(m4, this.matrix, parabolaToUnitEllipse), tMap(this.tMin), tMap(this.tMax));\r\n }\r\n roots() {\r\n // tangent(t) = f2 cos t - f1 sin t\r\n // solve for each dimension separately\r\n // tangent(eta, xi) = f2 eta - f1 xi\r\n return arrayFromFunction(3, (dim) => {\r\n const a = this.f2.e(dim);\r\n const b = -this.f1.e(dim);\r\n return intersectionUnitCircleLine2(a, b, 0)\r\n .map(([xi, eta]) => Math.atan2(eta, xi))\r\n .filter((t) => this.isValidT(t));\r\n });\r\n }\r\n closestTToPoint(p, tStart) {\r\n // (at(t) - p) * tangentAt(t) = 0\r\n // (xi f1 + eta f2 + q) * (xi f2 - eta f1) = 0\r\n // xi eta (f2^2-f1^2) + xi f2 q - eta² f1 f2 + xi² f1 f2 - eta f1 q = 0\r\n // (xi² - eta²) f1 f2 + xi eta (f2^2-f1^2) + xi f2 q - eta f1 q = 0\r\n // atan2 of p is a good first approximation for the searched t\r\n tStart = tStart || this.matrixInverse.transformPoint(p).angleXY();\r\n const pRelCenter = p.minus(this.center);\r\n const f = (t) => this.tangentAt(t).dot(this.f1\r\n .times(Math.cos(t))\r\n .plus(this.f2.times(Math.sin(t)))\r\n .minus(pRelCenter));\r\n return newtonIterate1d(f, tStart, 8);\r\n }\r\n area() {\r\n // see\r\n // https://upload.wikimedia.org/wikipedia/commons/thumb/4/4e/Cross_product_parallelogram.svg/220px-Cross_product_parallelogram.svg.png\r\n return Math.PI * this.f1.cross(this.f2).length();\r\n }\r\n angleToT(phi) {\r\n // atan2(y, x) = phi\r\n const phiDir = this.f1\r\n .unit()\r\n .times(Math.cos(phi))\r\n .plus(this.f2.rejectedFrom(this.f1).unit().times(Math.sin(phi)));\r\n const dirLC = this.matrixInverse.transformVector(phiDir);\r\n return dirLC.angleXY();\r\n }\r\n}\r\nEllipseCurve.UNIT = new EllipseCurve(V3.O, V3.X, V3.Y);\r\nEllipseCurve.prototype.hlol = Curve.hlol++;\r\nEllipseCurve.prototype.tIncrement = (2 * Math.PI) / (4 * 32);\r\n//# sourceMappingURL=EllipseCurve.js.map","import { arrayFromFunction, arraySamples, assert, between, eq, eq0, firstUnsorted, getLast, hasConstructor, le, lerp, M4, max, MINUS, newtonIterateWithDerivative2, NLA_DEBUG, setLast, snap, snap0, V, V3, vArrGet, Vector, VV, withMax, } from \"ts3dutils\";\r\nimport { BezierCurve, Curve, EllipseCurve, HyperbolaCurve, L3, P3, ParabolaCurve, } from \"../index\";\r\nimport { abs, cos, cosh, PI, sin, sinh, sqrt, SQRT1_2 } from \"../math\";\r\n/**\r\n * Non-Uniform Rational B-Spline implementation.\r\n *\r\n * See https://pages.mtu.edu/~shene/COURSES/cs3621/NOTES/ for a good reference.\r\n *\r\n *\r\n */\r\nexport class NURBS extends Curve {\r\n constructor(\r\n /**\r\n * The control points of the NURBS curve, as 4D homogeneous coordinates.\r\n */\r\n points, \r\n /**\r\n * The degree of the NURBS curve. Must be at least 1 (linear).\r\n */\r\n degree, knots = NURBS.openUniformKnots(points.length, degree), tMin = knots[degree], tMax = knots[knots.length - degree - 1]) {\r\n super(tMin, tMax);\r\n this.points = points;\r\n this.degree = degree;\r\n this.knots = knots;\r\n const knotsLength = points.length + degree + 1;\r\n NLA_DEBUG && Object.freeze(points);\r\n NLA_DEBUG && Object.freeze(knots);\r\n assert(knots.length === knotsLength, \"bad knot vector length: expected \" +\r\n knotsLength +\r\n \" (degree = \" +\r\n degree +\r\n \" pcount = \" +\r\n points.length +\r\n \"), but was \" +\r\n knots.length);\r\n assert(knots[degree] <= tMin);\r\n assert(tMax <= knots[knots.length - degree - 1]);\r\n for (let i = 0; i < points.length; i++) {\r\n assert(points[i].dim() == 4);\r\n }\r\n assert(degree >= 1, \"degree must be at least 1 (linear)\");\r\n assert(degree % 1 == 0);\r\n assert(-1 == firstUnsorted(knots, MINUS), \"knot values must be in ascending order\");\r\n }\r\n getConstructorParameters() {\r\n return [this.points, this.degree, this.knots];\r\n }\r\n at4(t) {\r\n NLA_DEBUG &&\r\n assert(between(t, this.tMin, this.tMax), t + \" \" + this.tMin + \" \" + this.tMax);\r\n const { points, degree, knots } = this;\r\n // find s (the spline segment) for the [t] value provided\r\n const s = this.tInterval(t);\r\n const v = Vector.pack(points, new Float64Array((degree + 1) * 4), s - degree, 0, degree + 1);\r\n for (let level = 0; level < degree; level++) {\r\n // build level l of the pyramid\r\n for (let i = degree; i > level; i--) {\r\n const alpha = (t - knots[i + s - degree]) /\r\n (knots[i + s - level] - knots[i + s - degree]);\r\n // interpolate each component\r\n for (let dim = 0; dim < 4; dim++) {\r\n v[i * 4 + dim] =\r\n (1 - alpha) * v[(i - 1) * 4 + dim] + alpha * v[i * 4 + dim];\r\n }\r\n }\r\n }\r\n return new Vector(v.slice(degree * 4, (degree + 1) * 4));\r\n }\r\n at(t) {\r\n return this.at4(t).p3();\r\n }\r\n /**\r\n d(k, i, t) = a(i, k, t) * d(k - 1, i, t) + (1 - a(i, k, t)) * d(k - 1, i - 1, t)\r\n a(i, k, t) = (t - knots[i]) / (knots[i + 1 + n - k] - knots[i])\r\n a'(i, k, t) = 1 / (knots[i + 1 + n - k] - knots[i])\r\n \r\n d/dt = a(i, k, t) * d'(k - 1, i, t) + a'(i, k, t) * d(k - 1, i, t)\r\n + (1 - a(i, k, t)) * d'(k - 1, i - 1, t) + a'(i, k, t) * d(k - 1, i - 1, t)\r\n */\r\n ptDtDdt4(t) {\r\n const { points, degree, knots } = this;\r\n // find s (the spline segment) for the [t] value provided\r\n const s = this.tInterval(t);\r\n const v = Vector.pack(points, new Float64Array((degree + 1) * 4), s - degree, 0, degree + 1);\r\n let ddt = Vector.Zero(4);\r\n let derivative;\r\n for (let level = 0; level < degree; level++) {\r\n if (level == degree - 2) {\r\n // see https://www.globalspec.com/reference/61012/203279/10-8-derivatives\r\n const a = new Vector(v.slice(degree * 4, (degree + 1) * 4));\r\n const b = new Vector(v.slice((degree - 1) * 4, degree * 4));\r\n const c = new Vector(v.slice((degree - 2) * 4, (degree - 1) * 4));\r\n function step(k, i, dkMinus1iMinus1, dkMinus1i) {\r\n return dkMinus1i\r\n .minus(dkMinus1iMinus1)\r\n .times(k / (knots[i + degree - k] - knots[i - 1]));\r\n }\r\n ddt = step(degree, s + 1, step(degree - 1, s + 1, a, b), step(degree - 1, s, b, c));\r\n }\r\n if (level == degree - 1) {\r\n const a = new Vector(v.slice(degree * 4, (degree + 1) * 4));\r\n const b = new Vector(v.slice((degree - 1) * 4, degree * 4));\r\n derivative = b.minus(a).times(degree / (knots[s] - knots[s + 1]));\r\n }\r\n for (let i = degree; i > level; i--) {\r\n const alpha = (t - knots[i + s - degree]) /\r\n (knots[i + s - level] - knots[i + s - degree]);\r\n // interpolate each component\r\n for (let dim = 0; dim < 4; dim++) {\r\n v[i * 4 + dim] =\r\n (1 - alpha) * v[(i - 1) * 4 + dim] + alpha * v[i * 4 + dim];\r\n }\r\n }\r\n }\r\n const p = new Vector(v.slice(degree * 4, degree * 4 + 4));\r\n return [p, derivative, ddt];\r\n }\r\n tangentAt(t) {\r\n // x(t) = xw(t) / w(t)\r\n // quotient rule\r\n const [p, derivative] = this.ptDtDdt4(t);\r\n const expected = derivative\r\n .times(p.w)\r\n .minus(p.times(derivative.w))\r\n .div(Math.pow(p.w, 2))\r\n .V3();\r\n return expected;\r\n }\r\n ddt(t) {\r\n const [p, dt, ddt] = this.ptDtDdt4(t);\r\n // =(-w(t) x(t) w''(t) - 2 w(t) w'(t) x'(t) + 2 x(t) w'(t)^2 + w(t)^2 x''(t))/w(t)^3\r\n // =(x(t) ((-w(t)) w''(t) + 2 w'(t)^2) - x'(t) 2 w(t) w'(t) + x''(t) w(t)^2 )/w(t)^3\r\n // prettier-ignore\r\n return Vector.add(p.times(-p.w * ddt.w + 2 * Math.pow(dt.w, 2)), dt.times(-2 * p.w * dt.w), ddt.times(Math.pow(p.w, 2))).div(Math.pow(p.w, 3)).V3();\r\n }\r\n ptDtDdt(t) {\r\n const [pt, dt4, ddt4] = this.ptDtDdt4(t);\r\n return [\r\n pt.p3(),\r\n dt4\r\n .times(pt.w)\r\n .minus(pt.times(dt4.w))\r\n .div(Math.pow(pt.w, 2))\r\n .V3(),\r\n Vector.add(pt.times(-pt.w * ddt4.w + 2 * Math.pow(dt4.w, 2)), //\r\n dt4.times(-2 * pt.w * dt4.w), ddt4.times(Math.pow(pt.w, 2)))\r\n .div(Math.pow(pt.w, 3))\r\n .V3(),\r\n ];\r\n }\r\n pointT(pWC) {\r\n return this.closestTToPoint(pWC);\r\n }\r\n closestTToPoint(p, tStart, tMin = this.tMin, tMax = this.tMax) {\r\n // this.at(t) has minimal distance to p when this.tangentAt(t) is perpendicular to\r\n // the vector between this.at(t) and p. This is the case iff the dot product of the two is 0.\r\n // f = (this.at(t) - p) . (this.tangentAt(t)\r\n // df = this.tangentAt(t) . this.tangentAt(t) + (this.at(t) - p) . this.ddt(t)\r\n // = this.tangentAt(t)² + (this.at(t) - p) . this.ddt(t)\r\n const f = (t) => {\r\n const [pt, dt, ddt] = this.ptDtDdt(t);\r\n return [pt.minus(p).dot(dt), dt.squared() + pt.minus(p).dot(ddt)];\r\n };\r\n //checkDerivate(f, df, tMin, tMax)\r\n const STEPS = 32;\r\n if (undefined === tStart) {\r\n tStart = withMax(arraySamples(tMin, tMax, STEPS), (t) => -this.at(t).distanceTo(p));\r\n }\r\n const result = newtonIterateWithDerivative2(f, tStart, 8, this.tMin, this.tMax);\r\n //assert(undefined !== result)\r\n return result;\r\n }\r\n containsPoint(pWC) {\r\n const tGuess = this.closestTToPoint(pWC);\r\n return undefined === tGuess ? false : this.at(tGuess).like(pWC);\r\n }\r\n derivate() {\r\n const k = this.degree;\r\n const ps = arrayFromFunction(this.points.length - 1, (i) => this.points[i]\r\n .to(this.points[i + 1])\r\n .times(k / (this.knots[i + k + 1] - this.knots[i + 1])));\r\n return new NURBS(ps, this.degree - 1, this.knots.slice(1, -1), this.tMin, this.tMax);\r\n }\r\n /**\r\n * Create a new NURBS of equal degree with the added knot [newKnot]. New NURBS will have one additional control\r\n * point.\r\n */\r\n withKnot(newKnot) {\r\n assert(between(newKnot, this.tMin, this.tMax));\r\n const k = this.tInterval(newKnot);\r\n const { knots, points, degree } = this;\r\n const insertPoints = arrayFromFunction(this.degree, (j) => {\r\n const i = k - degree + 1 + j;\r\n const aiNumerator = newKnot - knots[i];\r\n // 0/0 defined as 0:\r\n const ai = aiNumerator == 0 ? 0 : aiNumerator / (knots[i + degree] - knots[i]);\r\n assert(between(ai, 0, 1));\r\n return Vector.lerp(points[i - 1], points[i], ai);\r\n });\r\n const newPoints = points.slice();\r\n newPoints.splice(k - degree + 1, degree - 1, ...insertPoints);\r\n const newKnots = knots.slice();\r\n newKnots.splice(k + 1, 0, newKnot);\r\n return new NURBS(newPoints, degree, newKnots, this.tMin, this.tMax);\r\n }\r\n removeKnot(t) {\r\n const { knots, points, degree } = this;\r\n let k = this.tInterval(t), s = 0; // s = multiplicity of the knot\r\n while (knots[k + 1] == t) {\r\n k++;\r\n s++;\r\n }\r\n if (s == 0)\r\n throw new Error(\"There is no knot \" + t + \"!\");\r\n // the points which were relevant when inserting were (k - p - 1) to (k - 1). (- 1) because the current k has\r\n // been increased by one due to the insertion.\r\n // p - 1 points were replaced by p points, hence we need to generate the original p - 1 point, + 1 to check if\r\n // this transformation is valid.\r\n const insertPoints = [points[k - degree - 1]];\r\n const oldKnots = knots.slice();\r\n oldKnots.splice(k, 1);\r\n for (let i = k - degree; i <= k - s; i++) {\r\n const alphaInv = (oldKnots[i + degree] - oldKnots[i]) / (t - oldKnots[i]);\r\n const oldPoint = Vector.lerp(getLast(insertPoints), points[i], alphaInv);\r\n insertPoints.push(oldPoint);\r\n }\r\n if (getLast(insertPoints).like(points[k + 1 - s])) {\r\n const oldPoints = points.slice();\r\n oldPoints.splice(k - degree - 1, degree - s + 3, ...insertPoints);\r\n return new NURBS(oldPoints, degree, oldKnots);\r\n }\r\n return undefined;\r\n }\r\n static openUniformKnots(pointCount, degree, tMin = 0, tMax = 1) {\r\n const knotsLength = pointCount + degree + 1;\r\n return arrayFromFunction(knotsLength, (i) => {\r\n if (i <= degree) {\r\n return tMin;\r\n }\r\n else if (i >= knotsLength - degree - 1) {\r\n return tMax;\r\n }\r\n else {\r\n return lerp(tMin, tMax, (i - degree) / (knotsLength - degree * 2 - 1));\r\n }\r\n });\r\n }\r\n static bezierKnots(degree, tMin = 0, tMax = 1) {\r\n const result = new Array((degree + 1) * 2);\r\n for (let i = 0; i < degree + 1; i++) {\r\n result[i] = tMin;\r\n result[degree + 1 + i] = tMax;\r\n }\r\n return result;\r\n }\r\n static fromBezier(bezier) {\r\n const bezier01 = bezier.selectPart(bezier.tMin, bezier.tMax);\r\n return NURBS.Bezier(bezier01.points);\r\n }\r\n static Bezier(points, tMin = 0, tMax = 1) {\r\n return new NURBS(points.map((p) => p instanceof V3 ? new Vector(new Float64Array([p.x, p.y, p.z, 1])) : p), points.length - 1, arrayFromFunction(points.length * 2, (i) => (i < points.length ? 0 : 1)), tMin, tMax);\r\n }\r\n static fromHyperbola(hyperbola, tMin = hyperbola.tMin, tMax = hyperbola.tMax) {\r\n const p0 = HyperbolaCurve.XY.at(tMin);\r\n const p2 = HyperbolaCurve.XY.at(tMax);\r\n const p1 = new V3((sinh(tMin) - sinh(tMax)) / sinh(tMin - tMax), (cosh(tMin) - cosh(tMax)) / sinh(tMin - tMax), 0);\r\n // M: midpoint between p0 and p2\r\n // X: intersection of line through p1 and M and unit hyperbola\r\n // result.at(1/2) = X\r\n // result.at(1/2) = (1/4 p0 + 1/2 p1 w + 1/4 p2) / (1/4 + 1/ 2 w + 1/4)\r\n // result.at(1/2) = (1/2 p0 + p1 w + 1/2 p2) / (1 + w)\r\n // result.at(1/2) = (M + p1 w) / (1 + w) = X\r\n // => w * (p1 - X) = (X - M)\r\n // as p1, X and M are all on the same line, we can solve this equation with only the x\r\n const M = p0.lerp(p2, 0.5);\r\n const Xx = 1 / sqrt(1 - Math.pow((M.y / M.x), 2));\r\n const w = (Xx - M.x) / (p1.x - Xx);\r\n return NURBS.fromV3s([p0, p1, p2], 2, undefined, [1, w, 1]).transform(hyperbola.matrix);\r\n }\r\n static fromParabola(parabola) {\r\n return NURBS.fromBezier(parabola.asBezier());\r\n }\r\n static fromEllipse(ellipse) {\r\n const unitSemiEllipse = new NURBS([\r\n VV(1, 0, 0, 1),\r\n VV(1, 1, 0, 1).times(SQRT1_2),\r\n VV(0, 1, 0, 1),\r\n VV(-1, 1, 0, 1).times(SQRT1_2),\r\n VV(-1, 0, 0, 1),\r\n VV(-1, -1, 0, 1).times(SQRT1_2),\r\n VV(0, -1, 0, 1),\r\n ], 2, [0, 0, 0, PI / 2, PI / 2, PI, PI, (3 * PI) / 2, (3 * PI) / 2, 2 * PI]);\r\n return unitSemiEllipse.transform(ellipse.matrix);\r\n }\r\n /**\r\n * Create a new NURBS from V3s, with optional weights.\r\n * @param points\r\n * @param degree\r\n * @param knots\r\n * @param weights\r\n */\r\n static fromV3s(points, degree, knots, weights = arrayFromFunction(points.length, () => 1)) {\r\n assert(points.length == weights.length);\r\n return new NURBS(points.map((p, i) => Vector.fromV3AndWeight(p, weights[i])), degree, knots);\r\n }\r\n isUniform(precision = 0) {\r\n const intervals = arrayFromFunction(this.knots.length - 1, (i) => this.knots[i + 1] - this.knots[i]);\r\n const [min, max] = minAndMax(intervals);\r\n return eq(min, max, precision);\r\n }\r\n /**\r\n * NURBS is a B spline if control points all have the same weight.\r\n */\r\n isBSpline(precision = 0) {\r\n const [minWeight, maxWeight] = minAndMax(this.points.map((p) => p.w));\r\n return eq(minWeight, maxWeight, precision);\r\n }\r\n /**\r\n * Whether this is a (rational) bezier curve.\r\n */\r\n isBezier(precision = 0) {\r\n if (this.degree + 1 != this.points.length)\r\n return false;\r\n const [min0, max0] = minAndMax(this.knots, 0, this.degree + 1);\r\n if (!eq(min0, max0, precision))\r\n return false;\r\n const [min1, max1] = minAndMax(this.knots, this.degree + 1);\r\n if (!eq(min1, max1, precision))\r\n return false;\r\n return true;\r\n }\r\n /**\r\n * Splits NURBS curve into rational bezier curves.\r\n * See https://pages.mtu.edu/~shene/COURSES/cs3621/NOTES/spline/B-spline/subdivision.html\r\n */\r\n getSegments() {\r\n const { knots, points, degree } = this;\r\n const result = [];\r\n const v = Vector.pack(points, new Float64Array(points.length * 4));\r\n const vectorFromV = (i) => new Vector(v.slice(i * 4, (i + 1) * 4));\r\n let k = degree + 1; // k = knot index we are duplicating\r\n while (k < knots.length - degree - 1) {\r\n const t = knots[k];\r\n const prevKnot = knots[k - 1];\r\n let s = 1; // s = multiplicity of the knot\r\n while (knots[k + 1] == t) {\r\n k++;\r\n s++;\r\n }\r\n const newNURBSPoints = new Array(degree + 1);\r\n // the first s + 1 points are identical to the current curve\r\n for (let i = 0; i < s + 1; i++) {\r\n newNURBSPoints[i] = vectorFromV(k - degree - s + i);\r\n }\r\n // we need to have multiplicity degree, so insert (degree - s) times\r\n for (let level = 1; level <= degree - s; level++) {\r\n for (let i = k - degree; i <= k - s - level; i++) {\r\n const alpha = (t - prevKnot) / (knots[i + degree + 1] - prevKnot);\r\n for (let dim = 0; dim < 4; dim++) {\r\n v[i * 4 + dim] =\r\n (1 - alpha) * v[i * 4 + dim] + alpha * v[(i + 1) * 4 + dim];\r\n }\r\n }\r\n newNURBSPoints[s + level] = vectorFromV(k - degree);\r\n }\r\n const newNURBSKnots = arrayFromFunction((degree + 1) * 2, (i) => i < degree + 1 ? knots[k - s] : t);\r\n result.push(new NURBS(newNURBSPoints, degree, newNURBSKnots));\r\n k++;\r\n }\r\n // last curve\r\n const newNURBSPoints = arrayFromFunction(degree + 1, (i) => vectorFromV(points.length - degree - 1 + i));\r\n const newNURBSKnots = arrayFromFunction((degree + 1) * 2, (i) => i < degree + 1 ? knots[k - 1] : knots[k]);\r\n result.push(new NURBS(newNURBSPoints, degree, newNURBSKnots));\r\n return result;\r\n }\r\n split(t) {\r\n const { knots, points, degree } = this;\r\n assert(le(this.tMin, t) && le(t, this.tMax));\r\n let k = this.tInterval(t), s = 0; // s = multiplicity of the knot\r\n while (knots[k + 1] == t) {\r\n k++;\r\n s++;\r\n }\r\n const vectorFromV = (i) => new Vector(v.slice(i * 4, (i + 1) * 4));\r\n const leftPoints = new Array(k + 1 - s);\r\n // the first k + s + 1 points are identical to the current curve\r\n for (let i = 0; i < k + s - degree + 1; i++) {\r\n leftPoints[i] = this.points[i];\r\n }\r\n const rightPointsLength = points.length - (k - degree);\r\n const v = Vector.pack(points, new Float64Array(rightPointsLength * 4), k - degree);\r\n // we need to have multiplicity degree, so insert (degree - s) times\r\n for (let level = 1; level <= degree - s; level++) {\r\n for (let i = k - degree; i <= k - s - level; i++) {\r\n const alpha = (t - knots[i + level]) / (knots[i + degree + 1] - knots[i + level]);\r\n const j = i - (k - degree);\r\n for (let dim = 0; dim < 4; dim++) {\r\n v[j * 4 + dim] =\r\n (1 - alpha) * v[j * 4 + dim] + alpha * v[(j + 1) * 4 + dim];\r\n }\r\n }\r\n leftPoints[k - degree + level] = vectorFromV(0);\r\n }\r\n const leftKnots = knots.slice(0, k + degree + 2 - s);\r\n for (let i = 0; i < degree - s + 1; i++) {\r\n leftKnots[k - s + 1 + i] = t;\r\n }\r\n const rightKnots = knots.slice(k - degree);\r\n for (let i = 0; i < degree + 1; i++) {\r\n rightKnots[i] = t;\r\n }\r\n const rightPoints = arrayFromFunction(rightPointsLength, (i) => vArrGet(v, 4, i));\r\n return [\r\n new NURBS(leftPoints, degree, leftKnots),\r\n new NURBS(rightPoints, degree, rightKnots),\r\n ];\r\n }\r\n simplify() {\r\n assert(this.isBezier());\r\n if (3 == this.degree && this.isBSpline()) {\r\n return new BezierCurve(this.points[0].p3(), this.points[1].p3(), this.points[2].p3(), this.points[3].p3(), this.tMin, this.tMax);\r\n }\r\n else if (2 == this.degree) {\r\n const [P0, P1, P2] = this.points;\r\n const [p0, p1, p2] = this.points.map((p) => p.p3());\r\n const c = NURBS.simplifyUnit2(P0.w, P1.w, P2.w).transform(M4.forSys(p1.to(p0), p1.to(p2), undefined, p1));\r\n const [tMin, tMax] = [c.pointT(p0), c.pointT(p2)].sort();\r\n return c.withBounds(snap(tMin, c.tMin), snap(tMax, c.tMax));\r\n }\r\n else if (1 == this.degree) {\r\n return L3.throughPoints(this.points[0].p3(), this.points[1].p3());\r\n }\r\n else {\r\n return this;\r\n }\r\n }\r\n static simplifyUnit2(w0, w1, w2) {\r\n // see https://math.stackexchange.com/a/2794874/230980\r\n const delta = w0 * w2 - Math.pow(w1, 2);\r\n const cxy = (w0 * w2) / 2 / delta;\r\n const center = new V3(cxy, cxy, 0);\r\n const k = (Math.pow(w1, 2) + delta - 2 * w1 * sqrt(abs(delta))) / 2 / delta;\r\n const p = V3.X;\r\n const q = new V3(k, cxy, 0);\r\n // const q = new V3(cxy, k, 0)\r\n if (eq0(delta)) {\r\n return new ParabolaCurve(new V3(1 / 4, 1 / 4, 0), new V3(1, -1, 0), new V3(1, 1, 0), -0.5, 0.5);\r\n }\r\n else if (delta < 0) {\r\n // hyperbola\r\n return new HyperbolaCurve(center, center.to(p), center.to(q));\r\n }\r\n else {\r\n // ellipse\r\n return new EllipseCurve(center, center.to(p), center.to(q), 0);\r\n }\r\n }\r\n elevateDegreeBezier() {\r\n assert(this.isBezier());\r\n const newPoints = new Array(this.points.length + 1);\r\n newPoints[0] = this.points[0];\r\n newPoints[this.points.length] = this.points[this.points.length - 1];\r\n for (let i = 1; i < this.points.length; i++) {\r\n newPoints[i] = Vector.lerp(this.points[i], this.points[i - 1], i / (this.degree + 1));\r\n }\r\n const newKnots = NURBS.bezierKnots(this.degree + 1, this.knots[0], this.knots[this.degree + 1]);\r\n return new NURBS(newPoints, this.degree + 1, newKnots, this.tMin, this.tMax);\r\n }\r\n elevateDegree() {\r\n const segmentsElevated = this.getSegments().map((b) => b.elevateDegreeBezier());\r\n // stitch together the segments\r\n const newPoints = new Array(2 + segmentsElevated.length * this.degree);\r\n newPoints[0] = segmentsElevated[0].points[0];\r\n setLast(newPoints, getLast(getLast(segmentsElevated).points));\r\n for (let i = 0; i < segmentsElevated.length; i++) {\r\n for (let pi = 1; pi < segmentsElevated[i].points.length - 1; pi++) {\r\n newPoints[i * (segmentsElevated[0].points.length - 2) + pi] =\r\n segmentsElevated[i].points[pi];\r\n }\r\n }\r\n const newKnots = new Array(newPoints.length + this.degree + 2);\r\n for (let i = 0; i < this.degree + 2; i++) {\r\n newKnots[i] = this.knots[0];\r\n }\r\n for (let i = 0; i < segmentsElevated.length; i++) {\r\n for (let pi = 1; pi < segmentsElevated[i].points.length - 1; pi++) {\r\n newKnots[i * (segmentsElevated[0].points.length - 2) + pi + this.degree + 1] = getLast(segmentsElevated[i].knots);\r\n }\r\n }\r\n newKnots[newKnots.length - 1] = getLast(this.knots);\r\n newKnots[newKnots.length - 2] = getLast(this.knots);\r\n let result = new NURBS(newPoints, this.degree + 1, newKnots, this.tMin, this.tMax);\r\n for (let i = 0; i < segmentsElevated.length - 1; i++) {\r\n let optimization;\r\n while ((optimization = result.removeKnot(getLast(segmentsElevated[i].knots)))) {\r\n result = optimization;\r\n }\r\n }\r\n return result;\r\n }\r\n transform(m4) {\r\n return this.transform4(m4);\r\n }\r\n transform4(m4) {\r\n return new NURBS(this.points.map((p) => m4.timesVector(p)), this.degree, this.knots, this.tMin, this.tMax);\r\n }\r\n /**\r\n * Returns the index of the interval which contains the value t.\r\n */\r\n tInterval(t) {\r\n const { degree, knots } = this;\r\n for (let s = degree; s < knots.length - 1 - degree; s++) {\r\n if (t >= knots[s] && t <= knots[s + 1]) {\r\n return s;\r\n }\r\n }\r\n throw new Error(t + \" \" + knots);\r\n }\r\n static UnitCircle(sections = 2, tMin = 0, tMax = PI) {\r\n const dt = tMax - tMin;\r\n const tStep = dt / sections;\r\n const w = sin(PI / 2 - tStep / 2);\r\n // cos\r\n const r = 1 / cos(tStep / 2);\r\n const points = arrayFromFunction(sections * 2 + 1, (i) => {\r\n const t = lerp(tMin, tMax, i / 2 / sections);\r\n if (i % 2 == 0) {\r\n // control point on circle\r\n return VV(cos(t), sin(t), 0, 1);\r\n }\r\n else {\r\n return VV(r * w * cos(t), r * w * sin(t), 0, w);\r\n }\r\n });\r\n const knots = [];\r\n knots.push(tMin, tMin, tMin);\r\n for (let i = 0; i < sections - 1; i++) {\r\n const knot = lerp(tMin, tMax, (i + 1) / sections);\r\n knots.push(knot, knot);\r\n }\r\n knots.push(tMax, tMax, tMax);\r\n return new NURBS(points, 2, knots);\r\n }\r\n debugInfo() {\r\n return {\r\n points: [\r\n ...this.knots.slice(this.degree, -this.degree).map((t) => this.at(t)),\r\n ...this.points.map((p) => p.p3()),\r\n ],\r\n lines: this.points.flatMap((p, i, ps) => ps[i + 1] ? [p.p3(), ps[i + 1].p3()] : []),\r\n };\r\n }\r\n isTsWithPlane(planeWC) {\r\n const { knots, degree, points } = this;\r\n const controlPointTs = [\r\n knots[degree],\r\n ...points\r\n .slice(1, -1)\r\n .map((p, i) => this.closestTToPoint(p.p3(), undefined, knots[i + 3], knots[i + degree])),\r\n knots[knots.length - degree - 1],\r\n ];\r\n const result = [];\r\n for (let i = 0; i < this.points.length - 1; i++) {\r\n const findClosest = (startT) => {\r\n console.log(\"startT\", startT);\r\n // try {\r\n const f = (t) => {\r\n const [p, dt] = this.ptDtDdt(t);\r\n return [planeWC.distanceToPointSigned(p), planeWC.normal1.dot(dt)];\r\n };\r\n let t = newtonIterateWithDerivative2(f, startT, 8, this.tMin, this.tMax);\r\n let [distanceAtT, distanceDtAtT] = undefined === t ? [undefined, undefined] : f(t);\r\n if (t === undefined || !eq0(distanceAtT) || eq0(distanceDtAtT)) {\r\n t = newtonIterateWithDerivative2((t) => {\r\n const [, dt, ddt] = this.ptDtDdt(t);\r\n return [planeWC.normal1.dot(dt), planeWC.normal1.dot(ddt)];\r\n }, startT, 8, this.tMin, this.tMax);\r\n }\r\n ;\r\n [distanceAtT, distanceDtAtT] = undefined === t ? [] : f(t);\r\n if (undefined !== t &&\r\n eq0(distanceAtT) &&\r\n !result.some((r) => eq(r, t))) {\r\n result.push(t);\r\n }\r\n };\r\n const a = this.points[i].p3();\r\n const b = this.points[i + 1].p3();\r\n const ad = snap0(planeWC.distanceToPointSigned(a));\r\n const bd = snap0(planeWC.distanceToPointSigned(b));\r\n if (ad * bd < 0) {\r\n const startT = lerp(controlPointTs[i], controlPointTs[i + 1], ad / (ad - bd));\r\n findClosest(startT);\r\n }\r\n else if (0 == bd) {\r\n findClosest(this.closestTToPoint(b, controlPointTs[i + 1]));\r\n }\r\n }\r\n return result;\r\n }\r\n isInfosWithCurve(curveWC) {\r\n if (curveWC instanceof L3) {\r\n return this.isInfosWithLine(curveWC.anchor, curveWC.dir1);\r\n }\r\n return super.isInfosWithCurve(curveWC);\r\n }\r\n isInfosWithLine(anchor, dir) {\r\n const thisPlane = P3.fromPoints(this.points.map((p) => p.p3()));\r\n const l = L3.anchorDirection(anchor, dir);\r\n const maxDistanceToPlane = max(this.points.map((p) => thisPlane.distanceToPoint(p.p3())));\r\n const thisIsPlanar = eq0(maxDistanceToPlane);\r\n if (thisIsPlanar && !thisPlane.containsLine(l)) {\r\n const [t] = l.isTsWithPlane(thisPlane);\r\n if (undefined === t)\r\n return [];\r\n const p = l.at(t);\r\n return this.containsPoint(p)\r\n ? [{ tThis: this.pointT(p), tOther: L3.pointT(anchor, dir, p), p }]\r\n : [];\r\n }\r\n else {\r\n const thisTs = this.isTsWithPlane(P3.normalOnAnchor(thisPlane.normal1.cross(dir), anchor));\r\n const infos = thisTs.map((tThis) => {\r\n const p = this.at(tThis);\r\n return { tThis, tOther: L3.pointT(anchor, dir, p), p };\r\n });\r\n return thisIsPlanar\r\n ? infos\r\n : infos.filter((info) => L3.containsPoint(anchor, dir, info.p));\r\n }\r\n }\r\n roots() {\r\n console.log(this.tMin, this.tMax);\r\n arraySamples(this.tMin, this.tMax, 30).forEach((t) => {\r\n console.log(t + \",\" + this.tangentAt(t).z);\r\n });\r\n const result = [[], [], []];\r\n for (let i = 0; i < this.points.length - 1; i++) {\r\n const findClosest = (startT, d) => {\r\n console.log(\"d\", d, \"startT\", startT);\r\n // try {\r\n const root = newtonIterateWithDerivative2((t) => {\r\n const [, dt, ddt] = this.ptDtDdt(t);\r\n return [dt.e(d), ddt.e(d)];\r\n }, startT, 8, this.tMin, this.tMax);\r\n if (undefined !== root) {\r\n result[d].push(root);\r\n }\r\n console.log(\"d\", d, \"startT\", startT, \"root\", root);\r\n };\r\n const a = this.points[i].p3();\r\n const b = this.points[i + 1].p3();\r\n const ab = a.to(b);\r\n for (let d = 0; d < 3; d++) {\r\n if (0 !== i && eq0(ab.e(d))) {\r\n const startT = lerp(this.knots[i], this.knots[i + this.degree + 2], 0.5);\r\n findClosest(startT, d);\r\n }\r\n else if (i < this.points.length - 2) {\r\n const bc = b.to(this.points[i + 2].p3());\r\n if (!eq0(bc.e(d)) && ab.e(d) * bc.e(d) < 0) {\r\n findClosest(this.closestTToPoint(b, this.guessTClosestToControlPoint(i + 1)), d);\r\n }\r\n }\r\n }\r\n }\r\n console.log(result);\r\n return result;\r\n }\r\n //getAABB() {\r\n //\treturn new AABB().addPoints(this.points.map(p => p.p3()))\r\n //}\r\n /**\r\n * Rough approximation of t param for points closest to control point.\r\n */\r\n guessTClosestToControlPoint(pointIndex) {\r\n return lerp(this.knots[pointIndex], this.knots[pointIndex + this.degree + 1], 0.5);\r\n }\r\n likeCurve(curve) {\r\n return (this == curve ||\r\n (hasConstructor(curve, NURBS) &&\r\n this.degree === curve.degree &&\r\n this.points.every((p, i) => p.like(curve.points[i])) &&\r\n this.knots.every((k, i) => eq(k, curve.knots[i]))));\r\n }\r\n isColinearTo(curve) {\r\n throw new Error(\"This doesn't even make sense.\");\r\n }\r\n}\r\nNURBS.EX2D = NURBS.fromV3s([\r\n V(51, 141),\r\n V(11, 76),\r\n V(29, 32),\r\n V(46, 102),\r\n V(74, 148),\r\n V(189, 107),\r\n V(56, 10),\r\n V(206, 10),\r\n V(211, 98),\r\n V(195, 141),\r\n V(139, 148),\r\n], 4);\r\nNURBS.EX3D = new NURBS([\r\n VV(94, 0, -34, 1),\r\n VV(69, 57, 45, 0.5),\r\n VV(-20, 44, 91, 1),\r\n VV(-89, -13, 47, 0.5),\r\n VV(-56, -97, -7, 1),\r\n VV(34, -83, -54, 0.5),\r\n VV(112, -53, 16, 1),\r\n VV(79, 30, 70, 0.5),\r\n VV(-2, -9, 141, 1),\r\n VV(-80, -40, 72, 0.5),\r\n VV(-38, -150, 43, 1),\r\n VV(43, -110, -29, 0.5),\r\n VV(130, -106, 65, 1),\r\n], 2, [-12, -12, -12, -8, -8, -4, -4, 0, 0, 4, 4, 8, 8, 12, 12, 12]);\r\nNURBS.prototype.tIncrement = 1 / 128;\r\nfunction minAndMax(arr, start = 0, end = arr.length) {\r\n let min = Infinity, max = -Infinity;\r\n for (let i = start; i < end; i++) {\r\n if (min > arr[i])\r\n min = arr[i];\r\n if (max < arr[i])\r\n max = arr[i];\r\n }\r\n return [min, max];\r\n}\r\n//# sourceMappingURL=NURBS.js.map","import { assert, assertInst, assertNumbers, assertVectors, callsce, eq, eq0, floatHashCode, hasConstructor, M4, Transformable, V3, VV, } from \"ts3dutils\";\r\nimport { BezierCurve, EllipseCurve, HyperbolaCurve, L3, ParabolaCurve, } from \".\";\r\n/**\r\n * Plane x DOT this.normal1 = this.w\r\n */\r\nexport class P3 extends Transformable {\r\n /**\r\n * Oriented plane, i.e. splits R^3 in half, with one half being \"in front\" of the plane.\r\n * Leads to multiple comparisons: isCoplanarToPlane returns if the plane occupies the same space,\r\n * like returns if the plane occupies the same space and has the same orientation\r\n *\r\n * Points x on the plane fulfill the equation: normal1 DOT x = w\r\n *\r\n * @param normal1 unit plane normal1\r\n * @param w signed (rel to normal1) distance from the origin\r\n */\r\n constructor(normal1, w = 0) {\r\n super();\r\n this.normal1 = normal1;\r\n this.w = w;\r\n assertVectors(normal1);\r\n assertNumbers(w);\r\n assert(normal1.hasLength(1), \"normal1.hasLength(1)\" + normal1);\r\n }\r\n get anchor() {\r\n return this.normal1.times(this.w);\r\n }\r\n static throughPoints(a, b, c) {\r\n assertVectors(a, b, c);\r\n const n1 = b.minus(a).cross(c.minus(a)).unit();\r\n return new P3(n1, n1.dot(a));\r\n }\r\n static normalOnAnchor(normal, anchor) {\r\n assertVectors(normal, anchor);\r\n const n1 = normal.unit();\r\n return new this(n1, n1.dot(anchor));\r\n }\r\n /**\r\n * Create a plane which intersects the X, Y and Z axes at the specified offsets.\r\n * x/x0 + y/y0 + y/y0 = 1\r\n */\r\n static forAxisIntercepts(x0, y0, z0) {\r\n assertNumbers(x0, y0, z0);\r\n const normal = new V3(1 / x0, 1 / y0, 1 / z0);\r\n return new P3(normal.unit(), normal.length());\r\n }\r\n /**\r\n * Create a plane containing `anchor` and extending in directions `v0` and `v1`.\r\n * `v0` and `v1` may not be parallel.\r\n * @param anchor\r\n * @param v0\r\n * @param v1\r\n */\r\n static forAnchorAndPlaneVectors(anchor, v0, v1) {\r\n assertVectors(anchor, v0, v1);\r\n assert(!v0.isParallelTo(v1));\r\n return this.normalOnAnchor(v0.cross(v1), anchor);\r\n }\r\n /**\r\n * Create a plane which contains botha point and a line. The point may not lie on the line.\r\n * @param p\r\n * @param line\r\n */\r\n static forPointAndLine(p, line) {\r\n return this.forAnchorAndPlaneVectors(line.anchor, line.dir1, line.anchor.to(p));\r\n }\r\n /**\r\n * ax + by + cz + d = 0\r\n */\r\n static forABCD(a, b, c, d) {\r\n const normalLength = Math.hypot(a, b, c);\r\n if (eq0(normalLength))\r\n return undefined;\r\n return new P3(new V3(a / normalLength, b / normalLength, c / normalLength), -d / normalLength);\r\n }\r\n static vanishingPlane(m4) {\r\n return P3.forABCD(m4.m[12], m4.m[13], m4.m[14], m4.m[15]);\r\n }\r\n static forAABB(aabb, distance = 0) {\r\n return [\r\n new P3(V3.X, aabb.max.x + distance),\r\n new P3(V3.X.negated(), -aabb.min.x - distance),\r\n new P3(V3.Y, aabb.max.y + distance),\r\n new P3(V3.Y.negated(), -aabb.min.y - distance),\r\n new P3(V3.Z, aabb.max.z + distance),\r\n new P3(V3.Z.negated(), -aabb.min.z - distance),\r\n ];\r\n }\r\n // Fit a plane to a collection of points.\r\n // Fast, and accurate to within a few degrees.\r\n // Returns None if the points do not span a plane.\r\n static fromPoints(points) {\r\n const n = points.length;\r\n if (n < 3) {\r\n return undefined;\r\n }\r\n const centroid = V3.add(...points).div(n);\r\n // Calculate full 3x3 covariance matrix, excluding symmetries:\r\n let xx = 0.0;\r\n let xy = 0.0;\r\n let xz = 0.0;\r\n let yy = 0.0;\r\n let yz = 0.0;\r\n let zz = 0.0;\r\n for (const p of points) {\r\n const r = p.minus(centroid);\r\n xx += r.x * r.x;\r\n xy += r.x * r.y;\r\n xz += r.x * r.z;\r\n yy += r.y * r.y;\r\n yz += r.y * r.z;\r\n zz += r.z * r.z;\r\n }\r\n xx /= n;\r\n xy /= n;\r\n xz /= n;\r\n yy /= n;\r\n yz /= n;\r\n zz /= n;\r\n let weighted_dir = V3.O;\r\n {\r\n const det_x = yy * zz - yz * yz;\r\n const axis_dir = new V3(det_x, xz * yz - xy * zz, xy * yz - xz * yy);\r\n let weight = det_x * det_x;\r\n if (weighted_dir.dot(axis_dir) < 0.0) {\r\n weight = -weight;\r\n }\r\n weighted_dir = weighted_dir.plus(axis_dir.times(weight));\r\n }\r\n {\r\n const det_y = xx * zz - xz * xz;\r\n const axis_dir = new V3(xz * yz - xy * zz, det_y, xy * xz - yz * xx);\r\n let weight = det_y * det_y;\r\n if (weighted_dir.dot(axis_dir) < 0.0) {\r\n weight = -weight;\r\n }\r\n weighted_dir = weighted_dir.plus(axis_dir.times(weight));\r\n }\r\n {\r\n const det_z = xx * yy - xy * xy;\r\n const axis_dir = new V3(xy * yz - xz * yy, xy * xz - yz * xx, det_z);\r\n let weight = det_z * det_z;\r\n if (weighted_dir.dot(axis_dir) < 0.0) {\r\n weight = -weight;\r\n }\r\n weighted_dir = weighted_dir.plus(axis_dir.times(weight));\r\n }\r\n const normal = weighted_dir.unit();\r\n return P3.normalOnAnchor(normal, centroid);\r\n }\r\n axisIntercepts() {\r\n const w = this.w, n = this.normal1;\r\n return new V3(w / n.x, w / n.y, w / n.z);\r\n }\r\n isCoplanarToPlane(plane) {\r\n assertInst(P3, plane);\r\n return this.like(plane) || this.likeFlipped(plane);\r\n }\r\n like(plane) {\r\n assertInst(P3, plane);\r\n return eq(this.w, plane.w) && this.normal1.like(plane.normal1);\r\n }\r\n likeFlipped(plane) {\r\n assertInst(P3, plane);\r\n return eq(this.w, -plane.w) && this.normal1.like(plane.normal1.negated());\r\n }\r\n /**\r\n * True iff plane.normal1 is equal to this.normal1 or it's negation.\r\n *\r\n */\r\n isParallelToPlane(plane) {\r\n assertInst(P3, plane);\r\n return eq(1, Math.abs(this.normal1.dot(plane.normal1)));\r\n }\r\n isParallelToLine(line) {\r\n assertInst(L3, line);\r\n return eq0(this.normal1.dot(line.dir1));\r\n }\r\n isPerpendicularToLine(line) {\r\n assertInst(L3, line);\r\n // this.normal1 || line.dir1\r\n return eq(1, Math.abs(this.normal1.dot(line.dir1)));\r\n }\r\n isPerpendicularToPlane(plane) {\r\n assertInst(P3, plane);\r\n return eq0(this.normal1.dot(plane.normal1));\r\n }\r\n toSource() {\r\n return callsce(\"new P3\", this.normal1, this.w);\r\n }\r\n translated(offset) {\r\n return new P3(this.normal1, this.w + offset.dot(this.normal1));\r\n }\r\n transform(m4) {\r\n // See https://stackoverflow.com/questions/7685495/transforming-a-3d-plane-using-a-4x4-matrix\r\n // See http://www.songho.ca/opengl/gl_normaltransform.html\r\n // with homogeneous coordinates, the hessian normal form of this plane is\r\n // (p, 1) * (normal1, -w) = 0\r\n // transformation: (m4^-1 * (p, 1)) DOT (normal1, -w) = 0\r\n // => (p, 1) DOT ((m4^-T) * (normal1, -w)) = 0\r\n // (validity of the above transformation is easily seen by expanding the matrix multiplication and dot product)\r\n // hence, (newNormal, newW) = (m4^-T) * (normal1, -w)\r\n // we divide both newNormal and newW by newNormal.length() to normalize the normal vector\r\n const m4InversedTransposed = M4.transpose(M4.inverse(m4, M4.temp0), M4.temp1);\r\n const [nx, ny, nz] = this.normal1;\r\n const newNormal = m4InversedTransposed.timesVector(VV(nx, ny, nz, -this.w));\r\n return P3.forABCD(newNormal.x, newNormal.y, newNormal.z, newNormal.w);\r\n }\r\n distanceToLine(line) {\r\n assertInst(L3, line);\r\n if (!this.isParallelToLine(line)) {\r\n return this.distanceToPoint(line.anchor);\r\n }\r\n else {\r\n return 0;\r\n }\r\n }\r\n containsPoint(x) {\r\n assertVectors(x);\r\n return eq(this.w, this.normal1.dot(x));\r\n }\r\n containsLine(line) {\r\n assertInst(L3, line);\r\n return this.containsPoint(line.anchor) && this.isParallelToLine(line);\r\n }\r\n distanceToPointSigned(point) {\r\n assertInst(V3, point);\r\n return this.normal1.dot(point) - this.w;\r\n }\r\n distanceToPoint(point) {\r\n assertInst(V3, point);\r\n return Math.abs(this.normal1.dot(point) - this.w);\r\n }\r\n intersectionWithLine(line) {\r\n return line.intersectionWithPlane(this);\r\n }\r\n intersectionWithPlane(plane) {\r\n assertInst(P3, plane);\r\n /*\r\n \r\n this: n0 * x = w0\r\n plane: n1 * x = w1\r\n plane perpendicular to both which goes through origin:\r\n n2 := n0 X x1\r\n n2 * x = 0\r\n */\r\n if (this.isParallelToPlane(plane)) {\r\n return undefined;\r\n }\r\n /*\r\n var n0 = this.normal1, n1 = plane.normal1, n2 = n0.cross(n1).unit(), m = M4.forSys(n0, n1, n2)\r\n var x0 = this.anchor, x1 = plane.anchor, x2 = V3.O\r\n var p = n2.times(x2.dot(n2))\r\n .plus(n1.cross(n2).times(x0.dot(n0)))\r\n .plus(n2.cross(n0).times(x1.dot(n1)))\r\n .div(m.determinant())\r\n */\r\n const n0 = this.normal1, n1 = plane.normal1, n2 = n0.cross(n1).unit();\r\n const p = M4.forRows(n0, n1, n2)\r\n .inversed()\r\n .transformVector(new V3(this.w, plane.w, 0));\r\n return new L3(p, n2);\r\n }\r\n /**\r\n * Returns the point in the plane closest to the given point\r\n *\r\n */\r\n projectedPoint(x) {\r\n // See http://math.stackexchange.com/questions/444968/project-a-point-in-3d-on-a-given-plane\r\n // p = x - ((x - planeAnchor) * normal1) * normal1\r\n return x.minus(this.normal1.times(x.minus(this.anchor).dot(this.normal1)));\r\n }\r\n projectedVector(x) {\r\n // See V3.rejectedFrom. Simplified, as this.normal1.length() == 1\r\n return x.minus(this.normal1.times(x.dot(this.normal1)));\r\n }\r\n flipped() {\r\n return new P3(this.normal1.negated(), -this.w);\r\n }\r\n containsCurve(curve) {\r\n if (curve instanceof L3) {\r\n return this.containsLine(curve);\r\n }\r\n else if (curve instanceof EllipseCurve ||\r\n curve instanceof HyperbolaCurve ||\r\n curve instanceof ParabolaCurve) {\r\n return (this.containsPoint(curve.center) &&\r\n this.normal1.isParallelTo(curve.normal));\r\n }\r\n else if (curve instanceof BezierCurve) {\r\n return curve.points.every((p) => this.containsPoint(p));\r\n }\r\n else {\r\n throw new Error(\"\" + curve);\r\n }\r\n }\r\n equals(obj) {\r\n return (hasConstructor(obj, P3) &&\r\n this.normal1.equals(obj.normal1) &&\r\n this.w == obj.w);\r\n }\r\n hashCode() {\r\n return (this.normal1.hashCode() * 31) | (0 + floatHashCode(this.w));\r\n }\r\n}\r\nP3.YZ = new P3(V3.X, 0);\r\nP3.ZX = new P3(V3.Y, 0);\r\nP3.XY = new P3(V3.Z, 0);\r\n//# sourceMappingURL=P3.js.map","import { arrayEquals, arrayHashCode, callsce, eq, eq0, le, NLA_PRECISION, Transformable, } from \"ts3dutils\";\r\nimport { CalculateAreaVisitor, dotCurve2, ImplicitCurve, P3, PICurve, PPCurve, ZDirVolumeVisitor, } from \"..\";\r\nimport { ceil, floor, PI, sign } from \"../math\";\r\nexport class Surface extends Transformable {\r\n static loopContainsPointGeneral(loop, pWC, testLine, lineOut) {\r\n const testPlane = P3.normalOnAnchor(lineOut, pWC);\r\n // edges colinear to the testing line; these will always be counted as \"inside\" relative to the testing line\r\n const colinearEdges = loop.map((edge) => edge.colinearToLine(testLine));\r\n let inside = false;\r\n function logIS(isP) {\r\n const isT = testLine.pointT(isP);\r\n if (eq0(isT)) {\r\n return true;\r\n }\r\n else if (isT > 0) {\r\n inside = !inside;\r\n }\r\n return false;\r\n }\r\n for (let edgeIndex = 0; edgeIndex < loop.length; edgeIndex++) {\r\n const edge = loop[edgeIndex];\r\n const nextEdgeIndex = (edgeIndex + 1) % loop.length, nextEdge = loop[nextEdgeIndex];\r\n //console.log(edge.toSource()) {p:V(2, -2.102, 0),\r\n if (colinearEdges[edgeIndex]) {\r\n const lineAT = testLine.pointT(edge.a), lineBT = testLine.pointT(edge.b);\r\n if (Math.min(lineAT, lineBT) <= NLA_PRECISION &&\r\n -NLA_PRECISION <= Math.max(lineAT, lineBT)) {\r\n return PointVsFace.ON_EDGE;\r\n }\r\n // edge colinear to intersection\r\n const nextInside = colinearEdges[nextEdgeIndex] ||\r\n dotCurve2(nextEdge.curve, nextEdge.aT, lineOut, sign(nextEdge.deltaT())) < 0;\r\n if (!nextInside) {\r\n if (logIS(edge.b))\r\n return PointVsFace.ON_EDGE;\r\n }\r\n }\r\n else {\r\n for (const edgeT of edge.edgeISTsWithPlane(testPlane)) {\r\n if (edgeT == edge.bT) {\r\n if (!testLine.containsPoint(edge.b))\r\n continue;\r\n // endpoint lies on intersection line\r\n if (edge.b.like(pWC)) {\r\n // TODO: refactor, dont check for different sides, just logIs everything\r\n return PointVsFace.ON_EDGE;\r\n }\r\n const edgeInside = dotCurve2(edge.curve, edge.bT, lineOut, -sign(edge.deltaT())) < 0;\r\n const nextInside = colinearEdges[nextEdgeIndex] ||\r\n dotCurve2(nextEdge.curve, nextEdge.aT, lineOut, sign(nextEdge.deltaT())) < 0;\r\n if (edgeInside != nextInside) {\r\n if (logIS(edge.b))\r\n return PointVsFace.ON_EDGE;\r\n }\r\n }\r\n else if (edgeT != edge.aT) {\r\n const p = edge.curve.at(edgeT);\r\n if (!testLine.containsPoint(p))\r\n continue;\r\n // edge crosses line, neither starts nor ends on it\r\n if (logIS(p))\r\n return PointVsFace.ON_EDGE;\r\n // TODO: tangents?\r\n }\r\n }\r\n }\r\n }\r\n return inside ? PointVsFace.INSIDE : PointVsFace.OUTSIDE;\r\n }\r\n static loopContainsPointEllipse(loop, pWC, testLine, pWCT) {\r\n const lineOut = testLine.normal;\r\n const testPlane = P3.normalOnAnchor(testLine.normal, pWC);\r\n const colinearEdges = loop.map((edge) => testLine.isColinearTo(edge.curve));\r\n let inside = false;\r\n if (undefined === pWCT) {\r\n pWCT = testLine.pointT(pWC);\r\n }\r\n const pT = pWCT;\r\n function logIS(isP) {\r\n const isT = testLine.pointT(isP);\r\n if (eq(pT, isT)) {\r\n return true;\r\n }\r\n else if (pT < isT && le(isT, PI)) {\r\n inside = !inside;\r\n }\r\n return false;\r\n }\r\n for (let edgeIndex = 0; edgeIndex < loop.length; edgeIndex++) {\r\n const edge = loop[edgeIndex];\r\n const nextEdgeIndex = (edgeIndex + 1) % loop.length, nextEdge = loop[nextEdgeIndex];\r\n //console.log(edge.toSource()) {p:V(2, -2.102, 0),\r\n if (colinearEdges[edgeIndex]) {\r\n let edgeT;\r\n if (edge.curve.containsPoint(pWC) &&\r\n le(edge.minT, (edgeT = edge.curve.pointT(pWC))) &&\r\n le(edgeT, edge.maxT)) {\r\n return PointVsFace.ON_EDGE;\r\n }\r\n // edge colinear to intersection\r\n const nextInside = colinearEdges[nextEdgeIndex] ||\r\n dotCurve2(nextEdge.curve, nextEdge.aT, lineOut, sign(nextEdge.deltaT())) < 0;\r\n if (!nextInside && testLine.containsPoint(edge.b)) {\r\n if (logIS(edge.b))\r\n return PointVsFace.ON_EDGE;\r\n }\r\n }\r\n else {\r\n for (const edgeT of edge.edgeISTsWithPlane(testPlane)) {\r\n if (edgeT == edge.bT) {\r\n if (!testLine.containsPoint(edge.b))\r\n continue;\r\n // endpoint lies on intersection testLine\r\n const edgeInside = dotCurve2(edge.curve, edge.bT, lineOut, -sign(edge.deltaT())) < 0;\r\n const nextInside = colinearEdges[nextEdgeIndex] ||\r\n dotCurve2(nextEdge.curve, nextEdge.aT, lineOut, sign(nextEdge.deltaT())) < 0;\r\n if (edgeInside != nextInside) {\r\n if (logIS(edge.b))\r\n return PointVsFace.ON_EDGE;\r\n }\r\n }\r\n else if (edgeT != edge.aT) {\r\n const p = edge.curve.at(edgeT);\r\n if (!testLine.containsPoint(p))\r\n continue;\r\n // edge crosses testLine, neither starts nor ends on it\r\n if (logIS(p))\r\n return PointVsFace.ON_EDGE;\r\n // TODO: tangents?\r\n }\r\n }\r\n }\r\n }\r\n return inside ? PointVsFace.INSIDE : PointVsFace.OUTSIDE;\r\n }\r\n toString() {\r\n return this.toSource();\r\n }\r\n toSource(rounder = (x) => x) {\r\n return callsce.call(undefined, \"new \" + this.constructor.name, ...this.getConstructorParameters());\r\n }\r\n /**\r\n * Return points which would touch AABB. Doesnt include borders due to parametric bounds, for example.\r\n */\r\n getExtremePoints() {\r\n return [];\r\n }\r\n isCurvesWithSurface(surface) {\r\n return surface.isCurvesWithSurface(this); //.map(curve => curve.reversed())\r\n }\r\n containsCurve(curve) {\r\n if (curve instanceof PICurve) {\r\n // if (this.equals(curve.parametricSurface) || this.equals(curve.implicitSurface)) {\r\n // \treturn true\r\n // }\r\n }\r\n if (curve instanceof PPCurve) {\r\n if (this.equals(curve.parametricSurface1) ||\r\n this.equals(curve.parametricSurface2)) {\r\n return true;\r\n }\r\n }\r\n if (curve instanceof ImplicitCurve) {\r\n for (let i = ceil(curve.tMin) + 1; i <= floor(curve.tMax) - 1; i++) {\r\n if (!this.containsPoint(curve.points[i])) {\r\n return false;\r\n }\r\n }\r\n return true;\r\n }\r\n return false;\r\n }\r\n flipped2(doFlip) {\r\n return doFlip ? this.flipped() : this;\r\n }\r\n clipCurves(curves) {\r\n return curves;\r\n }\r\n equals(obj) {\r\n return (this === obj ||\r\n (this.constructor === obj.constructor &&\r\n arrayEquals(this.getConstructorParameters(), obj.getConstructorParameters())));\r\n }\r\n hashCode() {\r\n return arrayHashCode(this.getConstructorParameters());\r\n }\r\n zDirVolume(allEdges) {\r\n return this.visit(ZDirVolumeVisitor, allEdges);\r\n }\r\n calculateArea(allEdges) {\r\n return this.visit(CalculateAreaVisitor, allEdges);\r\n }\r\n}\r\nexport var PointVsFace;\r\n(function (PointVsFace) {\r\n PointVsFace[PointVsFace[\"INSIDE\"] = 0] = \"INSIDE\";\r\n PointVsFace[PointVsFace[\"OUTSIDE\"] = 1] = \"OUTSIDE\";\r\n PointVsFace[PointVsFace[\"ON_EDGE\"] = 2] = \"ON_EDGE\";\r\n})(PointVsFace || (PointVsFace = {}));\r\n//# sourceMappingURL=Surface.js.map","import { AABB, assert, assertNumbers, between, emod, isCCW, lerp, V, V3, } from \"ts3dutils\";\r\nimport { Mesh } from \"tsgl\";\r\nimport { breakDownPPCurves, Curve, MathFunctionR2R, PICurve, Surface, } from \"..\";\r\nimport { ceil, min } from \"../math\";\r\nexport class ParametricSurface extends Surface {\r\n constructor(uMin, uMax, vMin, vMax) {\r\n super();\r\n this.uMin = uMin;\r\n this.uMax = uMax;\r\n this.vMin = vMin;\r\n this.vMax = vMax;\r\n assertNumbers(uMin, uMax, vMin, vMax);\r\n assert(uMin < uMax);\r\n assert(vMin < vMax);\r\n assert(emod(this.getConstructorParameters(), -4) == this.uMin, this.getConstructorParameters(), this.uMin);\r\n }\r\n static isCurvesParametricImplicitSurface(ps, is, uStep, vStep = uStep, curveStepSize) {\r\n const pf = ps.pUVFunc(), icc = is.implicitFunction();\r\n const dpdu = ps.dpdu();\r\n const dpdv = ps.dpdv();\r\n const didp = is.didp.bind(is);\r\n const ist = (x, y) => icc(pf(x, y));\r\n const didu = (u, v) => didp(pf(u, v)).dot(dpdu(u, v));\r\n const didv = (u, v) => didp(pf(u, v)).dot(dpdv(u, v));\r\n const mf = MathFunctionR2R.forFFxFy(ist, didu, didv);\r\n const curves = Curve.breakDownIC(mf, ps, uStep, vStep, curveStepSize, (u, v) => is.containsPoint(pf(u, v))).map(({ points, tangents }, _i) => PICurve.forParametricPointsTangents(ps, is, points, tangents, curveStepSize));\r\n return curves;\r\n }\r\n static isCurvesParametricParametricSurface(ps1, ps2, s1Step, t1Step = s1Step, curveStepSize) {\r\n return breakDownPPCurves(ps1, ps2, s1Step, t1Step, curveStepSize);\r\n }\r\n static is(obj) {\r\n return obj.pUVFunc;\r\n }\r\n pUV(u, v) {\r\n return this.pUVFunc()(u, v);\r\n }\r\n pUVFunc() {\r\n return this.pUV.bind(this);\r\n }\r\n uvP(pWC) {\r\n return this.uvPFunc()(pWC);\r\n }\r\n uvPFunc() {\r\n return this.uvP.bind(this);\r\n }\r\n bounds(u, v) {\r\n return this.uMin <= u && u <= this.uMax && this.vMin <= v && v <= this.vMax;\r\n }\r\n /**\r\n * Positive values are inside bounds.\r\n */\r\n boundsSigned(u, v) {\r\n return min(u - this.uMin, this.uMax - u, v - this.vMin, this.vMax - v);\r\n }\r\n normalP(p) {\r\n const pmPoint = this.uvPFunc()(p);\r\n return this.normalUV(pmPoint.x, pmPoint.y);\r\n }\r\n normalUVFunc() {\r\n return this.normalUV.bind(this);\r\n }\r\n normalUV(u, v) {\r\n return this.normalUVFunc()(u, v);\r\n }\r\n parametersValid(u, v) {\r\n return between(u, this.uMin, this.uMax) && between(v, this.vMin, this.vMax);\r\n }\r\n toMesh(uStep = this.uStep, vStep = this.vStep) {\r\n assert(isFinite(this.vMin) &&\r\n isFinite(this.vMax) &&\r\n isFinite(this.uMin) &&\r\n isFinite(this.uMax));\r\n assert(isFinite(uStep) && isFinite(vStep));\r\n return Mesh.parametric(this.pUVFunc(), this.normalUVFunc(), this.uMin, this.uMax, this.vMin, this.vMax, ceil((this.uMax - this.uMin) / uStep), ceil((this.vMax - this.vMin) / vStep));\r\n }\r\n isCurvesWithImplicitSurface(is, uStep, vStep, stepSize) {\r\n return ParametricSurface.isCurvesParametricImplicitSurface(this, is, uStep, vStep, stepSize);\r\n }\r\n edgeLoopCCW(contour) {\r\n const ptpF = this.uvPFunc();\r\n return isCCW(contour.flatMap((e) => e.getVerticesNo0()).map((v) => ptpF(v)), V3.Z);\r\n }\r\n like(object) {\r\n if (!this.isCoplanarTo(object))\r\n return false;\r\n // normals need to point in the same direction (outwards or inwards) for both\r\n const pSMinTMin = this.pUVFunc()(this.uMin, this.vMin);\r\n const thisNormal = this.normalUVFunc()(this.uMin, this.vMin);\r\n const otherNormal = object.normalP(pSMinTMin);\r\n return 0 < thisNormal.dot(otherNormal);\r\n }\r\n getApproxAABB() {\r\n const result = new AABB();\r\n result.addPoints(this.getExtremePoints());\r\n const ps = [V(0, 0), V(0, 1), V(1, 0), V(1, 1), V(0.5, 0.5)].map((p) => this.pUV(lerp(this.uMin, this.uMax, p.x), lerp(this.vMin, this.vMax, p.y)));\r\n result.addPoints(ps);\r\n return result;\r\n }\r\n}\r\n//# sourceMappingURL=ParametricSurface.js.map","import { AABB, assert, assertInst, assertVectors, eq, eq0, getIntervals, M4, newtonIterate, pqFormula, TAU, V3, Vector, } from \"ts3dutils\";\r\nimport { CylinderSurface, EllipseCurve, HyperbolaCurve, ImplicitSurface, L3, P3, ParabolaCurve, ParametricSurface, PlaneSurface, Surface, } from \"..\";\r\nimport { abs, cos, max, min, PI, sign, sin, sqrt, SQRT1_2 } from \"../math\";\r\nexport class ConicSurface extends ParametricSurface {\r\n /**\r\n * returns new cone C = {apex + f1 * v * cos(u) + f2 * v * sin(u) + f3 * v |\r\n * -PI <= u <= PI, 0 <= v}\r\n *\r\n * If the coordinate system [f1 f2 dir] is right-handed, the normals will\r\n * point outwards, otherwise inwards.\r\n *\r\n * @param f1\r\n * @param f2\r\n * @param dir Direction in which the cone opens. The ellipse spanned by f1,\r\n * f2 is contained at (apex + dir).\r\n */\r\n constructor(center, f1, f2, dir, uMin = 0, uMax = PI, vMin = 0, vMax = 16) {\r\n super(uMin, uMax, vMin, vMax);\r\n this.center = center;\r\n this.f1 = f1;\r\n this.f2 = f2;\r\n this.dir = dir;\r\n assertVectors(center, f1, f2, dir);\r\n assert(-PI <= uMin && uMax <= PI);\r\n assert(0 <= vMin, vMin);\r\n this.matrix = M4.forSys(f1, f2, dir, center);\r\n this.matrixInverse = this.matrix.inversed();\r\n this.normalDir = sign(this.f1.cross(this.f2).dot(this.dir));\r\n this.pLCNormalWCMatrix = this.matrix\r\n .as3x3()\r\n .inversed()\r\n .transposed()\r\n .scale(this.normalDir);\r\n }\r\n getConstructorParameters() {\r\n return [\r\n this.center,\r\n this.f1,\r\n this.f2,\r\n this.dir,\r\n this.uMin,\r\n this.uMax,\r\n this.vMin,\r\n this.vMax,\r\n ];\r\n }\r\n pointFoot(pWC, startU, startV) {\r\n if (undefined === startU || undefined === startV) {\r\n // similar to uvP\r\n const pLC = this.matrixInverse.transformPoint(pWC);\r\n const angle = pLC.angleXY();\r\n if (undefined === startU) {\r\n startU = angle < -PI / 2 ? angle + TAU : angle;\r\n }\r\n if (undefined === startV) {\r\n startV = pLC.z + (pLC.lengthXY() - pLC.z) * SQRT1_2;\r\n }\r\n }\r\n const f = ([u, v]) => {\r\n const pUVToPWC = this.pUV(u, v).to(pWC);\r\n return [this.dpdu()(u, v).dot(pUVToPWC), this.dpdv()(u).dot(pUVToPWC)];\r\n };\r\n const { 0: x, 1: y } = newtonIterate(f, [startU, startV]);\r\n return new V3(x, y, 0);\r\n }\r\n get apex() {\r\n return this.center;\r\n }\r\n static atApexThroughEllipse(apex, ellipse, uMin, uMax, vMin, vMax) {\r\n assertVectors(apex);\r\n assertInst(EllipseCurve, ellipse);\r\n return new ConicSurface(apex, ellipse.f1, ellipse.f2, apex.to(ellipse.center), uMin, uMax, vMin, vMax);\r\n }\r\n static unitISLineTs(anchor, dir) {\r\n const { x: ax, y: ay, z: az } = anchor;\r\n const { x: dx, y: dy, z: dz } = dir;\r\n // this cone: x² + y² = z²\r\n // line: p = anchor + t * dir1\r\n // split line equation into 3 component equations, insert into cone equation\r\n // transform to form (a t² + b t + c = 0) and solve with pqFormula\r\n const a = dx * dx + dy * dy - dz * dz;\r\n const b = 2 * (ax * dx + ay * dy - az * dz);\r\n const c = ax * ax + ay * ay - az * az;\r\n // cone only defined for 0 <= z, so filter invalid values\r\n return pqFormula(b / a, c / a).filter((t) => 0 < az + t * dz);\r\n }\r\n // calculate intersection of plane ax + cz = d and cone x² + y² = z²\r\n static unitISPlane(a, c, d) {\r\n if (eq0(c)) {\r\n // plane is \"vertical\", i.e. parallel to Y and Z axes\r\n assert(!eq0(a)); // normal would be zero, which is invalid\r\n // z² - y² = d²/a²\r\n if (eq0(d)) {\r\n // d = 0 => z² - y² = 0 => z² = y² => z = y\r\n // plane goes through origin/V3.O\r\n return [\r\n new L3(V3.O, new V3(0, -SQRT1_2, -SQRT1_2), undefined, 0),\r\n new L3(V3.O, new V3(0, -SQRT1_2, SQRT1_2), 0),\r\n ];\r\n }\r\n else {\r\n // hyperbola\r\n const center = new V3(d / a, 0, 0);\r\n const f1 = new V3(0, 0, abs(d / a)); // abs, because we always want the\r\n // hyperbola to be pointing up\r\n const f2 = new V3(0, d / a, 0);\r\n return [new HyperbolaCurve(center, f1, f2)];\r\n }\r\n }\r\n else {\r\n // c != 0\r\n const aa = a * a, cc = c * c;\r\n if (eq0(d)) {\r\n // ax + cz = d => x = d - cz / a => x² = d² - 2cdz/a + c²z²/a²\r\n // x² + y² = z²\r\n // => d² - 2cdz/a + c²z²/a² + y² = z²\r\n if (eq(aa, cc)) {\r\n return [new L3(V3.O, new V3(c, 0, -a).unit())];\r\n }\r\n else if (aa < cc) {\r\n throw new Error(\"intersection is single point V3.O\");\r\n }\r\n else if (aa > cc) {\r\n return [\r\n new L3(V3.O, new V3(c, sqrt(aa - cc), -a).unit()),\r\n new L3(V3.O, new V3(c, -sqrt(aa - cc), -a).unit()),\r\n ];\r\n }\r\n }\r\n else {\r\n if (eq(aa, cc)) {\r\n // parabola\r\n const parabolaVertex = new V3(d / 2 / a, 0, d / 2 / c);\r\n const parabolaVertexTangentPoint = new V3(d / 2 / a, d / c, d / 2 / c);\r\n const p2 = new V3(0, 0, d / c);\r\n const f2 = p2.minus(parabolaVertex);\r\n return [\r\n new ParabolaCurve(parabolaVertex, parabolaVertexTangentPoint.minus(parabolaVertex), f2.z < 0 ? f2.negated() : f2),\r\n ];\r\n }\r\n else if (aa < cc) {\r\n // ellipse\r\n const center = new V3((-a * d) / (cc - aa), 0, (d * c) / (cc - aa));\r\n if (center.z < 0) {\r\n return [];\r\n }\r\n const p1 = new V3(d / (a - c), 0, -d / (a - c));\r\n const p2 = new V3((-a * d) / (cc - aa), d / sqrt(cc - aa), (d * c) / (cc - aa));\r\n return [\r\n new EllipseCurve(center, center.to(p1), center.to(p2), -PI, PI),\r\n ];\r\n }\r\n else if (aa > cc) {\r\n // hyperbola\r\n const center = new V3((-a * d) / (cc - aa), 0, (d * c) / (cc - aa));\r\n // const p1 = new V3(d / (a - c), 0, -d / (a - c))\r\n // const p2 = new V3(-a * d / (cc - aa), d / sqrt(aa - cc), d * c /\r\n // (cc - aa)) const f1 = center.to(p1)\r\n const f1 = new V3((d * c) / (aa - cc), 0, (-d * a) / (aa - cc));\r\n const f2 = new V3(0, d / sqrt(aa - cc), 0);\r\n return [new HyperbolaCurve(center, f1.z > 0 ? f1 : f1.negated(), f2)];\r\n }\r\n }\r\n }\r\n throw new Error(\"???\");\r\n }\r\n equals(obj) {\r\n return (this == obj ||\r\n (Object.getPrototypeOf(this) == Object.getPrototypeOf(obj) &&\r\n this.center.equals(obj.center) &&\r\n this.f1.equals(obj.f1) &&\r\n this.f2.equals(obj.f2) &&\r\n this.dir.equals(obj.dir)));\r\n }\r\n like(object) {\r\n if (!this.isCoplanarTo(object))\r\n return false;\r\n // normals need to point in the same direction (outwards or inwards) for\r\n // both\r\n return this.normalDir == object.normalDir;\r\n }\r\n getVectors() {\r\n return [\r\n { anchor: this.center, dir1: this.dir },\r\n { anchor: this.center.plus(this.dir), dir1: this.f1 },\r\n { anchor: this.center.plus(this.dir), dir1: this.f2 },\r\n ];\r\n }\r\n getSeamPlane() {\r\n return P3.forAnchorAndPlaneVectors(this.center, this.f1, this.dir);\r\n }\r\n loopContainsPoint(contour, p) {\r\n assertVectors(p);\r\n const line = this.center.like(p)\r\n ? new L3(p, this.matrix.transformVector(new V3(0, 1, 1)).unit())\r\n : L3.throughPoints(p, this.apex);\r\n const lineOut = line.dir1.cross(this.dir);\r\n return Surface.loopContainsPointGeneral(contour, p, line, lineOut);\r\n }\r\n isTsForLine(line) {\r\n // transforming line manually has advantage that dir1 will not be\r\n // renormalized, meaning that calculated values t for lineLC are directly\r\n // transferable to line\r\n const anchorLC = this.matrixInverse.transformPoint(line.anchor);\r\n const dirLC = this.matrixInverse.transformVector(line.dir1);\r\n return ConicSurface.unitISLineTs(anchorLC, dirLC);\r\n }\r\n /**\r\n * Interestingly, two cones don't need to have parallel dirs to be coplanar.\r\n */\r\n isCoplanarTo(surface) {\r\n if (this === surface)\r\n return true;\r\n if (!(surface instanceof ConicSurface) || !this.apex.like(surface.apex))\r\n return false;\r\n // at this point apexes are equal\r\n return this.containsEllipse(new EllipseCurve(surface.center.plus(surface.dir), surface.f1, surface.f2));\r\n }\r\n containsEllipse(ellipse) {\r\n const ellipseLC = ellipse.transform(this.matrixInverse);\r\n if (ellipseLC.center.z < 0) {\r\n return false;\r\n }\r\n const { f1, f2 } = ellipseLC.rightAngled();\r\n const p1 = ellipseLC.center.plus(f1), p2 = ellipseLC.center.plus(f2);\r\n // check if both endpoints are on the cone's surface\r\n // and that one main axis is perpendicular to the Z-axis\r\n return (eq(Math.pow(p1.x, 2) + Math.pow(p1.y, 2), Math.pow(p1.z, 2)) &&\r\n eq(Math.pow(p2.x, 2) + Math.pow(p2.y, 2), Math.pow(p2.z, 2)) &&\r\n (eq0(f1.z) || eq0(f2.z)));\r\n }\r\n containsLine(line) {\r\n const lineLC = line.transform(this.matrixInverse);\r\n const d = lineLC.dir1;\r\n return lineLC.containsPoint(V3.O) && eq(d.x * d.x + d.y * d.y, d.z * d.z);\r\n }\r\n containsParabola(curve) {\r\n assertInst(ParabolaCurve, curve);\r\n const curveLC = curve.transform(this.matrixInverse);\r\n if (curveLC.center.z < 0 || curveLC.f2.z < 0) {\r\n return false;\r\n }\r\n const { center, f1, f2 } = curveLC.rightAngled();\r\n // check if center is on the surface,\r\n // that tangent is perpendicular to the Z-axis\r\n // and that \"y\" axis is parallel to surface\r\n return (eq(center.x * center.x + center.y * center.y, center.z * center.z) &&\r\n eq0(f1.z) &&\r\n eq(f2.x * f2.x + f2.y * f2.y, f2.z * f2.z));\r\n }\r\n containsHyperbola(curve) {\r\n // calculate intersection of plane ax + cz = 1 and cone x² + y² = z²\r\n // const center = new V3(-a / (cc - aa), 0, 1 / (cc - aa))\r\n // const p1 = new V3(1 / (a - c), 0, -1 / (a - c))\r\n // const p2 = new V3(-a / (cc - aa), 1 / sqrt(aa - cc), 1 / (cc - aa))\r\n // const f1 = new V3(1 * c / (aa - cc), 0, -a / (aa - cc) )\r\n // const f2 = new V3(0, 1 / sqrt(aa - cc), 0)\r\n assertInst(HyperbolaCurve, curve);\r\n const curveLC = curve.transform(this.matrixInverse).rightAngled();\r\n const centerXY = curveLC.center.xy();\r\n if (centerXY.likeO()) {\r\n return false;\r\n }\r\n const rot = centerXY.angleXY();\r\n const { center, f1, f2 } = curveLC.rotateZ(-rot);\r\n // s = a / (aa - cc)\r\n // t = -c / (aa - cc)\r\n // s + t = 1 / (a + c)\r\n // s - t = 1 / (a - c)\r\n // (s + t)(s - t) = (ss - tt) = 1 / (aa - cc)\r\n // u = 1 / sqrt(aa - cc) = sqrt(ss - tt)\r\n // check if center is on the surface,\r\n // that tangent is perpendicular to the Z-axis\r\n return (f1.z > 0 &&\r\n eq(center.x, f1.z) &&\r\n eq(center.z, f1.x) &&\r\n eq0(center.y) &&\r\n eq0(f1.y) &&\r\n eq(sqrt(abs(Math.pow(center.x, 2) - Math.pow(center.z, 2))), abs(f2.y)) &&\r\n eq0(f2.x) &&\r\n eq0(f2.z));\r\n }\r\n containsCurve(curve) {\r\n if (curve instanceof EllipseCurve) {\r\n return this.containsEllipse(curve);\r\n }\r\n else if (curve instanceof L3) {\r\n return this.containsLine(curve);\r\n }\r\n else if (curve instanceof HyperbolaCurve) {\r\n return this.containsHyperbola(curve);\r\n }\r\n else if (curve instanceof ParabolaCurve) {\r\n return this.containsParabola(curve);\r\n }\r\n else {\r\n return super.containsCurve(curve);\r\n }\r\n }\r\n transform(m4) {\r\n return new ConicSurface(m4.transformPoint(this.center), m4.transformVector(this.f1).times(m4.isMirroring() ? -1 : 1), m4.transformVector(this.f2), m4.transformVector(this.dir), this.uMin, this.uMax, this.vMin, this.vMax);\r\n }\r\n transform4(m4) {\r\n const transformedApex = m4.timesVector(Vector.fromV3AndWeight(this.center, 1));\r\n const isometricV = (z) => new EllipseCurve(new V3(0, 0, z), new V3(z, 0, 0), new V3(0, z, 0));\r\n if (!eq0(transformedApex.w)) {\r\n // sMin doesn't change, but tMin does...\r\n const c = m4.transformPoint(this.center), f1 = m4\r\n .transformVector2(this.f1, this.center)\r\n .times(m4.isMirroring() ? -1 : 1), f2 = m4.transformVector2(this.f2, this.center), dir = m4.transformVector2(this.dir, this.center);\r\n const matrixInv = M4.forSys(f1, f2, dir, c).inversed();\r\n const x = isometricV(this.vMin).transform4(matrixInv.times(m4).times(this.matrix));\r\n const y = isometricV(this.vMax).transform4(matrixInv.times(m4).times(this.matrix));\r\n const aabb = AABB.forAABBs([x.getAABB(), y.getAABB()]);\r\n console.log(\"aabb\", aabb);\r\n console.log(matrixInv.str);\r\n console.log(x.str, y.str);\r\n return new ConicSurface(c, f1, f2, dir, this.uMin, this.uMax, aabb.min.z, aabb.max.z);\r\n }\r\n else {\r\n const dir = transformedApex.V3();\r\n const baseCurve = isometricV(this.vMin).transform4(m4.times(this.matrix));\r\n const matrixInv = M4.forSys(baseCurve.f1, baseCurve.f2, dir.unit(), baseCurve.center).inversed();\r\n const aabb = isometricV(this.vMax)\r\n .transform4(matrixInv.times(m4.times(this.matrix)))\r\n .getAABB();\r\n return new CylinderSurface(baseCurve, dir.unit(), this.uMin, this.uMax, min(0, aabb.min.z, aabb.max.z), max(0, aabb.min.z, aabb.max.z));\r\n }\r\n }\r\n flipped() {\r\n return new ConicSurface(this.center, this.f1.negated(), this.f2, this.dir);\r\n }\r\n normalUVFunc() {\r\n const { f1, f2 } = this, f3 = this.dir;\r\n return (d, _z) => {\r\n return f2\r\n .cross(f1)\r\n .plus(f2.cross(f3.times(Math.cos(d))))\r\n .plus(f3.cross(f1.times(Math.sin(d))))\r\n .unit();\r\n };\r\n }\r\n normalP(p) {\r\n //TODO assert(!p.like(this.center))\r\n const pLC = this.matrixInverse.transformPoint(p);\r\n return this.normalUVFunc()(pLC.angleXY(), pLC.z);\r\n }\r\n pUVFunc() {\r\n return (u, v) => {\r\n // center + f1 v cos u + f2 v sin u + v dir\r\n const resultLC = new V3(v * cos(u), v * sin(u), v);\r\n return this.matrix.transformPoint(resultLC);\r\n };\r\n }\r\n dpdu() {\r\n return (u, v) => {\r\n const resultLC = new V3(v * -sin(u), v * cos(u), 0);\r\n return this.matrix.transformVector(resultLC);\r\n };\r\n }\r\n dpdv() {\r\n return (s) => {\r\n const resultLC = new V3(cos(s), sin(s), 1);\r\n return this.matrix.transformVector(resultLC);\r\n };\r\n }\r\n implicitFunction() {\r\n return (pWC) => {\r\n const pLC = this.matrixInverse.transformPoint(pWC);\r\n const radiusLC = pLC.lengthXY();\r\n return this.normalDir * (radiusLC - pLC.z);\r\n };\r\n }\r\n didp(pWC) {\r\n const pLC = this.matrixInverse.transformPoint(pWC);\r\n return this.pLCNormalWCMatrix.transformVector(pLC.xy().unit().withElement(\"z\", -1).times(this.normalDir));\r\n }\r\n containsPoint(p) {\r\n return eq0(this.implicitFunction()(p));\r\n }\r\n uvP(pWC) {\r\n const pLC = this.matrixInverse.transformPoint(pWC);\r\n const angle = pLC.angleXY();\r\n return new V3(angle < -PI / 2 ? angle + TAU : angle, pLC.z, 0);\r\n }\r\n isCurvesWithSurface(surface) {\r\n if (surface instanceof PlaneSurface) {\r\n return this.isCurvesWithPlane(surface.plane);\r\n }\r\n else if (ImplicitSurface.is(surface)) {\r\n return ParametricSurface.isCurvesParametricImplicitSurface(this, surface, 0.1, 0.1 / this.dir.length(), 0.02);\r\n }\r\n return super.isCurvesWithSurface(surface);\r\n }\r\n getCenterLine() {\r\n return new L3(this.center, this.dir);\r\n }\r\n isCurvesWithPlane(plane) {\r\n assertInst(P3, plane);\r\n const planeLC = plane.transform(this.matrixInverse);\r\n const planeNormal = planeLC.normal1;\r\n const c = planeNormal.z;\r\n /** \"rotate\" plane normal1 when passing to {@link ConicSurface.unitISPlane} so that\r\n * y-component of normal1 is 0 */\r\n const a = planeNormal.lengthXY();\r\n const d = planeLC.w;\r\n // generated curves need to be rotated back before transforming to world\r\n // coordinates\r\n const rotationMatrix = M4.rotateZ(planeNormal.angleXY());\r\n const wcMatrix = eq0(planeNormal.lengthXY())\r\n ? this.matrix\r\n : this.matrix.times(rotationMatrix);\r\n return ConicSurface.unitISPlane(a, c, d).flatMap((curve) => {\r\n const curveWC = curve.transform(wcMatrix);\r\n if (curve instanceof EllipseCurve) {\r\n const curveLC = curve.transform(rotationMatrix);\r\n const ts = curveLC.isTsWithPlane(P3.ZX);\r\n const intervals = getIntervals(ts, -PI, PI).filter(([a, b]) => curveLC.at((a + b) / 2).y > 0);\r\n return intervals.flatMap(([a, b]) => curveWC.split(a, b));\r\n }\r\n const p = curveWC.at(0.2);\r\n return this.normalP(p).cross(plane.normal1).dot(curveWC.tangentAt(0.2)) >\r\n 0\r\n ? curveWC\r\n : curveWC.reversed();\r\n });\r\n }\r\n debugInfo() {\r\n return {\r\n ps: [this.center],\r\n lines: [\r\n this.center,\r\n this.center.plus(this.f1),\r\n this.center.plus(this.f2),\r\n this.center.plus(this.dir),\r\n ],\r\n };\r\n }\r\n}\r\n/**\r\n * Unit cone. x² + y² = z², 0 <= z\r\n */\r\nConicSurface.UNIT = new ConicSurface(V3.O, V3.X, V3.Y, V3.Z);\r\nConicSurface.prototype.uStep = PI / 16;\r\nConicSurface.prototype.vStep = 256;\r\n//# sourceMappingURL=ConicSurface.js.map","import { arrayHashCode, assert, assertInst, assertNumbers, assertVectors, hasConstructor, M4, V3, } from \"ts3dutils\";\r\nimport { ConicSurface, Curve, EllipseCurve, EllipsoidSurface, ImplicitCurve, ImplicitSurface, L3, P3, ParametricSurface, PlaneSurface, PointProjectedSurface, Surface, } from \"../index\";\r\nimport { sign } from \"../math\";\r\n/**\r\n * Surface normal1 is (t, z) => this.baseCurve.tangentAt(t) X this.dir\r\n * Choose dir appropriately to select surface orientation.\r\n */\r\nexport class ProjectedCurveSurface extends ParametricSurface {\r\n constructor(baseCurve, dir, uMin = baseCurve.tMin, uMax = baseCurve.tMax, vMin = -100, vMax = 100) {\r\n super(uMin, uMax, vMin, vMax);\r\n this.baseCurve = baseCurve;\r\n this.dir = dir;\r\n assertInst(Curve, baseCurve);\r\n assertInst(V3, dir);\r\n assert(uMin < uMax);\r\n assert(vMin < vMax);\r\n }\r\n getConstructorParameters() {\r\n return [\r\n this.baseCurve,\r\n this.dir,\r\n this.uMin,\r\n this.uMax,\r\n this.vMin,\r\n this.vMax,\r\n ];\r\n }\r\n equals(obj) {\r\n return (this == obj ||\r\n (Object.getPrototypeOf(this) == Object.getPrototypeOf(obj) &&\r\n this.dir.equals(obj.dir) &&\r\n this.baseCurve.equals(obj.baseCurve)));\r\n }\r\n hashCode() {\r\n return arrayHashCode([this.dir, this.baseCurve]);\r\n }\r\n containsLine(line) {\r\n return this.dir.isParallelTo(line.dir1) && this.containsPoint(line.anchor);\r\n }\r\n dpdu() {\r\n return (u, v) => this.baseCurve.tangentAt(u);\r\n }\r\n dpdv() {\r\n return (u, v) => this.dir;\r\n }\r\n normalUV(u, v) {\r\n return this.baseCurve.tangentAt(u).cross(this.dir).unit();\r\n }\r\n pUV(u, v) {\r\n return this.baseCurve.at(u).plus(this.dir.times(v));\r\n }\r\n pointFoot(pWC, ss) {\r\n const basePlane = new P3(this.dir.unit(), 0);\r\n const projCurve = this.baseCurve.project(basePlane);\r\n const projPoint = basePlane.projectedPoint(pWC);\r\n const t = projCurve.closestTToPoint(projPoint, ss, this.uMin, this.uMax);\r\n const z = L3.pointT(this.baseCurve.at(t), this.dir, pWC);\r\n return new V3(t, z, 0);\r\n }\r\n uvPFunc() {\r\n const projPlane = new P3(this.dir.unit(), 0);\r\n const projBaseCurve = this.baseCurve.project(projPlane);\r\n return (pWC) => {\r\n const projPoint = projPlane.projectedPoint(pWC);\r\n assertNumbers(this.uMin);\r\n const t = projBaseCurve.pointT(projPoint, this.uMin, this.uMax);\r\n const z = L3.pointT(this.baseCurve.at(t), this.dir, pWC);\r\n return new V3(t, z, 0);\r\n };\r\n }\r\n isCurvesWithPlane(plane) {\r\n assertInst(P3, plane);\r\n if (this.dir.isPerpendicularTo(plane.normal1)) {\r\n const ts = this.baseCurve.isTsWithPlane(plane);\r\n return ts.map((t) => {\r\n const l3dir = 0 < this.baseCurve.tangentAt(t).dot(plane.normal1)\r\n ? this.dir\r\n : this.dir.negated();\r\n return new L3(this.baseCurve.at(t), l3dir.unit());\r\n });\r\n }\r\n else {\r\n let projCurve = this.baseCurve.transform(M4.project(plane, this.dir));\r\n if (this.dir.dot(plane.normal1) > 0) {\r\n // we need to flip the ellipse so the tangent is correct\r\n projCurve = projCurve.reversed();\r\n }\r\n return [projCurve];\r\n }\r\n }\r\n isCurvesWithSurface(surface) {\r\n if (surface instanceof PlaneSurface) {\r\n return this.isCurvesWithPlane(surface.plane);\r\n }\r\n if (surface instanceof ProjectedCurveSurface) {\r\n const dir1 = surface.dir;\r\n if (this.dir.isParallelTo(dir1)) {\r\n const ts = surface.baseCurve.isTsWithSurface(this);\r\n return ts.map((t) => {\r\n const p = surface.baseCurve.at(t);\r\n const correctDir = this.normalP(p).cross(surface.normalP(p));\r\n return new L3(p, dir1.times(sign(correctDir.dot(dir1))));\r\n });\r\n }\r\n else if (ImplicitSurface.is(surface)) {\r\n let curves2 = ParametricSurface.isCurvesParametricImplicitSurface(this, surface, 0.1, 0.1 / surface.dir.length(), 0.05);\r\n curves2 = surface.clipCurves(curves2);\r\n return curves2;\r\n }\r\n else {\r\n let curves2 = ParametricSurface.isCurvesParametricParametricSurface(this, surface, 0.05, 0.1 / surface.dir.length(), 0.05);\r\n curves2 = this.clipCurves(curves2);\r\n curves2 = surface.clipCurves(curves2);\r\n return curves2;\r\n }\r\n }\r\n if (surface instanceof EllipsoidSurface) {\r\n return surface.isCurvesWithSurface(this);\r\n }\r\n return super.isCurvesWithSurface(surface);\r\n }\r\n containsPoint(pWC) {\r\n const uv = this.uvPFunc()(pWC);\r\n return this.pUVFunc()(uv.x, uv.y).like(pWC);\r\n }\r\n containsCurve(curve) {\r\n if (curve instanceof L3) {\r\n return (this.dir.isParallelTo(curve.dir1) && this.containsPoint(curve.anchor));\r\n }\r\n if (curve instanceof ImplicitCurve) {\r\n return super.containsCurve(curve);\r\n }\r\n // project baseCurve and test curve onto a common plane and check if the curves are alike\r\n const projPlane = new P3(this.dir.unit(), 0);\r\n const projBaseCurve = this.baseCurve.project(projPlane);\r\n const projCurve = curve.project(projPlane);\r\n return projBaseCurve.isColinearTo(projCurve);\r\n }\r\n isCoplanarTo(surface) {\r\n return (this == surface ||\r\n (hasConstructor(surface, ProjectedCurveSurface) &&\r\n this.dir.isParallelTo(surface.dir) &&\r\n this.containsCurve(surface.baseCurve)));\r\n }\r\n like(object) {\r\n if (!this.isCoplanarTo(object))\r\n return false;\r\n // normals need to point in the same direction (outwards or inwards) for both\r\n const p00 = this.pUVFunc()(0, 0);\r\n const thisNormal = this.normalUVFunc()(0, 0);\r\n const otherNormal = object.normalP(p00);\r\n return 0 < thisNormal.dot(otherNormal);\r\n }\r\n loopContainsPoint(loop, p) {\r\n assertVectors(p);\r\n assert(isFinite(p.x), p.y, p.z);\r\n const line = new L3(p, this.dir.unit());\r\n const ptpf = this.uvPFunc();\r\n const pp = ptpf(p);\r\n if (isNaN(pp.x)) {\r\n console.log(this.sce, p.sce);\r\n assert(false);\r\n }\r\n const lineOut = this.baseCurve.tangentAt(pp.x).rejectedFrom(this.dir);\r\n return Surface.loopContainsPointGeneral(loop, p, line, lineOut);\r\n }\r\n transform(m4) {\r\n const f = m4.isMirroring() ? -1 : 1;\r\n return new this.constructor(this.baseCurve.transform(m4), m4.transformVector(this.dir).times(f), this.uMin, this.uMax, 1 == f ? this.vMin : -this.vMax, 1 == f ? this.vMax : -this.vMin);\r\n }\r\n transform4(m4) {\r\n const vp = m4.vanishingPoint(this.dir);\r\n if (!vp) {\r\n const f = m4.isMirroring() ? -1 : 1;\r\n return new this.constructor(this.baseCurve.transform4(m4), m4.normalized().transformVector(this.dir).times(f), undefined, undefined, 1 == f ? this.vMin : -this.vMax, 1 == f ? this.vMax : -this.vMin);\r\n }\r\n const curveT = this.baseCurve.transform4(m4);\r\n if (curveT instanceof EllipseCurve) {\r\n console.log(vp.sce, curveT.sce);\r\n return ConicSurface.atApexThroughEllipse(vp, m4.isMirroring() ? curveT : curveT.reversed(), this.uMin, this.uMax, 1, 2);\r\n }\r\n return new PointProjectedSurface(curveT, vp, P3.throughPoints(curveT.at(curveT.tMin), curveT.at((curveT.tMin + curveT.tMax) / 2), curveT.at(curveT.tMax)), 1, this.uMin, this.uMax, 1, 2);\r\n }\r\n isTsForLine(line) {\r\n assertInst(L3, line);\r\n const projPlane = new P3(this.dir.unit(), 0);\r\n const projDir = projPlane.projectedVector(line.dir1);\r\n if (projDir.likeO()) {\r\n // line is parallel to this.dir\r\n return [];\r\n }\r\n const projAnchor = projPlane.projectedPoint(line.anchor);\r\n const projBaseCurve = this.baseCurve.project(projPlane);\r\n return projBaseCurve\r\n .isInfosWithLine(projAnchor, projDir, this.uMin, this.uMax, line.tMin, line.tMax)\r\n .map((info) => info.tOther);\r\n }\r\n flipped() {\r\n return new this.constructor(this.baseCurve, this.dir.negated(), this.uMin, this.uMax, -this.vMax, -this.vMin);\r\n }\r\n}\r\nProjectedCurveSurface.prototype.uStep = 1 / 128;\r\nProjectedCurveSurface.prototype.vStep = 256;\r\n//# sourceMappingURL=ProjectedCurveSurface.js.map","import { assert, assertInst, DEG, eq0, fuzzyBetween, hasConstructor, lerp, lt, M4, V3, VV, withMax, } from \"ts3dutils\";\r\nimport { EllipseCurve, HyperbolaCurve, intersectionUnitCircleLine2, L3, NURBS, NURBSSurface, P3, ParametricSurface, PlaneSurface, Surface, } from \"..\";\r\nimport { abs, cos, PI, sin } from \"../math\";\r\n/**\r\n * Rotation surface with r = f(z)\r\n */\r\nexport class RotatedCurveSurface extends ParametricSurface {\r\n constructor(curve, matrix = M4.IDENTITY, uMin = 0, uMax = PI, vMin = curve.tMin, vMax = curve.tMax) {\r\n // d/dz (r(z))\r\n super(uMin, uMax, vMin, vMax);\r\n this.curve = curve;\r\n this.matrix = matrix;\r\n assertInst(M4, matrix);\r\n assert(matrix.isNoProj());\r\n assert(eq0(curve.at(vMin).y));\r\n this.matrixInverse = matrix.inversed();\r\n this.vStep = this.curve.tIncrement;\r\n }\r\n getConstructorParameters() {\r\n return [this.curve, this.matrix, this.uMin, this.uMax, this.vMin, this.vMax];\r\n }\r\n flipped() {\r\n return new RotatedCurveSurface(this.curve, this.matrix.times(M4.mirror(P3.YZ)), this.uMin, this.uMax, this.vMin, this.vMax);\r\n }\r\n transform(m4) {\r\n return new RotatedCurveSurface(this.curve, m4.isMirroring()\r\n ? m4.times(this.matrix).times(M4.mirror(P3.YZ))\r\n : m4.times(this.matrix), this.uMin, this.uMax, this.vMin, this.vMax);\r\n }\r\n containsPoint(pWC) {\r\n const pLC = this.matrixInverse.transformPoint(pWC);\r\n const radius = pLC.lengthXY();\r\n return this.curve.containsPoint(new V3(radius, 0, pLC.z));\r\n }\r\n pUVFunc() {\r\n return (u, v) => {\r\n const { x: radius, z: z } = this.curve.at(v);\r\n return this.matrix.transformPoint(V3.polar(radius, u, z));\r\n };\r\n }\r\n dpdu() {\r\n return (u, v) => {\r\n const radius = this.curve.at(v).x;\r\n const resultLC = new V3(radius * -sin(u), radius * cos(u), 0);\r\n return this.matrix.transformVector(resultLC);\r\n };\r\n }\r\n dpdv() {\r\n return (u, v) => {\r\n const { x: drdt, z: dzdt } = this.curve.tangentAt(v);\r\n return this.matrix.transformVector(V3.polar(drdt, u, dzdt));\r\n };\r\n }\r\n normalUVFunc() {\r\n const matrix = this.matrix.inversed().transposed().as3x3();\r\n const normalLength = this.matrix.isMirroring() ? -1 : 1;\r\n return (u, v) => {\r\n const { x: drdt, z: dzdt } = this.curve.tangentAt(v);\r\n return matrix\r\n .transformVector(V3.polar(dzdt, u, -drdt))\r\n .toLength(normalLength);\r\n };\r\n }\r\n uvPFunc() {\r\n return (pWC) => {\r\n const pLC = this.matrixInverse.transformPoint(pWC);\r\n const angle = EllipseCurve.XYLCPointT(pLC, this.uMin, this.uMax);\r\n const radius = pLC.lengthXY();\r\n return new V3(angle, this.curve.pointT(new V3(radius, 0, pLC.z)), 0);\r\n };\r\n }\r\n pointFoot(pWC, startS, startT) {\r\n const pLC = this.matrixInverse.transformPoint(pWC);\r\n const angle = abs(pLC.angleXY());\r\n const radius = pLC.lengthXY();\r\n return new V3(angle, this.curve.closestTToPoint(new V3(radius, 0, pLC.z)), 0);\r\n }\r\n isTsForLine(line) {\r\n const anchorLC = this.matrixInverse.transformPoint(line.anchor);\r\n const dirLC = this.matrixInverse.transformVector(line.dir1);\r\n if (dirLC.isParallelTo(V3.Z)) {\r\n if (!fuzzyBetween(anchorLC.angleXY(), this.uMin, this.uMax))\r\n return [];\r\n return this.curve\r\n .isInfosWithLine(new V3(anchorLC.lengthXY(), 0, anchorLC.z), dirLC)\r\n .map((info) => info.tOther);\r\n }\r\n else if (L3.containsPoint(anchorLC.xy(), dirLC.xy(), V3.O)) {\r\n // line goes through Z axis\r\n const dotter = dirLC.xy().unit();\r\n return [\r\n ...this.curve.isInfosWithLine(new V3(dotter.dot(anchorLC), 0, anchorLC.z), new V3(dotter.dot(dirLC), 0, dirLC.z)),\r\n ...this.curve.isInfosWithLine(new V3(-dotter.dot(anchorLC), 0, anchorLC.z), new V3(-dotter.dot(dirLC), 0, dirLC.z)),\r\n ]\r\n .map((info) => info.tOther)\r\n .filter((t) => fuzzyBetween(L3.at(anchorLC, dirLC, t).angleXY(), this.uMin, this.uMax));\r\n }\r\n else if (dirLC.isPerpendicularTo(V3.Z)) {\r\n const secs = this.isCurvesWithPlaneLC(new P3(V3.Z, anchorLC.z));\r\n if (!secs)\r\n return [];\r\n return secs.flatMap((sec) => sec.isInfosWithLine(anchorLC, dirLC).map((info) => info.tOther));\r\n }\r\n else {\r\n // transform into hyperbola\r\n // f(t) = V(((ax + t dx)² + (ay + t dy)²) ** 1/2, 0, az + t dz)\r\n // f(t) = V((ax² + 2 ax t dx + t² dx² + ay² + 2 ay t dy + t² dy²) ** 1/2, 0, az + t dz)\r\n // f(t) = V((t² (dx² + dy²) + 2 t (ax dx + ay dy) + ax² + ay²) ** 1/2, 0, az + t * dz)\r\n // (anchorLC.xy + t * dirLC.xy) * dir.xy = 0\r\n // t * dirLC.xy² = -anchorLC.xy * dirLC.xy\r\n const closestTToZ = -anchorLC.xy().dot(dirLC.xy()) / dirLC.xy().squared();\r\n const closestPointToZ = L3.at(anchorLC, dirLC, closestTToZ);\r\n const scaleX = closestPointToZ.lengthXY();\r\n const lineGradientWC = dirLC.z / dirLC.lengthXY();\r\n const scaleZ = scaleX * lineGradientWC;\r\n const hc = HyperbolaCurve.XY.transform(M4.rotateX(90 * DEG)\r\n .scale(scaleX, 0, scaleZ)\r\n .translate(0, 0, closestPointToZ.z));\r\n const infos = hc.isInfosWithCurve(this.curve);\r\n return infos\r\n .map((info) => (info.p.z - anchorLC.z) / dirLC.z)\r\n .filter((t) => fuzzyBetween(L3.at(anchorLC, dirLC, t).angleXY(), this.uMin, this.uMax));\r\n }\r\n }\r\n isCurvesWithPlaneLC(planeLC) {\r\n if (planeLC.normal1.isParallelTo(V3.Z)) {\r\n return this.curve.isTsWithPlane(planeLC).map((t) => {\r\n const { x: radius } = this.curve.at(t);\r\n return new EllipseCurve(new V3(0, 0, planeLC.w), new V3(radius, 0, 0), new V3(0, radius, 0), this.uMin, this.uMax).transform(this.matrix);\r\n });\r\n }\r\n else if (planeLC.normal1.isPerpendicularTo(V3.Z) &&\r\n planeLC.containsPoint(V3.O)) {\r\n return [\r\n this.curve\r\n .rotateZ(V3.Y.angleRelativeNormal(planeLC.normal1, V3.Z))\r\n .transform(this.matrix),\r\n ];\r\n }\r\n return undefined;\r\n }\r\n isCurvesWithPlane(plane) {\r\n const planeLC = plane.transform(this.matrixInverse);\r\n const planeLCCurves = this.isCurvesWithPlaneLC(planeLC);\r\n if (planeLCCurves) {\r\n return planeLCCurves.map((curve) => curve.transform(this.matrix));\r\n }\r\n else {\r\n return ParametricSurface.isCurvesParametricImplicitSurface(this, new PlaneSurface(plane), 0.05, 0.05, 0.02);\r\n }\r\n }\r\n loopContainsPoint(loop, pWC) {\r\n const pLC = this.matrixInverse.transformPoint(pWC);\r\n const angle = EllipseCurve.XYLCPointT(pLC, this.uMin, this.uMax);\r\n const testCurveLC = EllipseCurve.semicircle(pLC.lengthXY(), new V3(0, 0, pLC.z));\r\n const testCurveWC = testCurveLC.transform(this.matrix);\r\n return Surface.loopContainsPointEllipse(loop, pWC, testCurveWC, angle);\r\n }\r\n isCoplanarTo(surface) {\r\n if (this === surface)\r\n return true;\r\n if (!hasConstructor(surface, RotatedCurveSurface))\r\n return false;\r\n const surfaceLCToThisLC = this.matrixInverse.times(surface.matrix);\r\n assert(!surfaceLCToThisLC.X.xy().likeO());\r\n const zRotation = surfaceLCToThisLC.X.angleXY();\r\n return surface.curve\r\n .transform(M4.rotateZ(-zRotation).times(surfaceLCToThisLC))\r\n .isColinearTo(this.curve);\r\n }\r\n isCurvesWithSurface(surface) {\r\n if (surface instanceof PlaneSurface) {\r\n return this.isCurvesWithPlane(surface.plane);\r\n }\r\n return super.isCurvesWithSurface(surface);\r\n }\r\n containsCurve(curve) {\r\n if (curve.constructor == this.curve.constructor) {\r\n const curveLC = curve.transform(this.matrixInverse);\r\n // find a point on curveLC which isn't on the Z-axis\r\n const t = withMax([0, 0.5, 1].map((x) => lerp(curveLC.tMin, curveLC.tMax, x)), (t) => curveLC.at(t).lengthXY());\r\n const angle = curveLC.at(t).angleXY();\r\n const curveLCRotated = curveLC.rotateZ(-angle);\r\n if (this.curve.isColinearTo(curveLCRotated)) {\r\n return true;\r\n }\r\n }\r\n if (curve instanceof EllipseCurve) {\r\n const curveLC = curve.transform(this.matrixInverse);\r\n if (curveLC.normal.isParallelTo(V3.Z)) {\r\n return (curveLC.isCircular() &&\r\n this.curve.containsPoint(new V3(curveLC.f1.length(), 0, curveLC.center.z)));\r\n }\r\n return false;\r\n }\r\n return super.containsCurve(curve);\r\n }\r\n getExtremePoints() {\r\n return getExtremePointsHelper.call(this, this.curve);\r\n }\r\n asNURBSSurface() {\r\n // y = 0 for baseNURBS\r\n const baseNURBS = NURBS.fromEllipse(this.curve);\r\n const rotationNURBS = NURBS.UnitCircle(2, this.vMin, this.vMax);\r\n return new NURBSSurface(rotationNURBS.points.flatMap((rv) => baseNURBS.points.map((b) => this.matrix.timesVector(VV(rv.x * b.x, rv.y * b.x, b.z * rv.w, rv.w * b.w)))), baseNURBS.knots, rotationNURBS.knots, baseNURBS.degree, rotationNURBS.degree, baseNURBS.tMin, baseNURBS.tMax, rotationNURBS.tMin, rotationNURBS.tMax);\r\n }\r\n}\r\nRotatedCurveSurface.prototype.uStep = EllipseCurve.prototype.tIncrement;\r\nexport function getExtremePointsHelper(curve) {\r\n // this logic comes from EllipseCurve.roots\r\n const f1 = this.matrix.X;\r\n const f2 = this.matrix.Y;\r\n return [0, 1, 2].flatMap((dim) => {\r\n const a = f2.e(dim);\r\n const b = -f1.e(dim);\r\n const xiEtas = eq0(a) && eq0(b) ? [[1, 0]] : intersectionUnitCircleLine2(a, b, 0);\r\n return xiEtas.flatMap(([xi, eta]) => {\r\n const u = Math.atan2(eta, xi);\r\n if (!(lt(this.uMin, u) && lt(u, this.uMax)))\r\n return [];\r\n const testCurve = curve.transform(this.matrix.times(M4.rotateZ(u)));\r\n return testCurve.roots()[dim].map((v) => this.pUV(u, v));\r\n });\r\n });\r\n}\r\n//# sourceMappingURL=RotatedCurveSurface.js.map","import { assert, assertInst, assertVectors, eq0, hasConstructor, M4, pqFormula, TAU, V3, } from \"ts3dutils\";\r\nimport { BezierCurve, EllipseCurve, L3, OUTSIDE, P3, ProjectedCurveSurface, Surface, } from \"..\";\r\nimport { sign } from \"../math\";\r\nexport class CylinderSurface extends ProjectedCurveSurface {\r\n // @ts-ignore\r\n // readonly baseCurve: EllipseCurve\r\n constructor(baseCurve, dir1, uMin = baseCurve.tMin, uMax = baseCurve.tMax, zMin = -Infinity, zMax = Infinity) {\r\n super(baseCurve, dir1, uMin, uMax, zMin, zMax);\r\n this.baseCurve = baseCurve;\r\n assertInst(EllipseCurve, baseCurve);\r\n //assert(!baseCurve.normal1.isPerpendicularTo(dir1), !baseCurve.normal1.isPerpendicularTo(dir1))\r\n this.matrix = M4.forSys(baseCurve.f1, baseCurve.f2, dir1, baseCurve.center);\r\n this.matrixInverse = this.matrix.inversed();\r\n this.normalDir = sign(this.baseCurve.normal.dot(this.dir));\r\n this.pLCNormalWCMatrix = this.matrix\r\n .as3x3()\r\n .inversed()\r\n .transposed()\r\n .scale(this.normalDir);\r\n this.pWCNormalWCMatrix = this.pLCNormalWCMatrix.times(this.matrixInverse);\r\n }\r\n static semicylinder(radius, sMin, sMax, tMin, tMax) {\r\n return new CylinderSurface(new EllipseCurve(V3.O, new V3(radius, 0, 0), new V3(0, radius, 0)), V3.Z, sMin, sMax, tMin, tMax);\r\n }\r\n /**\r\n *\r\n * @param anchorLC\r\n * @param dirLC not necessarily unit\r\n */\r\n static unitISLineTs(anchorLC, dirLC) {\r\n const { x: ax, y: ay } = anchorLC;\r\n const { x: dx, y: dy } = dirLC;\r\n // this cylinder: x² + y² = 1\r\n // line: p = anchorLC + t * dirLC\r\n // split line equation into 3 component equations, insert into cylinder equation\r\n // x = ax + t * dx\r\n // y = ay + t * dy\r\n // (ax² + 2 ax t dx + t²dx²) + (ay² + 2 ay t dy + t²dy²) = 1\r\n // transform to form (a t² + b t + c = 0) and solve with pqFormula\r\n const a = Math.pow(dx, 2) + Math.pow(dy, 2);\r\n const b = 2 * (ax * dx + ay * dy);\r\n const c = Math.pow(ax, 2) + Math.pow(ay, 2) - 1;\r\n return pqFormula(b / a, c / a).filter((t) => EllipseCurve.XYLCValid(new V3(ax + dx * t, ay + dy * t, 0)));\r\n }\r\n normalP(p) {\r\n return this.pLCNormalWCMatrix\r\n .transformVector(this.matrixInverse.transformPoint(p).xy())\r\n .unit();\r\n }\r\n loopContainsPoint(loop, p) {\r\n assertVectors(p);\r\n if (!this.containsPoint(p))\r\n return OUTSIDE;\r\n const line = new L3(p, this.dir.unit());\r\n const lineOut = this.dir.cross(this.normalP(p));\r\n return Surface.loopContainsPointGeneral(loop, p, line, lineOut);\r\n }\r\n isTsForLine(line) {\r\n assertInst(L3, line);\r\n // transforming line manually has advantage that dir1 will not be renormalized,\r\n // meaning that calculated values t for localLine are directly transferable to line\r\n const dirLC = this.matrixInverse.transformVector(line.dir1);\r\n if (dirLC.isParallelTo(V3.Z)) {\r\n // line is parallel to this.dir\r\n return [];\r\n }\r\n const anchorLC = this.matrixInverse.transformPoint(line.anchor);\r\n assert(!CylinderSurface.unitISLineTs(anchorLC, dirLC).length ||\r\n !isNaN(CylinderSurface.unitISLineTs(anchorLC, dirLC)[0]), \"sad \" + dirLC);\r\n return CylinderSurface.unitISLineTs(anchorLC, dirLC);\r\n }\r\n isCoplanarTo(surface) {\r\n return (this == surface ||\r\n (hasConstructor(surface, CylinderSurface) &&\r\n this.dir.isParallelTo(surface.dir) &&\r\n this.containsEllipse(surface.baseCurve, false)));\r\n }\r\n like(surface) {\r\n if (!this.isCoplanarTo(surface))\r\n return false;\r\n // normals need to point in the same direction (outwards or inwards) for both\r\n const thisFacesOut = 0 < this.baseCurve.normal.dot(this.dir);\r\n const objectFacesOut = 0 < surface.baseCurve.normal.dot(surface.dir);\r\n return thisFacesOut == objectFacesOut;\r\n }\r\n containsEllipse(ellipse, checkAABB = true) {\r\n const projEllipse = ellipse.transform(M4.project(this.baseCurve.getPlane(), this.dir));\r\n return this.baseCurve == ellipse || this.baseCurve.isColinearTo(projEllipse);\r\n }\r\n containsCurve(curve) {\r\n if (curve instanceof L3) {\r\n return this.containsLine(curve);\r\n }\r\n else if (curve instanceof EllipseCurve) {\r\n return this.containsEllipse(curve);\r\n }\r\n else if (curve instanceof BezierCurve) {\r\n return false;\r\n }\r\n else {\r\n return super.containsCurve(curve);\r\n }\r\n }\r\n implicitFunction() {\r\n return (pWC) => {\r\n const pLC = this.matrixInverse.transformPoint(pWC);\r\n return (pLC.lengthXY() - 1) * this.normalDir;\r\n };\r\n }\r\n didp(pWC) {\r\n const pLC = this.matrixInverse.transformPoint(pWC);\r\n const pLCLengthXY = pLC.lengthXY();\r\n const didpLC = new V3(pLC.x / pLCLengthXY, pLC.y / pLCLengthXY, 0);\r\n return this.pLCNormalWCMatrix.transformVector(didpLC);\r\n }\r\n containsPoint(pWC) {\r\n const pLC = this.matrixInverse.transformPoint(pWC);\r\n return this.baseCurve.isValidT(EllipseCurve.XYLCPointT(pLC, this.uMin, this.uMax));\r\n }\r\n uvP(pWC) {\r\n assert(arguments.length == 1);\r\n const pLC = this.matrixInverse.transformPoint(pWC);\r\n const u = EllipseCurve.XYLCPointT(pLC, this.vMin, this.vMax);\r\n return new V3(u, pLC.z, 0);\r\n }\r\n isCurvesWithSurface(surface2) {\r\n if (surface2 instanceof ProjectedCurveSurface) {\r\n if (surface2.dir.isParallelTo(this.dir)) {\r\n const projectedCurve = surface2.baseCurve.transform(M4.project(this.baseCurve.getPlane(), this.dir));\r\n return this.baseCurve.isInfosWithCurve(projectedCurve).map((info) => {\r\n const lineDir = sign(this.normalP(info.p)\r\n .cross(surface2.normalP(info.p))\r\n .dot(this.dir)) || 1;\r\n return new L3(info.p, this.dir.times(lineDir));\r\n });\r\n }\r\n }\r\n if (surface2 instanceof CylinderSurface) {\r\n if (eq0(this.getCenterLine().distanceToLine(surface2.getCenterLine()))) {\r\n throw new Error();\r\n }\r\n }\r\n return super.isCurvesWithSurface(surface2);\r\n }\r\n getCenterLine() {\r\n return new L3(this.baseCurve.center, this.dir);\r\n }\r\n facesOutwards() {\r\n return this.baseCurve.normal.dot(this.dir) > 0;\r\n }\r\n getSeamPlane() {\r\n let normal = this.baseCurve.f1.cross(this.dir);\r\n normal = normal.times(-sign(normal.dot(this.baseCurve.f2)));\r\n return P3.normalOnAnchor(normal, this.baseCurve.center);\r\n }\r\n clipCurves(curves) {\r\n return curves.flatMap((curve) => curve.clipPlane(this.getSeamPlane()));\r\n }\r\n}\r\nCylinderSurface.UNIT = new CylinderSurface(EllipseCurve.UNIT, V3.Z, undefined, undefined, 0, 1);\r\nCylinderSurface.prototype.uStep = TAU / 32;\r\nCylinderSurface.prototype.vStep = 256;\r\n//# sourceMappingURL=CylinderSurface.js.map","import { arrayFromFunction, assert, assertf, assertInst, assertNumbers, assertVectors, between, checkDerivate, clamp, eq, eq0, fuzzyBetween, gaussLegendreQuadrature24, getIntervals, getRoots, glqInSteps, hasConstructor, le, lt, M4, MINUS, newtonIterate, NLA_PRECISION, pqFormula, snap, sum, toSource, V, V3, } from \"ts3dutils\";\r\nimport { CylinderSurface, Edge, EllipseCurve, getExtremePointsHelper, L3, P3, ParametricSurface, PICurve, PlaneSurface, PointVsFace, ProjectedCurveSurface, Surface, } from \"..\";\r\nimport { abs, cos, max, min, PI, sign, sin, sqrt } from \"../math\";\r\nclass ArrayExt {\r\n}\r\nexport class EllipsoidSurface extends ParametricSurface {\r\n constructor(center, f1, f2, f3, uMin = 0, uMax = PI, vMin = -PI / 2, vMax = PI / 2) {\r\n super(uMin, uMax, vMin, vMax);\r\n this.center = center;\r\n this.f1 = f1;\r\n this.f2 = f2;\r\n this.f3 = f3;\r\n assert(0 <= uMin && uMin <= PI, uMin);\r\n assert(0 <= uMax && uMax <= PI, uMax);\r\n assert(-PI / 2 <= vMin && vMin <= PI / 2);\r\n assert(-PI / 2 <= vMax && vMax <= PI / 2);\r\n assertVectors(center, f1, f2, f3);\r\n this.matrix = M4.forSys(f1, f2, f3, center);\r\n this.matrixInverse = this.matrix.inversed();\r\n this.normalDir = sign(this.f1.cross(this.f2).dot(this.f3));\r\n this.pLCNormalWCMatrix = this.matrix\r\n .as3x3()\r\n .inversed()\r\n .transposed()\r\n .scale(this.normalDir);\r\n this.pWCNormalWCMatrix = this.pLCNormalWCMatrix.times(this.matrixInverse);\r\n }\r\n static unitArea(contour) {\r\n const totalArea = sum(contour.map((edge) => {\r\n if (edge.curve instanceof PICurve) {\r\n const points = edge.curve.calcSegmentPoints(edge.aT, edge.bT, edge.a, edge.b, edge.aT > edge.bT, true);\r\n let sum = 0;\r\n for (let i = 0; i < points.length - 1; i++) {\r\n const p = points[i], ppp = points[i + 1];\r\n sum += ((abs(p.angleXY()) + abs(ppp.angleXY())) / 2) * (ppp.z - p.z);\r\n }\r\n return sum;\r\n }\r\n else if (edge.curve instanceof EllipseCurve) {\r\n const f = (t) => {\r\n const at = edge.curve.at(t), tangent = edge.curve.tangentAt(t);\r\n const angleXY = abs(at.angleXY());\r\n //const arcLength = angleXY * Math.sqrt(1 - at.z ** 2) ( == at.lengthXY())\r\n //const scaling = tangent.z / at.lengthXY()\r\n return angleXY * tangent.z;\r\n };\r\n const val = glqInSteps(f, edge.aT, edge.bT, 1);\r\n return val;\r\n }\r\n else {\r\n throw new Error();\r\n }\r\n }));\r\n return totalArea;\r\n }\r\n /**\r\n * unit sphere: x² + y² + z² = 1\r\n * line: p = anchor + t * dir |^2\r\n * p² = (anchor + t * dir)^2\r\n * 1 == (anchor + t * dir)^2\r\n * 1 == anchor DOT anchor + 2 * anchor * t * dir + t² * dir DOT dir\r\n */\r\n static unitISTsWithLine(anchor, dir) {\r\n // for 0 = a t² + b t + c\r\n const a = dir.dot(dir);\r\n const b = 2 * anchor.dot(dir);\r\n const c = anchor.dot(anchor) - 1;\r\n return pqFormula(b / a, c / a).filter((t) => le(0, anchor.y + t * dir.y));\r\n }\r\n /**\r\n * unit sphere: x² + y² + z² = 1\r\n * plane: normal1 DOT p = w\r\n */\r\n static unitISCurvesWithPlane(plane) {\r\n const distPlaneCenter = Math.abs(plane.w);\r\n if (lt(distPlaneCenter, 1)) {\r\n // result is a circle\r\n // radius of circle: imagine right angled triangle (origin -> center of intersection circle -> point on\r\n // intersection circle) pythagoras: 1² == distPlaneCenter² + isCircleRadius² => isCircleRadius == sqrt(1 -\r\n // distPlaneCenter²)\r\n const isCircleRadius = Math.sqrt(1 - Math.pow(distPlaneCenter, 2));\r\n const anchorY = plane.normal1.y * plane.w;\r\n const d = abs(distPlaneCenter * isCircleRadius);\r\n if (le(anchorY, -d) && !eq0(distPlaneCenter)) {\r\n return [];\r\n }\r\n else if (le(anchorY, 0) && !plane.normal1.isParallelTo(V3.Y)) {\r\n const f1 = plane.normal1.isParallelTo(V3.Y)\r\n ? V3.Z\r\n : plane.normal1.cross(V3.Y).toLength(isCircleRadius);\r\n const f2 = f1.cross(plane.normal1);\r\n const minEta = -anchorY / f2.y, minT = max(0, Math.asin(minEta));\r\n return [new EllipseCurve(plane.anchor, f1, f2, minT, PI - minT)];\r\n }\r\n else {\r\n const f2 = (plane.normal1.isParallelTo(V3.Y)\r\n ? V3.X\r\n : plane.normal1.cross(V3.Y)).toLength(isCircleRadius);\r\n const f1 = f2.cross(plane.normal1);\r\n const minXi = eq0(f1.y) ? -1 : -anchorY / f1.y, maxT = Math.acos(max(-1, minXi - NLA_PRECISION));\r\n return [\r\n new EllipseCurve(plane.anchor, f1.negated(), f2, PI - maxT, PI),\r\n new EllipseCurve(plane.anchor, f1, f2.negated(), 0, maxT),\r\n ];\r\n }\r\n }\r\n else {\r\n return [];\r\n }\r\n }\r\n static unitISCurvesWithEllipsoidSurface(surface) {\r\n if (surface.isSphere()) {\r\n const surfaceRadius = surface.f1.length();\r\n const surfaceCenterDist = surface.center.length();\r\n if (le(1, surfaceCenterDist - surfaceRadius) ||\r\n le(surfaceCenterDist + surfaceRadius, 1) ||\r\n le(surfaceCenterDist - surfaceRadius, -1)) {\r\n return [];\r\n }\r\n else {\r\n // origin, surface.center and points on the intersection curves form a triangle.\r\n // the height on the segment origin - surface.center is the radius of the is curves\r\n // the distance from the origin to the lot point is the distance to the intersection plane\r\n function heron(a, b, c) {\r\n const p = (a + b + c) / 2;\r\n return sqrt(p * (p - a) * (p - b) * (p - c));\r\n }\r\n const triangleArea = heron(1, surfaceRadius, surfaceCenterDist);\r\n const radius = (triangleArea * 2) / surfaceCenterDist;\r\n const isCurvesCenterDist = sign(1 + Math.pow(surfaceCenterDist, 2) - Math.pow(surfaceRadius, 2)) *\r\n sqrt(1 - Math.pow(radius, 2));\r\n const plane = new P3(surface.center.unit(), isCurvesCenterDist);\r\n return EllipsoidSurface.unitISCurvesWithPlane(plane.flipped());\r\n }\r\n }\r\n throw new Error();\r\n }\r\n static unitISCurvesWithCylinderSurface(surface) {\r\n if (new L3(surface.baseCurve.center, surface.dir).containsPoint(V3.O)) {\r\n const projEllipse = surface.baseCurve.transform(M4.project(new P3(surface.dir, 0)));\r\n const f1Length = projEllipse.f1.length(), f2Length = projEllipse.f2.length();\r\n if (lt(1, min(f1Length, f2Length)))\r\n return [];\r\n if (projEllipse.isCircular()) {\r\n const distISCurveCenter = Math.sqrt(1 - Math.pow(min(1, f1Length), 2));\r\n const isCurveCenter = (surface.dir.y < 0\r\n ? surface.dir.negated()\r\n : surface.dir).times(distISCurveCenter);\r\n // isCurve.at(t).y = isCurveCenter.y + projEllipse.f1.y * cos(t) + projEllipse.f2.y * sin(t) = 0\r\n return [new EllipseCurve(isCurveCenter, projEllipse.f1, projEllipse.f2)];\r\n }\r\n }\r\n throw new Error();\r\n }\r\n static sphere(radius, center = V3.O) {\r\n assertNumbers(radius);\r\n return new EllipsoidSurface(center, new V3(radius, 0, 0), new V3(0, radius, 0), new V3(0, 0, radius));\r\n }\r\n /**\r\n * x²/a² + y²/b² + z²/c² = 1\r\n */\r\n static forABC(a, b, c, center = V3.O) {\r\n return new EllipsoidSurface(center, new V3(a, 0, 0), new V3(0, b, 0), new V3(0, 0, c));\r\n }\r\n static calculateAreaSpheroid(a, b, c, edges) {\r\n assertf(() => a.isPerpendicularTo(b));\r\n assertf(() => b.isPerpendicularTo(c));\r\n assertf(() => c.isPerpendicularTo(a));\r\n // handling discontinuities:\r\n // option 1: check for intersections with baseline, if there are any integrate parts separetely\r\n // \"rotate\" the edge so that there are no overlaps\r\n const matrix = M4.forSys(a, b, c), matrixInverse = matrix.inversed();\r\n const circleRadius = a.length();\r\n const c1 = c.unit();\r\n const totalArea = sum(edges.map((edge) => {\r\n if (edge.curve instanceof EllipseCurve) {\r\n const f = (t) => {\r\n const at = edge.curve.at(t), tangent = edge.tangentAt(t);\r\n const localAt = matrixInverse.transformPoint(at);\r\n const angleXY = localAt.angleXY();\r\n const arcLength = angleXY * circleRadius * Math.sqrt(1 + Math.pow(localAt.z, 2));\r\n const scaling = Math.sqrt(1 + Math.pow(c1.dot(tangent), 2));\r\n return arcLength * scaling;\r\n };\r\n const val = glqInSteps(f, edge.aT, edge.bT, 1);\r\n return val;\r\n }\r\n else {\r\n throw new Error();\r\n }\r\n }));\r\n return totalArea;\r\n }\r\n getConstructorParameters() {\r\n return [\r\n this.center,\r\n this.f1,\r\n this.f2,\r\n this.f3,\r\n this.uMin,\r\n this.uMax,\r\n this.vMin,\r\n this.vMax,\r\n ];\r\n }\r\n equals(obj) {\r\n return (this == obj ||\r\n (Object.getPrototypeOf(obj) == this.constructor.prototype &&\r\n this.matrix.equals(obj.matrix)));\r\n }\r\n edgeLoopCCW(loop) {\r\n return (EllipsoidSurface.unitArea(loop.map((edge) => edge.transform(this.matrixInverse))) > 0);\r\n //let totalAngle = 0\r\n //for (let i = 0; i < contour.length; i++) {\r\n // const ipp = (i + 1) % contour.length\r\n // const edge = contour[i], nextEdge = contour[ipp]\r\n // totalAngle += edge.bDir.angleRelativeNormal(nextEdge.aDir, this.normalP(edge.b))\r\n //}\r\n //return le(0, totalAngle)\r\n }\r\n like(object) {\r\n if (!this.isCoplanarTo(object))\r\n return false;\r\n // normals need to point in the same direction (outwards or inwards) for both\r\n return this.matrix.determinant3() * object.matrix.determinant3() > 0;\r\n }\r\n rootPoints() { }\r\n toMesh() {\r\n return ParametricSurface.prototype.toMesh.call(this);\r\n }\r\n clipCurves(curves) {\r\n return curves.flatMap((curve) => curve.clipPlane(this.getSeamPlane()));\r\n }\r\n dpdu() {\r\n // dp(u, v) = new V3(cos(t) * cos(s), cos(t) * sin(s), sin(t)\r\n return (u, v) => this.matrix.transformVector(new V3(cos(v) * -sin(u), cos(v) * cos(u), 0));\r\n }\r\n dpdv() {\r\n return (u, v) => this.matrix.transformVector(new V3(-sin(v) * cos(u), -sin(v) * sin(u), cos(v)));\r\n }\r\n isCurvesWithPCS(surface) {\r\n let curves2 = ParametricSurface.isCurvesParametricImplicitSurface(surface, this, 0.1, 0.1 / surface.dir.length(), 0.05);\r\n curves2 = this.clipCurves(curves2);\r\n return curves2;\r\n }\r\n isCurvesWithPCSSmart(surface) {\r\n const surfaceLC = surface.transform(this.matrixInverse);\r\n //const lcMinZ0RelO =\r\n const baseCurveLC = surfaceLC.baseCurve.project(new P3(surfaceLC.dir, 0));\r\n const ists = baseCurveLC.isTsWithSurface(EllipsoidSurface.UNIT);\r\n const insideIntervals = getIntervals(ists, baseCurveLC.tMin, baseCurveLC.tMax).filter(([a, b]) => baseCurveLC.at((a + b) / 2).length() < 1);\r\n const projectedCurves = [0, 1].map((id) => {\r\n return (t) => {\r\n const atSqr = snap(baseCurveLC.at(t).squared(), 1);\r\n const lineISTs = /* +- */ sqrt(1 - atSqr);\r\n //assert(!isNaN(lineISTs))\r\n return eq0(lineISTs)\r\n ? baseCurveLC.at(t)\r\n : baseCurveLC\r\n .at(t)\r\n .plus(surfaceLC.dir.times(sign(id - 0.5) * lineISTs));\r\n };\r\n });\r\n const dProjectedCurves = [0, 1].map((id) => {\r\n return (t) => {\r\n // d/dt sqrt(1 - baseCurveLC.at(t).squared())\r\n // = -1/2 * 1/sqrt(1 - baseCurveLC.at(t).squared()) * -2*baseCurveLC.at(t) * baseCurveLC.tangentAt(t)\r\n const atSqr = snap(baseCurveLC.at(t).squared(), 1);\r\n const lineISTs = /* +- */ baseCurveLC\r\n .at(t)\r\n .times(-1 / sqrt(1 - atSqr))\r\n .dot(baseCurveLC.tangentAt(t));\r\n //assert(!isNaN(lineISTs))\r\n return baseCurveLC\r\n .tangentAt(t)\r\n .plus(surfaceLC.dir.times(sign(id - 0.5) * lineISTs));\r\n };\r\n });\r\n //const f2 = t => sqrt(1 - baseCurveLC.at(t).squared())\r\n //const df2 = t => baseCurveLC.at(t).times(-1 / sqrt(1 -\r\n // baseCurveLC.at(t).squared())).dot(baseCurveLC.tangentAt(t)) checkDerivate(f2, df2, 0.31, 0.60)\r\n const curves = [];\r\n for (const [aT, bT] of insideIntervals) {\r\n //const aLine = new L3(baseCurveLC.at(aT), surfaceLC.dir1)\r\n //const a = EllipsoidSurface.UNIT.isTsForLine(aLine).map(t => aLine.at(t))\r\n //const bLine = new L3(baseCurveLC.at(bT), surfaceLC.dir1)\r\n //const b = EllipsoidSurface.UNIT.isTsForLine(bLine).map(t => bLine.at(t))\r\n for (const i of [0, 1]) {\r\n const f = (t) => projectedCurves[i](t).y;\r\n const df = (t) => dProjectedCurves[i](t).y;\r\n checkDerivate(f, df, aT + 0.1, bT - 0.1);\r\n const tsAtY0 = getRoots(f, aT + NLA_PRECISION, bT - NLA_PRECISION, 1 / (1 << 11), df);\r\n const ii2 = getIntervals(tsAtY0, aT, bT).filter(([a, b]) => f((a + b) / 2) > 0);\r\n for (const [aT2, bT2] of ii2) {\r\n let aP = projectedCurves[i](aT2), bP = projectedCurves[i](bT2);\r\n 0 === i && ([aP, bP] = [bP, aP]);\r\n assert(EllipsoidSurface.UNIT.containsPoint(aP));\r\n assert(EllipsoidSurface.UNIT.containsPoint(bP));\r\n curves.push(PICurve.forStartEnd(surface, this, this.matrix.transformPoint(bP), this.matrix.transformPoint(aP), undefined));\r\n }\r\n }\r\n }\r\n return surface.clipCurves(curves);\r\n }\r\n isCurvesWithSurface(surface) {\r\n if (surface instanceof PlaneSurface) {\r\n return this.isCurvesWithPlane(surface.plane);\r\n }\r\n else if (surface instanceof CylinderSurface) {\r\n return this.isCurvesWithCylinderSurface(surface);\r\n }\r\n else if (surface instanceof EllipsoidSurface) {\r\n const surfaceLC = surface.transform(this.matrixInverse);\r\n const curves = EllipsoidSurface.unitISCurvesWithEllipsoidSurface(surfaceLC).map((c) => c.transform(this.matrix));\r\n return surface.clipCurves(curves);\r\n }\r\n else if (surface instanceof ProjectedCurveSurface) {\r\n return this.isCurvesWithPCS(surface);\r\n }\r\n else if (surface instanceof ParametricSurface) {\r\n let curves2 = ParametricSurface.isCurvesParametricImplicitSurface(surface, this, 0.1, 0.1, 0.05);\r\n curves2 = this.clipCurves(curves2);\r\n curves2 = surface.clipCurves(curves2);\r\n return curves2;\r\n }\r\n else {\r\n throw new Error();\r\n }\r\n }\r\n isCurvesWithPlane(plane) {\r\n const planeLC = plane.transform(this.matrixInverse);\r\n return EllipsoidSurface.unitISCurvesWithPlane(planeLC).map((c) => c.transform(this.matrix));\r\n }\r\n isCurvesWithCylinderSurface(surface) {\r\n if (L3.containsPoint(surface.baseCurve.center, surface.dir, this.center)) {\r\n assert(this.isSphere());\r\n const ellipseProjected = surface.baseCurve.transform(M4.project(surface.baseCurve.getPlane(), surface.dir));\r\n if (ellipseProjected.isCircular()) {\r\n const thisRadius = this.f1.length();\r\n const surfaceRadius = ellipseProjected.f1.length();\r\n // sphereRadius² = distanceISFromCenter² + isRadius²\r\n if (eq(thisRadius, surfaceRadius)) {\r\n // return\r\n }\r\n else if (surfaceRadius < thisRadius) {\r\n }\r\n assert(false);\r\n }\r\n }\r\n return this.isCurvesWithPCS(surface);\r\n }\r\n isTsForLine(line) {\r\n assertInst(L3, line);\r\n // transforming line manually has advantage that dir1 will not be renormalized,\r\n // meaning that calculated values t for localLine are directly transferable to line\r\n const anchorLC = this.matrixInverse.transformPoint(line.anchor);\r\n const dirLC = this.matrixInverse.transformVector(line.dir1);\r\n return EllipsoidSurface.unitISTsWithLine(anchorLC, dirLC);\r\n }\r\n isCoplanarTo(surface) {\r\n if (this === surface)\r\n return true;\r\n if (!hasConstructor(surface, EllipsoidSurface))\r\n return false;\r\n if (!this.center.like(surface.center))\r\n return false;\r\n if (this.isSphere())\r\n return surface.isSphere() && eq(this.f1.length(), this.f2.length());\r\n const otherMatrixLC = this.matrixInverse.times(surface.matrix);\r\n // Ellipsoid with matrix otherMatrixLC is unit sphere iff otherMatrixLC is orthogonal\r\n return otherMatrixLC.like3x3() && otherMatrixLC.isOrthogonal();\r\n }\r\n containsEllipse(ellipse) {\r\n const ellipseLC = ellipse.transform(this.matrixInverse);\r\n const distEllipseLCCenter = ellipseLC.center.length();\r\n const correctRadius = Math.sqrt(1 - Math.pow(distEllipseLCCenter, 2));\r\n return (lt(distEllipseLCCenter, 1) &&\r\n ellipseLC.isCircular() &&\r\n ellipseLC.f1.hasLength(correctRadius));\r\n //&& le(0, ellipseLC.getAABB().min.y)\r\n }\r\n containsCurve(curve) {\r\n if (curve instanceof EllipseCurve) {\r\n return this.containsEllipse(curve);\r\n }\r\n else {\r\n return super.containsCurve(curve);\r\n }\r\n }\r\n transform(m4) {\r\n assert(m4.isNoProj(), () => m4.sce);\r\n return new EllipsoidSurface(m4.transformPoint(this.center), m4.transformVector(this.f1), m4.transformVector(this.f2), m4.transformVector(this.f3).times(m4.isMirroring() ? -1 : 1));\r\n }\r\n transform4(m4) {\r\n console.log(\"transform4\");\r\n const resultMatrix = m4.times(this.matrix);\r\n console.log(resultMatrix.toString());\r\n const scaleDir = V(resultMatrix.m[12], resultMatrix.m[13], resultMatrix.m[14]);\r\n // need to find parameters where scaleDir is parallel to the normal\r\n const pLC = this.pLCNormalWCMatrix.inversed().transformPoint(scaleDir);\r\n const s = pLC.angleXY();\r\n const t = Math.asin(clamp(pLC.z, -1, 1));\r\n const fa = resultMatrix.transformPoint(scaleDir.unit());\r\n const fb = resultMatrix.transformPoint(scaleDir.unit().negated());\r\n const newCenter = V3.lerp(fa, fb, 0.5);\r\n console.log(scaleDir.sce, s, t, fa, fb, \"newCenter\", newCenter.sce);\r\n return new EllipsoidSurface(newCenter, m4.transformVector2(this.f1, this.center), m4.transformVector2(this.f2, this.center), m4\r\n .transformVector2(this.f3, this.center)\r\n .times(m4.isMirroring() ? -1 : 1));\r\n }\r\n isInsideOut() {\r\n return this.f1.cross(this.f2).dot(this.f3) < 0;\r\n }\r\n flipped() {\r\n return new EllipsoidSurface(this.center, this.f1, this.f2, this.f3.negated(), this.uMin, this.uMax, -this.vMax, -this.vMin);\r\n }\r\n normalUVFunc() {\r\n // ugh\r\n // paramtric ellipsoid point q(a, b)\r\n // normal1 == (dq(a, b) / da) X (dq(a, b) / db) (cross product of partial derivatives)\r\n // normal1 == cos b * (f2 X f3 * cos b * cos a + f3 X f1 * cos b * sin a + f1 X f2 * sin b)\r\n return (a, b) => {\r\n const { f1, f2, f3 } = this;\r\n const normal = f2\r\n .cross(f3)\r\n .times(Math.cos(b) * Math.cos(a))\r\n .plus(f3.cross(f1).times(Math.cos(b) * Math.sin(a)))\r\n .plus(f1.cross(f2).times(Math.sin(b)))\r\n //.times(Math.cos(b))\r\n .unit();\r\n return normal;\r\n };\r\n }\r\n normalP(p) {\r\n return this.pLCNormalWCMatrix\r\n .transformVector(this.matrixInverse.transformPoint(p))\r\n .unit();\r\n }\r\n normalUV(u, v) {\r\n return this.pLCNormalWCMatrix.transformVector(V3.sphere(u, v)).unit();\r\n }\r\n uvPFunc() {\r\n return (pWC) => {\r\n const pLC = this.matrixInverse.transformPoint(pWC);\r\n const alpha = abs(pLC.angleXY());\r\n const beta = Math.asin(clamp(pLC.z, -1, 1));\r\n assert(isFinite(alpha));\r\n assert(isFinite(beta));\r\n return new V3(alpha, beta, 0);\r\n };\r\n }\r\n pUVFunc() {\r\n // this(a, b) = f1 cos a cos b + f2 sin a cos b + f2 sin b\r\n return (alpha, beta) => {\r\n return this.matrix.transformPoint(V3.sphere(alpha, beta));\r\n };\r\n }\r\n isSphere() {\r\n return (eq(this.f1.length(), this.f2.length()) &&\r\n eq(this.f2.length(), this.f3.length()) &&\r\n eq(this.f3.length(), this.f1.length()) &&\r\n this.f1.isPerpendicularTo(this.f2) &&\r\n this.f2.isPerpendicularTo(this.f3) &&\r\n this.f3.isPerpendicularTo(this.f1));\r\n }\r\n isVerticalSpheroid() {\r\n return (eq(this.f1.length(), this.f2.length()) &&\r\n this.f1.isPerpendicularTo(this.f2) &&\r\n this.f2.isPerpendicularTo(this.f3) &&\r\n this.f3.isPerpendicularTo(this.f1));\r\n }\r\n mainAxes() {\r\n // q(a, b) = f1 cos a cos b + f2 sin a cos b + f3 sin b\r\n // q(s, t, u) = s * f1 + t * f2 + u * f3 with s² + t² + u² = 1\r\n // (del q(a, b) / del a) = f1 (-sin a) cos b + f2 cos a cos b\r\n // (del q(a, b) / del b) = f1 cos a (-sin b) + f2 sin a (-sin b) + f2 cos b\r\n // del q(s, t, u) / del a = -t f1 + s f2\r\n // (del q(a, b) / del a) DOT q(a, b) == 0\r\n // (f1 (-sin a) cos b + f2 cos a cos b) DOT (f1 cos a cos b + f2 sin a cos b + f2 sin b) == 0\r\n // (del q(a, b) / del b) DOT q(a, b) == 0\r\n // (f1 cos a (-sin b) + f2 sin a (-sin b) + f2 cos b) DOT (f1 cos a cos b + f2 sin a cos b + f2 sin b) == 0\r\n // Solve[\r\n // (f1 (-sin a) cos b + f2 cos a cos b) * (f1 cos a cos b + f2 sin a cos b + f2 sin b) = 0,\r\n // (f1 cos a (-sin b) + f2 sin a (-sin b) + f2 cos b) * (f1 cos a cos b + f2 sin a cos b + f2 sin b) = 0}, a, b]\r\n const { f1, f2, f3 } = this;\r\n if (eq0(f1.dot(f2)) && eq0(f2.dot(f3)) && eq0(f3.dot(f1))) {\r\n return this;\r\n }\r\n //const f = ([a, b], x?) => {\r\n // const sinA = Math.sin(a), cosA = Math.cos(a), sinB = Math.sin(b), cosB = Math.cos(b)\r\n // const centerToP = V3.add(f1.times(cosA * cosB), f2.times(sinA * cosB), f3.times(sinB))\r\n // const centerToPdelA = f1.times(-sinA * cosB).plus(f2.times(cosA * cosB))\r\n // const centerToPdelB = V3.add(f1.times(cosA * -sinB), f2.times(sinA * -sinB), f3.times(cosB))\r\n // x && console.log(centerToP.sce, centerToPdelA.sce, centerToPdelB.sce)\r\n // return [centerToP.dot(centerToPdelA), centerToP.dot(centerToPdelB)]\r\n //}\r\n //const mainF1Params = newtonIterate(f, [0, 0], 8), mainF1 = this.pUVFunc()(mainF1Params[0], mainF1Params[1])\r\n //console.log(f(mainF1Params, 1).sce)\r\n //const mainF2Params = newtonIterate(f, this.uvPFunc()(f2.rejectedFrom(mainF1)).toArray(2), 8),\r\n // mainF2 = this.pUVFunc()(mainF2Params[0], mainF2Params[1])\r\n //console.log(this.normalUVFunc()(mainF2Params[0], mainF2Params[1]).sce)\r\n //assert(mainF1.isPerpendicularTo(mainF2), mainF1, mainF2, mainF1.dot(mainF2), mainF1Params)\r\n //const mainF3Params = this.uvPFunc()(mainF1.cross(mainF2)), mainF3 = this.pUVFunc()(mainF3Params[0],\r\n // mainF3Params[1]) return new EllipsoidSurface(this.center, mainF1, mainF2, mainF3)\r\n const { U, SIGMA } = this.matrix.svd3();\r\n assert(SIGMA.isDiagonal());\r\n assert(U.isOrthogonal());\r\n const U_SIGMA = U.times(SIGMA);\r\n // column vectors of U_SIGMA\r\n const [mainF1, mainF2, mainF3] = arrayFromFunction(3, (i) => new V3(U_SIGMA.m[i], U_SIGMA.m[i + 4], U_SIGMA.m[i + 8]));\r\n return new EllipsoidSurface(this.center, mainF1, mainF2, mainF3);\r\n }\r\n containsPoint(p) {\r\n return eq0(this.implicitFunction()(p));\r\n }\r\n boundsFunction() {\r\n return (a, b) => between(a, 0, PI) && between(b, -PI, PI);\r\n }\r\n volume() {\r\n return (4 / 3) * Math.PI * this.f1.dot(this.f2.cross(this.f3));\r\n }\r\n loopContainsPoint(loop, pWC) {\r\n if (!this.containsPoint(pWC))\r\n return PointVsFace.OUTSIDE;\r\n assertVectors(pWC);\r\n assert(Edge.isLoop(loop));\r\n const pLCXY = this.matrixInverse.transformPoint(pWC).xy();\r\n const testLine = new EllipseCurve(this.center, this.f3, pLCXY.likeO() ? this.f2 : this.matrix.transformVector(pLCXY.unit()));\r\n if (P3.normalOnAnchor(this.f2.unit(), this.center).containsPoint(pWC)) {\r\n return loop.some((edge) => edge.curve.containsPoint(pWC) &&\r\n fuzzyBetween(edge.curve.pointT(pWC), edge.minT, edge.maxT))\r\n ? PointVsFace.ON_EDGE\r\n : PointVsFace.OUTSIDE;\r\n }\r\n return Surface.loopContainsPointEllipse(loop, pWC, testLine);\r\n }\r\n surfaceAreaApprox() {\r\n // See https://en.wikipedia.org/wiki/Ellipsoid#Surface_area\r\n const mainAxes = this.mainAxes(), a = mainAxes.f1.length(), b = mainAxes.f2.length(), c = mainAxes.f3.length();\r\n const p = 1.6075;\r\n return (4 *\r\n PI *\r\n Math.pow((Math.pow(a * b, p) + Math.pow(b * c, p) + Math.pow(c * a, p)) / 3, 1 / p));\r\n }\r\n surfaceArea() {\r\n // See https://en.wikipedia.org/wiki/Ellipsoid#Surface_area\r\n const mainAxes = this.mainAxes(), f1l = mainAxes.f1.length(), f2l = mainAxes.f2.length(), f3l = mainAxes.f3.length(), [c, b, a] = [f1l, f2l, f3l].sort(MINUS);\r\n // https://en.wikipedia.org/w/index.php?title=Spheroid&oldid=761246800#Area\r\n function spheroidArea(a, c) {\r\n if (c < a) {\r\n const eccentricity2 = 1 - Math.pow(c, 2) / Math.pow(a, 2);\r\n const eccentricity = Math.sqrt(eccentricity2);\r\n return (2 *\r\n PI *\r\n Math.pow(a, 2) *\r\n (1 +\r\n ((1 - eccentricity2) / Math.sqrt(eccentricity)) *\r\n Math.atanh(eccentricity)));\r\n }\r\n else {\r\n const eccentricity = Math.sqrt(1 - Math.pow(a, 2) / Math.pow(c, 2));\r\n return (2 *\r\n PI *\r\n Math.pow(a, 2) *\r\n (1 + (c / a / eccentricity) * Math.asin(eccentricity)));\r\n }\r\n }\r\n if (eq(a, b)) {\r\n return spheroidArea(a, c);\r\n }\r\n else if (eq(b, c)) {\r\n return spheroidArea(b, a);\r\n }\r\n else if (eq(c, a)) {\r\n return spheroidArea(c, b);\r\n }\r\n const phi = Math.acos(c / a);\r\n const kk = (Math.pow(a, 2) * (Math.pow(b, 2) - Math.pow(c, 2))) / (Math.pow(b, 2) * (Math.pow(a, 2) - Math.pow(c, 2)));\r\n const incompleteEllipticInt1 = gaussLegendreQuadrature24((phi) => Math.pow(1 - kk * Math.pow(Math.sin(phi), 2), -0.5), 0, phi);\r\n const incompleteEllipticInt2 = gaussLegendreQuadrature24((phi) => Math.pow(1 - kk * Math.pow(Math.sin(phi), 2), 0.5), 0, phi);\r\n return ((2 * PI * Math.pow(c, 2) + (2 * PI * a * b) / Math.sin(phi)) *\r\n (incompleteEllipticInt2 * Math.pow(Math.sin(phi), 2) +\r\n incompleteEllipticInt1 * Math.pow(Math.cos(phi), 2)));\r\n }\r\n getSeamPlane() {\r\n const plane = P3.forAnchorAndPlaneVectors(this.center, this.f1, this.f3);\r\n return plane.normal1.dot(this.f2) < 0 ? plane : plane.flipped();\r\n }\r\n getExtremePoints() {\r\n return getExtremePointsHelper.call(this, new EllipseCurve(V3.O, V3.X, V3.Z, -PI / 2, PI / 2));\r\n }\r\n pointFoot(pWC, startS, startT) {\r\n console.log(pWC.sce);\r\n if (undefined === startS || undefined === startT) {\r\n let pLC1 = this.matrixInverse.transformPoint(pWC).unit();\r\n if (pLC1.y < 0)\r\n pLC1 = pLC1.negated();\r\n ({ x: startS, y: startT } = EllipsoidSurface.UNIT.uvP(pLC1));\r\n }\r\n const dpdu = this.dpdu();\r\n const dpdv = this.dpdv();\r\n const [u, v] = newtonIterate(([u, v]) => {\r\n const p = this.pUV(u, v);\r\n console.log([p, p.plus(dpdu(u, v)), p, p.plus(dpdv(u, v))].map(toSource).join() +\r\n \",\");\r\n const pUVToPWC = this.pUV(u, v).to(pWC);\r\n return [pUVToPWC.dot(dpdu(u, v)), pUVToPWC.dot(dpdv(u, v))];\r\n }, [startS, startT], 8, undefined, 0.1);\r\n return new V3(u, v, 0);\r\n }\r\n implicitFunction() {\r\n return (pWC) => {\r\n const pLC = this.matrixInverse.transformPoint(pWC);\r\n return (pLC.length() - 1) * this.normalDir;\r\n };\r\n }\r\n // = this.inverseMatrix.transformPoint(this.inverseMatrix.transformPoint(pWC).unit())\r\n didp(pWC) {\r\n // i(pWC) = this.inverseMatrix.transformPoint(pWC).length() - 1\r\n // chain diff rule\r\n const pLC = this.matrixInverse.transformPoint(pWC);\r\n return this.pLCNormalWCMatrix.transformVector(pLC.unit()); //.times(this.normalDir)\r\n }\r\n /*+\r\n * An ellipsoid remains an ellipsoid after a perspective transform (as long as it does not intersect the vanishing\r\n * plane. This transforms a matrix with a perspective component into one which would return an identical ellipsoid,\r\n * but with no perspective component.\r\n */\r\n static unitTransform4(m) {\r\n m.m[15] !== 1 && (m = m.divScalar(m.m[15]));\r\n // X * P = m => X = m * P^-1\r\n // prettier-ignore\r\n const Pinv = new M4(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -m.m[12], -m.m[13], -m.m[14], 1);\r\n const pn = new V3(m.m[12], m.m[13], m.m[14]), pw = m.m[15];\r\n const pwSqrMinusPnSqr = Math.pow(pw, 2) - pn.squared();\r\n if (lt(pwSqrMinusPnSqr, 0)) {\r\n throw new Error(\"vanishing plane intersects unit sphere\");\r\n }\r\n const c = pn.div(-pwSqrMinusPnSqr);\r\n const scale = pn.times((pw * pn.length()) / (pn.squared() * -pwSqrMinusPnSqr));\r\n const scale1 = pw / -pwSqrMinusPnSqr;\r\n const scale2 = 1 / sqrt(pwSqrMinusPnSqr);\r\n const rotNX = M4.forSys(pn.unit(), pn.getPerpendicular().unit());\r\n return M4.product(m, Pinv, M4.translate(c), rotNX, M4.scale(scale1, scale2, scale2), rotNX.transposed());\r\n }\r\n}\r\nEllipsoidSurface.UNIT = new EllipsoidSurface(V3.O, V3.X, V3.Y, V3.Z);\r\nEllipsoidSurface.prototype.uStep = PI / 32;\r\nEllipsoidSurface.prototype.vStep = PI / 32;\r\n//# sourceMappingURL=EllipsoidSurface.js.map","import { assert, assertInst, callsce, hasConstructor, isCCW, M4, V3, } from \"ts3dutils\";\r\nimport { Edge, ImplicitCurve, L3, P3, ParametricSurface, Surface, } from \"..\";\r\nexport class PlaneSurface extends ParametricSurface {\r\n constructor(plane, right = plane.normal1.getPerpendicular().unit(), up = plane.normal1.cross(right).unit(), uMin = -100, uMax = 100, vMin = -100, vMax = 100) {\r\n super(uMin, uMax, vMin, vMax);\r\n this.plane = plane;\r\n this.right = right;\r\n this.up = up;\r\n assertInst(P3, plane);\r\n assert(this.right.cross(this.up).like(this.plane.normal1));\r\n this.matrix = M4.forSys(right, up, plane.normal1, plane.anchor);\r\n }\r\n toSource(rounder = (x) => x) {\r\n return callsce.call(undefined, \"new PlaneSurface\", ...this.getConstructorParameters());\r\n }\r\n static throughPoints(a, b, c) {\r\n return new PlaneSurface(P3.throughPoints(a, b, c));\r\n }\r\n static forAnchorAndPlaneVectors(anchor, v0, v1, uMin, uMax, vMin, vMax) {\r\n return new PlaneSurface(P3.forAnchorAndPlaneVectors(anchor, v0, v1), v0, v1, uMin, uMax, vMin, vMax);\r\n }\r\n isCoplanarTo(surface) {\r\n return (hasConstructor(surface, PlaneSurface) &&\r\n this.plane.isCoplanarToPlane(surface.plane));\r\n }\r\n isTsForLine(line) {\r\n return line.isTsWithPlane(this.plane);\r\n }\r\n like(surface) {\r\n return (hasConstructor(surface, PlaneSurface) && this.plane.like(surface.plane));\r\n }\r\n pUV(u, v) {\r\n return this.matrix.transformPoint(new V3(u, v, 0));\r\n }\r\n implicitFunction() {\r\n return (p) => this.plane.distanceToPointSigned(p);\r\n }\r\n isCurvesWithSurface(surface2) {\r\n if (surface2 instanceof PlaneSurface) {\r\n return this.isCurvesWithPlane(surface2.plane);\r\n }\r\n return super.isCurvesWithSurface(surface2);\r\n }\r\n isCurvesWithPlane(plane) {\r\n const result = this.plane.intersectionWithPlane(plane);\r\n return result ? [result] : [];\r\n }\r\n edgeLoopCCW(contour) {\r\n assert(Edge.isLoop(contour), \"isLoop\");\r\n return isCCW(contour.flatMap((edge) => edge.points()), this.plane.normal1);\r\n }\r\n loopContainsPoint(loop, p) {\r\n const dir = this.right.plus(this.up.times(0.123)).unit();\r\n const line = new L3(p, dir);\r\n const lineOut = dir.cross(this.plane.normal1);\r\n return Surface.loopContainsPointGeneral(loop, p, line, lineOut);\r\n }\r\n uvPFunc() {\r\n const matrixInverse = this.matrix.inversed();\r\n return function (pWC) {\r\n return matrixInverse.transformPoint(pWC);\r\n };\r\n }\r\n pointFoot(pWC) {\r\n return this.uvP(pWC);\r\n }\r\n normalP(pWC) {\r\n return this.plane.normal1;\r\n }\r\n containsPoint(p) {\r\n return this.plane.containsPoint(p);\r\n }\r\n containsCurve(curve) {\r\n return curve instanceof ImplicitCurve\r\n ? super.containsCurve(curve)\r\n : this.plane.containsCurve(curve);\r\n }\r\n transform(m4) {\r\n return new PlaneSurface(this.plane.transform(m4));\r\n }\r\n transform4(m4) {\r\n return new PlaneSurface(this.plane.transform(m4));\r\n }\r\n flipped() {\r\n return new PlaneSurface(this.plane.flipped(), this.right, this.up.negated());\r\n }\r\n getConstructorParameters() {\r\n return [\r\n this.plane,\r\n this.right,\r\n this.up,\r\n this.uMin,\r\n this.uMax,\r\n this.vMin,\r\n this.vMax,\r\n ];\r\n }\r\n dpdu() {\r\n return () => this.right;\r\n }\r\n dpdv() {\r\n return () => this.up;\r\n }\r\n didp(pWC) {\r\n return this.plane.normal1;\r\n }\r\n normalUV() {\r\n return this.plane.normal1;\r\n }\r\n}\r\nPlaneSurface.prototype.uStep = 1e6;\r\nPlaneSurface.prototype.vStep = 1e6;\r\n//# sourceMappingURL=PlaneSurface.js.map","import { assert, assertInst, assertVectors, hasConstructor, M4, newtonIterate, pqFormula, V3, } from \"ts3dutils\";\r\nimport { Curve, EllipseCurve, ImplicitCurve, ImplicitSurface, L3, ParametricSurface, PlaneSurface, Surface, } from \"..\";\r\nexport class PointProjectedSurface extends ParametricSurface {\r\n constructor(curve, apex, curvePlane, normalDir = 1, uMin = curve.tMin, uMax = curve.tMax, vMin = 0, vMax = 16) {\r\n super(uMin, uMax, vMin, vMax);\r\n this.curve = curve;\r\n this.apex = apex;\r\n this.curvePlane = curvePlane;\r\n this.normalDir = normalDir;\r\n assertInst(Curve, curve);\r\n assert(!(curve instanceof L3), \"use PlaneSurface instead\");\r\n assert(!(curve instanceof EllipseCurve), \"use ConicSurface instead\");\r\n assert(!(curve instanceof ImplicitCurve), \"this just seems like a terrible idea\");\r\n assert(new PlaneSurface(curvePlane).containsCurve(curve));\r\n assertVectors(apex);\r\n assert(0 <= vMin);\r\n this.planeProjectionMatrix = M4.projectPlanePoint(apex, curvePlane);\r\n this.uStep = curve.tIncrement;\r\n }\r\n pointFoot(pWC, startU, startV) {\r\n if (undefined === startU || undefined === startV) {\r\n // similar to stP\r\n if (undefined === startU) {\r\n startU = pWC.like(this.apex)\r\n ? 0\r\n : this.curve.closestTToPoint(this.planeProjectionMatrix.transformPoint(pWC)) * this.normalDir;\r\n }\r\n if (undefined === startV) {\r\n startV = V3.inverseLerp(this.apex, this.curve.at(startU), pWC);\r\n }\r\n }\r\n const f = ([u, v]) => {\r\n const pUVToPWC = this.pUV(u, v).to(pWC);\r\n return [this.dpdu()(u, v).dot(pUVToPWC), this.dpdv()(u).dot(pUVToPWC)];\r\n };\r\n const { 0: x, 1: y } = newtonIterate(f, [startU, startV]);\r\n return new V3(x, y, 0);\r\n }\r\n getConstructorParameters() {\r\n return [\r\n this.curve,\r\n this.apex,\r\n this.curvePlane,\r\n this.normalDir,\r\n this.uMin,\r\n this.uMax,\r\n this.vMin,\r\n this.vMax,\r\n ];\r\n }\r\n static unitISLineTs(anchor, dir) {\r\n const { x: ax, y: ay, z: az } = anchor;\r\n const { x: dx, y: dy, z: dz } = dir;\r\n // this cone: x² + y² = z²\r\n // line: p = anchor + t * dir1\r\n // split line equation into 3 component equations, insert into cone equation\r\n // transform to form (a t² + b t + c = 0) and solve with pqFormula\r\n const a = dx * dx + dy * dy - dz * dz;\r\n const b = 2 * (ax * dx + ay * dy - az * dz);\r\n const c = ax * ax + ay * ay - az * az;\r\n // cone only defined for 0 <= z, so filter invalid values\r\n return pqFormula(b / a, c / a).filter((t) => 0 < az + t * dz);\r\n }\r\n equals(obj) {\r\n return (this == obj ||\r\n (hasConstructor(obj, PointProjectedSurface) &&\r\n this.curve.equals(obj.curve) &&\r\n this.apex.equals(this.apex)));\r\n }\r\n like(object) {\r\n if (!this.isCoplanarTo(object))\r\n return false;\r\n // normals need to point in the same direction (outwards or inwards) for both\r\n return this.normalDir == object.normalDir;\r\n }\r\n loopContainsPoint(contour, p) {\r\n assertVectors(p);\r\n const line = this.apex.like(p)\r\n ? new L3(p, this.apex.to(this.curve.at(this.curve.tMin)).unit())\r\n : L3.throughPoints(p, this.apex);\r\n const lineOut = line.dir1.cross(this.curvePlane.normal1);\r\n return Surface.loopContainsPointGeneral(contour, p, line, lineOut);\r\n }\r\n isTsForLine(line) {\r\n // transforming line manually has advantage that dir1 will not be renormalized,\r\n // meaning that calculated values t for lineLC are directly transferable to line\r\n const anchorPlane = this.planeProjectionMatrix.transformPoint(line.anchor);\r\n const anchor2Plane = this.planeProjectionMatrix.transformPoint(line.anchor.plus(line.dir1));\r\n if (anchorPlane.like(anchor2Plane)) {\r\n // line projects onto a point in plane.\r\n // there are either no or infinite intersection points\r\n return [];\r\n }\r\n return this.curve\r\n .isInfosWithLine(anchorPlane, anchorPlane.to(anchor2Plane), undefined, undefined, line.tMin, line.tMax)\r\n .map((info) => info.tOther);\r\n }\r\n /**\r\n * Interestingly, two cones don't need to have parallel dirs to be coplanar.\r\n */\r\n isCoplanarTo(surface) {\r\n if (this === surface)\r\n return true;\r\n if (!(surface instanceof PointProjectedSurface) ||\r\n !this.apex.like(surface.apex))\r\n return false;\r\n // at this point apexes are equal\r\n return this.containsCurve(surface.curve);\r\n }\r\n containsLine(line) {\r\n if (this.curvePlane.isParallelToLine(line)) {\r\n return false;\r\n }\r\n if (!line.containsPoint(this.apex)) {\r\n return false;\r\n }\r\n const p = this.curvePlane.intersectionWithLine(line);\r\n return this.curve.containsPoint(p);\r\n }\r\n containsCurve(curve) {\r\n if (curve instanceof L3) {\r\n return this.containsLine(curve);\r\n }\r\n else if (!(curve instanceof ImplicitCurve)) {\r\n const otherCurveOnThisPlane = curve.transform(this.planeProjectionMatrix);\r\n return this.curve.isColinearTo(otherCurveOnThisPlane);\r\n }\r\n else {\r\n return super.containsCurve(curve);\r\n }\r\n }\r\n transform(m4) {\r\n return new PointProjectedSurface(this.curve.transform(m4), m4.transformPoint(this.apex), this.curvePlane.transform(m4), (m4.isMirroring() ? -1 : 1) * this.normalDir, this.uMin, this.uMax, this.vMin, this.vMax);\r\n }\r\n flipped() {\r\n return new PointProjectedSurface(this.curve, this.apex, this.curvePlane, -this.normalDir, -this.uMax, -this.uMin, this.vMin, this.vMax);\r\n }\r\n normalUVFunc() {\r\n const dpdv = this.dpdv();\r\n return (u) => this.curve\r\n .tangentAt(u * this.normalDir)\r\n .times(this.normalDir)\r\n .cross(dpdv(u))\r\n .unit();\r\n }\r\n pUVFunc() {\r\n return (u, v) => {\r\n return this.apex.lerp(this.curve.at(u * this.normalDir), v);\r\n };\r\n }\r\n dpdu() {\r\n return (u, v) => {\r\n return this.curve.tangentAt(u * this.normalDir).times(v * this.normalDir);\r\n };\r\n }\r\n dpdv() {\r\n return (u) => {\r\n return this.apex.to(this.curve.at(u * this.normalDir));\r\n };\r\n }\r\n containsPoint(pWC) {\r\n return (this.apex.like(pWC) ||\r\n this.curve.containsPoint(this.planeProjectionMatrix.transformPoint(pWC)));\r\n }\r\n uvP(pWC) {\r\n const u = pWC.like(this.apex)\r\n ? 0\r\n : this.curve.pointT(this.planeProjectionMatrix.transformPoint(pWC));\r\n const v = V3.inverseLerp(this.apex, this.curve.at(u), pWC);\r\n return new V3(u * this.normalDir, v, 0);\r\n }\r\n isCurvesWithSurface(surface) {\r\n if (surface instanceof PlaneSurface) {\r\n return this.isCurvesWithPlane(surface.plane);\r\n }\r\n else if (ImplicitSurface.is(surface)) {\r\n return ParametricSurface.isCurvesParametricImplicitSurface(this, surface, 0.1, 0.1 / this.curvePlane.distanceToPoint(this.apex), 0.02);\r\n }\r\n return super.isCurvesWithSurface(surface);\r\n }\r\n isCurvesWithPlane(plane) {\r\n if (plane.containsPoint(this.apex)) {\r\n if (plane.isParallelToPlane(this.curvePlane)) {\r\n return [];\r\n }\r\n return this.curve\r\n .isTsWithPlane(plane)\r\n .map((t) => L3.throughPoints(this.apex, this.curve.at(t)));\r\n }\r\n return [this.curve.transform(M4.projectPlanePoint(this.apex, plane))];\r\n }\r\n}\r\nPointProjectedSurface.prototype.vStep = 256;\r\n//# sourceMappingURL=PointProjectedSurface.js.map","import { arrayFromFunction, assert, clamp, firstUnsorted, ilog, indexWithMax, lerp, MINUS, newtonIterate, sliceStep, V, V3, Vector, } from \"ts3dutils\";\r\nimport { NURBS, ParametricSurface } from \"..\";\r\nimport { ceil, floor } from \"../math\";\r\nexport class NURBSSurface extends ParametricSurface {\r\n constructor(\r\n /**\r\n * Control points in u-major order. I.e. the first pointCountU points are a NURBS.\r\n */\r\n points, knotsU, knotsV, degreeU, degreeV, uMin = knotsU[degreeU], uMax = knotsU[knotsU.length - degreeU - 1], vMin = knotsV[degreeV], vMax = knotsV[knotsV.length - degreeV - 1]) {\r\n super(uMin, uMax, vMin, vMax);\r\n this.points = points;\r\n this.knotsU = knotsU;\r\n this.knotsV = knotsV;\r\n this.degreeU = degreeU;\r\n this.degreeV = degreeV;\r\n const pointCountU = knotsU.length - 1 - degreeU;\r\n const pointCountV = knotsV.length - 1 - degreeV;\r\n assert(pointCountU * pointCountV == points.length);\r\n assert(degreeU <= degreeV, \"degreeU <= degreeV\");\r\n assert(-1 === firstUnsorted(knotsU, MINUS), \"knot values must be in ascending order\");\r\n assert(-1 === firstUnsorted(knotsV, MINUS), \"knot values must be in ascending order\");\r\n }\r\n getConstructorParameters() {\r\n return [\r\n this.points,\r\n this.knotsU,\r\n this.knotsV,\r\n this.degreeU,\r\n this.degreeV,\r\n this.uMin,\r\n this.uMax,\r\n this.vMin,\r\n this.vMax,\r\n ];\r\n }\r\n transform(m4) {\r\n return this.transform4(m4);\r\n }\r\n transform4(m4) {\r\n return new NURBSSurface(this.points.map((p) => m4.timesVector(p)), this.knotsU, this.knotsV, this.degreeU, this.degreeV, this.uMin, this.uMax, this.vMin, this.vMax);\r\n }\r\n pUV(u, v) {\r\n return this.isoparametricU(u).at(v);\r\n }\r\n dpdu() {\r\n return (u, v) => this.isoparametricV(v).tangentAt(u);\r\n }\r\n dpdv() {\r\n return (u, v) => this.isoparametricU(u).tangentAt(v);\r\n }\r\n normalUV(u, v) {\r\n const normal = this.dpdu()(u, v).cross(this.dpdv()(u, v));\r\n return normal.likeO() ? V3.X : normal.unit();\r\n }\r\n isoparametricU(u) {\r\n const pointCountU = this.knotsU.length - 1 - this.degreeU;\r\n const pointCountV = this.knotsV.length - 1 - this.degreeV;\r\n return new NURBS(arrayFromFunction(pointCountV, (i) => {\r\n return deBoor(this.points.slice(i * pointCountU, (i + 1) * pointCountU), this.degreeU, this.knotsU, u);\r\n }), this.degreeV, this.knotsV, this.vMin, this.vMax);\r\n }\r\n isoparametricV(v) {\r\n const pointCountU = this.knotsU.length - 1 - this.degreeU;\r\n return new NURBS(arrayFromFunction(pointCountU, (i) => {\r\n return deBoor(sliceStep(this.points, i, this.points.length, pointCountU, 1), this.degreeV, this.knotsV, v);\r\n }), this.degreeU, this.knotsU, this.uMin, this.uMax);\r\n }\r\n debugInfo() {\r\n const pointCountU = this.knotsU.length - 1 - this.degreeU;\r\n const pointCountV = this.knotsV.length - 1 - this.degreeV;\r\n const grid = [];\r\n for (let u = 0; u < pointCountU; u++) {\r\n for (let v = 0; v < pointCountV; v++) {\r\n const i = v * pointCountU + u;\r\n if (u < pointCountU - 1) {\r\n const j = v * pointCountU + u + 1;\r\n grid.push(this.points[i].p3(), this.points[j].p3());\r\n }\r\n if (v < pointCountV - 1) {\r\n const j = (v + 1) * pointCountU + u;\r\n grid.push(this.points[i].p3(), this.points[j].p3());\r\n }\r\n }\r\n }\r\n return { points: this.points.map((p) => p.p3()), lines: grid };\r\n }\r\n flipped() {\r\n const pointCountU = this.knotsU.length - 1 - this.degreeU;\r\n return new NURBSSurface(arrayFromFunction(this.points.length, (i) => {\r\n const u = i % pointCountU;\r\n return this.points[i - u + (pointCountU - u - 1)];\r\n }), this.knotsU.map((x) => -x).reverse(), this.knotsV, this.degreeU, this.degreeV, -this.uMax, -this.uMin, this.vMin, this.vMax);\r\n }\r\n isCoplanarTo(surface) {\r\n throw new Error(\"not implemented\");\r\n }\r\n isTsForLine(line) {\r\n // intersect line with\r\n const startT = 4;\r\n // Once we have a starting t param, there are two options:\r\n // 1. 1-D Newton iterate on (t) -> (distanceFromSurface)\r\n // 2. 3-D Newton iterate on (u, v, t) -> this.pUV(u, v).to(line.at(t))\r\n // Let's go with 2, because 1 will require doing a nested newton iteration.\r\n const [startU, startV] = this.pointFoot(line.at(startT));\r\n const [, , t] = newtonIterate(([u, v, t]) => {\r\n console.log(\"uvt\", u, v, t);\r\n const lineP = line.at(t);\r\n return ilog(this.pUV(u, v).to(lineP).toArray());\r\n }, [startU, startV, startT], 8);\r\n return [t];\r\n }\r\n pointFoot(pWC, startU, startV) {\r\n const closestPointIndex = indexWithMax(this.points, (p) => -p.p3().distanceTo(pWC));\r\n const pointCountU = this.knotsU.length - this.degreeU - 1;\r\n const closestPointPos = V(closestPointIndex % pointCountU, (closestPointIndex / pointCountU) | 0);\r\n const start = this.guessUVForMeshPos(closestPointPos.x, closestPointPos.y);\r\n const dpdu = this.dpdu();\r\n const dpdv = this.dpdv();\r\n try {\r\n const [u, v] = newtonIterate(([u, v]) => {\r\n // console.log(\"u,v\", u, v)\r\n const pUV = this.pUV(u, v);\r\n const pUVToPWC = pUV.to(pWC);\r\n return [pUVToPWC.dot(dpdu(u, v)), pUVToPWC.dot(dpdv(u, v))];\r\n }, [start.x, start.y], 16);\r\n return new V3(u, v, 0);\r\n }\r\n catch (e) {\r\n return undefined;\r\n }\r\n }\r\n isCurvesWithPlane(plane) {\r\n throw new Error(\"Method not implemented.\");\r\n }\r\n containsPoint(pWC) {\r\n const foot = this.pointFoot(pWC);\r\n return foot && this.pUV(foot.x, foot.y).like(pWC);\r\n }\r\n loopContainsPoint(contour, point) {\r\n throw new Error(\"Method not implemented.\");\r\n }\r\n guessUVForMeshPos(x, y) {\r\n function eLerp(arr, t, lerp) {\r\n if (0 === t % 1)\r\n return arr[t];\r\n return lerp(arr[floor(t)], arr[ceil(t)], t % 1);\r\n }\r\n return new V3(clamp(eLerp(this.knotsU, x + (this.degreeU + 1) / 2, lerp), this.uMin, this.uMax), clamp(eLerp(this.knotsV, y + (this.degreeV + 1) / 2, lerp), this.vMin, this.vMax), 0);\r\n }\r\n}\r\nNURBSSurface.prototype.uStep = 1 / 8;\r\nNURBSSurface.prototype.vStep = 1 / 8;\r\nfunction getInterval(degree, knots, t) {\r\n for (let s = degree; s < knots.length - 1 - degree; s++) {\r\n if (t >= knots[s] && t <= knots[s + 1]) {\r\n return s;\r\n }\r\n }\r\n throw new Error(t + \" \" + knots);\r\n}\r\nfunction deBoor(points, degree, knots, t) {\r\n // find s (the spline segment) for the [t] value provided\r\n const s = getInterval(degree, knots, t);\r\n const v = Vector.pack(points, new Float64Array(points.length * 4));\r\n // l (level) goes from 1 to the curve degree + 1\r\n for (let l = 1; l <= degree; l++) {\r\n // build level l of the pyramid\r\n for (let i = s; i > s - degree - 1 + l; i--) {\r\n const alpha = (t - knots[i]) / (knots[i + degree + 1 - l] - knots[i]);\r\n // interpolate each component\r\n for (let d = 0; d < 4; d++) {\r\n v[i * 4 + d] = (1 - alpha) * v[(i - 1) * 4 + d] + alpha * v[i * 4 + d];\r\n }\r\n }\r\n }\r\n return new Vector(v.slice(s * 4, s * 4 + 4));\r\n}\r\n//# sourceMappingURL=NURBSSurface.js.map","import { assert, gaussLegendre24Weights, gaussLegendre24Xs, gaussLegendreQuadrature24, glqInSteps, M4, sum, V, V3, } from \"ts3dutils\";\r\nimport { ConicSurface, EllipseCurve, EllipsoidSurface, HyperbolaCurve, ImplicitCurve, L3, ParabolaCurve, ParametricSurface, PlaneSurface, ProjectedCurveSurface, RotatedCurveSurface, } from \"../index\";\r\nimport { cos, sin } from \"../math\";\r\n/**\r\n * In general: the z-dir shadow volume of a face is the integral: SURFACE_INTEGRAL[p in face] (normal(p).z * p.z) dp\r\n * In general: the centroid of the z-dir shadow volume of a face is the integral:\r\n * SURFACE_INTEGRAL[p in face] ((p schur (1, 1, 0.5)) * normal(p).z * p.z) dp\r\n * dividing the z component by 2 is usually done at the very end\r\n */\r\nexport const ZDirVolumeVisitor = {\r\n [ConicSurface.name](edges) {\r\n console.log(this);\r\n const dpdu = this.dpdu();\r\n const dpdv = this.dpdv();\r\n // INT[edge.at; edge.bT] (at(t) DOT dir) * (at(t) - at(t).projectedOn(dir) / 2).z dt\r\n const totalVolume = sum(edges.map((edgeWC) => {\r\n const curveWC = edgeWC.curve;\r\n if (curveWC instanceof EllipseCurve ||\r\n curveWC instanceof HyperbolaCurve ||\r\n curveWC instanceof ParabolaCurve) {\r\n const f = (curveT) => {\r\n const at = curveWC.at(curveT), tangentWC = curveWC.tangentAt(curveT);\r\n const uvOfPWC = this.uvP(at);\r\n // INTEGRATE [0; atUV.y] (dpdu(atUV.x, t) X dpdv(atUV.x)).z * pUV(atUV.x, t).z dt\r\n // dpdu(u, v) === t * dpdu(s, 1)\r\n // => INTEGRATE [0; atUV.y] (t * dpdu(atUV.x, 1) X dpdv(atUV.x)).z * pUV(atUV.x, t).z dt\r\n // => (dpdu(atUV.x, 1) X dpdv(atUV.x)).z * INTEGRATE [0; atUV.y] t * pUV(atUV.x, t).z dt\r\n // pUV(u, v) === t * (pUV(s, 1) - center) + center\r\n // => (dpdu(atUV.x, 1) X dpdv(atUV.x)).z\r\n // * INTEGRATE [0; atUV.y] t² * (pUV(atUV.x, t) - center).z + t * center.z dt\r\n // => (dpdu(atUV.x, 1) X dpdv(atUV.x)).z\r\n // * INTEGRATE [0; atUV.y] t² * (pUV(atUV.x, t) - center).z + t * center.z dt\r\n // => (dpdu(atUV.x, 1) X dpdv(atUV.x)).z\r\n // * (1/3 t³ pUV(atUV.x, 1).z + 1/2 t² center.z)[0; atUV.y]\r\n const du = -M4.forSys(dpdu(uvOfPWC.x, uvOfPWC.y), dpdv(uvOfPWC.x))\r\n .inversed()\r\n .transformVector(tangentWC).x;\r\n const factor = (Math.pow(uvOfPWC.y, 3) / 3) *\r\n (this.pUV(uvOfPWC.x, 1).z - this.center.z) +\r\n (Math.pow(uvOfPWC.y, 2) / 2) * this.center.z;\r\n const actual = dpdu(uvOfPWC.x, factor).cross(dpdv(uvOfPWC.x)).z;\r\n return actual * du;\r\n };\r\n const val = glqInSteps(f, edgeWC.aT, edgeWC.bT, 1);\r\n return val;\r\n }\r\n else if (curveWC instanceof L3) {\r\n return 0;\r\n }\r\n else {\r\n throw new Error();\r\n }\r\n }));\r\n const centroidZX2Parts = edges.map((edgeWC) => {\r\n const curveWC = edgeWC.curve;\r\n if (curveWC instanceof EllipseCurve ||\r\n curveWC instanceof HyperbolaCurve ||\r\n curveWC instanceof ParabolaCurve) {\r\n const f = (curveT) => {\r\n const at = curveWC.at(curveT), tangentWC = curveWC.tangentAt(curveT);\r\n const uvOfPWC = this.uvP(at);\r\n // INTEGRATE [0; atUV.y] dpdu(atUV.x, t) X dpdv(atUV.x, t) * pUV(atUV.x, t).z dt\r\n // dpdv is constant with respect to t\r\n // => (dpdu(atUV.x, t) X dpdv(atUV.x, t)).z\r\n // * (INTEGRATE [0; atUV.y] t * pUV(atUV.x, t) * pUV(atUV.x, t).z dt)\r\n // dpdu(u, v) === t * dpdu(s, 1)\r\n // pUV(u, v) === t * (pUV(s, 1) - center) + center\r\n // INTEGRATE [0; atUV.y] t * pUV(atUV.x, t) * pUV(atUV.x, t).z dt\r\n // = INTEGRATE [0; atUV.y] t *\r\n // (t * (pUV(s, 1) - center) + center) *\r\n // (t (pUV(s, 1) - center).z + center.z) dt\r\n // = INTEGRATE [0; atUV.y] t³ (pUV(s, 1) - center) * (pUV(s, 1) - center).z\r\n // + t² ((pUV(s, 1) - center) * center.z + (pUV(s, 1) - center).z * center)\r\n // + t center center.z dt\r\n // = (1/4 t^4 (pUV(s, 1) - center) * (pUV(s, 1) - center).z\r\n // (1/3 t³ ((pUV(s, 1) - center) * center.z + (pUV(s, 1) - center).z * center)\r\n // (1/2 t² center center.z dt)[0; atUV.y]\r\n const pUVS1V = this.pUV(uvOfPWC.x, 1).minus(this.center);\r\n const factor = V3.add(pUVS1V.times((1 / 4) * Math.pow(uvOfPWC.y, 4) * pUVS1V.z +\r\n (1 / 3) * Math.pow(uvOfPWC.y, 3) * this.center.z), this.center.times((1 / 3) * Math.pow(uvOfPWC.y, 3) * pUVS1V.z +\r\n (1 / 2) * Math.pow(uvOfPWC.y, 2) * this.center.z));\r\n const partialCentroid = factor.times(dpdu(uvOfPWC.x, 1).cross(dpdv(uvOfPWC.x)).z);\r\n const ds = -M4.forSys(dpdu(uvOfPWC.x, uvOfPWC.y), dpdv(uvOfPWC.x))\r\n .inversed()\r\n .transformVector(tangentWC).x;\r\n return partialCentroid.times(ds);\r\n };\r\n return glqV3(f, edgeWC.aT, edgeWC.bT);\r\n }\r\n else if (curveWC instanceof L3) {\r\n return V3.O;\r\n }\r\n else {\r\n throw new Error();\r\n }\r\n });\r\n const centroid = V3.add(...centroidZX2Parts)\r\n .schur(new V3(1, 1, 0.5))\r\n .div(totalVolume);\r\n return { volume: totalVolume, centroid: centroid };\r\n },\r\n [PlaneSurface.name](edges) {\r\n const r1 = this.right;\r\n const u1 = this.up;\r\n const c = this.plane.anchor;\r\n assert(r1.hasLength(1));\r\n assert(u1.hasLength(1));\r\n assert(r1.isPerpendicularTo(u1));\r\n const volumeAndCentroidZX2Parts = edges.map((edgeWC) => {\r\n const curveWC = edgeWC.curve;\r\n if (curveWC instanceof L3) {\r\n // split shadow volume into two triangle shadow volumes and use the same logic as for mesh triangles:\r\n function triangleShadowVolumeAndCentroid(a, b, c) {\r\n const ab = b.minus(a), ac = c.minus(a);\r\n const normal = ab.cross(ac);\r\n const faceCentroid = V3.add(a, b, c).div(3);\r\n return [\r\n (faceCentroid.z * normal.z) / 2,\r\n V3.add(a.times(2 * a.z + b.z + c.z), b.times(a.z + 2 * b.z + c.z), c.times(a.z + b.z + 2 * c.z)).times(normal.z),\r\n ];\r\n }\r\n const a = edgeWC.a, b = edgeWC.b;\r\n const as = a.dot(r1);\r\n const bs = b.dot(r1);\r\n const aBase = this.pUV(as, 0);\r\n const bBase = this.pUV(bs, 0);\r\n const [v1, c1] = triangleShadowVolumeAndCentroid(a, b, aBase);\r\n const [v2, c2] = triangleShadowVolumeAndCentroid(bBase, aBase, b);\r\n return [v1 + v2, c1.plus(c2).div(24)];\r\n }\r\n else if (curveWC instanceof ImplicitCurve) {\r\n throw new Error();\r\n }\r\n else {\r\n const sliceAreaAndCentroidZX2TimesDs = (curveT) => {\r\n const p = curveWC.at(curveT);\r\n const s = p.dot(r1);\r\n const t = p.dot(u1);\r\n const area = t * c.z + s * t * r1.z + (1 / 2) * Math.pow(t, 2) * u1.z;\r\n const ds = -curveWC.tangentAt(curveT).dot(r1);\r\n return [\r\n area * ds,\r\n ...V3.add(c.times(area), r1.times(c.z * s * t + r1.z * Math.pow(s, 2) * t + (1 / 2) * s * Math.pow(t, 2) * u1.z), u1.times((1 / 2) * c.z * Math.pow(t, 2) +\r\n (1 / 2) * r1.z * s * Math.pow(t, 2) +\r\n (1 / 3) * Math.pow(t, 3) * u1.z)).times(ds),\r\n ];\r\n };\r\n const [vol, cx, cy, cz] = glqArray(sliceAreaAndCentroidZX2TimesDs, edgeWC.aT, edgeWC.bT, 4);\r\n return [\r\n vol * this.plane.normal1.z,\r\n new V3(cx, cy, cz).times(this.plane.normal1.z),\r\n ];\r\n }\r\n });\r\n return mergeVolumeAndCentroidZX2Parts(volumeAndCentroidZX2Parts);\r\n },\r\n /**\r\n * Generic implementation.\r\n */\r\n [ParametricSurface.name](edges) {\r\n const dpdu = this.dpdu();\r\n const dpdv = this.dpdv();\r\n const volume = edges.map((edgeWC) => {\r\n const curveWC = edgeWC.curve;\r\n if (curveWC instanceof ImplicitCurve) {\r\n throw new Error();\r\n }\r\n else {\r\n const sliceAreaAndCentroidZX2TimesDs = (curveT) => {\r\n // use curve.tangent not edge.tangent, reverse edges are handled by the integration boundaries\r\n const pWC = curveWC.at(curveT), tangentWC = curveWC.tangentAt(curveT);\r\n const uvOfPWC = this.uvP(pWC);\r\n const slice = (t) => {\r\n const p = this.pUV(uvOfPWC.x, t);\r\n const normal = dpdu(uvOfPWC.x, t).cross(dpdv(uvOfPWC.x, t));\r\n return p.z * normal.z;\r\n };\r\n const sliceIntegral0ToPWCT = glqInSteps(slice, 0, uvOfPWC.y, 1);\r\n // const dt = tangentWC.dot(scalingVector)\r\n const dt = -M4.forSys(dpdu(uvOfPWC.x, uvOfPWC.y), dpdv(uvOfPWC.x, uvOfPWC.y))\r\n .inversed()\r\n .transformVector(tangentWC).x;\r\n const sliceAreaTimesDs = sliceIntegral0ToPWCT * dt;\r\n const slice2 = (t) => {\r\n const p = this.pUV(uvOfPWC.x, t);\r\n const normal = dpdu(uvOfPWC.x, t).cross(dpdv(uvOfPWC.x, t));\r\n return p.times(p.z * normal.z);\r\n };\r\n const sliceIntegral0ToPWCT2 = glqV3(slice2, 0, uvOfPWC.y);\r\n // const dt = tangentWC.dot(scalingVector)\r\n const sliceCentroidZX2TimesDs = sliceIntegral0ToPWCT2.times(dt);\r\n return [sliceAreaTimesDs, ...sliceCentroidZX2TimesDs.toArray()];\r\n };\r\n const [vol, cx, cy, cz] = glqArray(sliceAreaAndCentroidZX2TimesDs, edgeWC.aT, edgeWC.bT, 4);\r\n return [vol, new V3(cx, cy, cz)];\r\n }\r\n });\r\n return mergeVolumeAndCentroidZX2Parts(volume);\r\n },\r\n /**\r\n * at(t)\r\n * |\\ ^\r\n * | \\ at(t).projectedOn(dir1) \\ dir1\r\n * | \\ \\\r\n * | \\ at(t).rejectedFrom(dir1) = b\r\n * | |\r\n * |___|\r\n * z = 0\r\n *\r\n *\r\n * A = ((at(t) + at(t).rejectedFrom(dir1)) / 2).z * at(t).projectedOn(dir1).lengthXY()\r\n * scaling = tangentAt(t) DOT dir1.cross(V3.Z).unit()\r\n */\r\n [ProjectedCurveSurface.name](edges) {\r\n if (V3.Z.cross(this.dir).likeO())\r\n return { volume: 0, centroid: V3.O };\r\n // normalize this.dir so it always points up\r\n const upDir1 = this.dir.toLength(Math.sign(this.dir.z) || 1);\r\n const scalingVector = V3.Z.cross(upDir1).unit();\r\n // the length of the base of the trapezoid is calculated by dotting with the baseVector\r\n const baseVector = upDir1.rejectedFrom(V3.Z).unit();\r\n // INT[edge.at; edge.bT] (at(t) DOT dir1) * (at(t) - at(t).projectedOn(dir) / 2).z\r\n const volume = edges.map((edgeWC) => {\r\n if (edgeWC.curve instanceof L3) {\r\n return [0, V3.O];\r\n }\r\n else if (edgeWC.curve instanceof ImplicitCurve) {\r\n return [0, V3.O];\r\n // \tconst { points, tangents } = edgeWC.curve\r\n // \tconst minT = edgeWC.minT,\r\n // \t\tmaxT = edgeWC.maxT\r\n // \tlet sum = 0\r\n // \tconst start = Math.ceil(minT + NLA_PRECISION)\r\n // \tconst end = Math.floor(maxT - NLA_PRECISION)\r\n // \tfor (let i = start; i <= end; i++) {\r\n // \t\tconst at = points[i],\r\n // \t\t\ttangent = tangents[i]\r\n // \t\tconst area = (at.z + at.rejectedFrom1(upDir1).z) / 2 * at.projectedOn(upDir1).dot(baseVector)\r\n // \t\tconst scale = tangent.dot(scalingVector)\r\n // \t\tsum += area * scale\r\n // \t}\r\n // \tconst f = (t: number) => {\r\n // \t\tconst at = edgeWC.curve.at(t),\r\n // \t\t\ttangent = edgeWC.curve.tangentAt(t)\r\n // \t\tconst area = (at.z + at.rejectedFrom1(upDir1).z) / 2 * at.projectedOn(upDir1).dot(baseVector)\r\n // \t\tconst scale = tangent.dot(scalingVector)\r\n // \t\treturn area * scale\r\n // \t}\r\n // \tsum += f(minT) * (start - minT - 0.5)\r\n // \tsum += f(maxT) * (maxT - end - 0.5)\r\n // \treturn sum * Math.sign(edgeWC.deltaT())\r\n }\r\n else {\r\n const f = (curveT) => {\r\n // use curve.tangent not edge.tangent, reverse edges are handled by the integration boundaries\r\n const at = edgeWC.curve.at(curveT), tangent = edgeWC.curve.tangentAt(curveT);\r\n const b = at.rejectedFrom1(upDir1);\r\n const area = (at.z * b.to(at).dot(baseVector)) / 2 +\r\n (b.z * b.to(at).dot(baseVector)) / 2;\r\n const areaCentroidA = V3.add(at.xy(), b, at).times((at.z * b.to(at).dot(baseVector)) / 2 / 3);\r\n const areaCentroidB = V3.add(at.xy(), b, b.xy()).times((b.z * b.to(at).dot(baseVector)) / 2 / 3);\r\n const scale = tangent.dot(scalingVector);\r\n return [\r\n area * scale,\r\n ...areaCentroidA.plus(areaCentroidB).times(scale).schur(V(1, 1, 2)),\r\n ];\r\n };\r\n const [vol, cx, cy, cz] = glqArray(f, edgeWC.aT, edgeWC.bT, 4);\r\n return [vol, new V3(cx, cy, cz)];\r\n }\r\n });\r\n return mergeVolumeAndCentroidZX2Parts(volume);\r\n },\r\n // volume does scale linearly, so this could be done in the local coordinate system\r\n // however, shear matrices lead to point-to-plane distances having to be calculated along a vector other than\r\n // the plane normal\r\n [RotatedCurveSurface.name](edges) {\r\n const dpdu = this.dpdu();\r\n const dpdv = this.dpdv();\r\n const totalVolume = sum(edges.map((edgeWC) => {\r\n const curveWC = edgeWC.curve;\r\n const f = (curveT) => {\r\n const pWC = curveWC.at(curveT), tangentWC = curveWC.tangentAt(curveT);\r\n const uvOfPWC = this.uvP(pWC);\r\n const pLC = this.matrixInverse.transformPoint(pWC);\r\n const dpdvAtS0 = this instanceof RotatedCurveSurface\r\n ? this.curve.tangentAt(uvOfPWC.y)\r\n : V(-pLC.z, 0, pLC.lengthXY());\r\n // const slice = (phi: number) => {\r\n // \tconst p = this.pUV(phi, uvOfPWC.y)\r\n // \tconst normal = dpdu(phi, uvOfPWC.y).cross(dpdv(phi, uvOfPWC.y))\r\n // \treturn p.z * normal.z\r\n // }\r\n // const z = this.curve.at(uvOfPWC.y).z\r\n // const r = this.curve.at(uvOfPWC.y).lengthXY()\r\n // const pz =\r\n // \tthis.f1.z * r * cos(s) +\r\n // \tthis.f2.z * r * sin(s) +\r\n // \tthis.f3.z * z +\r\n // \tthis.center.z\r\n // const dpdux = this.f1.x * r * -sin(s) + this.f2.x * r * cos(s)\r\n // const dpduy = this.f1.y * r * -sin(s) + this.f2.y * r * cos(s)\r\n // const dpdvx = this.f1.x * dr * cos(s) + this.f2.x * dr * sin(s) + this.f3.x * dz\r\n // const dpdvy = this.f1.y * dr * cos(s) + this.f2.y * dr * sin(s) + this.f3.y * dz\r\n // const normalz = dpdux * dpdvy - dpduy * dpdvx\r\n // result = pz * normalz\r\n const r = pLC.lengthXY(), z = pLC.z;\r\n const dr = dpdvAtS0.x;\r\n const dz = dpdvAtS0.z;\r\n const a = this.matrix.X.z * r, b = this.matrix.Y.z * r, c = this.matrix.Z.z * z + this.matrix.O.z;\r\n const t0 = (this.matrix.X.x * this.matrix.Y.y -\r\n this.matrix.X.y * this.matrix.Y.x) *\r\n r *\r\n dr;\r\n const t1 = (this.matrix.Y.x * this.matrix.X.y -\r\n this.matrix.Y.y * this.matrix.X.x) *\r\n r *\r\n dr;\r\n const t2 = (this.matrix.X.x * this.matrix.X.y -\r\n this.matrix.X.y * this.matrix.X.x) *\r\n r *\r\n dr;\r\n const t3 = (this.matrix.Y.x * this.matrix.Y.y -\r\n this.matrix.Y.y * this.matrix.Y.x) *\r\n r *\r\n dr;\r\n const t4 = (this.matrix.Y.x * this.matrix.Z.y -\r\n this.matrix.Y.y * this.matrix.Z.x) *\r\n r *\r\n dz;\r\n const t5 = (this.matrix.X.x * this.matrix.Z.y -\r\n this.matrix.X.y * this.matrix.Z.x) *\r\n r *\r\n dz;\r\n const sliceIntegral = (p) => {\r\n return ((6 * (c * (-t0 + t1) + a * t4 - b * t5) * p +\r\n 3 *\r\n (3 * b * t0 - b * t1 + a * (t2 - t3) + 4 * c * t5) *\r\n cos(p) +\r\n 3 *\r\n (3 * a * t1 - a * t0 - b * (t2 - t3) + 4 * c * t4) *\r\n sin(p) +\r\n 3 * (a * t5 - b * t4 + c * (t2 - t3)) * cos(2 * p) +\r\n 3 * (a * t4 + b * t5 + c * (t0 + t1)) * sin(2 * p) +\r\n (a * (t2 - t3) - b * (t0 + t1)) * cos(3 * p) +\r\n (a * (t0 + t1) + b * (t2 - t3)) * sin(3 * p)) /\r\n 12);\r\n };\r\n const dt = M4.forSys(dpdu(uvOfPWC.x, uvOfPWC.y), dpdv(uvOfPWC.x, uvOfPWC.y))\r\n .inversed()\r\n .transformVector(tangentWC).y;\r\n const sliceIntegral0ToPWCS = sliceIntegral(uvOfPWC.x); //- sliceIntegral(0) //(always 0)\r\n const result = sliceIntegral0ToPWCS * dt;\r\n return result;\r\n };\r\n return gaussLegendreQuadrature24(f, edgeWC.aT, edgeWC.bT);\r\n }));\r\n // calc centroid:\r\n const centroidZX2Parts = edges.map((edgeWC) => {\r\n const f = (curveT) => {\r\n const curveWC = edgeWC.curve;\r\n const pWC = curveWC.at(curveT), tangentWC = curveWC.tangentAt(curveT);\r\n const uvOfPWC = this.uvP(pWC);\r\n const slice = (phi) => {\r\n const p = this.pUV(phi, uvOfPWC.y);\r\n const normal = dpdu(phi, uvOfPWC.y).cross(dpdv(phi, uvOfPWC.y));\r\n return p.times(p.z * normal.z);\r\n };\r\n const sliceIntegral0ToPWCS = glqV3(slice, 0, uvOfPWC.x);\r\n const dt = M4.forSys(dpdu(uvOfPWC.x, uvOfPWC.y), dpdv(uvOfPWC.x, uvOfPWC.y))\r\n .inversed()\r\n .transformVector(tangentWC).y;\r\n const result = sliceIntegral0ToPWCS.times(dt);\r\n return result;\r\n };\r\n return glqV3(f, edgeWC.aT, edgeWC.bT);\r\n });\r\n const centroid = V3.add(...centroidZX2Parts)\r\n .schur(new V3(1, 1, 0.5))\r\n .div(totalVolume);\r\n return { volume: totalVolume, centroid: centroid };\r\n },\r\n};\r\nZDirVolumeVisitor[EllipsoidSurface.name] =\r\n ZDirVolumeVisitor[RotatedCurveSurface.name];\r\nexport function glqV3(f, startT, endT) {\r\n return gaussLegendre24Xs\r\n .reduce((val, currVal, index) => {\r\n const x = startT + ((currVal + 1) / 2) * (endT - startT);\r\n return val.plus(f(x).times(gaussLegendre24Weights[index]));\r\n }, V3.O)\r\n .times((endT - startT) / 2);\r\n}\r\nexport function glqArray(f, startT, endT, numEls = 3) {\r\n const result = new Array(numEls).fill(0);\r\n for (let i = 0; i < 24; i++) {\r\n const x = startT + ((gaussLegendre24Xs[i] + 1) / 2) * (endT - startT);\r\n const fx = f(x);\r\n for (let j = 0; j < numEls; j++) {\r\n result[j] += fx[j] * gaussLegendre24Weights[i];\r\n }\r\n }\r\n for (let j = 0; j < numEls; j++) {\r\n result[j] *= (endT - startT) / 2;\r\n }\r\n return result;\r\n}\r\nfunction mergeVolumeAndCentroidZX2Parts(volumeAndCentroidZX2Parts) {\r\n const volume = volumeAndCentroidZX2Parts.reduce((result, [volume]) => result + volume, 0);\r\n const weightedCentroid = V3.add(...volumeAndCentroidZX2Parts.map(([, centroidZX2]) => centroidZX2)).schur(new V3(1, 1, 0.5));\r\n return { volume, centroid: weightedCentroid.div(volume) };\r\n}\r\n//# sourceMappingURL=ZDirVolumeVisitor.js.map","import { assert, assertf, eq, glqInSteps, M4, NLA_PRECISION, sum, } from \"ts3dutils\";\r\nimport { ConicSurface, EllipseCurve, EllipsoidSurface, HyperbolaCurve, ImplicitCurve, L3, ParabolaCurve, PlaneSurface, ProjectedCurveSurface, RotatedCurveSurface, } from \"../index\";\r\nimport { ceil, cos, floor, sign, sin } from \"../math\";\r\nexport const CalculateAreaVisitor = {\r\n [ConicSurface.name](edges) {\r\n const dpdu = this.dpdu();\r\n const dpdv = this.dpdv();\r\n // calculation cannot be done in local coordinate system, as the area doesnt scale proportionally\r\n const totalArea = sum(edges.map((edge) => {\r\n if (edge.curve instanceof EllipseCurve ||\r\n edge.curve instanceof HyperbolaCurve ||\r\n edge.curve instanceof ParabolaCurve) {\r\n const f = (t) => {\r\n const at = edge.curve.at(t), tangentWC = edge.tangentAt(t);\r\n const uvOfPWC = this.uvP(at);\r\n // INTEGRATE [0; atUV.y]\r\n // dpdu(atUV.x, t) X dpdv(atUV.x, t)\r\n // dt\r\n // dpdv is constant with respect to t\r\n // => dpdv(atUV.x, 0) X (INTEGRATE [0; atUV.y] dpdu(atUV.x, t) dt)\r\n // dpdu(u, v) === v * dpdu(u, 1)\r\n // => dpdv(atUV.x, 0) X (1/2 t² dpdu(atUV.x, 1))[0; atUV.y]\r\n // => dpdv(atUV.x, 0) X dpdu(atUV.x, atUV.y² / 2)\r\n const du = -M4.forSys(dpdu(uvOfPWC.x, uvOfPWC.y), dpdv(uvOfPWC.x))\r\n .inversed()\r\n .transformVector(tangentWC).x;\r\n return (dpdu(uvOfPWC.x, Math.pow(uvOfPWC.y, 2) / 2)\r\n .cross(dpdv(uvOfPWC.x))\r\n .length() * du);\r\n };\r\n return glqInSteps(f, edge.aT, edge.bT, 1);\r\n }\r\n else if (edge.curve instanceof L3) {\r\n return 0;\r\n }\r\n else {\r\n throw new Error();\r\n }\r\n }));\r\n return totalArea * this.normalDir;\r\n },\r\n [PlaneSurface.name](edges) {\r\n let totalArea = 0;\r\n const r1 = this.right, u1 = this.up;\r\n for (const edge of edges) {\r\n let edgeArea;\r\n const curve = edge.curve;\r\n if (curve instanceof L3) {\r\n edgeArea =\r\n ((edge.a.dot(u1) + edge.b.dot(u1)) / 2) * edge.b.to(edge.a).dot(r1);\r\n }\r\n else if (curve instanceof EllipseCurve) {\r\n // INTEGRATE[aT; bT] (curve.at(t) * u1) * (tangent(t) * r1) dt\r\n // INTEGRATE[aT; bT] (u1 f1 cos t + u1 f2 sin t + u1 c) * (r1 f1 (-sin t) + r1 f2 cos t) dt\r\n const { f1, f2, center } = curve;\r\n const a = u1.dot(f1), b = u1.dot(f2), c = u1.dot(center), d = r1.dot(f1), e = r1.dot(f2);\r\n function fArea(t) {\r\n return (0.25 *\r\n (2 * (-b * d + a * e) * t +\r\n 4 * c * d * cos(t) +\r\n 4 * c * e * sin(t) +\r\n (a * d - b * e) * cos(2 * t) +\r\n (b * d + a * e) * sin(2 * t)));\r\n }\r\n edgeArea = -(fArea(edge.bT) - fArea(edge.aT));\r\n }\r\n else if (curve instanceof ImplicitCurve) {\r\n throw new Error(\"implement for implicitCurve\");\r\n }\r\n else {\r\n const dir1 = u1;\r\n assertf(() => dir1.hasLength(1));\r\n // INT[aT; bT] at(t) * dir1 * tangentAt(t).rejectedFrom(dir1) dt\r\n const f = (curveT) => {\r\n const at = curve.at(curveT);\r\n const tangent = curve.tangentAt(curveT);\r\n const ds = r1.dot(tangent);\r\n const t = u1.dot(at);\r\n return ds * t;\r\n };\r\n edgeArea = glqInSteps(f, edge.aT, edge.bT, 3);\r\n }\r\n totalArea += edgeArea;\r\n }\r\n assert(isFinite(totalArea));\r\n return totalArea;\r\n },\r\n [RotatedCurveSurface.name](edges, canApproximate = true) {\r\n const f1 = this.matrix.X, f2 = this.matrix.Y, f3 = this.matrix.Z;\r\n const likeVerticalSpheroid = eq(f1.length(), f2.length()) &&\r\n f1.isPerpendicularTo(f2) &&\r\n f2.isPerpendicularTo(f3) &&\r\n f3.isPerpendicularTo(f1);\r\n const areaParts = edges.map((edgeWC, ei) => {\r\n console.log(\"edge\", ei, edgeWC.sce);\r\n const curveWC = edgeWC.curve;\r\n if (edgeWC.curve instanceof ImplicitCurve) {\r\n throw new Error();\r\n }\r\n else {\r\n if (likeVerticalSpheroid) {\r\n const f = (curveT) => {\r\n const pWC = curveWC.at(curveT), tangent = curveWC.tangentAt(curveT);\r\n const pLC = this.matrixInverse.transformPoint(pWC);\r\n const { x: angleXY, y: t } = this.uvP(pWC);\r\n const arcRadius = this.matrix.transformVector(pLC.xy()).length();\r\n const arcLength = angleXY * arcRadius;\r\n const dpdv = this.dpdv()(angleXY, t).unit();\r\n const scaling = dpdv.dot(tangent);\r\n return arcLength * scaling;\r\n };\r\n return glqInSteps(f, edgeWC.aT, edgeWC.bT, 1);\r\n }\r\n else {\r\n const dpdu = this.dpdu(), dpdv = this.dpdv();\r\n const f2 = (curveT) => {\r\n const pWC = curveWC.at(curveT), tangentWC = curveWC.tangentAt(curveT);\r\n const uvPWC = this.uvP(pWC);\r\n const slice = (phi) => {\r\n //return this.dpdu()(phi, st.y).length() * this.dpdv()(phi, st.y).length()\r\n return dpdu(phi, uvPWC.y).cross(dpdv(phi, uvPWC.y)).length();\r\n };\r\n // we need to do a coordinate transform from curveT to dt, as that is what we are integrating\r\n const dt = M4.forSys(dpdu(uvPWC.x, uvPWC.y), dpdv(uvPWC.x, uvPWC.y))\r\n .inversed()\r\n .transformVector(tangentWC).y;\r\n return glqInSteps(slice, 0, uvPWC.x, 1) * dt;\r\n };\r\n return glqInSteps(f2, edgeWC.aT, edgeWC.bT, 1);\r\n }\r\n }\r\n });\r\n return sum(areaParts);\r\n },\r\n [ProjectedCurveSurface.name](edges) {\r\n // calculation cannot be done in local coordinate system, as the area doesn't scale proportionally\r\n const thisDir1 = this.dir.unit();\r\n const totalArea = sum(edges.map((edge) => {\r\n if (edge.curve instanceof L3) {\r\n return 0;\r\n }\r\n else if (edge.curve instanceof ImplicitCurve) {\r\n const { points, tangents } = edge.curve;\r\n const minT = edge.minT, maxT = edge.maxT;\r\n let sum = 0;\r\n const start = ceil(minT + NLA_PRECISION);\r\n const end = floor(maxT - NLA_PRECISION);\r\n for (let i = start; i <= end; i++) {\r\n const at = points[i], tangent = tangents[i]; //.toLength(edge.curve.stepSize)\r\n const scaling = this.normalP(at).cross(thisDir1).unit().dot(tangent);\r\n sum += at.dot(thisDir1) * scaling;\r\n }\r\n const f = (t) => {\r\n const at = edge.curve.at(t), tangent = edge.curve.tangentAt(t);\r\n const scaling = this.normalP(at).cross(thisDir1).unit().dot(tangent);\r\n return at.dot(thisDir1) * scaling;\r\n };\r\n sum += f(minT) * (start - minT - 0.5);\r\n sum += f(maxT) * (maxT - end - 0.5);\r\n return sum * sign(edge.deltaT());\r\n }\r\n else {\r\n const f = (t) => {\r\n const at = edge.curve.at(t);\r\n const tangent = edge.tangentAt(t);\r\n const scaling = tangent.rejected1Length(thisDir1);\r\n return at.dot(thisDir1) * scaling;\r\n };\r\n const val = glqInSteps(f, edge.aT, edge.bT, 1);\r\n const sign = Math.sign(this.normalP(edge.a)\r\n .cross(this.dir)\r\n .dot(edge.curve.tangentAt(edge.aT)));\r\n assert(0 !== sign);\r\n return val * sign;\r\n }\r\n }));\r\n console.log(\"totalArea\", totalArea);\r\n return totalArea;\r\n },\r\n};\r\nCalculateAreaVisitor[EllipsoidSurface.name] =\r\n CalculateAreaVisitor[RotatedCurveSurface.name];\r\n//# sourceMappingURL=CalculateAreaVisitor.js.map","import * as opentype from \"opentype.js\";\r\nimport { arrayFromFunction, assert, assertf, assertInst, assertNumbers, assertVectors, callsce, eq, eq0, getLast, GOLDEN_RATIO, le, lerp, lt, M4, MINUS, snap, TAU, V, V3, VV, } from \"ts3dutils\";\r\nimport { BezierCurve, BRep, ConicSurface, CylinderSurface, Edge, EllipseCurve, EllipsoidSurface, Face, getGlobalId, L3, NURBS, P3, PCurveEdge, PlaneFace, PlaneSurface, ProjectedCurveSurface, RotatedCurveSurface, StraightEdge, XiEtaCurve, createEdge, edgeForCurveAndTs, edgePathFromSVG, } from \".\";\r\nimport { max, min, PI, SQRT1_2 } from \"./math\";\r\nimport { NURBSSurface } from \"./surface/NURBSSurface\";\r\n/**\r\n * Create a surface by projecting a curve in a direction.\r\n *\r\n * @param curve The curve to project.\r\n * @param offset The direction and distance to project curve.\r\n * @param flipped Whether the surface's default orientation (normal = curve tangent cross offset) should be flipped.\r\n */\r\nexport function projectCurve(curve, offset, flipped) {\r\n if (curve instanceof L3) {\r\n const surfaceNormal = offset.cross(curve.dir1).toLength(flipped ? -1 : 1);\r\n return new PlaneSurface(P3.normalOnAnchor(surfaceNormal, curve.anchor));\r\n }\r\n if (curve instanceof EllipseCurve) {\r\n const curveDir = flipped ? offset : offset.negated();\r\n return new CylinderSurface(curve, curveDir.unit(), undefined, undefined);\r\n }\r\n if (curve instanceof BezierCurve || curve instanceof XiEtaCurve) {\r\n const curveDir = offset.times(flipped ? 1 : -1);\r\n return new ProjectedCurveSurface(curve, curveDir, undefined, undefined, flipped ? 0 : -1, flipped ? 1 : 0);\r\n }\r\n throw new Error();\r\n}\r\n/**\r\n * Create a surface by projecting a curve onto a point.\r\n */\r\nexport function projectPointCurve(curve, tMin = curve.tMin, tMax = curve.tMax, p, flipped) {\r\n if (curve instanceof L3) {\r\n const up = curve.anchor.to(p).rejectedFrom(curve.dir1);\r\n return PlaneSurface.forAnchorAndPlaneVectors(curve.anchor, curve.dir1, up.unit(), tMin, tMax, 0, up.length());\r\n }\r\n else if (curve instanceof EllipseCurve) {\r\n // flip f2 by default\r\n const factor = -1 * (flipped ? -1 : 1);\r\n return new ConicSurface(p, curve.f1.times(factor), curve.f2, p.to(curve.center), tMin, tMax, 0, 1);\r\n }\r\n else {\r\n throw new Error(\"projectPointCurve not implemented for \" + curve.constructor.name);\r\n }\r\n}\r\n/**\r\n * Create a surface by rotating a curve in the XZ-plane, with X > 0, around the Z-axis according to the right-hand rule.\r\n * @param curve The curve to rotate.\r\n * @param tMin The minimum value for t for which the surface should be defined.\r\n * @param tMax The maximum value for t for which the surface should be defined.\r\n * @param angle How much the curve should be rotated. sMin/sMax will be be 0/angle.\r\n * @param flipped Whether the surface's default orientation (normal = curve tangent cross rotation tangent) should be\r\n * flipped.\r\n */\r\nexport function rotateCurve(curve, tMin = curve.tMin, tMax = curve.tMax, angle, flipped) {\r\n assertf(() => new PlaneSurface(P3.ZX).containsCurve(curve));\r\n if (curve instanceof L3) {\r\n if (curve.dir1.isParallelTo(V3.Z)) {\r\n if (eq0(curve.anchor.x)) {\r\n return undefined;\r\n //throw new Error('Cannot rotate curve colinear to Z axis.')\r\n }\r\n const baseEllipse = new EllipseCurve(V3.O, curve.anchor.xy(), curve.anchor.xy().getPerpendicular(), 0, angle);\r\n // if curve.dir1 is going up (+Z), it the cylinder surface should face inwards\r\n const factor = (curve.dir1.z > 0 ? -1 : 1) * (flipped ? -1 : 1);\r\n const [zMin, zMax] = [\r\n curve.at(tMin).z * factor,\r\n curve.at(tMax).z * factor,\r\n ].sort(MINUS);\r\n return new CylinderSurface(baseEllipse, V3.Z.times(factor), 0, angle, zMin, zMax);\r\n }\r\n if (curve.at(tMin).xy().dot(curve.dir1) *\r\n curve.at(tMax).xy().dot(curve.dir1) <\r\n 0) {\r\n throw new Error(\"line cannot cross the Z axis in the [tMin, tMax] interval, as conic surfaces cannot have an hourglass shape.\");\r\n }\r\n if (curve.dir1.isPerpendicularTo(V3.Z)) {\r\n // if line.dir1 is pointing aways from V3.Z, then the surface should face up\r\n const factor = (curve.at(lerp(tMin, tMax, 0.5)).dot(curve.dir1) > 0 ? 1 : -1) *\r\n (flipped ? -1 : 1);\r\n return new PlaneSurface(new P3(V3.Z.times(factor), curve.anchor.z * factor));\r\n }\r\n else {\r\n // apex is intersection of segment with Z-axis\r\n const a = curve.at(tMin), b = curve.at(tMax);\r\n const apexZ = a.z - (a.x * (b.z - a.z)) / (b.x - a.x);\r\n const apex = new V3(0, 0, apexZ);\r\n const factor = -(a.x > b.x ? -1 : 1) * (flipped ? -1 : 1);\r\n const s = new ConicSurface(apex, new V3(curve.dir1.lengthXY(), 0, 0), new V3(0, curve.dir1.lengthXY(), 0), new V3(0, 0, (a.x > b.x ? -1 : 1) * curve.dir1.z), 0, angle, 0, 1);\r\n return factor > 0 ? s : s.flipped();\r\n }\r\n }\r\n if (curve instanceof EllipseCurve) {\r\n const a = curve.at(tMin), b = curve.at(tMax);\r\n const ell = curve.rightAngled();\r\n const f1Perp = ell.f1.isPerpendicularTo(V3.Z), f2Perp = ell.f2.isPerpendicularTo(V3.Z);\r\n if (L3.Z.containsPoint(ell.center) && (f1Perp || f2Perp)) {\r\n flipped = flipped == a.z > b.z;\r\n let width = ell.f1.length(), height = ell.f2.length();\r\n if (ell.f1.isParallelTo(V3.Z)) {\r\n ;\r\n [width, height] = [height, width];\r\n }\r\n return EllipsoidSurface.forABC(width, (!flipped ? 1 : -1) * width, height, ell.center);\r\n }\r\n else {\r\n const s = new RotatedCurveSurface(curve, M4.IDENTITY, tMin, tMax);\r\n return s;\r\n }\r\n }\r\n throw new Error();\r\n}\r\nexport var B2T;\r\n(function (B2T) {\r\n /**\r\n * Create a [BRep] of an axis-aligned box width starting at the origin and extending into +XYZ space.\r\n * @param width x-direction size.\r\n * @param height y-direction size.\r\n * @param depth z-direction size.\r\n * @param name\r\n */\r\n function box(width = 1, height = 1, depth = 1, name = \"box\" + getGlobalId()) {\r\n assertNumbers(width, height, depth);\r\n assert(\"string\" === typeof name);\r\n const baseVertices = [\r\n new V3(0, 0, 0),\r\n new V3(0, height, 0),\r\n new V3(width, height, 0),\r\n new V3(width, 0, 0),\r\n ];\r\n const generator = callsce(\"B2T.box\", width, height, depth, name);\r\n return B2T.extrudeVertices(baseVertices, P3.XY.flipped(), new V3(0, 0, depth), name, generator);\r\n }\r\n B2T.box = box;\r\n function puckman(radius, rads, height, name = \"puckman\" + getGlobalId()) {\r\n assertf(() => lt(0, radius));\r\n assertf(() => lt(0, rads) && le(rads, TAU));\r\n assertf(() => lt(0, height));\r\n const edges = StraightEdge.chain([\r\n V3.O,\r\n new V3(radius, 0, 0),\r\n new V3(radius, 0, height),\r\n new V3(0, 0, height),\r\n ], true);\r\n return B2T.rotateEdges(edges, rads, name);\r\n }\r\n B2T.puckman = puckman;\r\n function registerVertexName(map, name, p) {\r\n // TODO\r\n if (!Array.from(map.keys()).some((p2) => p2.like(p))) {\r\n map.set(p, name);\r\n }\r\n }\r\n B2T.registerVertexName = registerVertexName;\r\n /**\r\n * Create a [BRep] by projecting a number of edges in a direction.\r\n * @param baseFaceEdges\r\n * @param baseFacePlane\r\n * @param offset\r\n * @param name\r\n * @param gen\r\n * @param infoFactory\r\n */\r\n function extrudeEdges(baseFaceEdges, baseFacePlane = P3.XY, offset = V3.Z, name = \"extrude\" + getGlobalId(), gen, infoFactory) {\r\n baseFaceEdges = fixEdges(baseFaceEdges);\r\n //Array.from(combinations(baseFaceEdges.length)).forEach(({i, j}) => {\r\n //\tassertf(() => !Edge.edgesIntersect(baseFaceEdges[i], baseFaceEdges[j]), baseFaceEdges[i].sce +\r\n // baseFaceEdges[j].sce) })\r\n assertf(() => Edge.isLoop(baseFaceEdges));\r\n // TODO checks..\r\n //if (offset.dot(baseFacePlane.normal1) > 0) {\r\n //\tbaseFacePlane = baseFacePlane.flipped()\r\n //}\r\n const vertexNames = new Map();\r\n const basePlaneSurface = new PlaneSurface(baseFacePlane);\r\n //assert(basePlaneSurface.edgeLoopCCW(baseFaceEdges), 'edges not CCW on baseFacePlane')\r\n const translationMatrix = M4.translate(offset);\r\n const topEdges = baseFaceEdges.map((edge) => edge.transform(translationMatrix, \"top\"));\r\n const edgeCount = baseFaceEdges.length;\r\n const bottomInfo = infoFactory && infoFactory.extrudeBottom(basePlaneSurface, baseFaceEdges);\r\n const bottomFace = new PlaneFace(basePlaneSurface, baseFaceEdges, [], name + \"Bottom\", bottomInfo);\r\n const topFaceEdges = topEdges.map((edge) => edge.flipped()).reverse();\r\n const topSurface = new PlaneSurface(baseFacePlane.flipped().translated(offset));\r\n const topInfo = infoFactory && infoFactory.extrudeBottom(topSurface, topFaceEdges);\r\n const topFace = new PlaneFace(topSurface, topFaceEdges, [], name + \"Top\", topInfo);\r\n baseFaceEdges.forEach((edge) => B2T.registerVertexName(vertexNames, edge.name + \"A\", edge.a));\r\n topFaceEdges.forEach((edge) => B2T.registerVertexName(vertexNames, edge.name + \"A\", edge.a));\r\n const ribs = arrayFromFunction(edgeCount, (i) => StraightEdge.throughPoints(baseFaceEdges[i].a, topEdges[i].a, name + \"Rib\" + i));\r\n const faces = baseFaceEdges.map((edge, i) => {\r\n const faceName = name + \"Wall\" + i;\r\n const j = (i + 1) % edgeCount;\r\n const faceEdges = [\r\n baseFaceEdges[i].flipped(),\r\n ribs[i],\r\n topEdges[i],\r\n ribs[j].flipped(),\r\n ];\r\n const surface = projectCurve(edge.curve, offset, edge.reversed);\r\n const info = infoFactory && infoFactory.extrudeWall(i, surface, faceEdges);\r\n return Face.create(surface, faceEdges, undefined, faceName, info);\r\n });\r\n faces.push(bottomFace, topFace);\r\n gen =\r\n gen ||\r\n callsce(\"B2T.extrudeEdges\", baseFaceEdges, baseFacePlane, offset, name);\r\n return new BRep(faces, baseFacePlane.normal1.dot(offset) > 0, gen, vertexNames);\r\n }\r\n B2T.extrudeEdges = extrudeEdges;\r\n function cylinder(radius = 1, height = 1, rads = TAU, name = \"cylinder\" + getGlobalId()) {\r\n const vertices = [\r\n new V3(0, 0, 0),\r\n new V3(radius, 0, 0),\r\n new V3(radius, 0, height),\r\n new V3(0, 0, height),\r\n ];\r\n return rotateEdges(StraightEdge.chain(vertices, true), rads, name);\r\n }\r\n B2T.cylinder = cylinder;\r\n function cone(radius = 1, height = 1, rads = TAU, name = \"cone\" + getGlobalId()) {\r\n const vertices = [\r\n new V3(0, 0, 0),\r\n new V3(radius, 0, height),\r\n new V3(0, 0, height),\r\n ];\r\n return rotateEdges(StraightEdge.chain(vertices, true), rads, name);\r\n }\r\n B2T.cone = cone;\r\n function sphere(radius = 1, name = \"sphere\" + getGlobalId(), rot = TAU) {\r\n const ee = new PCurveEdge(new EllipseCurve(V3.O, new V3(0, 0, -radius), new V3(radius, 0, 0)), new V3(0, 0, -radius), new V3(0, 0, radius), 0, PI, undefined, new V3(radius, 0, 0), new V3(-radius, 0, 0));\r\n const generator = callsce(\"B2T.sphere\", radius, name, rot);\r\n return rotateEdges([StraightEdge.throughPoints(ee.b, ee.a), ee], rot, name, generator);\r\n }\r\n B2T.sphere = sphere;\r\n /**\r\n * Create a [[BRep]] of a menger sponge.\r\n * @param res 0: just a cube, 1: every cube face has one hole, 2: 9 holes, etc\r\n * @param name\r\n */\r\n function menger(res = 2, name = \"menger\" + getGlobalId()) {\r\n let result = B2T.box(1, 1, 1);\r\n if (0 == res)\r\n return result;\r\n const punch = B2T.box(1 / 3, 1 / 3, 2)\r\n .translate(1 / 3, 1 / 3, -1 / 2)\r\n .flipped();\r\n function recurse(steps, m4) {\r\n result = result.and(punch.transform(m4));\r\n if (steps > 1) {\r\n const scaled = m4.times(M4.scale(1 / 3, 1 / 3, 1));\r\n for (let i = 0; i < 9; i++) {\r\n if (4 == i)\r\n continue;\r\n recurse(steps - 1, scaled.times(M4.translate(i % 3, (i / 3) | 0, 0)));\r\n }\r\n }\r\n }\r\n recurse(res, M4.IDENTITY);\r\n recurse(res, M4.YZX);\r\n recurse(res, M4.ZXY);\r\n return result;\r\n }\r\n B2T.menger = menger;\r\n function menger2(res = 2, name = \"menger\" + getGlobalId()) {\r\n if (0 == res)\r\n return B2T.box(1, 1, 1);\r\n const punch = B2T.box(1 / 3, 1 / 3, 2)\r\n .translate(1 / 3, 1 / 3, -1 / 2)\r\n .flipped();\r\n const stencilFaces = [];\r\n function recurse(steps, m4) {\r\n stencilFaces.push(...punch.transform(m4).faces);\r\n if (steps > 1) {\r\n const scaled = m4.times(M4.scale(1 / 3, 1 / 3, 1));\r\n for (let i = 0; i < 9; i++) {\r\n if (4 == i)\r\n continue;\r\n recurse(steps - 1, scaled.times(M4.translate(i % 3, (i / 3) | 0, 0)));\r\n }\r\n }\r\n }\r\n recurse(res, M4.IDENTITY);\r\n const stencil = new BRep(stencilFaces, true);\r\n return B2T.box(1, 1, 1, name)\r\n .and(stencil)\r\n .and(stencil.transform(M4.YZX))\r\n .and(stencil.transform(M4.ZXY));\r\n }\r\n B2T.menger2 = menger2;\r\n /**\r\n * Create a [BRep] of a torus.\r\n * @param rSmall The radius to the surface of the torus.\r\n * @param rLarge The radius from the origin to the inside of the torus.\r\n * @param rads\r\n * @param name\r\n */\r\n function torus(rSmall, rLarge, rads = TAU, name = \"torus\" + getGlobalId()) {\r\n assertNumbers(rSmall, rLarge, rads);\r\n assertf(() => rLarge > rSmall);\r\n const curves = [\r\n EllipseCurve.semicircle(rSmall, new V3(rLarge, 0, 0)),\r\n EllipseCurve.semicircle(-rSmall, new V3(rLarge, 0, 0)),\r\n ];\r\n const baseEdges = curves.map((c) => PCurveEdge.forCurveAndTs(c, 0, Math.PI).rotateX(PI / 2));\r\n return B2T.rotateEdges(baseEdges, rads, name);\r\n }\r\n B2T.torus = torus;\r\n /**\r\n * Create a [BRep] by smoothly rotating edges around Z.\r\n * baseLoop should be CCW on XZ plane for a bounded BRep\r\n */\r\n function rotateEdges(baseLoop, totalRads, name = \"rotateEdges\" + getGlobalId(), generator, infoFactory) {\r\n assert(baseLoop.every((e) => new PlaneSurface(P3.ZX).containsCurve(e.curve)));\r\n assert(!eq(PI, totalRads) || PI == totalRads); // URHGJ\r\n assertf(() => lt(0, totalRads) && le(totalRads, TAU));\r\n totalRads = snap(totalRads, TAU);\r\n assertf(() => Edge.isLoop(baseLoop));\r\n const basePlane = new PlaneSurface(P3.ZX.flipped()).edgeLoopCCW(baseLoop)\r\n ? new PlaneSurface(P3.ZX.flipped())\r\n : new PlaneSurface(P3.ZX);\r\n // const rotationSteps = ceil((totalRads - NLA_PRECISION) / PI)\r\n // const angles = rotationSteps == 1 ? [-PI, -PI + totalRads] : [-PI, 0, totalRads - PI]\r\n const open = !eq(totalRads, 2 * PI);\r\n const baseRibCurves = baseLoop.map((edge) => {\r\n const a = edge.a, radius = a.lengthXY();\r\n if (!eq0(radius)) {\r\n return new EllipseCurve(V(0, 0, a.z), V(radius, 0, 0), V(0, radius, 0));\r\n }\r\n return undefined;\r\n });\r\n const baseSurfaces = baseLoop.map((edge) => {\r\n const s = rotateCurve(edge.curve, edge.minT, edge.maxT, PI, edge.deltaT() > 0);\r\n const t = lerp(edge.aT, edge.bT, 0.5);\r\n s &&\r\n assert(edge\r\n .tangentAt(t)\r\n .cross(V3.Y)\r\n .dot(s.normalP(edge.curve.at(t))) < 0);\r\n return s;\r\n });\r\n let stepStartEdges = baseLoop, stepEndEdges;\r\n const faces = [];\r\n for (let rot = 0; rot < totalRads; rot += PI) {\r\n const aT = 0, bT = min(totalRads - rot, PI);\r\n const rotation = M4.rotateZ(rot + bT);\r\n stepEndEdges =\r\n rot + bT == TAU\r\n ? baseLoop\r\n : baseLoop.map((edge) => edge.transform(rotation));\r\n const ribs = arrayFromFunction(baseLoop.length, (i) => {\r\n const a = stepStartEdges[i].a, radius = a.lengthXY();\r\n const b = stepEndEdges[i].a;\r\n if (!eq0(radius)) {\r\n const curve = 0 === rot ? baseRibCurves[i] : baseRibCurves[i].rotateZ(rot);\r\n return new PCurveEdge(curve, a, b, aT, bT, undefined, curve.tangentAt(aT), curve.tangentAt(bT), name + \"rib\" + i);\r\n }\r\n return undefined;\r\n });\r\n for (let edgeIndex = 0; edgeIndex < baseLoop.length; edgeIndex++) {\r\n if (baseSurfaces[edgeIndex]) {\r\n const edge = stepStartEdges[edgeIndex];\r\n const ipp = (edgeIndex + 1) % baseLoop.length;\r\n const faceEdges = [\r\n stepStartEdges[edgeIndex].flipped(),\r\n !eq0(edge.a.x) && ribs[edgeIndex],\r\n stepEndEdges[edgeIndex],\r\n !eq0(edge.b.x) && ribs[ipp].flipped(),\r\n ].filter((x) => x);\r\n const surface = 0 === rot\r\n ? baseSurfaces[edgeIndex]\r\n : baseSurfaces[edgeIndex].rotateZ(rot);\r\n const info = infoFactory &&\r\n infoFactory.extrudeWall(edgeIndex, surface, faceEdges, undefined);\r\n faces.push(Face.create(surface, faceEdges, undefined, name + \"Wall\" + edgeIndex, info));\r\n }\r\n }\r\n stepStartEdges = stepEndEdges;\r\n }\r\n if (open) {\r\n const endFaceEdges = Edge.reversePath(stepEndEdges);\r\n const infoStart = infoFactory && infoFactory.rotationStart(basePlane, baseLoop, undefined);\r\n const infoEnd = infoFactory &&\r\n infoFactory.rotationEnd(basePlane.flipped().rotateZ(totalRads), endFaceEdges, undefined);\r\n faces.push(new PlaneFace(basePlane, baseLoop, undefined, name + \"start\", infoStart), new PlaneFace(basePlane.flipped().rotateZ(totalRads), endFaceEdges, undefined, name + \"end\", infoEnd));\r\n }\r\n const infiniteVolume = new PlaneSurface(P3.ZX).edgeLoopCCW(baseLoop);\r\n return new BRep(faces, infiniteVolume, generator);\r\n }\r\n B2T.rotateEdges = rotateEdges;\r\n /**\r\n * loop should be CCW on XZ plane for a bounded BRep\r\n */\r\n //export function rotateEdgesUnsplit(loop: Edge[], rads: raddd, name: string): BRep {\r\n //\tassert(Edge.isLoop(loop))\r\n //\tconst rotationMatrix = M4.rotateZ(rads)\r\n //\tconst open = !eq(rads, 2 * PI)\r\n //\tconst endEdges = open ? loop.map(edge => edge.transform(rotationMatrix)) : loop\r\n //\tconst edgeCount = loop.length\r\n //\tconst ribs = arrayFromFunction(edgeCount, i => {\r\n //\t\tconst a = loop[i].a, radius = a.lengthXY()\r\n //\t\tconst b = endEdges[i].a\r\n //\t\tif (!eq0(radius)) {\r\n //\t\t\tconst curve = new EllipseCurve(V(0, 0, a.z), V(-radius, 0, 0), V(0, -radius, 0))\r\n //\t\t\tconst aT = -PI, bT = -PI + rads\r\n //\t\t\treturn new PCurveEdge(curve, a, b, aT, bT, undefined, curve.tangentAt(aT), curve.tangentAt(bT), name\r\n // + 'rib' + i) } }) const faces = loop.map((edge, i) => { const ipp = (i + 1) % edgeCount console.log('ljl', i,\r\n // ipp, ribs) const faceEdges = [ edge.flipped(), !eq0(edge.a.x) && ribs[i], endEdges[i], !eq0(edge.b.x) &&\r\n // ribs[ipp].flipped()].filter(x => x) if (edge instanceof StraightEdge) { const line = edge.curve let surface if\r\n // (line.dir1.isParallelTo(V3.Z)) { if (eq0(edge.a.x)) { return } let flipped = edge.a.z > edge.b.z surface = new\r\n // CylinderSurface(ribs[i].curve, !flipped ? V3.Z : V3.Z.negated()) } else if\r\n // (line.dir1.isPerpendicularTo(V3.Z)) { let flipped = edge.a.x > edge.b.x let surface = new PlaneSurface(new\r\n // P3(V3.Z, edge.a.z)) if (!flipped) surface = surface.flipped() if (!open) { const hole = flipped ? !eq0(edge.b.x)\r\n // && ribs[ipp].flipped() : !eq0(edge.a.x) && ribs[i] return new PlaneFace(surface, [flipped ? ribs[i] :\r\n // ribs[ipp].flipped()], hole && [[hole]]) } return new PlaneFace(surface, faceEdges) } else { // apex is\r\n // intersection of segment with Z-axis let a = edge.a, b = edge.b let apexZ = a.z - a.x * (b.z - a.z) / (b.x - a.x)\r\n // let apex = new V3(0, 0, apexZ) let flipped = edge.a.z > edge.b.z surface =\r\n // ConicSurface.atApexThroughEllipse(apex, ribs[a.x > b.x ? i : ipp].curve as EllipseCurve, !flipped ? 1 : -1)\r\n // } return Face.create(surface, faceEdges) } if (edge.curve instanceof EllipseCurve) { let flipped = undefined\r\n // let ell = edge.curve.rightAngled() let f1Perp = ell.f1.isPerpendicularTo(V3.Z), f2Perp =\r\n // ell.f2.isPerpendicularTo(V3.Z) if (L3.Z.containsPoint(ell.center) && (f1Perp || f2Perp)) { let f3length = f1Perp\r\n // ? ell.f1.length() : ell.f2.length() if (flipped) { f3length *= -1 } let surface = new\r\n // EllipsoidSurface(ell.center, ell.f1, ell.f2, ell.f1.cross(ell.f2).toLength(f3length)) return new\r\n // RotationFace(surface, faceEdges) } } else { assert(false, edge) } }).filter(x => x) if (open) { const\r\n // endFaceEdges = endEdges.map(edge => edge.flipped()).reverse() faces.push( new PlaneFace(new\r\n // PlaneSurface(P3.ZX.flipped()), loop), new PlaneFace(new PlaneSurface(P3.ZX.rotateZ(rads)), endFaceEdges)) }\r\n // return new BRep(faces, undefined) }\r\n function quaffle() {\r\n const baseK = B2T.sphere(1).translate(0, 1.7).flipped();\r\n //const baseK = B2T.box().scale(0.2).translate(0, 0.95).flipped()\r\n // const vs = B2T.DODECAHEDRON_VERTICES.concat(\r\n // B2T.DODECAHEDRON_FACE_VERTICES.map(fis => fis\r\n // .map(vi => B2T.DODECAHEDRON_VERTICES[vi])\r\n // .reduce((a,b) => a.plus(b), V3.O)\r\n // .unit()))\r\n const ss = new BRep(B2T.TETRAHEDRON_VERTICES.flatMap((v) => baseK.rotateAB(V3.Y, v).faces), false);\r\n //return ss\r\n return B2T.sphere().and(ss);\r\n }\r\n B2T.quaffle = quaffle;\r\n function extrudeFace(face, dir) {\r\n return new BRep(extrudeEdges(face.contour, face.surface.plane, dir)\r\n .faces.slice(0, -2)\r\n .concat(face, face.translate(dir.x, dir.y, dir.z).flipped(), face.holes.flatMap((hole) => extrudeEdges(hole, face.surface.plane.flipped(), dir).faces.slice(0, -2))), false);\r\n }\r\n B2T.extrudeFace = extrudeFace;\r\n function loadFonts() {\r\n return loadFont(\"fonts/FiraSansMedium.woff\").then((font) => (B2T.defaultFont = font));\r\n }\r\n B2T.loadFonts = loadFonts;\r\n const loadedFonts = new Map();\r\n function loadFont(fontPath) {\r\n return new Promise(function (resolve, reject) {\r\n const font = loadedFonts.get(fontPath);\r\n if (font) {\r\n resolve(font);\r\n }\r\n else {\r\n opentype.load(fontPath, function (err, f) {\r\n if (err) {\r\n reject(err);\r\n }\r\n else {\r\n loadedFonts.set(fontPath, f);\r\n resolve(f);\r\n }\r\n });\r\n }\r\n });\r\n }\r\n B2T.loadFont = loadFont;\r\n function loadFontsAsync(callback) {\r\n if (B2T.defaultFont) {\r\n callback();\r\n }\r\n else {\r\n opentype.load(\"fonts/FiraSansMedium.woff\", function (err, font) {\r\n if (err) {\r\n throw new Error(\"Could not load font: \" + err);\r\n }\r\n else {\r\n B2T.defaultFont = font;\r\n callback();\r\n }\r\n });\r\n }\r\n }\r\n B2T.loadFontsAsync = loadFontsAsync;\r\n /**\r\n * Create the [BRep] of a string rendered in a font.\r\n * @param text\r\n * @param size\r\n * @param depth\r\n * @param font An opentype.js font.\r\n */\r\n function text(text, size, depth = 1, font = B2T.defaultFont) {\r\n const path = font.getPath(text, 0, 0, size);\r\n const subpaths = [];\r\n path.commands.forEach((c) => {\r\n if (c.type == \"M\") {\r\n subpaths.push([]);\r\n }\r\n getLast(subpaths).push(c);\r\n });\r\n const loops = subpaths.map((sp) => {\r\n const path = new opentype.Path();\r\n path.commands = sp;\r\n const loop = Edge.reversePath(edgePathFromSVG(path.toPathData(13))).map((e) => e.mirrorY());\r\n assert(Edge.isLoop(loop));\r\n return loop;\r\n });\r\n const faces = Face.assembleFacesFromLoops(loops, new PlaneSurface(P3.XY), PlaneFace);\r\n const generator = callsce(\"B2T.text\", text, size, depth);\r\n return BRep.join(faces.map((face) => B2T.extrudeFace(face, V(0, 0, -depth))), generator);\r\n }\r\n B2T.text = text;\r\n function minorityReport() {\r\n const a = B2T.sphere();\r\n const b = B2T.text(\"LEO CROW\", 64, 128)\r\n .scale(0.1 / 32)\r\n .translate(-0.5, -0.05, 1.2)\r\n .flipped();\r\n const c = B2T.sphere(0.98);\r\n return a.and(b).plus(c);\r\n }\r\n B2T.minorityReport = minorityReport;\r\n function whatever() {\r\n const iso = icosahedron();\r\n const numbersBRep = BRep.join(iso.faces.map((face, i) => {\r\n const numberBRep = text(\"\" + (i + 1), 0.4, -2);\r\n const centroid = face.contour\r\n .map((edge) => edge.a)\r\n .reduce((a, b) => a.plus(b), V3.O)\r\n .div(3);\r\n const sys = M4.forSys(face.contour[0].aDir, centroid.cross(face.contour[0].aDir), centroid.unit(), centroid);\r\n return numberBRep.transform(sys.times(M4.translate(-numberBRep.getAABB().size().x / 2, -0.1, -0.04)));\r\n }));\r\n const s = sphere(0.9);\r\n //return iso.and(numbersBRep)\r\n return iso.and(s).and(numbersBRep);\r\n //return numbersBRep\r\n }\r\n B2T.whatever = whatever;\r\n function whatever3() {\r\n const t = B2T.torus(1, 2);\r\n return B2T.box(5, 5, 2).translate(-2.5, -2.5).minus(t);\r\n }\r\n B2T.whatever3 = whatever3;\r\n function d20() {\r\n const iso = icosahedron();\r\n const numbersBRep = BRep.join(iso.faces.map((face, i) => {\r\n const numberBRep = text(\"\" + (i + 1), 0.4, -2);\r\n const centroid = face.contour\r\n .map((edge) => edge.a)\r\n .reduce((a, b) => a.plus(b), V3.O)\r\n .div(3);\r\n const sys = M4.forSys(face.contour[0].aDir, centroid.cross(face.contour[0].aDir), centroid.unit(), centroid);\r\n return numberBRep.transform(sys.times(M4.translate(-numberBRep.getAABB().size().x / 2, -0.1, -0.04)));\r\n }));\r\n const s = sphere(0.9);\r\n //return iso.and(numbersBRep)\r\n return iso.and(s).and(numbersBRep);\r\n //return numbersBRep\r\n }\r\n B2T.d20 = d20;\r\n function rotStep(edges, totalRadsOrAngles, countO) {\r\n const angles = \"number\" === typeof totalRadsOrAngles\r\n ? arrayFromFunction(countO, (i) => ((i + 1) / countO) * totalRadsOrAngles)\r\n : totalRadsOrAngles;\r\n const count = angles.length;\r\n const open = !eq(TAU, getLast(angles));\r\n const ribs = [\r\n edges,\r\n ...angles.map((phi) => {\r\n if (eq(TAU, phi)) {\r\n return edges;\r\n }\r\n const matrix = M4.rotateZ(phi);\r\n return edges.map((edge) => edge.transform(matrix));\r\n }),\r\n ];\r\n const horizontalEdges = arrayFromFunction(count, (i) => {\r\n const ipp = (i + 1) % (count + 1);\r\n return arrayFromFunction(edges.length, (j) => {\r\n if (!eq0(edges[j].a.lengthXY())) {\r\n return StraightEdge.throughPoints(ribs[i][j].a, ribs[ipp][j].a);\r\n }\r\n return undefined;\r\n });\r\n });\r\n const faces = [];\r\n let face;\r\n edges.forEach((edge, i) => {\r\n const ipp = (i + 1) % edges.length;\r\n // for straight edges perpendicular to the Z-axis, we only create one face.\r\n if (edge instanceof StraightEdge &&\r\n edge.curve.dir1.isPerpendicularTo(V3.Z)) {\r\n const flipped = edge.a.x > edge.b.x;\r\n const surface = new PlaneSurface(flipped ? new P3(V3.Z, edge.a.z) : new P3(V3.Z.negated(), -edge.a.z));\r\n if (open) {\r\n const faceEdges = [];\r\n if (!eq0(edge.a.x)) {\r\n faceEdges.push(...arrayFromFunction(count, (j) => horizontalEdges[j][i]));\r\n }\r\n faceEdges.push(ribs[count][i]);\r\n if (!eq0(edge.b.x)) {\r\n faceEdges.push(...arrayFromFunction(count, (j) => horizontalEdges[count - j - 1][ipp].flipped()));\r\n }\r\n faceEdges.push(edge.flipped());\r\n face = new PlaneFace(surface, faceEdges);\r\n }\r\n else {\r\n const contour = flipped\r\n ? arrayFromFunction(count, (j) => horizontalEdges[j][i])\r\n : arrayFromFunction(count, (j) => horizontalEdges[count - j - 1][ipp].flipped());\r\n let hole;\r\n if (flipped && !eq0(edge.b.x)) {\r\n hole = arrayFromFunction(count, (j) => horizontalEdges[count - j - 1][ipp].flipped());\r\n }\r\n else if (!flipped && !eq0(edge.a.x)) {\r\n hole = arrayFromFunction(count, (j) => horizontalEdges[j][i]);\r\n }\r\n face = new PlaneFace(surface, contour, hole ? [hole] : []);\r\n }\r\n faces.push(face);\r\n return;\r\n }\r\n else if (edge instanceof StraightEdge) {\r\n if (eq0(edge.a.lengthXY()) && eq0(edge.b.lengthXY())) {\r\n return;\r\n }\r\n }\r\n for (let r = 0; r < count; r++) {\r\n const rpp = (r + 1) % (count + 1);\r\n const faceEdges = [\r\n ribs[r][i].flipped(),\r\n horizontalEdges[r][i],\r\n ribs[rpp][i],\r\n horizontalEdges[r][ipp] && horizontalEdges[r][ipp].flipped(),\r\n ].filter((x) => x);\r\n let surface;\r\n if (edge instanceof StraightEdge) {\r\n surface = new PlaneSurface(P3.throughPoints(faceEdges[0].a, faceEdges[1].a, faceEdges[2].a));\r\n }\r\n else {\r\n const maxX = edges[i].getAABB().max.x;\r\n const phi = angles[r], prevPhi = 0 == r ? 0 : angles[r - 1];\r\n const offset = V3.polar(maxX, prevPhi).to(V3.polar(maxX, phi));\r\n surface = projectCurve(ribs[r][i].curve, offset, false);\r\n }\r\n faces.push(Face.create(surface, faceEdges));\r\n }\r\n });\r\n if (open) {\r\n const endFaceEdges = ribs[count].map((edge) => edge.flipped()).reverse();\r\n const endFace = new PlaneFace(new PlaneSurface(P3.ZX.rotateZ(getLast(angles))), endFaceEdges);\r\n faces.push(new PlaneFace(new PlaneSurface(P3.ZX.flipped()), edges), endFace);\r\n }\r\n return new BRep(faces, new PlaneSurface(P3.ZX).edgeLoopCCW(edges));\r\n }\r\n B2T.rotStep = rotStep;\r\n function fixEdges(edges) {\r\n return edges.flatMap((edge) => {\r\n const c = edge.curve;\r\n if (c instanceof EllipseCurve && c.tMin === -PI && c.tMax === PI) {\r\n const splitEdges = edge.minT < 0 && edge.maxT > 0 ? edge.split(0) : [edge];\r\n return splitEdges.map((edge) => {\r\n if (edge.minT >= 0) {\r\n return createEdge(new EllipseCurve(c.center, c.f1, c.f2, max(0, c.tMin), c.tMax), edge.a, edge.b, edge.aT, edge.bT, undefined, edge.aDir, edge.bDir, edge.name);\r\n }\r\n else {\r\n // \"rotate\" the curve\r\n return createEdge(new EllipseCurve(c.center, c.f1.negated(), c.f2.negated(), c.tMin + PI, min(PI, c.tMax + PI)), edge.a, edge.b, edge.aT + PI, edge.bT + PI, undefined, edge.aDir, edge.bDir, edge.name);\r\n }\r\n });\r\n }\r\n if (c instanceof BezierCurve) {\r\n if (edge.a.like(edge.b)) {\r\n return edge.split(lerp(edge.aT, edge.bT, 0.5));\r\n }\r\n }\r\n return edge;\r\n });\r\n }\r\n B2T.fixEdges = fixEdges;\r\n /**\r\n * Create a [BRep] by projecting edges created by joining vertices with straight edges.\r\n * @param baseVertices\r\n * @param baseFacePlane\r\n * @param offset\r\n * @param name\r\n * @param generator\r\n */\r\n function extrudeVertices(baseVertices, baseFacePlane, offset, name, generator) {\r\n assert(baseVertices.every((v) => v instanceof V3), \"baseVertices.every(v => v instanceof V3)\");\r\n assertInst(P3, baseFacePlane);\r\n assertVectors(offset);\r\n if (baseFacePlane.normal1.dot(offset) > 0)\r\n baseFacePlane = baseFacePlane.flipped();\r\n const edges = StraightEdge.chain(baseVertices, true);\r\n generator =\r\n generator ||\r\n callsce(\"B2T.extrudeVertices\", baseVertices, baseFacePlane, offset, name);\r\n return B2T.extrudeEdges(edges, baseFacePlane, offset, name, generator);\r\n }\r\n B2T.extrudeVertices = extrudeVertices;\r\n /**\r\n * Create a tetrahedron (3 sided pyramid) [BRep].\r\n * `a`, `b`, `c` and `d` can be in any order. The only constraint is that they cannot be on a common plane.\r\n * The resulting tetrahedron will always have outwards facing faces.\r\n * @param a\r\n * @param b\r\n * @param c\r\n * @param d\r\n * @param name\r\n */\r\n function tetrahedron(a, b, c, d, name = \"tetra\" + getGlobalId()) {\r\n assertVectors(a, b, c, d);\r\n const dDistance = P3.throughPoints(a, b, c).distanceToPointSigned(d);\r\n if (eq0(dDistance)) {\r\n throw new Error(\"four points are coplanar\");\r\n }\r\n if (dDistance > 0) {\r\n ;\r\n [c, d] = [d, c];\r\n }\r\n const ab = StraightEdge.throughPoints(a, b);\r\n const ac = StraightEdge.throughPoints(a, c);\r\n const ad = StraightEdge.throughPoints(a, d);\r\n const bc = StraightEdge.throughPoints(b, c);\r\n const bd = StraightEdge.throughPoints(b, d);\r\n const cd = StraightEdge.throughPoints(c, d);\r\n const faces = [\r\n new PlaneFace(PlaneSurface.throughPoints(a, b, c), [ab, bc, ac.flipped()], [], name + \"abc\"),\r\n new PlaneFace(PlaneSurface.throughPoints(a, d, b), [ad, bd.flipped(), ab.flipped()], [], name + \"adb\"),\r\n new PlaneFace(PlaneSurface.throughPoints(b, d, c), [bd, cd.flipped(), bc.flipped()], [], name + \"bdc\"),\r\n new PlaneFace(PlaneSurface.throughPoints(c, d, a), [cd, ad.flipped(), ac], [], name + \"cda\"),\r\n ];\r\n const gen = callsce(\"B2T.tetrahedron\", a, b, c, d);\r\n return new BRep(faces, false, gen);\r\n }\r\n B2T.tetrahedron = tetrahedron;\r\n const b = 1 / GOLDEN_RATIO, c = 2 - GOLDEN_RATIO;\r\n B2T.TETRAHEDRON_VERTICES = [\r\n new V3(1, 0, -SQRT1_2),\r\n new V3(-1, 0, -SQRT1_2),\r\n new V3(0, -1, SQRT1_2),\r\n new V3(0, 1, SQRT1_2),\r\n ].map((v) => v.unit());\r\n B2T.DODECAHEDRON_VERTICES = [\r\n new V3(c, 0, 1),\r\n new V3(-c, 0, 1),\r\n new V3(-b, b, b),\r\n new V3(0, 1, c),\r\n new V3(b, b, b),\r\n new V3(b, -b, b),\r\n new V3(0, -1, c),\r\n new V3(-b, -b, b),\r\n new V3(c, 0, -1),\r\n new V3(-c, 0, -1),\r\n new V3(-b, -b, -b),\r\n new V3(0, -1, -c),\r\n new V3(b, -b, -b),\r\n new V3(b, b, -b),\r\n new V3(0, 1, -c),\r\n new V3(-b, b, -b),\r\n new V3(1, c, 0),\r\n new V3(-1, c, 0),\r\n new V3(-1, -c, 0),\r\n new V3(1, -c, 0),\r\n ].map((v) => v.unit());\r\n B2T.DODECAHEDRON_FACE_VERTICES = [\r\n [4, 3, 2, 1, 0],\r\n [7, 6, 5, 0, 1],\r\n [12, 11, 10, 9, 8],\r\n [15, 14, 13, 8, 9],\r\n [14, 3, 4, 16, 13],\r\n [3, 14, 15, 17, 2],\r\n [11, 6, 7, 18, 10],\r\n [6, 11, 12, 19, 5],\r\n [4, 0, 5, 19, 16],\r\n [12, 8, 13, 16, 19],\r\n [15, 9, 10, 18, 17],\r\n [7, 1, 2, 17, 18],\r\n ];\r\n B2T.OCTAHEDRON_VERTICES = [\r\n new V3(1, 0, 0),\r\n new V3(-1, 0, 0),\r\n new V3(0, 1, 0),\r\n new V3(0, -1, 0),\r\n new V3(0, 0, 1),\r\n new V3(0, 0, -1),\r\n ];\r\n B2T.OCTAHEDRON_FACE_VERTICES = [\r\n [0, 2, 4],\r\n [2, 1, 4],\r\n [1, 3, 4],\r\n [3, 0, 4],\r\n [2, 0, 5],\r\n [1, 2, 5],\r\n [3, 1, 5],\r\n [0, 3, 5],\r\n ];\r\n const { x: s, y: t } = new V3(1, GOLDEN_RATIO, 0).unit();\r\n B2T.ICOSAHEDRON_VERTICES = [\r\n new V3(-s, t, 0),\r\n new V3(s, t, 0),\r\n new V3(-s, -t, 0),\r\n new V3(s, -t, 0),\r\n new V3(0, -s, t),\r\n new V3(0, s, t),\r\n new V3(0, -s, -t),\r\n new V3(0, s, -t),\r\n new V3(t, 0, -s),\r\n new V3(t, 0, s),\r\n new V3(-t, 0, -s),\r\n new V3(-t, 0, s),\r\n ];\r\n B2T.ICOSAHEDRON_FACE_VERTICES = [\r\n // 5 faces around point 0\r\n [0, 11, 5],\r\n [0, 5, 1],\r\n [0, 1, 7],\r\n [0, 7, 10],\r\n [0, 10, 11],\r\n // 5 adjacent faces\r\n [1, 5, 9],\r\n [5, 11, 4],\r\n [11, 10, 2],\r\n [10, 7, 6],\r\n [7, 1, 8],\r\n // 5 faces around point 3\r\n [3, 9, 4],\r\n [3, 4, 2],\r\n [3, 2, 6],\r\n [3, 6, 8],\r\n [3, 8, 9],\r\n // 5 adjacent faces\r\n [4, 9, 5],\r\n [2, 4, 11],\r\n [6, 2, 10],\r\n [8, 6, 7],\r\n [9, 8, 1],\r\n ];\r\n /**\r\n * Create a dodecahedron [BRep]. The vertices are on the unit sphere.\r\n */\r\n function dodecahedron() {\r\n return makePlatonic(B2T.DODECAHEDRON_VERTICES, B2T.DODECAHEDRON_FACE_VERTICES, \"B2T.dodecahedron()\");\r\n }\r\n B2T.dodecahedron = dodecahedron;\r\n /**\r\n * Create an octahedron [BRep]. The vertices are on the unit sphere.\r\n */\r\n function octahedron() {\r\n return makePlatonic(B2T.OCTAHEDRON_VERTICES, B2T.OCTAHEDRON_FACE_VERTICES, \"B2T.octahedron()\");\r\n }\r\n B2T.octahedron = octahedron;\r\n /**\r\n * Create an icosahedron [BRep]. The vertices are on the unit sphere.\r\n */\r\n function icosahedron() {\r\n return makePlatonic(B2T.ICOSAHEDRON_VERTICES, B2T.ICOSAHEDRON_FACE_VERTICES, \"B2T.icosahedron()\");\r\n }\r\n B2T.icosahedron = icosahedron;\r\n function makePlatonic(VS, FVIS, generator) {\r\n const edgeMap = new Map();\r\n const faces = FVIS.map((faceIndexes) => {\r\n const surface = PlaneSurface.throughPoints(VS[faceIndexes[0]], VS[faceIndexes[1]], VS[faceIndexes[2]]);\r\n const contour = arrayFromFunction(faceIndexes.length, (i) => {\r\n const ipp = (i + 1) % faceIndexes.length;\r\n const iA = faceIndexes[i], iB = faceIndexes[ipp];\r\n const iMin = min(iA, iB), iMax = max(iA, iB), edgeID = iMin * VS.length + iMax;\r\n let edge = edgeMap.get(edgeID);\r\n !edge &&\r\n edgeMap.set(edgeID, (edge = StraightEdge.throughPoints(VS[iMin], VS[iMax])));\r\n return iA < iB ? edge : edge.flipped();\r\n });\r\n return new PlaneFace(surface, contour);\r\n });\r\n return new BRep(faces, false, generator);\r\n }\r\n /**\r\n * Create a [BRep] by projecting a number of edges onto a point.\r\n * @param baseEdges The edges forming the base of the pyramid.\r\n * @param apex The tip of the pyramid.\r\n * @param name\r\n */\r\n function pyramidEdges(baseEdges, apex, name = \"pyramid\" + getGlobalId()) {\r\n assertInst(Edge, ...baseEdges);\r\n assertVectors(apex);\r\n const ribs = baseEdges.map((baseEdge) => StraightEdge.throughPoints(apex, baseEdge.a));\r\n const faces = baseEdges.map((baseEdge, i) => {\r\n const faceName = name + \"Wall\" + i;\r\n const ipp = (i + 1) % baseEdges.length;\r\n const faceEdges = [ribs[i], baseEdge, ribs[ipp].flipped()];\r\n const surface = projectPointCurve(baseEdge.curve, baseEdge.minT, baseEdge.maxT, apex, baseEdge.deltaT() < 0);\r\n return Face.create(surface, faceEdges, undefined, faceName);\r\n });\r\n const baseSurface = new PlaneSurface(P3.XY).flipped();\r\n const bottomFace = Face.create(baseSurface, Edge.reversePath(baseEdges));\r\n faces.push(bottomFace);\r\n const generator = callsce(\"B2T.pyramidEdges\", baseEdges, apex, name);\r\n return new BRep(faces, false, generator);\r\n }\r\n B2T.pyramidEdges = pyramidEdges;\r\n function fromBPT(bpt) {\r\n const lineRegex = /.+/g;\r\n const readLine = () => lineRegex.exec(bpt)[0];\r\n const readLineNumbers = () => readLine()\r\n .trim()\r\n .split(/\\s+/)\r\n .map((s) => parseFloat(s));\r\n const numOfPatches = parseInt(readLine());\r\n const faces = arrayFromFunction(numOfPatches, () => {\r\n const [pointsUCount, pointsVCount] = readLineNumbers();\r\n const points = Array.from({ length: (pointsUCount + 1) * (pointsVCount + 1) }, () => VV(...readLineNumbers(), 1));\r\n const surface = new NURBSSurface(points, NURBS.bezierKnots(pointsUCount), NURBS.bezierKnots(pointsVCount), pointsUCount, pointsVCount, 0, 1, 0, 1);\r\n const edges = [\r\n edgeForCurveAndTs(surface.isoparametricV(0)),\r\n edgeForCurveAndTs(surface.isoparametricU(1)),\r\n edgeForCurveAndTs(surface.isoparametricV(1)).flipped(),\r\n edgeForCurveAndTs(surface.isoparametricU(0)).flipped(),\r\n ];\r\n return Face.create(surface, edges);\r\n });\r\n return new BRep(faces, false);\r\n }\r\n B2T.fromBPT = fromBPT;\r\n})(B2T || (B2T = {}));\r\n//# sourceMappingURL=BRepGenerators.js.map","import { callsce, min } from \"ts3dutils\";\r\nimport * as chroma from \"chroma.ts\";\r\nimport { GL_COLOR_BLACK } from \"tsgl\";\r\nimport { getGlobalId, L3, P3, PlaneSurface } from \".\";\r\nexport class CustomPlane extends P3 {\r\n constructor(anchor, right, up, name = \"CustomPlane\" + getGlobalId(), color = chroma.random().gl(), uMin = -500, uMax = 500, vMin = -500, vMax = 500) {\r\n const { normal1, w } = P3.forAnchorAndPlaneVectors(anchor, right, up);\r\n super(normal1, w);\r\n this.up = up;\r\n this.right = right;\r\n this.uMin = uMin;\r\n this.uMax = uMax;\r\n this.vMin = vMin;\r\n this.vMax = vMax;\r\n this.name = name;\r\n this.color = color;\r\n }\r\n get plane() {\r\n return this;\r\n }\r\n toPlaneSurface() {\r\n return new PlaneSurface(this, this.right, this.up);\r\n }\r\n toSource() {\r\n return callsce(\"new CustomPlane\", this.anchor, this.right, this.up, this.name, this.color, this.uMin, this.uMax, this.vMin, this.vMax);\r\n }\r\n static forPlane(plane, color = GL_COLOR_BLACK, name) {\r\n //assert(!name)\r\n const up = plane.normal1.getPerpendicular().unit(), right = up.cross(plane.normal1);\r\n return new CustomPlane(plane.anchor, right, up, name, color);\r\n }\r\n static fromPlaneSurface(surface) {\r\n return new CustomPlane(surface.plane.anchor, surface.right, surface.up, \"genCustomPlane\" + getGlobalId());\r\n }\r\n distanceTo(line, mindist) {\r\n return min([\r\n new L3(this.anchor.plus(this.right.times(this.uMin)), this.up),\r\n new L3(this.anchor.plus(this.right.times(this.uMax)), this.up),\r\n new L3(this.anchor.plus(this.up.times(this.vMin)), this.right),\r\n new L3(this.anchor.plus(this.up.times(this.vMax)), this.right),\r\n ].map((line2, line2Index) => {\r\n const info = line2.infoClosestToLine(line);\r\n if ((isNaN(info.t) || // parallel LINES\r\n (line2Index < 2 && this.vMin <= info.t && info.t <= this.vMax) ||\r\n (line2Index >= 2 && this.uMin <= info.t && info.t <= this.uMax)) &&\r\n info.distance <= mindist) {\r\n return info.s;\r\n }\r\n else {\r\n return Infinity;\r\n }\r\n }));\r\n }\r\n distanceTo2(line, mindist) {\r\n return min([\r\n new L3(this.anchor.plus(this.right.times(this.uMin)), this.up),\r\n new L3(this.anchor.plus(this.right.times(this.uMax)), this.up),\r\n new L3(this.anchor.plus(this.up.times(this.vMin)), this.right),\r\n new L3(this.anchor.plus(this.up.times(this.vMax)), this.right),\r\n ].map((line2, line2Index) => {\r\n const info = line2.infoClosestToLine(line);\r\n if ((isNaN(info.t) || // parallel LINES\r\n (line2Index < 2 && this.vMin <= info.t && info.t <= this.vMax) ||\r\n (line2Index >= 2 && this.uMin <= info.t && info.t <= this.uMax)) &&\r\n info.distance <= mindist) {\r\n return info.distance;\r\n }\r\n else {\r\n return Infinity;\r\n }\r\n }));\r\n }\r\n}\r\n//# sourceMappingURL=CustomPlane.js.map","import { AABB, arrayFromFunction, arrayRange, assert, assertf, assertInst, assertNumbers, assertVectors, callsce, clamp, eq, fuzzyBetween, le, lt, Transformable, V, } from \"ts3dutils\";\r\nimport { Curve, L3 } from \".\";\r\nimport { sign } from \"./math\";\r\nexport class Edge extends Transformable {\r\n constructor(curve, a, b, aT, bT, flippedOf, name) {\r\n super();\r\n this.curve = curve;\r\n this.a = a;\r\n this.b = b;\r\n this.aT = aT;\r\n this.bT = bT;\r\n this.flippedOf = flippedOf;\r\n this.name = name;\r\n assertNumbers(aT, bT);\r\n assert(!eq(aT, bT));\r\n assertVectors(a, b);\r\n assertf(() => curve instanceof Curve, curve);\r\n assertf(() => !curve.isValidT || (curve.isValidT(aT) && curve.isValidT(bT)), aT, bT, curve);\r\n //if (curve instanceof PICurve) {\r\n // assertf(() => curve.at(aT).to(a).length() < 0.1, ''+curve.at(aT)+a)\r\n // assertf(() => curve.at(bT).to(b).length() < 0.1, '' + curve.at(bT) + b)\r\n //} else {\r\n assertf(() => curve.at(aT).like(a), () => \"\" + curve.at(aT) + a + \" aT should have been \" + curve.pointT(a));\r\n assertf(() => curve.at(bT).like(b), () => \"\" + curve.at(bT) + b + \" bT should have been \" + curve.pointT(b));\r\n //}\r\n assertf(() => fuzzyBetween(aT, curve.tMin, curve.tMax), aT, curve.tMin, curve.tMax);\r\n assertf(() => fuzzyBetween(bT, curve.tMin, curve.tMax), bT, curve.tMin, curve.tMax);\r\n assert(!a.like(b), \"!a.like(b)\" + a + b);\r\n this.aT = clamp(aT, curve.tMin, curve.tMax);\r\n this.bT = clamp(bT, curve.tMin, curve.tMax);\r\n this.reversed = this.aT > this.bT;\r\n }\r\n get minT() {\r\n return Math.min(this.aT, this.bT);\r\n }\r\n get maxT() {\r\n return Math.max(this.aT, this.bT);\r\n }\r\n static isLoop(loop) {\r\n return loop.every((edge, i) => edge.b.like(loop[(i + 1) % loop.length].a));\r\n }\r\n static edgesIntersect(e1, e2) {\r\n // TODO: still getting some NaNs here..\r\n assertNumbers(e1.curve.hlol, e2.curve.hlol);\r\n assertInst(Edge, e1, e2);\r\n if (e1.curve.hlol < e2.curve.hlol) {\r\n ;\r\n [e2, e1] = [e1, e2];\r\n }\r\n const sts = e1.curve.isInfosWithCurve(e2.curve);\r\n if (sts.some((info) => isNaN(info.tThis) || isNaN(info.tOther))) {\r\n console.log(e1.sce);\r\n console.log(e2.sce);\r\n assert(false);\r\n }\r\n return sts.some(\r\n /// ( e1.aT < tThis < e1.bT ) && ( e2.aT < tOther < e2.bT )\r\n ({ tThis, tOther }) => {\r\n return e1.tValueInside(tThis) && e2.tValueInside(tOther);\r\n });\r\n }\r\n static assertLoop(edges) {\r\n edges.forEach((edge, i) => {\r\n const j = (i + 1) % edges.length;\r\n assert(edge.b.like(edges[j].a), `edges[${i}].b != edges[${j}].a (${edges[i].b.sce} != ${edges[j].a.sce})`);\r\n });\r\n }\r\n static reversePath(path, doReverse = true) {\r\n return doReverse\r\n ? arrayFromFunction(path.length, (i) => path[path.length - 1 - i].flipped())\r\n : path;\r\n }\r\n toString() {\r\n return callsce(\"new \" + this.constructor.name, this.curve, this.a, this.b, this.aT, this.bT, undefined, this.aDir, this.bDir);\r\n }\r\n colinearToLine(line) {\r\n return this.curve instanceof L3 && this.curve.isColinearTo(line);\r\n }\r\n tValueInside(t) {\r\n return this.aT < this.bT\r\n ? lt(this.aT, t) && lt(t, this.bT)\r\n : lt(this.bT, t) && lt(t, this.aT);\r\n }\r\n isValidT(t) {\r\n return this.aT < this.bT\r\n ? le(this.aT, t) && le(t, this.bT)\r\n : le(this.bT, t) && le(t, this.aT);\r\n }\r\n clampedT(t) {\r\n return this.aT < this.bT\r\n ? clamp(t, this.aT, this.bT)\r\n : clamp(t, this.bT, this.aT);\r\n }\r\n /**\r\n * this is equals-equals. \"isColinearTo\" might make more sense but can't be used, because you can't get a\r\n * consistent hashCode for colinear curves\r\n * @param obj\r\n * @returns\r\n */\r\n equals(obj) {\r\n return (this === obj ||\r\n (this.constructor == obj.constructor &&\r\n this.a.equals(obj.a) &&\r\n this.b.equals(obj.b) &&\r\n this.curve.equals(obj.curve)));\r\n }\r\n hashCode() {\r\n let hashCode = 0;\r\n hashCode = hashCode * 31 + this.a.hashCode();\r\n hashCode = hashCode * 31 + this.b.hashCode();\r\n hashCode = hashCode * 31 + this.curve.hashCode();\r\n return hashCode | 0;\r\n }\r\n like(edge) {\r\n // TODO this breaks on colinear edges,\r\n // TODO: what, where?\r\n return (this === edge ||\r\n (this.curve.isColinearTo(edge.curve) &&\r\n this.a.like(edge.a) &&\r\n this.b.like(edge.b) &&\r\n this.aDir.isParallelTo(edge.aDir) &&\r\n this.aDir.dot(edge.aDir) > 0));\r\n }\r\n isCanon() {\r\n return !this.reversed;\r\n }\r\n getCanon() {\r\n return this.reversed ? this.flipped() : this;\r\n }\r\n overlaps(edge, noback) {\r\n assert(this.curve.isColinearTo(edge.curve));\r\n const edgeAT = this.curve.containsPoint(edge.a) && this.curve.pointT(edge.a);\r\n const edgeBT = this.curve.containsPoint(edge.b) && this.curve.pointT(edge.b);\r\n if (false === edgeAT && false === edgeBT) {\r\n return noback ? false : edge.overlaps(this, true);\r\n }\r\n return !(le(edge.maxT, this.minT) || le(this.maxT, edge.minT));\r\n }\r\n getAABB() {\r\n const min = [Infinity, Infinity, Infinity], max = [-Infinity, -Infinity, -Infinity];\r\n this.curve.roots().forEach((ts, dim) => {\r\n ts.forEach((t) => {\r\n if (lt(this.minT, t) && lt(t, this.maxT)) {\r\n min[dim] = Math.min(min[dim], this.curve.at(t).e(dim));\r\n max[dim] = Math.max(max[dim], this.curve.at(t).e(dim));\r\n }\r\n });\r\n });\r\n const aabb = new AABB(V(min), V(max));\r\n aabb.addPoint(this.a);\r\n aabb.addPoint(this.b);\r\n return aabb;\r\n }\r\n length(steps = 1) {\r\n return this.curve.arcLength(this.minT, this.maxT, steps);\r\n }\r\n deltaT() {\r\n return this.bT - this.aT;\r\n }\r\n deltaTSign() {\r\n return sign(this.bT - this.aT);\r\n }\r\n atAvgT() {\r\n return this.curve.at((this.minT + this.maxT) / 2);\r\n }\r\n /**\r\n * Whether two edge loops are equal. Takes into account that two loops need not start with the same edge.\r\n * @param loop1\r\n * @param loop2\r\n */\r\n static loopsEqual(loop1, loop2) {\r\n return (loop1.length == loop2.length &&\r\n arrayRange(0, loop1.length, 1).some((offset) => loop1.every((edge, i) => edge.equals(loop2[(offset + i) % loop1.length]))));\r\n }\r\n}\r\n//# sourceMappingURL=Edge.js.map","import { arrayFromFunction, assertf, assertInst, assertVectors, callsce, eq0, snap2, } from \"ts3dutils\";\r\nimport { Edge, L3, PlaneSurface } from \".\";\r\nexport class StraightEdge extends Edge {\r\n constructor(line, a, b, aT, bT, flippedOf, name) {\r\n super(line, a, b, aT, bT, flippedOf, name);\r\n this.flippedOf = flippedOf;\r\n assertInst(L3, line);\r\n !flippedOf || assertInst(StraightEdge, flippedOf);\r\n !name || assertf(() => \"string\" === typeof name, name);\r\n this.tangent =\r\n this.aT < this.bT ? this.curve.dir1 : this.curve.dir1.negated();\r\n }\r\n get aDir() {\r\n return this.tangent;\r\n }\r\n get bDir() {\r\n return this.tangent;\r\n }\r\n static throughPoints(a, b, name) {\r\n return new StraightEdge(L3.throughPoints(a, b, 0, a.to(b).length()), a, b, 0, a.to(b).length(), undefined, name);\r\n }\r\n /**\r\n * Create a list of StraightEdges from a list of vertices.\r\n * @param vertices\r\n * @param closed Whether to connect the first and last vertices. Defaults to true.\r\n * @returns\r\n */\r\n static chain(vertices, closed = true) {\r\n const vc = vertices.length;\r\n return arrayFromFunction(closed ? vc : vc - 1, (i) => StraightEdge.throughPoints(vertices[i], vertices[(i + 1) % vc]));\r\n }\r\n toSource() {\r\n return callsce(\"new StraightEdge\", this.curve, this.a, this.b, this.aT, this.bT);\r\n }\r\n getVerticesNo0() {\r\n return [this.b];\r\n }\r\n pointsCount() {\r\n return 2;\r\n }\r\n points() {\r\n return [this.a, this.b];\r\n }\r\n edgeISTsWithPlane(plane) {\r\n const edgeT = snap2(this.curve.isTWithPlane(plane), this.aT, this.bT);\r\n return this.minT <= edgeT && edgeT <= this.maxT ? [edgeT] : [];\r\n }\r\n edgeISTsWithSurface(surface) {\r\n if (surface instanceof PlaneSurface) {\r\n return this.edgeISTsWithPlane(surface.plane);\r\n }\r\n else {\r\n return surface\r\n .isTsForLine(this.curve)\r\n .map((edgeT) => snap2(edgeT, this.aT, this.bT))\r\n .filter((edgeT) => this.minT <= edgeT && edgeT <= this.maxT);\r\n }\r\n }\r\n tangentAt() {\r\n return this.tangent;\r\n }\r\n flipped() {\r\n return (this.flippedOf ||\r\n (this.flippedOf = new StraightEdge(this.curve, this.b, this.a, this.bT, this.aT, this, this.name)));\r\n }\r\n transform(m4, desc) {\r\n const lineDir1TransLength = m4\r\n .transformVector2(this.curve.dir1, this.curve.anchor)\r\n .length();\r\n const curve = this.curve.transform(m4);\r\n const a = m4.transformPoint(this.a);\r\n const b = m4.transformPoint(this.b);\r\n return new StraightEdge(curve, a, b, m4.isNoProj() ? this.aT * lineDir1TransLength : curve.pointT(a), m4.isNoProj() ? this.bT * lineDir1TransLength : curve.pointT(b), undefined, \"\" + this.name + desc);\r\n }\r\n transform4(m4, desc) {\r\n const lineDir1TransLength = m4\r\n .transformVector2(this.curve.dir1, this.curve.anchor)\r\n .length();\r\n const curve = this.curve.transform4(m4);\r\n const a = m4.transformPoint(this.a);\r\n const b = m4.transformPoint(this.b);\r\n return new StraightEdge(curve, a, b, m4.isNoProj() ? this.aT * lineDir1TransLength : curve.pointT(a), m4.isNoProj() ? this.bT * lineDir1TransLength : curve.pointT(b), undefined, \"\" + this.name + desc);\r\n }\r\n isCoEdge(edge) {\r\n return (this === edge ||\r\n this === edge.flippedOf ||\r\n (edge.constructor instanceof StraightEdge &&\r\n ((this.a.like(edge.a) && this.b.like(edge.b)) ||\r\n (this.a.like(edge.b) && this.b.like(edge.a)))));\r\n }\r\n getEdgeT(p) {\r\n assertVectors(p);\r\n let edgeT = p.minus(this.curve.anchor).dot(this.curve.dir1);\r\n if (!eq0(this.curve.at(edgeT).distanceTo(p))) {\r\n return;\r\n }\r\n edgeT = snap2(edgeT, this.aT, this.bT);\r\n return this.minT <= edgeT && edgeT <= this.maxT ? edgeT : undefined;\r\n }\r\n split(t) {\r\n const p = this.curve.at(t);\r\n return [\r\n new StraightEdge(this.curve, this.a, p, this.aT, t, undefined, this.name + \"left\"),\r\n new StraightEdge(this.curve, p, this.b, t, this.bT, undefined, this.name + \"right\"),\r\n ];\r\n }\r\n}\r\n//# sourceMappingURL=StraightEdge.js.map","import { assert, assertf, assertVectors, callsce, snap2, snap, } from \"ts3dutils\";\r\nimport { Edge, PICurve } from \".\";\r\nexport class PCurveEdge extends Edge {\r\n constructor(curve, a, b, aT, bT, flippedOf, aDir, bDir, name) {\r\n super(curve, a, b, aT, bT, flippedOf, name);\r\n this.flippedOf = flippedOf;\r\n this.aDir = aDir;\r\n this.bDir = bDir;\r\n assertVectors(aDir, bDir);\r\n assertf(() => !aDir.likeO(), curve);\r\n assertf(() => !bDir.likeO(), curve);\r\n if (!(curve instanceof PICurve)) {\r\n // TODO\r\n assertf(() => curve.tangentAt(aT).likeOrReversed(aDir), \"\" + aT + curve.tangentAt(aT).sce + \" \" + aDir.sce);\r\n assertf(() => curve.tangentAt(bT).likeOrReversed(bDir), \"\" + bT + curve.tangentAt(bT).sce + \" \" + bDir.sce);\r\n }\r\n assert(this.reversed === this.aDir.dot(curve.tangentAt(aT)) < 0, aT +\r\n \" \" +\r\n bT +\r\n \" \" +\r\n curve.constructor.name +\r\n \" \" +\r\n this.aDir.sce +\r\n \" \" +\r\n this.bDir.sce +\r\n \" \" +\r\n curve.tangentAt(aT));\r\n assert(this.reversed === this.bDir.dot(curve.tangentAt(bT)) < 0, aT +\r\n \" \" +\r\n bT +\r\n \" \" +\r\n curve.constructor.name +\r\n \" \" +\r\n this.aDir.sce +\r\n \" \" +\r\n this.bDir.sce +\r\n \" \" +\r\n curve.tangentAt(aT));\r\n }\r\n static forCurveAndTs(curve, aT, bT, name) {\r\n return new PCurveEdge(curve, curve.at(aT), curve.at(bT), aT, bT, undefined, aT < bT ? curve.tangentAt(aT) : curve.tangentAt(aT).negated(), aT < bT ? curve.tangentAt(bT) : curve.tangentAt(bT).negated(), name);\r\n }\r\n toSource() {\r\n return callsce(\"new PCurveEdge\", this.curve, this.a, this.b, this.aT, this.bT, undefined, this.aDir, this.bDir, this.name);\r\n }\r\n getVerticesNo0() {\r\n return this.curve.calcSegmentPoints(this.aT, this.bT, this.a, this.b, this.reversed, false);\r\n }\r\n pointsCount() {\r\n return this.points().length;\r\n }\r\n points() {\r\n return this.curve.calcSegmentPoints(this.aT, this.bT, this.a, this.b, this.reversed, true);\r\n }\r\n edgeISTsWithSurface(surface) {\r\n return this.curve\r\n .isTsWithSurface(surface)\r\n .map((edgeT) => snap2(edgeT, this.aT, this.bT))\r\n .filter((edgeT) => this.minT <= edgeT && edgeT <= this.maxT);\r\n }\r\n edgeISTsWithPlane(surface) {\r\n return this.curve\r\n .isTsWithPlane(surface)\r\n .map((edgeT) => snap2(edgeT, this.aT, this.bT))\r\n .filter((edgeT) => this.minT <= edgeT && edgeT <= this.maxT);\r\n }\r\n tangentAt(t) {\r\n return !this.reversed\r\n ? this.curve.tangentAt(t)\r\n : this.curve.tangentAt(t).negated();\r\n }\r\n flipped() {\r\n return (this.flippedOf ||\r\n (this.flippedOf = new PCurveEdge(this.curve, this.b, this.a, this.bT, this.aT, this, this.bDir.negated(), this.aDir.negated(), this.name)));\r\n }\r\n transform(m4, desc) {\r\n return new PCurveEdge(this.curve.transform(m4), m4.transformPoint(this.a), m4.transformPoint(this.b), this.aT, this.bT, undefined, m4.transformVector(this.aDir), m4.transformVector(this.bDir), \"\" + this.name + desc);\r\n }\r\n transform4(m4, desc) {\r\n const a_ = m4.transformPoint(this.a);\r\n const b_ = m4.transformPoint(this.b);\r\n const curve_ = this.curve.transform4(m4);\r\n return new PCurveEdge(curve_, a_, b_, snap(curve_.pointT(a_), this.aT), snap(curve_.pointT(b_), this.bT), undefined, m4.transformVector(this.aDir), m4.transformVector(this.bDir), \"\" + this.name + desc);\r\n }\r\n isCoEdge(edge) {\r\n return (this === edge ||\r\n this === edge.flippedOf ||\r\n (this.curve.isColinearTo(edge.curve) &&\r\n ((this.a.like(edge.a) && this.b.like(edge.b)) ||\r\n (this.a.like(edge.b) && this.b.like(edge.a)))));\r\n }\r\n split(t) {\r\n const p = this.curve.at(t);\r\n const dir = this.tangentAt(t);\r\n return [\r\n new PCurveEdge(this.curve, this.a, p, this.aT, t, undefined, this.aDir, dir, this.name + \"left\"),\r\n new PCurveEdge(this.curve, p, this.b, t, this.bT, undefined, this.aDir, dir, this.name + \"right\"),\r\n ];\r\n }\r\n}\r\n//# sourceMappingURL=PCurveEdge.js.map","import { SVGPathData } from \"svg-pathdata\";\r\nimport { arrayFromFunction, arrayRange, assert, DEG, eq0, getIntervals, M4, MINUS, mod, newtonIterate, NLA_PRECISION, PI, TAU, V, V3, } from \"ts3dutils\";\r\nimport { BezierCurve, Edge, EllipseCurve, L3, ParabolaCurve, PCurveEdge, StraightEdge, } from \".\";\r\nimport { floor, ceil, abs, sign } from \"./math\";\r\nexport function edgePathFromSVG(pathString) {\r\n let currentPos = undefined;\r\n const parsed = new SVGPathData(pathString)\r\n .toAbs()\r\n .normalizeHVZ()\r\n .sanitize(NLA_PRECISION)\r\n .annotateArcs().commands;\r\n const path = [];\r\n for (const c of parsed) {\r\n assert(\"x\" in c && \"y\" in c);\r\n const endPos = new V3(c.x, c.y, 0);\r\n switch (c.type) {\r\n case SVGPathData.LINE_TO:\r\n path.push(StraightEdge.throughPoints(currentPos, endPos));\r\n break;\r\n case SVGPathData.CURVE_TO: {\r\n const c1 = new V3(c.x1, c.y1, 0);\r\n const c2 = new V3(c.x2, c.y2, 0);\r\n const curve = new BezierCurve(currentPos, c1, c2, endPos, 0, 1);\r\n const edge = new PCurveEdge(curve, currentPos, endPos, 0, 1, undefined, curve.tangentAt(0), curve.tangentAt(1));\r\n path.push(edge);\r\n break;\r\n }\r\n case SVGPathData.QUAD_TO: {\r\n const c1 = new V3(c.x1, c.y1, 0);\r\n const curve = ParabolaCurve.quadratic(currentPos, c1, endPos).rightAngled();\r\n const edge = new PCurveEdge(curve, currentPos, endPos, curve.tMin, curve.tMax, undefined, curve.tangentAt(curve.tMin), curve.tangentAt(curve.tMax));\r\n path.push(edge);\r\n break;\r\n }\r\n case SVGPathData.ARC: {\r\n const phi1 = c.phi1 * DEG, phi2 = c.phi2 * DEG, [phiMin, phiMax] = [phi1, phi2].sort(MINUS);\r\n const stops = arrayRange(-3, 4, 1)\r\n .map((n) => n * PI)\r\n .filter((stop) => phiMin <= stop && stop <= phiMax);\r\n const center = V(c.cX, c.cY);\r\n const f1 = V3.polar(c.rX, c.xRot * DEG);\r\n const f2 = V3.polar(c.rY, c.xRot * DEG + Math.PI / 2);\r\n const edges = getIntervals(stops, phiMin, phiMax).map(([t1, t2]) => {\r\n const deltaT = t2 - t1;\r\n const t1_ = mod(t1, TAU);\r\n const t2_ = t1_ + deltaT;\r\n assert(t1_ >= 0 == t2_ >= 0);\r\n const gtPI = t1_ > PI || t2_ > PI;\r\n const aT = gtPI ? t1_ - PI : t1_;\r\n const bT = gtPI ? t2_ - PI : t2_;\r\n const curve = new EllipseCurve(center, gtPI ? f1.negated() : f1, gtPI ? f2.negated() : f2);\r\n const a = phi1 == t1 ? currentPos : phi2 == t1 ? endPos : curve.at(aT);\r\n const b = phi1 == t2 ? currentPos : phi2 == t2 ? endPos : curve.at(bT);\r\n return new PCurveEdge(curve, a, b, aT, bT, undefined, curve.tangentAt(aT), curve.tangentAt(bT));\r\n });\r\n path.push(...(c.phiDelta > 0 ? edges : Edge.reversePath(edges)));\r\n break;\r\n }\r\n }\r\n currentPos = endPos;\r\n }\r\n return path;\r\n}\r\n/**\r\n * Create an axis-aligned rectangle of edges on the XY-plane with the bottom-left corner on the origin.\r\n * @param width\r\n * @param height\r\n */\r\nexport function edgeRect(width = 1, height = width) {\r\n const vertices = [\r\n new V3(0, 0, 0),\r\n new V3(width, 0, 0),\r\n new V3(width, height, 0),\r\n new V3(0, height, 0),\r\n ];\r\n return StraightEdge.chain(vertices);\r\n}\r\nexport function edgeNgon(n = 3, radius = 1) {\r\n return StraightEdge.chain(arrayFromFunction(n, (i) => V3.polar(radius, (TAU * i) / n)));\r\n}\r\nexport function edgeStar(pointCount = 5, r0 = 1, r1 = 0.5) {\r\n const vertices = arrayFromFunction(pointCount * 2, (i) => V3.polar(0 == i % 2 ? r0 : r1, (TAU * i) / pointCount / 2));\r\n return StraightEdge.chain(vertices);\r\n}\r\nexport function createEdge(curve, a, b, aT, bT, flippedOf, aDir, bDir, name) {\r\n if (curve instanceof L3) {\r\n return new StraightEdge(curve, a, b, aT, bT, flippedOf, name);\r\n }\r\n else {\r\n return new PCurveEdge(curve, a, b, aT, bT, flippedOf, aDir, bDir, name);\r\n }\r\n}\r\nexport function edgeForCurveAndTs(curve, aT = curve.tMin, bT = curve.tMax) {\r\n return createEdge(curve, curve.at(aT), curve.at(bT), aT, bT, undefined, aT < bT ? curve.tangentAt(aT) : curve.tangentAt(aT).negated(), aT < bT ? curve.tangentAt(bT) : curve.tangentAt(bT).negated());\r\n}\r\nexport function reuleaux(n = 3, radius = 1) {\r\n assert(3 <= n);\r\n assert(1 == n % 2);\r\n const corners = arrayFromFunction(n, (i) => V3.polar(radius, (TAU * i) / n));\r\n return arrayFromFunction(n, (i) => {\r\n const aI = (i + floor(n / 2)) % n, bI = (i + ceil(n / 2)) % n;\r\n const a = corners[aI], b = corners[bI];\r\n const center = corners[i];\r\n const f1 = center.to(a), curve = new EllipseCurve(center, f1, V3.Z.cross(f1));\r\n return createEdge(curve, a, b, 0, curve.pointT(b), undefined, V3.Z.cross(f1), V3.Z.cross(center.to(b)));\r\n });\r\n}\r\nexport function round(edges, radius) {\r\n if (eq0(radius)) {\r\n return edges;\r\n }\r\n const corners = edges.map((edge, i) => {\r\n const j = (i + 1) % edges.length, nextEdge = edges[j];\r\n if (!edge.b.like(nextEdge.a))\r\n return undefined;\r\n const angleToNext = edge.bDir.angleTo(nextEdge.aDir);\r\n const c1 = edge.curve, c2 = nextEdge.curve;\r\n if (c1 instanceof L3 && c2 instanceof L3) {\r\n const normal = c1.dir1.cross(c2.dir1);\r\n if (eq0(angleToNext))\r\n return undefined;\r\n const l1inside = normal.cross(c1.dir1), l2inside = normal.cross(c2.dir1);\r\n const l1offset = c1.transform(M4.translate(l1inside.toLength(radius)));\r\n const l2offset = c2.transform(M4.translate(l2inside.toLength(radius)));\r\n const center = l1offset.isInfoWithLine(l2offset);\r\n if (!center)\r\n throw new Error(\"tangential curves\");\r\n const cornerA = center.plus(l1inside.toLength(-radius));\r\n const cornerB = center.plus(l2inside.toLength(-radius));\r\n const f1 = l1inside.toLength(-radius);\r\n const curve = new EllipseCurve(center, f1, normal.cross(f1).toLength(radius));\r\n const cornerEdge = createEdge(curve, cornerA, cornerB, 0, curve.pointT(cornerB), undefined, c1.dir1, c2.dir1);\r\n return cornerEdge;\r\n }\r\n else {\r\n return arbitraryCorner(edge, nextEdge, radius);\r\n }\r\n });\r\n const result = edges.flatMap((edge, i) => {\r\n const h = (i + edges.length - 1) % edges.length;\r\n const prevCorner = corners[h], nextCorner = corners[i];\r\n if (!prevCorner && !nextCorner) {\r\n return edge;\r\n }\r\n const [aT, a, aDir] = !prevCorner\r\n ? [edge.aT, edge.a, edge.aDir]\r\n : [edge.curve.pointT(prevCorner.b), prevCorner.b, prevCorner.bDir];\r\n const [bT, b, bDir] = !nextCorner\r\n ? [edge.bT, edge.b, edge.bDir]\r\n : [edge.curve.pointT(nextCorner.a), nextCorner.a, nextCorner.aDir];\r\n const newEdge = createEdge(edge.curve, a, b, aT, bT, undefined, aDir, bDir);\r\n return !nextCorner ? newEdge : [newEdge, nextCorner];\r\n });\r\n return result;\r\n}\r\nexport function arbitraryCorner(e1, e2, radius) {\r\n const c1 = e1.curve, c2 = e2.curve;\r\n function f([t1, t2]) {\r\n const p1 = c1.at(t1), p2 = c2.at(t2);\r\n const dp1 = c1.tangentAt(t1), dp2 = c2.tangentAt(t2);\r\n const virtualPlaneNormal = dp1.cross(dp2);\r\n const normal1 = virtualPlaneNormal.cross(dp1).unit(), normal2 = virtualPlaneNormal.cross(dp2).unit();\r\n const dirCross = normal1.cross(normal2);\r\n if (virtualPlaneNormal.likeO()) {\r\n assert(false);\r\n } // lines parallel\r\n const p1p2 = p1.to(p2);\r\n // check if distance is zero (see also L3.distanceToLine)\r\n if (!eq0(p1p2.dot(virtualPlaneNormal))) {\r\n assert(false);\r\n }\r\n const dist1 = p1p2.cross(normal2).dot(dirCross) / dirCross.squared();\r\n const dist2 = p1p2.cross(normal1).dot(dirCross) / dirCross.squared();\r\n const g1 = p1.plus(normal1.times(dist1));\r\n const g2 = p2.plus(normal2.times(dist2));\r\n assert(g1.like(g2));\r\n return [abs(dist1) - radius, abs(dist2) - radius];\r\n }\r\n const startT1 = e1.bT - (radius * sign(e1.deltaT())) / e1.bDir.length();\r\n const startT2 = e2.aT + (radius * sign(e2.deltaT())) / e2.aDir.length();\r\n const [t1, t2] = newtonIterate(f, [startT1, startT2]);\r\n const cornerA = e1.curve.at(t1);\r\n const cornerB = e2.curve.at(t2);\r\n const dp1 = c1.tangentAt(t1), dp2 = c2.tangentAt(t2);\r\n const virtualPlaneNormal = dp1.cross(dp2);\r\n const normal1 = virtualPlaneNormal.cross(dp1).unit();\r\n const f1 = normal1.toLength(-radius);\r\n const center = cornerA.minus(f1);\r\n const curve = new EllipseCurve(center, f1, virtualPlaneNormal.cross(f1).toLength(radius));\r\n const cornerEdge = createEdge(curve, cornerA, cornerB, 0, curve.pointT(cornerB), undefined, c1.tangentAt(t1), c2.tangentAt(t2));\r\n return cornerEdge;\r\n}\r\n//# sourceMappingURL=edgeUtil.js.map","/**\r\n * Created by aval on 19.04.2017.\r\n */\r\nexport class FaceInfoFactory {\r\n static makeStatic(staticInfo) {\r\n return new (class extends FaceInfoFactory {\r\n constructor() {\r\n super();\r\n }\r\n info(surface, contour, holes) {\r\n return staticInfo;\r\n }\r\n })();\r\n }\r\n info(surface, contour, holes) {\r\n throw new Error(\"no default implementation\");\r\n }\r\n extrudeBottom(surface, contour, holes = []) {\r\n return this.info(surface, contour, holes);\r\n }\r\n extrudeTop(surface, contour, holes = []) {\r\n return this.info(surface, contour, holes);\r\n }\r\n extrudeWall(index, surface, contour, holes = []) {\r\n return this.info(surface, contour, holes);\r\n }\r\n rotationWall(index, surface, contour, holes = []) {\r\n return this.info(surface, contour, holes);\r\n }\r\n rotationStart(surface, contour, holes = []) {\r\n return this.info(surface, contour, holes);\r\n }\r\n rotationEnd(surface, contour, holes = []) {\r\n return this.info(surface, contour, holes);\r\n }\r\n newSubFace(original, surface, contour, holes = []) {\r\n return original.info;\r\n }\r\n transform(original, m4, desc, surface, contour, holes = []) {\r\n return original.info;\r\n }\r\n}\r\n//# sourceMappingURL=FaceInfo.js.map","import { Pair } from \"javasetmap.ts\";\r\nimport { AABB, arrayFromFunction, arrayRange, assert, assertf, assertInst, assertVectors, bagRemoveIndex, binaryIndexOf, binaryInsert, concatenated, disableConsole, doubleSignedArea, enableConsole, eq, eq0, ge, getLast, GOLDEN_RATIO, gt, indexWithMax, isCCW, le, lerp, lt, mapPush, MINUS, mod, NLA_PRECISION, snap, TAU, Transformable, V3, min as arrayMin, } from \"ts3dutils\";\r\nimport { Mesh, pushQuad } from \"tsgl\";\r\nimport { BRep, ConicSurface, COPLANAR_SAME, createEdge, dotCurve2, Edge, EllipsoidSurface, EPS, fff, getGlobalId, INSIDE, L3, P3, ParametricSurface, PlaneSurface, PointVsFace, splitsVolumeEnclosingCone2, splitsVolumeEnclosingFaces, splitsVolumeEnclosingFacesP, splitsVolumeEnclosingFacesP2, StraightEdge, triangulateVertices, } from \".\";\r\nimport { abs, ceil, floor, max, min, sign } from \"./math\";\r\nexport class Face extends Transformable {\r\n constructor(surface, contour, holes = [], name, info) {\r\n super();\r\n this.surface = surface;\r\n this.contour = contour;\r\n this.holes = holes;\r\n this.name = name;\r\n this.info = info;\r\n this.aabb = undefined;\r\n //assert(name)\r\n Edge.assertLoop(contour);\r\n assert(contour.every((f) => f instanceof Edge), () => \"contour.every(f => f instanceof Edge)\" + contour);\r\n // contour.forEach(e => !surface.containsCurve(e.curve) &&\r\n // console.log('FAIL:'+surface.distanceToPoint(e.curve.anchor)))\r\n //contour.forEach(e => {\r\n //\tassert(surface.containsCurve(e.curve), 'edge not in surface ' + e + surface)\r\n //})\r\n //assert(surface.edgeLoopCCW(contour), surface.toString() + contour.join('\\n'))\r\n holes && holes.forEach((hole) => Edge.assertLoop(hole));\r\n holes && holes.forEach((hole) => assert(!surface.edgeLoopCCW(hole)));\r\n assert(!holes || holes.constructor == Array, holes && holes.toString());\r\n this.allEdges = Array.prototype.concat.apply(this.contour, this.holes);\r\n }\r\n static assembleFacesFromLoops(loops, surface, faceConstructor) {\r\n function placeRecursively(newLoopInfo, loopInfos) {\r\n if (loopInfos.length == 0) {\r\n loopInfos.push(newLoopInfo);\r\n }\r\n else {\r\n const subLoopInfo = loopInfos.find((loopInfo) => BRep.loop1ContainsLoop2(loopInfo.loop, loopInfo.ccw, newLoopInfo.loop, newLoopInfo.ccw, surface));\r\n if (subLoopInfo) {\r\n placeRecursively(newLoopInfo, subLoopInfo.subloops);\r\n }\r\n else {\r\n // newLoopInfo isnt contained by any other subLoopInfo\r\n for (let i = loopInfos.length; --i >= 0;) {\r\n const subLoopInfo = loopInfos[i];\r\n //console.log('cheving subLoopInfo', surface.loopContainsPoint(newLoopInfo.edges,\r\n // subLoopInfo.edges[0].a))\r\n if (BRep.loop1ContainsLoop2(newLoopInfo.loop, newLoopInfo.ccw, subLoopInfo.loop, subLoopInfo.ccw, surface)) {\r\n newLoopInfo.subloops.push(subLoopInfo);\r\n loopInfos.splice(i, 1); // remove it\r\n }\r\n }\r\n loopInfos.push(newLoopInfo);\r\n }\r\n }\r\n }\r\n function newFacesRecursive(loopInfo) {\r\n newFaces.push(new faceConstructor(surface, loopInfo.ccw ? loopInfo.loop : Edge.reversePath(loopInfo.loop), loopInfo.subloops.map((sl) => sl.ccw ? Edge.reversePath(sl.loop) : sl.loop)));\r\n loopInfo.subloops.forEach((sl) => sl.subloops.forEach((sl2) => newFacesRecursive(sl2)));\r\n }\r\n const newFaces = [];\r\n const topLevelLoops = [];\r\n loops.forEach((loop) => placeRecursively({\r\n loop: loop,\r\n ccw: surface.edgeLoopCCW(loop),\r\n subloops: [],\r\n }, topLevelLoops));\r\n topLevelLoops.forEach((tll) => newFacesRecursive(tll));\r\n return newFaces;\r\n }\r\n //fromLoops(loops: Edge[][], surface: Surface) {\r\n //\ttype LoopInfo = {loop: Edge[], ccw: boolean, subloops: LoopInfo[]}\r\n //\tfunction placeRecursively(newLoopInfo: LoopInfo, loopInfos: LoopInfo[]) {\r\n //\t\tif (loopInfos.length == 0) {\r\n //\t\t\tloopInfos.push(newLoopInfo)\r\n //\t\t} else {\r\n //\t\t\tconst subLoopInfo = loopInfos.find(loopInfo => BRep.loop1ContainsLoop2(loopInfo.loop, loopInfo.ccw,\r\n // newLoopInfo.loop, newLoopInfo.ccw, surface)) if (subLoopInfo) { placeRecursively(newLoopInfo,\r\n // subLoopInfo.subloops) } else { // newLoopInfo isnt contained by any other subLoopInfo for (let i =\r\n // loopInfos.length; --i >= 0;) { const subLoopInfo = loopInfos[i] //console.log('cheving subLoopInfo',\r\n // surface.loopContainsPoint(newLoopInfo.edges, subLoopInfo.edges[0].a)) if\r\n // (BRep.loop1ContainsLoop2(newLoopInfo.loop, subLoopInfo.loop, surface)) { newLoopInfo.subloops.push(subLoopInfo)\r\n // loopInfos.splice(i, 1) // remove it } } loopInfos.push(newLoopInfo) } } } function newFacesRecursive(loopInfo:\r\n // LoopInfo): void { // CW loops can be top level, if they are holes in the original face not contained in the new\r\n // face if (loopInfo.ccw) { if (loopInfo.subloops.every(sl => !sl.ccw)) { const newFace = new\r\n // faceConstructor(surface, loopInfo.loop, loopInfo.subloops.map(sl => sl.loop)) newFaces.push(newFace)\r\n // loopInfo.subloops.forEach(sl => sl.subloops.forEach(slsl => slsl.ccw && newFacesRecursive(slsl))) } else {\r\n // loopInfo.subloops.forEach(sl => sl.ccw && newFacesRecursive(sl)) } } } const newFaces: Face[] = [] const\r\n // topLevelLoops:LoopInfo[] = [] loops.forEach(loop => placeRecursively({loop: loop, ccw:\r\n // surface.edgeLoopCCW(loop), subloops: []}, topLevelLoops)) topLevelLoops.forEach(tll => newFacesRecursive(tll))\r\n // return newFaces }\r\n static create(surface, faceEdges, holes, faceName, info) {\r\n return surface instanceof PlaneSurface\r\n ? new PlaneFace(surface, faceEdges, holes, faceName, info)\r\n : new RotationFace(surface, faceEdges, holes, faceName, info);\r\n }\r\n intersectFace(face2, thisBrep, face2Brep, faceMap, thisEdgePoints, otherEdgePoints, checkedPairs) {\r\n //thisEdgePoints = {\r\n // get(key) {\r\n // return _thisEdgePoints.get(key)\r\n // },\r\n // set(key, value) {\r\n // assert(thisBrep.edgeFaces.get(key))\r\n // _thisEdgePoints.set(key, value)\r\n // }\r\n //}\r\n function hasPair(a, b) {\r\n return checkedPairs.has(new Pair(a, b));\r\n }\r\n function addPair(a, b) {\r\n return checkedPairs.add(new Pair(a, b));\r\n }\r\n /**\r\n * @param newEdge generated segment\r\n * @param col1 if newEdge is colinear to an edge of this, the edge in question\r\n * @param col2 same for face2\r\n * @return whether new edge was added.\r\n */\r\n function handleNewEdge(newEdge, col1, col2) {\r\n if (!col1 && !col2) {\r\n let correctDir = face.surface\r\n .normalP(newEdge.a)\r\n .cross(face2.surface.normalP(newEdge.a));\r\n if (correctDir.likeO()) {\r\n const t = lerp(newEdge.aT, newEdge.bT, 1 / GOLDEN_RATIO), p = newEdge.curve.at(t);\r\n correctDir = face.surface.normalP(p).cross(face2.surface.normalP(p));\r\n }\r\n if (!correctDir.likeO()) {\r\n if (correctDir.dot(newEdge.aDir) < 0) {\r\n newEdge = newEdge.flipped();\r\n }\r\n mapPush(faceMap, face, newEdge);\r\n mapPush(faceMap, face2, newEdge.flipped());\r\n }\r\n else {\r\n const p = newEdge.a;\r\n const plane = P3.normalOnAnchor(newEdge.aDir, p);\r\n const up = face.surface.normalP(p);\r\n const sameDir = up.dot(face2.surface.normalP(p)) > 0;\r\n const canonDir = plane.normal1.cross(up);\r\n const curve = face.surface.isCurvesWithPlane(plane)[0], curveT = curve.pointT(p), curveDir = sign(canonDir.dot(curve.tangentAt(curveT)));\r\n const curve2 = face2.surface.isCurvesWithPlane(plane)[0], curve2T = curve2.pointT(p), curve2Dir = sign(canonDir.dot(curve.tangentAt(curve2T)));\r\n const foo = curve.diff(curveT, EPS * curveDir).dot(up);\r\n const foo2 = curve2.diff(curve2T, EPS * curve2Dir).dot(up);\r\n if (foo2 < foo) {\r\n mapPush(faceMap, face2, sameDir ? newEdge.flipped() : newEdge);\r\n }\r\n if (up.dot(face2.surface.normalP(p)) < 0 == foo2 < foo) {\r\n mapPush(faceMap, face, newEdge.flipped());\r\n }\r\n const bar = curve.diff(curveT, EPS * curveDir).dot(up);\r\n const bar2 = curve2.diff(curve2T, EPS * curve2Dir).dot(up);\r\n if (bar2 < bar) {\r\n mapPush(faceMap, face2, sameDir ? newEdge : newEdge.flipped());\r\n }\r\n if (sameDir != bar2 < bar) {\r\n mapPush(faceMap, face, newEdge);\r\n }\r\n }\r\n return true;\r\n }\r\n function handleEdgeInFace(col1, col2, face, face2, thisBrep, face2Brep, coplanarSameIsInside, has, add) {\r\n if (col1 && !col2) {\r\n if (hasPair(col1.getCanon(), face2))\r\n return false;\r\n //add(col1.getCanon(), face2)\r\n const surface2 = face2.surface;\r\n // NB: a new edge is inserted even though it may be the same as an old one\r\n // however it indicates that it intersects the other volume here, i.e. the old edge cannot\r\n // be counted as 'inside' for purposes of reconstitution\r\n thisBrep.edgeFaces.get(col1.getCanon()).forEach((faceInfo) => {\r\n //const dot = snap0(surface2.normal1.dot(faceInfo.inside))\r\n //if (dot == 0 ? !coplanarSameIsInside : dot < 0) {\r\n const pointsInsideFace = fff(faceInfo, face2.surface);\r\n const edgeInside = pointsInsideFace == INSIDE ||\r\n (!coplanarSameIsInside && pointsInsideFace == COPLANAR_SAME);\r\n const pushEdge = faceInfo.edge\r\n .tangentAt(faceInfo.edge.curve.pointT(newEdge.a))\r\n .like(newEdge.aDir)\r\n ? newEdge\r\n : newEdge.flipped();\r\n assert(faceInfo.edge\r\n .tangentAt(faceInfo.edge.curve.pointT(pushEdge.a))\r\n .like(pushEdge.aDir));\r\n edgeInside && mapPush(faceMap, faceInfo.face, pushEdge);\r\n });\r\n const surface2NormalAtNewEdgeA = surface2.normalP(newEdge.a);\r\n const newEdgeInside = surface2NormalAtNewEdgeA.cross(newEdge.aDir);\r\n const sVEF1 = splitsVolumeEnclosingFacesP(thisBrep, col1.getCanon(), newEdge.a, newEdgeInside, surface2NormalAtNewEdgeA);\r\n let addNewEdge, addNewEdgeFlipped;\r\n if ((addNewEdge =\r\n sVEF1 == INSIDE ||\r\n (coplanarSameIsInside && sVEF1 == COPLANAR_SAME))) {\r\n mapPush(faceMap, face2, newEdge);\r\n }\r\n const sVEF2 = splitsVolumeEnclosingFacesP(thisBrep, col1.getCanon(), newEdge.a, newEdgeInside.negated(), surface2NormalAtNewEdgeA);\r\n if ((addNewEdgeFlipped =\r\n sVEF2 == INSIDE ||\r\n (coplanarSameIsInside && sVEF2 == COPLANAR_SAME))) {\r\n mapPush(faceMap, face2, newEdge.flipped());\r\n }\r\n if (addNewEdge ||\r\n addNewEdgeFlipped ||\r\n (sVEF1 == COPLANAR_SAME && sVEF2 == INSIDE) ||\r\n (sVEF2 == COPLANAR_SAME && sVEF1 == INSIDE)) {\r\n return true;\r\n }\r\n }\r\n return false;\r\n }\r\n const c1 = handleEdgeInFace(col1, col2, face, face2, thisBrep, face2Brep, false, hasPair, addPair);\r\n const c2 = handleEdgeInFace(col2, col1, face2, face, face2Brep, thisBrep, true, (a, b) => hasPair(b, a), (a, b) => addPair(b, a));\r\n if (c1 || c2)\r\n return true;\r\n if (col1 && col2) {\r\n if (hasPair(col1.getCanon(), col2.getCanon()))\r\n return false;\r\n addPair(col1.getCanon(), col2.getCanon());\r\n function handleColinearEdgeFaces(col1, col2, thisBrep, face2Brep, coplanarSameIsInside, thisEdgePoints, has, add) {\r\n // not entirely sure for what i had the dirInsides in?\r\n //const aDirNegatedInside = (newEdge.a.like(col2.a) || newEdge.a.like(col2.b)) &&\r\n // splitsVolumeEnclosingCone(face2Brep, newEdge.a, newEdge.aDir.negated()) == INSIDE const\r\n // bDirInside = (newEdge.b.like(col2.a) || newEdge.b.like(col2.b)) &&\r\n // splitsVolumeEnclosingCone(face2Brep, newEdge.b, newEdge.bDir) == INSIDE\r\n for (const faceInfo of thisBrep.edgeFaces.get(col1.getCanon())) {\r\n const sVEF = splitsVolumeEnclosingFaces(face2Brep, col2.getCanon(), faceInfo.inside, faceInfo.normalAtCanonA);\r\n const edgeInside = sVEF == INSIDE || (coplanarSameIsInside && sVEF == COPLANAR_SAME);\r\n const pushEdge = faceInfo.edge.aDir.like(newEdge.aDir)\r\n ? newEdge\r\n : newEdge.flipped();\r\n if (edgeInside) {\r\n mapPush(faceMap, faceInfo.face, pushEdge);\r\n const aT = col1.getCanon().curve.pointT(newEdge.a);\r\n if (!eq(aT, col1.aT) && !eq(aT, col1.bT)) {\r\n // newEdge.a is in center of col1\r\n if (splitsVolumeEnclosingCone2(face2Brep, newEdge.a, newEdge.curve, newEdge.aT, -Math.sign(newEdge.deltaT())) == INSIDE) {\r\n mapPush(thisEdgePoints, col1.getCanon(), {\r\n p: newEdge.a,\r\n edgeT: aT,\r\n });\r\n }\r\n }\r\n const bT = col1.getCanon().curve.pointT(newEdge.b);\r\n if (!eq(bT, col1.aT) && !eq(bT, col1.bT)) {\r\n if (splitsVolumeEnclosingCone2(face2Brep, newEdge.b, newEdge.curve, newEdge.bT, Math.sign(newEdge.deltaT())) == INSIDE) {\r\n mapPush(thisEdgePoints, col1.getCanon(), {\r\n p: newEdge.b,\r\n edgeT: bT,\r\n });\r\n }\r\n }\r\n }\r\n }\r\n }\r\n handleColinearEdgeFaces(col1, col2, thisBrep, face2Brep, true, thisEdgePoints, hasPair, addPair);\r\n handleColinearEdgeFaces(col2, col1, face2Brep, thisBrep, false, otherEdgePoints, (a, b) => hasPair(b, a), (a, b) => addPair(b, a));\r\n return false;\r\n }\r\n return false;\r\n }\r\n // what needs to be generated: new edges on face\r\n // points on edges where they are cut by faces so that sub edges will be generated for loops\r\n // points on ends of edges where the edge will be an edge in the new volume where it goes from A to B\r\n // you don't want those to be marked as 'inside', otherwise invalid faces will be added\r\n // if a face cuts a corner, nothing needs to be done, as that alone does not limit what adjacent faces will be\r\n function handleEndPoint(a, b, newEdge) {\r\n // ends in the middle of b's face\r\n if (a && !b) {\r\n if (!a.colinear && a.edgeT != a.edge.aT && a.edgeT != a.edge.bT) {\r\n mapPush(thisEdgePoints, a.edge.getCanon(), a);\r\n assert(a.edge.isValidT(a.edgeT));\r\n }\r\n // else colinear segment ends in middle of other face, do nothing\r\n }\r\n // ends in the middle of a's face\r\n if (b && !a) {\r\n if (!b.colinear && b.edgeT != b.edge.aT && b.edgeT != b.edge.bT) {\r\n mapPush(otherEdgePoints, b.edge.getCanon(), b);\r\n assert(b.edge.isValidT(b.edgeT));\r\n }\r\n // else colinear segment ends in middle of other face, do nothing\r\n }\r\n if (a && b) {\r\n assert(a.colinear || b.colinear || eq(a.t, b.t));\r\n // if a or b is colinear the correct points will already have been added to the edge by handleNewEdge\r\n // segment starts/ends on edge/edge intersection\r\n function handleAB(a, b, face, face2, thisPlane, face2Plane, thisBrep, face2Brep, first, thisEdgePoints) {\r\n if (!a.colinear && a.edgeT != a.edge.aT && a.edgeT != a.edge.bT) {\r\n //if (!hasPair(a.edge.getCanon(), b.edge.getCanon())) {\r\n addPair(a.edge.getCanon(), b.edge.getCanon());\r\n // ends on a, on colinear segment b bT != a.edge.bT &&\r\n // b can be colinear, so edgeT == aT is possible\r\n if (a.p.like(b.edge.a) || a.p.like(b.edge.b)) {\r\n const corner = a.p.like(b.edge.a) ? b.edge.a : b.edge.b;\r\n // face2brep corner on edge\r\n const sVEC1 = splitsVolumeEnclosingCone2(face2Brep, corner, a.edge.curve, a.edgeT, 1);\r\n const sVEC2 = splitsVolumeEnclosingCone2(face2Brep, corner, a.edge.curve, a.edgeT, -1);\r\n // if either of these return ALONG_EDGE_OR_PLANE, then the breps share a colinear edge\r\n if (INSIDE == sVEC1 || INSIDE == sVEC2) {\r\n mapPush(thisEdgePoints, a.edge.getCanon(), a);\r\n assert(a.edge.isValidT(a.edgeT));\r\n }\r\n }\r\n else {\r\n // edge / edge center intersection\r\n // todo: is this even necessary considering we add edges anyway? i think so...\r\n // const testVector =\r\n // a.edge.tangentAt(a.edgeT).rejectedFrom(b.edge.tangentAt(b.edge.curve.pointT(a.p)))\r\n // assert(!testVector.likeO())\r\n const sVEF1 = splitsVolumeEnclosingFacesP2(face2Brep, b.edge.getCanon(), a.p, a.edge.curve, a.edgeT, 1, thisPlane.normalP(a.p));\r\n const sVEF2 = splitsVolumeEnclosingFacesP2(face2Brep, b.edge.getCanon(), a.p, a.edge.curve, a.edgeT, -1, thisPlane.normalP(a.p));\r\n if (INSIDE == sVEF1 ||\r\n (first && COPLANAR_SAME == sVEF1) ||\r\n INSIDE == sVEF2 ||\r\n (first && COPLANAR_SAME == sVEF2)) {\r\n mapPush(thisEdgePoints, a.edge.getCanon(), a);\r\n assert(a.edge.isValidT(a.edgeT));\r\n }\r\n }\r\n //}\r\n }\r\n }\r\n handleAB(a, b, face, face2, surface, surface2, thisBrep, face2Brep, true, thisEdgePoints);\r\n handleAB(b, a, face2, face, surface2, surface, face2Brep, thisBrep, false, otherEdgePoints);\r\n }\r\n }\r\n assertInst(Face, face2);\r\n const face = this;\r\n const surface = face.surface, surface2 = face2.surface;\r\n if (!this.getAABB().touchesAABBfuzzy(face2.getAABB())) {\r\n return;\r\n }\r\n if (surface.isCoplanarTo(surface2)) {\r\n return;\r\n }\r\n const isCurves = surface.isCurvesWithSurface(surface2);\r\n if (0 == isCurves.length) {\r\n return;\r\n }\r\n for (const isCurve of isCurves) {\r\n assert(surface.containsCurve(isCurve));\r\n assert(surface2.containsCurve(isCurve));\r\n }\r\n for (let isCurveIndex = 0; isCurveIndex < isCurves.length; isCurveIndex++) {\r\n // get intersections of newCurve with other edges of face and face2\r\n const isCurve = isCurves[isCurveIndex];\r\n const ps1 = face.edgeISPsWithSurface(isCurve, face2.surface);\r\n const ps2 = face2.edgeISPsWithSurface(isCurve, face.surface);\r\n // for non-endless curves, e.g. ellipses, the intersections of the faces can be non-zero, even if one of\r\n // the faces doesn't register any points on the curve. For example, if a cylinder is cut entirely by a\r\n // plane face (all its edges around the cylinder), then the face will contain the entire curve and\r\n // 'ps' for the plane face will be empty\r\n // TODO: behavior when curves touch face?\r\n // !! start in does depend on insideDir... TODO\r\n assertf(() => 0 == ps1.length ||\r\n !eq0(ps1[0].insideDir.dot(isCurve.tangentAt(ps1[0].t))), () => ps1[0].insideDir.dot(isCurve.tangentAt(ps1[0].t)));\r\n assertf(() => 0 == ps2.length ||\r\n !eq0(ps2[0].insideDir.dot(isCurve.tangentAt(ps2[0].t))), () => ps2[0].insideDir.dot(isCurve.tangentAt(ps2[0].t)));\r\n function startsInside(ps, face) {\r\n if (0 == ps.length) {\r\n return (isFinite(isCurve.tMin) &&\r\n face.containsPoint2(isCurve.at(isCurve.tMin)) == PointVsFace.INSIDE);\r\n }\r\n else {\r\n return ps[0].insideDir.dot(isCurve.tangentAt(ps[0].t)) < 0;\r\n }\r\n }\r\n // they can't both be empty currently\r\n // they can't both start 'inside'\r\n let in1 = startsInside(ps1, face);\r\n let in2 = startsInside(ps2, face2);\r\n if ((0 == ps1.length && !in1) || (0 == ps2.length && !in2)) {\r\n continue;\r\n }\r\n //assert(!in1 || !in2)\r\n let col1, col2;\r\n let i = 0, j = 0, last;\r\n let startP = in1 && in2 ? isCurve.at(isCurve.tMin) : undefined, startDir, startT = isCurve.tMin, startA, startB;\r\n while (i < ps1.length || j < ps2.length) {\r\n assert(i <= ps1.length);\r\n assert(j <= ps2.length);\r\n const a = ps1[i], b = ps2[j];\r\n assert(a || b);\r\n if (j == ps2.length || (i < ps1.length && lt(a.t, b.t))) {\r\n last = a;\r\n in1 = !in1;\r\n a.used = true;\r\n col1 = a.colinear ? a : undefined;\r\n i++;\r\n }\r\n else if (i == ps1.length || gt(a.t, b.t)) {\r\n last = b;\r\n b.used = true;\r\n in2 = !in2;\r\n col2 = b.colinear ? b : undefined;\r\n j++;\r\n }\r\n else {\r\n last = a;\r\n a.used = true;\r\n b.used = true;\r\n in1 = !in1;\r\n in2 = !in2;\r\n //if (in1 == in2) {\r\n col1 = a.colinear ? a : undefined;\r\n col2 = b.colinear ? b : undefined;\r\n //}\r\n i++;\r\n j++;\r\n }\r\n if (startP && !(in1 && in2)) {\r\n // segment end\r\n startDir = isCurve.tangentAt(startT);\r\n if (eq(startT, last.t)) {\r\n startP = undefined;\r\n continue;\r\n }\r\n assert(lt(startT, last.t));\r\n startT > last.t && (startDir = startDir.negated());\r\n let endDir = isCurve.tangentAt(last.t);\r\n startT > last.t && (endDir = endDir.negated());\r\n const newEdge = createEdge(isCurve, startP, last.p, startT, last.t, undefined, startDir, endDir, \"genseg\" + getGlobalId());\r\n startP = undefined;\r\n if (handleNewEdge(newEdge, col1 && col1.edge, col2 && col2.edge)) {\r\n handleEndPoint(startA || col1, startB || col2, newEdge);\r\n handleEndPoint((a && a.used && a) || col1, (b && b.used && b) || col2, newEdge);\r\n }\r\n }\r\n else if (in1 && in2) {\r\n // new segment just started\r\n startP = last.p;\r\n startDir = last.insideDir;\r\n startT = last.t;\r\n startA = a && a.used ? a : undefined;\r\n startB = b && b.used ? b : undefined;\r\n }\r\n }\r\n if (in1 && in2 && startT !== isCurve.tMax) {\r\n const endT = isCurve.tMax;\r\n startDir = isCurve.tangentAt(startT);\r\n startT > endT && (startDir = startDir.negated());\r\n let endDir = isCurve.tangentAt(endT);\r\n startT > endT && (endDir = endDir.negated());\r\n const newEdge = createEdge(isCurve, startP, isCurve.at(endT), startT, endT, undefined, startDir, endDir, \"genseg\" + getGlobalId());\r\n if (handleNewEdge(newEdge, col1 && col1.edge, col2 && col2.edge)) {\r\n handleEndPoint(startA || col1, startB || col2, newEdge);\r\n }\r\n }\r\n }\r\n face.getAllEdges().forEach((edge) => {\r\n checkedPairs.add(new Pair(edge.getCanon(), face2));\r\n });\r\n face2.getAllEdges().forEach((edge) => {\r\n checkedPairs.add(new Pair(edge.getCanon(), face));\r\n });\r\n }\r\n edgeISPsWithSurface(isCurve, surface2) {\r\n const face = this;\r\n const surface = face.surface;\r\n const loops = face.holes.concat([face.contour]);\r\n const ps = [];\r\n for (const loop of loops) {\r\n const colinearEdges = loop.map((edge) => edge.curve.isColinearTo(isCurve));\r\n //const colinearSides = loop.map((edge, edgeIndex) => -1 != colinearEdges[edgeIndex]\r\n // && -sign(isCurves[colinearEdges[edgeIndex]].tangentAt(edge.aT).dot(edge.aDir)))\r\n for (let edgeIndex = 0; edgeIndex < loop.length; edgeIndex++) {\r\n const edge = loop[edgeIndex];\r\n const nextEdgeIndex = (edgeIndex + 1) % loop.length, nextEdge = loop[nextEdgeIndex];\r\n //console.log(edge.toSource()) {p:V3(2, -2.102, 0),\r\n if (colinearEdges[edgeIndex]) {\r\n if (isCurve.containsPoint(edge.a)) {\r\n const prevEdgeIndex = (edgeIndex - 1 + loop.length) % loop.length, prevEdge = loop[prevEdgeIndex];\r\n const curveAT = isCurve.pointT(edge.a);\r\n const colinearOutA = edge.aDir.cross(surface.normalP(edge.a));\r\n if (!colinearEdges[prevEdgeIndex] &&\r\n dotCurve2(prevEdge.curve, prevEdge.bT, colinearOutA, -sign(prevEdge.deltaT())) > 0) {\r\n ps.push({\r\n p: prevEdge.b,\r\n insideDir: edge.aDir.negated(),\r\n t: curveAT,\r\n edge: prevEdge,\r\n edgeT: prevEdge.bT,\r\n colinear: false,\r\n });\r\n }\r\n ps.push({\r\n p: edge.a,\r\n insideDir: edge.aDir,\r\n t: curveAT,\r\n edge: edge,\r\n edgeT: edge.aT,\r\n colinear: true,\r\n });\r\n }\r\n if (isCurve.containsPoint(edge.b)) {\r\n const curveBT = isCurve.pointT(edge.b);\r\n const colinearOutB = edge.bDir.cross(surface.normalP(edge.b));\r\n if (!colinearEdges[nextEdgeIndex] &&\r\n dotCurve2(nextEdge.curve, nextEdge.aT, colinearOutB, sign(nextEdge.deltaT())) > 0) {\r\n ps.push({\r\n p: edge.b,\r\n insideDir: edge.bDir,\r\n t: curveBT,\r\n edge: nextEdge,\r\n edgeT: nextEdge.aT,\r\n colinear: false,\r\n });\r\n }\r\n ps.push({\r\n p: edge.b,\r\n insideDir: edge.bDir.negated(),\r\n t: curveBT,\r\n edge: edge,\r\n edgeT: edge.bT,\r\n colinear: true,\r\n });\r\n }\r\n }\r\n else {\r\n const edgeTs = edge.edgeISTsWithSurface(surface2);\r\n for (const edgeT of edgeTs) {\r\n const p = edge.curve.at(edgeT);\r\n if (!isCurve.containsPoint(p))\r\n continue;\r\n const curveT = isCurve.pointT(p);\r\n assert(!isNaN(curveT));\r\n const insideDir = edge\r\n .tangentAt(edgeT)\r\n .cross(surface.normalP(p))\r\n .negated();\r\n const isTangent = isCurve.tangentAt(curveT);\r\n //if(!eq0(insideDir.dot(isTangent))) {\r\n // Edge.edgeISTsWithSurface returns snapped values, so comparison with == is ok:\r\n if (edgeT == edge.bT) {\r\n // endpoint lies on intersection line\r\n if (!colinearEdges[nextEdgeIndex]) {\r\n if (!eq(curveT, isCurve.tMax)) {\r\n const pointsToInside = this.pointsToInside3(edge.b, isCurve, curveT, 1);\r\n assert(pointsToInside != PointVsFace.ON_EDGE);\r\n if (PointVsFace.INSIDE == pointsToInside) {\r\n ps.push({\r\n p: edge.b,\r\n insideDir: isTangent,\r\n t: curveT,\r\n edge: edge,\r\n edgeT: edge.bT,\r\n colinear: false,\r\n });\r\n }\r\n }\r\n if (!eq(curveT, isCurve.tMin)) {\r\n const pointsToInside = this.pointsToInside3(edge.b, isCurve, curveT, -1);\r\n assert(pointsToInside != PointVsFace.ON_EDGE);\r\n if (PointVsFace.INSIDE == pointsToInside) {\r\n ps.push({\r\n p: edge.b,\r\n insideDir: isTangent.negated(),\r\n t: curveT,\r\n edge: edge,\r\n edgeT: edge.bT,\r\n colinear: false,\r\n });\r\n }\r\n }\r\n //let thisSide = -normVector.dot(edge.bDir)\r\n //if (eq0(thisSide)) {\r\n // // advanced test\r\n // const dir = -sign(edge.deltaT())\r\n // const iscd = isCurve.at(curveT).to(isCurve.at(curveT + dir * dirFactor *\r\n // eps)).dot(normVector) const ecd = edge.curve.at(edgeT).to(edge.curve.at(edgeT + dir\r\n // * eps)).dot(normVector) thisSide = sign(ecd - iscd) } let nextSide =\r\n // normVector.dot(nextEdge.aDir) if (eq0(nextSide)) { // advanced test const dirFactor\r\n // = sign(snap0(isTangent.dot(nextEdge.curve.tangentAt(nextEdge.aT)))) assert(dirFactor\r\n // !== 0) const dir = sign(nextEdge.deltaT()) const iscd =\r\n // isCurve.at(curveT).to(isCurve.at(curveT + dir * dirFactor * eps)).dot(normVector)\r\n // const ecd = nextEdge.curve.at(nextEdge.aT).to(nextEdge.curve.at(nextEdge.aT + dir *\r\n // eps)).dot(normVector) nextSide = sign(ecd - iscd) } if (nextSide < 0 || thisSide <\r\n // 0) { assert(!eq0(insideDir.dot(isTangent))) // next segment is not colinear and ends\r\n // on different side ps.push({ p: edge.b, insideDir: insideDir, t: curveT, edge: edge,\r\n // edgeT: edge.bT, colinear: false}) }\r\n }\r\n }\r\n else if (edgeT != edge.aT) {\r\n // edge crosses/touches an intersection curve, neither starts nor ends on it\r\n if (eq0(insideDir.dot(isTangent))) {\r\n const dirFactor = sign(isTangent.dot(edge.curve.tangentAt(edgeT)));\r\n const eps = 1e-4;\r\n for (const dir of [-1, 1]) {\r\n if ((-1 == dir * dirFactor && edgeT == edge.minT) ||\r\n (1 == dir * dirFactor && edgeT == edge.maxT) ||\r\n (-1 == dir && curveT == isCurve.tMin) ||\r\n (1 == dir && curveT == isCurve.tMax))\r\n continue;\r\n const iscd = isCurve\r\n .at(curveT)\r\n .to(isCurve.at(curveT + dir * eps))\r\n .dot(insideDir);\r\n const ecd = edge.curve\r\n .at(edgeT)\r\n .to(edge.curve.at(edgeT + dir * dirFactor * eps))\r\n .dot(insideDir);\r\n if (iscd - ecd > 0) {\r\n ps.push({\r\n p,\r\n insideDir: isTangent.times(dir),\r\n t: curveT,\r\n edge: edge,\r\n edgeT: edgeT,\r\n colinear: false,\r\n });\r\n }\r\n }\r\n }\r\n else {\r\n ps.push({\r\n p: p,\r\n insideDir: insideDir,\r\n t: curveT,\r\n edge: edge,\r\n edgeT: edgeT,\r\n colinear: false,\r\n });\r\n }\r\n }\r\n //} else {\r\n //\r\n //\tconst dirFactor = sign(isTangent.dot(edge.curve.tangentAt(edgeT)))\r\n //\tconst eps = 1e-4\r\n //\tconst normVector = surface2.normalP(p)\r\n //\tfor (const dir of [-1, 1]) {\r\n //\t\tif (-1 == dir * dirFactor && edgeT == edge.minT ||\r\n //\t\t\t1 == dir * dirFactor && edgeT == edge.maxT ||\r\n //\t\t\t-1 == dir && curveT == isCurve.tMin ||\r\n //\t\t\t1 == dir && curveT == isCurve.tMax) continue\r\n //\t\tconst iscd = isCurve.at(curveT).to(isCurve.at(curveT + dir * eps)).dot(normVector)\r\n //\t\tconst ecd = edge.curve.at(edgeT).to(edge.curve.at(edgeT + dir * dirFactor *\r\n // eps)).dot(normVector) if (iscd > ecd) { ps.push({p, insideDir: isTangent.times(dir *\r\n // dirFactor), t: curveT, edge: edge, edgeT: edgeT, colinear: false}) } }\r\n // curveVsSurface(isCurve, curveT, p, surface2) }\r\n }\r\n }\r\n }\r\n }\r\n // duplicate 't's are ok, as sometimes a segment needs to stop and start again\r\n // should be sorted so that back facing ones are first\r\n ps.sort((a, b) => a.t - b.t || a.insideDir.dot(isCurve.tangentAt(a.t)));\r\n return ps;\r\n }\r\n transform(m4) {\r\n const mirroring = m4.isMirroring();\r\n const newEdges = Edge.reversePath(this.contour.map((e) => e.transform(m4)), mirroring);\r\n const newHoles = this.holes.map((hole) => Edge.reversePath(hole.map((e) => e.transform(m4)), mirroring));\r\n return new this.constructor(this.surface.transform(m4), newEdges, newHoles, this.name, this.info);\r\n }\r\n transform4(m4) {\r\n const mirroring = m4.isMirroring();\r\n const newEdges = Edge.reversePath(this.contour.map((e) => e.transform4(m4)), mirroring);\r\n const newHoles = this.holes.map((hole) => Edge.reversePath(hole.map((e) => e.transform4(m4)), mirroring));\r\n return new this.constructor(this.surface.transform4(m4), newEdges, newHoles, this.name, this.info);\r\n }\r\n flipped() {\r\n const newEdges = this.contour.map((e) => e.flipped()).reverse();\r\n const newHoles = this.holes.map((hole) => hole.map((e) => e.flipped()).reverse());\r\n return new this.constructor(this.surface.flipped(), newEdges, newHoles, this.name, this.info);\r\n }\r\n toString() {\r\n return (\"new \" +\r\n this.constructor.name +\r\n \"(\" +\r\n this.surface +\r\n \", [\" +\r\n this.contour.map((e) => \"\\n\\t\" + e).join() +\r\n \"]\" +\r\n this.holes.map((hole) => \"\\n\\t\\thole: \" + hole.join()) +\r\n \")\");\r\n }\r\n toSource() {\r\n return (\"new \" +\r\n this.constructor.name +\r\n \"(\" +\r\n this.surface.toSource() +\r\n \", [\" +\r\n this.contour.map((e) => \"\\n\\t\" + e.toSource() + \",\").join(\"\") +\r\n \"], [\" +\r\n this.holes\r\n .map((hole) => \"[\" + hole.map((e) => \"\\n\\t\" + e.toSource() + \",\").join(\"\") + \"]\")\r\n .join(\",\") +\r\n \"])\");\r\n }\r\n equals(obj) {\r\n return (this == obj ||\r\n (Object.getPrototypeOf(this) == Object.getPrototypeOf(obj) &&\r\n this.holes.length == obj.holes.length &&\r\n Edge.loopsEqual(this.contour, obj.contour) &&\r\n this.holes.every((hole) => obj.holes.some((hole2) => Edge.loopsEqual(hole, hole2)))));\r\n }\r\n hashCode() {\r\n function arrayHashCode(array) {\r\n let hashCode = 0;\r\n for (const val of array) {\r\n hashCode = (hashCode * 31 + val) | 0;\r\n }\r\n return hashCode;\r\n }\r\n function loopHashCode(loop) {\r\n return arrayHashCode(loop.map((edge) => edge.hashCode()).sort(MINUS));\r\n }\r\n let hashCode = 0;\r\n hashCode =\r\n (hashCode * 31 +\r\n arrayHashCode(this.holes.map((loop) => loopHashCode(loop)).sort(MINUS))) |\r\n 0;\r\n hashCode = (hashCode * 31 + loopHashCode(this.contour)) | 0;\r\n hashCode = (hashCode * 31 + this.surface.hashCode()) | 0;\r\n return hashCode;\r\n }\r\n likeFace(face2) {\r\n function loopsLike(a, b) {\r\n return (a.length == b.length &&\r\n arrayRange(0, a.length, 1).some((offset) => a.every((edge, i) => edge.like(b[(offset + i) % a.length]))));\r\n }\r\n assertInst(Face, face2);\r\n return (this.surface.like(face2.surface) &&\r\n this.holes.length == face2.holes.length &&\r\n loopsLike(this.contour, face2.contour) &&\r\n this.holes.every((hole) => face2.holes.some((hole2) => loopsLike(hole, hole2))));\r\n }\r\n getAllEdges() {\r\n return this.allEdges;\r\n }\r\n addEdgeLines(mesh) {\r\n assert(false, \"buggy, fix\");\r\n const vertices = this.contour.flatMap((edge) => edge.getVerticesNo0()), mvl = mesh.vertices.length;\r\n for (let i = 0; i < vertices.length; i++) {\r\n mesh.vertices.push(vertices[i]);\r\n mesh.LINES.push(mvl + i, mvl + ((i + 1) % vertices.length));\r\n }\r\n }\r\n containsPoint(p) {\r\n assertVectors(p);\r\n return (this.surface.loopContainsPoint(this.contour, p) != PointVsFace.OUTSIDE &&\r\n !this.holes.some((hole) => this.surface.loopContainsPoint(hole, p) != PointVsFace.OUTSIDE));\r\n }\r\n containsPoint2(p) {\r\n assertVectors(p);\r\n const contourContainsPoint = this.surface.loopContainsPoint(this.contour, p);\r\n if (contourContainsPoint != PointVsFace.INSIDE)\r\n return contourContainsPoint;\r\n for (const hole of this.holes) {\r\n const loopContainsPoint = this.surface.loopContainsPoint(hole, p);\r\n if (loopContainsPoint != PointVsFace.OUTSIDE) {\r\n return loopContainsPoint == PointVsFace.ON_EDGE\r\n ? PointVsFace.ON_EDGE\r\n : PointVsFace.OUTSIDE;\r\n }\r\n }\r\n return PointVsFace.INSIDE;\r\n }\r\n /**\r\n *\r\n * @param line\r\n * @returns t param of the line if there is an intersection, NaN otherwise\r\n */\r\n intersectsLine(line) {\r\n assertInst(L3, line);\r\n if (!this.getAABB().intersectsLine(line))\r\n return NaN;\r\n const containedIntersectionsTs = this.surface\r\n .isTsForLine(line)\r\n .filter((t) => this.containsPoint(line.at(t)));\r\n const nearestPointT = arrayMin(containedIntersectionsTs);\r\n return undefined != nearestPointT ? nearestPointT : NaN;\r\n }\r\n toMesh() {\r\n const mesh = new Mesh()\r\n .addIndexBuffer(\"TRIANGLES\")\r\n .addIndexBuffer(\"LINES\")\r\n .addVertexBuffer(\"normals\", \"ts_Normal\");\r\n this.addToMesh(mesh);\r\n //mesh.compile()\r\n return mesh;\r\n }\r\n zDirVolume() {\r\n return this.surface.zDirVolume(this.getAllEdges());\r\n }\r\n calcArea() {\r\n return this.surface.calculateArea(this.getAllEdges());\r\n }\r\n getLoops() {\r\n return [this.contour, ...this.holes];\r\n }\r\n getAABB() {\r\n return (this.aabb ||\r\n (this.aabb = AABB.forAABBs(this.contour.map((e) => e.getAABB()))));\r\n }\r\n pointsToInside3(p, curve, curveT, dir) {\r\n const eps = 1e-6;\r\n const normal = this.surface.normalP(p);\r\n const curveTangent = curve.tangentAt(curveT).times(dir);\r\n const up = normal.cross(curveTangent);\r\n const ecd = curve\r\n .at(curveT)\r\n .to(curve.at(curveT + dir * eps))\r\n .dot(up);\r\n let minValue = Infinity, result, advanced = false;\r\n for (const edge of this.getAllEdges()) {\r\n const aEqP = edge.a.like(p), bEqP = edge.b.like(p);\r\n assert(aEqP == edge.a.like(p));\r\n assert(bEqP == edge.b.like(p));\r\n if (!aEqP && !bEqP)\r\n continue;\r\n const edgeTangent = aEqP ? edge.aDir : edge.bDir.negated();\r\n const angle = curveTangent.angleRelativeNormal(edgeTangent, normal);\r\n if (eq0(angle)) {\r\n if (curve.isColinearTo(edge.curve)) {\r\n return PointVsFace.ON_EDGE;\r\n }\r\n const edgeT = aEqP ? edge.aT : edge.bT;\r\n const edgeDir = (aEqP ? 1 : -1) * sign(edge.deltaT());\r\n const iscd = edge.curve.diff(edgeT, edgeDir * eps).dot(up);\r\n //const iscd = edge.curve.at(edgeT).to(curve.at(edgeT + edgeDir * eps)).dot(up)\r\n const diff = iscd - ecd;\r\n if (diff > 0 && (!advanced || diff < minValue)) {\r\n advanced = true;\r\n minValue = diff;\r\n result = aEqP ? PointVsFace.OUTSIDE : PointVsFace.INSIDE;\r\n }\r\n }\r\n else if (!advanced) {\r\n const angle2 = (angle + TAU) % TAU;\r\n if (angle2 < minValue) {\r\n minValue = angle2;\r\n result = aEqP ? PointVsFace.OUTSIDE : PointVsFace.INSIDE;\r\n }\r\n }\r\n }\r\n if (result == undefined)\r\n throw new Error();\r\n return result;\r\n }\r\n pointsToInside2(p, dir) {\r\n return this.pointsToInside3(p, L3.anchorDirection(p, dir), 0, 1);\r\n //const normal = this.surface.normalP(p)\r\n //let minAngle = Infinity, inOut = false\r\n //function test(v, b) {\r\n //\tconst angle = (dir.angleRelativeNormal(v, normal) + TAU + NLA_PRECISION / 2) % TAU\r\n //\tif (angle <= 2 * NLA_PRECISION) {\r\n //\t\treturn true\r\n //\t}\r\n //\tif (angle < minAngle) {\r\n //\t\tminAngle = angle\r\n //\t\tinOut = b\r\n //\t}\r\n //}\r\n //for (const edge of this.getAllEdges()) {\r\n //\tassert(edge.a.equals(p) || !edge.a.like(p))\r\n //\tassert(edge.b.equals(p) || !edge.b.like(p))\r\n //\tif (edge.a.equals(p) && test(edge.aDir, false)) return PointVsFace.ON_EDGE\r\n //\tif (edge.b.equals(p) && test(edge.bDir.negated(), true)) return PointVsFace.ON_EDGE\r\n //}\r\n //return inOut ? PointVsFace.INSIDE : PointVsFace.OUTSIDE\r\n }\r\n}\r\nexport class PlaneFace extends Face {\r\n constructor(p, contour, holes, name, info) {\r\n assert(p instanceof P3 || p instanceof PlaneSurface);\r\n super(p instanceof P3 ? new PlaneSurface(p) : p, contour, holes, name, info);\r\n }\r\n static forVertices(planeSurface, vs, ...holeVss) {\r\n const _planeSurface = planeSurface instanceof P3 ? new PlaneSurface(planeSurface) : planeSurface;\r\n assert(isCCW(vs, _planeSurface.plane.normal1), \"isCCW(vs, planeSurface.plane.normal1)\");\r\n const edges = StraightEdge.chain(vs);\r\n holeVss.forEach((vs) => assert(doubleSignedArea(vs, _planeSurface.plane.normal1) >= 0, \"doubleSignedArea(vs, planeSurface.plane.normal1) >= 0\"));\r\n const holes = holeVss.map((hvs) => StraightEdge.chain(hvs));\r\n return new PlaneFace(planeSurface, edges, holes);\r\n }\r\n addToMesh(mesh) {\r\n const mvl = mesh.vertices.length;\r\n const normal = this.surface.plane.normal1;\r\n const vertices = this.contour.flatMap((edge) => edge.getVerticesNo0());\r\n for (let i = 0; i < vertices.length; i++) {\r\n mesh.LINES.push(mvl + i, mvl + ((i + 1) % vertices.length));\r\n }\r\n const holeStarts = [];\r\n this.holes.forEach((hole) => {\r\n holeStarts.push(vertices.length);\r\n vertices.push(...hole.flatMap((edge) => edge.getVerticesNo0()));\r\n });\r\n const triangles = triangulateVertices(normal, vertices, holeStarts).map((index) => index + mvl);\r\n Array.prototype.push.apply(mesh.vertices, vertices);\r\n Array.prototype.push.apply(mesh.TRIANGLES, triangles);\r\n Array.prototype.push.apply(mesh.normals, arrayFromFunction(vertices.length, () => normal));\r\n }\r\n intersectsLine(line) {\r\n assertInst(L3, line);\r\n const lambda = line.isTWithPlane(this.surface.plane);\r\n if (!Number.isFinite(lambda)) {\r\n return NaN;\r\n }\r\n const inside = this.containsPoint(line.at(lambda));\r\n return inside ? lambda : NaN;\r\n }\r\n //intersectPlaneFace(face2: PlaneFace,\r\n // thisBrep: BRep,\r\n // face2Brep: BRep,\r\n // faceMap: Map,\r\n // thisEdgePoints: CustomMap,\r\n // otherEdgePoints: CustomMap,\r\n // checkedPairs: CustomSet>) {\r\n //\tassertInst(CustomMap, thisEdgePoints, otherEdgePoints)\r\n //\r\n //\tfunction hasPair(a: Equalable, b: Equalable) {\r\n //\t\treturn checkedPairs.has(new Pair(a, b))\r\n //\t}\r\n //\tfunction addPair(a: Equalable, b: Equalable) {\r\n //\t\treturn checkedPairs.add(new Pair(a, b))\r\n //\t}\r\n //\r\n //\t/**\r\n //\t * @param newEdge generated segment\r\n //\t * @param col1 if newEdge is colinear to an edge of this, the edge in question\r\n //\t * @param col2 same for face2\r\n //\t */\r\n //\tfunction handleNewEdge(newEdge: StraightEdge, col1: Edge, col2: Edge) {\r\n //\t\tif (!col1 && !col2) {\r\n //\t\t\tmapPush(faceMap, face, newEdge)\r\n //\t\t\tmapPush(faceMap, face2, newEdge.flipped())\r\n //\t\t\treturn true\r\n //\t\t}\r\n //\t\tfunction handleEdgeInFace(col1, col2, face, face2, thisBrep, face2Brep, coplanarSameIsInside: boolean,\r\n // has, add) { if (col1 && !col2) { if (hasPair(col1.getCanon(), face2)) return //add(col1.getCanon(), face2)\r\n // const face2Plane = face2.surface.plane // NB: a new edge is inserted even though it may be the same as an old\r\n // one // however it indicates that it intersects the other volume here, i.e. the old edge cannot // be counted as\r\n // 'inside' for purposes of reconstitution thisBrep.edgeFaces.get(col1.getCanon()).forEach(faceInfo => { //const\r\n // dot = snap0(face2Plane.normal1.dot(faceInfo.inside)) //if (dot == 0 ? !coplanarSameIsInside : dot < 0) { const\r\n // pointsInsideFace = fff(faceInfo, face2.surface) const edgeInside = pointsInsideFace == INSIDE ||\r\n // !coplanarSameIsInside && pointsInsideFace == COPLANAR_SAME const pushEdge =\r\n // (faceInfo.edge.aDir.like(newEdge.aDir)) ? newEdge : newEdge.flipped()\r\n // assert(faceInfo.edge.aDir.like(pushEdge.aDir)) edgeInside && mapPush(faceMap, faceInfo.face, pushEdge) }) const\r\n // newEdgeInside = face2Plane.normal1.cross(newEdge.aDir) const sVEF1 = splitsVolumeEnclosingFaces(thisBrep,\r\n // col1.getCanon(), newEdgeInside, face2Plane.normal1) let addNewEdge, addNewEdgeFlipped if (addNewEdge = sVEF1 ==\r\n // INSIDE || coplanarSameIsInside && sVEF1 == COPLANAR_SAME) { mapPush(faceMap, face2, newEdge) } const sVEF2 =\r\n // splitsVolumeEnclosingFaces(thisBrep, col1.getCanon(), newEdgeInside.negated(), face2Plane.normal1) if\r\n // (addNewEdgeFlipped = sVEF2 == INSIDE || coplanarSameIsInside && sVEF2 == COPLANAR_SAME) { mapPush(faceMap,\r\n // face2, newEdge.flipped()) } if (addNewEdge || addNewEdgeFlipped || sVEF1 == COPLANAR_SAME && sVEF2 == INSIDE ||\r\n // sVEF2 == COPLANAR_SAME && sVEF1 == INSIDE) { return true } } } const c1 = handleEdgeInFace(col1, col2, face,\r\n // face2, thisBrep, face2Brep, false, hasPair, addPair) const c2 = handleEdgeInFace(col2, col1, face2, face,\r\n // face2Brep, thisBrep, true, (a, b) => hasPair(b, a), (a, b) => addPair(b, a)) if (c1 || c2) return true if (col1\r\n // && col2) { if (hasPair(col1.getCanon(), col2.getCanon())) return addPair(col1.getCanon(), col2.getCanon())\r\n // function handleColinearEdgeFaces(col1, col2, thisBrep, face2Brep, coplanarSameIsInside: boolean, thisEdgePoints,\r\n // has, add) { // not entirely sure for what i had the dirInsides in? //const aDirNegatedInside =\r\n // (newEdge.a.like(col2.a) || newEdge.a.like(col2.b)) && splitsVolumeEnclosingCone(face2Brep, newEdge.a,\r\n // newEdge.aDir.negated()) == INSIDE //const bDirInside = (newEdge.b.like(col2.a) || newEdge.b.like(col2.b)) &&\r\n // splitsVolumeEnclosingCone(face2Brep, newEdge.b, newEdge.bDir) == INSIDE\r\n // thisBrep.edgeFaces.get(col1.getCanon()).forEach(faceInfo => { const sVEF = splitsVolumeEnclosingFaces(face2Brep,\r\n // col2.getCanon(), faceInfo.inside, faceInfo.normalAtCanonA) const edgeInside = sVEF == INSIDE ||\r\n // coplanarSameIsInside && sVEF == COPLANAR_SAME const pushEdge = (faceInfo.edge.aDir.like(newEdge.aDir)) ? newEdge\r\n // : newEdge.flipped() edgeInside && mapPush(faceMap, faceInfo.face, pushEdge) }) } handleColinearEdgeFaces(col1,\r\n // col2, thisBrep, face2Brep, true, thisEdgePoints, hasPair, addPair) handleColinearEdgeFaces(col2, col1,\r\n // face2Brep, thisBrep, false, otherEdgePoints, (a, b) => hasPair(b, a), (a, b) => addPair(b, a)) } } // what\r\n // needs to be generated: new edges on face // points on edges where they are cut by faces so that sub edges will\r\n // be generated for loops // points on ends of edges where the edge will be an edge in the new volume where it goes\r\n // from A to B // you don't want thos to be marked as 'inside', otherwise invalid faces will be added // if\r\n // a face cuts a corner, nothings needs to be done, as that alone does not limit what adjacent faces will be\r\n // function handleEndPoint(a: IntersectionPointInfo, b: IntersectionPointInfo, newEdge: Edge) { // ends in the\r\n // middle of b's face if (a && !b) { if (!a.colinear && a.edgeT != a.edge.aT && a.edgeT != a.edge.bT) {\r\n // mapPush(thisEdgePoints, a.edge.getCanon(), a) assert(a.edge.isValidT(a.edgeT)) } // else colinear segment ends\r\n // in middle of other face, do nothing } // ends in the middle of a's face if (b && !a) { if (!b.colinear &&\r\n // b.edgeT != b.edge.aT && b.edgeT != b.edge.bT) { mapPush(otherEdgePoints, b.edge.getCanon(), b)\r\n // assert(b.edge.isValidT(b.edgeT)) } // else colinear segment ends in middle of other face, do nothing } if (a &&\r\n // b) { // if a or b is colinear the correct points will already have been added to the edge by handleNewEdge //\r\n // segment starts/ends on edge/edge intersection function foo(a, b, face, face2, thisPlane, face2Plane, thisBrep,\r\n // face2Brep, first, thisEdgePoints) { if (!a.colinear && a.edgeT != a.edge.aT && a.edgeT != a.edge.bT) { if\r\n // (!hasPair(a.edge.getCanon(), b.edge.getCanon())) { addPair(a.edge.getCanon(), b.edge.getCanon()) // ends on a,\r\n // on colinear segment b bT != a.edge.bT && // b can be colinear, so edgeT == aT is possible if (a.p.like(b.edge.a)\r\n // || a.p.like(b.edge.b)) { const corner = a.p.like(b.edge.a) ? b.edge.a : b.edge.b // face2brep corner on edge\r\n // const sVEC1 = splitsVolumeEnclosingCone(face2Brep, corner, a.edge.aDir) const sVEC2 =\r\n // splitsVolumeEnclosingCone(face2Brep, corner, a.edge.aDir.negated()) // if either of these return\r\n // ALONG_EDGE_OR_PLANE, then the breps share a colinear edge if (INSIDE == sVEC1 || INSIDE == sVEC2) {\r\n // mapPush(thisEdgePoints, a.edge.getCanon(), a) assert(a.edge.isValidT(a.edgeT)) } } else { // edge / edge center\r\n // intersection const aEdgeDir = a.edge.tangentAt(a.edgeT) const bEdgeDir = b.edge.tangentAt(b.edgeT) const\r\n // testVector = aEdgeDir.rejectedFrom(bEdgeDir) assert(!testVector.likeO()) const sVEF1 =\r\n // splitsVolumeEnclosingFaces(face2Brep, b.edge.getCanon()Vector, thisPlane.normal1) const sVEF2 =\r\n // splitsVolumeEnclosingFaces(face2Brep, b.edge.getCanon()Vector.negated(), thisPlane.normal1) if (INSIDE ==\r\n // sVEF1 || INSIDE == sVEF2) { mapPush(thisEdgePoints, a.edge.getCanon(), a) assert(a.edge.isValidT(a.edgeT)) } } }\r\n // } } foo(a, b, face, face2, thisPlane, face2Plane, thisBrep, face2Brep, true, thisEdgePoints) foo(b, a, face2,\r\n // face, face2Plane, thisPlane, face2Brep, thisBrep, false, otherEdgePoints) } } assertInst(PlaneFace, face2)\r\n // const face: PlaneFace = this // get intersection const thisPlane = this.surface.plane, face2Plane =\r\n // face2.surface.plane if (thisPlane.isParallelToPlane(face2Plane)) { if (thisPlane.like(face2Plane)) { // normal1\r\n // same and same location in space // addLikeSurfaceFaces(likeSurfaceFaces, this, face2) } return } const isLine =\r\n // L3.fromPlanes(thisPlane, face2Plane) // get intersections of newCurve with other edges of face and face2 const\r\n // ps1 = planeFaceEdgeISPsWithPlane(face, isLine, face2Plane) const ps2 = planeFaceEdgeISPsWithPlane(face2, isLine,\r\n // thisPlane) if (ps1.length == 0 || ps2.length == 0) { // faces to not intersect return } let col1:\r\n // IntersectionPointInfo, col2: IntersectionPointInfo let in1 = false, in2 = false let i = 0, j = 0, last let\r\n // startP, startDir, startT, startA, startB while (i < ps1.length || j < ps2.length) { assert(i <= ps1.length)\r\n // assert(j <= ps2.length) const a = ps1[i], b = ps2[j] assert(a || b) if (j == ps2.length || i < ps1.length &&\r\n // lt(a.t, b.t)) { last = a in1 = !in1 a.used = true in1 && (col1 = a.colinear && a) i++ } else if (i == ps1.length\r\n // || gt(a.t, b.t)) { last = b in2 = !in2 b.used = true in2 && (col2 = b.colinear && b) j++ } else { // TODO: this\r\n // will break if 3 points on the same t last = a in1 = !in1 in2 = !in2 //if (in1 == in2) { a.used = true b.used =\r\n // true in1 && (col1 = a.colinear && a) in2 && (col2 = b.colinear && b) //} i++ j++ } if (startP && !(in1 && in2))\r\n // { // segment end const newEdge = new StraightEdge(isLine, startP, last.p, startT, last.t, undefined, 'genseg' +\r\n // getGlobalId()) startP = undefined last.used = true if (handleNewEdge(newEdge, col1 && col1.edge, col2 &&\r\n // col2.edge)) { handleEndPoint(startA || col1, startB || col2, newEdge) handleEndPoint(a && a.used && a || col1, b\r\n // && b.used && b || col2, newEdge) } } else if (in1 && in2) { // new segment just started startP = last.p startDir\r\n // = last.insideDir startT = last.t startA = a && a.used && a startB = b && b.used && b } if (!in1 && a && last ==\r\n // a && a.colinear) { checkedPairs.add(new Pair(a.edge.getCanon(), face2)) } if (!in2 && b && (last == b || b.used)\r\n // && b.colinear) { checkedPairs.add(new Pair(b.edge.getCanon(), face)) } } }\r\n withHole(holeEdges) {\r\n return new PlaneFace(this.surface, this.contour, [holeEdges]);\r\n }\r\n pointsToInside(p, dir) {\r\n return this.containsPoint2(p.plus(dir.times(NLA_PRECISION * 8)));\r\n }\r\n edgeISPsWithPlane(isLine, plane2) {\r\n const face = this;\r\n assert(face.surface.plane.containsLine(isLine));\r\n assert(plane2.containsLine(isLine));\r\n const plane = face.surface.plane;\r\n const ps = [];\r\n const loops = [face.contour].concat(face.holes);\r\n loops.forEach((loop) => {\r\n const colinearEdges = loop.map((edge) => edge.colinearToLine(isLine) && -sign(edge.aDir.dot(isLine.dir1)));\r\n const isLineOut = isLine.dir1.cross(plane.normal1);\r\n loop.forEach((edge, edgeIndex, edges) => {\r\n const nextEdgeIndex = (edgeIndex + 1) % edges.length, nextEdge = edges[nextEdgeIndex], colinearEdge = colinearEdges[edgeIndex];\r\n //console.log(edge.toSource()) {p:V3(2, -2.102, 0),\r\n if (colinearEdge) {\r\n // edge colinear to intersection line\r\n const curveAT = isLine.pointT(edge.a), curveBT = isLine.pointT(edge.b);\r\n // add interval for colinear segment\r\n ps.push({\r\n p: edge.a,\r\n insideDir: edge.aDir,\r\n t: curveAT,\r\n edge: edge,\r\n edgeT: edge.aT,\r\n colinear: true,\r\n }, {\r\n p: edge.b,\r\n insideDir: edge.bDir.negated(),\r\n t: curveBT,\r\n edge: edge,\r\n edgeT: edge.bT,\r\n colinear: true,\r\n });\r\n // open next interval if necessary\r\n const nextSide = colinearEdges[nextEdgeIndex] ||\r\n dotCurve2(nextEdge.curve, nextEdge.aT, isLineOut, nextEdge.deltaTSign());\r\n if (colinearEdge * nextSide < 0) {\r\n // side changes\r\n ps.push({\r\n p: nextEdge.a,\r\n insideDir: edge.bDir,\r\n t: curveBT,\r\n edge: nextEdge,\r\n edgeT: nextEdge.aT,\r\n colinear: false,\r\n });\r\n }\r\n }\r\n else {\r\n // not necessarily a straight edge, so multiple intersections are possible\r\n const edgeTs = edge.edgeISTsWithPlane(plane2);\r\n assert(edgeTs.every((t) => plane2.containsPoint(edge.curve.at(t))), edgeTs);\r\n for (const edgeT of edgeTs) {\r\n if (edgeT == edge.bT) {\r\n // endpoint lies on intersection line\r\n const side = dotCurve2(edge.curve, edge.bT, isLineOut, -edge.deltaTSign());\r\n const nextSide = colinearEdges[nextEdgeIndex] ||\r\n dotCurve2(nextEdge.curve, nextEdge.aT, isLineOut, nextEdge.deltaTSign());\r\n if (side * nextSide < 0) {\r\n // next segment is not colinear and ends on different side\r\n ps.push({\r\n p: edge.b,\r\n insideDir: plane2.normal1.negated(),\r\n t: isLine.pointT(edge.b),\r\n edge: edge,\r\n edgeT: edge.bT,\r\n colinear: false,\r\n });\r\n }\r\n }\r\n else if (edgeT != edge.aT) {\r\n // edge crosses intersection line, neither starts nor ends on it\r\n const p = edge.curve.at(edgeT);\r\n assert(plane2.containsPoint(p), edge.toString(), p, edgeT, plane2.distanceToPoint(p));\r\n assert(isLine.containsPoint(p), edge.toString(), p, edgeT, isLine.distanceToPoint(p));\r\n const insideDir = plane2.normal1.negated();\r\n ps.push({\r\n p: p,\r\n insideDir: insideDir,\r\n t: isLine.pointT(p),\r\n edge: edge,\r\n edgeT: edgeT,\r\n colinear: false,\r\n });\r\n }\r\n }\r\n }\r\n });\r\n });\r\n // duplicate 't's are ok, as sometimes a segment needs to stop and start again\r\n // should be sorted so that back facing ones are first\r\n ps.sort((a, b) => a.t - b.t || a.insideDir.dot(isLine.dir1));\r\n return ps;\r\n }\r\n}\r\nexport class RotationFace extends Face {\r\n constructor(rot, contour, holes, name, info) {\r\n super(rot, contour, holes, name, info);\r\n }\r\n static loopDoesNotCrossPlane(loop, seamPlane) {\r\n let side = 0;\r\n // returns true if d is on the other side as previous calls\r\n function checkSide(d) {\r\n if (side == 0) {\r\n side = d;\r\n }\r\n else {\r\n return !side || side * d < 0;\r\n }\r\n return false;\r\n }\r\n for (const edge of loop) {\r\n const ts = edge.edgeISTsWithPlane(seamPlane);\r\n if (ts.length == 0) {\r\n if (!(edge.curve instanceof L3) &&\r\n checkSide(seamPlane.distanceToPointSigned(edge.a)))\r\n return false;\r\n }\r\n else {\r\n for (const t of ts) {\r\n // TODO: this part probably should be in a separate function\r\n // check 'backwards' only if if aT != t\r\n if (edge.aT != t) {\r\n if (checkSide(dotCurve2(edge.curve, t, seamPlane.normal1, -edge.deltaTSign())))\r\n return false;\r\n }\r\n if (edge.bT != t) {\r\n if (checkSide(dotCurve2(edge.curve, t, seamPlane.normal1, edge.deltaTSign())))\r\n return false;\r\n }\r\n }\r\n }\r\n }\r\n return true;\r\n }\r\n getAABB() {\r\n if (this.aabb)\r\n return this.aabb;\r\n this.aabb = AABB.forAABBs(this.contour.map((e) => e.getAABB()));\r\n this.aabb.addPoints(this.surface.getExtremePoints().filter((p) => this.containsPoint(p)));\r\n return this.aabb;\r\n }\r\n unrollLoop(edgeLoop) {\r\n const vs = [];\r\n const uvP = this.surface.uvPFunc();\r\n const verticesNo0s = edgeLoop.map((edge) => edge.getVerticesNo0());\r\n const startEdgeIndex = verticesNo0s.findIndex((edgeVertices) => !eq(uvP(edgeVertices[0]).x, Math.PI));\r\n assert(-1 != startEdgeIndex);\r\n // console.log(startEdgeIndex)\r\n for (let i = 0; i < edgeLoop.length; i++) {\r\n const edgeIndex = (i + startEdgeIndex) % edgeLoop.length;\r\n for (let j = 0; j < verticesNo0s[edgeIndex].length; j++) {\r\n const p = verticesNo0s[edgeIndex][j];\r\n const localP = uvP(p);\r\n // console.log(hint, p.sce, localP.sce)\r\n vs.push(localP);\r\n }\r\n }\r\n edgeLoop.forEach((edge) => {\r\n edge.getVerticesNo0().forEach((p) => {\r\n vs.push(uvP(p));\r\n });\r\n });\r\n console.log(\"vs\\n\", vs.join(\"\\n\"), vs.length);\r\n return vs;\r\n }\r\n /**\r\n * f1 cos t + f2 sin t\r\n * tan(phi) = sin / cos\r\n * = (f1x cos t + f2x sin t) / (f1y cos t + f2y sin t)\r\n *\r\n * = (-f1x sin t + f2x cos t) / (-f1y sin t + f2y cos t)\r\n */\r\n unrollEllipsoidLoops(edgeLoops) {\r\n const verticesUV = [], vertices = [], loopStarts = [];\r\n const ellipsoid = this.surface;\r\n const ptpf = ellipsoid.uvPFunc();\r\n const testDegeneratePoint = ellipsoid instanceof EllipsoidSurface\r\n ? (nextStart) => nextStart.like(ellipsoid.center.plus(ellipsoid.f3)) ||\r\n nextStart.like(ellipsoid.center.minus(ellipsoid.f3))\r\n : (nextStart) => nextStart.like(this.surface.center);\r\n for (const edgeLoop of edgeLoops) {\r\n loopStarts.push(verticesUV.length);\r\n // console.log(startEdgeIndex)\r\n for (let i = 0; i < edgeLoop.length; i++) {\r\n const ipp = (i + 1) % edgeLoop.length;\r\n const verticesNo0 = edgeLoop[i].getVerticesNo0();\r\n vertices.push(...verticesNo0);\r\n verticesUV.push(...verticesNo0.map((v) => ptpf(v)));\r\n const nextStart = edgeLoop[ipp].a;\r\n //console.log('BLAH', nextStart.str, ellipsoid.center.plus(ellipsoid.f3).str)\r\n if (testDegeneratePoint(nextStart)) {\r\n const bDirLC = ellipsoid.matrixInverse.transformVector(edgeLoop[i].bDir), aDirLC = ellipsoid.matrixInverse.transformVector(edgeLoop[ipp].aDir);\r\n const inAngle = Math.atan2(-bDirLC.y, -bDirLC.x);\r\n const outAngle = Math.atan2(aDirLC.y, aDirLC.x);\r\n const stLast = verticesUV.pop();\r\n verticesUV.push(new V3(inAngle, stLast.y, 0), new V3(outAngle, stLast.y, 0));\r\n vertices.push(getLast(vertices));\r\n }\r\n verticesUV.forEach(({ u, v }) => {\r\n assert(isFinite(u));\r\n assert(isFinite(v));\r\n });\r\n }\r\n }\r\n let normals;\r\n if (this.surface instanceof EllipsoidSurface) {\r\n normals = vertices.map((v) => ellipsoid.normalP(v));\r\n }\r\n else {\r\n const normalUV = ellipsoid.normalUVFunc();\r\n normals = verticesUV.map(({ u, v }) => normalUV(u, v));\r\n }\r\n assert(vertices.length == vertices.length);\r\n //console.log(verticesUV.map(v => v.str).join('\\n'))\r\n return {\r\n verticesUV: verticesUV,\r\n vertices: vertices,\r\n normals: normals,\r\n loopStarts: loopStarts,\r\n };\r\n }\r\n unrollCylinderLoops(loops) {\r\n const vertexLoops = loops.map((loop) => loop.flatMap((edge) => edge.getVerticesNo0()));\r\n const surface = this.surface;\r\n const vertices = concatenated(vertexLoops);\r\n // this.unrollLoop(loop).map(v => new V3(v.x / uStep, v.y / vStep, 0)))\r\n const loopStarts = vertexLoops.reduce((arr, loop) => (arr.push(getLast(arr) + loop.length), arr), [0]);\r\n const uvPFunc = surface.uvPFunc();\r\n const verticesUV = vertices.map((v) => uvPFunc(v));\r\n const uvN = surface.normalUVFunc();\r\n const normals = verticesUV.map(({ u, v }) => uvN(u, v));\r\n return {\r\n verticesUV: verticesUV,\r\n vertices: vertices,\r\n normals: normals,\r\n loopStarts: loopStarts,\r\n };\r\n }\r\n /**\r\n * at(s, t) = new V3(s cos t, s sin t, t + )\r\n *\r\n * x = 0\r\n *\r\n * s cos t = 0\r\n * ==> s = 0 || cos t = 0\r\n * ==> L3.Z || V3(0, +-s, k * 2 pi)\r\n *\r\n * x = c\r\n * s cos t = c\r\n * ==> V3(c, c sin t / cos t = c tan t, t)\r\n * ==> V3(c, c t, arctan t)\r\n *\r\n *\r\n * x . n = w\r\n * s cos t nx + s sin t ny + t nz = w\r\n * s = (w - t nz) / (cos t nx + sub t ny)\r\n * ==> V3(\r\n * cos t (w - t nz) / (cos t nx + sin t ny)\r\n * sin t (w - t nz) / (cos t nx + sin t ny)\r\n * t)\r\n *\r\n * ==> V3(\r\n * (w - z arctan t) / (x + t y)\r\n * (w - z arctan t) / (y + x / t)\r\n * arctan t)\r\n *\r\n *\r\n *\r\n */\r\n addToMesh(mesh, uStep = this.surface.uStep, vStep = this.surface.vStep) {\r\n assertf(() => uStep > 0 && vStep > 0, uStep, vStep, \"Surface: \" + this.surface);\r\n const triangles = [];\r\n const pMN = (m, n) => this.surface.pUVFunc()(m * uStep, n * vStep);\r\n const normalMN = (m, n) => this.surface.normalUVFunc()(m * uStep, n * vStep);\r\n const loops = this.getLoops();\r\n const { vertices, verticesUV, normals, loopStarts } = this.surface instanceof EllipsoidSurface ||\r\n this.surface instanceof ConicSurface\r\n ? this.unrollEllipsoidLoops(loops)\r\n : this.unrollCylinderLoops(loops);\r\n loopStarts.push(vertices.length);\r\n const verticesMN = verticesUV.map(({ u, v }) => new V3(u / uStep, v / vStep, 0));\r\n for (let vertexLoopIndex = 0; vertexLoopIndex < loops.length; vertexLoopIndex++) {\r\n const vertexLoopStart = loopStarts[vertexLoopIndex];\r\n const vertexLoopLength = loopStarts[vertexLoopIndex + 1] - vertexLoopStart;\r\n const base = mesh.vertices.length + loopStarts[vertexLoopIndex];\r\n for (let i = 0; i < vertexLoopLength; i++) {\r\n mesh.LINES.push(base + i, base + ((i + 1) % vertexLoopLength));\r\n }\r\n }\r\n disableConsole();\r\n let minM = Infinity, maxM = -Infinity, minN = Infinity, maxN = -Infinity;\r\n //console.log('surface', this.surface.str)\r\n //console.log(verticesMN)\r\n //drPs.push(...verticesMN.map((v, i) => ({p: vertices[i], text: `${i} uv: ${v.toString(x => round10(x,\r\n // -4))}`})))\r\n verticesMN.forEach(([m, n]) => {\r\n assert(isFinite(m));\r\n assert(isFinite(n));\r\n minM = min(minM, m);\r\n maxM = max(maxM, m);\r\n minN = min(minN, n);\r\n maxN = max(maxN, n);\r\n });\r\n if (ParametricSurface.is(this.surface)) {\r\n //assert(this.surface.boundsSigned(minM * uStep, minN * vStep) > -NLA_PRECISION)\r\n //assert(this.surface.boundsSigned(maxM * uStep, maxN * vStep) > -NLA_PRECISION)\r\n }\r\n const mOffset = floor(minM + NLA_PRECISION), nOffset = floor(minN + NLA_PRECISION);\r\n const mRes = ceil(maxM - NLA_PRECISION) - mOffset, nRes = ceil(maxN - NLA_PRECISION) - nOffset;\r\n console.log(uStep, vStep, mRes, nRes);\r\n if (mRes == 1 && nRes == 1) {\r\n // triangulate this face as if it were a plane\r\n const polyTriangles = triangulateVertices(V3.Z, verticesMN, loopStarts.slice(1, 1 + this.holes.length));\r\n triangles.push(...polyTriangles);\r\n }\r\n else {\r\n const partss = new Array(mRes * nRes);\r\n function fixUpPart(part, baseM, baseN) {\r\n assert(baseM < mRes && baseN < nRes, `${baseM}, ${baseN}, ${mRes}, ${nRes}`);\r\n console.log(\"complete part\", part, baseM, baseN);\r\n //console.trace()\r\n assert(part.length);\r\n const cellM = baseM + mOffset, cellN = baseN + nOffset;\r\n for (const index of part) {\r\n assert(le(cellM, verticesMN[index].x) &&\r\n le(verticesMN[index].x, cellM + 1), `${index} ${verticesMN[index].str} ${cellM} ${cellM}`);\r\n assert(le(cellN, verticesMN[index].y) &&\r\n le(verticesMN[index].y, cellN + 1));\r\n }\r\n const pos = baseN * mRes + baseM;\r\n (partss[pos] || (partss[pos] = [])).push(part);\r\n //const outline = partss[pos] || (partss[pos] = [minM + baseM * uStep, minN + baseN * vStep, minM +\r\n // (baseM + 1) * uStep, minN + (baseN + 1) * vStep])\r\n }\r\n // 'some' instead of forEach so we can return out of the entire function if this.edges crosses no borders\r\n // and\r\n for (let vertexLoopIndex = 0; vertexLoopIndex < loops.length; vertexLoopIndex++) {\r\n let part = undefined;\r\n let firstPart = undefined;\r\n let firstPartBaseM = -1;\r\n let firstPartBaseN = -1;\r\n let lastBaseM = -1, lastBaseN = -1;\r\n let partCount = 0;\r\n const vertexLoopStart = loopStarts[vertexLoopIndex];\r\n const vertexLoopLength = loopStarts[vertexLoopIndex + 1] - vertexLoopStart;\r\n for (let vlvi = 0; vlvi < vertexLoopLength; vlvi++) {\r\n const vx0index = vertexLoopStart + vlvi, vx0 = verticesMN[vx0index];\r\n const vx1index = vertexLoopStart + ((vlvi + 1) % vertexLoopLength), vx1 = verticesMN[vx1index];\r\n //console.log('dask', vx0index, vx1index)\r\n const vx01 = vx0.to(vx1);\r\n assert(vx0);\r\n const di = vx01.x, dj = vx01.y;\r\n let vxIndex = vx0index, vx = vx0, currentT = 0;\r\n let whileLimit = 400;\r\n while (--whileLimit) {\r\n // points which are on a grid line are assigned to the cell into which they are going (+\r\n // NLA_PRECISION * sign(di)) if they are parallel to the gridline (eq0(di)), they belong the\r\n // the cell for which they are a CCW boundary\r\n const baseM = floor(vx.u + (!eq0(di) ? sign(di) : -sign(dj)) * NLA_PRECISION) -\r\n mOffset;\r\n const baseN = floor(vx.v + (!eq0(dj) ? sign(dj) : sign(di)) * NLA_PRECISION) -\r\n nOffset;\r\n assert(baseM < mRes && baseN < nRes, `${baseM}, ${baseN}, ${mRes}, ${nRes}`);\r\n // figure out the next intersection with a gridline:\r\n // iNext is the positive horizontal distance to the next vertical gridline\r\n const iNext = ceil(sign(di) * vx.u + NLA_PRECISION) - sign(di) * vx.u;\r\n const jNext = ceil(sign(dj) * vx.v + NLA_PRECISION) - sign(dj) * vx.v;\r\n const iNextT = currentT + iNext / abs(di);\r\n const jNextT = currentT + jNext / abs(dj);\r\n //console.log(vxIndex, vx.str, 'vij', vx.u, vx.v, 'd', di, dj, 'ijNext', iNext, jNext, 'nextT',\r\n // iNextT, jNextT)\r\n if (lastBaseM != baseM || lastBaseN != baseN) {\r\n if (part) {\r\n if (!firstPart) {\r\n firstPart = part;\r\n firstPartBaseM = lastBaseM;\r\n firstPartBaseN = lastBaseN;\r\n }\r\n else {\r\n partCount++;\r\n fixUpPart(part, lastBaseM, lastBaseN);\r\n }\r\n }\r\n part = [vxIndex];\r\n }\r\n lastBaseM = baseM;\r\n lastBaseN = baseN;\r\n currentT = min(iNextT, jNextT);\r\n if (ge(currentT, 1)) {\r\n //console.log('breaking ', vx1index)\r\n part.push(vx1index);\r\n break;\r\n }\r\n else {\r\n const nextPoint = vx0.lerp(vx1, currentT);\r\n const nextPointIndex = addVertex(nextPoint.x, nextPoint.y);\r\n //console.log('pushing ', nextPointIndex)\r\n part.push(nextPointIndex);\r\n vx = nextPoint;\r\n vxIndex = nextPointIndex;\r\n }\r\n }\r\n assert(whileLimit, \"whileLimit\");\r\n }\r\n if (0 == partCount) {\r\n // complete loop\r\n assert(false, \"found a hole, try increasing resolution\");\r\n }\r\n // at this point, the firstPart hasn't been added, and the last part also hasn't been added\r\n // either they belong to the same cell, or not\r\n if (firstPartBaseM == lastBaseM && firstPartBaseN == lastBaseN) {\r\n part.pop();\r\n fixUpPart(part.concat(firstPart), lastBaseM, lastBaseN);\r\n }\r\n else {\r\n fixUpPart(firstPart, firstPartBaseM, firstPartBaseN);\r\n fixUpPart(part, lastBaseM, lastBaseN);\r\n }\r\n console.log(\"firstPart\", firstPart);\r\n }\r\n console.log(\"calculated parts\", partss);\r\n const fieldVertexIndices = new Array((mRes + 1) * (nRes + 1));\r\n function addVertex(m, n) {\r\n verticesMN.push(new V3(m, n, 0));\r\n normals.push(normalMN(m, n));\r\n return vertices.push(pMN(m, n)) - 1;\r\n }\r\n function getGridVertexIndex(i, j) {\r\n const index = j * (mRes + 1) + i;\r\n return (fieldVertexIndices[index] ||\r\n (fieldVertexIndices[index] = addVertex(i + mOffset, j + nOffset)));\r\n }\r\n for (let col = 0; col < mRes; col++) {\r\n let inside = false;\r\n for (let row = 0; row < nRes; row++) {\r\n const pos = row * mRes + col;\r\n const fieldU = mOffset + col, fieldV = nOffset + row;\r\n const parts = partss[pos];\r\n if (!parts) {\r\n if (inside) {\r\n pushQuad(triangles, false, getGridVertexIndex(col, row), getGridVertexIndex(col + 1, row), getGridVertexIndex(col, row + 1), getGridVertexIndex(col + 1, row + 1));\r\n }\r\n }\r\n else {\r\n // assemble the field with segments in in\r\n function opos(index) {\r\n const p = verticesMN[index], u1 = p.x - fieldU, v1 = p.y - fieldV;\r\n assert(-NLA_PRECISION < u1 &&\r\n u1 < 1 + NLA_PRECISION &&\r\n -NLA_PRECISION < v1 &&\r\n v1 < 1 + NLA_PRECISION, \"oob u1 v1 \" +\r\n u1 +\r\n \" \" +\r\n v1 +\r\n \" \" +\r\n index +\r\n \" \" +\r\n p.str +\r\n \"IF THIS FAILS check canonSeamU is correct\");\r\n return v1 < u1 ? u1 + v1 : 4 - u1 - v1;\r\n }\r\n while (parts.length) {\r\n const outline = [];\r\n const startPart = parts[0];\r\n assert(startPart.length > 0);\r\n let currentPart = startPart;\r\n do {\r\n outline.push(...currentPart);\r\n const currentPartEndOpos = opos(getLast(currentPart));\r\n const nextPartIndex = indexWithMax(parts, (part) => -mod(opos(part[0]) - currentPartEndOpos, 4));\r\n const nextPart = bagRemoveIndex(parts, nextPartIndex);\r\n let currentOpos = currentPartEndOpos;\r\n const nextPartStartOpos = opos(nextPart[0]) > currentOpos\r\n ? opos(nextPart[0])\r\n : opos(nextPart[0]) + 4;\r\n let nextOpos = ceil(currentOpos + NLA_PRECISION);\r\n let flipping = eq0(((currentOpos + NLA_PRECISION) % 1) - NLA_PRECISION);\r\n //inside = inside != (!eq0(currentOpos % 1) && currentOpos % 2 < 1)\r\n while (lt(nextOpos, nextPartStartOpos)) {\r\n switch (nextOpos % 4) {\r\n case 0:\r\n outline.push(getGridVertexIndex(col, row));\r\n break;\r\n case 1:\r\n inside = inside != flipping;\r\n outline.push(getGridVertexIndex(col + 1, row));\r\n break;\r\n case 2:\r\n outline.push(getGridVertexIndex(col + 1, row + 1));\r\n break;\r\n case 3:\r\n inside = inside != flipping;\r\n outline.push(getGridVertexIndex(col, row + 1));\r\n break;\r\n }\r\n flipping = true;\r\n nextOpos++;\r\n }\r\n // if the next loop would have completed a top or bottom segment\r\n inside =\r\n inside !=\r\n (flipping &&\r\n nextOpos % 2 == 1 &&\r\n eq(nextOpos, nextPartStartOpos));\r\n currentOpos = nextOpos;\r\n currentPart = nextPart;\r\n } while (currentPart != startPart);\r\n // triangulate outline\r\n if (outline.length == 3) {\r\n // its just a triangle\r\n triangles.push(...outline);\r\n }\r\n else {\r\n const polyTriangles = triangulateVertices(V3.Z, outline.map((i) => verticesMN[i]), []).map((i) => outline[i]);\r\n triangles.push(...polyTriangles);\r\n }\r\n //console.log('outline', col, row, outline)\r\n }\r\n }\r\n }\r\n }\r\n }\r\n //console.log('trinagle', triangles.max(), vertices.length, triangles.length, triangles.toSource(),\r\n // triangles.map(col => vertices[col].$).toSource() ) assert(normals.every(n => n.hasLength(1)), normals.find(n\r\n // => !n.hasLength(1)).length() +' '+normals.findIndex(n => !n.hasLength(1)))\r\n Array.prototype.push.apply(mesh.TRIANGLES, triangles.map((index) => index + mesh.vertices.length));\r\n Array.prototype.push.apply(mesh.vertices, vertices);\r\n Array.prototype.push.apply(mesh.normals, normals);\r\n //this.addEdgeLines(mesh)\r\n enableConsole();\r\n }\r\n addToMesh2(mesh) {\r\n const closed = false;\r\n const zSplit = 8;\r\n const ribs = [];\r\n let minZ = Infinity, maxZ = -Infinity;\r\n //let cmp = (a, b) => a.value - b.value\r\n const f = this.surface.pUVFunc();\r\n const normalF = this.surface.normalUVFunc();\r\n const vertexLoops = this.holes\r\n .concat([this.contour])\r\n .map((loop) => this.unrollLoop(loop));\r\n vertexLoops.forEach((vertexLoop) => {\r\n vertexLoop.forEach(({ x: d, y: z }) => {\r\n const index0 = binaryIndexOf(ribs, d, (a, b) => snap(a.value - b, 0));\r\n if (index0 < 0) {\r\n ribs.splice(-index0 - 1, 0, { value: d, left: [], right: [] });\r\n }\r\n minZ = min(minZ, z);\r\n maxZ = max(maxZ, z);\r\n });\r\n });\r\n console.log(\"zzzs\", minZ, maxZ, vertexLoops[0].toSource().replace(/\\), /g, \",\\n\"));\r\n const correction = 1;\r\n vertexLoops.forEach((vertexLoop) => {\r\n vertexLoop.forEach((v0, i, vs) => {\r\n let v1 = vs[(i + 1) % vs.length], dDiff = v1.x - v0.x;\r\n //console.log(v0.sce, v1.sce)\r\n if (eq0(dDiff)) {\r\n return;\r\n }\r\n if (dDiff < 0) {\r\n ;\r\n [v0, v1] = [v1, v0];\r\n dDiff = -dDiff;\r\n }\r\n const index0 = binaryIndexOf(ribs, v0.x, (a, b) => snap(a.value - b, 0));\r\n const index1 = binaryIndexOf(ribs, v1.x, (a, b) => snap(a.value - b, 0));\r\n binaryInsert(ribs[index0].right, v0.y);\r\n for (let j = (index0 + correction) % ribs.length; j != index1; j = (j + correction) % ribs.length) {\r\n const x = ribs[j].value;\r\n const part = (x - v0.x) / dDiff;\r\n const interpolated = v1.y * part + v0.y * (1 - part);\r\n binaryInsert(ribs[j].left, interpolated);\r\n binaryInsert(ribs[j].right, interpolated);\r\n }\r\n binaryInsert(ribs[index1].left, v1.y);\r\n // console.log(ribs.map(r=>r.toSource()).join('\\n'))\r\n });\r\n });\r\n const vertices = [], triangles0 = [], normals = [];\r\n for (let i = 0; i < ribs.length; i++) {\r\n const ribLeft = ribs[i], ribRight = ribs[(i + 1) % ribs.length];\r\n assert(ribLeft.right.length == ribRight.left.length);\r\n for (let j = 0; j < ribLeft.right.length; j++) {\r\n vertices.push(f(ribLeft.value, ribLeft.right[j]), f(ribRight.value, ribRight.left[j]));\r\n normals.push(normalF(ribLeft.value, ribLeft.right[j]), normalF(ribRight.value, ribRight.left[j]));\r\n }\r\n }\r\n //console.log(ribs.map(r=>r.toSource()).join('\\n'))\r\n const vss = vertices.length, detailVerticesStart = vss;\r\n const zInterval = maxZ - minZ, zStep = zInterval / zSplit;\r\n const detailZs = arrayFromFunction(zSplit - 1, (i) => minZ + (1 + i) * zStep);\r\n console.log(\"detailsZs\", detailZs);\r\n for (let i = 0; i < ribs.length; i++) {\r\n const d = ribs[i].value;\r\n for (let j = 0; j < detailZs.length; j++) {\r\n vertices.push(f(d, detailZs[j]));\r\n normals.push(normalF(d, detailZs[j]));\r\n }\r\n }\r\n // console.log('detailVerticesStart', detailVerticesStart, 'vl', vertices.length, vertices.length -\r\n // detailVerticesStart, ribs.length) finally, fill in the ribs\r\n let vsStart = 0;\r\n const flipped2 = true;\r\n //for (var i = 0; i < 1; i++) {\r\n const end = closed ? ribs.length : ribs.length - 1;\r\n for (let i = 0; i < end; i++) {\r\n const ipp = (i + 1) % ribs.length;\r\n let inside = false, colPos = 0;\r\n const ribLeft = ribs[i], ribRight = ribs[(i + 1) % ribs.length];\r\n for (let j = 0; j < detailZs.length + 1; j++) {\r\n const detailZ = detailZs[j] || 100000;\r\n if (!inside) {\r\n if (ribLeft.right[colPos] < detailZ &&\r\n ribRight.left[colPos] < detailZ) {\r\n if (ribLeft.right[colPos + 1] < detailZ ||\r\n ribRight.left[colPos + 1] < detailZ) {\r\n pushQuad(triangles0, flipped2, vsStart + colPos * 2, vsStart + (colPos + 1) * 2, vsStart + colPos * 2 + 1, vsStart + (colPos + 1) * 2 + 1);\r\n colPos += 2;\r\n if (ribLeft.right[colPos] < detailZ ||\r\n ribRight.left[colPos] < detailZ) {\r\n j--;\r\n }\r\n }\r\n else {\r\n pushQuad(triangles0, flipped2, vsStart + colPos * 2, vsStart + colPos * 2 + 1, detailVerticesStart + i * detailZs.length + j, detailVerticesStart + ipp * detailZs.length + j);\r\n inside = true;\r\n colPos++;\r\n }\r\n }\r\n }\r\n else {\r\n if (ribLeft.right[colPos] < detailZ ||\r\n ribRight.left[colPos] < detailZ) {\r\n pushQuad(triangles0, flipped2, detailVerticesStart + i * detailZs.length + j - 1, detailVerticesStart + ipp * detailZs.length + j - 1, vsStart + colPos * 2, vsStart + colPos * 2 + 1);\r\n inside = false;\r\n colPos++;\r\n if (ribLeft.right[colPos] < detailZ ||\r\n ribRight.left[colPos] < detailZ) {\r\n j--;\r\n }\r\n }\r\n else {\r\n pushQuad(triangles0, flipped2, detailVerticesStart + i * detailZs.length + j, detailVerticesStart + i * detailZs.length + j - 1, detailVerticesStart + ipp * detailZs.length + j, detailVerticesStart + ipp * detailZs.length + j - 1);\r\n }\r\n }\r\n }\r\n vsStart += ribLeft.right.length * 2;\r\n }\r\n //console.log('trinagle', triangles0.max(), vertices.length, triangles0.length, triangles0.toSource(),\r\n // triangles0.map(i => vertices[i].$).toSource() )\r\n const triangles = triangles0.map((index) => index + mesh.vertices.length);\r\n //assert(normals.every(n => n.hasLength(1)), normals.find(n => !n.hasLength(1)).length() +'\r\n // '+normals.findIndex(n => !n.hasLength(1)))\r\n Array.prototype.push.apply(mesh.vertices, vertices);\r\n Array.prototype.push.apply(mesh.TRIANGLES, triangles);\r\n Array.prototype.push.apply(mesh.normals, normals);\r\n //this.addEdgeLines(mesh)\r\n }\r\n}\r\n//# sourceMappingURL=Face.js.map","import earcut from \"earcut\";\r\nimport { JavaMap, JavaSet, JavaSet as CustomSet } from \"javasetmap.ts\";\r\nimport nerdamer from \"nerdamer\";\r\nimport { AABB, assert, assertf, assertInst, assertNever, assertNumbers, assertVectors, concatenated, eq, eq0, getLast, gt, indexWithMax, lt, mapFilter, mapPush, newtonIterate2d, newtonIterateWithDerivative, NLA_DEBUG, NLA_PRECISION, SCE, snap, snap0, sum, TAU, Transformable, V, V3, withMax, } from \"ts3dutils\";\r\nimport { Mesh } from \"tsgl\";\r\nimport { curvePointMF, Face, L3, P3, PlaneFace, PointVsFace, uvInAABB2, createEdge, } from \".\";\r\nimport { abs, sign, sqrt } from \"./math\";\r\nexport const EPS = 1e-5;\r\nlet globalId = 0;\r\nexport function getGlobalId() {\r\n return globalId++;\r\n}\r\nexport function addLikeSurfaceFaces(likeSurfaceFaces, face1, face2) {\r\n // There cannot be two subgroups which will later be connected, as the \"graph\" of like surface faces is fully\r\n // connected\r\n for (let i = 0; i < likeSurfaceFaces.length; i++) {\r\n const faceGroup = likeSurfaceFaces[i];\r\n let foundFace1 = false, foundFace2 = false;\r\n for (let j = 0; j < faceGroup.length; j++) {\r\n const face = faceGroup[j];\r\n if (face == face1) {\r\n foundFace1 = true;\r\n }\r\n if (face == face2) {\r\n foundFace2 = true;\r\n }\r\n }\r\n if (foundFace1 != foundFace2) {\r\n faceGroup.push(foundFace1 ? face2 : face1);\r\n return;\r\n }\r\n else if (foundFace1) {\r\n // found both\r\n return;\r\n }\r\n }\r\n // nothing found, add a new group\r\n likeSurfaceFaces.push([face1, face2]);\r\n}\r\nexport function assembleFaceFromLooseEdges(edges, surface, originalFace) {\r\n const visited = new Set();\r\n function nextStart() {\r\n return edges.find((edge) => !visited.has(edge));\r\n }\r\n const loops = [];\r\n let startEdge, currentEdge = undefined;\r\n while ((startEdge = nextStart())) {\r\n currentEdge = startEdge;\r\n const loop = [];\r\n let total = 0;\r\n do {\r\n visited.add(currentEdge);\r\n loop.push(currentEdge);\r\n const possibleEdges = edges.filter((edge) => currentEdge.b.like(edge.a));\r\n const normalAtCurrentB = surface.normalP(currentEdge.b);\r\n const nextEdgeIndex = indexWithMax(possibleEdges, (edge) => currentEdge.bDir.angleRelativeNormal(edge.aDir, normalAtCurrentB));\r\n currentEdge = possibleEdges[nextEdgeIndex];\r\n } while (startEdge != currentEdge && total++ < 200);\r\n assert(total != 201);\r\n loops.push(loop);\r\n }\r\n const assembledFaces = BRep.assembleFacesFromLoops(loops, surface, originalFace);\r\n assertf(() => 1 == assembledFaces.length);\r\n return assembledFaces[0];\r\n}\r\n/**\r\n * ## Markdown header\r\n * ![foo](screenshots/Capture.PNG)\r\n * {@link ../screenshots/Capture.PNG}\r\n * find the next edge with the MAXIMUM angle\r\n */\r\nexport function calcNextEdgeIndex(currentEdge, possibleEdges, faceNormalAtCurrentB) {\r\n let maxValue = -20, advanced = false, result = Number.MAX_SAFE_INTEGER;\r\n const normVector = currentEdge.bDir.cross(faceNormalAtCurrentB);\r\n const eps = 1e-4;\r\n const dir = sign(currentEdge.deltaT());\r\n const ecd = currentEdge.curve.diff(currentEdge.bT, -dir * eps).dot(normVector);\r\n for (let i = possibleEdges.length; i--;) {\r\n const edge = possibleEdges[i];\r\n const angle1 = currentEdge.bDir\r\n .negated()\r\n .angleRelativeNormal(edge.aDir, faceNormalAtCurrentB);\r\n const angle = ((angle1 + TAU + NLA_PRECISION) % TAU) - NLA_PRECISION;\r\n if (eq0(angle)) {\r\n // do advanced analysis\r\n if (currentEdge.curve.isColinearTo(edge.curve)) {\r\n continue;\r\n }\r\n const edgeDir = sign(edge.deltaT());\r\n const iscd = edge.curve.diff(edge.aT, edgeDir * eps).dot(normVector);\r\n const diff = iscd - ecd;\r\n // if diff > 0, the angle is actually ~= 0\r\n if (diff < 0 && (!advanced || diff > maxValue)) {\r\n advanced = true;\r\n maxValue = diff;\r\n result = i;\r\n }\r\n }\r\n else if (!advanced) {\r\n if (gt(angle, maxValue)) {\r\n maxValue = angle;\r\n result = i;\r\n }\r\n }\r\n }\r\n return result == Number.MAX_SAFE_INTEGER ? 0 : result;\r\n}\r\nexport class BRep extends Transformable {\r\n constructor(faces, infiniteVolume, generator, vertexNames) {\r\n super();\r\n this.faces = faces;\r\n assertInst(Face, ...faces);\r\n this.infiniteVolume = infiniteVolume;\r\n assert(!this.infiniteVolume || true === this.infiniteVolume);\r\n this.generator = generator;\r\n this.vertexNames = vertexNames;\r\n this.edgeFaces = undefined;\r\n //this.assertSanity()\r\n }\r\n static loop1ContainsLoop2(loop1, ccw1, loop2, ccw2, surface) {\r\n for (const edge of loop2) {\r\n const loop1ContainsPoint = surface.loopContainsPoint(loop1, edge.a);\r\n if (PointVsFace.ON_EDGE != loop1ContainsPoint)\r\n return PointVsFace.INSIDE == loop1ContainsPoint;\r\n }\r\n for (const edge of loop2) {\r\n const edgePoint = edge.curve.at(edge.aT * 0.2 + edge.bT * 0.8);\r\n const loop1ContainsPoint = surface.loopContainsPoint(loop1, edgePoint);\r\n if (PointVsFace.ON_EDGE != loop1ContainsPoint)\r\n return PointVsFace.INSIDE == loop1ContainsPoint;\r\n }\r\n if (ccw1 != ccw2) {\r\n return ccw2;\r\n }\r\n throw new Error(loop1.sce + loop2.sce);\r\n }\r\n static assembleFacesFromLoops(loops, surface, originalFace, infoFactory) {\r\n function placeRecursively(newLoopInfo, loopInfos) {\r\n if (loopInfos.length == 0) {\r\n loopInfos.push(newLoopInfo);\r\n }\r\n else {\r\n const subLoopInfo = loopInfos.find((loopInfo) => BRep.loop1ContainsLoop2(loopInfo.loop, loopInfo.ccw, newLoopInfo.loop, newLoopInfo.ccw, surface));\r\n if (subLoopInfo) {\r\n placeRecursively(newLoopInfo, subLoopInfo.subloops);\r\n }\r\n else {\r\n // newLoopInfo isnt contained by any other subLoopInfo\r\n for (let i = loopInfos.length; --i >= 0;) {\r\n const subLoopInfo = loopInfos[i];\r\n //console.log(\"cheving subLoopInfo\", surface.loopContainsPoint(newLoopInfo.edges,\r\n // subLoopInfo.edges[0].a))\r\n if (BRep.loop1ContainsLoop2(newLoopInfo.loop, newLoopInfo.ccw, subLoopInfo.loop, subLoopInfo.ccw, surface)) {\r\n newLoopInfo.subloops.push(subLoopInfo);\r\n loopInfos.splice(i, 1); // remove it\r\n }\r\n }\r\n loopInfos.push(newLoopInfo);\r\n }\r\n }\r\n }\r\n function newFacesRecursive(loopInfo) {\r\n // CW loops can be top level, if they are holes in the original face not contained in the new face\r\n if (loopInfo.ccw) {\r\n if (loopInfo.subloops.every((sl) => !sl.ccw)) {\r\n const holes = loopInfo.subloops.map((sl) => sl.loop);\r\n const info = infoFactory &&\r\n infoFactory.newSubFace(originalFace, surface, loopInfo.loop, holes);\r\n const newFace = new originalFace.constructor(surface, loopInfo.loop, holes, \"genface\" + getGlobalId(), info);\r\n newFaces.push(newFace);\r\n loopInfo.subloops.forEach((sl) => sl.subloops.forEach((slsl) => slsl.ccw && newFacesRecursive(slsl)));\r\n }\r\n else {\r\n loopInfo.subloops.forEach((sl) => sl.ccw && newFacesRecursive(sl));\r\n }\r\n }\r\n }\r\n const newFaces = [];\r\n const topLevelLoops = [];\r\n loops.forEach((loop) => placeRecursively({\r\n loop: loop,\r\n ccw: surface.edgeLoopCCW(loop),\r\n subloops: [],\r\n }, topLevelLoops));\r\n topLevelLoops.forEach((tll) => newFacesRecursive(tll));\r\n return newFaces;\r\n }\r\n /**\r\n * Create a [BRep] by concatenating the faces of other BReps. Only use this if certain that the faces of the BReps do not intersect.\r\n * Otherwise, use [BRep.plus].\r\n * @param bReps\r\n * @param generator\r\n */\r\n static join(bReps, generator) {\r\n return new BRep(bReps.flatMap((b2) => b2.faces), false, generator);\r\n }\r\n containsPoint(p, forceInsideOutside = false) {\r\n const dirs = [\r\n V(-0.3920414696448526, -0.12936136783391444, -0.9108068525164064),\r\n V(0.6520650903544943, -0.07151288645511984, -0.7547827667692488),\r\n V(0.9433494201061395, -0.2402757256238473, -0.22882186797013926),\r\n V(0.13678704228501923, -0.04480387361087783, 0.9895867410047372),\r\n V(0.0662057922721913, -0.5865836917435423, 0.8071780259955845),\r\n V(-0.7322576567870621, -0.12953393611526787, 0.6685953061989045),\r\n V(0.6579719127258273, -0.012300218400456116, 0.7529420075219719),\r\n V(-0.5576497966736425, 0.8006695748324647, 0.2189861552871446),\r\n ];\r\n dirLoop: for (const dir of dirs) {\r\n const testLine = new L3(p, dir);\r\n let inside = this.infiniteVolume, minT = Infinity;\r\n for (const face of this.faces) {\r\n assert(!face.surface.containsCurve(testLine));\r\n const ists = face.surface.isTsForLine(testLine);\r\n for (const t of ists) {\r\n const p = testLine.at(t);\r\n const pvf = face.containsPoint2(p);\r\n //assert(pvf != PointVsFace.ON_EDGE)\r\n !forceInsideOutside && assert(!eq0(t));\r\n if (t > 0) {\r\n if (pvf == PointVsFace.ON_EDGE) {\r\n continue dirLoop;\r\n }\r\n if (pvf == PointVsFace.INSIDE) {\r\n inside = !inside;\r\n if (t < minT) {\r\n minT = t;\r\n }\r\n }\r\n }\r\n }\r\n }\r\n return inside;\r\n }\r\n return false;\r\n }\r\n withMergedFaces() {\r\n const likeSurfaceFaces = [];\r\n for (let i = 0; i < this.faces.length; i++) {\r\n let addedToGroup = false;\r\n for (let j = 0; j < i; j++) {\r\n if (this.faces[i].surface.isCoplanarTo(this.faces[j].surface)) {\r\n const faceGroup = likeSurfaceFaces.find((faceGroup) => faceGroup.includes(this.faces[j]));\r\n if (faceGroup) {\r\n faceGroup.push(this.faces[i]);\r\n addedToGroup = true;\r\n }\r\n }\r\n }\r\n !addedToGroup && likeSurfaceFaces.push([this.faces[i]]);\r\n }\r\n console.log(\"likeSurfaceFaces\", likeSurfaceFaces);\r\n if (likeSurfaceFaces.every((group) => group.length == 1))\r\n return this;\r\n const newFaces = [];\r\n let total = 0;\r\n for (const faceGroup of likeSurfaceFaces) {\r\n console.log(faceGroup);\r\n if (faceGroup.length == 1) {\r\n newFaces.push(faceGroup[0]);\r\n }\r\n else {\r\n const allEdges = faceGroup.flatMap((face) => face.getAllEdges());\r\n for (let i = allEdges.length; i-- > 0;) {\r\n for (let j = 0; j < i; j++) {\r\n console.log(\"blugh\", total);\r\n assert(i >= 0 && j >= 0 && total++ < 500, i + \" \" + j + \" \" + total);\r\n if (allEdges[i].isCoEdge(allEdges[j])) {\r\n // remove both\r\n allEdges.splice(i, 1);\r\n allEdges.splice(j, 1);\r\n i--;\r\n break;\r\n }\r\n }\r\n }\r\n const newFace = assembleFaceFromLooseEdges(allEdges, faceGroup[0].surface, faceGroup[0]);\r\n newFaces.push(newFace);\r\n }\r\n }\r\n return new BRep(newFaces, this.infiniteVolume, this.generator && this.generator + \".withMergedFaces()\", this.vertexNames);\r\n }\r\n calculateVolume() {\r\n return sum(this.faces.map((face) => face.zDirVolume().volume));\r\n }\r\n toMesh() {\r\n const mesh = new Mesh()\r\n .addVertexBuffer(\"normals\", \"ts_Normal\")\r\n .addIndexBuffer(\"TRIANGLES\")\r\n .addIndexBuffer(\"LINES\");\r\n mesh.faceIndexes = new Map();\r\n for (const face of this.faces) {\r\n const triangleStart = mesh.TRIANGLES.length;\r\n face.addToMesh(mesh);\r\n mesh.faceIndexes.set(face, {\r\n start: triangleStart,\r\n count: mesh.TRIANGLES.length - triangleStart,\r\n });\r\n }\r\n //this.buildAdjacencies()\r\n //for (const edge of this.edgeFaces.keys()) {\r\n //\r\n //}\r\n return mesh;\r\n }\r\n minus(other, infoFactory) {\r\n const generator = this.generator &&\r\n other.generator &&\r\n this.generator + \".minus(\" + other.generator + \")\";\r\n return this.intersection(other.flipped(), true, true, generator, infoFactory);\r\n }\r\n plus(other, infoFactory) {\r\n const generator = this.generator &&\r\n other.generator &&\r\n this.generator + \".plus(\" + other.generator + \")\";\r\n return this.flipped()\r\n .intersection(other.flipped(), true, true, generator, infoFactory)\r\n .flipped();\r\n }\r\n and(other, infoFactory) {\r\n const generator = this.generator &&\r\n other.generator &&\r\n this.generator + \".and(\" + other.generator + \")\";\r\n return this.intersection(other, true, true, generator, infoFactory);\r\n }\r\n xor(other, infoFactory) {\r\n const generator = this.generator &&\r\n other.generator &&\r\n this.generator + \".xor(\" + other.generator + \")\";\r\n return new BRep(this.minus(other, infoFactory).faces.concat(other.minus(this, infoFactory).faces), this.infiniteVolume != other.infiniteVolume, generator);\r\n }\r\n equals(obj) {\r\n return (this.faces.length == obj.faces.length &&\r\n this.faces.every((face) => obj.faces.some((face2) => face.equals(face2))));\r\n }\r\n like(brep) {\r\n return (this.faces.length == brep.faces.length &&\r\n this.faces.every((face) => brep.faces.some((face2) => face.likeFace(face2))));\r\n }\r\n //reconstituteCoplanarFaces(likeSurfacePlanes, edgeLooseSegments, faceMap, newFaces) {\r\n // likeSurfacePlanes.forEach(faceGroup => {\r\n // // calculate total contours\r\n // let surface = faceGroup[0].surface, bag = []\r\n // faceGroup.forEach(face => {\r\n // Array.prototype.push.apply(bag, faceMap(face))\r\n // face.getAllEdges().forEach(edge => {\r\n // let edgeSubSegments\r\n // if (edgeSubSegments = edgeLooseSegments.get(edge)) {\r\n // Array.prototype.push.apply(bag, edgeSubSegments)\r\n // } else {\r\n // bag.push(edge)\r\n // }\r\n // })\r\n // })\r\n // let currentEdge, loops = []\r\n // while (currentEdge = bag.find(edge => !edge.visited)) {\r\n // let path = []\r\n // do {\r\n // currentEdge.visited = true\r\n // path.push(currentEdge)\r\n // let possibleNextEdges = bag.filter(edge => currentEdge.b.like(edge.a))\r\n // // lowest angle, i.e. the right-most next edge\r\n // let nextEdgeIndex = possibleNextEdges.indexWithMax((edge, index) =>\r\n // -currentEdge.bDir.angleRelativeNormal(edge.aDir, surface.normalP(currentEdge.b))) currentEdge =\r\n // possibleNextEdges[nextEdgeIndex] } while (!currentEdge.visited) let startIndex = path.find(currentEdge) if (-1\r\n // != startIndex) { loops.push(path.slice(startIndex)) } } }) }\r\n toString() {\r\n return `new BRep([\\n${this.faces.join(\",\\n\").replace(/^/gm, \"\\t\")}], ${this.infiniteVolume})`;\r\n }\r\n getConstructorParameters() {\r\n return [this.faces, this.infiniteVolume];\r\n }\r\n toSource(useGenerator = true) {\r\n return ((useGenerator && this.generator) ||\r\n `new BRep([\\n${this.faces.map(SCE).join(\",\\n\").replace(/^/gm, \"\\t\")}], ${this.infiniteVolume})`);\r\n }\r\n /**\r\n * Rightmost next segment doesn't work, as the correct next segment isn't obvious from the current corner\r\n * alone.\r\n * (at least, not without extensive pre-analysis on the face edges, which shouldn't be necessary, as the\r\n * correct new faces are defined by the new edges already.) Leftmost edge should work. Holes which touch the\r\n * edge of the face will be added to the face contour.\r\n *\r\n * New segments will always be part left-er than existing ones, so no special check is required.\r\n *\r\n */\r\n reconstituteFaces(oldFaces, edgeSubEdges, faceMap, newFaces, infoFactory) {\r\n const oldFaceStatuses = new Map();\r\n // reconstitute faces\r\n const insideEdges = [];\r\n for (const face of oldFaces) {\r\n const usableOldEdges = face\r\n .getAllEdges()\r\n .filter((edge) => !edgeSubEdges.get(edge));\r\n const subEdges = concatenated(mapFilter(face.getAllEdges(), (edge) => edgeSubEdges.get(edge)));\r\n const newEdges = faceMap.get(face) || [];\r\n if (newEdges.length || subEdges.length) {\r\n oldFaceStatuses.set(face, \"partial\");\r\n const loops = [];\r\n // new edges are definitely part of a resulting loop\r\n // old edges (both contour and holes) can either be part of a new loop, in which case they will already\r\n // have been visited when starting a loop search with a new edge, OR they can be stranded, OR they can\r\n // remain in their old loop\r\n function getNextStart() {\r\n return (newEdges.find((edge) => !visitedEdges.has(edge)) ||\r\n subEdges.find((edge) => !visitedEdges.has(edge)) ||\r\n usableOldEdges.find((edge) => !visitedEdges.has(edge)));\r\n }\r\n const visitedEdges = new Set();\r\n // search for a loop:\r\n let currentEdge;\r\n while ((currentEdge = getNextStart())) {\r\n const startEdge = currentEdge, edges = [];\r\n let i = 0;\r\n // wether only new edges are used (can include looseSegments)\r\n do {\r\n visitedEdges.add(currentEdge);\r\n edges.push(currentEdge);\r\n // find next edge\r\n const possibleOldEdges = usableOldEdges.filter((edge) => currentEdge.b.like(edge.a));\r\n const possibleSubEdges = subEdges.filter((edge) => currentEdge.b.like(edge.a));\r\n const possibleNewEdges = newEdges.filter((edge) => currentEdge.b.like(edge.a));\r\n const possibleEdges = possibleOldEdges.concat(possibleSubEdges, possibleNewEdges);\r\n if (0 == possibleEdges.length)\r\n break;\r\n assert(0 < possibleEdges.length, () => face.sce);\r\n const faceNormalAtCurrentB = face.surface.normalP(currentEdge.b);\r\n const nextEdgeIndex = calcNextEdgeIndex(currentEdge, possibleEdges, faceNormalAtCurrentB);\r\n currentEdge = possibleEdges[nextEdgeIndex];\r\n if (visitedEdges.has(currentEdge)) {\r\n break;\r\n }\r\n assert(currentEdge);\r\n assert(currentEdge != startEdge);\r\n } while (++i < 400);\r\n if (400 == i) {\r\n assert(false, \"too many\");\r\n }\r\n // check if we found a loop\r\n if (edges.length > 1 && currentEdge == startEdge) {\r\n loops.push(edges);\r\n }\r\n }\r\n const faceNewFaces = BRep.assembleFacesFromLoops(loops, face.surface, face, infoFactory);\r\n newFaces.push(...faceNewFaces);\r\n const faceNewFacesEdges = faceNewFaces.flatMap((face) => face.getAllEdges());\r\n insideEdges.push(...usableOldEdges.filter((edge) => faceNewFacesEdges.includes(edge)));\r\n }\r\n }\r\n while (insideEdges.length != 0) {\r\n const insideEdge = insideEdges.pop();\r\n const adjacentFaces = this.edgeFaces.get(insideEdge.getCanon());\r\n adjacentFaces.forEach((info) => {\r\n if (!oldFaceStatuses.has(info.face)) {\r\n oldFaceStatuses.set(info.face, \"inside\");\r\n insideEdges.push.apply(insideEdges, info.face.getAllEdges());\r\n }\r\n });\r\n }\r\n newFaces.push(...oldFaces.filter((face) => oldFaceStatuses.get(face) == \"inside\"));\r\n }\r\n static getLooseEdgeSegments(edgePointInfoss, edgeFaces) {\r\n const result = new JavaMap();\r\n // if there are no point info, the original edge will be kept, so we should return nothing\r\n // otherwise, something will be returned, even if it a new edge identical to the base edge\r\n for (const [canonEdge, pointInfos] of edgePointInfoss) {\r\n if (0 == pointInfos.length)\r\n continue;\r\n const allFaces = edgeFaces.get(canonEdge);\r\n pointInfos.sort((a, b) => snap0(a.edgeT - b.edgeT) || +!!undefined);\r\n let startP = canonEdge.a, startDir = canonEdge.aDir, startT = canonEdge.aT, startInfo;\r\n function addNewEdge(startInfo, endInfo, newEdge) {\r\n for (let i = 0; i < allFaces.length; i++) {\r\n const faceInfo = allFaces[i];\r\n mapPush(result, !faceInfo.reversed ? canonEdge : canonEdge.flipped(), !faceInfo.reversed ? newEdge : newEdge.flipped());\r\n }\r\n }\r\n for (let i = 0; i < pointInfos.length; i++) {\r\n const info = pointInfos[i];\r\n const pDir = canonEdge.tangentAt(info.edgeT);\r\n if (!eq(info.edgeT, startT)) {\r\n const newEdge = createEdge(canonEdge.curve, startP, info.p, startT, info.edgeT, undefined, startDir, pDir, \"looseSegment\" + getGlobalId());\r\n addNewEdge(startInfo, info, newEdge);\r\n }\r\n startP = info.p;\r\n startT = info.edgeT;\r\n startInfo = info;\r\n startDir = pDir;\r\n }\r\n if (startInfo && !eq(startT, canonEdge.bT)) {\r\n const newEdge = createEdge(canonEdge.curve, startP, canonEdge.b, startT, canonEdge.bT, undefined, startDir, canonEdge.bDir, \"looseSegment\" + getGlobalId());\r\n addNewEdge(startInfo, undefined, newEdge);\r\n }\r\n }\r\n return result;\r\n }\r\n getIntersectionEdges(brep2) {\r\n const faceMap = new Map(), thisEdgePoints = new JavaMap(), otherEdgePoints = new JavaMap();\r\n const checkedPairs = new JavaSet();\r\n this.faces.forEach((face) => {\r\n //console.log('face', face.toString())\r\n brep2.faces.forEach((face2) => {\r\n //console.log('face2', face2.toString())\r\n face.intersectFace(face2, this, brep2, faceMap, thisEdgePoints, otherEdgePoints, checkedPairs);\r\n });\r\n });\r\n return concatenated(Array.from(faceMap.values()));\r\n }\r\n shellCount() {\r\n const foundFaces = new Set();\r\n let face, result = 0;\r\n while ((face = this.faces.find((face) => !foundFaces.has(face)))) {\r\n result++;\r\n const stack = [face];\r\n while ((face = stack.pop())) {\r\n // @ts-ignore\r\n for (const edge of face.getAllEdges()) {\r\n // @ts-ignore\r\n for (const { face: face2 } of this.edgeFaces.get(edge.getCanon())) {\r\n if (face !== face2 && !foundFaces.has(face2)) {\r\n foundFaces.add(face2);\r\n stack.push(face2);\r\n }\r\n }\r\n }\r\n }\r\n }\r\n return result;\r\n }\r\n getAABB() {\r\n return AABB.forAABBs(this.faces.map((face) => face.getAABB()));\r\n }\r\n assertSanity() {\r\n if (!NLA_DEBUG)\r\n return;\r\n // const allFaceEdges = this.faces.flatMap(face => face.getAllEdges())\r\n // for (const { i, j } of combinations(allFaceEdges.length)) {\r\n // const a = allFaceEdges[i],\r\n // \tb = allFaceEdges[j]\r\n // assert(i == j || !a.isCoEdge(b) || a == b || a.flippedOf == b, 'coedges not linked properly', a, b)\r\n // assert(\r\n // \ti == j ||\r\n // \t\t!a.curve.isColinearTo(b.curve) ||\r\n // \t\t(a.curve.equals(b.curve) && a.isCoEdge(b)) ||\r\n // \t\t!a.overlaps(b),\r\n // \t'colinear edges overlap',\r\n // \ta,\r\n // \tb,\r\n // )\r\n // }\r\n this.buildAdjacencies();\r\n for (const [canonEdge, edgeFaceInfos] of this.edgeFaces) {\r\n // TODO handle curved faces\r\n assert(edgeFaceInfos.length % 2 == 0, () => canonEdge + edgeFaceInfos.sce);\r\n }\r\n }\r\n //intersection3(other: BRep, buildThis: boolean, buildOther: boolean, name?: string): BRep {\r\n // this.assertSanity()\r\n // other.assertSanity()\r\n // this.buildAdjacencies()\r\n // other.buildAdjacencies()\r\n //\r\n // // edge / edge\r\n // for (const [edge1, edge1Faces] of this.edgeFaces) {\r\n // for (const [edge2, edge2Faces] of other.edgeFaces) {\r\n // const curve1 = edge1.curve, curve2 = edge2.curve\r\n // if (curve1.isColinearTo(curve2)) {\r\n // if (edge1.overlaps(edge2)) {\r\n // // faces have a common edge\r\n // const aT = curve1.pointT(edge2.a), bT = curve1.pointT(edge2.a)\r\n // const minT = min(aT, bT), maxT = max(aT, bT)\r\n // const commonEdge = createEdge(curve1, min(edge1.minT, minT), min(edge1.maxT, maxT), )\r\n // }\r\n // } else if (x = curve1.isInfosWithCurve(edge2.curve)) {\r\n // // edges intersect in a point\r\n // }\r\n // }\r\n // }\r\n //\r\n // // point / edge\r\n // function pointEdge(b1, b2, has, add) {\r\n // for (const v1 of this.vertFaces.keys()) {\r\n // for (const edge2 of other.edgeFaces.keys()) {\r\n // if (edge2.curve.containsPoint(v1)) {\r\n // const edge2T = edge2.curve.pointT(v1)\r\n // if (eq(edge2.aT, edge2T) || eq(edge2.bT, edge2T)) {\r\n // add(v1, eq(edge2.aT, edge2T) ? edge2.a : edge2.b)\r\n // }\r\n // }\r\n // }\r\n // }\r\n // }\r\n // const pairs: CustomSet<[Equalable, Equalable]> = new CustomSet<[Equalable, Equalable]>()\r\n // pointEdge(this, other, (a, b) => pairs.has([a, b]), (a, b) => pairs.add([a, b]))\r\n // pointEdge(other, this, (b, a) => pairs.has([a, b]), (b, a) => pairs.add([a, b]))\r\n //\r\n //\r\n // // point / point\r\n // for (const v1 of this.vertFaces.keys()) {\r\n // for (const v2 of other.vertFaces.keys()) {\r\n // if (v1.like(v2)) {\r\n //\r\n // }\r\n // }\r\n // }\r\n //\r\n // for (const face1 of this.faces) {\r\n // for (const face2 of other.faces) {\r\n // face1.intersectFace(face2)\r\n // }\r\n // }\r\n //\r\n //}\r\n buildAdjacencies() {\r\n if (this.edgeFaces)\r\n return this;\r\n this.edgeFaces = new JavaMap();\r\n for (const face of this.faces) {\r\n for (const edge of face.getAllEdges()) {\r\n const canon = edge.getCanon();\r\n const normalAtCanonA = face.surface.normalP(canon.a);\r\n const inside = normalAtCanonA.cross(canon == edge ? edge.aDir : edge.bDir);\r\n mapPush(this.edgeFaces, canon, {\r\n face: face,\r\n edge: edge,\r\n normalAtCanonA: normalAtCanonA,\r\n reversed: canon != edge,\r\n inside: inside,\r\n angle: 0,\r\n });\r\n }\r\n }\r\n for (const [canonEdge, edgeFaceInfos] of this.edgeFaces) {\r\n // TODO handle curved faces\r\n //assert(edgeFaceInfos.length % 2 == 0, () => canonEdge + edgeFaceInfos.sce)\r\n const faceInfo0 = edgeFaceInfos.find((faceInfo) => faceInfo.reversed);\r\n if (!faceInfo0) {\r\n console.warn(\"invalid brep\");\r\n continue;\r\n }\r\n edgeFaceInfos.forEach((faceInfo) => {\r\n if (faceInfo != faceInfo0) {\r\n faceInfo.angle = faceInfo0.inside.angleRelativeNormal(faceInfo.inside, canonEdge.aDir.unit());\r\n if (faceInfo.angle < 0)\r\n faceInfo.angle += 2 * Math.PI;\r\n }\r\n });\r\n edgeFaceInfos.sort((a, b) => snap(a.angle - b.angle, 0)); // TODO || assertNever()\r\n }\r\n return this;\r\n }\r\n /**\r\n * Cases for volumes A and B\r\n *\r\n * 1. Volumes do not touch.\r\n * 2. face/face Face surfaces intersect each other.\r\n * implies edges going through faces.\r\n * e.g. box(5, 5, 5) - box(5, 5, 5).translate(1, 1, 1)\r\n * 3. face/edge Edge of A lies in a face of B\r\n * implies vertices of A lying in face of B\r\n * e.g. box(5, 5, 5) - box(3, 3, 3).rotateZ([0, 1, 2] * PI / 2).translate(0, 1, 1)\r\n * 4. edge/edge Two edges are colinear.\r\n * implies vertex of A lying in edge of B\r\n * 5. vertex/edge Vertex of A lies on edge of B (but no edge/edge)\r\n * 6. vertex/vertex with/without edge/edge, edge/face and face/face intersections\r\n * 7. vertex lies in face\r\n *\r\n *\r\n *\r\n */\r\n intersection(other, buildThis, buildOther, generator, infoFactory) {\r\n this.assertSanity();\r\n other.assertSanity();\r\n this.buildAdjacencies();\r\n other.buildAdjacencies();\r\n const faceMap = new Map();\r\n const thisEdgePoints = new JavaMap(), otherEdgePoints = new JavaMap();\r\n const checkedPairs = new CustomSet();\r\n for (const thisFace of this.faces) {\r\n for (const otherFace of other.faces) {\r\n thisFace.intersectFace(otherFace, this, other, faceMap, thisEdgePoints, otherEdgePoints, checkedPairs);\r\n }\r\n }\r\n for (const edge of thisEdgePoints.keys()) {\r\n assert(this.edgeFaces.get(edge));\r\n }\r\n for (const edge of otherEdgePoints.keys()) {\r\n assert(other.edgeFaces.get(edge));\r\n }\r\n const newFaces = [];\r\n if (0 == faceMap.size &&\r\n 0 == thisEdgePoints.size &&\r\n 0 == otherEdgePoints.size) {\r\n const thisInOther = other.containsPoint(this.faces[0].contour[0].a, true) !==\r\n other.infiniteVolume;\r\n const otherInThis = !thisInOther &&\r\n this.containsPoint(other.faces[0].contour[0].a) !== this.infiniteVolume;\r\n if (thisInOther || otherInThis) {\r\n const [inside, outside] = thisInOther ? [this, other] : [other, this];\r\n if (inside.infiniteVolume) {\r\n if (outside.infiniteVolume) {\r\n return outside;\r\n }\r\n else {\r\n return BRep.join([inside, outside]);\r\n }\r\n }\r\n else {\r\n if (outside.infiniteVolume) {\r\n return BRep.EMPTY;\r\n }\r\n else {\r\n return inside;\r\n }\r\n }\r\n }\r\n else {\r\n if (this.infiniteVolume) {\r\n if (other.infiniteVolume) {\r\n return BRep.join([this, other]);\r\n }\r\n else {\r\n other;\r\n }\r\n }\r\n else {\r\n if (other.infiniteVolume) {\r\n return this;\r\n }\r\n else {\r\n return BRep.EMPTY;\r\n }\r\n }\r\n }\r\n return BRep.EMPTY;\r\n }\r\n else {\r\n if (buildThis) {\r\n const edgeLooseSegments = BRep.getLooseEdgeSegments(thisEdgePoints, this.edgeFaces);\r\n // @ts-ignore\r\n const els = this.faces.map((face) => [\r\n face,\r\n Array.from(edgeLooseSegments.entries()).flatMap(([edge, subs]) => face.getAllEdges().some((e) => e.equals(edge)) ? subs : []),\r\n ]);\r\n this.reconstituteFaces(this.faces, edgeLooseSegments, faceMap, newFaces, infoFactory);\r\n }\r\n if (buildOther) {\r\n const edgeLooseSegments = BRep.getLooseEdgeSegments(otherEdgePoints, other.edgeFaces);\r\n // @ts-ignore\r\n const els = other.faces.map((face) => [\r\n face,\r\n Array.from(edgeLooseSegments.entries()).flatMap(([edge, subs]) => face.getAllEdges().some((e) => e.equals(edge)) ? subs : []),\r\n ]);\r\n other.reconstituteFaces(other.faces, edgeLooseSegments, faceMap, newFaces, infoFactory);\r\n }\r\n }\r\n //buildCoplanar && this.reconstituteCoplanarFaces(likeSurfaceFaces, edgeLooseSegments, faceMap, newFaces,\r\n // this.infiniteVolume, other.infiniteVolume)\r\n const result = new BRep(newFaces, this.infiniteVolume && other.infiniteVolume, generator);\r\n //result.buildAdjacencies()\r\n return result;\r\n }\r\n transform(m4, desc) {\r\n let vertexNames;\r\n if (this.vertexNames) {\r\n vertexNames = new Map();\r\n this.vertexNames.forEach((name, vertex) => vertexNames.set(m4.transformPoint(vertex), name + desc));\r\n }\r\n return new BRep(this.faces.map((f) => f.transform(m4)), this.infiniteVolume, this.generator && desc && this.generator + desc, // if desc isn't set, the generator will be invalid\r\n vertexNames);\r\n }\r\n transform4(m4, desc) {\r\n let vertexNames;\r\n if (this.vertexNames) {\r\n vertexNames = new Map();\r\n this.vertexNames.forEach((name, vertex) => vertexNames.set(m4.transformPoint(vertex), name + desc));\r\n }\r\n return new BRep(this.faces.map((f) => f.transform4(m4)), this.infiniteVolume, this.generator && desc && this.generator + desc, // if desc isn't set, the generator will be invalid\r\n vertexNames);\r\n }\r\n flipped() {\r\n return new BRep(this.faces.map((f) => f.flipped()), !this.infiniteVolume, this.generator && this.generator + \".flipped()\", this.vertexNames);\r\n }\r\n}\r\nBRep.EMPTY = new BRep([], false, \"BRep.EMPTY\", new Map()).buildAdjacencies();\r\nBRep.R3 = new BRep([], true, \"BRep.R3\", new Map()).buildAdjacencies();\r\nexport function dotCurve(v, cDir, cDDT) {\r\n let dot = v.dot(cDir);\r\n if (eq0(dot)) {\r\n dot = v.dot(cDDT);\r\n }\r\n assert(!eq0(dot));\r\n return dot;\r\n}\r\nexport function dotCurve2(curve, t, normal, sign) {\r\n assert(sign == 1 || sign == -1, sign);\r\n const tangentDot = curve.tangentAt(t).dot(normal);\r\n // if tangentDot != 0 the curve simply crosses the plane\r\n if (!eq0(tangentDot)) {\r\n return sign * tangentDot;\r\n }\r\n if (curve.ddt) {\r\n const ddtDot = curve.ddt(t).dot(normal);\r\n // tangentDot == 0 ==> critical point at t, if ddtDot != 0, then it is a turning point, otherwise we can't be sure\r\n // and must do a numeric test\r\n if (!eq0(ddtDot)) {\r\n return ddtDot;\r\n }\r\n }\r\n const numericDot = curve\r\n .at(t)\r\n .to(curve.at(t + sign * 4 * NLA_PRECISION))\r\n .dot(normal);\r\n assert(!(curve instanceof L3));\r\n return numericDot;\r\n}\r\nexport const INSIDE = 0, OUTSIDE = 1, COPLANAR_SAME = 2, COPLANAR_OPPOSITE = 3, ALONG_EDGE_OR_PLANE = 4;\r\n/**\r\n *\r\n * @param brep BREP to check\r\n * @param edge edge to check\r\n * @param dirAtEdgeA the direction vector to check\r\n * @param faceNormal If dirAtEdgeA doesn't split a volume, but is along a face, the returned value depends on\r\n * wether that faces normal1 points in the same direction as faceNormal\r\n * @returns INSIDE, OUTSIDE, COPLANAR_SAME or COPLANAR_OPPOSITE\r\n */\r\n//function splitsVolumeEnclosingFaces(brep: BRep, edge: Edge, dirAtEdgeA: V3, faceNormal: V3): int {\r\n// assert(arguments.length == 4)\r\n// //assert(p.equals(edge.a))\r\n// const ab1 = edge.aDir.unit()\r\n// const relFaces = facesWithEdge(edge, brep.faces) as any[]\r\n// relFaces.forEach(faceInfo => {\r\n// faceInfo.normalAtEdgeA = faceInfo.face.surface.normalP(edge.a)\r\n// faceInfo.edgeDirAtEdgeA = !faceInfo.reversed\r\n// ? faceInfo.edge.aDir\r\n// : faceInfo.edge.bDir\r\n// faceInfo.outsideVector = faceInfo.edgeDirAtEdgeA.cross(faceInfo.normalAtEdgeA)\r\n// faceInfo.angle = (dirAtEdgeA.angleRelativeNormal(faceInfo.outsideVector.negated(), ab1) + 2 * Math.PI +\r\n// NLA_PRECISION / 2) % (2 * Math.PI) }) assert(relFaces.length != 0, edge.toSource()) relFaces.sort((a, b) => a.angle\r\n// - b.angle) // assert(relFaces.length % 2 == 0, edge.toSource()) // even number of touching faces if\r\n// (eq0(relFaces[0].angle)) { //assert(false) todo const coplanarSame = relFaces[0].normalAtEdgeA.dot(faceNormal) > 0;\r\n// return coplanarSame ? COPLANAR_SAME : COPLANAR_OPPOSITE } else { return !relFaces[0].reversed ? INSIDE : OUTSIDE } }\r\nexport function splitsVolumeEnclosingFaces(brep, canonEdge, dirAtEdgeA, faceNormal) {\r\n assert(arguments.length == 4);\r\n assert(canonEdge == canonEdge.getCanon());\r\n //assert(p.equals(canonEdge.a))\r\n const edgeFaceInfos = brep.edgeFaces.get(canonEdge);\r\n assertf(() => edgeFaceInfos.length % 2 == 0);\r\n assertf(() => brep.edgeFaces);\r\n const faceInfo0 = edgeFaceInfos[0];\r\n const aDir1 = canonEdge.aDir.unit();\r\n const angleToCanon = ((faceInfo0.inside.angleRelativeNormal(dirAtEdgeA, aDir1) +\r\n 2 * Math.PI +\r\n NLA_PRECISION) %\r\n (2 * Math.PI)) -\r\n NLA_PRECISION;\r\n const nearestFaceInfoIndex = edgeFaceInfos.findIndex((faceInfo) => lt(angleToCanon, faceInfo.angle));\r\n const nearestFaceInfo = edgeFaceInfos[nearestFaceInfoIndex == -1\r\n ? edgeFaceInfos.length - 1\r\n : nearestFaceInfoIndex - 1];\r\n if (eq(nearestFaceInfo.angle, angleToCanon)) {\r\n //assert(false) todo\r\n const coplanarSame = nearestFaceInfo.normalAtCanonA.dot(faceNormal) > 0;\r\n return coplanarSame ? COPLANAR_SAME : COPLANAR_OPPOSITE;\r\n }\r\n else {\r\n return nearestFaceInfo.reversed ? INSIDE : OUTSIDE;\r\n }\r\n}\r\nexport function splitsVolumeEnclosingFacesP(brep, canonEdge, p, pInside, pFaceNormal) {\r\n assert(arguments.length == 5);\r\n assert(canonEdge == canonEdge.getCanon());\r\n //assert(p.equals(canonEdge.a))\r\n assertf(() => brep.edgeFaces);\r\n const edgeFaceInfos = brep.edgeFaces.get(canonEdge);\r\n assertf(() => edgeFaceInfos.length % 2 == 0);\r\n const pDir1 = canonEdge.tangentAt(canonEdge.curve.pointT(p)).unit();\r\n const faceInfoAngleFromPInsideNeg = (faceInfo) => {\r\n const faceInfoPDir = faceInfo.edge.getCanon() == faceInfo.edge ? pDir1 : pDir1.negated();\r\n const faceInfoInsideAtP = faceInfo.face.surface\r\n .normalP(p)\r\n .cross(faceInfoPDir);\r\n const faceInfoAngleAtP = pInside.angleRelativeNormal(faceInfoInsideAtP, pDir1);\r\n return -(((faceInfoAngleAtP + TAU + NLA_PRECISION) % TAU) - NLA_PRECISION);\r\n };\r\n const nearestFaceInfo = withMax(edgeFaceInfos, faceInfoAngleFromPInsideNeg);\r\n if (eq0(faceInfoAngleFromPInsideNeg(nearestFaceInfo))) {\r\n //assert(false) todo\r\n const coplanarSame = nearestFaceInfo.face.surface.normalP(p).dot(pFaceNormal) > 0;\r\n return coplanarSame ? COPLANAR_SAME : COPLANAR_OPPOSITE;\r\n }\r\n else {\r\n return nearestFaceInfo.reversed ? OUTSIDE : INSIDE;\r\n }\r\n}\r\nexport function splitsVolumeEnclosingFacesP2(brep, canonEdge, p, testCurve, curveT, dir, faceNormal) {\r\n assert(canonEdge == canonEdge.getCanon());\r\n //assert(p.equals(canonEdge.a))\r\n assertf(() => brep.edgeFaces);\r\n const edgeFaceInfos = brep.edgeFaces.get(canonEdge);\r\n assertf(() => edgeFaceInfos.length % 2 == 0);\r\n const pDir1 = canonEdge.tangentAt(canonEdge.curve.pointT(p)).unit();\r\n let pInside = testCurve.tangentAt(curveT).times(dir);\r\n if (pInside.isParallelTo(pDir1)) {\r\n pInside = testCurve\r\n .diff(curveT, (1e-4 * dir) / testCurve.tangentAt(curveT).length())\r\n .rejectedFrom(pDir1);\r\n pInside = pInside.div(pInside.length());\r\n }\r\n let minValue = 20, advanced = false, result = OUTSIDE;\r\n for (const faceInfo of edgeFaceInfos) {\r\n const faceInfoPDir = faceInfo.edge.getCanon() == faceInfo.edge ? pDir1 : pDir1.negated();\r\n const faceInfoInsideAtP = faceInfo.face.surface\r\n .normalP(p)\r\n .cross(faceInfoPDir);\r\n const faceInfoAngleAtP = pInside.angleRelativeNormal(faceInfoInsideAtP, pDir1);\r\n const angle = ((faceInfoAngleAtP + TAU + NLA_PRECISION) % TAU) - NLA_PRECISION;\r\n if (eq0(angle)) {\r\n // do advanced analysis\r\n const normVector = faceInfo.face.surface.normalP(p);\r\n if (faceInfo.face.surface.containsCurve(testCurve)) {\r\n const coplanarSame = normVector.dot(faceNormal) > 0;\r\n return coplanarSame ? COPLANAR_SAME : COPLANAR_OPPOSITE;\r\n }\r\n const testPlane = P3.normalOnAnchor(pDir1, p);\r\n const isCurve = faceInfo.face.surface.isCurvesWithPlane(testPlane)[0];\r\n const isCurvePT = isCurve.pointT(p);\r\n const dirFactor = sign(isCurve.tangentAt(isCurvePT).dot(pInside));\r\n const eps = 1e-4;\r\n const iscd = isCurve\r\n .at(isCurvePT)\r\n .to(isCurve.at(isCurvePT + dir * dirFactor * eps))\r\n .dot(normVector);\r\n const ecd = testCurve\r\n .at(curveT)\r\n .to(testCurve.at(curveT + dir * eps))\r\n .dot(normVector);\r\n const diff = (iscd - ecd) * (faceInfo.reversed ? -1 : 1);\r\n if (diff > 0 && (!advanced || diff < minValue)) {\r\n advanced = true;\r\n minValue = diff;\r\n result = faceInfo.reversed ? OUTSIDE : INSIDE;\r\n }\r\n }\r\n else if (!advanced) {\r\n if (angle < minValue) {\r\n minValue = angle;\r\n result = faceInfo.reversed ? OUTSIDE : INSIDE;\r\n }\r\n }\r\n }\r\n return result;\r\n}\r\nexport function splitsVolumeEnclosingCone(brep, p, dir) {\r\n const testPlane = P3.forAnchorAndPlaneVectors(p, dir, dir.getPerpendicular());\r\n const rays = [];\r\n for (let k = 0; k < brep.faces.length; k++) {\r\n const planeFace = brep.faces[k];\r\n assertf(() => planeFace instanceof PlaneFace);\r\n if (planeFace.getAllEdges().some((edge) => edge.a.like(p))) {\r\n if (testPlane.isParallelToPlane(planeFace.surface.plane)) {\r\n if (planeFace.pointsToInside(p, dir) != PointVsFace.OUTSIDE) {\r\n return ALONG_EDGE_OR_PLANE;\r\n }\r\n }\r\n else {\r\n const isLine = L3.fromPlanes(testPlane, planeFace.surface.plane);\r\n const ps = planeFace.edgeISPsWithPlane(isLine, testPlane);\r\n let i = 0;\r\n while (i < ps.length) {\r\n const a = ps[i++], b = ps[i++];\r\n const out = a.p.like(p);\r\n if (out || b.p.like(p)) {\r\n const dir2 = out ? isLine.dir1 : isLine.dir1.negated();\r\n const angle = (dir.angleRelativeNormal(dir2, testPlane.normal1) +\r\n 2 * Math.PI +\r\n NLA_PRECISION / 2) %\r\n (2 * Math.PI);\r\n rays.push({ angle: angle, out: out });\r\n }\r\n }\r\n }\r\n }\r\n }\r\n rays.sort((a, b) => a.angle - b.angle);\r\n //console.log(\"testPlane\"Plane.toSource(), \"rays\", rays.toSource())\r\n if (eq0(rays[0].angle)) {\r\n return ALONG_EDGE_OR_PLANE;\r\n }\r\n else {\r\n return rays[0].out ? OUTSIDE : INSIDE;\r\n }\r\n}\r\nexport function splitsVolumeEnclosingCone2(brep, p, curve, curveT, fb) {\r\n assert(curve.containsPoint(p));\r\n const pFaces = brep.faces.filter((face) => face.getAllEdges().some((edge) => edge.a.like(p)));\r\n for (let k = 0; k < pFaces.length; k++) {\r\n const face = pFaces[k];\r\n if (face.surface.containsCurve(curve)) {\r\n //assert(false)\r\n if (face.pointsToInside3(p, curve, curveT, fb) != PointVsFace.OUTSIDE) {\r\n return ALONG_EDGE_OR_PLANE;\r\n }\r\n }\r\n }\r\n const EPS = 1e-6;\r\n return brep.containsPoint(curve.at(curveT + fb * EPS), true)\r\n ? INSIDE\r\n : OUTSIDE;\r\n}\r\nexport function fff(info, surface) {\r\n const canonA = info.edge.reversed ? info.edge.b : info.edge.a;\r\n const surfaceNormalAtCanonA = surface.normalP(canonA);\r\n const dot = snap0(info.inside.dot(surfaceNormalAtCanonA));\r\n if (0 !== dot) {\r\n return 0 < dot ? OUTSIDE : INSIDE;\r\n }\r\n if (surface.isCoplanarTo(info.face.surface)) {\r\n return 0 < info.normalAtCanonA.dot(surfaceNormalAtCanonA)\r\n ? COPLANAR_SAME\r\n : COPLANAR_OPPOSITE;\r\n }\r\n throw new Error();\r\n}\r\nexport function triangulateVertices(normal, vertices, holeStarts) {\r\n const absMaxDim = normal.maxAbsDim(), factor = sign(normal.e(absMaxDim));\r\n const contour = new Float64Array(vertices.length * 2);\r\n let i = vertices.length;\r\n /*\r\n var [coord0, coord1] = [['y', 'z'], ['z', 'x'], ['x', 'y']][maxAbsDim]\r\n while (i--) {\r\n contour[i * 2 ] = vertices[i][coord0] * factor\r\n contour[i * 2 + 1] = vertices[i][coord1]\r\n }\r\n */\r\n while (i--) {\r\n // unroll disambiguation instead of accessing elements by string name ([coord0] etc)\r\n // as it confuses google closure\r\n switch (absMaxDim) {\r\n case 0:\r\n contour[i * 2] = vertices[i].y * factor;\r\n contour[i * 2 + 1] = vertices[i].z;\r\n break;\r\n case 1:\r\n contour[i * 2] = vertices[i].z * factor;\r\n contour[i * 2 + 1] = vertices[i].x;\r\n break;\r\n case 2:\r\n contour[i * 2] = vertices[i].x * factor;\r\n contour[i * 2 + 1] = vertices[i].y;\r\n break;\r\n }\r\n }\r\n return earcut(contour, holeStarts);\r\n}\r\n/**\r\n * Solves a quadratic system of equations of the form\r\n * a * x + b * y = c\r\n * x² + y² = 1\r\n * This can be understood as the intersection of the unit circle with a line.\r\n * => y = (c - a x) / b\r\n * => x² + (c - a x)² / b² = 1\r\n * => x² b² + c² - 2 c a x + a² x² = b²\r\n * => (a² + b²) x² - 2 a c x + (c² - b²) = 0\r\n *\r\n * a * b + (b -c) * (b + c)\r\n */\r\nexport function intersectionUnitCircleLine(a, b, c) {\r\n assertNumbers(a, b, c);\r\n // TODO: disambiguate on a < b\r\n const term = sqrt(a * a + b * b - c * c);\r\n return {\r\n x1: (a * c + b * term) / (a * a + b * b),\r\n x2: (a * c - b * term) / (a * a + b * b),\r\n y1: (b * c - a * term) / (a * a + b * b),\r\n y2: (b * c + a * term) / (a * a + b * b),\r\n };\r\n}\r\nexport function intersectionUnitCircleLine2(a, b, c) {\r\n assertNumbers(a, b, c);\r\n // TODO: disambiguate on a < b\r\n // cf. pqFormula\r\n const termSqr = snap0(a * a + b * b - c * c);\r\n if (termSqr < 0) {\r\n return [];\r\n }\r\n else if (termSqr == 0) {\r\n return [[(a * c) / (a * a + b * b), (b * c) / (a * a + b * b)]];\r\n }\r\n else {\r\n const term = sqrt(termSqr);\r\n return [\r\n [\r\n (a * c + b * term) / (a * a + b * b),\r\n (b * c - a * term) / (a * a + b * b),\r\n ],\r\n [\r\n (a * c - b * term) / (a * a + b * b),\r\n (b * c + a * term) / (a * a + b * b),\r\n ],\r\n ];\r\n }\r\n}\r\nexport function intersectionCircleLine(a, b, c, r) {\r\n assertNumbers(a, b, c, r);\r\n const term = sqrt(r * r * (a * a + b * b) - c * c);\r\n return {\r\n x1: (a * c + b * term) / (a * a + b * b),\r\n x2: (a * c - b * term) / (a * a + b * b),\r\n y1: (b * c - a * term) / (a * a + b * b),\r\n y2: (b * c + a * term) / (a * a + b * b),\r\n };\r\n}\r\n/**\r\n * Solves a quadratic system of equations of the form\r\n * a * x + b * y = c\r\n * x^2 - y^2 = 1\r\n * This can be understood as the intersection of the unit hyperbola with a line.\r\n *\r\n * @returns with x1 >= x2 and y1 <= y2\r\n * a * b + (b -c) * (b + c)\r\n */\r\nexport function intersectionUnitHyperbolaLine(a, b, c) {\r\n assertNumbers(a, b, c);\r\n const aa = a * a, bb = b * b, cc = c * c;\r\n // TODO: disambiguate on a < b\r\n //var xTerm = sqrt(4*cc*aa-4*(bb-aa)*(-cc-bb))\r\n const xTerm = 2 * sqrt(bb * cc + bb * bb - aa * bb);\r\n const yTerm = sqrt(4 * cc * bb - 4 * (bb - aa) * (cc - aa));\r\n return {\r\n x1: (-2 * a * c + xTerm) / 2 / (bb - aa),\r\n x2: (-2 * a * c - xTerm) / 2 / (bb - aa),\r\n y1: (2 * b * c - yTerm) / 2 / (bb - aa),\r\n y2: (2 * b * c + yTerm) / 2 / (bb - aa),\r\n };\r\n}\r\nexport function curvePointPP(ps1, ps2, startPoint, dontCheck) {\r\n const EPS = NLA_PRECISION / 4;\r\n //if (!dontCheck) {\r\n // const p = curvePointPP(ps1, ps2, startPoint, true).p\r\n // if (!ps1.containsPoint(p)) {\r\n // console.log(\"foo, startPoint was \" + startPoint.sce)\r\n // ps1.containsPoint(p)\r\n // }\r\n //}\r\n let Q = startPoint;\r\n let st1 = ps1.pointFoot(Q);\r\n let st2 = ps2.pointFoot(Q);\r\n let a, b, aNormal, bNormal, abNormalsCross;\r\n //console.log(\"curvePointPP, startPoint was \" + startPoint.sce)\r\n //console.log(Q.sce+ ',')\r\n let i = 16;\r\n do {\r\n a = ps1.pUV(st1.x, st1.y);\r\n b = ps2.pUV(st2.x, st2.y);\r\n if (eq0(a.distanceTo(b), EPS))\r\n break;\r\n // drPs.push({p:a,text:'a'+j+' '+i})\r\n // drPs.push({p:b,text:'b'+j+' '+i})\r\n aNormal = ps1.normalUV(st1.x, st1.y);\r\n bNormal = ps2.normalUV(st2.x, st2.y);\r\n // next Q is the intersection of the planes\r\n // (x - a) * aNormal,\r\n // (x - b) * bNormal and\r\n // (x - Q) * (aNormal X bNormal)\r\n abNormalsCross = aNormal.cross(bNormal);\r\n // drVs.push({anchor: Q, dir: aNormal})\r\n // drVs.push({anchor: Q, dir: bNormal})\r\n Q = V3.add(bNormal.cross(abNormalsCross).times(a.dot(aNormal)), abNormalsCross.cross(aNormal).times(b.dot(bNormal)), abNormalsCross.times(abNormalsCross.dot(Q))).div(abNormalsCross.squared());\r\n //console.log(Q.sce+ ',')\r\n // feet of Q on ps1 and ps2 (closest points)\r\n st1 = ps1.pointFoot(Q, st1.x, st1.y);\r\n st2 = ps2.pointFoot(Q, st2.x, st2.y);\r\n } while (--i);\r\n //assert(ps1.containsPoint(Q), Q, ps1)\r\n //assert(ps2.containsPoint(Q))\r\n if (!eq0(a.distanceTo(b), EPS)) {\r\n return undefined;\r\n }\r\n return { p: Q, st1: st1, st2: st2 };\r\n}\r\n/**\r\n * Follow the intersection curve of two parametric surfaces starting from a given point.\r\n * @param {ParametricSurface} ps1\r\n * @param {ParametricSurface} ps2\r\n * @param {number} s1Step\r\n * @param {number} t1Step\r\n * @param {number} s2Step\r\n * @param {number} t2Step\r\n * @param {number} curveStepSize\r\n * @return {Curve[]}\r\n */\r\nexport function followAlgorithmPP(ps1, ps2, startPoint, curveStepSize, bounds1 = uvInAABB2.bind(undefined, ps1), bounds2 = uvInAABB2.bind(undefined, ps2)) {\r\n const points = [];\r\n const tangents = [];\r\n const st1s = [];\r\n const st2s = [];\r\n let Q = startPoint;\r\n let st1 = ps1.uvP(Q);\r\n let st2 = ps2.uvP(Q);\r\n assert(ps1.pUV(st1.x, st1.y).like(Q));\r\n assert(st1.like(ps1.pointFoot(Q, st1.x, st1.y)));\r\n assert(ps2.pUV(st2.x, st2.y).like(Q));\r\n assert(st2.like(ps2.pointFoot(Q, st2.x, st2.y)));\r\n for (let i = 0; i < 1000; i++) {\r\n ;\r\n ({ p: Q, st1, st2 } = curvePointPP(ps1, ps2, Q));\r\n assert(ps1.containsPoint(Q), Q, ps1);\r\n assert(ps2.containsPoint(Q));\r\n const aNormal = ps1.normalUV(st1.x, st1.y);\r\n const bNormal = ps2.normalUV(st2.x, st2.y);\r\n const tangent = aNormal.cross(bNormal).toLength(curveStepSize);\r\n tangents.push(tangent);\r\n points.push(Q);\r\n st1s.push(st1);\r\n st2s.push(st2);\r\n if (i > 4) {\r\n if (!bounds1(st1.x, st1.y) || !bounds2(st2.x, st2.y)) {\r\n break;\r\n }\r\n }\r\n Q = Q.plus(tangent);\r\n }\r\n return { points, tangents, st1s, st2s };\r\n}\r\n/**\r\n * Iteratively calculate points on an implicit 2D curve.\r\n * @param ic The curve in question.\r\n * @param startP The point at which to start.\r\n * @param stepLength The step the algorithm takes. Will be the approximate distance between points.\r\n * @param bounds Bounds function.\r\n * @param endP End point. If undefined, algorithm will continue until out of bounds or back at start point.\r\n * @param startTangent TODO Ignore this.\r\n * @returns Calculated points and tangents. points[0] and tangents[0] will be startP and startTangent.\r\n */\r\nexport function followAlgorithm2d(ic, startP, stepLength = 0.5, bounds, validUV, endP, startTangent) {\r\n assertNumbers(stepLength, ic(0, 0));\r\n assertVectors(startP);\r\n if (!startTangent) {\r\n startTangent = new V3(-ic.y(startP.x, startP.y), ic.x(startP.x, startP.y), 0).toLength(stepLength);\r\n }\r\n assertVectors(startTangent);\r\n const points = [];\r\n const tangents = [];\r\n assert(eq0(ic(startP.x, startP.y), 0.01), \"isZero(implicitCurve(startPoint.x, startPoint.y))\", ic(startP.x, startP.y));\r\n let i = 0, p = startP, tangent = startTangent, fullLoop = false;\r\n do {\r\n points.push(p);\r\n tangents.push(tangent);\r\n const searchStart = p.plus(tangent);\r\n assert(searchStart);\r\n const newP = curvePointMF(ic, searchStart);\r\n const dfpdx = ic.x(newP.x, newP.y), dfpdy = ic.y(newP.x, newP.y);\r\n const newTangent = new V3(-dfpdy, dfpdx, 0).toLength(stepLength);\r\n //const reversedDir = p.minus(prevp).dot(tangent) < 0\r\n assert(!p.equals(newP));\r\n // check if we passed a singularity\r\n if (tangent.dot(newTangent) < 0) {\r\n const singularity = newtonIterate2d(ic.x, ic.y, p.x, p.y);\r\n if (eq0(ic(singularity.x, singularity.y)) &&\r\n singularity.distanceTo(p) < abs(stepLength)) {\r\n // end on this point\r\n points.push(singularity);\r\n tangents.push(p.to(singularity));\r\n break;\r\n }\r\n else {\r\n throw new Error();\r\n }\r\n }\r\n // check for endP\r\n if (endP && p.equals(endP)) {\r\n break;\r\n }\r\n // check if loop\r\n if (fullLoop) {\r\n if (p.distanceTo(startP) > abs(stepLength)) {\r\n points.pop();\r\n tangents.pop();\r\n assert(getLast(points).distanceTo(startP) <= abs(stepLength));\r\n break;\r\n }\r\n }\r\n else {\r\n if (i > 4 && p.distanceTo(startP) <= abs(stepLength)) {\r\n fullLoop = true;\r\n }\r\n }\r\n // check if out of bounds\r\n if (i > 1 && !uvInAABB2(bounds, p.x, p.y)) {\r\n const endP = figureOutBorderPoint(bounds, p, ic);\r\n points.pop();\r\n tangents.pop();\r\n if (getLast(points).distanceTo(endP) < abs(stepLength) / 2) {\r\n points.pop();\r\n tangents.pop();\r\n }\r\n const endTangent = new V3(-ic.y(endP.x, endP.y), ic.x(endP.x, endP.y), 0).toLength(stepLength);\r\n points.push(endP);\r\n tangents.push(endTangent);\r\n break;\r\n }\r\n if (i > 4 && !validUV(p.x, p.y)) {\r\n break;\r\n }\r\n assert(eq0(ic(newP.x, newP.y), NLA_PRECISION * 2), p, newP, searchStart, ic(newP.x, newP.y));\r\n tangent = newTangent;\r\n p = newP;\r\n } while (++i < 1000);\r\n assert(i < 1000);\r\n //assert(points.length > 6)\r\n return { points, tangents };\r\n}\r\n/**\r\n * Given a point p just outside the bounds, figure out the nearby intersection of the bounds with the ic.\r\n * @param bounds\r\n * @param p\r\n * @param ic\r\n */\r\nfunction figureOutBorderPoint(bounds, p, ic) {\r\n if (p.x < bounds.uMin || bounds.uMax < p.x) {\r\n const u = bounds.uMax < p.x ? bounds.uMax : bounds.uMin;\r\n const v = newtonIterateWithDerivative((t) => ic(u, t), p.y, 4, (t) => ic.y(u, t));\r\n if (uvInAABB2(bounds, u, v)) {\r\n return new V3(u, v, 0);\r\n }\r\n }\r\n if (p.y < bounds.vMin || bounds.vMax < p.y) {\r\n const v = bounds.vMax < p.y ? bounds.vMax : bounds.vMin;\r\n const u = newtonIterateWithDerivative((s) => ic(s, v), p.x, 4, (s) => ic.x(s, v));\r\n assert(uvInAABB2(bounds, u, v));\r\n return new V3(u, v, 0);\r\n }\r\n throw new Error(p + \" \" + bounds);\r\n}\r\nexport function followAlgorithm2dAdjustable(ic, start, stepLength = 0.5, bounds, endp = start) {\r\n assertNumbers(stepLength, ic(0, 0));\r\n assertVectors(start);\r\n //assert (!startDir || startDir instanceof V3)\r\n const points = [];\r\n const tangents = [];\r\n assert(eq0(ic(start.x, start.y), 0.01), \"isZero(implicitCurve(startPoint.x, startPoint.y))\");\r\n let p = start, prevp = p;\r\n let i = 0;\r\n do {\r\n const dfpdx = ic.x(p.x, p.y), dfpdy = ic.y(p.x, p.y);\r\n const dfpdxx = ic.xx(p.x, p.y), dfpdyy = ic.yy(p.x, p.y), dfpdxy = ic.xy(p.x, p.y);\r\n const c2factor = abs((Math.pow(dfpdy, 2) * dfpdxx - 2 * dfpdx * dfpdy * dfpdxy + Math.pow(dfpdx, 2) * dfpdyy) /\r\n Math.pow((Math.pow(dfpdx, 2) + Math.pow(dfpdy, 2)), 2));\r\n const c2 = new V3(dfpdx, dfpdy, 0).times(c2factor);\r\n const s = 1 / 16 / c2.length();\r\n const tangent = new V3(-dfpdy, dfpdx, 0).unit();\r\n const newPStart = p.plus(tangent.times(s).plus(c2.times(Math.pow(s, 2) / 2)));\r\n points.push(p);\r\n tangents.push(tangent);\r\n prevp = p;\r\n const newP = curvePointMF(ic, newPStart);\r\n if (newP.equals(p)) {\r\n assertNever();\r\n }\r\n console.log(p.to(newP).length());\r\n p = newP;\r\n assert(eq0(ic(p.x, p.y)));\r\n } while (i++ < 1000 &&\r\n (i < 4 || prevp.distanceTo(endp) > stepLength) &&\r\n bounds(p.x, p.y));\r\n assert(i != 1000);\r\n //assert(bounds(p.x, p.y))\r\n const end = i < 4 || prevp.distanceTo(endp) > stepLength ? p : endp;\r\n const endTangent = new V3(-ic.y(end.x, end.y), ic.x(end.x, end.y), 0).toLength(stepLength);\r\n points.push(end);\r\n tangents.push(endTangent);\r\n //assert(points.length > 6)\r\n // TODO gleichmäßige Verteilung der Punkte\r\n return { points, tangents };\r\n}\r\n// both curves must be in the same s-t coordinates for this to make sense\r\nexport function intersectionICurveICurve(iCurve1, startParams1, endParams1, startDir, stepLength, iCurve2) {\r\n assertNumbers(stepLength, iCurve1(0, 0), iCurve2(0, 0));\r\n assertVectors(startParams1, endParams1);\r\n assert(!startDir || startDir instanceof V3);\r\n const vertices = [];\r\n assert(eq0(iCurve1(startParams1.x, startParams1.y)));\r\n stepLength = stepLength || 0.5;\r\n const eps = 1e-5;\r\n let p = startParams1, prevp = p; // startDir ? p.minus(startDir) : p\r\n let i = 0;\r\n while (i++ < 1000 && (i < 4 || p.distanceTo(endParams1) > 1.1 * stepLength)) {\r\n const fp = iCurve1(p.x, p.y);\r\n const dfpdx = (iCurve1(p.x + eps, p.y) - fp) / eps, dfpdy = (iCurve1(p.x, p.y + eps) - fp) / eps;\r\n let tangent = new V3(-dfpdy, dfpdx, 0).toLength(stepLength);\r\n if (p.minus(prevp).dot(tangent) < 0)\r\n tangent = tangent.negated();\r\n prevp = p;\r\n p = curvePointMF(iCurve1, p.plus(tangent));\r\n vertices.push(p);\r\n }\r\n // TODO gleichmäßige Verteilung der Punkte\r\n return vertices;\r\n}\r\nexport function intersectionICurveICurve2(iCurve1, loopPoints1, iCurve2) {\r\n let p = loopPoints1[0], val = iCurve2(p.x, p.y), lastVal;\r\n const iss = [];\r\n for (let i = 0; i < loopPoints1.length; i++) {\r\n lastVal = val;\r\n p = loopPoints1[i];\r\n val = iCurve2(p.x, p.y);\r\n if (val * lastVal <= 0) {\r\n // TODO < ?\r\n iss.push(newtonIterate2d(iCurve1, iCurve2, p.x, p.y));\r\n }\r\n }\r\n return iss;\r\n}\r\n// export function intersectionPCurveISurface(\r\n// \tparametricCurve: Curve,\r\n// \tsearchStart: number,\r\n// \tsearchEnd: number,\r\n// \tsearchStep: number,\r\n// \timplicitSurface: ImplicitSurface,\r\n// ) {\r\n// \tassertNumbers(searchStart, searchEnd, searchStep)\r\n// \tconst iss = []\r\n// \tlet val = implicitSurface(parametricCurve(searchStart)),\r\n// \t\tlastVal\r\n// \tfor (let t = searchStart + searchStep; t <= searchEnd; t += searchStep) {\r\n// \t\tlastVal = val\r\n// \t\tval = implicitSurface(parametricCurve(t))\r\n// \t\tif (val * lastVal <= 0) {\r\n// \t\t\tiss.push(newtonIterate1d(t => implicitSurface(parametricCurve(t)), t))\r\n// \t\t}\r\n// \t}\r\n// \treturn iss\r\n// }\r\nexport function cassini(a, c) {\r\n return (x, y) => (x * x + y * y) * (x * x + y * y) -\r\n 2 * c * c * (x * x - y * y) -\r\n (Math.pow(a, 4) - Math.pow(c, 4));\r\n}\r\nexport var MathFunctionR2R;\r\n(function (MathFunctionR2R) {\r\n function forNerdamer(expression, args = [\"x\", \"y\"]) {\r\n const ndf = nerdamer(expression);\r\n const ndfs = nerdamer.diff(ndf, args[0]);\r\n const ndft = nerdamer.diff(ndf, args[1]);\r\n const f = ndf.buildFunction(args);\r\n f.x = ndfs.buildFunction(args);\r\n f.y = ndft.buildFunction(args);\r\n f.xx = nerdamer.diff(ndfs, args[0]).buildFunction(args);\r\n f.xy = nerdamer.diff(ndfs, args[1]).buildFunction(args);\r\n f.yy = nerdamer.diff(ndft, args[1]).buildFunction(args);\r\n return f;\r\n }\r\n MathFunctionR2R.forNerdamer = forNerdamer;\r\n function nerdamerToR2_R(expression, args = [\"x\", \"y\"]) {\r\n return expression.buildFunction(args);\r\n }\r\n MathFunctionR2R.nerdamerToR2_R = nerdamerToR2_R;\r\n function forFFxFy(f, fx, fy) {\r\n ;\r\n f.x = fx;\r\n f.y = fy;\r\n return f;\r\n }\r\n MathFunctionR2R.forFFxFy = forFFxFy;\r\n})(MathFunctionR2R || (MathFunctionR2R = {}));\r\nexport const cas2 = cassini(0.9, 1.02);\r\nexport function arrayLerp(lerp, arr, t) {\r\n if (0 === t % 1)\r\n return arr[t];\r\n return lerp(arr[Math.floor(t)], arr[Math.ceil(t)], t % 1);\r\n}\r\n//# sourceMappingURL=BRep.js.map","import { assert } from \"ts3dutils\";\r\nimport { getGlobalId } from \".\";\r\nexport function doNotSerialize(target, key) {\r\n const map = target.__SERIALIZATION_BLACKLIST || (target.__SERIALIZATION_BLACKLIST = {});\r\n map[key] = \"no\";\r\n}\r\nexport class ClassSerializer {\r\n constructor() {\r\n this.CLASS_NAMES = new Map();\r\n this.NAME_CLASSES = new Map();\r\n this.addClass(\"Object\", Object);\r\n }\r\n addClass(name, clazz) {\r\n if (this.NAME_CLASSES.has(name)) {\r\n throw new Error(name);\r\n }\r\n this.NAME_CLASSES.set(name, clazz);\r\n this.CLASS_NAMES.set(clazz, name);\r\n return this;\r\n }\r\n addNamespace(namespace, namespaceName) {\r\n Object.keys(namespace).forEach((symbol) => {\r\n const o = namespace[symbol];\r\n if (\"function\" == typeof o && o.name) {\r\n this.addClass((namespaceName ? namespaceName + \".\" : \"\") + symbol, o);\r\n }\r\n });\r\n return this;\r\n }\r\n setUpdater(f) {\r\n this.updater = f;\r\n return this;\r\n }\r\n serialize(v) {\r\n return JSON.stringify(this.serializeObj(v));\r\n }\r\n serializeObj(v) {\r\n const path = [];\r\n const gatherList = (v) => {\r\n //console.log(path.toString())\r\n if (undefined !== v &&\r\n v.hasOwnProperty(\"constructor\") &&\r\n this.CLASS_NAMES.has(v.constructor)) {\r\n // do nothing, this is a class/function prototype\r\n }\r\n else if (Array.isArray(v)) {\r\n if (visited.has(v)) {\r\n if (!listMap.has(v)) {\r\n listMap.set(v, resultList.length);\r\n resultList.push(v);\r\n }\r\n }\r\n else {\r\n visited.add(v);\r\n for (let i = 0; i < v.length; i++) {\r\n path.push(\"\" + i);\r\n gatherList(v[i]);\r\n path.pop();\r\n }\r\n }\r\n }\r\n else if (undefined !== v && \"object\" == typeof v) {\r\n if (visited.has(v)) {\r\n if (!listMap.has(v)) {\r\n listMap.set(v, resultList.length);\r\n resultList.push(v);\r\n }\r\n }\r\n else {\r\n assert(!v.__noxTarget || !visited.has(v.__noxTarget));\r\n assert(!v.__noxProxy || !visited.has(v.__noxProxy));\r\n visited.add(v);\r\n if (!v.getConstructorParameters) {\r\n for (const key of Object.keys(v).sort()) {\r\n if (key == \"__noxProxy\" || key == \"__noxTarget\")\r\n continue;\r\n if (!v.__SERIALIZATION_BLACKLIST ||\r\n !v.__SERIALIZATION_BLACKLIST[key]) {\r\n path.push(key);\r\n gatherList(v[key]);\r\n path.pop();\r\n }\r\n }\r\n }\r\n path.push(\"proto\");\r\n gatherList(Object.getPrototypeOf(v));\r\n path.pop();\r\n }\r\n }\r\n };\r\n const transform = (v, allowLinks, first) => {\r\n if (\"string\" == typeof v ||\r\n \"number\" == typeof v ||\r\n \"boolean\" == typeof v ||\r\n null === v) {\r\n return v;\r\n }\r\n if (\"undefined\" == typeof v) {\r\n return { \"#REF\": -1 };\r\n }\r\n if (v.hasOwnProperty(\"constructor\") &&\r\n this.CLASS_NAMES.has(v.constructor)) {\r\n return { \"#REF\": this.CLASS_NAMES.get(v.constructor) };\r\n }\r\n let index;\r\n if (allowLinks && !first && undefined !== (index = listMap.get(v))) {\r\n return { \"#REF\": index };\r\n }\r\n if (Array.isArray(v)) {\r\n return v.map((x) => transform(x, allowLinks));\r\n }\r\n //if (mobx && mobx.isObservableArray(v)) {\r\n //\tconst result = {'#PROTO': 'ObservableArray'} as any\r\n //\tv.forEach((val, i) => result[i] = transform(val))\r\n //\treturn result\r\n //}\r\n if (\"object\" == typeof v) {\r\n if (v.getConstructorParameters) {\r\n return {\r\n \"#CONSTRUCTOR\": this.CLASS_NAMES.get(v.constructor),\r\n \"#ARGS\": transform(v.getConstructorParameters(), false),\r\n };\r\n }\r\n const result = {};\r\n if (Object.prototype !== Object.getPrototypeOf(v)) {\r\n result[\"#PROTO\"] = transform(Object.getPrototypeOf(v), allowLinks);\r\n }\r\n for (const key of Object.keys(v)) {\r\n if (key == \"__noxProxy\" || key == \"__noxTarget\")\r\n continue;\r\n if (!v.__SERIALIZATION_BLACKLIST ||\r\n !v.__SERIALIZATION_BLACKLIST[key]) {\r\n result[key] = transform(v[key], allowLinks);\r\n }\r\n }\r\n return result;\r\n }\r\n throw new Error(\"?\" + typeof v + v.toString());\r\n };\r\n const visited = new Set();\r\n const listMap = new Map();\r\n let resultList = [];\r\n listMap.set(v, 0);\r\n resultList.push(v);\r\n gatherList(v);\r\n resultList = resultList.map((v) => transform(v, true, true));\r\n return resultList;\r\n }\r\n unserialize(string) {\r\n let depth = 0;\r\n const fixObject = (v, onReady) => {\r\n depth++;\r\n if (depth > 100)\r\n throw new Error();\r\n if (v && v.constructor === Array) {\r\n onReady(v);\r\n for (let i = 0; i < v.length; i++) {\r\n fixObject(v[i], (x) => (v[i] = x));\r\n }\r\n }\r\n else if (\"object\" == typeof v && undefined != v) {\r\n if (\"#CONSTRUCTOR\" in v) {\r\n const protoName = v[\"#CONSTRUCTOR\"];\r\n const proto = this.NAME_CLASSES.get(protoName);\r\n assert(proto, protoName + \" Missing \");\r\n let args = undefined;\r\n fixObject(v[\"#ARGS\"], (x) => (args = x));\r\n onReady(new proto(...args));\r\n }\r\n else if (\"#REF\" in v) {\r\n const ref = v[\"#REF\"];\r\n if (\"string\" == typeof ref) {\r\n onReady(this.NAME_CLASSES.get(ref).prototype);\r\n }\r\n else if (\"number\" == typeof ref) {\r\n if (-1 == ref) {\r\n onReady(undefined);\r\n }\r\n else if (fixedObjects[ref]) {\r\n onReady(fixedObjects[ref]);\r\n }\r\n else {\r\n fixObject(tree[ref], (x) => onReady((fixedObjects[ref] = x)));\r\n }\r\n }\r\n }\r\n else {\r\n let result;\r\n if (\"#PROTO\" in v) {\r\n fixObject(v[\"#PROTO\"], (x) => {\r\n result = Object.create(x);\r\n onReady(result);\r\n });\r\n }\r\n else {\r\n onReady((result = v));\r\n }\r\n const keys = Object.keys(v);\r\n for (let i = 0; i < keys.length; i++) {\r\n //if ('name' == keys[i]) console.log(result)\r\n if (\"#PROTO\" != keys[i]) {\r\n fixObject(v[keys[i]], (x) => (result[keys[i]] = x));\r\n //Object.defineProperty(result, keys[i], {\r\n //\tvalue: fixObjects(v[keys[i]]),\r\n //\tenumerable: true,\r\n //\twritable: true,\r\n //\tconfigurable: true\r\n //})\r\n }\r\n }\r\n Object.defineProperty(result, \"loadID\", {\r\n value: getGlobalId(),\r\n enumerable: false,\r\n writable: false,\r\n });\r\n this.updater && this.updater(result);\r\n }\r\n }\r\n else {\r\n onReady(v);\r\n }\r\n depth--;\r\n };\r\n // const linkReferences = (v: any) => {\r\n // \tif (v && v.constructor === Array) {\r\n // \t\tfor (let i = 0; i < v.length; i++) {\r\n // \t\t\tv[i] = linkReferences(v[i])\r\n // \t\t}\r\n // \t\treturn v\r\n // \t} else if ('object' == typeof v && undefined != v) {\r\n // \t\tif ('#REF' in v) {\r\n // \t\t\treturn tree[v['#REF']]\r\n // \t\t} else {\r\n // \t\t\tconst keys = Object.keys(v)\r\n // \t\t\tfor (let i = 0; i < keys.length; i++) {\r\n // \t\t\t\tv[keys[i]] = linkReferences(v[keys[i]])\r\n // \t\t\t}\r\n // \t\t\treturn v\r\n // \t\t}\r\n // \t} else {\r\n // \t\treturn v\r\n // \t}\r\n // }\r\n const tree = JSON.parse(string);\r\n // console.log(tree)\r\n const fixedObjects = new Array(tree.length);\r\n fixObject({ \"#REF\": 0 }, () => { });\r\n // console.log(tree)\r\n // linkReferences(tree)\r\n // console.log(tree)\r\n return fixedObjects[0];\r\n }\r\n}\r\n//# sourceMappingURL=ClassSerializer.js.map","export const fragmentShaderLighting = `\n\tprecision highp float;\n\tuniform vec4 color;\n\tuniform vec3 camPos;\n\tvarying vec3 normal;\n\tvarying vec4 vPosition;\n\tvoid main() {\n\t\tvec3 normal1 = normalize(normal);\n\t\tvec3 lightPos = vec3(1000, 2000, 4000);\n\t\tvec3 lightDir = normalize(vPosition.xyz - lightPos);\n vec3 reflectionDirection = reflect(lightDir, normal1);\n vec3 eyeDirection = normalize(camPos.xyz-vPosition.xyz);\n float uMaterialShininess = 256.0;\n\t\tfloat specularLightWeighting = pow(max(dot(reflectionDirection, eyeDirection), 0.0), uMaterialShininess);\n\t\tfloat lightIntensity = 0.6 + 0.2 * max(0.0, -dot(lightDir, normal1)) + 0.2*specularLightWeighting;\n\t\tgl_FragColor = vec4(vec3(color) * lightIntensity, 1);\n\t}\n`;\r\nexport const vertexShaderLighting = `\n\tuniform mat4 ts_ModelViewProjectionMatrix;\n\tuniform mat4 ts_ModelViewMatrix;\n\tattribute vec4 ts_Vertex;\n\tuniform mat3 ts_NormalMatrix;\n\tattribute vec3 ts_Normal;\n\tuniform vec4 color;\n\tvarying vec3 normal;\n\tvarying vec4 vPosition;\n\tvoid main() {\n\t\tgl_Position = ts_ModelViewProjectionMatrix * ts_Vertex;\n vPosition = ts_ModelViewMatrix * ts_Vertex;\n\t\tnormal = normalize(ts_NormalMatrix * ts_Normal);\n\t}\n`;\r\nexport const vertexShaderWaves = `\n\tuniform mat4 ts_ModelViewProjectionMatrix;\n\tuniform mat4 ts_ModelViewMatrix;\n\tattribute vec4 ts_Vertex;\n\tuniform mat3 ts_NormalMatrix;\n\tattribute vec3 ts_Normal;\n\tuniform vec4 color;\n\tvarying vec3 normal;\n\tvarying vec4 vPosition;\n\tvoid main() {\n\t\tnormal = normalize(ts_NormalMatrix * ts_Normal);\n\t\tfloat offset = mod (((ts_Vertex.x + ts_Vertex.y + ts_Vertex.z) * 31.0), 20.0) - 10.0;\n\t\tvec4 modPos = ts_Vertex + vec4(normal * offset, 0);\n\t\tgl_Position = ts_ModelViewProjectionMatrix * modPos;\n vPosition = ts_ModelViewMatrix * modPos;\n\t}\n`;\r\nexport const vertexShader = `\n\tvarying vec4 pos;\n\tvoid main() {\n\t\tpos = vec4(position,1.0);\n\t\tgl_Position = projectionMatrix *\n\t\t\tmodelViewMatrix *\n\t\t\tvec4(position,1.0);\n\t}\n`;\r\nexport const fragmentShader = `\n\tprecision highp float;\n\tuniform vec3 color;\n\tvarying vec4 pos;\n\tvoid main() {\n\t\tfloat distance = pos.x * pos.x + pos.y * pos.y;\n\t\tif (distance <= 0.98) {\n\t\t\tgl_FragColor = vec4(color, 1.0);\n\t\t} else if (distance <= 1.0) {\n\t\t\tgl_FragColor = vec4(color, 0.5);\n\t\t} else {\n\t\t\tgl_FragColor = vec4(0.0, 0.0, 0.0, 0.0);\n\t\t}\n\t}\n\t/*\n\t precision mediump float;\n\n\t varying vec4 pos;\n\n\n\t void main() {\n\t float inside = pos.r * pos.r + pos.g * pos.g;\n\t if (inside <= 1) {\n\t gl_FragColor = vec4(0.0, 1.0, 0.0, 1.0);\n\t } else {\n\t gl_FragColor = vec4(0.0, 0.0, 0.0, 0.0);\n\t }\n\t }\n\t */\n`;\r\nexport const vertexShaderBasic = `\n\tuniform mat4 ts_ModelViewProjectionMatrix;\n\tattribute vec4 ts_Vertex;\n\tvoid main() {\n\t\tgl_Position = ts_ModelViewProjectionMatrix * ts_Vertex;\n\t}\n`;\r\nexport const vertexShaderColor = `\n\tuniform mat4 ts_ModelViewProjectionMatrix;\n\tattribute vec4 ts_Vertex;\n\tattribute vec4 ts_Color;\n\tvarying vec4 fragColor;\n\tvoid main() {\n\t\tgl_Position = ts_ModelViewProjectionMatrix * ts_Vertex;\n\t\tfragColor = ts_Color;\n\t}\n`;\r\nexport const vertexShaderArc = `\n\tuniform mat4 ts_ModelViewProjectionMatrix;\n\tattribute vec4 ts_Vertex;\n\tuniform float step, offset;\n\tuniform float radius, width;\n\tvoid main() {\n\t\tfloat r = radius;\n\t\tfloat t = offset + ts_Vertex.x * step;\n\t\tfloat pRadius = r - ts_Vertex.y * width;\n\t\tvec4 p = vec4(pRadius * cos(t), pRadius * sin(t), 0, 1);\n\t\tgl_Position = ts_ModelViewProjectionMatrix * p;\n}\n`;\r\nexport const vertexShaderConic3d = `\n\tuniform mat4 ts_ModelViewProjectionMatrix;\n\tattribute vec4 ts_Vertex;\n\tuniform float startT, endT, scale;\n\tuniform vec3 center, f1, f2;\n\tuniform int mode;\n\tfloat sinh(float x) { return (exp(x) - exp(-x)) / 2.0; }\n\tfloat cosh(float x) { return (exp(x) + exp(-x)) / 2.0; }\n\tvoid main() {\n\t\tfloat t = startT + ts_Vertex.x * (endT - startT);\n\n\t\tvec3 normal = normalize(cross(f1, f2));\n\n\t\tvec3 p, tangent;\n\t\tif (0 == mode) { // ellipse\n\t\t\tp = center + f1 * cos(t) + f2 * sin(t);\n\t\t\ttangent = f1 * -sin(t) + f2 * cos(t);\n\t\t}\n\t\tif (1 == mode) { // parabola\n\t\t\tp = center + f1 * t + f2 * t * t;\n\t\t\ttangent = f1 + 2.0 * f2 * t;\n\t\t}\n\t\tif (2 == mode) { // hyperbola\n\t\t\tp = center + f1 * cosh(t) + f2 * sinh(t);\n\t\t\ttangent = f1 * sinh(t) + f2 * cosh(t);\n\t\t}\n\t\tvec3 outDir = normalize(cross(normal, tangent));\n\t\tvec3 p2 = p + scale * (outDir * ts_Vertex.y + normal * ts_Vertex.z);\n\t\tgl_Position = ts_ModelViewProjectionMatrix * vec4(p2, 1);\n\t}\n`;\r\nexport const vertexShaderNURBS = `#version 300 es\n\tuniform mat4 ts_ModelViewProjectionMatrix;\n\tin vec4 ts_Vertex;\n\tuniform float startT, endT, scale;\n\tuniform vec4 points[32];\n\tuniform int pointCount, degree;\n\tuniform float knots[40];\n\tuniform vec3 normal;\n\tconst int MIN_DEGREE = 1;\n\tconst int MAX_DEGREE = 6;\n\t\n\tint tInterval(float t) {\n\t\tfor (int s = degree; s < 40 - 1 - degree; s++) {\n\t\t\tif (t >= knots[s] && t <= knots[s + 1]) {\n\t\t\t\treturn s;\n\t\t\t}\n\t\t}\n\t}\n\t\n\tvec4 stepp(int k, int i, vec4 dkMinus1iMinus1, vec4 dkMinus1i) {\n\t return dkMinus1i - dkMinus1iMinus1 * float(k) / (knots[i + degree - k] - knots[i - 1]);\n\t}\n\t\n\tvoid main() {\n\t\t// ts_Vertex.x is in [0, 1]\n\t\tfloat t = startT + ts_Vertex.x * (endT - startT);\n\t\t\n\t\tint s = tInterval(t);\n\t\t\n\t\tvec4 v[MAX_DEGREE + 1];\n\t\tfor (int i = 0; i < degree + 1; i++) {\n\t\t v[i] = points[s - degree + i];\n\t\t}\n\t\t\n\t\tvec4 pTangent4, ddt4 = vec4(0, 0, 1, 0);\n\t\tfor (int level = 0; level < degree; level++) {\n\t\t\tif (level == degree - 2) {\n\t\t\t\t// see https://www.globalspec.com/reference/61012/203279/10-8-derivatives\n\t\t\t\tvec4 a = v[degree];\n\t\t\t\tvec4 b = v[degree - 1];\n\t\t\t\tvec4 c = v[degree - 2];\n\t\t\t\tddt4 = stepp(degree, s + 1, stepp(degree - 1, s + 1, a, b), stepp(degree - 1, s, b, c));\n\t\t\t}\n\t\t\tif (level == degree - 1) {\n\t\t\t\tvec4 a = v[degree];\n\t\t\t\tvec4 b = v[degree - 1];\n\t\t\t\tpTangent4 = (b - a) * (float(degree) / (knots[s] - knots[s + 1]));\n\t\t\t}\n\t\t\tfor (int i = degree; i > level; i--) {\n\t\t\t\tfloat alpha = (t - knots[i + s - degree]) / (knots[i + s - level] - knots[i + s - degree]);\n\n\t\t\t\t// interpolate each component\n v[i] = (1.0 - alpha) * v[i - 1] + alpha * v[i];\n\t\t\t}\n\t\t}\n\t\t\n\t\tvec4 p4 = v[degree];\n\t\t\n\t\tvec3 p = p4.xyz / p4.w;\n\t\tvec3 pTangent = ((pTangent4.xyz * p4.w) - (p4.xyz * pTangent4.w)) / (p4.w * p4.w);\n\t\tvec3 ddt = (\n\t\t p4.xyz * (-p4.w * ddt4.w + 2.0 * pow(pTangent4.w, 2.0))\n\t\t + pTangent4.xyz * (-2.0 * p4.w * pTangent4.w) \n\t\t + ddt4.xyz * pow(p4.w, 2.0)\n ) / pow(p4.w, 3.0);\n\t\t\n\t\tvec3 outDir = normalize(cross(ddt, pTangent));\n\t\tvec3 correctNormal = normalize(cross(pTangent, outDir));\n\t\tvec3 p2 = p + scale * (outDir * ts_Vertex.y + correctNormal * ts_Vertex.z);\n\t\tgl_Position = ts_ModelViewProjectionMatrix * vec4(p2, 1);\n }\n`;\r\nexport const vertexShaderBezier = `\n // calculates a bezier curve using ts_Vertex.x as the (t) parameter of the curve\n\tuniform mat4 ts_ModelViewProjectionMatrix;\n\tattribute vec4 ts_Vertex;\n\tuniform float width, startT, endT;\n\tuniform vec3 p0, p1, p2, p3;\n\tvoid main() {\n\t\t// ts_Vertex.x is in [0, 1]\n\t\tfloat t = startT + ts_Vertex.x * (endT - startT), s = 1.0 - t;\n\t\tfloat c0 = s * s * s, c1 = 3.0 * s * s * t, c2 = 3.0 * s * t * t, c3 = t * t * t;\n\t\tvec3 pPos = p0 * c0 + p1 * c1 + p2 * c2 + p3 * c3;\n\t\tfloat c01 = 3.0 * s * s, c12 = 6.0 * s * t, c23 = 3.0 * t * t;\n\t\tvec3 pTangent = (p1 - p0) * c01 + (p2 - p1) * c12 + (p3 - p2) * c23;\n\t\tvec3 pNormal = normalize(vec3(pTangent.y, -pTangent.x, 0));\n\t\tvec4 p = vec4(pPos - ts_Vertex.y * width * pNormal, 1);\n\t\tgl_Position = ts_ModelViewProjectionMatrix * p;\n\t}\n`;\r\nexport const vertexShaderBezier3d = `\n precision highp float;\n // calculates a bezier curve using ts_Vertex.x as the (t) parameter of the curve\n\tuniform float scale, startT, endT;\n\tuniform vec3 ps[4];\n\tuniform vec3 p0, p1, p2, p3, normal;\n\tuniform mat4 ts_ModelViewProjectionMatrix;\n\tattribute vec4 ts_Vertex;\n\tvoid main() {\n\t\t// ts_Vertex.y is in [0, 1]\n\t\tvec3 p5 = ps[0];\n\t\tfloat t = startT * (1.0 - ts_Vertex.x) + endT * ts_Vertex.x, s = 1.0 - t;\n\t\tfloat c0 = s * s * s, \n\t\t c1 = 3.0 * s * s * t, \n\t\t c2 = 3.0 * s * t * t, c3 = t * t * t;\n\t\tvec3 p = (p0 * c0 + p1 * c1) + (p2 * c2 + p3 * c3);\n\t\tfloat c01 = 3.0 * s * s, \n\t\t c12 = 6.0 * s * t, \n\t\t c23 = 3.0 * t * t;\n\t\tvec3 pTangent = (p1 - p0) * c01 + (p2 - p1) * c12 + (p3 - p2) * c23;\n\t\tvec3 outDir = normalize(cross(normal, pTangent));\n\t\tvec3 correctNormal = normalize(cross(pTangent, outDir));\n\t\tvec3 p2 = p + scale * (outDir * ts_Vertex.y + correctNormal * ts_Vertex.z);\n\t\tgl_Position = ts_ModelViewProjectionMatrix * vec4(p2, 1);\n\t}\n`;\r\nexport const vertexShaderGeneric = `\n\tuniform float scale;\n\tuniform mat4 ts_ModelViewProjectionMatrix;\n\tattribute vec4 ts_Vertex;\n\tuniform mat3 ts_NormalMatrix;\n\tattribute vec3 ts_Normal;\n\tvoid main() {\n\t\tvec3 normal = normalize(ts_NormalMatrix * ts_Normal);\n\t\tvec4 vertexPos = ts_Vertex + vec4(normal * scale, 0);\n\t\tgl_Position = ts_ModelViewProjectionMatrix * vertexPos;\n\t}\n`;\r\nexport const vertexShaderRing = `\n\t#define M_PI 3.1415926535897932384626433832795\n\tuniform float step;\n\tuniform float innerRadius, outerRadius;\n\tattribute float index;\n\tuniform mat4 ts_ModelViewProjectionMatrix;\n\tattribute vec4 ts_Vertex;\n\tvoid main() {\n\t\tgl_Position = ts_ModelViewProjectionMatrix * vec4(index, index, index, 1);\n\t\tfloat id = atan(ts_Vertex.x, ts_Vertex.y) / M_PI * 32.0;\n\t\tfloat radius = mod(id, 2.0) < 1.0 ? outerRadius : innerRadius;\n\t\tgl_Position = ts_ModelViewProjectionMatrix * vec4(radius * cos(index * step), radius * sin(index * step), 0, 1);\n\t}\n`;\r\nexport const fragmentShaderColor = `\n\tprecision highp float;\n\tuniform vec4 color;\n\tvoid main() {\n\t\tgl_FragColor = color;\n\t}\n`;\r\nexport const fragmentShaderColor3 = `#version 300 es\n\tprecision highp float;\n\tuniform vec4 color;\n\tout vec4 fragColor;\n\tvoid main() {\n\t\tfragColor = color;\n\t}\n`;\r\nexport const fragmentShaderVaryingColor = `\n\tprecision highp float;\n\tvarying vec4 fragColor;\n\tvoid main() {\n\t\tgl_FragColor = fragColor;\n\t}\n`;\r\nexport const fragmentShaderColorHighlight = `\n\tprecision highp float;\n\tuniform vec4 color;\n\tvoid main() {\n\t\tfloat diagonal = (gl_FragCoord.x + 2.0 * gl_FragCoord.y);\n\t\tif (mod(diagonal, 50.0) > 40.0) { // mod(diagonal, 2.0) > 1.0\n\t\t\tdiscard;\n\t\t\t//gl_FragColor = color + vec4(0.2,0.2,0.2,0);\n\t\t} else {\n\t\t\tgl_FragColor = color - vec4(0.2,0.2,0.2,0);\n\t\t}\n\t}\n`;\r\nexport const vertexShaderTexture = `\n\tvarying vec2 texturePos;\n\tattribute vec4 ts_Vertex;\n\tuniform mat4 ts_ModelViewProjectionMatrix;\n\tvoid main() {\n\t\ttexturePos = ts_Vertex.xy;\n\t\tgl_Position = ts_ModelViewProjectionMatrix * ts_Vertex;\n\t}\n`;\r\nexport const fragmentShaderTextureColor = `\n\tprecision highp float;\n\tvarying vec2 texturePos;\n\tuniform vec4 color;\n\tuniform sampler2D texture;\n\tvoid main() {\n\t\tgl_FragColor = texture2D(texture, texturePos) * color;\n\t}\n`;\r\nexport const fragmentShaderTexture = `\n\tprecision highp float;\n\tvarying vec2 texturePos;\n\tuniform sampler2D texture;\n\tvoid main() {\n\t\tgl_FragColor = texture2D(texture, texturePos);\n\t}\n`;\r\n//# sourceMappingURL=shaders.js.map","import * as chroma from \"chroma.ts\";\r\nimport { addOwnProperties, arrayFromFunction, DEG, M4, TAU, V, V3, Vector, } from \"ts3dutils\";\r\nimport { GL_COLOR_BLACK, Mesh, Shader } from \"tsgl\";\r\nimport { B2T, BezierCurve, EllipseCurve, HyperbolaCurve, ImplicitCurve, L3, NURBS, ParabolaCurve, PICurve, PPCurve, } from \".\";\r\nimport { ceil, floor, pow, sign } from \"./math\";\r\nimport * as shaders from \"./shaders\";\r\nexport function parseGetParams(str) {\r\n const result = {};\r\n str.split(\"&\").forEach(function (item) {\r\n const splitIndex = item.indexOf(\"=\");\r\n if (-1 == splitIndex) {\r\n result[item] = item;\r\n }\r\n else {\r\n result[item.substr(0, splitIndex)] = decodeURI(item.substr(splitIndex + 1));\r\n }\r\n });\r\n return result;\r\n}\r\nexport const COLORS = {\r\n RD_FILL: chroma.color(\"#9EDBF9\"),\r\n RD_STROKE: chroma.color(\"#77B0E0\"),\r\n TS_FILL: chroma.color(\"#D19FE3\"),\r\n TS_STROKE: chroma.color(\"#A76BC2\"),\r\n PP_FILL: chroma.color(\"#F3B6CF\"),\r\n PP_STROKE: chroma.color(\"#EB81B4\"),\r\n};\r\nexport class BREPGLContext {\r\n constructor(gl) {\r\n this.cachedMeshes = new WeakMap();\r\n this.shaders = initShaders(gl);\r\n initMeshes((this.meshes = {}), gl);\r\n }\r\n static create(gl) {\r\n addOwnProperties(gl, BREPGLContext.prototype);\r\n addOwnProperties(gl, new BREPGLContext(gl));\r\n return gl;\r\n }\r\n drawPoint(p, color = GL_COLOR_BLACK, size = 5) {\r\n this.pushMatrix();\r\n this.translate(p);\r\n this.scale(size / 2, size / 2, size / 2);\r\n this.shaders.singleColor\r\n .uniforms({ color: color })\r\n .draw(this.meshes.sphere1);\r\n this.popMatrix();\r\n }\r\n drawEdge(edge, color = GL_COLOR_BLACK, width = 2) {\r\n CURVE_PAINTERS[edge.curve.constructor.name](this, edge.curve, color, edge.minT, edge.maxT, width);\r\n }\r\n drawCurve(curve, color = GL_COLOR_BLACK, width = 2, tStart, tEnd) {\r\n CURVE_PAINTERS[curve.constructor.name](this, curve, color, tStart, tEnd, width);\r\n }\r\n drawVector(vector, anchor, color = GL_COLOR_BLACK, size = 1) {\r\n if (vector.likeO())\r\n return;\r\n this.pushMatrix();\r\n const headLength = size * 4;\r\n if (headLength > vector.length())\r\n return;\r\n const vT = vector.getPerpendicular().unit();\r\n this.multMatrix(M4.forSys(vector.unit(), vT, vector.cross(vT).unit(), anchor));\r\n this.scale(vector.length() - headLength, size / 2, size / 2);\r\n this.shaders.singleColor\r\n .uniforms({\r\n color: color,\r\n })\r\n .draw(this.meshes.vectorShaft);\r\n this.scale(1 / (vector.length() - headLength), 1, 1);\r\n this.translate(vector.length() - headLength, 0, 0);\r\n this.scale(headLength / 2, 1, 1);\r\n this.shaders.singleColor.draw(this.meshes.vectorHead);\r\n this.popMatrix();\r\n }\r\n drawVectors(drVs, size = undefined) {\r\n this.drawVector(V3.X, V3.O, chroma.color(\"red\").gl(), size);\r\n this.drawVector(V3.Y, V3.O, chroma.color(\"green\").gl(), size);\r\n this.drawVector(V3.Z, V3.O, chroma.color(\"blue\").gl(), size);\r\n drVs.forEach((vi) => this.drawVector(vi.v, vi.anchor, vi.color, size));\r\n }\r\n drawPlane(customPlane, color, dotted = false) {\r\n this.pushMatrix();\r\n this.multMatrix(M4.forSys(customPlane.right, customPlane.up, customPlane.normal1, customPlane.anchor));\r\n this.translate(customPlane.uMin, customPlane.vMin, 0);\r\n this.scale(customPlane.uMax - customPlane.uMin, customPlane.vMax - customPlane.vMin, 1);\r\n const mesh = dotted\r\n ? this.meshes.xyDottedLinePlane\r\n : this.meshes.xyLinePlane;\r\n this.shaders.singleColor.uniforms({ color: color }).draw(mesh, this.LINES);\r\n this.popMatrix();\r\n }\r\n drawBox(m4, color) {\r\n this.pushMatrix();\r\n this.multMatrix(m4.m[15] >= 0 ? m4 : m4.mulScalar(-1));\r\n if (color) {\r\n this.shaders.singleColor\r\n .uniforms({ color: color })\r\n .draw(this.meshes.cube, this.LINES);\r\n }\r\n else {\r\n this.shaders.multiColor.draw(this.meshes.cube, this.LINES);\r\n }\r\n this.popMatrix();\r\n }\r\n}\r\nfunction conicPainter(mode, gl, ellipse, color, startT, endT, width = 2) {\r\n gl.shaders.ellipse3d\r\n .uniforms({\r\n f1: ellipse.f1,\r\n f2: ellipse.f2,\r\n center: ellipse.center,\r\n color: color,\r\n startT: startT,\r\n endT: endT,\r\n scale: width,\r\n mode: mode,\r\n })\r\n .draw(gl.meshes.pipe);\r\n}\r\nexport const CURVE_PAINTERS = {\r\n [EllipseCurve.name]: conicPainter.bind(undefined, 0),\r\n [ParabolaCurve.name]: conicPainter.bind(undefined, 1),\r\n [HyperbolaCurve.name]: conicPainter.bind(undefined, 2),\r\n [ImplicitCurve.name](gl, curve, color, startT, endT, width = 2) {\r\n let mesh = gl.cachedMeshes.get(curve);\r\n const RES = 4;\r\n if (!mesh) {\r\n mesh = new Mesh()\r\n .addIndexBuffer(\"TRIANGLES\")\r\n .addVertexBuffer(\"normals\", \"ts_Normal\");\r\n curve.addToMesh(mesh, RES);\r\n mesh.compile();\r\n gl.cachedMeshes.set(curve, mesh);\r\n }\r\n const startIndex = ceil(startT);\r\n const endIndex = floor(endT);\r\n if (startIndex <= endIndex) {\r\n const indexFactor = 2 * // no of triangles per face\r\n RES * // no of faces\r\n 3; // no of indexes per triangle\r\n gl.shaders.generic3d\r\n .uniforms({\r\n color: color,\r\n scale: width,\r\n })\r\n .draw(mesh, gl.TRIANGLES, startIndex * indexFactor, (floor(endT) - startIndex) * indexFactor);\r\n if (startT % 1 !== 0) {\r\n const p = curve.at(startT);\r\n gl.pushMatrix();\r\n const m = M4.forSys(p.to(curve.points[startIndex]), mesh.normals[startIndex * RES].toLength(width), mesh.normals[startIndex * RES + 1].toLength(width), p);\r\n gl.multMatrix(m);\r\n gl.shaders.singleColor\r\n .uniforms({ color: color })\r\n .draw(gl.meshes.pipeSegmentForICurve);\r\n console.log(gl.meshes.pipeSegmentForICurve);\r\n gl.popMatrix();\r\n }\r\n if (endT % 1 !== 0) {\r\n const p = curve.at(endT);\r\n gl.pushMatrix();\r\n const m = M4.forSys(curve.points[endIndex].to(p), mesh.normals[endIndex * RES].toLength(width), mesh.normals[endIndex * RES + 1].toLength(width), curve.points[endIndex]);\r\n gl.multMatrix(m);\r\n gl.shaders.singleColor\r\n .uniforms({ color: color })\r\n .draw(gl.meshes.pipeSegmentForICurve);\r\n gl.popMatrix();\r\n }\r\n }\r\n else {\r\n const p1 = curve.at(startT);\r\n const p2 = curve.at(endT);\r\n gl.pushMatrix();\r\n const v0 = p1.to(p2), v1 = v0.getPerpendicular().toLength(width), v2 = v0.cross(v1).toLength(width);\r\n const m = M4.forSys(v0, v1, v2, p1);\r\n gl.multMatrix(m);\r\n gl.shaders.singleColor\r\n .uniforms({ color: color })\r\n .draw(gl.meshes.pipeSegmentForICurve);\r\n gl.popMatrix();\r\n }\r\n },\r\n [BezierCurve.name](gl, curve, color, startT, endT, width = 2, normal = V3.Z) {\r\n gl.shaders.bezier3d\r\n .uniforms({\r\n p0: curve.p0,\r\n p1: curve.p1,\r\n p2: curve.p2,\r\n p3: curve.p3,\r\n color: color,\r\n startT: startT,\r\n endT: endT,\r\n scale: width,\r\n normal: normal,\r\n })\r\n .draw(gl.meshes.pipe);\r\n },\r\n [NURBS.name](gl, curve, color, startT, endT, width = 2, normal = V3.Z) {\r\n gl.shaders.nurbs\r\n .uniforms({\r\n \"points[0]\": Vector.pack(curve.points),\r\n degree: curve.degree,\r\n \"knots[0]\": curve.knots,\r\n color: color,\r\n startT: startT,\r\n endT: endT,\r\n scale: width,\r\n normal: normal,\r\n })\r\n .draw(gl.meshes.pipe);\r\n },\r\n [L3.name](gl, curve, color, startT, endT, width = 2, normal = V3.Z) {\r\n gl.pushMatrix();\r\n const a = curve.at(startT), b = curve.at(endT);\r\n const ab = b.minus(a), abT = ab.getPerpendicular().unit();\r\n const m = M4.forSys(ab, abT, ab.cross(abT).unit(), a);\r\n gl.multMatrix(m);\r\n gl.scale(1, width, width);\r\n gl.shaders.singleColor\r\n .uniforms({\r\n color: color,\r\n })\r\n .draw(gl.meshes.pipe);\r\n gl.popMatrix();\r\n },\r\n};\r\nCURVE_PAINTERS[PICurve.name] = CURVE_PAINTERS[ImplicitCurve.name];\r\nCURVE_PAINTERS[PPCurve.name] = CURVE_PAINTERS[ImplicitCurve.name];\r\nexport function initMeshes(_meshes, _gl) {\r\n _gl.makeCurrent();\r\n _meshes.cube = (() => {\r\n const cube = B2T.box().toMesh().addVertexBuffer(\"colors\", \"ts_Color\");\r\n cube.colors = cube.vertices.map((p) => [p.x, p.y, p.z, 1].map((x) => x * 0.9));\r\n cube.compile();\r\n return cube;\r\n })();\r\n _meshes.sphere1 = Mesh.sphere(2);\r\n _meshes.segment = Mesh.plane({ startY: -0.5, height: 1, detailX: 128 });\r\n _meshes.text = Mesh.plane();\r\n _meshes.vector = Mesh.rotation([V3.O, V(0, 0.05, 0), V(0.8, 0.05), V(0.8, 0.1), V(1, 0)], L3.X, TAU, 16, true);\r\n _meshes.vectorShaft = Mesh.rotation([V3.O, V3.Y, V3.XY], L3.X, TAU, 8, true);\r\n _meshes.vectorHead = Mesh.rotation([V3.Y, V(0, 2, 0), V(2, 0, 0)], L3.X, TAU, 8, true);\r\n _meshes.pipe = Mesh.rotation(arrayFromFunction(512, (i, l) => new V3(i / (l - 1), -0.5, 0)), L3.X, TAU, 8, true);\r\n _meshes.xyLinePlane = Mesh.plane();\r\n _meshes.xyDottedLinePlane = makeDottedLinePlane();\r\n _meshes.pipeSegmentForICurve = Mesh.offsetVertices(M4.rotateY(90 * DEG).transformedPoints(arrayFromFunction(4, (i) => V3.polar(1, (TAU * i) / 4))), V3.X, true);\r\n}\r\nexport function initShaders(_gl) {\r\n _gl.makeCurrent();\r\n return {\r\n singleColor: Shader.create(shaders.vertexShaderBasic, shaders.fragmentShaderColor),\r\n multiColor: Shader.create(shaders.vertexShaderColor, shaders.fragmentShaderVaryingColor),\r\n singleColorHighlight: Shader.create(shaders.vertexShaderBasic, shaders.fragmentShaderColorHighlight),\r\n textureColor: Shader.create(shaders.vertexShaderTexture, shaders.fragmentShaderTextureColor),\r\n arc: Shader.create(shaders.vertexShaderRing, shaders.fragmentShaderColor),\r\n arc2: Shader.create(shaders.vertexShaderArc, shaders.fragmentShaderColor),\r\n ellipse3d: Shader.create(shaders.vertexShaderConic3d, shaders.fragmentShaderColor),\r\n generic3d: Shader.create(shaders.vertexShaderGeneric, shaders.fragmentShaderColor),\r\n bezier3d: Shader.create(shaders.vertexShaderBezier3d, shaders.fragmentShaderColor),\r\n nurbs: Shader.create(shaders.vertexShaderNURBS, shaders.fragmentShaderColor3),\r\n bezier: Shader.create(shaders.vertexShaderBezier, shaders.fragmentShaderColor),\r\n lighting: Shader.create(shaders.vertexShaderLighting, shaders.fragmentShaderLighting),\r\n waves: Shader.create(shaders.vertexShaderWaves, shaders.fragmentShaderLighting),\r\n };\r\n}\r\nfunction makeDottedLinePlane(count = 128) {\r\n const mesh = new Mesh().addIndexBuffer(\"LINES\");\r\n const OXvertices = arrayFromFunction(count, (i) => new V3(i / count, 0, 0));\r\n mesh.vertices.push(...OXvertices);\r\n mesh.vertices.push(...M4.forSys(V3.Y, V3.O, V3.O, V3.X).transformedPoints(OXvertices));\r\n mesh.vertices.push(...M4.forSys(V3.X.negated(), V3.O, V3.O, new V3(1, 1, 0)).transformedPoints(OXvertices));\r\n mesh.vertices.push(...M4.forSys(V3.Y.negated(), V3.O, V3.O, V3.Y).transformedPoints(OXvertices));\r\n mesh.LINES = arrayFromFunction(count * 4, (i) => i - (i >= count * 2 ? 1 : 0));\r\n mesh.compile();\r\n return mesh;\r\n}\r\nexport function initNavigationEvents(_gl, eye, paintScreen) {\r\n const canvas = _gl.canvas;\r\n let lastPos = V3.O;\r\n //_gl.onmousedown.push((e) => {\r\n //\te.preventDefault()\r\n //\te.stopPropagation()\r\n //})\r\n //_gl.onmouseup.push((e) => {\r\n //\te.preventDefault()\r\n //\te.stopPropagation()\r\n //})\r\n canvas.addEventListener(\"mousemove\", (e) => {\r\n const pagePos = V(e.pageX, e.pageY);\r\n const delta = lastPos.to(pagePos);\r\n //noinspection JSBitwiseOperatorUsage\r\n if (e.buttons & 4) {\r\n // pan\r\n const moveCamera = V((-delta.x * 2) / _gl.canvas.width, (delta.y * 2) / _gl.canvas.height);\r\n const inverseProjectionMatrix = _gl.projectionMatrix.inversed();\r\n const worldMoveCamera = inverseProjectionMatrix.transformVector(moveCamera);\r\n eye.pos = eye.pos.plus(worldMoveCamera);\r\n eye.focus = eye.focus.plus(worldMoveCamera);\r\n setupCamera(eye, _gl);\r\n paintScreen();\r\n }\r\n // scene rotation\r\n //noinspection JSBitwiseOperatorUsage\r\n if (e.buttons & 2) {\r\n const rotateLR = (-delta.x / 6.0) * DEG;\r\n const rotateUD = (-delta.y / 6.0) * DEG;\r\n // rotate\r\n let matrix = M4.rotateLine(eye.focus, eye.up, rotateLR);\r\n //let horizontalRotationAxis = focus.minus(pos).cross(up)\r\n const horizontalRotationAxis = eye.up.cross(eye.pos.minus(eye.focus));\r\n matrix = matrix.times(M4.rotateLine(eye.focus, horizontalRotationAxis, rotateUD));\r\n eye.pos = matrix.transformPoint(eye.pos);\r\n eye.up = matrix.transformVector(eye.up);\r\n setupCamera(eye, _gl);\r\n paintScreen();\r\n }\r\n lastPos = pagePos;\r\n });\r\n canvas.addEventListener(\"wheel\", (e) => {\r\n // zoom\r\n const wheelY = -sign(e.deltaY) * 2;\r\n // console.log(e.deltaY, e.deltaX)\r\n eye.zoomFactor *= pow(0.9, -wheelY);\r\n const mouseCoordsOnCanvas = getPosOnTarget(e);\r\n const mousePosFrustrum = V((mouseCoordsOnCanvas.x * 2) / _gl.canvas.offsetWidth - 1, (-mouseCoordsOnCanvas.y * 2) / _gl.canvas.offsetHeight + 1, 0);\r\n const moveCamera = mousePosFrustrum.times(1 - 1 / pow(0.9, -wheelY));\r\n const inverseProjectionMatrix = _gl.projectionMatrix.inversed();\r\n const worldMoveCamera = inverseProjectionMatrix.transformVector(moveCamera);\r\n //console.log(\"moveCamera\", moveCamera)\r\n //console.log(\"worldMoveCamera\", worldMoveCamera)\r\n eye.pos = eye.pos.plus(worldMoveCamera);\r\n eye.focus = eye.focus.plus(worldMoveCamera);\r\n // tilt\r\n const mousePosWC = inverseProjectionMatrix.transformPoint(mousePosFrustrum);\r\n const tiltMatrix = M4.rotateLine(mousePosWC, eye.pos.to(eye.focus), -sign(e.deltaX) * 10 * DEG);\r\n eye.up = tiltMatrix.transformVector(eye.up);\r\n eye.pos = tiltMatrix.transformPoint(eye.pos);\r\n eye.focus = tiltMatrix.transformPoint(eye.focus);\r\n setupCamera(eye, _gl);\r\n paintScreen();\r\n e.preventDefault();\r\n });\r\n}\r\n/**\r\n * Transforms position on the screen into a line in world coordinates.\r\n */\r\nexport function getMouseLine(pos, _gl) {\r\n const ndc1 = V((pos.x * 2) / _gl.canvas.width - 1, (-pos.y * 2) / _gl.canvas.height + 1, 0);\r\n const ndc2 = V((pos.x * 2) / _gl.canvas.width - 1, (-pos.y * 2) / _gl.canvas.height + 1, 1);\r\n //console.log(ndc)\r\n const inverseProjectionMatrix = _gl.projectionMatrix.inversed();\r\n const s = inverseProjectionMatrix.transformPoint(ndc1);\r\n const dir = inverseProjectionMatrix.transformPoint(ndc2).minus(s);\r\n return L3.anchorDirection(s, dir);\r\n}\r\nexport function getPosOnTarget(e) {\r\n const target = e.target;\r\n const targetRect = target.getBoundingClientRect();\r\n const mouseCoordsOnElement = {\r\n x: e.clientX - targetRect.left,\r\n y: e.clientY - targetRect.top,\r\n };\r\n return mouseCoordsOnElement;\r\n}\r\nexport function setupCamera(_eye, _gl, suppressEvents = false) {\r\n const { pos, focus, up, zoomFactor } = _eye;\r\n //console.log(\"pos\", pos.$, \"focus\", focus.$, \"up\", up.$)\r\n _gl.matrixMode(_gl.PROJECTION);\r\n _gl.loadIdentity();\r\n //_gl.perspective(70, _gl.canvas.width / _gl.canvas.height, 0.1, 1000);\r\n const lr = _gl.canvas.width / 2 / zoomFactor;\r\n const bt = _gl.canvas.height / 2 / zoomFactor;\r\n _gl.ortho(-lr, lr, -bt, bt, -1e4, 1e4);\r\n _gl.lookAt(pos, focus, up);\r\n _gl.matrixMode(_gl.MODELVIEW);\r\n !suppressEvents && cameraChangeListeners.forEach((l) => l(_eye));\r\n}\r\nexport const cameraChangeListeners = [];\r\nexport const SHADERS_TYPE_VAR = false && initShaders(0);\r\n// let shaders: typeof SHADERS_TYPE_VAR\r\n// declare let a: BRep, b: BRep, c: BRep, d: BRep, edges: Edge[] = [], hovering: any,\r\n// \t, normallines: boolean = false, b2s: BRep[] = []\r\n// const\r\n//# sourceMappingURL=BREPGLContext.js.map","import { assertf, eq, floatHashCode, M4, V3 } from \"ts3dutils\";\r\nimport { acos, cos, sin } from \"./math\";\r\nexport class Quaternion {\r\n constructor(s, x, y, z) {\r\n this.s = s;\r\n this.x = x;\r\n this.y = y;\r\n this.z = z;\r\n }\r\n static axis(axis, rotation) {\r\n assertf(() => axis.hasLength(1));\r\n return new Quaternion(cos(rotation / 2), sin(rotation / 2) * axis.x, sin(rotation / 2) * axis.y, sin(rotation / 2) * axis.z);\r\n }\r\n static of(s, x, y, z) {\r\n return new Quaternion(s, x, y, z);\r\n }\r\n plus(q) {\r\n return new Quaternion(this.s + q.s, this.x + q.x, this.y + q.y, this.z + q.z);\r\n }\r\n times(q) {\r\n return \"number\" == typeof q\r\n ? new Quaternion(q * this.s, q * this.x, q * this.y, q * this.z)\r\n : new Quaternion(this.s * q.s - (this.x * q.x + this.y * q.y + this.z * q.z), this.y * q.z - this.z * q.y + this.s * q.x + q.s * this.x, this.z * q.x - this.x * q.z + this.s * q.y + q.s * this.y, this.x * q.y - this.y * q.x + this.s * q.z + q.s * this.z);\r\n }\r\n conjugated() {\r\n return new Quaternion(this.s, -this.x, -this.y, -this.z);\r\n }\r\n length() {\r\n return Math.hypot(this.s, this.x, this.y, this.z);\r\n }\r\n norm() {\r\n return Math.pow(this.s, 2) + Math.pow(this.x, 2) + (Math.pow(this.y, 2) + Math.pow(this.z, 2));\r\n }\r\n unit() {\r\n const l = this.length();\r\n return new Quaternion(this.s / l, this.x / l, this.y / l, this.z / l);\r\n }\r\n inverse() {\r\n return this.conjugated().times(1 / this.norm());\r\n }\r\n toM4() {\r\n assertf(() => eq(1, this.length()));\r\n const { s, x, y, z } = this;\r\n // prettier-ignore\r\n return new M4([\r\n 1 - 2 * (y * y + z * z), 2 * (x * y - z * s), 2 * (x * z + y * s), 0,\r\n 2 * (x * y + z * s), 1 - 2 * (x * x + z * z), 2 * (y * z - x * s), 0,\r\n 2 * (x * z - y * s), 2 * (y * z + x * s), 1 - 2 * (x * x + y * y), 0,\r\n 0, 0, 0, 1,\r\n ]);\r\n }\r\n static fromRotation(m4) {\r\n const sqrtTracePlus1 = Math.sqrt(m4.trace() + 1);\r\n const f = 1 / (2 * sqrtTracePlus1);\r\n return new Quaternion(sqrtTracePlus1 / 2, f * (m4.e(2, 1) - m4.e(1, 2)), f * (m4.e(0, 2) - m4.e(2, 0)), f * (m4.e(1, 0) - m4.e(0, 1)));\r\n }\r\n rotatePoint(p) {\r\n const v = this.times(Quaternion.of(1, p.x, p.y, p.z)).times(this.conjugated());\r\n return new V3(v.x, v.y, v.z);\r\n }\r\n like(q, precision) {\r\n return (eq(this.s, q.s, precision) &&\r\n eq(this.x, q.x, precision) &&\r\n eq(this.y, q.y, precision) &&\r\n eq(this.z, q.z, precision));\r\n }\r\n equals(q) {\r\n return (this == q ||\r\n (q instanceof Quaternion &&\r\n this.s == q.s &&\r\n this.x == q.x &&\r\n this.y == q.y &&\r\n this.z == q.z));\r\n }\r\n hashCode() {\r\n let hashCode = 0;\r\n hashCode = (hashCode * 31 + floatHashCode(this.s)) | 0;\r\n hashCode = (hashCode * 31 + floatHashCode(this.x)) | 0;\r\n hashCode = (hashCode * 31 + floatHashCode(this.y)) | 0;\r\n hashCode = (hashCode * 31 + floatHashCode(this.z)) | 0;\r\n return hashCode;\r\n }\r\n slerp(b, f) {\r\n assertf(() => eq(1, this.length()));\r\n assertf(() => eq(1, b.length()));\r\n const a = this;\r\n let dot = a.s * b.s + a.x * b.x + a.y * b.y + a.z * b.z;\r\n if (dot < 0) {\r\n dot = -dot;\r\n b = b.times(-1);\r\n console.log(\"dot < 0\");\r\n }\r\n const DOT_THRESHOLD = 0.9995;\r\n if (dot > DOT_THRESHOLD) {\r\n // If the inputs are too close for comfort, linearly interpolate\r\n // and normalize the result.\r\n return a\r\n .times(1 - f)\r\n .plus(b.times(f))\r\n .unit();\r\n }\r\n // Since dot is in range [0, DOT_THRESHOLD], acos is safe\r\n const theta0 = acos(dot); // theta_0 = angle between input vectors\r\n const theta = theta0 * f; // theta = angle between v0 and result\r\n const s0 = cos(theta) - (dot * sin(theta)) / sin(theta0); // == sin(theta_0 - theta) / sin(theta_0)\r\n const s1 = sin(theta) / sin(theta0);\r\n console.log(s0, s1, a.times(s0), b.times(s1));\r\n return a.times(s0).plus(b.times(s1));\r\n }\r\n toArray() {\r\n return [this.s, this.x, this.y, this.z];\r\n }\r\n}\r\nQuaternion.O = new Quaternion(1, 0, 0, 0);\r\n//# sourceMappingURL=Quaternion.js.map","import { Surface } from \"..\";\r\nexport class ImplicitSurface extends Surface {\r\n static is(obj) {\r\n return obj.implicitFunction && obj.didp;\r\n }\r\n}\r\n//# sourceMappingURL=ImplicitSurface.js.map"],"names":["max","L3","EllipseCurve","HyperbolaCurve","ParabolaCurve","BezierCurve","P3","dotCurve2","PPCurve","ImplicitCurve","ZDirVolumeVisitor","CalculateAreaVisitor","Surface","MathFunctionR2R","Curve","PICurve","breakDownPPCurves","ParametricSurface","CylinderSurface","PlaneSurface","ImplicitSurface","NURBS","NURBSSurface","intersectionUnitCircleLine2","ProjectedCurveSurface","OUTSIDE","PointVsFace","Edge","getExtremePointsHelper","XiEtaCurve","ConicSurface","EllipsoidSurface","RotatedCurveSurface","getGlobalId","StraightEdge","PlaneFace","Face","BRep","PCurveEdge","opentype.load","opentype.Path","edgePathFromSVG","createEdge","edgeForCurveAndTs","chroma.random","min","PI","round","EPS","fff","INSIDE","COPLANAR_SAME","splitsVolumeEnclosingFacesP","splitsVolumeEnclosingFaces","splitsVolumeEnclosingCone2","splitsVolumeEnclosingFacesP2","arrayMin","triangulateVertices","CustomSet","uvInAABB2","curvePointMF","chroma.color","B2T","shaders.vertexShaderBasic","shaders.fragmentShaderColor","shaders.vertexShaderColor","shaders.fragmentShaderVaryingColor","shaders.fragmentShaderColorHighlight","shaders.vertexShaderTexture","shaders.fragmentShaderTextureColor","shaders.vertexShaderRing","shaders.vertexShaderArc","shaders.vertexShaderConic3d","shaders.vertexShaderGeneric","shaders.vertexShaderBezier3d","shaders.vertexShaderNURBS","shaders.fragmentShaderColor3","shaders.vertexShaderBezier","shaders.vertexShaderLighting","shaders.fragmentShaderLighting","shaders.vertexShaderWaves"],"mappings":";;;;;;;;;;;AAAO,MAAM,EAAE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AAC,KAAK,CAAC,IAAI,CAAC,OAAO,EAAE,iBAAiB,CAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,MAAM,CAAC,CAAC,CAAC;AACnG,KAAK;AACL,IAAI,cAAc,CAAC,IAAI,EAAE;AACzB,QAAQ,UAAU,CAACxD,IAAE,EAAE,IAAI,CAAC,CAAC;AAC7B,QAAQ,MAAM,MAAM,GAAG,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAC7D,QAAQ,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE;AACtC,YAAY,OAAO,GAAG,CAAC;AACvB,SAAS;AACT,QAAQ,MAAM,MAAM,GAAG,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC;AAC3D,QAAQ,OAAO,MAAM,GAAG,MAAM,GAAG,GAAG,CAAC;AACrC,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAI,QAAQ,CAAC,SAAS,EAAE;AACxB,QAAQ,OAAO,IAAI,SAAS,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,CAAC,SAA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K;AACL;;AC5PO,MAAM,sBAAsB,GAAG,CAAC;AACvC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC,CAAC;AACK,MAAM,oBAAoB,GAAG,CAAC;AACrC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC,CAAC;AACK,MAAM,iBAAiB,GAAG,CAAC;AAClC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC,CAAC;AAwCK,MAAM,iBAAiB,GAAG,CAAC;AAClC;AACA;AACA;AACA;AACA;AACA,CAAC,CAAC;AACK,MAAM,iBAAiB,GAAG,CAAC;AAClC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC,CAAC;AACK,MAAM,eAAe,GAAG,CAAC;AAChC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC,CAAC;AACK,MAAM,mBAAmB,GAAG,CAAC;AACpC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC,CAAC;AACK,MAAM,iBAAiB,GAAG,CAAC;AAClC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC,CAAC;AACK,MAAM,kBAAkB,GAAG,CAAC;AACnC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC,CAAC;AACK,MAAM,oBAAoB,GAAG,CAAC;AACrC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC,CAAC;AACK,MAAM,mBAAmB,GAAG,CAAC;AACpC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC,CAAC;AACK,MAAM,gBAAgB,GAAG,CAAC;AACjC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC,CAAC;AACK,MAAM,mBAAmB,GAAG,CAAC;AACpC;AACA;AACA;AACA;AACA;AACA,CAAC,CAAC;AACK,MAAM,oBAAoB,GAAG,CAAC;AACrC;AACA;AACA;AACA;AACA;AACA;AACA,CAAC,CAAC;AACK,MAAM,0BAA0B,GAAG,CAAC;AAC3C;AACA;AACA;AACA;AACA;AACA,CAAC,CAAC;AACK,MAAM,4BAA4B,GAAG,CAAC;AAC7C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC,CAAC;AACK,MAAM,mBAAmB,GAAG,CAAC;AACpC;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC,CAAC;AACK,MAAM,0BAA0B,GAAG,CAAC;AAC3C;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;;AClVM,SAAS,cAAc,CAAC,GAAG,EAAE;AACpC,IAAI,MAAM,MAAM,GAAG,EAAE,CAAC;AACtB,IAAI,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,UAAU,IAAI,EAAE;AAC3C,QAAQ,MAAM,UAAU,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;AAC7C,QAAQ,IAAI,CAAC,CAA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end of file diff --git a/dist/bundle.module.min.js b/dist/bundle.module.min.js deleted file mode 100644 index cca2ac2..0000000 --- a/dist/bundle.module.min.js +++ /dev/null @@ -1 +0,0 @@ -import{AABB,arrayFromFunction,assert,assertNumbers,callsce,clamp,eq,eq0,fuzzyUniquesF,getIntervals,glqInSteps,hasConstructor,le,newtonIterate1d,newtonIterate2dWithDerivatives,newtonIterateWithDerivative,NLA_PRECISION,Transformable,V,V3,assertInst,assertVectors,M4,snap0,solveCubicReal2,TAU,DEG,arrayRange,bisect,assertf,assertNever,between,combinations,fuzzyUniques,lerp,MINUS,lt,VV,newtonIterate,pqFormula,checkDerivate,fuzzyBetween,newtonIterateSmart,arraySamples,newtonIterateWithDerivative2,snap,vArrGet,Vector,floatHashCode,isCCW,gaussLegendreQuadrature24,getRoots,toSource,gaussLegendre24Weights,gaussLegendre24Xs,GOLDEN_RATIO,mod,snap2,disableConsole,doubleSignedArea,enableConsole,ge,gt,mapPush,newtonIterate2d,NLA_DEBUG,SCE,addOwnProperties}from"ts3dutils";import{pushQuad,Mesh,GL_COLOR_BLACK,Shader}from"tsgl";import{load,Path}from"opentype.js";import chroma from"chroma-js";import{SVGPathData}from"svg-pathdata";import{Pair,JavaMap,JavaSet}from"javasetmap.ts";import earcut from"earcut";import nerdamer from"nerdamer";const{abs:abs,acos:acos,acosh:acosh,asin:asin,asinh:asinh,atan:atan,atanh:atanh,atan2:atan2,ceil:ceil,cbrt:cbrt,expm1:expm1,clz32:clz32,cos:cos,cosh:cosh,exp:exp,floor:floor,fround:fround,hypot:hypot,imul:imul,log:log,log1p:log1p,log2:log2,log10:log10,max:max,min:min,pow:pow,random:random,round:round,sign:sign,sin:sin,sinh:sinh,sqrt:sqrt,tan:tan,tanh:tanh,trunc:trunc,E:E,LN10:LN10,LN2:LN2,LOG10E:LOG10E,LOG2E:LOG2E,PI:PI,SQRT1_2:SQRT1_2,SQRT2:SQRT2}=Math;let insideIsInfosWithCurve=!1;class Curve$$1 extends Transformable{constructor(t,e){super(),this.tMin=t,this.tMax=e,assertNumbers(t,e),assert("number"==typeof t&&!isNaN(t)),assert("number"==typeof e&&!isNaN(e)),assert(teq(t.tThis,e)&&eq(t.tOther,s))){const n=(t,e,s,r)=>t.ddt(s).dot(t.at(s).minus(e.at(r)))+t.tangentAt(s).squared(),i=(t,e,s,r)=>-t.tangentAt(s).dot(e.tangentAt(r)),a=newtonIterate2dWithDerivatives((e,s)=>t.tangentAt(e).dot(t.at(e).minus(r.at(s))),(e,s)=>r.tangentAt(s).dot(t.at(e).minus(r.at(s))),e,s,16,n.bind(void 0,t,r),i.bind(void 0,t,r),(e,s)=>-i(r,t,s,e),(e,s)=>-n(r,t,s,e));assert(isFinite(a.x)),assert(isFinite(a.y)),void 0==a&&console.log(e,s,t.sce,r.sce),o.push({tThis:a.x,tOther:a.y,p:t.at(a.x)})}}(c,h),!0;{const o=t.getAABB(s,c),l=r.getAABB(i,h);let f,p;e(s,c,i,h,o,l,u+1)||e(s,c,h,a,o,p=r.getAABB(h,a),u+1)||e(c,n,i,h,f=t.getAABB(c,n),l,u+1)||e(c,n,h,a,f,p,u+1)}}return!1}(e,s,n,i,t.getAABB(e,s),r.getAABB(n,i)),fuzzyUniquesF(o,t=>t.tThis)}static breakDownIC(t,e,s,r,n,i){const{uMin:o,uMax:a,vMin:c,vMax:h}=e,u=h-c,l=ceil((a-o)/s),f=ceil(u/r),p=new Array(l*f).fill(0),d=(t,e)=>p[e*l+t],m=(t,e)=>0<=t&&t2);for(const{x:e,y:n}of t.points){const t=(e-o)/s,i=(n-c)/r;m(t-.5|0,i-.5|0),m(t-.5|0,i+.5|0),m(t+.5|0,i-.5|0),m(t+.5|0,i+.5|0)}}$.push(...a)}}for(const{points:t}of $)for(let e=0;et)){return callsce.call(void 0,"new "+this.constructor.name,...this.getConstructorParameters(),this.tMin,this.tMax)}withBounds(t=this.tMin,e=this.tMax){return new this.constructor(...this.getConstructorParameters(),t,e)}closestPointToPoint(t){return this.at(this.closestTToPoint(t))}isValidT(t){return le(this.tMin,t)&&le(t,this.tMax)}diff(t,e){return this.at(t).to(this.at(t+e))}closestTToPoint(t,e,s=this.tMin,r=this.tMax){return void 0===e&&(e=arrayFromFunction(32,t=>s+(r-s)*t/31).withMax(e=>-this.at(e).distanceTo(t))),newtonIterateWithDerivative(e=>this.at(e).minus(t).dot(this.tangentAt(e)),e,16,e=>this.tangentAt(e).squared()+this.at(e).minus(t).dot(this.ddt(e)))}calcSegmentPoints(t,e,s,r,n,i){assert(this.tIncrement,"tIncrement not defined on "+this);const o=this.tIncrement,a=[];if(i&&a.push(s),assert(n!=t=r;t--)a.push(this.at(t*o))}return a.push(r),a}calcSegmentTs(t,e,s,r){assert(this.tIncrement,"tIncrement not defined on "+this);const n=this.tIncrement,i=[];if(r&&i.push(t),assert(s!=t=r;t--)i.push(t*n)}return i.push(e),i}distanceToPoint(t,e,s){const r=this.closestTToPoint(t,e,s);return this.at(r).distanceTo(t)}asSegmentDistanceToPoint(t,e,s){let r=this.closestTToPoint(t,e,s);return r=clamp(r,e,s),this.at(r).distanceTo(t)}isInfosWithCurve(t){if(insideIsInfosWithCurve)return Curve$$1.ispsRecursive(this,this.tMin,this.tMax,t,t.tMin,t.tMax);try{return insideIsInfosWithCurve=!0,t.isInfosWithCurve(this).map(t=>{assert(t);const{tThis:e,tOther:s,p:r}=t;return{tOther:e,tThis:s,p:r}})}finally{insideIsInfosWithCurve=!1}}isTsWithSurface(t){if(t instanceof PlaneSurface$$1)return this.isTsWithPlane(t.plane);if(t instanceof ProjectedCurveSurface$$1){const e=new P3$$1(t.dir.unit(),0),s=this.project(e);return t.baseCurve.project(e).isInfosWithCurve(s).map(t=>t.tOther)}if(t instanceof EllipsoidSurface$$1){const e=this.transform(t.matrixInverse);if(!e.getAABB().touchesAABBfuzzy(new AABB(V3.XYZ.negated(),V3.XYZ)))return[];const s=t=>e.at(t).length()-1,r=t=>e.at(t).unit().dot(e.tangentAt(t)),n=1/2048,i=[];for(let t=this.tMin;t<=this.tMax;t+=n){const o=n*e.tangentAt(t).length();if(abs(s(t))<=o){let e=newtonIterateWithDerivative(s,t,16,r);eq0(s(e))&&!eq0(r(e))||(e=newtonIterate1d(r,t,16)),eq0(s(e))&&!i.some(t=>eq(t,e))&&i.push(e)}}return i.filter(e=>t.containsPoint(this.at(e)))}throw new Error}arcLength(t,e,s=1){return assert(tthis.tangentAt(t).length(),t,e,s)}equals(t){return this===t||hasConstructor(t,this.constructor)&&this.getConstructorParameters().equals(t.getConstructorParameters())}hashCode(){return this.getConstructorParameters().hashCode()}getAABB(t=this.tMin,e=this.tMax){t=isFinite(t)?t:this.tMin,e=isFinite(e)?e:this.tMax;const s=this.at(t),r=this.at(e),n=this.roots(),i=new Array(3),o=new Array(3);for(let a=0;a<3;a++){const c=n[a];i[a]=Math.min(s.e(a),r.e(a)),o[a]=Math.max(s.e(a),r.e(a));for(const s of c)tthis.tMin<=t&&t<=this.tMax);return getIntervals(e,this.tMin,this.tMax).mapFilter(([e,s])=>{const r=(e+s)/2;return!eq(e,s)&&t.distanceToPointSigned(this.at(r))<0&&this.withBounds(e,s)})}}function mkcurves(t,e,s,r,n,i){const o=V(e,s);assert(r>0);const{points:a,tangents:c}=followAlgorithm2d$$1(t,o,r,n,i);if(a.length>4&&a[0].distanceTo(a.last)<=abs(r)){for(let t=0;t2),[a]}}function breakDownPPCurves$$1(t,e,s,r,n){const{uMin:i,uMax:o,vMin:a,vMax:c}=t,h=uvInAABB2$$1.bind(void 0,t),u=uvInAABB2$$1.bind(void 0,e),l=c-a,f=ceil((o-i)/s),p=ceil(l/r),d=new Array(f*p).fill(0),m=(t,e)=>d[e*f+t],$=(t,e)=>0<=t&&t2);for(const{x:e,y:n}of t.st1s){const t=(e-i)/s,o=(n-a)/r;$(t-.5|0,o-.5|0),$(t-.5|0,o+.5|0),$(t+.5|0,o-.5|0),$(t+.5|0,o+.5|0)}}g.push(...o)}}console.table(v);for(const{points:t}of g)for(let e=0;enew PPCurve$$1(s,r,t,e,i,void 0,n,1))}function mkPPCurves(t,e,s,r,n,i){const{points:o,tangents:a,st1s:c}=followAlgorithmPP$$1(t,e,s,r,n,i);if(o[0].distanceTo(o.last)2){for(let t=0;t2),[a]}}function AABB2$$1(t,e,s,r){return{uMin:t,uMax:e,vMin:s,vMax:r}}function uvInAABB2$$1(t,e,s){return t.uMin<=e&&e<=t.uMax&&t.vMin<=s&&s<=t.vMax}function curvePoint$$1(t,e,s,r){let n=e;for(let e=0;e<8;e++){const e=t(n.x,n.y),i=s(n.x,n.y),o=r(n.x,n.y),a=e/(i*i+o*o);n=n.minus(new V3(a*i,a*o,0))}return n}function curvePointMF$$1(t,e,s=8,r=1/(1<<30)){let n=e;for(let e=0;eV3.polar(1,TAU*t/e)),i=arrayFromFunction(e,t=>V3.polar(s,TAU*t/e)),o=this.tIncrement,a=Math.ceil((this.tMin+NLA_PRECISION)/o),c=Math.floor((this.tMax-NLA_PRECISION)/o);for(let s=a;s<=c;s+=r){const r=s*o,a=t.vertices.length;if(0!==s)for(let s=0;s{const s=this.at(e);if(t.containsPoint(s))return{tThis:e,tOther:t.pointT(s),p:s}}):super.isInfosWithCurve(t)}transform(t){return new this.constructor(t.transformPoint(this.center),t.transformVector(this.f1),t.transformVector(this.f2),this.tMin,this.tMax)}equals(t){return this==t||void 0!=t&&this.constructor==t.constructor&&this.center.equals(t.center)&&this.f1.equals(t.f1)&&this.f2.equals(t.f2)}hashCode(){let t=0;return 0|(t=31*(t=31*(t=31*t+this.center.hashCode())+this.f1.hashCode())+this.f2.hashCode())}likeCurve(t){return hasConstructor(t,this.constructor)&&this.center.like(t.center)&&this.f1.like(t.f1)&&this.f2.like(t.f2)}normalP(t){return this.tangentAt(t).cross(this.normal)}getPlane(){return P3$$1.normalOnAnchor(this.normal,this.center)}isTsWithPlane(t){if(assertInst(P3$$1,t),t.normal1.isParallelTo(this.normal))return[];const e=t.normal1,s=t.w,r=this.center,n=this.f1,i=this.f2,o=e.dot(n),a=e.dot(i),c=s-e.dot(r);return this.constructor.intersectionUnitLine(o,a,c,this.tMin,this.tMax)}pointT(t){assertVectors(t);const e=this.matrixInverse.transformPoint(t);return this.constructor.XYLCPointT(e)}containsPoint(t){const e=this.matrixInverse.transformPoint(t);return eq0(e.z)&&this.isValidT(this.constructor.XYLCPointT(e,this.tMin,this.tMax))}isInfosWithLine(t,e,s=this.tMin,r=this.tMax,n=-1e5,i=1e5){const o=this.matrixInverse.transformPoint(t),a=this.matrixInverse.transformVector(e);if(eq0(a.z)){if(eq0(o.z))return this.constructor.unitIsInfosWithLine(o,a,t,e,s,r)}else{const s=o.z/a.z,r=a.times(s).plus(o);if(this.constructor.XYLCValid(r))return[{tThis:this.constructor.XYLCPointT(r),tOther:s,p:t.plus(e.times(s))}]}return[]}isTsWithSurface(t){if(t instanceof PlaneSurface$$1)return this.isTsWithPlane(t.plane);if(t instanceof EllipsoidSurface$$1){return t.isCurvesWithPlane(this.getPlane()).flatMap(t=>this.isInfosWithCurve(t)).filter(e=>t.containsPoint(e.p)).map(t=>t.tThis)}if(t instanceof ProjectedCurveSurface$$1||t instanceof ConicSurface$$1)return t.isCurvesWithPlane(this.getPlane()).flatMap(t=>this.isInfosWithCurve(t)).map(t=>t.tThis);throw new Error}isInfosWithBezier(t){const e=t.transform(this.matrixInverse);if(new PlaneSurface$$1(P3$$1.XY).containsCurve(e))return this.isInfosWithBezier2D(t);return e.isTsWithPlane(P3$$1.XY).mapFilter(s=>{const r=e.at(s);if(this.constructor.XYLCValid(r))return{tOther:s,p:t.at(s),tThis:this.constructor.XYLCPointT(r)}})}isInfosWithBezier2D(t,e=t.tMin,s=t.tMax){return Curve$$1.ispsRecursive(this,this.tMin,this.tMax,t,e,s)}isOrthogonal(){return this.f1.isPerpendicularTo(this.f2)}at2(t,e){return assertNumbers(t,e),this.center.plus(this.f1.times(t)).plus(this.f2.times(e))}debugInfo(){return{points:[this.center,this.at2(.5,0),this.at2(0,1/3),this.at2(0,2/3)],lines:[this.center,this.at2(0,1),this.center,this.at2(1,0)]}}}function parabola4Projection$$1(t,e,s){return HyperbolaCurve$$1.XY.rotateZ(45*DEG)}class ImplicitCurve$$1 extends Curve$$1{constructor(t,e,s=1,r,n=(1==s?0:-(t.length-1)),i=(1==s?t.length-1:0)){super(n,i),this.points=t,this.tangents=e,this.dir=s,this.generator=r,assert(t.length>2),assert(0<=n&&n<=t.length-1,n,t.length),assert(0<=i&&i<=t.length-1,i,t.length)}likeCurve(t){throw new Error("Method not implemented.")}toSource(t=(t=>t)){return this.generator||super.toSource(t)}containsPoint(t){return assertVectors(t),!isNaN(this.pointT(t))}equals(t){return this==t||Object.getPrototypeOf(t)==PICurve$$1.prototype&&this.points[0].equals(t.points[0])&&this.tangents[0].equals(t.tangents[0])}hashCode(){return[this.points[0],this.tangents[0]].hashCode()}tangentP(t){assertVectors(t),assert(this.containsPoint(t),"this.containsPoint(pWC)"+this.containsPoint(t));const e=this.pointT(t);return this.tangentAt(e)}tangentAt(t){return t=clamp(t,this.tMin,this.tMax),V3.lerp(this.tangents[floor(t)],this.tangents[ceil(t)],t%1)}at(t){return assert(isFinite(t)),V3.lerp(this.points[floor(t)],this.points[ceil(t)],t%1)}getConstructorParameters(){throw new Error}roots(){const t=arrayRange(0,this.points.length);return[t,t,t]}addToMesh(t,e=4,s=0,r=1){const n=arrayFromFunction(e,t=>V3.polar(1,TAU*t/e)),i=arrayFromFunction(e,t=>V3.polar(s,TAU*t/e));let o=V3.Z,a=M4.IDENTITY;for(let s=0;s-t.distanceTo(this.points[e]));if(void 0===e)throw new Error;if(this.points[e].like(t))return e;const s=max(0,e-1),r=min(this.points.length-1,e+1),n=this.tangentAt(e),i=bisect(e=>this.at(e).to(t).dot(n),s,r,32);return isFinite(i)&&eq0(this.at(i).distanceTo(t))?i:NaN}}function surfaceIsICurveIsInfosWithLine$$1(t,e,s,r,n,i,o,a){const c=new L3$$1(s,r.unit()),h=t.isTsForLine(c),u=e.isTsForLine(c);h.filter(t=>u.some(e=>eq(t,e))).map(t=>({tThis:0,tOther:t/r.length(),p:c.at(t)})).filter(t=>this.containsPoint(t.p)).forEach(t=>t.tThis=this.pointT(t.p))}ImplicitCurve$$1.prototype.tIncrement=1;class BezierCurve$$1 extends Curve$$1{constructor(t,e,s,r,n=-.1,i=1.1){super(n,i),assertVectors(t,e,s,r),assert(isFinite(n)&&isFinite(i)),this.p0=t,this.p1=e,this.p2=s,this.p3=r}get points(){return[this.p0,this.p1,this.p2,this.p3]}static graphXY(t,e,s,r,n,i){const o=s/3+r,a=e/3-r+2*o,c=t+r-3*o+3*a;return new BezierCurve$$1(V(0,r),V(1/3,o),V(2/3,a),V(1,c),n,i)}static quadratic(t,e,s,r=0,n=1){const i=L3$$1.throughPoints(t,s);return i.containsPoint(e)?i:new BezierCurve$$1(t,e.times(2).plus(t).div(3),e.times(2).plus(s).div(3),s,r,n)}static approximateUnitArc(t){const e=4/3*Math.tan(t/4);return new BezierCurve$$1(V3.X,new V3(1,e,0),new V3(cos(t)+e*sin(t),sin(t)-e*cos(t),0),V3.sphere(t,0),0,1)}getConstructorParameters(){return[this.p0,this.p1,this.p2,this.p3]}at(t){assertNumbers(t);const e=this.p0,s=this.p1,r=this.p2,n=this.p3,i=1-t,o=i*i*i,a=3*i*i*t,c=3*i*t*t,h=t*t*t;return new V3(e.x*o+s.x*a+r.x*c+n.x*h,e.y*o+s.y*a+r.y*c+n.y*h,e.z*o+s.z*a+r.z*c+n.z*h)}tangentAt(t){assertNumbers(t);const e=this.p0,s=this.p1,r=this.p2,n=this.p3,i=1-t,o=3*i*i,a=6*i*t,c=3*t*t;return new V3((s.x-e.x)*o+(r.x-s.x)*a+(n.x-r.x)*c,(s.y-e.y)*o+(r.y-s.y)*a+(n.y-r.y)*c,(s.z-e.z)*o+(r.z-s.z)*a+(n.z-r.z)*c)}ddt(t){assertNumbers(t);const e=this.p0,s=this.p1,r=this.p2,n=this.p3,i=6*(1-t),o=6*t;return new V3((r.x-2*s.x+e.x)*i+(n.x-2*r.x+s.x)*o,(r.y-2*s.y+e.y)*i+(n.y-2*r.y+s.y)*o,(r.z-2*s.z+e.z)*i+(n.z-2*r.z+s.z)*o)}normalP(t){const e=this.tangentAt(t);return e.cross(this.ddt(t)).cross(e)}isTsWithPlane(t){assertInst(P3$$1,t);const{p0:e,p1:s,p2:r,p3:n}=this,i=t.normal1,o=s.minus(r).times(3).minus(e).plus(n),a=e.plus(r).times(3).minus(s.times(6)),c=s.minus(e).times(3),h=e;return solveCubicReal2(o.dot(i),a.dot(i),c.dot(i),h.dot(i)-t.w).filter(t=>between(t,this.tMin,this.tMax))}isTsWithSurface(t){if(t instanceof CylinderSurface$$1){const e=new P3$$1(t.dir.unit(),0),s=this.project(e);return t.baseCurve.project(e).isInfosWithBezier2D(s).map(t=>t.tOther)}return super.isTsWithSurface(t)}likeCurve(t){return this==t||hasConstructor(t,BezierCurve$$1)&&this.p0.like(t.p0)&&this.p1.like(t.p1)&&this.p2.like(t.p2)&&this.p3.like(t.p3)}equals(t){return this==t||hasConstructor(t,BezierCurve$$1)&&this.p0.equals(t.p0)&&this.p1.equals(t.p1)&&this.p2.equals(t.p2)&&this.p3.equals(t.p3)}hashCode(){let t=0;return 0|(t=31*(t=31*(t=31*(t=31*t+this.p0.hashCode())+this.p1.hashCode())+this.p2.hashCode())+this.p3.hashCode())}isColinearTo(t){if(this===t||this.likeCurve(t))return!0;if(!(t instanceof BezierCurve$$1))return!1;let e,s,r;if(isNaN(e=this.pointT(t.p0))||isNaN(s=this.pointT(t.p3)))return!1;if(eq(1,e))r=this.split(s)[1].reversed();else{const t=(s-e)/(1-e);r=this.split(e)[1].split(t)[0]}return t.likeCurve(r)}selectPart(t,e){const s=(e-t)/(1-t);return this.split(t)[1].split(s)[0]}reversed(){return new BezierCurve$$1(this.p3,this.p2,this.p1,this.p0,1-this.tMax,1-this.tMin)}getCoefficients(){const{p0:t,p1:e,p2:s,p3:r}=this;return[e.minus(s).times(3).minus(t).plus(r),t.plus(s).times(3).minus(e.times(6)),e.minus(t).times(3),t]}tangentCoefficients(){const{p0:t,p1:e,p2:s,p3:r}=this,n=e.minus(t),i=s.minus(e),o=r.minus(s),a=n.plus(o).times(3).minus(i.times(6)),c=i.minus(n).times(6),h=n.times(3);return[V3.O,a,c,h]}pointT2(t,e=this.tMin,s=this.tMax){const r=this.closestTToPoint(t,void 0,e,s);return assert(this.at(r).like(t)),r}pointT(t){const{p0:e,p1:s,p2:r,p3:n}=this,i=s.minus(r).times(3).minus(e).plus(n),o=e.plus(r).times(3).minus(s.times(6)),a=s.minus(e).times(3),c=e.minus(t),h=NLA_PRECISIONthis.at(e).like(t));if(0==u.length)return NaN;if(1==u.length)return u[0];throw new Error("multiple intersection "+this.toString()+t.sce)}pointT3(t){const{p0:e,p1:s,p2:r,p3:n}=this,i=s.minus(r).times(3).minus(e).plus(n).els(),o=e.plus(r).times(3).minus(s.times(6)).els(),a=s.minus(e).times(3).els(),c=e.minus(t).els();let h=void 0;for(let t=0;t<3;t++)if(eq0(i[t])&&eq0(o[t])&&eq0(a[t])){if(!eq0(c[t]))return NaN}else{const e=solveCubicReal2(i[t],o[t],a[t],c[t]);if(0==e.length)return NaN;if(1==e.length)return e[0];if(h){if(0==(h=h.filter(t=>e.some(e=>eq(t,e)))).length)return NaN;if(1==h.length)return h[0]}else h=e}throw new Error("multiple intersection "+h+this.toString()+t.sce)}transform(t){return assert(t.isNoProj(),t.str),new BezierCurve$$1(t.transformPoint(this.p0),t.transformPoint(this.p1),t.transformPoint(this.p2),t.transformPoint(this.p3),this.tMin,this.tMax)}isClosed(){return this.p0.like(this.p3)}isQuadratic(){return this.p0.lerp(this.p1,1.5).like(this.p3.lerp(this.p2,1.5))}debugInfo(){return{lines:[0,1,1,2,2,3].map(t=>this.points[t]),points:this.points}}split(t){const e=1-t,{p0:s,p1:r,p2:n,p3:i}=this,o=s.times(e).plus(r.times(t)),a=r.times(e).plus(n.times(t)),c=n.times(e).plus(i.times(t)),h=o.times(e).plus(a.times(t)),u=a.times(e).plus(c.times(t)),l=h.times(e).plus(u.times(t));return[new BezierCurve$$1(s,o,h,l),new BezierCurve$$1(l,u,c,i)]}containsPoint(t){return isFinite(this.pointT(t))}roots(){const{p0:t,p1:e,p2:s,p3:r}=this,n=e.minus(t),i=s.minus(e),o=r.minus(s),a=n.plus(o).times(3).minus(i.times(6)),c=i.minus(n).times(6),h=n.times(3);return arrayFromFunction(3,t=>solveCubicReal2(0,a.e(t),c.e(t),h.e(t)))}isInfosWithLine(t,e,s,r,n=-1e5,i=1e5){const{p0:o,p1:a,p2:c,p3:h}=this,u=a.minus(c).times(3).minus(o).plus(h),l=V3.UNITS[u.minAbsDim()],f=P3$$1.forAnchorAndPlaneVectors(t,e,l.isParallelTo(e)?u:l);return this.isTsWithPlane(f).map(s=>{const r=this.at(s);return{tThis:s,tOther:L3$$1.pointT(t,e,r),p:r}}).filter(s=>L3$$1.containsPoint(t,e,s.p))}closestPointToLine(t,e,s){e=isFinite(e)?e:this.tMin,s=isFinite(s)?s:this.tMax;const r=t.anchor.dot(t.dir1),n=e=>{const s=this.at(e);return s.minus(t.at(s.dot(t.dir1)-r)).dot(this.tangentAt(e))},i=arrayFromFunction(32,t=>e+(s-e)*t/32).withMax(t=>-n(t));return newtonIterate1d(n,i,8)}isInfosWithBezier3(t,e,s,r,n){const i=(e,s)=>{if(!a.some(t=>eq(t.tThis,e)&&eq(t.tOther,s))){const r=(t,e,s,r)=>t.ddt(s).dot(t.at(s).minus(e.at(r)))+t.tangentAt(s).squared(),n=(t,e,s,r)=>-t.tangentAt(s).dot(e.tangentAt(r)),i=newtonIterate2dWithDerivatives((e,s)=>this.tangentAt(e).dot(this.at(e).minus(t.at(s))),(e,s)=>t.tangentAt(s).dot(this.at(e).minus(t.at(s))),e,s,16,r.bind(void 0,this,t),n.bind(void 0,this,t),(e,s)=>-n(t,this,s,e),(e,s)=>-r(t,this,s,e));a.push({tThis:i.x,tOther:i.y,p:this.at(i.x)})}},o=[e=void 0!==e?e:this.tMin,s=void 0!==s?s:this.tMax,r=void 0!==r?r:t.tMin,n=void 0!==n?n:t.tMax],a=[];for(;o.length;){const e=o.length-4,s=o[e],r=o[e+1],n=o[e+2],a=o[e+3];o.length-=4;const c=this.getAABB(s,r),h=t.getAABB(n,a);if(c&&h&&c.intersectsAABB2d(h)){const t=(s+r)/2,e=(n+a)/2,u=1e-5;r-ser{Math.abs(e-s)>2&&i.push(...Curve$$1.ispsRecursive(this,a[e],a[e+1],t,a[s],a[s+1]))})}return i}selfIntersectionsInfo(){return this.isInfosWithBezier(this)}isInfosWithCurve(t){return t instanceof L3$$1?this.isInfosWithLine(t.anchor,t.dir1,t.tMin,t.tMax):t instanceof BezierCurve$$1?this.isInfosWithBezier(t):t.isInfosWithCurve(this).map(({tThis:t,tOther:e,p:s})=>({tThis:e,tOther:t,p:s}))}circleApprox(t=this.tMin,e=this.tMax,s=1/1024,r=[]){const n=this.at(t),i=this.at(e),o=(t+e)/2,a=this.at(o),c=L3$$1.throughPoints(n,i);if(!c.containsPoint(a)&&between(c.pointT(a),0,c.pointT(i))){const o=EllipseCurve$$1.circleThroughPoints(n,a,i),c=o.f1.length(),h=this.at(lerp(t,e,.25)),u=this.at(lerp(t,e,.75));if(abs(o.center.distanceTo(h)/c-1)<=s&&abs(o.center.distanceTo(u)/c-1)<=s)return r.push(o),r}return this.circleApprox(t,o,s,r),this.circleApprox(o,e,s,r),r}}BezierCurve$$1.EX2D=BezierCurve$$1.graphXY(2,-3,-3,2),BezierCurve$$1.EX3D=new BezierCurve$$1(V3.O,V(-.1,-1,1),V(1.1,1,1),V3.X),BezierCurve$$1.QUARTER_CIRCLE=BezierCurve$$1.approximateUnitArc(PI/2),BezierCurve$$1.prototype.hlol=Curve$$1.hlol++,BezierCurve$$1.prototype.tIncrement=1/80;class HyperbolaCurve$$1 extends XiEtaCurve$$1{constructor(t,e,s,r=-7,n=7){super(t,e,s,r,n)}static XYLCValid(t){return t.x>0&&eq(1,t.x*t.x-t.y*t.y)}static XYLCPointT(t){return Math.asinh(t.y)}static intersectionUnitLine(t,e,s){if(eq0(e)){const e=snap0(Math.pow(s,2)/Math.pow(t,2)-1);if(e<0||s*t<0)return[];if(0==e)return[0];const r=Math.sqrt(e);return[-Math.asinh(r),Math.asinh(r)]}if(eq(abs(t),abs(e))){if(le(s*t,0))return[];const r=sign(t*e)*(Math.pow(s,2)-Math.pow(t,2))/2/t/s;return[Math.asinh(r)]}{const r=snap0(Math.pow(e,2)*(-Math.pow(t,2)+Math.pow(e,2)+Math.pow(s,2)));if(r<0)return[];const n=(t*s-Math.sqrt(r))/(Math.pow(t,2)-Math.pow(e,2)),i=(t*s+Math.sqrt(r))/(Math.pow(t,2)-Math.pow(e,2)),o=(Math.pow(e,2)*s-t*Math.sqrt(r))/(e*(Math.pow(e,2)-Math.pow(t,2))),a=(Math.pow(e,2)*s+t*Math.sqrt(r))/(e*(Math.pow(e,2)-Math.pow(t,2)));return[n>0&&Math.asinh(o),i>0&&Math.asinh(a)].filter(t=>!1!==t)}}at(t){return assertNumbers(t),this.center.plus(this.f1.times(Math.cosh(t))).plus(this.f2.times(Math.sinh(t)))}toString(){return`${this.center} + ${this.f1} * cosh(t) + ${this.f2} * sinh(t)`}tangentAt(t){return assertNumbers(t),this.f1.times(Math.sinh(t)).plus(this.f2.times(Math.cosh(t)))}tangentAt2(t,e){return assertNumbers(t,e),this.f1.times(e).plus(this.f2.times(t))}ddt(t){return assertNumbers(t),this.f1.times(Math.cosh(t)).plus(this.f2.times(Math.sinh(t)))}isColinearTo(t){if(!hasConstructor(t,HyperbolaCurve$$1))return!1;if(!t.center||!this.center.like(t.center))return!1;if(this===t)return!0;const{f1:e,f2:s}=this.rightAngled(),{f1:r,f2:n}=t.rightAngled();return eq(e.squared(),Math.abs(e.dot(r)))&&eq(s.squared(),Math.abs(s.dot(n)))}reversed(){return new HyperbolaCurve$$1(this.center,this.f1,this.f2.negated(),-this.tMax,-this.tMin)}rightAngled(){const t=this.f1,e=this.f2,s=t.dot(e),r=e.squared()+t.squared();if(eq0(s))return this;const n=2*s,i=r+Math.sqrt(r*r-4*s*s),{x1:o,y1:a}=intersectionUnitHyperbolaLine$$1(n,i,0);return new HyperbolaCurve$$1(this.center,t.times(o).plus(e.times(a)),t.times(a).plus(e.times(o)))}eccentricity(){const t=this.rightAngled(),e=t.f1.length(),s=t.f1.length(),[r,n]=e>s?[e,s]:[s,e];return Math.sqrt(1+n*n/r/r)}roots(){return arrayFromFunction(3,t=>{const e=this.f2.e(t),s=this.f1.e(t);return HyperbolaCurve$$1.intersectionUnitLine(e,s,0)})}transform4(t){const e=t=>sign(t)*min(10,sqrt(-(1-cosh(t))/(1+cosh(t)))),s=new M4(0,1,0,1,2,0,0,0,0,0,1,0,0,-1,0,1);return parabola4Projection$$1(M4.product(t,this.matrix,s),e(this.tMin),e(this.tMax))}}HyperbolaCurve$$1.XY=new HyperbolaCurve$$1(V3.O,V3.X,V3.Y),HyperbolaCurve$$1.prototype.tIncrement=PI/16;class L3$$1 extends Curve$$1{constructor(t,e,s=-4096,r=4096){super(s,r),this.anchor=t,this.dir1=e,assertVectors(t,e),assert(e.hasLength(1),"dir must be unit"+e),assertf(()=>!Number.isNaN(t.x))}isTsWithSurface(t){return t.isTsForLine(this)}static throughPoints(t,e,s=0,r){const n=e.minus(t);return new L3$$1(t,n.unit(),s,void 0!==r?r:n.length())}static anchorDirection(t,e,s=0,r=e.length()){const n=e.unit();return new L3$$1(t,n,"number"==typeof s?s:s.minus(t).dot(n),"number"==typeof r?r:r.minus(t).dot(n))}static pointT(t,e,s){return assertVectors(t,e,s),s.minus(t).dot(e)/e.squared()}static at(t,e,s){return t.plus(e.times(s))}static fromPlanes(t,e){if(assertInst(P3$$1,t,e),t.normal1.cross(e.normal1).length()<1e-10)throw new Error("Parallel planes");return t.intersectionWithPlane(e)}static containsPoint(t,e,s){const r=L3$$1.pointT(t,e,s),n=L3$$1.at(t,e,r).distanceTo(s);return eq0(n)}roots(){return[[],[],[]]}containsPoint(t){assertVectors(t);const e=this.distanceToPoint(t);return assertNumbers(e),eq0(e)}likeCurve(t){return this==t||hasConstructor(t,L3$$1)&&this.anchor.like(t.anchor)&&this.dir1.like(t.dir1)}equals(t){return this==t||Object.getPrototypeOf(t)==L3$$1.prototype&&this.anchor.equals(t.anchor)&&this.dir1.equals(t.dir1)}isColinearTo(t){return t instanceof L3$$1&&this.containsPoint(t.anchor)&&eq(1,Math.abs(this.dir1.dot(t.dir1)))}distanceToLine(t){if(assertInst(L3$$1,t),this.isParallelToLine(t))return this.distanceToPoint(t.anchor);const e=this.dir1.cross(t.dir1).unit(),s=this.anchor.minus(t.anchor);return Math.abs(s.dot(e))}distanceToPoint(t){assertVectors(t);const e=t.minus(this.anchor).dot(this.dir1);return this.at(e).distanceTo(t)}asSegmentDistanceToPoint(t,e,s){let r=t.minus(this.anchor).dot(this.dir1);return r=clamp(r,e,s),this.at(r).minus(t).length()}asSegmentDistanceToLine(t,e,s){assertInst(L3$$1,t);const r=this.dir1.cross(t.dir1),n=r.squared();if(eq0(n))return;const i=t.anchor.minus(this.anchor);if(!eq0(i.dot(r.unit())))return;let o=this.infoClosestToLine(t).t;return o=clamp(o,e,s),this.at(clamp(o,e,s))}at(t){return assertNumbers(t),this.anchor.plus(this.dir1.times(t))}pointT(t){return assertVectors(t),t.minus(this.anchor).dot(this.dir1)}isParallelToLine(t){return assertInst(L3$$1,t),eq(1,Math.abs(this.dir1.dot(t.dir1)))}angleToLine(t){return assertInst(L3$$1,t),this.dir1.angleTo(t.dir1)}intersectsLine(t){return eq0(this.distanceToLine(t))}isInfosWithCurve(t){return t instanceof L3$$1?this.isInfosWithLine(t.anchor,t.dir1):super.isInfosWithCurve(t)}isInfosWithLine(t,e){const s=this.dir1.cross(e),r=s.squared();if(eq0(r))return[];const n=t.minus(this.anchor);if(eq0(n.dot(s))){const t=n.cross(e).dot(s)/r;return[{tThis:t,tOther:n.cross(this.dir1).dot(s)/r,p:this.at(t)}]}return[]}isInfoWithLine(t){assertInst(L3$$1,t);const e=this.dir1.cross(t.dir1),s=e.squared();if(eq0(s))return;const r=t.anchor.minus(this.anchor);if(!eq0(r.dot(e.unit())))return;const n=r.cross(t.dir1).dot(e)/s;return this.at(n)}intersectionLineST(t){assertInst(L3$$1,t);const e=this.dir1.cross(t.dir1),s=e.squared(),r=t.anchor.minus(this.anchor);return{s:r.cross(this.dir1).dot(e)/s,t:r.cross(t.dir1).dot(e)/s}}ddt(){return V3.O}getConstructorParameters(){return[this.anchor,this.dir1]}closestTToPoint(t){return t.minus(this.anchor).dot(this.dir1)}infoClosestToLine(t){if(this.isParallelToLine(t))return{t:NaN,s:NaN,distance:this.distanceToLine(t)};const e=t.anchor,s=t.dir1,r=this.anchor,n=this.dir1,i=s.dot(n),o=s.squared(),a=n.squared(),c=e.minus(r),h=i*i-a*o,u=(c.dot(s)*i-c.dot(n)*o)/h,l=(c.dot(s)*a-c.dot(n)*i)/h;return{t:u,s:l,closest:this.at(u),closest2:t.at(l),distance:this.at(u).distanceTo(t.at(l))}}intersectionWithPlane(t){const e=(t.w-t.normal1.dot(this.anchor))/t.normal1.dot(this.dir1);return this.anchor.plus(this.dir1.times(e))}tangentAt(){return this.dir1}isTWithPlane(t){const e=t.normal1.dot(this.dir1);return eq0(e)?NaN:(t.w-t.normal1.dot(this.anchor))/e}reversed(){return new L3$$1(this.anchor,this.dir1.negated(),-this.tMax,-this.tMin)}isTsWithPlane(t){const e=this.isTWithPlane(t);return isNaN(e)?[]:[e]}flipped(){return new L3$$1(this.anchor,this.dir1.negated())}transform(t){const e=t.transformPoint(this.anchor),s=t.transformVector(this.dir1);return new L3$$1(e,s.unit(),this.tMin*s.length(),this.tMax*s.length())}transform4(t){const e=P3$$1.vanishingPlane(t);if(!e)return this.transform(t);const s=this.at(this.tMin),r=this.at(this.tMax);if(le(e.distanceToPointSigned(s),0)||le(e.distanceToPointSigned(r),0))throw new Error("line must be in front of vanishingPlane in [tMin, tMax]");const n=lt(0,e.distanceToPointSigned(this.anchor))?this.anchor:this.at((this.tMin+this.tMax)/2),i=t.timesVector(VV(n.x,n.y,n.z,1)),o=t.timesVector(VV(this.dir1.x,this.dir1.y,this.dir1.z,0)),a=o.times(i.w).minus(i.times(o.w)).V3(),c=i.p3();return L3$$1.anchorDirection(c,a,t.transformPoint(s),t.transformPoint(r))}hashCode(){return 31*this.anchor.hashCode()+this.dir1.hashCode()}}L3$$1.X=new L3$$1(V3.O,V3.X),L3$$1.Y=new L3$$1(V3.O,V3.Y),L3$$1.Z=new L3$$1(V3.O,V3.Z),L3$$1.prototype.hlol=Curve$$1.hlol++,L3$$1.prototype.tIncrement=256;class PICurve$$1 extends ImplicitCurve$$1{constructor(t,e,s,r,n,i,o,a=1,c,h,u){super(t,e,a,c,h,u),this.parametricSurface=s,this.implicitSurface=r,this.pmPoints=n,this.pmTangents=i,this.stepSize=o,assert(Array.isArray(n)),assert(1==a),assert(o<=1);const l=s.pUVFunc(),f=s.dpdu(),p=s.dpdv(),d=r.didp.bind(r);this.didu=((t,e)=>d(l(t,e)).dot(f(t,e))),this.didv=((t,e)=>d(l(t,e)).dot(p(t,e)));for(let e=0;en(s(t,e)),(t,e)=>c(s(t,e)).dot(i(t,e)),(t,e)=>c(s(t,e)).dot(a(t,e))),{points:u}=followAlgorithm2d$$1(h,this.pmPoints[0],o,t,(t,r)=>e.containsPoint(s(t,r)),this.pmPoints.last,this.pmTangents[0]);u.length!==this.points.length&&followAlgorithm2d$$1(h,this.pmPoints[0],o,t,(t,r)=>e.containsPoint(s(t,r)),this.pmPoints.last,this.pmTangents[0]),assert(u.length==this.points.length,u.length,this.points.length)}}static forParametricStartEnd(t,e,s,r,n=.02,i,o,a){const c=t.pUVFunc(),h=e.implicitFunction(),u=t.dpdu(),l=t.dpdv(),f=e.didp.bind(e),p=MathFunctionR2R.forFFxFy((t,e)=>h(c(t,e)),(t,e)=>f(c(t,e)).dot(u(t,e)),(t,e)=>f(c(t,e)).dot(l(t,e))),{points:d,tangents:m}=followAlgorithm2d$$1(p,s,n,t,(t,s)=>e.containsPoint(c(t,s)),r,i);return PICurve$$1.forParametricPointsTangents(t,e,d,m,n,1,o,a)}static forStartEnd(t,e,s,r,n=.02,i,o,a){const c=t.uvP(s),h=t.dpdu()(c.x,c.y),u=t.dpdv()(c.x,c.y),l=i&&M4.forSys(h,u).inversed().transformVector(i),f=PICurve$$1.forParametricStartEnd(t,e,c,t.uvP(r),n,l);return f.withBounds(o&&f.pointT(o),a&&f.pointT(a))}static forParametricPointsTangents(t,e,s,r,n,i=1,o,a){const c=t.pUVFunc(),h=t.dpdu(),u=t.dpdv(),l=s.map(({x:t,y:e})=>c(t,e)),f=s.map(({x:t,y:e},s)=>{const n=h(t,e),i=u(t,e);return n.times(r[s].x).plus(i.times(r[s].y))});return new PICurve$$1(l,f,t,e,s,r,n,i,void 0,o,a)}getConstructorParameters(){return[this.points,this.tangents,this.parametricSurface,this.implicitSurface,this.pmPoints,this.pmTangents,this.stepSize,this.dir,this.generator]}implicitCurve(){const t=this.parametricSurface.pUVFunc(),e=this.implicitSurface.implicitFunction();return(s,r)=>e(t(s,r))}isColinearTo(t){return t instanceof PICurve$$1&&(!!this.equals(t)||(this.parametricSurface.isCoplanarTo(t.parametricSurface)&&this.implicitSurface.isCoplanarTo(t.implicitSurface),!1))}containsPoint(t){assertVectors(t);const e=this.pointT(t);return!isNaN(e)&&this.isValidT(e)}equals(t){return Object.getPrototypeOf(t)==PICurve$$1.prototype&&this.parametricSurface.equals(t.parametricSurface)&&this.implicitSurface.equals(t.implicitSurface)&&this.points[0].equals(t.points[0])&&this.tangents[0].equals(t.tangents[0])&&this.dir===t.dir}hashCode(){let t=0;return 0|(t=31*(t=31*(t=31*(t=31*t+this.parametricSurface.hashCode())+this.implicitSurface.hashCode())+this.points[0].hashCode())+this.tangents[0].hashCode())}tangentP(t){assertVectors(t),assert(this.containsPoint(t),"this.containsPoint(point)");const e=this.pointT(t);return this.tangentAt(e)}tangentAt(t){if(assert(!isNaN(t)),0==t%1)return this.tangents[t];const e=this.uvT(t),s=new V3(-this.didv(e.x,e.y),this.didu(e.x,e.y),0).toLength(this.stepSize),r=this.parametricSurface.dpdu()(e.x,e.y),n=this.parametricSurface.dpdv()(e.x,e.y);return r.times(s.x).plus(n.times(s.y))}at(t){if(assert(!isNaN(t)),0==t%1)return this.points[t];const e=V3.lerp(this.pmPoints[floor(t)],this.pmPoints[ceil(t)],t%1);return this.closestPointToParams(e)}uvT(t){if(assert(!isNaN(t)),0==t%1)return this.pmPoints[t];const e=V3.lerp(this.pmPoints[floor(t)],this.pmPoints[ceil(t)],t%1);return curvePoint$$1(this.implicitCurve(),e,this.didu,this.didv)}closestTToPoint(t,e){return 0}closestPointToParams(t){const e=curvePoint$$1(this.implicitCurve(),t,this.didu,this.didv);return this.parametricSurface.pUVFunc()(e.x,e.y)}isTsWithSurface(t){if(t instanceof EllipsoidSurface$$1){const e=this.parametricSurface,s=this.implicitSurface;if(e instanceof ProjectedCurveSurface$$1&&s instanceof EllipsoidSurface$$1){const r=s.isCurvesWithSurface(t).flatMap(t=>t.isTsWithSurface(e).map(e=>t.at(e)));return fuzzyUniques(r.map(t=>this.pointT(t))).filter(t=>!isNaN(t)&&this.isValidT(t))}}else if(ImplicitSurface$$1.is(t)){const e=[],s=t.implicitFunction();let r=s(this.points[0]);for(let n=1;ns(i(t,e)),h.x,h.y,4,this.didu,this.didv,(e,s)=>a(e,s).dot(t.didp(i(e,s))),(e,s)=>c(e,s).dot(t.didp(i(e,s))));e.push(this.pointT(this.parametricSurface.pUV(u.x,u.y)))}r=o}return e}throw new Error}isTsWithPlane(t){return this.isTsWithSurface(new PlaneSurface$$1(t))}pointT(t){if(assertVectors(t),!this.parametricSurface.containsPoint(t)||!this.implicitSurface.containsPoint(t))return NaN;const e=this.parametricSurface.uvPFunc()(t),s=this.points,r=this.pmPoints;let n=0,i=e.distanceTo(r[0]);for(;i>abs(this.stepSize)&&n1.1*abs(this.stepSize))return NaN;if(n==s.length-1&&n--,s[n].like(t))return n;if(s[n+1].like(t))return n+1;const o=arrayRange(floor(this.tMin),ceil(this.tMax),1).withMax(t=>-e.distanceTo(r[t]));if(void 0===o)throw new Error;if(s[o].like(t))return o;const a=max(0,o-1),c=min(this.points.length-1,o+1),h=this.tangentAt(o);return n=bisect(e=>this.at(clamp(e,0,this.points.length-1)).to(t).dot(h),a,c,32),!isFinite(n)||this.at(n).distanceTo(t)>abs(this.stepSize)?NaN:n}transform(t){const e=t.isMirroring()?-1:1;return PICurve$$1.forStartEnd(this.parametricSurface.transform(t),this.implicitSurface.transform(t),t.transformPoint(this.points[0]),t.transformPoint(this.points.last),this.stepSize*e,t.transformVector(this.tangents[0]),t.transformPoint(this.at(this.tMin)),t.transformPoint(this.at(this.tMax)))}roots(){const t=arrayRange(0,this.points.length);return[t,t,t]}isInfosWithLine(t,e,s,r,n,i){return surfaceIsICurveIsInfosWithLine$$1.call(this,t,e,s,r,n,i)}toSource(t=(t=>t)){return callsce("PICurve.forParametricStartEnd",this.parametricSurface,this.implicitSurface,this.pmPoints[0],this.pmPoints.last,this.stepSize,this.pmTangents[0],this.tMin,this.tMax)}}PICurve$$1.prototype.tIncrement=1;class PPCurve$$1 extends ImplicitCurve$$1{constructor(t,e,s,r,n,i,o,a=1,c,h,u){super(t,e,a,c,h,u),this.parametricSurface1=s,this.parametricSurface2=r,this.st1s=n,this.pmTangents=i,this.stepSize=o,assert(ParametricSurface$$1.is(s)),assert(ParametricSurface$$1.is(r)),assert(Array.isArray(n)),assert(1==a),assert(o<=1)}at(t){if(assert(!isNaN(t)),0==t%1)return this.points[t];const e=V3.lerp(this.points[floor(t)],this.points[ceil(t)],t%1);return curvePointPP$$1(this.parametricSurface1,this.parametricSurface2,e).p}isColinearTo(t){return t instanceof PPCurve$$1&&(!!this.equals(t)||(this.parametricSurface1.isCoplanarTo(t.parametricSurface1)&&this.parametricSurface1.isCoplanarTo(t.parametricSurface2),!1))}containsPoint(t){return assertVectors(t),this.parametricSurface1.containsPoint(t)&&this.parametricSurface2.containsPoint(t)&&!isNaN(this.pointT(t))}rootPoints(){const t=this.parametricSurface1.pUVFunc(),e=this.parametricSurface2.pUVFunc(),s=this.parametricSurface1.normalUVFunc(),r=this.parametricSurface2.normalUVFunc(),n=this.rootsApprox(),i=[[],[],[]];for(let a=0;a<3;a++)for(let c=0;ct.map(t=>this.pointT(t)))}pointTangent(t){assertVectors(t),assert(this.containsPoint(t),"this.containsPoint(pWC)");const e=this.parametricSurface1.normalP(t),s=this.parametricSurface2.normalP(t);return e.cross(s)}transform(t){return new PPCurve$$1(t.transformedPoints(this.points),t.transformedVectors(this.tangents),this.parametricSurface1.transform(t),this.parametricSurface2.transform(t),this.st1s,void 0,this.stepSize,this.dir,void 0)}toSource(){return callsce("PPCurve.forStartEnd",this.parametricSurface1,this.parametricSurface2,this.points[0],this.points.last,this.stepSize)}static forStartEnd(t,e,s,r,n=.02){const{points:i,tangents:o,st1s:a}=followAlgorithmPP$$1(t,e,s,n);return new PPCurve$$1(i,o,t,e,a,void 0,n,1)}isInfosWithLine(t,e,s,r,n,i){return surfaceIsICurveIsInfosWithLine$$1.call(this,t,e,s,r,n,i)}isTsWithSurface(t){if(ImplicitSurface$$1.is(t)){const e=[],s=t.implicitFunction(),r=this.parametricSurface1.pUVFunc(),n=this.parametricSurface2.pUVFunc();let i=s(this.points[0]);for(let t=1;t{const a=r(t,e),c=n(i,o);return[...a.to(c),s(a)]},[h.x,h.y,u.x,u.y]);e.push(this.pointT(this.parametricSurface1.pUV(l[0],l[1])))}i=a}return e}throw new Error("Method not implemented.")}isTsWithPlane(t){return this.isTsWithSurface(new PlaneSurface$$1(t))}}class ParabolaCurve$$1 extends XiEtaCurve$$1{constructor(t,e,s,r=-10,n=10){super(t,e,s,r,n)}static eccentricity(){return 1}static unitIsInfosWithLine(t,e,s,r){const n=Math.pow(e.x,2);return pqFormula((t.x*e.x+e.y)/n,(Math.pow(t.x,2)+t.y)/n).filter(s=>le(0,t.y+s*e.y)).map(n=>({tThis:e.x*n+t.x,tOther:n,p:L3$$1.at(s,r,n)}))}static intersectionUnitLine(t,e,s){return pqFormula(t/e,-s/e)}static XYLCValid(t){return eq(Math.pow(t.x,2),t.y)}static XYLCPointT(t){return t.x}static quadratic(t,e,s){const r=t.plus(s).minus(e.times(2)),n=e.minus(t).times(2);return new ParabolaCurve$$1(t,n,r,0,1)}at(t){return this.center.plus(this.f1.times(t)).plus(this.f2.times(t*t))}tangentAt(t){return assertNumbers(t),this.f1.plus(this.f2.times(2*t))}ddt(t){return assertNumbers(t),this.f2.times(2)}tangentAt2(t,e){return assertNumbers(t,e),this.f1.plus(this.f2.times(2*e))}reversed(){return new this.constructor(this.center,this.f1.negated(),this.f2,-this.tMax,-this.tMin)}roots(){return arrayFromFunction(3,t=>eq0(this.f2.e(t))?[]:[-this.f1.e(t)/2/this.f2.e(t)])}isColinearTo(t){if(!hasConstructor(t,ParabolaCurve$$1))return!1;const e=this.rightAngled(),s=t.rightAngled();return e.center.like(s.center)&&e.f2.like(s.f2)&&e.f1.likeOrReversed(s.f1)}rightAngled(){const t=this.f1,e=this.f2,s=t.dot(e);if(eq0(s)&&t.hasLength(1))return this;const r=-s/e.squared()/2,n=this.at(r),i=this.tangentAt(r),o=i.length(),a=i.unit(),c=t=>this.at(t).minus(n).dot(a);return new ParabolaCurve$$1(n,a,e.div(Math.pow(o,2)),c(this.tMin),c(this.tMax))}arcLength(t,e){let s=this.f1;const r=this.f2,n=s.dot(r);let i=0;eq0(n)||(i=-n/r.squared()/2,s=s.plus(r.times(2*i)));const o=s.length(),a=r.length()/o;function c(t){return Math.asinh(2*a*t)/4/a+t*Math.sqrt(1+a*a*4*t*t)/2}return o*(c(e-i)-c(t-i))}transform4(t){return parabola4Projection$$1(this.matrix.transform(t),this.tMin,this.tMax)}asBezier(){return BezierCurve$$1.quadratic(this.at(-1),new L3$$1(this.at(-1),this.tangentAt(-1).unit()).isInfoWithLine(new L3$$1(this.at(1),this.tangentAt(1).unit())),this.at(1))}recenter(t){return new ParabolaCurve$$1(this.at(t),this.f1.plus(this.f2.times(2*t)),this.f2)}}ParabolaCurve$$1.XY=new ParabolaCurve$$1(V3.O,V3.X,V3.Y),ParabolaCurve$$1.YZ=new ParabolaCurve$$1(V3.O,V3.Y,V3.Z),ParabolaCurve$$1.ZX=new ParabolaCurve$$1(V3.O,V3.Z,V3.X),ParabolaCurve$$1.prototype.tIncrement=1/32;class EllipseCurve$$1 extends XiEtaCurve$$1{constructor(t,e,s,r=0,n=PI){super(t,e,s,r,n),assert(-PI<=this.tMin&&this.tMinlerp(s,e+TAU,.5)?r-TAU:r}static intersectionUnitLine(t,e,s,r,n){const i=intersectionUnitCircleLine2$$1(t,e,s),o=[];for(const[t,e]of i){const s=EllipseCurve$$1.XYLCPointT(new V3(t,e,0),r,n);fuzzyBetween(s,r,n)&&o.push(s)}return o}static unitIsInfosWithLine(t,e,s,r,n,i){const o=e.squared();return pqFormula(2*e.dot(t)/o,(t.squared()-1)/o).filter(s=>le(0,t.y+s*e.y)).map(o=>({tThis:EllipseCurve$$1.XYLCPointT(e.times(o).plus(t),n,i),tOther:o,p:L3$$1.at(s,r,o)}))}static semicircle(t,e=V3.O,s,r){return new EllipseCurve$$1(e,new V3(t,0,0),new V3(0,t,0),s,r)}static circleForCenter2P(t,e,s,r,n,i){const o=t.to(e),a=o.cross(t.to(s)).cross(o).toLength(o.length());return new EllipseCurve$$1(t,o,a,void 0!==n?n:0,void 0!==i?i:o.angleTo(t.to(s)))}split(t=this.tMin,e=this.tMax){const s=[];return t<0&&s.push(new EllipseCurve$$1(this.center,this.f1.negated(),this.f2.negated(),t+PI,min(0,e)+PI)),e>0&&s.push(new EllipseCurve$$1(this.center,this.f1,this.f2,max(0,t),e)),s}static forAB(t,e,s=V3.O){return super.forAB(t,e,s)}static circleThroughPoints(t,e,s,r=0,n){assertf(()=>!L3$$1.throughPoints(t,s).containsPoint(e));const i=t.to(e).cross(e.to(s)),o=new L3$$1(t.lerp(e,.5),i.cross(t.to(e)).unit()).isInfoWithLine(new L3$$1(e.lerp(s,.5),i.cross(e.to(s)).unit())),a=o.to(t).negated();return new EllipseCurve$$1(o,a,i.unit().cross(a),-PI,void 0===n?a.angleRelativeNormal(o.to(s),i.unit()):n)}getAreaInDir(t,e,s,r){assertf(()=>t.isPerpendicularTo(this.normal)),assertf(()=>e.isPerpendicularTo(this.normal));const n=this.matrixInverse.transformVector(e),i=n.cross(V3.Z),o=s-i.angleXY(),a=r-i.angleXY(),c=this.matrixInverse.getTranslation().dot(n.unit());function h(t){return(t-Math.sin(t)*Math.cos(t))/2}function u(t){return Math.pow(Math.sin(t),3)/3}function l(t){return(Math.cos(3*t)-9*Math.cos(t))/24}const f=-c*(-Math.cos(a)+Math.cos(o)),p=h(a)-h(o)+f,d=(u(a)-u(o)+-c*(-Math.cos(a)-Math.cos(o))/2*f)/p,m=(l(a)-l(o)- -c/2*f)/p,$=this.matrix.xyAreaFactor();return assert(!eq0($)),{area:p*$,centroid:this.matrix.transformPoint(M4.rotateZ(i.angleXY()).transformPoint(new V3(d,m,0)))}}at(t){return assertNumbers(t),this.center.plus(this.f1.times(Math.cos(t))).plus(this.f2.times(Math.sin(t)))}tangentAt(t){return assertNumbers(t),this.f2.times(Math.cos(t)).minus(this.f1.times(Math.sin(t)))}ddt(t){return assertNumbers(t),assert(this.isValidT(t)),this.f2.times(-Math.sin(t)).minus(this.f1.times(Math.cos(t)))}tangentAt2(t,e){return this.f2.times(t).minus(this.f1.times(e))}isCircular(){return eq(this.f1.length(),this.f2.length())&&this.f1.isPerpendicularTo(this.f2)}isColinearTo(t){if(!hasConstructor(t,EllipseCurve$$1))return!1;if(!this.center.like(t.center))return!1;if(this==t)return!0;if(this.isCircular())return t.isCircular()&&eq(this.f1.length(),t.f1.length())&&this.normal.isParallelTo(t.normal);{let{f1:e,f2:s}=this.rightAngled(),{f1:r,f2:n}=t.rightAngled();return e.length()>s.length()&&([e,s]=[s,e]),r.length()>n.length()&&([r,n]=[n,r]),eq(e.squared(),Math.abs(e.dot(r)))&&eq(s.squared(),Math.abs(s.dot(n)))}}pointT(t){assertVectors(t),assert(this.containsPoint(t));const e=this.matrixInverse.transformPoint(t),s=EllipseCurve$$1.XYLCPointT(e,this.tMin,this.tMax);return assert(this.isValidT(s)),s}reversed(){return new EllipseCurve$$1(this.center,this.f1.negated(),this.f2,PI-this.tMax,PI-this.tMin)}eccentricity(){const t=this.rightAngled(),e=t.f1.length(),s=t.f1.length(),[r,n]=e>s?[e,s]:[s,e];return Math.sqrt(1-n*n/r/r)}circumference(){return this.arcLength(-Math.PI,Math.PI)}arcLength(t=this.tMin,e=this.tMax,s=2){assert(te.at(t).lengthXY()-1,c=t=>e.at(t).xy().dot(e.tangentAt(t))/e.at(t).lengthXY();checkDerivate(a,c,-PI,PI,1);const h=[];for(let t=-.8*PI;teq(e,t))&&h.push(e)}const u=[];for(const s of h){const r=this.matrix.transformPoint(e.at(s));this.containsPoint(r)&&t.containsPoint(r)&&u.push({tThis:this.pointT(r),tOther:t.pointT(r),p:r})}return u}return this.isTsWithPlane(P3$$1.normalOnAnchor(t.normal.unit(),t.center)).mapFilter(e=>{const s=this.at(e);if(t.containsPoint(s))return{tThis:e,tOther:t.pointT(s),p:s}})}isInfosWithCurve(t){return t instanceof EllipseCurve$$1?this.isInfosWithEllipse(t):super.isInfosWithCurve(t)}transform4(t){const e=t=>sign(t)*sqrt((1-cos(t))/(1+cos(t))),s=new M4(0,-1,0,1,2,0,0,0,0,0,1,0,0,1,0,1);return parabola4Projection$$1(M4.product(t,this.matrix,s),e(this.tMin),e(this.tMax))}roots(){return arrayFromFunction(3,t=>{return intersectionUnitCircleLine2$$1(this.f2.e(t),-this.f1.e(t),0).map(([t,e])=>Math.atan2(e,t)).filter(t=>this.isValidT(t))})}closestTToPoint(t,e){e=e||this.matrixInverse.transformPoint(t).angleXY();const s=t.minus(this.center);return newtonIterate1d(t=>this.tangentAt(t).dot(this.f1.times(Math.cos(t)).plus(this.f2.times(Math.sin(t))).minus(s)),e,8)}area(){return Math.PI*this.f1.cross(this.f2).length()}angleToT(t){const e=this.f1.unit().times(Math.cos(t)).plus(this.f2.rejectedFrom(this.f1).unit().times(Math.sin(t)));return this.matrixInverse.transformVector(e).angleXY()}}EllipseCurve$$1.UNIT=new EllipseCurve$$1(V3.O,V3.X,V3.Y),EllipseCurve$$1.prototype.hlol=Curve$$1.hlol++,EllipseCurve$$1.prototype.tIncrement=2*Math.PI/128;class NURBS$$1 extends Curve$$1{constructor(t,e,s=NURBS$$1.openUniformKnots(t.length,e),r=s[e],n=s[s.length-e-1]){super(r,n),this.points=t,this.degree=e,this.knots=s;const i=t.length+e+1;assert(s.length===i,"bad knot vector length: expected "+i+" (degree = "+e+" pcount = "+t.length+"), but was "+s.length),assert(s[e]<=r),assert(n<=s[s.length-e-1]);for(let e=0;e=1,"degree must be at least 1 (linear)"),assert(e%1==0);for(let t=0;te;o--){const a=(t-r[o+n-s])/(r[o+n-e]-r[o+n-s]);for(let t=0;t<4;t++)i[4*o+t]=(1-a)*i[4*(o-1)+t]+a*i[4*o+t]}return new Vector(i.slice(4*s,4*(s+1)))}at(t){return this.at4(t).p3()}ptDtDdt4(t){const{points:e,degree:s,knots:r}=this,n=this.tInterval(t),i=Vector.pack(e,new Float64Array(4*(s+1)),n-s,0,s+1);let o,a=Vector.Zero(4);for(let e=0;ee;o--){const a=(t-r[o+n-s])/(r[o+n-e]-r[o+n-s]);for(let t=0;t<4;t++)i[4*o+t]=(1-a)*i[4*(o-1)+t]+a*i[4*o+t]}}return[new Vector(i.slice(4*s,4*s+4)),o,a]}tangentAt(t){const[e,s]=this.ptDtDdt4(t);return s.times(e.w).minus(e.times(s.w)).div(Math.pow(e.w,2)).V3()}ddt(t){const[e,s,r]=this.ptDtDdt4(t);return Vector.add(e.times(-e.w*r.w+2*Math.pow(s.w,2)),s.times(-2*e.w*s.w),r.times(Math.pow(e.w,2))).div(Math.pow(e.w,3)).V3()}ptDtDdt(t){const[e,s,r]=this.ptDtDdt4(t);return[e.p3(),s.times(e.w).minus(e.times(s.w)).div(Math.pow(e.w,2)).V3(),Vector.add(e.times(-e.w*r.w+2*Math.pow(s.w,2)),s.times(-2*e.w*s.w),r.times(Math.pow(e.w,2))).div(Math.pow(e.w,3)).V3()]}pointT(t){return this.closestTToPoint(t)}closestTToPoint(t,e,s=this.tMin,r=this.tMax){return void 0===e&&(e=arraySamples(s,r,32).withMax(e=>-this.at(e).distanceTo(t))),newtonIterateWithDerivative2(e=>{const[s,r,n]=this.ptDtDdt(e);return[s.minus(t).dot(r),r.squared()+s.minus(t).dot(n)]},e,8,this.tMin,this.tMax)}containsPoint(t){const e=this.closestTToPoint(t);return void 0!==e&&this.at(e).like(t)}derivate(){const t=this.degree,e=arrayFromFunction(this.points.length-1,e=>this.points[e].to(this.points[e+1]).times(t/(this.knots[e+t+1]-this.knots[e+1])));return new NURBS$$1(e,this.degree-1,this.knots.slice(1,-1),this.tMin,this.tMax)}withKnot(t,e=1){assert(between(t,this.tMin,this.tMax));const s=this.tInterval(t),{knots:r,points:n,degree:i}=this,o=arrayFromFunction(this.degree,e=>{const o=s-i+1+e,a=t-r[o],c=0==a?0:a/(r[o+i]-r[o]);return assert(between(c,0,1)),Vector.lerp(n[o-1],n[o],c)}),a=n.slice();a.splice(s-i+1,i-1,...o);const c=r.slice();return c.splice(s+1,0,t),new NURBS$$1(a,i,c,this.tMin,this.tMax)}removeKnot(t){const{knots:e,points:s,degree:r}=this;let n=this.tInterval(t),i=0;for(;e[n+1]==t;)n++,i++;if(0==i)throw new Error("There is no knot "+t+"!");const o=[s[n-r-1]],a=e.slice();a.splice(n,1);for(let e=n-r;e<=n-i;e++){const n=(a[e+r]-a[e])/(t-a[e]),i=Vector.lerp(o.last,s[e],n);o.push(i)}if(o.last.like(s[n+1-i])){const t=s.slice();return t.splice(n-r-1,r-i+3,...o),new NURBS$$1(t,r,a)}}static openUniformKnots(t,e,s=0,r=1){const n=t+e+1;return arrayFromFunction(n,t=>t<=e?s:t>=n-e-1?r:lerp(s,r,(t-e)/(n-2*e-1)))}static bezierKnots(t,e=0,s=1){const r=new Array(2*(t+1));for(let n=0;nt instanceof V3?new Vector(new Float64Array([t.x,t.y,t.z,1])):t),t.length-1,arrayFromFunction(2*t.length,e=>e1)){return assert(t.length==r.length),new NURBS$$1(t.map((t,e)=>Vector.fromV3AndWeight(t,r[e])),e,s)}isUniform(t=0){const e=arrayFromFunction(this.knots.length-1,t=>this.knots[t+1]-this.knots[t]),[s,r]=minAndMax(e);return eq(s,r,t)}isBSpline(t=0){const[e,s]=minAndMax(this.points.map(t=>t.w));return eq(e,s,t)}isBezier(t=0){if(this.degree+1!=this.points.length)return!1;const[e,s]=minAndMax(this.knots,0,this.degree+1);if(!eq(e,s,t))return!1;const[r,n]=minAndMax(this.knots,this.degree+1);return!!eq(r,n,t)}getSegments(){const{knots:t,points:e,degree:s}=this,r=[],n=Vector.pack(e,new Float64Array(4*e.length)),i=t=>new Vector(n.slice(4*t,4*(t+1)));let o=s+1;for(;ori(e.length-s-1+t)),c=arrayFromFunction(2*(s+1),e=>enew Vector(h.slice(4*t,4*(t+1))),a=new Array(n+1-i);for(let t=0;tvArrGet(h,4,t));return[new NURBS$$1(a,r,u),new NURBS$$1(f,r,l)]}simplify(){if(assert(this.isBezier()),3==this.degree&&this.isBSpline())return new BezierCurve$$1(this.points[0].p3(),this.points[1].p3(),this.points[2].p3(),this.points[3].p3(),this.tMin,this.tMax);if(2==this.degree){const[t,e,s]=this.points,[r,n,i]=this.points.map(t=>t.p3()),o=NURBS$$1.simplifyUnit2(t.w,e.w,s.w).transform(M4.forSys(n.to(r),n.to(i),void 0,n)),[a,c]=[o.pointT(r),o.pointT(i)].sort();return o.withBounds(snap(a,o.tMin),snap(c,o.tMax))}return 1==this.degree?L3$$1.throughPoints(this.points[0].p3(),this.points[1].p3()):this}static simplifyUnit2(t,e,s){const r=t*s-Math.pow(e,2),n=t*s/2/r,i=new V3(n,n,0),o=(Math.pow(e,2)+r-2*e*sqrt(abs(r)))/2/r,a=V3.X,c=new V3(o,n,0);return eq0(r)?new ParabolaCurve$$1(new V3(.25,.25,0),new V3(1,-1,0),new V3(1,1,0),-.5,.5):r<0?new HyperbolaCurve$$1(i,i.to(a),i.to(c)):new EllipseCurve$$1(i,i.to(a),i.to(c),0)}elevateDegreeBezier(){assert(this.isBezier());const t=new Array(this.points.length+1);t[0]=this.points[0],t[this.points.length]=this.points[this.points.length-1];for(let e=1;et.elevateDegreeBezier()),e=new Array(2+t.length*this.degree);e[0]=t[0].points[0],e.last=t.last.points.last;for(let s=0;st.timesVector(e)),this.degree,this.knots,this.tMin,this.tMax)}tInterval(t){const{degree:e,knots:s}=this;for(let r=e;r=s[r]&&t<=s[r+1])return r;throw new Error(t+" "+s)}static UnitCircle(t=2,e=0,s=PI){const r=(s-e)/t,n=sin(PI/2-r/2);console.log(r/2/DEG);const i=1/cos(r/2),o=arrayFromFunction(2*t+1,r=>{const o=lerp(e,s,r/2/t);return r%2==0?VV(cos(o),sin(o),0,1):VV(i*n*cos(o),i*n*sin(o),0,n)}),a=[];a.push(e,e,e);for(let r=0;rthis.at(t)),...this.points.map(t=>t.p3())],lines:this.points.flatMap((t,e,s)=>s[e+1]?[t.p3(),s[e+1].p3()]:[])}}isTsWithPlane(t){const{knots:e,degree:s,points:r}=this,n=[e[s],...r.slice(1,-1).map((t,r)=>this.closestTToPoint(t.p3(),void 0,e[r+3],e[r+s])),e[e.length-s-1]],i=[];for(let e=0;e{console.log("startT",e);const s=e=>{const[s,r]=this.ptDtDdt(e);return[t.distanceToPointSigned(s),t.normal1.dot(r)]};let r=newtonIterateWithDerivative2(s,e,8,this.tMin,this.tMax),[n,o]=void 0===r?[]:s(r);void 0!==r&&eq0(n)&&!eq0(o)||(r=newtonIterateWithDerivative2(e=>{const[,s,r]=this.ptDtDdt(e);return[t.normal1.dot(s),t.normal1.dot(r)]},e,8,this.tMin,this.tMax)),[n,o]=void 0===r?[]:s(r),void 0!==r&&eq0(n)&&!i.some(t=>eq(t,r))&&i.push(r)},r=this.points[e].p3(),o=this.points[e+1].p3(),a=snap0(t.distanceToPointSigned(r)),c=snap0(t.distanceToPointSigned(o));if(a*c<0){s(lerp(n[e],n[e+1],a/(a-c)))}else 0==c&&s(this.closestTToPoint(o,n[e+1]))}return i}isInfosWithCurve(t){return t instanceof L3$$1?this.isInfosWithLine(t.anchor,t.dir1):super.isInfosWithCurve(t)}isInfosWithLine(t,e){const s=P3$$1.fromPoints(this.points.map(t=>t.p3())),r=L3$$1.anchorDirection(t,e),n=this.points.map(t=>s.distanceToPoint(t.p3())).max(),i=eq0(n);if(i&&!s.containsLine(r)){const[n]=r.isTsWithPlane(s);if(void 0===n)return[];const i=r.at(n);return this.containsPoint(i)?[{tThis:this.pointT(i),tOther:L3$$1.pointT(t,e,i),p:i}]:[]}{const r=this.isTsWithPlane(P3$$1.normalOnAnchor(s.normal1.cross(e),t)).map(s=>{const r=this.at(s);return{tThis:s,tOther:L3$$1.pointT(t,e,r),p:r}});return i?r:r.filter(s=>L3$$1.containsPoint(t,e,s.p))}}roots(){console.log(this.tMin,this.tMax),arraySamples(this.tMin,this.tMax,30).forEach(t=>{console.log(t+","+this.tangentAt(t).z)});const t=[[],[],[]];for(let e=0;e{console.log("d",s,"startT",e);const r=newtonIterateWithDerivative2(t=>{const[,e,r]=this.ptDtDdt(t);return[e.e(s),r.e(s)]},e,8,this.tMin,this.tMax);void 0!==r&&t[s].push(r),console.log("d",s,"startT",e,"root",r)},r=this.points[e].p3(),n=this.points[e+1].p3(),i=r.to(n);for(let t=0;t<3;t++)if(0!==e&&eq0(i.e(t))){s(lerp(this.knots[e],this.knots[e+this.degree+2],.5),t)}else if(ee.like(t.points[s]))&&this.knots.every((e,s)=>eq(e,t.knots[s]))}isColinearTo(t){throw new Error("This doesn't even make sense.")}}function minAndMax(t,e=0,s=t.length){let r=1/0,n=-1/0;for(let i=e;it[i]&&(r=t[i]),nthis.containsPoint(t));throw new Error(""+t)}equals(t){return hasConstructor(t,P3$$1)&&this.normal1.equals(t.normal1)&&this.w==t.w}hashCode(){return 31*this.normal1.hashCode()|0+floatHashCode(this.w)}}P3$$1.YZ=new P3$$1(V3.X,0),P3$$1.ZX=new P3$$1(V3.Y,0),P3$$1.XY=new P3$$1(V3.Z,0);class Surface$$1 extends Transformable{static loopContainsPointGeneral(t,e,s,r){const n=P3$$1.normalOnAnchor(r,e),i=t.map(t=>t.colinearToLine(s));let o=!1;function a(t){const e=s.pointT(t);return!!eq0(e)||(e>0&&(o=!o),!1)}for(let o=0;os.isColinearTo(t.curve));let a=!1;void 0===r&&(r=s.pointT(e));const c=r;function h(t){const e=s.pointT(t);return!!eq(c,e)||(ct)){return callsce.call(void 0,"new "+this.constructor.name,...this.getConstructorParameters())}getExtremePoints(){return[]}isCurvesWithSurface(t){return t.isCurvesWithSurface(this)}containsCurve(t){if(t instanceof PPCurve$$1&&(this.equals(t.parametricSurface1)||this.equals(t.parametricSurface2)))return!0;if(t instanceof ImplicitCurve$$1){for(let e=ceil(t.tMin)+1;e<=floor(t.tMax)-1;e++)if(!this.containsPoint(t.points[e]))return!1;return!0}return!1}flipped2(t){return t?this.flipped():this}clipCurves(t){return t}equals(t){return this===t||this.constructor===t.constructor&&this.getConstructorParameters().equals(t.getConstructorParameters())}hashCode(){return this.getConstructorParameters().hashCode()}zDirVolume(t){return this.visit(ZDirVolumeVisitor$$1,t)}calculateArea(t){return this.visit(CalculateAreaVisitor$$1,t)}}var PointVsFace;!function(t){t[t.INSIDE=0]="INSIDE",t[t.OUTSIDE=1]="OUTSIDE",t[t.ON_EDGE=2]="ON_EDGE"}(PointVsFace||(PointVsFace={}));class ImplicitSurface$$1 extends Surface$$1{static is(t){return t.implicitFunction&&t.didp}}class ParametricSurface$$1 extends Surface$$1{constructor(t,e,s,r){super(),this.uMin=t,this.uMax=e,this.vMin=s,this.vMax=r,assertNumbers(t,e,s,r),assert(tt[t.length-4])(this.getConstructorParameters())==this.uMin,this.getConstructorParameters(),this.uMin)}static isCurvesParametricImplicitSurface(t,e,s,r=s,n){const i=t.pUVFunc(),o=e.implicitFunction(),a=t.dpdu(),c=t.dpdv(),h=e.didp.bind(e),u=MathFunctionR2R.forFFxFy((t,e)=>o(i(t,e)),(t,e)=>h(i(t,e)).dot(a(t,e)),(t,e)=>h(i(t,e)).dot(c(t,e)));return Curve$$1.breakDownIC(u,t,s,r,n,(t,s)=>e.containsPoint(i(t,s))).map(({points:s,tangents:r},i)=>PICurve$$1.forParametricPointsTangents(t,e,s,r,n))}static isCurvesParametricParametricSurface(t,e,s,r=s,n){return breakDownPPCurves$$1(t,e,s,r,n)}static is(t){return t.pUVFunc}pUV(t,e){return this.pUVFunc()(t,e)}pUVFunc(){return this.pUV.bind(this)}uvP(t){return this.uvPFunc()(t)}uvPFunc(){return this.uvP.bind(this)}bounds(t,e){return this.uMin<=t&&t<=this.uMax&&this.vMin<=e&&e<=this.vMax}boundsSigned(t,e){return min(t-this.uMin,this.uMax-t,e-this.vMin,this.vMax-e)}normalP(t){const e=this.uvPFunc()(t);return this.normalUV(e.x,e.y)}normalUVFunc(){return this.normalUV.bind(this)}normalUV(t,e){return this.normalUVFunc()(t,e)}parametersValid(t,e){return between(t,this.uMin,this.uMax)&&between(e,this.vMin,this.vMax)}toMesh(t=this.uStep,e=this.vStep){return assert(isFinite(this.vMin)&&isFinite(this.vMax)&&isFinite(this.uMin)&&isFinite(this.uMax)),assert(isFinite(t)&&isFinite(e)),Mesh.parametric(this.pUVFunc(),this.normalUVFunc(),this.uMin,this.uMax,this.vMin,this.vMax,ceil((this.uMax-this.uMin)/t),ceil((this.vMax-this.vMin)/e))}isCurvesWithImplicitSurface(t,e,s,r){return ParametricSurface$$1.isCurvesParametricImplicitSurface(this,t,e,s,r)}edgeLoopCCW(t){const e=this.uvPFunc();return isCCW(t.flatMap(t=>t.getVerticesNo0()).map(t=>e(t)),V3.Z)}like(t){if(!this.isCoplanarTo(t))return!1;const e=this.pUVFunc()(this.uMin,this.vMin),s=this.normalUVFunc()(this.uMin,this.vMin),r=t.normalP(e);return 0this.pUV(lerp(this.uMin,this.uMax,t.x),lerp(this.vMin,this.vMax,t.y)));return t.addPoints(e),t}}class ConicSurface$$1 extends ParametricSurface$$1{constructor(t,e,s,r,n=0,i=PI,o=0,a=16){super(n,i,o,a),this.center=t,this.f1=e,this.f2=s,this.dir=r,assertVectors(t,e,s,r),assert(0<=o),this.matrix=M4.forSys(e,s,r,t),this.matrixInverse=this.matrix.inversed(),this.normalDir=sign(this.f1.cross(this.f2).dot(this.dir)),this.pLCNormalWCMatrix=this.matrix.as3x3().inversed().transposed().scale(this.normalDir)}pointFoot(t,e,s){if(void 0===e||void 0===s){const r=this.matrixInverse.transformPoint(t),n=r.angleXY();void 0===e&&(e=n<-PI/2?n+TAU:n),void 0===s&&(s=r.z+(r.lengthXY()-r.z)*SQRT1_2)}const{0:r,1:n}=newtonIterate(([e,s])=>{const r=this.pUV(e,s).to(t);return[this.dpdu()(e,s).dot(r),this.dpdv()(e).dot(r)]},[e,s]);return new V3(r,n,0)}get apex(){return this.center}static atApexThroughEllipse(t,e,s,r,n,i){return assertVectors(t),assertInst(EllipseCurve$$1,e),new ConicSurface$$1(t,e.f1,e.f2,t.to(e.center),s,r,n,i)}static unitISLineTs(t,e){const{x:s,y:r,z:n}=t,{x:i,y:o,z:a}=e,c=i*i+o*o-a*a;return pqFormula(2*(s*i+r*o-n*a)/c,(s*s+r*r-n*n)/c).filter(t=>0n)return[new L3$$1(V3.O,new V3(e,sqrt(r-n),-t).unit()),new L3$$1(V3.O,new V3(e,-sqrt(r-n),-t).unit())]}else{if(eq(r,n)){const r=new V3(s/2/t,0,s/2/e),n=new V3(s/2/t,s/e,s/2/e),i=new V3(0,0,s/e).minus(r);return[new ParabolaCurve$$1(r,n.minus(r),i.z<0?i.negated():i)]}if(rn){const i=new V3(-t*s/(n-r),0,s*e/(n-r)),o=new V3(s*e/(r-n),0,-s*t/(r-n)),a=new V3(0,s/sqrt(r-n),0);return[new HyperbolaCurve$$1(i,o.z>0?o:o.negated(),a)]}}}throw new Error("???")}equals(t){return this==t||Object.getPrototypeOf(this)==Object.getPrototypeOf(t)&&this.center.equals(t.center)&&this.f1.equals(t.f1)&&this.f2.equals(t.f2)&&this.dir.equals(t.dir)}like(t){return!!this.isCoplanarTo(t)&&this.normalDir==t.normalDir}getVectors(){return[{anchor:this.center,dir1:this.dir},{anchor:this.center.plus(this.dir),dir1:this.f1},{anchor:this.center.plus(this.dir),dir1:this.f2}]}getSeamPlane(){return P3$$1.forAnchorAndPlaneVectors(this.center,this.f1,this.dir)}loopContainsPoint(t,e){assertVectors(e);const s=this.center.like(e)?new L3$$1(e,this.matrix.transformVector(new V3(0,1,1)).unit()):L3$$1.throughPoints(e,this.apex),r=s.dir1.cross(this.dir);return Surface$$1.loopContainsPointGeneral(t,e,s,r)}getConstructorParameters(){return[this.center,this.f1,this.f2,this.dir,this.uMin,this.uMax,this.vMin,this.vMax]}isTsForLine(t){const e=this.matrixInverse.transformPoint(t.anchor),s=this.matrixInverse.transformVector(t.dir1);return ConicSurface$$1.unitISLineTs(e,s)}isCoplanarTo(t){return this===t||!!(t instanceof ConicSurface$$1&&this.apex.like(t.apex))&&this.containsEllipse(new EllipseCurve$$1(t.center.plus(t.dir),t.f1,t.f2))}containsEllipse(t){const e=t.transform(this.matrixInverse);if(e.center.z<0)return!1;const{f1:s,f2:r}=e.rightAngled(),n=e.center.plus(s),i=e.center.plus(r);return eq(Math.pow(n.x,2)+Math.pow(n.y,2),Math.pow(n.z,2))&&eq(Math.pow(i.x,2)+Math.pow(i.y,2),Math.pow(i.z,2))&&(eq0(s.z)||eq0(r.z))}containsLine(t){const e=t.transform(this.matrixInverse),s=e.dir1;return e.containsPoint(V3.O)&&eq(s.x*s.x+s.y*s.y,s.z*s.z)}containsParabola(t){assertInst(ParabolaCurve$$1,t);const e=t.transform(this.matrixInverse);if(e.center.z<0||e.f2.z<0)return!1;const{center:s,f1:r,f2:n}=e.rightAngled();return eq(s.x*s.x+s.y*s.y,s.z*s.z)&&eq0(r.z)&&eq(n.x*n.x+n.y*n.y,n.z*n.z)}containsHyperbola(t){assertInst(HyperbolaCurve$$1,t);const e=t.transform(this.matrixInverse).rightAngled(),s=e.center.xy();if(s.likeO())return!1;const r=s.angleXY(),{center:n,f1:i,f2:o}=e.rotateZ(-r);return i.z>0&&eq(n.x,i.z)&&eq(n.z,i.x)&&eq0(n.y)&&eq0(i.y)&&eq(sqrt(abs(Math.pow(n.x,2)-Math.pow(n.z,2))),abs(o.y))&&eq0(o.x)&&eq0(o.z)}containsCurve(t){return t instanceof EllipseCurve$$1?this.containsEllipse(t):t instanceof L3$$1?this.containsLine(t):t instanceof HyperbolaCurve$$1?this.containsHyperbola(t):t instanceof ParabolaCurve$$1?this.containsParabola(t):super.containsCurve(t)}transform(t){return new ConicSurface$$1(t.transformPoint(this.center),t.transformVector(this.f1).times(t.isMirroring()?-1:1),t.transformVector(this.f2),t.transformVector(this.dir),this.uMin,this.uMax,this.vMin,this.vMax)}transform4(t){const e=t.timesVector(Vector.fromV3AndWeight(this.center,1)),s=t=>new EllipseCurve$$1(new V3(0,0,t),new V3(t,0,0),new V3(0,t,0));if(eq0(e.w)){const r=e.V3(),n=s(this.vMin).transform4(t.times(this.matrix)),i=M4.forSys(n.f1,n.f2,r.unit(),n.center).inversed(),o=s(this.vMax).transform4(i.times(t.times(this.matrix))).getAABB();return new CylinderSurface$$1(n,r.unit(),this.uMin,this.uMax,min(0,o.min.z,o.max.z),max(0,o.min.z,o.max.z))}{const e=t.transformPoint(this.center),r=t.transformVector2(this.f1,this.center).times(t.isMirroring()?-1:1),n=t.transformVector2(this.f2,this.center),i=t.transformVector2(this.dir,this.center),o=M4.forSys(r,n,i,e).inversed(),a=s(this.vMin).transform4(o.times(t.times(this.matrix))).getAABB().addAABB(s(this.vMax).transform4(o.times(t.times(this.matrix))).getAABB());return new ConicSurface$$1(e,r,n,i,this.uMin,this.uMax,a.min.z,a.max.z)}}flipped(){return new ConicSurface$$1(this.center,this.f1.negated(),this.f2,this.dir)}normalUVFunc(){const{f1:t,f2:e}=this,s=this.dir;return(r,n)=>e.cross(t).plus(e.cross(s.times(Math.cos(r)))).plus(s.cross(t.times(Math.sin(r)))).unit()}normalP(t){const e=this.matrixInverse.transformPoint(t);return this.normalUVFunc()(e.angleXY(),e.z)}pUVFunc(){return(t,e)=>{const s=new V3(e*cos(t),e*sin(t),e);return this.matrix.transformPoint(s)}}dpdu(){return(t,e)=>{const s=new V3(e*-sin(t),e*cos(t),0);return this.matrix.transformVector(s)}}dpdv(){return t=>{const e=new V3(cos(t),sin(t),1);return this.matrix.transformVector(e)}}implicitFunction(){return t=>{const e=this.matrixInverse.transformPoint(t),s=e.lengthXY();return this.normalDir*(s-e.z)}}didp(t){const e=this.matrixInverse.transformPoint(t);return this.pLCNormalWCMatrix.transformVector(e.xy().unit().withElement("z",-1).times(this.normalDir))}containsPoint(t){return eq0(this.implicitFunction()(t))}uvP(t){const e=this.matrixInverse.transformPoint(t),s=e.angleXY();return new V3(s<-PI/2?s+TAU:s,e.z,0)}isCurvesWithSurface(t){return t instanceof PlaneSurface$$1?this.isCurvesWithPlane(t.plane):ImplicitSurface$$1.is(t)?ParametricSurface$$1.isCurvesParametricImplicitSurface(this,t,.1,.1/this.dir.length(),.02):super.isCurvesWithSurface(t)}getCenterLine(){return new L3$$1(this.center,this.dir)}isCurvesWithPlane(t){assertInst(P3$$1,t);const e=t.transform(this.matrixInverse),s=e.normal1,r=s.z,n=s.lengthXY(),i=e.w,o=M4.rotateZ(s.angleXY()),a=eq0(s.lengthXY())?this.matrix:this.matrix.times(o);return ConicSurface$$1.unitISPlane(n,r,i).flatMap(e=>{const s=e.transform(a);if(e instanceof EllipseCurve$$1){const t=e.transform(o),r=t.isTsWithPlane(P3$$1.ZX);return getIntervals(r,-PI,PI).filter(([e,s])=>t.at((e+s)/2).y>0).flatMap(([t,e])=>s.split(t,e))}const r=s.at(.2);return this.normalP(r).cross(t.normal1).dot(s.tangentAt(.2))>0?s:s.reversed()})}debugInfo(){return{ps:[this.center],lines:[this.center,this.center.plus(this.f1),this.center.plus(this.f2),this.center.plus(this.dir)]}}}ConicSurface$$1.UNIT=new ConicSurface$$1(V3.O,V3.X,V3.Y,V3.Z),ConicSurface$$1.prototype.uStep=PI/16,ConicSurface$$1.prototype.vStep=256;class ProjectedCurveSurface$$1 extends ParametricSurface$$1{constructor(t,e,s=t.tMin,r=t.tMax,n=-100,i=100){super(s,r,n,i),this.baseCurve=t,this.dir=e,assertInst(Curve$$1,t),assertInst(V3,e),assert(sthis.baseCurve.tangentAt(t)}dpdv(){return(t,e)=>this.dir}normalUV(t,e){return this.baseCurve.tangentAt(t).cross(this.dir).unit()}pUV(t,e){return this.baseCurve.at(t).plus(this.dir.times(e))}pointFoot(t,e){const s=new P3$$1(this.dir.unit(),0),r=this.baseCurve.project(s),n=s.projectedPoint(t),i=r.closestTToPoint(n,e,this.uMin,this.uMax),o=L3$$1.pointT(this.baseCurve.at(i),this.dir,t);return new V3(i,o,0)}uvPFunc(){const t=new P3$$1(this.dir.unit(),0),e=this.baseCurve.project(t);return s=>{const r=t.projectedPoint(s);assertNumbers(this.uMin);const n=e.pointT(r,this.uMin,this.uMax),i=L3$$1.pointT(this.baseCurve.at(n),this.dir,s);return new V3(n,i,0)}}isCurvesWithPlane(t){if(assertInst(P3$$1,t),this.dir.isPerpendicularTo(t.normal1)){return this.baseCurve.isTsWithPlane(t).map(e=>{const s=00&&(e=e.reversed()),[e]}}isCurvesWithSurface(t){if(t instanceof PlaneSurface$$1)return this.isCurvesWithPlane(t.plane);if(t instanceof ProjectedCurveSurface$$1){const e=t.dir;if(this.dir.isParallelTo(e)){return t.baseCurve.isTsWithSurface(this).map(s=>{const r=t.baseCurve.at(s),n=this.normalP(r).cross(t.normalP(r));return new L3$$1(r,e.times(sign(n.dot(e))))})}if(ImplicitSurface$$1.is(t)){let e=ParametricSurface$$1.isCurvesParametricImplicitSurface(this,t,.1,.1/t.dir.length(),.05);return e=t.clipCurves(e)}{let e=ParametricSurface$$1.isCurvesParametricParametricSurface(this,t,.05,.1/t.dir.length(),.05);return e=this.clipCurves(e),e=t.clipCurves(e)}}return t instanceof EllipsoidSurface$$1?t.isCurvesWithSurface(this):super.isCurvesWithSurface(t)}containsPoint(t){const e=this.uvPFunc()(t);return this.pUVFunc()(e.x,e.y).like(t)}containsCurve(t){if(t instanceof L3$$1)return this.dir.isParallelTo(t.dir1)&&this.containsPoint(t.anchor);if(t instanceof ImplicitCurve$$1)return super.containsCurve(t);const e=new P3$$1(this.dir.unit(),0),s=this.baseCurve.project(e),r=t.project(e);return s.isColinearTo(r)}isCoplanarTo(t){return this==t||hasConstructor(t,ProjectedCurveSurface$$1)&&this.dir.isParallelTo(t.dir)&&this.containsCurve(t.baseCurve)}like(t){if(!this.isCoplanarTo(t))return!1;const e=this.pUVFunc()(0,0),s=this.normalUVFunc()(0,0),r=t.normalP(e);return 0t.tOther)}flipped(){return new this.constructor(this.baseCurve,this.dir.negated(),this.uMin,this.uMax,-this.vMax,-this.vMin)}}ProjectedCurveSurface$$1.prototype.uStep=1/128,ProjectedCurveSurface$$1.prototype.vStep=256;class RotatedCurveSurface$$1 extends ParametricSurface$$1{constructor(t,e=M4.IDENTITY,s=0,r=PI,n=t.tMin,i=t.tMax){super(s,r,n,i),this.curve=t,this.matrix=e,assertInst(M4,e),assert(e.isNoProj()),assert(eq0(t.at(n).y)),this.matrixInverse=e.inversed(),this.vStep=this.curve.tIncrement}getConstructorParameters(){return[this.curve,this.matrix,this.uMin,this.uMax,this.vMin,this.vMax]}flipped(){return new RotatedCurveSurface$$1(this.curve,this.matrix.times(M4.mirror(P3$$1.YZ)),this.uMin,this.uMax,this.vMin,this.vMax)}transform(t){return new RotatedCurveSurface$$1(this.curve,t.isMirroring()?t.times(this.matrix).times(M4.mirror(P3$$1.YZ)):t.times(this.matrix),this.uMin,this.uMax,this.vMin,this.vMax)}containsPoint(t){const e=this.matrixInverse.transformPoint(t),s=e.lengthXY();return this.curve.containsPoint(new V3(s,0,e.z))}pUVFunc(){return(t,e)=>{const{x:s,z:r}=this.curve.at(e);return this.matrix.transformPoint(V3.polar(s,t,r))}}dpdu(){return(t,e)=>{const s=this.curve.at(e).x,r=new V3(s*-sin(t),s*cos(t),0);return this.matrix.transformVector(r)}}dpdv(){return(t,e)=>{const{x:s,z:r}=this.curve.tangentAt(e);return this.matrix.transformVector(V3.polar(s,t,r))}}normalUVFunc(){const t=this.matrix.inversed().transposed().as3x3(),e=this.matrix.isMirroring()?-1:1;return(s,r)=>{const{x:n,z:i}=this.curve.tangentAt(r);return t.transformVector(V3.polar(i,s,-n)).toLength(e)}}uvPFunc(){return t=>{const e=this.matrixInverse.transformPoint(t),s=EllipseCurve$$1.XYLCPointT(e,this.uMin,this.uMax),r=e.lengthXY();return new V3(s,this.curve.pointT(new V3(r,0,e.z)),0)}}pointFoot(t,e,s){const r=this.matrixInverse.transformPoint(t),n=abs(r.angleXY()),i=r.lengthXY();return new V3(n,this.curve.closestTToPoint(new V3(i,0,r.z)),0)}isTsForLine(t){const e=this.matrixInverse.transformPoint(t.anchor),s=this.matrixInverse.transformVector(t.dir1);if(s.isParallelTo(V3.Z))return fuzzyBetween(e.angleXY(),this.uMin,this.uMax)?this.curve.isInfosWithLine(new V3(e.lengthXY(),0,e.z),s).map(t=>t.tOther):[];if(L3$$1.containsPoint(e.xy(),s.xy(),V3.O)){const t=s.xy().unit();return[...this.curve.isInfosWithLine(new V3(t.dot(e),0,e.z),new V3(t.dot(s),0,s.z)),...this.curve.isInfosWithLine(new V3(-t.dot(e),0,e.z),new V3(-t.dot(s),0,s.z))].map(t=>t.tOther).filter(t=>fuzzyBetween(L3$$1.at(e,s,t).angleXY(),this.uMin,this.uMax))}if(s.isPerpendicularTo(V3.Z)){const t=this.isCurvesWithPlaneLC(new P3$$1(V3.Z,e.z));return t?t.flatMap(t=>t.isInfosWithLine(e,s).map(t=>t.tOther)):[]}{const t=-e.xy().dot(s.xy())/s.xy().squared(),r=L3$$1.at(e,s,t),n=r.lengthXY(),i=n*(s.z/s.lengthXY());return HyperbolaCurve$$1.XY.transform(M4.rotateX(90*DEG).scale(n,0,i).translate(0,0,r.z)).isInfosWithCurve(this.curve).map(t=>(t.p.z-e.z)/s.z).filter(t=>fuzzyBetween(L3$$1.at(e,s,t).angleXY(),this.uMin,this.uMax))}}isCurvesWithPlaneLC(t){return t.normal1.isParallelTo(V3.Z)?this.curve.isTsWithPlane(t).map(e=>{const{x:s}=this.curve.at(e);return new EllipseCurve$$1(new V3(0,0,t.w),new V3(s,0,0),new V3(0,s,0),this.uMin,this.uMax).transform(this.matrix)}):t.normal1.isPerpendicularTo(V3.Z)&&t.containsPoint(V3.O)?[this.curve.rotateZ(V3.Y.angleRelativeNormal(t.normal1,V3.Z)).transform(this.matrix)]:void 0}isCurvesWithPlane(t){const e=t.transform(this.matrixInverse),s=this.isCurvesWithPlaneLC(e);return s?s.map(t=>t.transform(this.matrix)):ParametricSurface$$1.isCurvesParametricImplicitSurface(this,new PlaneSurface$$1(t),.05,.05,.02)}loopContainsPoint(t,e){const s=this.matrixInverse.transformPoint(e),r=EllipseCurve$$1.XYLCPointT(s,this.uMin,this.uMax),n=EllipseCurve$$1.semicircle(s.lengthXY(),new V3(0,0,s.z)).transform(this.matrix);return Surface$$1.loopContainsPointEllipse(t,e,n,r)}isCoplanarTo(t){if(this===t)return!0;if(!hasConstructor(t,RotatedCurveSurface$$1))return!1;const e=this.matrixInverse.times(t.matrix);assert(!e.X.xy().likeO());const s=e.X.angleXY();return t.curve.transform(M4.rotateZ(-s).times(e)).isColinearTo(this.curve)}isCurvesWithSurface(t){return t instanceof PlaneSurface$$1?this.isCurvesWithPlane(t.plane):super.isCurvesWithSurface(t)}containsCurve(t){if(t.constructor==this.curve.constructor){const e=t.transform(this.matrixInverse),s=[0,.5,1].map(t=>lerp(e.tMin,e.tMax,t)).withMax(t=>e.at(t).lengthXY()),r=e.at(s).angleXY(),n=e.rotateZ(-r);if(this.curve.isColinearTo(n))return!0}if(t instanceof EllipseCurve$$1){const e=t.transform(this.matrixInverse);return!!e.normal.isParallelTo(V3.Z)&&(e.isCircular()&&this.curve.containsPoint(new V3(e.f1.length(),0,e.center.z)))}return super.containsCurve(t)}getExtremePoints(){return getExtremePointsHelper$$1.call(this,this.curve)}asNURBSSurface(){const t=NURBS$$1.fromEllipse(this.curve),e=NURBS$$1.UnitCircle(2,this.tMin,this.tMax);return new NURBSSurface$$1(e.points.flatMap(e=>t.points.map(t=>this.matrix.timesVector(VV(e.x*t.x,e.y*t.x,t.z*e.w,e.w*t.w)))),t.knots,e.knots,t.degree,e.degree,t.tMin,t.tMax,e.tMin,e.tMax)}}function getExtremePointsHelper$$1(t){const e=this.matrix.X,s=this.matrix.Y;return[0,1,2].flatMap(r=>{const n=s.e(r),i=-e.e(r);return(eq0(n)&&eq0(i)?[[1,0]]:intersectionUnitCircleLine2$$1(n,i,0)).flatMap(([e,s])=>{const n=Math.atan2(s,e);return lt(this.uMin,n)&<(n,this.uMax)?t.transform(this.matrix.times(M4.rotateZ(n))).roots()[r].map(t=>this.pUV(n,t)):[]})})}RotatedCurveSurface$$1.prototype.uStep=EllipseCurve$$1.prototype.tIncrement;class CylinderSurface$$1 extends ProjectedCurveSurface$$1{constructor(t,e,s=t.tMin,r=t.tMax,n=-1/0,i=1/0){super(t,e,s,r,n,i),this.baseCurve=t,assertInst(EllipseCurve$$1,t),this.matrix=M4.forSys(t.f1,t.f2,e,t.center),this.matrixInverse=this.matrix.inversed(),this.normalDir=sign(this.baseCurve.normal.dot(this.dir)),this.pLCNormalWCMatrix=this.matrix.as3x3().inversed().transposed().scale(this.normalDir),this.pWCNormalWCMatrix=this.pLCNormalWCMatrix.times(this.matrixInverse)}static semicylinder(t,e,s,r,n){return new CylinderSurface$$1(new EllipseCurve$$1(V3.O,new V3(t,0,0),new V3(0,t,0)),V3.Z,e,s,r,n)}static unitISLineTs(t,e){const{x:s,y:r}=t,{x:n,y:i}=e,o=Math.pow(n,2)+Math.pow(i,2),a=2*(s*n+r*i),c=Math.pow(s,2)+Math.pow(r,2)-1;return pqFormula(a/o,c/o).filter(t=>EllipseCurve$$1.XYLCValid(new V3(s+n*t,r+i*t,0)))}normalP(t){return this.pLCNormalWCMatrix.transformVector(this.matrixInverse.transformPoint(t).xy()).unit()}loopContainsPoint(t,e){if(assertVectors(e),!this.containsPoint(e))return OUTSIDE$$1;const s=new L3$$1(e,this.dir.unit()),r=this.dir.cross(this.normalP(e));return Surface$$1.loopContainsPointGeneral(t,e,s,r)}isTsForLine(t){assertInst(L3$$1,t);const e=this.matrixInverse.transformVector(t.dir1);if(e.isParallelTo(V3.Z))return[];const s=this.matrixInverse.transformPoint(t.anchor);return assert(!CylinderSurface$$1.unitISLineTs(s,e).length||!isNaN(CylinderSurface$$1.unitISLineTs(s,e)[0]),"sad "+e),CylinderSurface$$1.unitISLineTs(s,e)}isCoplanarTo(t){return this==t||hasConstructor(t,CylinderSurface$$1)&&this.dir.isParallelTo(t.dir)&&this.containsEllipse(t.baseCurve,!1)}like(t){if(!this.isCoplanarTo(t))return!1;return 0{return(this.matrixInverse.transformPoint(t).lengthXY()-1)*this.normalDir}}didp(t){const e=this.matrixInverse.transformPoint(t),s=e.lengthXY(),r=new V3(e.x/s,e.y/s,0);return this.pLCNormalWCMatrix.transformVector(r)}containsPoint(t){const e=this.matrixInverse.transformPoint(t);return this.baseCurve.isValidT(EllipseCurve$$1.XYLCPointT(e,this.uMin,this.uMax))}uvP(t){assert(1==arguments.length);const e=this.matrixInverse.transformPoint(t),s=EllipseCurve$$1.XYLCPointT(e,this.vMin,this.vMax);return new V3(s,e.z,0)}isCurvesWithSurface(t){if(t instanceof ProjectedCurveSurface$$1&&t.dir.isParallelTo(this.dir)){const e=t.baseCurve.transform(M4.project(this.baseCurve.getPlane(),this.dir));return this.baseCurve.isInfosWithCurve(e).map(e=>{const s=sign(this.normalP(e.p).cross(t.normalP(e.p)).dot(this.dir))||1;return new L3$$1(e.p,this.dir.times(s))})}if(t instanceof CylinderSurface$$1&&eq0(this.getCenterLine().distanceToLine(t.getCenterLine())))throw new Error;return super.isCurvesWithSurface(t)}getCenterLine(){return new L3$$1(this.baseCurve.center,this.dir)}facesOutwards(){return this.baseCurve.normal.dot(this.dir)>0}getSeamPlane(){let t=this.baseCurve.f1.cross(this.dir);return t=t.times(-sign(t.dot(this.baseCurve.f2))),P3$$1.normalOnAnchor(t,this.baseCurve.center)}clipCurves(t){return t.flatMap(t=>t.clipPlane(this.getSeamPlane()))}}CylinderSurface$$1.UNIT=new CylinderSurface$$1(EllipseCurve$$1.UNIT,V3.Z,void 0,void 0,0,1),CylinderSurface$$1.prototype.uStep=TAU/32,CylinderSurface$$1.prototype.vStep=256;class EllipsoidSurface$$1 extends ParametricSurface$$1{constructor(t,e,s,r,n=0,i=PI,o=-PI/2,a=PI/2){super(n,i,o,a),this.center=t,this.f1=e,this.f2=s,this.f3=r,assert(0<=n&&n<=PI),assert(0<=i&&i<=PI),assert(-PI/2<=o&&o<=PI/2),assert(-PI/2<=a&&a<=PI/2),assertVectors(t,e,s,r),this.matrix=M4.forSys(e,s,r,t),this.matrixInverse=this.matrix.inversed(),this.normalDir=sign(this.f1.cross(this.f2).dot(this.f3)),this.pLCNormalWCMatrix=this.matrix.as3x3().inversed().transposed().scale(this.normalDir),this.pWCNormalWCMatrix=this.pLCNormalWCMatrix.times(this.matrixInverse)}static unitArea(t){return t.map(t=>{if(t.curve instanceof PICurve$$1){const e=t.curve.calcSegmentPoints(t.aT,t.bT,t.a,t.b,t.aT>t.bT,!0);let s=0;for(let t=0;t{const s=t.curve.at(e),r=t.curve.tangentAt(e);return abs(s.angleXY())*r.z},t.aT,t.bT,1)}throw new Error}).sum()}static unitISTsWithLine(t,e){const s=e.dot(e),r=2*t.dot(e),n=t.dot(t)-1;return pqFormula(r/s,n/s).filter(s=>le(0,t.y+s*e.y))}static unitISCurvesWithPlane(t){const e=Math.abs(t.w);if(lt(e,1)){const s=Math.sqrt(1-Math.pow(e,2)),r=t.normal1.y*t.w,n=abs(e*s);if(le(r,-n)&&!eq0(e))return[];if(le(r,0)&&!t.normal1.isParallelTo(V3.Y)){const e=t.normal1.isParallelTo(V3.Y)?V3.Z:t.normal1.cross(V3.Y).toLength(s),n=e.cross(t.normal1),i=-r/n.y,o=max(0,Math.asin(i));return[new EllipseCurve$$1(t.anchor,e,n,o,PI-o)]}{const e=(t.normal1.isParallelTo(V3.Y)?V3.X:t.normal1.cross(V3.Y)).toLength(s),n=e.cross(t.normal1),i=eq0(n.y)?-1:-r/n.y,o=Math.acos(max(-1,i-NLA_PRECISION));return[new EllipseCurve$$1(t.anchor,n.negated(),e,PI-o,PI),new EllipseCurve$$1(t.anchor,n,e.negated(),0,o)]}}return[]}static unitISCurvesWithEllipsoidSurface(t){if(t.isSphere()){const e=t.f1.length(),s=t.center.length();if(le(1,s-e)||le(s+e,1)||le(s-e,-1))return[];{const r=2*function(t,e,s){const r=(t+e+s)/2;return sqrt(r*(r-t)*(r-e)*(r-s))}(1,e,s)/s,n=sign(1+Math.pow(s,2)-Math.pow(e,2))*sqrt(1-Math.pow(r,2)),i=new P3$$1(t.center.unit(),n);return EllipsoidSurface$$1.unitISCurvesWithPlane(i.flipped())}}throw new Error}static unitISCurvesWithCylinderSurface(t){if(new L3$$1(t.baseCurve.center,t.dir).containsPoint(V3.O)){const e=t.baseCurve.transform(M4.project(new P3$$1(t.dir,0))),s=e.f1.length(),r=e.f2.length();if(lt(1,min(s,r)))return[];if(e.isCircular()){const r=Math.sqrt(1-Math.pow(min(1,s),2)),n=(t.dir.y<0?t.dir.negated():t.dir).times(r);return[new EllipseCurve$$1(n,e.f1,e.f2)]}}throw new Error}static sphere(t,e=V3.O){return assertNumbers(t),new EllipsoidSurface$$1(e,new V3(t,0,0),new V3(0,t,0),new V3(0,0,t))}static forABC(t,e,s,r=V3.O){return new EllipsoidSurface$$1(r,new V3(t,0,0),new V3(0,e,0),new V3(0,0,s))}static calculateAreaSpheroid(t,e,s,r){assertf(()=>t.isPerpendicularTo(e)),assertf(()=>e.isPerpendicularTo(s)),assertf(()=>s.isPerpendicularTo(t));const n=M4.forSys(t,e,s).inversed(),i=t.length(),o=s.unit();return r.map(t=>{if(t.curve instanceof EllipseCurve$$1){return glqInSteps(e=>{const s=t.curve.at(e),r=t.tangentAt(e),a=n.transformPoint(s);return a.angleXY()*i*Math.sqrt(1+Math.pow(a.z,2))*Math.sqrt(1+Math.pow(o.dot(r),2))},t.aT,t.bT,1)}throw new Error}).sum()}getConstructorParameters(){return[this.center,this.f1,this.f2,this.f3,this.uMin,this.uMax,this.vMin,this.vMax]}equals(t){return this==t||Object.getPrototypeOf(t)==this.constructor.prototype&&this.matrix.equals(t.matrix)}edgeLoopCCW(t){return EllipsoidSurface$$1.unitArea(t.map(t=>t.transform(this.matrixInverse)))>0}like(t){return!!this.isCoplanarTo(t)&&this.matrix.determinant3()*t.matrix.determinant3()>0}rootPoints(){}toMesh(){return ParametricSurface$$1.prototype.toMesh.call(this)}clipCurves(t){return t.flatMap(t=>t.clipPlane(this.getSeamPlane()))}dpdu(){return(t,e)=>this.matrix.transformVector(new V3(cos(e)*-sin(t),cos(e)*cos(t),0))}dpdv(){return(t,e)=>this.matrix.transformVector(new V3(-sin(e)*cos(t),-sin(e)*sin(t),cos(e)))}isCurvesWithPCS(t){let e=ParametricSurface$$1.isCurvesParametricImplicitSurface(t,this,.1,.1/t.dir.length(),.05);return e=this.clipCurves(e)}isCurvesWithPCSSmart(t){const e=t.transform(this.matrixInverse),s=e.baseCurve.project(new P3$$1(e.dir,0)),r=s.isTsWithSurface(EllipsoidSurface$$1.UNIT),n=getIntervals(r,s.tMin,s.tMax).filter(([t,e])=>s.at((t+e)/2).length()<1),i=[0,1].map(t=>r=>{const n=snap(s.at(r).squared(),1),i=sqrt(1-n);return eq0(i)?s.at(r):s.at(r).plus(e.dir.times(sign(t-.5)*i))}),o=[0,1].map(t=>r=>{const n=snap(s.at(r).squared(),1),i=s.at(r).times(-1/sqrt(1-n)).dot(s.tangentAt(r));return s.tangentAt(r).plus(e.dir.times(sign(t-.5)*i))}),a=[];for(const[e,s]of n)for(const r of[0,1]){const n=t=>i[r](t).y,c=t=>o[r](t).y;checkDerivate(n,c,e+.1,s-.1);const h=getRoots(n,e+NLA_PRECISION,s-NLA_PRECISION,1/2048,c),u=getIntervals(h,e,s).filter(([t,e])=>n((t+e)/2)>0);for(const[e,s]of u){let n=i[r](e),o=i[r](s);0===r&&([n,o]=[o,n]),assert(EllipsoidSurface$$1.UNIT.containsPoint(n)),assert(EllipsoidSurface$$1.UNIT.containsPoint(o)),a.push(PICurve$$1.forStartEnd(t,this,this.matrix.transformPoint(o),this.matrix.transformPoint(n),void 0))}}return t.clipCurves(a)}isCurvesWithSurface(t){if(t instanceof PlaneSurface$$1)return this.isCurvesWithPlane(t.plane);if(t instanceof CylinderSurface$$1)return this.isCurvesWithCylinderSurface(t);if(t instanceof EllipsoidSurface$$1){const e=t.transform(this.matrixInverse),s=EllipsoidSurface$$1.unitISCurvesWithEllipsoidSurface(e).map(t=>t.transform(this.matrix));return t.clipCurves(s)}if(t instanceof ProjectedCurveSurface$$1)return this.isCurvesWithPCS(t);if(t instanceof ParametricSurface$$1){let e=ParametricSurface$$1.isCurvesParametricImplicitSurface(t,this,.1,.1,.05);return e=this.clipCurves(e),e=t.clipCurves(e)}throw new Error}isCurvesWithPlane(t){const e=t.transform(this.matrixInverse);return EllipsoidSurface$$1.unitISCurvesWithPlane(e).map(t=>t.transform(this.matrix))}isCurvesWithCylinderSurface(t){if(L3$$1.containsPoint(t.baseCurve.center,t.dir,this.center)){assert(this.isSphere());const e=t.baseCurve.transform(M4.project(t.baseCurve.getPlane(),t.dir));if(e.isCircular()){const t=this.f1.length(),s=e.f1.length();eq(t,s),assert(!1)}}return this.isCurvesWithPCS(t)}isTsForLine(t){assertInst(L3$$1,t);const e=this.matrixInverse.transformPoint(t.anchor),s=this.matrixInverse.transformVector(t.dir1);return EllipsoidSurface$$1.unitISTsWithLine(e,s)}isCoplanarTo(t){if(this===t)return!0;if(!hasConstructor(t,EllipsoidSurface$$1))return!1;if(!this.center.like(t.center))return!1;if(this.isSphere())return t.isSphere()&&eq(this.f1.length(),this.f2.length());const e=this.matrixInverse.times(t.matrix);return e.like3x3()&&e.isOrthogonal()}containsEllipse(t){const e=t.transform(this.matrixInverse),s=e.center.length(),r=Math.sqrt(1-Math.pow(s,2));return lt(s,1)&&e.isCircular()&&e.f1.hasLength(r)}containsCurve(t){return t instanceof EllipseCurve$$1?this.containsEllipse(t):super.containsCurve(t)}transform(t){return assert(t.isNoProj(),()=>t.sce),new EllipsoidSurface$$1(t.transformPoint(this.center),t.transformVector(this.f1),t.transformVector(this.f2),t.transformVector(this.f3).times(t.isMirroring()?-1:1))}transform4(t){console.log("transform4");const e=t.times(this.matrix);console.log(e.toString());const s=V(e.m[12],e.m[13],e.m[14]),r=this.pLCNormalWCMatrix.inversed().transformPoint(s),n=r.angleXY(),i=Math.asin(clamp(r.z,-1,1)),o=e.transformPoint(s.unit()),a=e.transformPoint(s.unit().negated()),c=V3.lerp(o,a,.5);return console.log(s.sce,n,i,o,a,"newCenter",c.sce),new EllipsoidSurface$$1(c,t.transformVector2(this.f1,this.center),t.transformVector2(this.f2,this.center),t.transformVector2(this.f3,this.center).times(t.isMirroring()?-1:1))}isInsideOut(){return this.f1.cross(this.f2).dot(this.f3)<0}flipped(){return new EllipsoidSurface$$1(this.center,this.f1,this.f2,this.f3.negated(),this.uMin,this.uMax,-this.vMax,-this.vMin)}normalUVFunc(){return(t,e)=>{const{f1:s,f2:r,f3:n}=this;return r.cross(n).times(Math.cos(e)*Math.cos(t)).plus(n.cross(s).times(Math.cos(e)*Math.sin(t))).plus(s.cross(r).times(Math.sin(e))).unit()}}normalP(t){return this.pLCNormalWCMatrix.transformVector(this.matrixInverse.transformPoint(t)).unit()}normalUV(t,e){return this.pLCNormalWCMatrix.transformVector(V3.sphere(t,e)).unit()}uvPFunc(){return t=>{const e=this.matrixInverse.transformPoint(t),s=abs(e.angleXY()),r=Math.asin(clamp(e.z,-1,1));return assert(isFinite(s)),assert(isFinite(r)),new V3(s,r,0)}}pUVFunc(){return(t,e)=>this.matrix.transformPoint(V3.sphere(t,e))}isSphere(){return eq(this.f1.length(),this.f2.length())&&eq(this.f2.length(),this.f3.length())&&eq(this.f3.length(),this.f1.length())&&this.f1.isPerpendicularTo(this.f2)&&this.f2.isPerpendicularTo(this.f3)&&this.f3.isPerpendicularTo(this.f1)}isVerticalSpheroid(){return eq(this.f1.length(),this.f2.length())&&this.f1.isPerpendicularTo(this.f2)&&this.f2.isPerpendicularTo(this.f3)&&this.f3.isPerpendicularTo(this.f1)}mainAxes(){const{f1:t,f2:e,f3:s}=this;if(eq0(t.dot(e))&&eq0(e.dot(s))&&eq0(s.dot(t)))return this;const{U:r,SIGMA:n}=this.matrix.svd3();assert(n.isDiagonal()),assert(r.isOrthogonal());const i=r.times(n),[o,a,c]=arrayFromFunction(3,t=>new V3(i.m[t],i.m[t+4],i.m[t+8]));return new EllipsoidSurface$$1(this.center,o,a,c)}containsPoint(t){return eq0(this.implicitFunction()(t))}boundsFunction(){return(t,e)=>between(t,0,PI)&&between(e,-PI,PI)}volume(){return 4/3*Math.PI*this.f1.dot(this.f2.cross(this.f3))}loopContainsPoint(t,e){if(!this.containsPoint(e))return PointVsFace.OUTSIDE;assertVectors(e),assert(Edge$$1.isLoop(t));const s=this.matrixInverse.transformPoint(e).xy(),r=new EllipseCurve$$1(this.center,this.f3,s.likeO()?this.f2:this.matrix.transformVector(s.unit()));return P3$$1.normalOnAnchor(this.f2.unit(),this.center).containsPoint(e)?t.some(t=>t.curve.containsPoint(e)&&fuzzyBetween(t.curve.pointT(e),t.minT,t.maxT))?PointVsFace.ON_EDGE:PointVsFace.OUTSIDE:Surface$$1.loopContainsPointEllipse(t,e,r)}surfaceAreaApprox(){const t=this.mainAxes(),e=t.f1.length(),s=t.f2.length(),r=t.f3.length(),n=1.6075;return 4*PI*Math.pow((Math.pow(e*s,n)+Math.pow(s*r,n)+Math.pow(r*e,n))/3,1/n)}surfaceArea(){const t=this.mainAxes(),e=t.f1.length(),s=t.f2.length(),r=t.f3.length(),[n,i,o]=[e,s,r].sort(MINUS);function a(t,e){if(eMath.pow(1-h*Math.pow(Math.sin(t),2),-.5),0,c),l=gaussLegendreQuadrature24(t=>Math.pow(1-h*Math.pow(Math.sin(t),2),.5),0,c);return(2*PI*Math.pow(n,2)+2*PI*o*i/Math.sin(c))*(l*Math.pow(Math.sin(c),2)+u*Math.pow(Math.cos(c),2))}getSeamPlane(){const t=P3$$1.forAnchorAndPlaneVectors(this.center,this.f1,this.f3);return t.normal1.dot(this.f2)<0?t:t.flipped()}getExtremePoints(){return getExtremePointsHelper$$1.call(this,new EllipseCurve$$1(V3.O,V3.X,V3.Z,-PI/2,PI/2))}pointFoot(t,e,s){if(console.log(t.sce),void 0===e||void 0===s){let r=this.matrixInverse.transformPoint(t).unit();r.y<0&&(r=r.negated()),({x:e,y:s}=EllipsoidSurface$$1.UNIT.uvP(r))}const r=this.dpdu(),n=this.dpdv(),[i,o]=newtonIterate(([e,s])=>{const i=this.pUV(e,s);console.log([i,i.plus(r(e,s)),i,i.plus(n(e,s))].map(toSource).join()+",");const o=this.pUV(e,s).to(t);return[o.dot(r(e,s)),o.dot(n(e,s))]},[e,s],8,void 0,.1);return new V3(i,o,0)}implicitFunction(){return t=>{return(this.matrixInverse.transformPoint(t).length()-1)*this.normalDir}}didp(t){const e=this.matrixInverse.transformPoint(t);return this.pLCNormalWCMatrix.transformVector(e.unit())}static unitTransform4(t){1!==t.m[15]&&(t=t.divScalar(t.m[15]));const e=new M4(1,0,0,0,0,1,0,0,0,0,1,0,-t.m[12],-t.m[13],-t.m[14],1),s=new V3(t.m[12],t.m[13],t.m[14]),r=t.m[15],n=Math.pow(r,2)-s.squared();if(lt(n,0))throw new Error("vanishing plane intersects unit sphere");const i=s.div(-n),o=(s.times(r*s.length()/(s.squared()*-n)),r/-n),a=1/sqrt(n),c=M4.forSys(s.unit(),s.getPerpendicular().unit());return M4.product(t,e,M4.translate(i),c,M4.scale(o,a,a),c.transposed())}}EllipsoidSurface$$1.UNIT=new EllipsoidSurface$$1(V3.O,V3.X,V3.Y,V3.Z),EllipsoidSurface$$1.prototype.uStep=PI/32,EllipsoidSurface$$1.prototype.vStep=PI/32;class PlaneSurface$$1 extends ParametricSurface$$1{constructor(t,e=t.normal1.getPerpendicular().unit(),s=t.normal1.cross(e).unit(),r=-100,n=100,i=-100,o=100){super(r,n,i,o),this.plane=t,this.right=e,this.up=s,assertInst(P3$$1,t),assert(this.right.cross(this.up).like(this.plane.normal1)),this.matrix=M4.forSys(e,s,t.normal1,t.anchor)}toSource(t=(t=>t)){return callsce.call(void 0,"new PlaneSurface",...this.getConstructorParameters())}static throughPoints(t,e,s){return new PlaneSurface$$1(P3$$1.throughPoints(t,e,s))}static forAnchorAndPlaneVectors(t,e,s,r,n,i,o){return new PlaneSurface$$1(P3$$1.forAnchorAndPlaneVectors(t,e,s),e,s,r,n,i,o)}isCoplanarTo(t){return hasConstructor(t,PlaneSurface$$1)&&this.plane.isCoplanarToPlane(t.plane)}isTsForLine(t){return t.isTsWithPlane(this.plane)}like(t){return hasConstructor(t,PlaneSurface$$1)&&this.plane.like(t.plane)}pUV(t,e){return this.matrix.transformPoint(new V3(t,e,0))}implicitFunction(){return t=>this.plane.distanceToPointSigned(t)}isCurvesWithSurface(t){return t instanceof PlaneSurface$$1?this.isCurvesWithPlane(t.plane):super.isCurvesWithSurface(t)}isCurvesWithPlane(t){const e=this.plane.intersectionWithPlane(t);return e?[e]:[]}edgeLoopCCW(t){return assert(Edge$$1.isLoop(t),"isLoop"),isCCW(t.flatMap(t=>t.points()),this.plane.normal1)}loopContainsPoint(t,e){const s=this.right.plus(this.up.times(.123)).unit(),r=new L3$$1(e,s),n=s.cross(this.plane.normal1);return Surface$$1.loopContainsPointGeneral(t,e,r,n)}uvPFunc(){const t=this.matrix.inversed();return function(e){return t.transformPoint(e)}}pointFoot(t){return this.uvP(t)}normalP(t){return this.plane.normal1}containsPoint(t){return this.plane.containsPoint(t)}containsCurve(t){return t instanceof ImplicitCurve$$1?super.containsCurve(t):this.plane.containsCurve(t)}transform(t){return new PlaneSurface$$1(this.plane.transform(t))}transform4(t){return new PlaneSurface$$1(this.plane.transform(t))}flipped(){return new PlaneSurface$$1(this.plane.flipped(),this.right,this.up.negated())}getConstructorParameters(){return[this.plane,this.right,this.up,this.uMin,this.uMax,this.vMin,this.vMax]}dpdu(){return()=>this.right}dpdv(){return()=>this.up}didp(t){return this.plane.normal1}normalUV(){return this.plane.normal1}}PlaneSurface$$1.prototype.uStep=1e6,PlaneSurface$$1.prototype.vStep=1e6;class PointProjectedSurface$$1 extends ParametricSurface$$1{constructor(t,e,s,r=1,n=t.tMin,i=t.tMax,o=0,a=16){super(n,i,o,a),this.curve=t,this.apex=e,this.curvePlane=s,this.normalDir=r,assertInst(Curve$$1,t),assert(!(t instanceof L3$$1),"use PlaneSurface instead"),assert(!(t instanceof EllipseCurve$$1),"use ConicSurface instead"),assert(!(t instanceof ImplicitCurve$$1),"this just seems like a terrible idea"),assert(new PlaneSurface$$1(s).containsCurve(t)),assertVectors(e),assert(0<=o),this.planeProjectionMatrix=M4.projectPlanePoint(e,s),this.uStep=t.tIncrement}pointFoot(t,e,s){void 0!==e&&void 0!==s||(void 0===e&&(e=t.like(this.apex)?0:this.curve.closestTToPoint(this.planeProjectionMatrix.transformPoint(t))*this.normalDir),void 0===s&&(s=V3.inverseLerp(this.apex,this.curve.at(e),t)));const{0:r,1:n}=newtonIterate(([e,s])=>{const r=this.pST(e,s).to(t);return[this.dpds()(e,s).dot(r),this.dpdt()(e).dot(r)]},[e,s]);return new V3(r,n,0)}getConstructorParameters(){return[this.curve,this.apex,this.curvePlane,this.normalDir,this.sMin,this.sMax,this.tMin,this.tMax]}static unitISLineTs(t,e){const{x:s,y:r,z:n}=t,{x:i,y:o,z:a}=e,c=i*i+o*o-a*a;return pqFormula(2*(s*i+r*o-n*a)/c,(s*s+r*r-n*n)/c).filter(t=>0t.tOther)}isCoplanarTo(t){return this===t||!!(t instanceof PointProjectedSurface$$1&&this.apex.like(t.apex))&&this.containsCurve(t.curve)}containsLine(t){if(this.curvePlane.isParallelToLine(t))return!1;if(!t.containsPoint(this.apex))return!1;const e=this.curvePlane.intersectionWithLine(t);return this.curve.containsPoint(e)}containsCurve(t){if(t instanceof L3$$1)return this.containsLine(t);if(t instanceof ImplicitCurve$$1)return super.containsCurve(t);{const e=t.transform(this.planeProjectionMatrix);return this.curve.isColinearTo(e)}}transform(t){return new PointProjectedSurface$$1(this.curve.transform(t),t.transformPoint(this.apex),this.curvePlane.transform(t),(t.isMirroring()?-1:1)*this.normalDir,this.sMin,this.sMax,this.tMin,this.tMax)}flipped(){return new PointProjectedSurface$$1(this.curve,this.apex,this.curvePlane,-this.normalDir,-this.sMax,-this.sMin,this.tMin,this.tMax)}normalSTFunc(){const t=this.dpdt();return(e,s)=>this.curve.tangentAt(e*this.normalDir).times(this.normalDir).cross(t(e)).unit()}pSTFunc(){return(t,e)=>this.apex.lerp(this.curve.at(t*this.normalDir),e)}dpds(){return(t,e)=>this.curve.tangentAt(t*this.normalDir).times(e*this.normalDir)}dpdt(){return t=>this.apex.to(this.curve.at(t*this.normalDir))}containsPoint(t){return this.apex.like(t)||this.curve.containsPoint(this.planeProjectionMatrix.transformPoint(t))}stP(t){const e=t.like(this.apex)?0:this.curve.pointT(this.planeProjectionMatrix.transformPoint(t)),s=V3.inverseLerp(this.apex,this.curve.at(e),t);return new V3(e*this.normalDir,s,0)}isCurvesWithSurface(t){return t instanceof PlaneSurface$$1?this.isCurvesWithPlane(t.plane):ImplicitSurface$$1.is(t)?ParametricSurface$$1.isCurvesParametricImplicitSurface(this,t,.1,.1/this.curvePlane.distanceToPoint(this.apex),.02):super.isCurvesWithSurface(t)}isCurvesWithPlane(t){return t.containsPoint(this.apex)?t.isParallelToPlane(this.curvePlane)?[]:this.curve.isTsWithPlane(t).map(t=>L3$$1.throughPoints(this.apex,this.curve.at(t))):[this.curve.transform(M4.projectPlanePoint(this.apex,t))]}}PointProjectedSurface$$1.prototype.vStep=256;class NURBSSurface$$1 extends ParametricSurface$$1{constructor(t,e,s,r,n,i=e[r],o=e[e.length-r-1],a=s[n],c=s[s.length-n-1]){super(i,o,a,c),this.points=t,this.knotsU=e,this.knotsV=s,this.degreeU=r,this.degreeV=n;const h=e.length-1-r,u=s.length-1-n;assert(h*u==t.length),assert(r<=n,"degreeU <= degreeV")}getConstructorParameters(){return[this.points,this.knotsU,this.knotsV,this.degreeU,this.degreeV,this.sMin,this.sMax,this.tMin,this.tMax]}transform(t){return this.transform4(t)}transform4(t){return new NURBSSurface$$1(this.points.map(e=>t.timesVector(e)),this.knotsU,this.knotsV,this.degreeU,this.degreeV,this.sMin,this.sMax,this.tMin,this.tMax)}pST(t,e){return this.isoparametricU(t).at(e)}dpds(){return(t,e)=>this.isoparametricV(e).tangentAt(t)}dpdt(){return(t,e)=>this.isoparametricU(t).tangentAt(e)}normalST(t,e){return this.dpds()(t,e).cross(this.dpdt()(t,e)).unit()}isoparametricU(t){const e=this.knotsU.length-1-this.degreeU,s=this.knotsV.length-1-this.degreeV;return new NURBS$$1(arrayFromFunction(s,s=>deBoor(this.points.slice(s*e,(s+1)*e),this.degreeU,this.knotsU,t)),this.degreeV,this.knotsV,this.tMin,this.tMax)}isoparametricV(t){const e=this.knotsU.length-1-this.degreeU;this.knotsV.length,this.degreeV;return new NURBS$$1(arrayFromFunction(e,s=>deBoor(this.points.sliceStep(s,this.points.length,e,1),this.degreeV,this.knotsV,t)),this.degreeU,this.knotsU,this.sMin,this.sMax)}debugInfo(){const t=this.knotsU.length-1-this.degreeU,e=this.knotsV.length-1-this.degreeV,s=[];for(let r=0;rt.p3()),lines:s}}}function getInterval(t,e,s){for(let r=t;r=e[r]&&s<=e[r+1])return r;throw new Error(s+" "+e)}function deBoor(t,e,s,r){const n=getInterval(e,s,r),i=Vector.pack(t,new Float64Array(4*t.length));for(let t=1;t<=e;t++)for(let o=n;o>n-e-1+t;o--){const n=(r-s[o])/(s[o+e+1-t]-s[o]);for(let t=0;t<4;t++)i[4*o+t]=(1-n)*i[4*(o-1)+t]+n*i[4*o+t]}return new Vector(i.slice(4*n,4*n+4))}NURBSSurface$$1.prototype.uStep=1/8,NURBSSurface$$1.prototype.vStep=1/8;const ZDirVolumeVisitor$$1={[ConicSurface$$1.name](t){console.log(this);const e=this.dpdu(),s=this.dpdv(),r=t.map(t=>{const r=t.curve;if(r instanceof EllipseCurve$$1||r instanceof HyperbolaCurve$$1||r instanceof ParabolaCurve$$1){return glqInSteps(t=>{const n=r.at(t),i=r.tangentAt(t),o=this.uvP(n),a=-M4.forSys(e(o.x,o.y),s(o.x)).inversed().transformVector(i).x,c=Math.pow(o.y,3)/3*(this.pUV(o.x,1).z-this.center.z)+Math.pow(o.y,2)/2*this.center.z;return e(o.x,c).cross(s(o.x)).z*a},t.aT,t.bT,1)}if(r instanceof L3$$1)return 0;throw new Error}).sum(),n=t.map(t=>{const r=t.curve;if(r instanceof EllipseCurve$$1||r instanceof HyperbolaCurve$$1||r instanceof ParabolaCurve$$1){return glqV3$$1(t=>{const n=r.at(t),i=r.tangentAt(t),o=this.uvP(n),a=this.pUV(o.x,1).minus(this.center),c=V3.add(a.times(.25*Math.pow(o.y,4)*a.z+1/3*Math.pow(o.y,3)*this.center.z),this.center.times(1/3*Math.pow(o.y,3)*a.z+.5*Math.pow(o.y,2)*this.center.z)).times(e(o.x,1).cross(s(o.x)).z),h=-M4.forSys(e(o.x,o.y),s(o.x)).inversed().transformVector(i).x;return c.times(h)},t.aT,t.bT)}if(r instanceof L3$$1)return V3.O;throw new Error});return{volume:r,centroid:V3.add(...n).schur(new V3(1,1,.5)).div(r)}},[PlaneSurface$$1.name](t){const e=this.right,s=this.up,r=this.plane.anchor;return assert(e.hasLength(1)),assert(s.hasLength(1)),assert(e.isPerpendicularTo(s)),mergeVolumeAndCentroidZX2Parts(t.map(t=>{const n=t.curve;if(n instanceof L3$$1){function i(t,e,s){const r=e.minus(t),n=s.minus(t),i=r.cross(n);return[V3.add(t,e,s).div(3).z*i.z/2,V3.add(t.times(2*t.z+e.z+s.z),e.times(t.z+2*e.z+s.z),s.times(t.z+e.z+2*s.z)).times(i.z)]}const s=t.a,r=t.b,n=s.dot(e),o=r.dot(e),a=this.pUV(n,0),c=this.pUV(o,0),[h,u]=i(s,r,a),[l,f]=i(c,a,r);return[h+l,u.plus(f).div(24)]}if(n instanceof ImplicitCurve$$1)throw new Error;{const i=t=>{const i=n.at(t),o=i.dot(e),a=i.dot(s),c=a*r.z+o*a*e.z+.5*Math.pow(a,2)*s.z,h=-n.tangentAt(t).dot(e);return[c*h,...V3.add(r.times(c),e.times(r.z*o*a+e.z*Math.pow(o,2)*a+.5*o*Math.pow(a,2)*s.z),s.times(.5*r.z*Math.pow(a,2)+.5*e.z*o*Math.pow(a,2)+1/3*Math.pow(a,3)*s.z)).times(h)]},[o,a,c,h]=glqArray$$1(i,t.aT,t.bT,4);return[o*this.plane.normal1.z,new V3(a,c,h).times(this.plane.normal1.z)]}}))},[ParametricSurface$$1.name](t){const e=this.dpdu(),s=this.dpdv();return mergeVolumeAndCentroidZX2Parts(t.map(t=>{const r=t.curve;if(r instanceof ImplicitCurve$$1)throw new Error;{const n=t=>{const n=r.at(t),i=r.tangentAt(t),o=this.uvP(n),a=glqInSteps(t=>{const r=this.pUV(o.x,t),n=e(o.x,t).cross(s(o.x,t));return r.z*n.z},0,o.y,1),c=-M4.forSys(e(o.x,o.y),s(o.x,o.y)).inversed().transformVector(i).x;return[a*c,...glqV3$$1(t=>{const r=this.pUV(o.x,t),n=e(o.x,t).cross(s(o.x,t));return r.times(r.z*n.z)},0,o.y).times(c).toArray()]},[i,o,a,c]=glqArray$$1(n,t.aT,t.bT,4);return[i,new V3(o,a,c)]}}))},[ProjectedCurveSurface$$1.name](t){if(V3.Z.cross(this.dir).likeO())return{volume:0,centroid:V3.O};const e=this.dir.toLength(Math.sign(this.dir.z)||1),s=V3.Z.cross(e).unit(),r=e.rejectedFrom(V3.Z).unit();return mergeVolumeAndCentroidZX2Parts(t.map(t=>{if(t.curve instanceof L3$$1)return[0,V3.O];if(t.curve instanceof ImplicitCurve$$1)return[0,V3.O];{const n=n=>{const i=t.curve.at(n),o=t.curve.tangentAt(n),a=i.rejectedFrom1(e),c=i.z*a.to(i).dot(r)/2+a.z*a.to(i).dot(r)/2,h=V3.add(i.xy(),a,i).times(i.z*a.to(i).dot(r)/2/3),u=V3.add(i.xy(),a,a.xy()).times(a.z*a.to(i).dot(r)/2/3),l=o.dot(s);return[c*l,...h.plus(u).times(l).schur(V(1,1,2))]},[i,o,a,c]=glqArray$$1(n,t.aT,t.bT,4);return[i,new V3(o,a,c)]}}))},[RotatedCurveSurface$$1.name](t){const e=this.dpdu(),s=this.dpdv(),r=t.map(t=>{const r=t.curve;return gaussLegendreQuadrature24(t=>{const n=r.at(t),i=r.tangentAt(t),o=this.uvP(n),a=this.matrixInverse.transformPoint(n),c=this instanceof RotatedCurveSurface$$1?this.curve.tangentAt(o.y):V(-a.z,0,a.lengthXY()),h=a.lengthXY(),u=a.z,l=c.x,f=c.z,p=this.matrix.X.z*h,d=this.matrix.Y.z*h,m=this.matrix.Z.z*u+this.matrix.O.z,$=(this.matrix.X.x*this.matrix.Y.y-this.matrix.X.y*this.matrix.Y.x)*h*l,g=(this.matrix.Y.x*this.matrix.X.y-this.matrix.Y.y*this.matrix.X.x)*h*l,v=(this.matrix.X.x*this.matrix.X.y-this.matrix.X.y*this.matrix.X.x)*h*l,P=(this.matrix.Y.x*this.matrix.Y.y-this.matrix.Y.y*this.matrix.Y.x)*h*l,C=(this.matrix.Y.x*this.matrix.Z.y-this.matrix.Y.y*this.matrix.Z.x)*h*f,x=(this.matrix.X.x*this.matrix.Z.y-this.matrix.X.y*this.matrix.Z.x)*h*f,M=M4.forSys(e(o.x,o.y),s(o.x,o.y)).inversed().transformVector(i).y;return(t=>(6*(m*(-$+g)+p*C-d*x)*t+3*(3*d*$-d*g+p*(v-P)+4*m*x)*cos(t)+3*(3*p*g-p*$-d*(v-P)+4*m*C)*sin(t)+3*(p*x-d*C+m*(v-P))*cos(2*t)+3*(p*C+d*x+m*($+g))*sin(2*t)+(p*(v-P)-d*($+g))*cos(3*t)+(p*($+g)+d*(v-P))*sin(3*t))/12)(o.x)*M},t.aT,t.bT)}).sum(),n=t.map(t=>{return glqV3$$1(r=>{const n=t.curve,i=n.at(r),o=n.tangentAt(r),a=this.uvP(i),c=glqV3$$1(t=>{const r=this.pUV(t,a.y),n=e(t,a.y).cross(s(t,a.y));return r.times(r.z*n.z)},0,a.x),h=M4.forSys(e(a.x,a.y),s(a.x,a.y)).inversed().transformVector(o).y;return c.times(h)},t.aT,t.bT)});return{volume:r,centroid:V3.add(...n).schur(new V3(1,1,.5)).div(r)}}};function glqV3$$1(t,e,s){return gaussLegendre24Xs.reduce((r,n,i)=>{const o=e+(n+1)/2*(s-e);return r.plus(t(o).times(gaussLegendre24Weights[i]))},V3.O).times((s-e)/2)}function glqArray$$1(t,e,s,r=3){const n=new Array(r).fill(0);for(let i=0;i<24;i++){const o=t(e+(gaussLegendre24Xs[i]+1)/2*(s-e));for(let t=0;tt+e,0);return{volume:e,centroid:V3.add(...t.map(([,t])=>t)).schur(new V3(1,1,.5)).div(e)}}ZDirVolumeVisitor$$1[EllipsoidSurface$$1.name]=ZDirVolumeVisitor$$1[RotatedCurveSurface$$1.name];const CalculateAreaVisitor$$1={[ConicSurface$$1.name](t){const e=this.dpdu(),s=this.dpdv();return t.map(t=>{if(t.curve instanceof EllipseCurve$$1||t.curve instanceof HyperbolaCurve$$1||t.curve instanceof ParabolaCurve$$1){return glqInSteps(r=>{const n=t.curve.at(r),i=t.tangentAt(r),o=this.uvP(n),a=-M4.forSys(e(o.x,o.y),s(o.x)).inversed().transformVector(i).x;return e(o.x,Math.pow(o.y,2)/2).cross(s(o.x)).length()*a},t.aT,t.bT,1)}if(t.curve instanceof L3$$1)return 0;throw new Error}).sum()*this.normalDir},[PlaneSurface$$1.name](t){let e=0;const s=this.right,r=this.up;for(const i of t){let t;const o=i.curve;if(o instanceof L3$$1)t=(i.a.dot(r)+i.b.dot(r))/2*i.b.to(i.a).dot(s);else if(o instanceof EllipseCurve$$1){const{f1:e,f2:a,center:c}=o,h=r.dot(e),u=r.dot(a),l=r.dot(c),f=s.dot(e),p=s.dot(a);function n(t){return.25*(2*(-u*f+h*p)*t+4*l*f*cos(t)+4*l*p*sin(t)+(h*f-u*p)*cos(2*t)+(u*f+h*p)*sin(2*t))}t=-(n(i.bT)-n(i.aT))}else{if(o instanceof ImplicitCurve$$1)throw new Error("implement for implicitCurve");{const e=r;assertf(()=>e.hasLength(1)),t=glqInSteps(t=>{const e=o.at(t),n=o.tangentAt(t);return s.dot(n)*r.dot(e)},i.aT,i.bT,3)}}e+=t}return assert(isFinite(e)),e},[RotatedCurveSurface$$1.name](t,e=!0){const s=this.matrix.X,r=this.matrix.Y,n=this.matrix.Z,i=eq(s.length(),r.length())&&s.isPerpendicularTo(r)&&r.isPerpendicularTo(n)&&n.isPerpendicularTo(s);return t.map((t,e)=>{console.log("edge",e,t.sce);const s=t.curve;if(t.curve instanceof ImplicitCurve$$1)throw new Error;if(i){return glqInSteps(t=>{const e=s.at(t),r=s.tangentAt(t),n=this.matrixInverse.transformPoint(e),{x:i,y:o}=this.uvP(e);return i*this.matrix.transformVector(n.xy()).length()*this.dpdv()(i,o).unit().dot(r)},t.aT,t.bT,1)}{const e=this.dpdu(),r=this.dpdv();return glqInSteps(t=>{const n=s.at(t),i=s.tangentAt(t),o=this.uvP(n),a=M4.forSys(e(o.x,o.y),r(o.x,o.y)).inversed().transformVector(i).y;return glqInSteps(t=>e(t,o.y).cross(r(t,o.y)).length(),0,o.x,1)*a},t.aT,t.bT,1)}}).sum()},[ProjectedCurveSurface$$1.name](t){const e=this.dir.unit(),s=t.map(t=>{if(t.curve instanceof L3$$1)return 0;if(t.curve instanceof ImplicitCurve$$1){const{points:s,tangents:r}=t.curve,n=t.minT,i=t.maxT;let o=0;const a=ceil(n+NLA_PRECISION),c=floor(i-NLA_PRECISION);for(let t=a;t<=c;t++){const n=s[t],i=r[t],a=this.normalP(n).cross(e).unit().dot(i);o+=n.dot(e)*a}const h=s=>{const r=t.curve.at(s),n=t.curve.tangentAt(s),i=this.normalP(r).cross(e).unit().dot(n);return r.dot(e)*i};return o+=h(n)*(a-n-.5),(o+=h(i)*(i-c-.5))*sign(t.deltaT())}{const s=glqInSteps(s=>{const r=t.curve.at(s),n=t.tangentAt(s).rejected1Length(e);return r.dot(e)*n},t.aT,t.bT,1),r=Math.sign(this.normalP(t.a).cross(this.dir).dot(t.curve.tangentAt(t.aT)));return assert(0!==r),s*r}}).sum();return console.log("totalArea",s),s}};function projectCurve$$1(t,e,s){if(t instanceof L3$$1){const r=e.cross(t.dir1).toLength(s?-1:1);return new PlaneSurface$$1(P3$$1.normalOnAnchor(r,t.anchor))}if(t instanceof EllipseCurve$$1){const r=s?e:e.negated();return new CylinderSurface$$1(t,r.unit(),void 0,void 0)}if(t instanceof BezierCurve$$1||t instanceof XiEtaCurve$$1){const r=e.times(s?1:-1);return new ProjectedCurveSurface$$1(t,r,void 0,void 0,s?0:-1,s?1:0)}throw new Error}function projectPointCurve$$1(t,e=t.tMin,s=t.tMax,r,n){if(t instanceof L3$$1){const n=t.anchor.to(r).rejectedFrom(t.dir1);return PlaneSurface$$1.forAnchorAndPlaneVectors(t.anchor,t.dir1,n.unit(),e,s,0,n.length())}if(t instanceof EllipseCurve$$1){const i=-1*(n?-1:1);return new ConicSurface$$1(r,t.f1.times(i),t.f2,r.to(t.center),e,s,0,1)}throw new Error("projectPointCurve not implemented for "+t.constructor.name)}function rotateCurve$$1(t,e=t.tMin,s=t.tMax,r,n){if(assertf(()=>new PlaneSurface$$1(P3$$1.ZX).containsCurve(t)),t instanceof L3$$1){if(t.dir1.isParallelTo(V3.Z)){if(eq0(t.anchor.x))return;const i=new EllipseCurve$$1(V3.O,t.anchor.xy(),t.anchor.xy().getPerpendicular(),0,r),o=(t.dir1.z>0?-1:1)*(n?-1:1),[a,c]=[t.at(e).z*o,t.at(s).z*o].sort(MINUS);return new CylinderSurface$$1(i,V3.Z.times(o),0,r,a,c)}if(t.at(e).xy().dot(t.dir1)*t.at(s).xy().dot(t.dir1)<0)throw new Error("line cannot cross the Z axis in the [tMin, tMax] interval, as conic surfaces cannot have an hourglass shape.");if(t.dir1.isPerpendicularTo(V3.Z)){const r=(t.at(lerp(e,s,.5)).dot(t.dir1)>0?1:-1)*(n?-1:1);return new PlaneSurface$$1(new P3$$1(V3.Z.times(r),t.anchor.z*r))}{const i=t.at(e),o=t.at(s),a=i.z-i.x*(o.z-i.z)/(o.x-i.x),c=new V3(0,0,a),h=-(i.x>o.x?-1:1)*(n?-1:1),u=new ConicSurface$$1(c,new V3(t.dir1.lengthXY(),0,0),new V3(0,t.dir1.lengthXY(),0),new V3(0,0,(i.x>o.x?-1:1)*t.dir1.z),0,r,0,1);return h>0?u:u.flipped()}}if(t instanceof EllipseCurve$$1){const r=t.at(e),i=t.at(s),o=t.rightAngled(),a=o.f1.isPerpendicularTo(V3.Z),c=o.f2.isPerpendicularTo(V3.Z);if(L3$$1.Z.containsPoint(o.center)&&(a||c)){n=n==r.z>i.z;let t=o.f1.length(),e=o.f2.length();return o.f1.isParallelTo(V3.Z)&&([t,e]=[e,t]),EllipsoidSurface$$1.forABC(t,(n?-1:1)*t,e,o.center)}return new RotatedCurveSurface$$1(t,M4.IDENTITY,e,s)}throw new Error}var B2T;CalculateAreaVisitor$$1[EllipsoidSurface$$1.name]=CalculateAreaVisitor$$1[RotatedCurveSurface$$1.name],function(t){function e(e,s=P3$$1.XY,r=V3.Z,n="extrude"+getGlobalId$$1(),i,o){e=a(e),assertf(()=>Edge$$1.isLoop(e));const c=new Map,h=new PlaneSurface$$1(s),u=M4.translate(r),l=e.map(t=>t.transform(u,"top")),f=e.length,p=o&&o.extrudeBottom(h,e),d=new PlaneFace$$1(h,e,[],n+"Bottom",p),m=l.map(t=>t.flipped()).reverse(),$=new PlaneSurface$$1(s.flipped().translated(r)),g=o&&o.extrudeBottom($,m),v=new PlaneFace$$1($,m,[],n+"Top",g);e.forEach(e=>t.registerVertexName(c,e.name+"A",e.a)),m.forEach(e=>t.registerVertexName(c,e.name+"A",e.a));const P=arrayFromFunction(f,t=>StraightEdge$$1.throughPoints(e[t].a,l[t].a,n+"Rib"+t)),C=e.map((t,s)=>{const i=n+"Wall"+s,a=(s+1)%f,c=[e[s].flipped(),P[s],l[s],P[a].flipped()],h=projectCurve$$1(t.curve,r,t.reversed),u=o&&o.extrudeWall(s,h,c);return Face$$1.create(h,c,void 0,i,u)});return C.push(d,v),i=i||callsce("B2T.extrudeEdges",e,s,r,n),new BRep$$1(C,s.normal1.dot(r)>0,i,c)}function s(t=1,e="sphere"+getGlobalId$$1(),s=TAU){const n=PCurveEdge$$1.create(new EllipseCurve$$1(V3.O,new V3(0,0,-t),new V3(t,0,0)),new V3(0,0,-t),new V3(0,0,t),0,PI,void 0,new V3(t,0,0),new V3(-t,0,0)),i=callsce("B2T.sphere",t,e,s);return r([StraightEdge$$1.throughPoints(n.b,n.a),n],s,e,i)}function r(t,e,s="rotateEdges"+getGlobalId$$1(),r,n){assert(t.every(t=>new PlaneSurface$$1(P3$$1.ZX).containsCurve(t.curve))),assert(!eq(PI,e)||PI==e),assertf(()=>lt(0,e)&&le(e,TAU)),e=snap(e,TAU),assertf(()=>Edge$$1.isLoop(t));const i=new PlaneSurface$$1(P3$$1.ZX.flipped()).edgeLoopCCW(t)?new PlaneSurface$$1(P3$$1.ZX.flipped()):new PlaneSurface$$1(P3$$1.ZX),o=!eq(e,2*PI),a=t.map(t=>{const e=t.a,s=e.lengthXY();if(!eq0(s))return new EllipseCurve$$1(V(0,0,e.z),V(s,0,0),V(0,s,0))}),c=t.map((t,e)=>{const s=rotateCurve$$1(t.curve,t.minT,t.maxT,PI,t.deltaT()>0),r=lerp(t.aT,t.bT,.5);return s&&assert(t.tangentAt(r).cross(V3.Y).dot(s.normalP(t.curve.at(r)))<0),s});let h,u=t;const l=[];for(let r=0;rt.transform(f));const p=arrayFromFunction(t.length,t=>{const e=u[t].a,n=e.lengthXY(),c=h[t].a;if(!eq0(n)){const n=0===r?a[t]:a[t].rotateZ(r);return new PCurveEdge$$1(n,e,c,i,o,void 0,n.tangentAt(i),n.tangentAt(o),s+"rib"+t)}});for(let e=0;et),f=0===r?c[e]:c[e].rotateZ(r),d=n&&n.extrudeWall(e,f,a,void 0);l.push(Face$$1.create(f,a,void 0,s+"Wall"+e,d))}u=h}if(o){const r=Edge$$1.reversePath(h),o=n&&n.rotationStart(i,t,void 0),a=n&&n.rotationEnd(i.flipped().rotateZ(e),r,void 0);l.push(new PlaneFace$$1(i,t,void 0,s+"start",o),new PlaneFace$$1(i.flipped().rotateZ(e),r,void 0,s+"end",a))}const f=new PlaneSurface$$1(P3$$1.ZX).edgeLoopCCW(t);return new BRep$$1(l,f,r)}t.box=function(e=1,s=1,r=1,n="box"+getGlobalId$$1()){assertNumbers(e,s,r),assert("string"==typeof n);const i=[new V3(0,0,0),new V3(0,s,0),new V3(e,s,0),new V3(e,0,0)],o=callsce("B2T.box",e,s,r,n);return t.extrudeVertices(i,P3$$1.XY.flipped(),new V3(0,0,r),n,o)},t.puckman=function(e,s,r,n="puckman"+getGlobalId$$1()){assertf(()=>lt(0,e)),assertf(()=>lt(0,s)&&le(s,TAU)),assertf(()=>lt(0,r));const i=StraightEdge$$1.chain([V3.O,new V3(e,0,0),new V3(e,0,r),new V3(0,0,r)],!0);return t.rotateEdges(i,s,n)},t.registerVertexName=function(t,e,s){Array.from(t.keys()).some(t=>t.like(s))||t.set(s,e)},t.extrudeEdges=e,t.cylinder=function(t=1,e=1,s=TAU,n="cylinder"+getGlobalId$$1()){const i=[new V3(0,0,0),new V3(t,0,0),new V3(t,0,e),new V3(0,0,e)];return r(StraightEdge$$1.chain(i,!0),s,n)},t.cone=function(t=1,e=1,s=TAU,n="cone"+getGlobalId$$1()){const i=[new V3(0,0,0),new V3(t,0,e),new V3(0,0,e)];return r(StraightEdge$$1.chain(i,!0),s,n)},t.sphere=s,t.menger=function(e=2,s="menger"+getGlobalId$$1()){let r=t.box(1,1,1);if(0==e)return r;const n=t.box(1/3,1/3,2).translate(1/3,1/3,-.5).flipped();function i(t,e){if(r=r.and(n.transform(e)),t>1){const s=e.times(M4.scale(1/3,1/3,1));for(let e=0;e<9;e++)4!=e&&i(t-1,s.times(M4.translate(e%3,e/3|0,0)))}}return i(e,M4.IDENTITY),i(e,M4.YZX),i(e,M4.ZXY),r},t.menger2=function(e=2,s="menger"+getGlobalId$$1()){if(0==e)return t.box(1,1,1);const r=t.box(1/3,1/3,2).translate(1/3,1/3,-.5).flipped(),n=[];!function t(e,s){if(n.push(...r.transform(s).faces),e>1){const r=s.times(M4.scale(1/3,1/3,1));for(let s=0;s<9;s++)4!=s&&t(e-1,r.times(M4.translate(s%3,s/3|0,0)))}}(e,M4.IDENTITY);const i=new BRep$$1(n,!0);return t.box().and(i).and(i.transform(M4.YZX)).and(i.transform(M4.ZXY))},t.torus=function(e,s,r=TAU,n="torus"+getGlobalId$$1()){assertNumbers(e,s,r),assertf(()=>s>e);const i=[EllipseCurve$$1.semicircle(e,new V3(s,0,0)),EllipseCurve$$1.semicircle(-e,new V3(s,0,0))].map(t=>PCurveEdge$$1.forCurveAndTs(t,0,Math.PI).rotateX(PI/2));return t.rotateEdges(i,r,n)},t.rotateEdges=r,t.quaffle=function(){const e=t.sphere(1).translate(0,1.7).flipped(),s=new BRep$$1(t.TETRAHEDRON_VERTICES.flatMap(t=>e.rotateAB(V3.Y,t).faces),!1);return t.sphere().and(s)},t.extrudeFace=function(t,s){return new BRep$$1(e(t.contour,t.surface.plane,s).faces.slice(0,-2).concat(t,t.translate(s.x,s.y,s.z).flipped(),t.holes.flatMap(r=>e(r,t.surface.plane.flipped(),s).faces.slice(0,-2))),!1)},t.loadFonts=function(){return i("fonts/FiraSansMedium.woff").then(e=>t.defaultFont=e)};const n=new Map;function i(t){return new Promise(function(e,s){const r=n.get(t);r?e(r):load(t,function(r,i){r?s(r):(n.set(t,i),e(i))})})}function o(e,s,r=1,n=t.defaultFont){const i=[];n.getPath(e,0,0,s).commands.forEach(t=>{"M"==t.type&&i.push([]),i.last.push(t)});const o=i.map(t=>{const e=new Path;e.commands=t;const s=Edge$$1.reversePath(Edge$$1.pathFromSVG(e.toPathData(13))).map(t=>t.mirrorY());return assert(Edge$$1.isLoop(s)),s}),a=Face$$1.assembleFacesFromLoops(o,new PlaneSurface$$1(P3$$1.XY),PlaneFace$$1),c=callsce("B2T.text",e,s,r);return BRep$$1.join(a.map(e=>t.extrudeFace(e,V(0,0,-r))),c)}function a(t){return t.flatMap(t=>{const e=t.curve;if(e instanceof EllipseCurve$$1&&e.tMin===-PI&&e.tMax===PI){return(t.minT<0&&t.maxT>0?t.split(0):[t]).map(t=>t.minT>=0?Edge$$1.create(new EllipseCurve$$1(e.center,e.f1,e.f2,max(0,e.tMin),e.tMax),t.a,t.b,t.aT,t.bT,void 0,t.aDir,t.bDir,t.name):Edge$$1.create(new EllipseCurve$$1(e.center,e.f1.negated(),e.f2.negated(),e.tMin+PI,min(PI,e.tMax+PI)),t.a,t.b,t.aT+PI,t.bT+PI,void 0,t.aDir,t.bDir,t.name))}return e instanceof BezierCurve$$1&&t.a.like(t.b)?t.split(lerp(t.aT,t.bT,.5)):t})}t.loadFont=i,t.loadFontsAsync=function(e){t.defaultFont?e():load("fonts/FiraSansMedium.woff",function(s,r){if(s)throw new Error("Could not load font: "+s);t.defaultFont=r,e()})},t.text=o,t.minorityReport=function(){const e=t.sphere(),s=t.text("LEO CROW",64,128).scale(.1/32).translate(-.5,-.05,1.2).flipped(),r=t.sphere(.98);return e.and(s).plus(r)},t.whatever=function(){const t=f(),e=BRep$$1.join(t.faces.map((t,e)=>{const s=o(""+(e+1),.4,-2),r=t.contour.map(t=>t.a).reduce((t,e)=>t.plus(e),V3.O).div(3),n=M4.forSys(t.contour[0].aDir,r.cross(t.contour[0].aDir),r.unit(),r);return s.transform(n.times(M4.translate(-s.getAABB().size().x/2,-.1,-.04)))})),r=s(.9);return t.and(r).and(e)},t.whatever3=function(){const e=t.torus(1,2);return t.box(5,5,2).translate(-2.5,-2.5).minus(e)},t.d20=function(){const t=f(),e=BRep$$1.join(t.faces.map((t,e)=>{const s=o(""+(e+1),.4,-2),r=t.contour.map(t=>t.a).reduce((t,e)=>t.plus(e),V3.O).div(3),n=M4.forSys(t.contour[0].aDir,r.cross(t.contour[0].aDir),r.unit(),r);return s.transform(n.times(M4.translate(-s.getAABB().size().x/2,-.1,-.04)))})),r=s(.9);return t.and(r).and(e)},t.rotStep=function(t,e,s){const r="number"==typeof e?arrayFromFunction(s,t=>(t+1)/s*e):e,n=r.length,i=!eq(TAU,r.last),o=[t,...r.map(e=>{if(eq(TAU,e))return t;const s=M4.rotateZ(e);return t.map(t=>t.transform(s))})],a=arrayFromFunction(n,e=>{const s=(e+1)%(n+1);return arrayFromFunction(t.length,r=>{if(!eq0(t[r].a.lengthXY()))return StraightEdge$$1.throughPoints(o[e][r].a,o[s][r].a)})}),c=[];let h;if(t.forEach((e,s)=>{const u=(s+1)%t.length;if(e instanceof StraightEdge$$1&&e.curve.dir1.isPerpendicularTo(V3.Z)){const t=e.a.x>e.b.x,r=new PlaneSurface$$1(t?new P3$$1(V3.Z,e.a.z):new P3$$1(V3.Z.negated(),-e.a.z));if(i){const t=[];eq0(e.a.x)||t.push(...arrayFromFunction(n,t=>a[t][s])),t.push(o[n][s]),eq0(e.b.x)||t.push(...arrayFromFunction(n,t=>a[n-t-1][u].flipped())),t.push(e.flipped()),h=new PlaneFace$$1(r,t)}else{const i=arrayFromFunction(n,t?t=>a[t][s]:t=>a[n-t-1][u].flipped());let o;t&&!eq0(e.b.x)?o=arrayFromFunction(n,t=>a[n-t-1][u].flipped()):t||eq0(e.a.x)||(o=arrayFromFunction(n,t=>a[t][s])),h=new PlaneFace$$1(r,i,o?[o]:[])}c.push(h)}else if(!(e instanceof StraightEdge$$1&&eq0(e.a.lengthXY())&&eq0(e.b.lengthXY())))for(let i=0;it);let f;if(e instanceof StraightEdge$$1)f=new PlaneSurface$$1(P3$$1.throughPoints(l[0].a,l[1].a,l[2].a));else{const e=t[s].getAABB().max.x,n=r[i],a=0==i?0:r[i-1],c=V3.polar(e,a).to(V3.polar(e,n));f=projectCurve$$1(o[i][s].curve,c,!1)}c.push(Face$$1.create(f,l))}}),i){const e=o[n].map(t=>t.flipped()).reverse(),s=new PlaneFace$$1(new PlaneSurface$$1(P3$$1.ZX.rotateZ(r.last)),e);c.push(new PlaneFace$$1(new PlaneSurface$$1(P3$$1.ZX.flipped()),t),s)}return new BRep$$1(c,new PlaneSurface$$1(P3$$1.ZX).edgeLoopCCW(t))},t.fixEdges=a,t.extrudeVertices=function(e,s,r,n,i){assert(e.every(t=>t instanceof V3),"baseVertices.every(v => v instanceof V3)"),assertInst(P3$$1,s),assertVectors(r),s.normal1.dot(r)>0&&(s=s.flipped());const o=StraightEdge$$1.chain(e,!0);return i=i||callsce("B2T.extrudeVertices",e,s,r,n),t.extrudeEdges(o,s,r,n,i)},t.tetrahedron=function(t,e,s,r,n="tetra"+getGlobalId$$1()){assertVectors(t,e,s,r);const i=P3$$1.throughPoints(t,e,s).distanceToPointSigned(r);if(eq0(i))throw new Error("four points are coplanar");i>0&&([s,r]=[r,s]);const o=StraightEdge$$1.throughPoints(t,e),a=StraightEdge$$1.throughPoints(t,s),c=StraightEdge$$1.throughPoints(t,r),h=StraightEdge$$1.throughPoints(e,s),u=StraightEdge$$1.throughPoints(e,r),l=StraightEdge$$1.throughPoints(s,r),f=[new PlaneFace$$1(PlaneSurface$$1.throughPoints(t,e,s),[o,h,a.flipped()],[],n+"abc"),new PlaneFace$$1(PlaneSurface$$1.throughPoints(t,r,e),[c,u.flipped(),o.flipped()],[],n+"adb"),new PlaneFace$$1(PlaneSurface$$1.throughPoints(e,r,s),[u,l.flipped(),h.flipped()],[],n+"bdc"),new PlaneFace$$1(PlaneSurface$$1.throughPoints(s,r,t),[l,c.flipped(),a],[],n+"cda")],p=callsce("B2T.tetrahedron",t,e,s,r);return new BRep$$1(f,!1,p)};const c=1/GOLDEN_RATIO,h=2-GOLDEN_RATIO;t.TETRAHEDRON_VERTICES=[new V3(1,0,-SQRT1_2),new V3(-1,0,-SQRT1_2),new V3(0,-1,SQRT1_2),new V3(0,1,SQRT1_2)].map(t=>t.unit()),t.DODECAHEDRON_VERTICES=[new V3(h,0,1),new V3(-h,0,1),new V3(-c,c,c),new V3(0,1,h),new V3(c,c,c),new V3(c,-c,c),new V3(0,-1,h),new V3(-c,-c,c),new V3(h,0,-1),new V3(-h,0,-1),new V3(-c,-c,-c),new V3(0,-1,-h),new V3(c,-c,-c),new V3(c,c,-c),new V3(0,1,-h),new V3(-c,c,-c),new V3(1,h,0),new V3(-1,h,0),new V3(-1,-h,0),new V3(1,-h,0)].map(t=>t.unit()),t.DODECAHEDRON_FACE_VERTICES=[[4,3,2,1,0],[7,6,5,0,1],[12,11,10,9,8],[15,14,13,8,9],[14,3,4,16,13],[3,14,15,17,2],[11,6,7,18,10],[6,11,12,19,5],[4,0,5,19,16],[12,8,13,16,19],[15,9,10,18,17],[7,1,2,17,18]],t.OCTAHEDRON_VERTICES=[new V3(1,0,0),new V3(-1,0,0),new V3(0,1,0),new V3(0,-1,0),new V3(0,0,1),new V3(0,0,-1)],t.OCTAHEDRON_FACE_VERTICES=[[0,2,4],[2,1,4],[1,3,4],[3,0,4],[2,0,5],[1,2,5],[3,1,5],[0,3,5]];const{x:u,y:l}=new V3(1,GOLDEN_RATIO,0).unit();function f(){return p(t.ICOSAHEDRON_VERTICES,t.ICOSAHEDRON_FACE_VERTICES,"B2T.icosahedron()")}function p(t,e,s){const r=new Map,n=e.map(e=>{const s=PlaneSurface$$1.throughPoints(t[e[0]],t[e[1]],t[e[2]]),n=arrayFromFunction(e.length,s=>{const n=(s+1)%e.length,i=e[s],o=e[n],a=min(i,o),c=max(i,o),h=a*t.length+c;let u=r.get(h);return!u&&r.set(h,u=StraightEdge$$1.throughPoints(t[a],t[c])),iStraightEdge$$1.throughPoints(e,t.a)),n=t.map((n,i)=>{const o=s+"Wall"+i,a=(i+1)%t.length,c=[r[i],n,r[a].flipped()],h=projectPointCurve$$1(n.curve,n.minT,n.maxT,e,n.deltaT()<0);return Face$$1.create(h,c,void 0,o)}),i=new PlaneSurface$$1(P3$$1.XY).flipped(),o=Face$$1.create(i,Edge$$1.reversePath(t));n.push(o);const a=callsce("B2T.pyramidEdges",t,e,s);return new BRep$$1(n,!1,a)},t.fromBPT=function(t){const e=/.*/g,s=()=>e.exec(t)[0],r=()=>s().trim().split(/\s+/).map(t=>parseFloat(t)),n=parseInt(s()),i=arrayFromFunction(n,()=>{const[t,e]=r(),s=arrayFromFunction(t*e,()=>VV(...r(),1)),n=new NURBSSurface$$1(s,NURBS$$1.bezierKnots(t),NURBS$$1.bezierKnots(e),t,e,0,1,0,1),i=[Edge$$1.forCurveAndTs(n.isoparametricV(0)),Edge$$1.forCurveAndTs(n.isoparametricU(1)),Edge$$1.forCurveAndTs(n.isoparametricV(1)).flipped(),Edge$$1.forCurveAndTs(n.isoparametricU(0)).flipped()];return Face$$1.create(n,i)});return new BRep$$1(i,!1)}}(B2T||(B2T={}));class CustomPlane$$1 extends P3$$1{constructor(t,e,s,r="CustomPlane"+getGlobalId$$1(),n=chroma.random().gl(),i=-500,o=500,a=-500,c=500){const{normal1:h,w:u}=P3$$1.forAnchorAndPlaneVectors(t,e,s);super(h,u),this.up=s,this.right=e,this.uMin=i,this.uMax=o,this.vMin=a,this.vMax=c,this.name=r,this.color=n}get plane(){return this}toPlaneSurface(){return new PlaneSurface$$1(this,this.right,this.up)}toSource(){return callsce("new CustomPlane",this.anchor,this.right,this.up,this.name,this.color,this.sMin,this.sMax,this.tMin,this.tMax)}static forPlane(t,e=GL_COLOR_BLACK,s){const r=t.normal1.getPerpendicular().unit(),n=r.cross(t.normal1);return new CustomPlane$$1(t.anchor,n,r,s,e)}static fromPlaneSurface(t){return new CustomPlane$$1(t.plane.anchor,t.right,t.up,"genCustomPlane"+getGlobalId$$1())}distanceTo(t,e){return[new L3$$1(this.anchor.plus(this.right.times(this.uMin)),this.up),new L3$$1(this.anchor.plus(this.right.times(this.uMax)),this.up),new L3$$1(this.anchor.plus(this.up.times(this.vMin)),this.right),new L3$$1(this.anchor.plus(this.up.times(this.vMax)),this.right)].map((s,r)=>{const n=s.infoClosestToLine(t);return(isNaN(n.t)||r<2&&this.vMin<=n.t&&n.t<=this.vMax||r>=2&&this.uMin<=n.t&&n.t<=this.uMax)&&n.distance<=e?n.s:1/0}).min()}distanceTo2(t,e){return[new L3$$1(this.anchor.plus(this.right.times(this.uMin)),this.up),new L3$$1(this.anchor.plus(this.right.times(this.uMax)),this.up),new L3$$1(this.anchor.plus(this.up.times(this.vMin)),this.right),new L3$$1(this.anchor.plus(this.up.times(this.vMax)),this.right)].map((s,r)=>{const n=s.infoClosestToLine(t);return(isNaN(n.t)||r<2&&this.vMin<=n.t&&n.t<=this.vMax||r>=2&&this.uMin<=n.t&&n.t<=this.uMax)&&n.distance<=e?n.distance:1/0}).min()}}class Edge$$1 extends Transformable{constructor(t,e,s,r,n,i,o){super(),this.curve=t,this.a=e,this.b=s,this.aT=r,this.bT=n,this.flippedOf=i,this.name=o,assertNumbers(r,n),assert(!eq(r,n)),assertVectors(e,s),assertf(()=>t instanceof Curve$$1,t),assertf(()=>!t.isValidT||t.isValidT(r)&&t.isValidT(n),r,n,t),assertf(()=>t.at(r).like(e),()=>""+t.at(r)+e+" aT should have been "+t.pointT(e)),assertf(()=>t.at(n).like(s),()=>""+t.at(n)+s+" bT should have been "+t.pointT(s)),assertf(()=>fuzzyBetween(r,t.tMin,t.tMax),r,t.tMin,t.tMax),assertf(()=>fuzzyBetween(n,t.tMin,t.tMax),n,t.tMin,t.tMax),this.aT=clamp(r,t.tMin,t.tMax),this.bT=clamp(n,t.tMin,t.tMax),this.reversed=this.aT>this.bT}get minT(){return Math.min(this.aT,this.bT)}get maxT(){return Math.max(this.aT,this.bT)}static forCurveAndTs(t,e=t.tMin,s=t.tMax){return Edge$$1.create(t,t.at(e),t.at(s),e,s,void 0,ee.b.like(t[(s+1)%t.length].a))}static edgesIntersect(t,e){assertNumbers(t.curve.hlol,e.curve.hlol),assertInst(Edge$$1,t,e),t.curve.hlolisNaN(t.tThis)||isNaN(t.tOther))&&(console.log(t.sce),console.log(e.sce),assert(!1)),s.some(({tThis:s,tOther:r})=>t.tValueInside(s)&&e.tValueInside(r))}static assertLoop(t){t.forEach((e,s)=>{const r=(s+1)%t.length;assert(e.b.like(t[r].a),`edges[${s}].b != edges[${r}].a (${t[s].b.sce} != ${t[r].a.sce})`)})}static ngon(t=3,e=1){return StraightEdge$$1.chain(arrayFromFunction(t,s=>V3.polar(e,TAU*s/t)))}static star(t=5,e=1,s=.5){const r=arrayFromFunction(2*t,r=>V3.polar(0==r%2?e:s,TAU*r/t/2));return StraightEdge$$1.chain(r)}static reversePath(t,e=!0){return e?arrayFromFunction(t.length,e=>t[t.length-1-e].flipped()):t}static rect(t=1,e=t){const s=[new V3(0,0,0),new V3(t,0,0),new V3(t,e,0),new V3(0,e,0)];return StraightEdge$$1.chain(s)}static reuleaux(t=3,e=1){assert(3<=t),assert(1==t%2);const s=arrayFromFunction(t,s=>V3.polar(e,TAU*s/t));return arrayFromFunction(t,e=>{const r=(e+floor(t/2))%t,n=(e+ceil(t/2))%t,i=s[r],o=s[n],a=s[e],c=a.to(i),h=new EllipseCurve$$1(a,c,V3.Z.cross(c));return Edge$$1.create(h,i,o,0,h.pointT(o),void 0,V3.Z.cross(c),V3.Z.cross(a.to(o)))})}static round(t,e){if(eq0(e))return t;const s=t.map((s,r)=>{const n=(r+1)%t.length,i=t[n];if(!s.b.like(i.a))return;const o=s.bDir.angleTo(i.aDir),a=s.curve,c=i.curve;if(a instanceof L3$$1&&c instanceof L3$$1){const t=a.dir1.cross(c.dir1);if(eq0(o))return;const s=t.cross(a.dir1),r=t.cross(c.dir1),n=a.transform(M4.translate(s.toLength(e))),i=c.transform(M4.translate(r.toLength(e))),h=n.isInfoWithLine(i);if(!h)throw new Error("tangential curves");const u=h.plus(s.toLength(-e)),l=h.plus(r.toLength(-e)),f=s.toLength(-e),p=new EllipseCurve$$1(h,f,t.cross(f).toLength(e));return Edge$$1.create(p,u,l,0,p.pointT(l),void 0,a.dir1,c.dir1)}return Edge$$1.arbitraryCorner(s,i,e)});return t.flatMap((e,r)=>{const n=(r+t.length-1)%t.length,i=s[n],o=s[r];if(!i&&!o)return e;const[a,c,h]=i?[e.curve.pointT(i.b),i.b,i.bDir]:[e.aT,e.a,e.aDir],[u,l,f]=o?[e.curve.pointT(o.a),o.a,o.aDir]:[e.bT,e.b,e.bDir],p=Edge$$1.create(e.curve,c,l,a,u,void 0,h,f);return o?[p,o]:p})}static arbitraryCorner(t,e,s){const r=t.curve,n=e.curve;const i=t.bT-s*sign(t.deltaT())/t.bDir.length(),o=e.aT+s*sign(e.deltaT())/e.aDir.length(),[a,c]=newtonIterate(function([t,e]){const i=r.at(t),o=n.at(e),a=r.tangentAt(t),c=n.tangentAt(e),h=a.cross(c),u=h.cross(a).unit(),l=h.cross(c).unit(),f=u.cross(l);h.likeO()&&assert(!1);const p=i.to(o);eq0(p.dot(h))||assert(!1);const d=p.cross(l).dot(f)/f.squared(),m=p.cross(u).dot(f)/f.squared(),$=i.plus(u.times(d)),g=o.plus(l.times(m));return assert($.like(g)),[abs(d)-s,abs(m)-s]},[i,o]),h=t.curve.at(a),u=e.curve.at(c),l=r.tangentAt(a),f=n.tangentAt(c),p=l.cross(f),d=p.cross(l).unit().toLength(-s),m=h.minus(d),$=new EllipseCurve$$1(m,d,p.cross(d).toLength(s));return Edge$$1.create($,h,u,0,$.pointT(u),void 0,r.tangentAt(a),n.tangentAt(c))}static pathFromSVG(t){let e=void 0;const s=new SVGPathData(t).toAbs().normalizeHVZ().sanitize(NLA_PRECISION).annotateArcs().commands,r=[];for(const t of s){assert("x"in t&&"y"in t);const s=new V3(t.x,t.y,0);switch(t.type){case SVGPathData.LINE_TO:r.push(StraightEdge$$1.throughPoints(e,s));break;case SVGPathData.CURVE_TO:{const n=new V3(t.x1,t.y1,0),i=new V3(t.x2,t.y2,0),o=new BezierCurve$$1(e,n,i,s,0,1),a=new PCurveEdge$$1(o,e,s,0,1,void 0,o.tangentAt(0),o.tangentAt(1));r.push(a);break}case SVGPathData.QUAD_TO:{const n=new V3(t.x1,t.y1,0),i=ParabolaCurve$$1.quadratic(e,n,s).rightAngled(),o=new PCurveEdge$$1(i,e,s,i.tMin,i.tMax,void 0,i.tangentAt(i.tMin),i.tangentAt(i.tMax));r.push(o);break}case SVGPathData.ARC:{const n=t.phi1*DEG,i=t.phi2*DEG,[o,a]=[n,i].sort(MINUS),c=arrayRange(-3,4,1).map(t=>t*PI).filter(t=>o<=t&&t<=a),h=V(t.cX,t.cY),u=V3.polar(t.rX,t.xRot*DEG),l=V3.polar(t.rY,t.xRot*DEG+Math.PI/2),f=getIntervals(c,o,a).map(([t,r])=>{const o=r-t,a=mod(t,TAU),c=a+o;assert(a>=0==c>=0);const f=a>PI||c>PI,p=f?a-PI:a,d=f?c-PI:c,m=new EllipseCurve$$1(h,f?u.negated():u,f?l.negated():l),$=n==t?e:i==t?s:m.at(p),g=n==r?e:i==r?s:m.at(d);return new PCurveEdge$$1(m,$,g,p,d,void 0,m.tangentAt(p),m.tangentAt(d))});r.push(...t.phiDelta>0?f:Edge$$1.reversePath(f));break}}e=s}return r}toString(){return callsce("new "+this.constructor.name,this.curve,this.a,this.b,this.aT,this.bT,void 0,this.aDir,this.bDir)}split(t){const e=this.curve.at(t),s=this.tangentAt(t);return[Edge$$1.create(this.curve,this.a,e,this.aT,t,void 0,this.aDir,s,this.name+"left"),Edge$$1.create(this.curve,e,this.b,t,this.bT,void 0,s,this.bDir,this.name+"left")]}colinearToLine(t){return this.curve instanceof L3$$1&&this.curve.isColinearTo(t)}tValueInside(t){return this.aT{s.forEach(s=>{lt(this.minT,s)&<(s,this.maxT)&&(t[r]=Math.min(t[r],this.curve.at(s).e(r)),e[r]=Math.max(e[r],this.curve.at(s).e(r)))})});const s=new AABB(V(t),V(e));return s.addPoint(this.a),s.addPoint(this.b),s}length(t=1){return this.curve.arcLength(this.minT,this.maxT,t)}deltaT(){return this.bT-this.aT}deltaTSign(){return sign(this.bT-this.aT)}atAvgT(){return this.curve.at((this.minT+this.maxT)/2)}static loopsEqual(t,e){return t.length==e.length&&arrayRange(0,t.length,1).some(s=>t.every((r,n)=>r.equals(e[(s+n)%t.length])))}}class PCurveEdge$$1 extends Edge$$1{constructor(t,e,s,r,n,i,o,a,c){super(t,e,s,r,n,i,c),this.flippedOf=i,this.aDir=o,this.bDir=a,assertVectors(o,a),assertf(()=>!o.likeO(),t),assertf(()=>!a.likeO(),t),t instanceof PICurve$$1||(assertf(()=>t.tangentAt(r).likeOrReversed(o),""+r+t.tangentAt(r).sce+" "+o.sce),assertf(()=>t.tangentAt(n).likeOrReversed(a),""+n+t.tangentAt(n).sce+" "+a.sce)),assert(this.reversed===this.aDir.dot(t.tangentAt(r))<0,r+" "+n+" "+t.constructor.name+" "+this.aDir.sce+" "+this.bDir.sce+" "+t.tangentAt(r)),assert(this.reversed===this.bDir.dot(t.tangentAt(n))<0,r+" "+n+" "+t.constructor.name+" "+this.aDir.sce+" "+this.bDir.sce+" "+t.tangentAt(r))}static forCurveAndTs(t,e,s,r){return new PCurveEdge$$1(t,t.at(e),t.at(s),e,s,void 0,esnap2(t,this.aT,this.bT)).filter(t=>this.minT<=t&&t<=this.maxT)}edgeISTsWithPlane(t){return this.curve.isTsWithPlane(t).map(t=>snap2(t,this.aT,this.bT)).filter(t=>this.minT<=t&&t<=this.maxT)}tangentAt(t){return this.reversed?this.curve.tangentAt(t).negated():this.curve.tangentAt(t)}flipped(){return this.flippedOf||(this.flippedOf=new PCurveEdge$$1(this.curve,this.b,this.a,this.bT,this.aT,this,this.bDir.negated(),this.aDir.negated(),this.name))}transform(t,e){return new PCurveEdge$$1(this.curve.transform(t),t.transformPoint(this.a),t.transformPoint(this.b),this.aT,this.bT,void 0,t.transformVector(this.aDir),t.transformVector(this.bDir),""+this.name+e)}transform4(t,e){const s=t.transformPoint(this.a),r=t.transformPoint(this.b),n=this.curve.transform4(t);return new PCurveEdge$$1(n,s,r,snap(n.pointT(s),this.aT),snap(n.pointT(r),this.bT),void 0,t.transformVector(this.aDir),t.transformVector(this.bDir),""+this.name+e)}isCoEdge(t){return this===t||this===t.flippedOf||this.curve.isColinearTo(t.curve)&&(this.a.like(t.a)&&this.b.like(t.b)||this.a.like(t.b)&&this.b.like(t.a))}}class StraightEdge$$1 extends Edge$$1{constructor(t,e,s,r,n,i,o){super(t,e,s,r,n,i,o),this.flippedOf=i,assertInst(L3$$1,t),!i||assertInst(StraightEdge$$1,i),!o||assertf(()=>"string"==typeof o,o),assert(!e.like(s),"!a.like(b)"+e+s),this.tangent=this.aTStraightEdge$$1.throughPoints(t[e],t[(e+1)%s]))}toSource(){return callsce("new StraightEdge",this.curve,this.a,this.b,this.aT,this.bT)}getVerticesNo0(){return[this.b]}pointsCount(){return 2}points(){return[this.a,this.b]}edgeISTsWithPlane(t){const e=snap2(this.curve.isTWithPlane(t),this.aT,this.bT);return this.minT<=e&&e<=this.maxT?[e]:[]}edgeISTsWithSurface(t){return t instanceof PlaneSurface$$1?this.edgeISTsWithPlane(t.plane):t.isTsForLine(this.curve).map(t=>snap2(t,this.aT,this.bT)).filter(t=>this.minT<=t&&t<=this.maxT)}tangentAt(){return this.tangent}flipped(){return this.flippedOf||(this.flippedOf=new StraightEdge$$1(this.curve,this.b,this.a,this.bT,this.aT,this,this.name))}transform(t,e){const s=t.transformVector2(this.curve.dir1,this.curve.anchor).length(),r=this.curve.transform(t),n=t.transformPoint(this.a),i=t.transformPoint(this.b);return new StraightEdge$$1(r,n,i,t.isNoProj()?this.aT*s:r.pointT(n),t.isNoProj()?this.bT*s:r.pointT(i),void 0,""+this.name+e)}transform4(t,e){const s=t.transformVector2(this.curve.dir1,this.curve.anchor).length(),r=this.curve.transform4(t),n=t.transformPoint(this.a),i=t.transformPoint(this.b);return new StraightEdge$$1(r,n,i,t.isNoProj()?this.aT*s:r.pointT(n),t.isNoProj()?this.bT*s:r.pointT(i),void 0,""+this.name+e)}isCoEdge(t){return this===t||this===t.flippedOf||t.constructor===StraightEdge$$1&&(this.a.like(t.a)&&this.b.like(t.b)||this.a.like(t.b)&&this.b.like(t.a))}getEdgeT(t){assertVectors(t);let e=t.minus(this.curve.anchor).dot(this.curve.dir1);if(eq0(this.curve.at(e).distanceTo(t)))return e=snap2(e,this.aT,this.bT),this.minT<=e&&e<=this.maxT?e:void 0}}class FaceInfoFactory{static makeStatic(t){return new class extends FaceInfoFactory{constructor(){super()}info(e,s,r){return t}}}info(t,e,s){throw new Error("no default implementation")}extrudeBottom(t,e,s=[]){return this.info(t,e,s)}extrudeTop(t,e,s=[]){return this.info(t,e,s)}extrudeWall(t,e,s,r=[]){return this.info(e,s,r)}rotationWall(t,e,s,r=[]){return this.info(e,s,r)}rotationStart(t,e,s=[]){return this.info(t,e,s)}rotationEnd(t,e,s=[]){return this.info(t,e,s)}newSubFace(t,e,s,r=[]){return t.info}transform(t,e,s,r,n,i=[]){return t.info}}class Face$$1 extends Transformable{constructor(t,e,s=[],r,n){super(),this.surface=t,this.contour=e,this.holes=s,this.name=r,this.info=n,this.aabb=void 0,Edge$$1.assertLoop(e),assert(e.every(t=>t instanceof Edge$$1),()=>"contour.every(f => f instanceof Edge)"+e),assert(t.edgeLoopCCW(e),t.toString()+e.join("\n")),s&&s.forEach(t=>Edge$$1.assertLoop(t)),s&&s.forEach(e=>assert(!t.edgeLoopCCW(e))),assert(!s||s.constructor==Array,s&&s.toString()),this.allEdges=Array.prototype.concat.apply(this.contour,this.holes)}static assembleFacesFromLoops(t,e,s){const r=[],n=[];return t.forEach(t=>(function t(s,r){if(0==r.length)r.push(s);else{const n=r.find(t=>BRep$$1.loop1ContainsLoop2(t.loop,t.ccw,s.loop,s.ccw,e));if(n)t(s,n.subloops);else{for(let t=r.length;--t>=0;){const n=r[t];BRep$$1.loop1ContainsLoop2(s.loop,s.ccw,n.loop,n.ccw,e)&&(s.subloops.push(n),r.splice(t,1))}r.push(s)}}})({loop:t,ccw:e.edgeLoopCCW(t),subloops:[]},n)),n.forEach(t=>(function t(n){r.push(new s(e,n.ccw?n.loop:Edge$$1.reversePath(n.loop),n.subloops.map(t=>t.ccw?Edge$$1.reversePath(t.loop):t.loop))),n.subloops.forEach(e=>e.subloops.forEach(e=>t(e)))})(t)),r}static create(t,e,s,r,n){return t instanceof PlaneSurface$$1?new PlaneFace$$1(t,e,s,r,n):new RotationFace$$1(t,e,s,r,n)}intersectFace(t,e,s,r,n,i,o){function a(t,e){return o.has(new Pair(t,e))}function c(t,e){return o.add(new Pair(t,e))}function h(o,h,u){if(!h&&!u){let e=l.surface.normalP(o.a).cross(t.surface.normalP(o.a));if(e.likeO()){const s=lerp(o.aT,o.bT,1/GOLDEN_RATIO),r=o.curve.at(s);e=l.surface.normalP(r).cross(t.surface.normalP(r))}if(e.likeO()){const e=o.a,s=P3$$1.normalOnAnchor(o.aDir,e),n=l.surface.normalP(e),i=n.dot(t.surface.normalP(e))>0,a=s.normal1.cross(n),c=l.surface.isCurvesWithPlane(s)[0],h=c.pointT(e),u=sign(a.dot(c.tangentAt(h))),f=t.surface.isCurvesWithPlane(s)[0],p=f.pointT(e),d=sign(a.dot(c.tangentAt(p))),m=c.diff(h,EPS$$1*u).dot(n),$=f.diff(p,EPS$$1*d).dot(n);${const e=fff$$1(t,n.surface),s=e==INSIDE$$1||!h&&e==COPLANAR_SAME$$1,i=t.edge.tangentAt(t.edge.curve.pointT(o.a)).like(o.aDir)?o:o.flipped();console.log(o.sce),assert(t.edge.tangentAt(t.edge.curve.pointT(i.a)).like(i.aDir)),s&&mapPush(r,t.face,i)});const s=e.normalP(o.a),c=s.cross(o.aDir),u=splitsVolumeEnclosingFacesP$$1(i,t.getCanon(),o.a,c,s);let l,f;(l=u==INSIDE$$1||h&&u==COPLANAR_SAME$$1)&&mapPush(r,n,o);const p=splitsVolumeEnclosingFacesP$$1(i,t.getCanon(),o.a,c.negated(),s);if((f=p==INSIDE$$1||h&&p==COPLANAR_SAME$$1)&&mapPush(r,n,o.flipped()),l||f||u==COPLANAR_SAME$$1&&p==INSIDE$$1||p==COPLANAR_SAME$$1&&u==INSIDE$$1)return!0}return!1}const p=f(h,u,0,t,e,0,!1),d=f(u,h,0,l,s,0,!0);if(p||d)return!0;if(h&&u){if(a(h.getCanon(),u.getCanon()))return!1;function m(t,e,s,n,i,a,c,h){for(const c of s.edgeFaces.get(t.getCanon())){const s=splitsVolumeEnclosingFaces$$1(n,e.getCanon(),c.inside,c.normalAtCanonA),h=s==INSIDE$$1||i&&s==COPLANAR_SAME$$1,u=c.edge.aDir.like(o.aDir)?o:o.flipped();if(h){mapPush(r,c.face,u);const e=t.getCanon().curve.pointT(o.a);eq(e,t.aT)||eq(e,t.bT)||splitsVolumeEnclosingCone2$$1(n,o.a,o.curve,o.aT,-Math.sign(o.deltaT()))==INSIDE$$1&&mapPush(a,t.getCanon(),{p:o.a,edgeT:e});const s=t.getCanon().curve.pointT(o.b);eq(s,t.aT)||eq(s,t.bT)||splitsVolumeEnclosingCone2$$1(n,o.b,o.curve,o.bT,Math.sign(o.deltaT()))==INSIDE$$1&&mapPush(a,t.getCanon(),{p:o.b,edgeT:s})}}}return c(h.getCanon(),u.getCanon()),m(h,u,e,s,!0,n),m(u,h,s,e,!1,i),!1}return!1}function u(t,r,o){if(t&&!r&&(t.colinear||t.edgeT==t.edge.aT||t.edgeT==t.edge.bT||(mapPush(n,t.edge.getCanon(),t),assert(t.edge.isValidT(t.edgeT)))),r&&!t&&(r.colinear||r.edgeT==r.edge.aT||r.edgeT==r.edge.bT||(mapPush(i,r.edge.getCanon(),r),assert(r.edge.isValidT(r.edgeT)))),t&&r){function a(t,e,s,r,n,i,o,a,h,u){if(!t.colinear&&t.edgeT!=t.edge.aT&&t.edgeT!=t.edge.bT)if(c(t.edge.getCanon(),e.edge.getCanon()),t.p.like(e.edge.a)||t.p.like(e.edge.b)){const s=t.p.like(e.edge.a)?e.edge.a:e.edge.b,r=splitsVolumeEnclosingCone2$$1(a,s,t.edge.curve,t.edgeT,1),n=splitsVolumeEnclosingCone2$$1(a,s,t.edge.curve,t.edgeT,-1);INSIDE$$1!=r&&INSIDE$$1!=n||(mapPush(u,t.edge.getCanon(),t),assert(t.edge.isValidT(t.edgeT)))}else{const s=splitsVolumeEnclosingFacesP2$$1(a,e.edge.getCanon(),t.p,t.edge.curve,t.edgeT,1,n.normalP(t.p)),r=splitsVolumeEnclosingFacesP2$$1(a,e.edge.getCanon(),t.p,t.edge.curve,t.edgeT,-1,n.normalP(t.p));(INSIDE$$1==s||h&&COPLANAR_SAME$$1==s||INSIDE$$1==r||h&&COPLANAR_SAME$$1==r)&&(mapPush(u,t.edge.getCanon(),t),assert(t.edge.isValidT(t.edgeT)))}}assert(t.colinear||r.colinear||eq(t.t,r.t)),a(t,r,0,0,f,0,0,s,!0,n),a(r,t,0,0,p,0,0,e,!1,i)}}assertInst(Face$$1,t);const l=this,f=l.surface,p=t.surface;if(!this.getAABB().touchesAABBfuzzy(t.getAABB()))return;if(f.isCoplanarTo(p))return;const d=f.isCurvesWithSurface(p);if(0!=d.length){for(const t of d)assert(f.containsCurve(t)),assert(p.containsCurve(t));for(let e=0;e0==r.length||!eq0(r[0].insideDir.dot(s.tangentAt(r[0].t))),()=>r[0].insideDir.dot(s.tangentAt(r[0].t))),assertf(()=>0==n.length||!eq0(n[0].insideDir.dot(s.tangentAt(n[0].t))),()=>n[0].insideDir.dot(s.tangentAt(n[0].t)));let i,o,a=m(r,l),c=m(n,t);if(0==r.length&&!a||0==n.length&&!c)continue;let f,p,$,g,v=0,P=0,C=a&&c?s.at(s.tMin):void 0,x=s.tMin;for(;vf.t&&(p=p.negated());let r=s.tangentAt(f.t);x>f.t&&(r=r.negated());const n=Edge$$1.create(s,C,f.p,x,f.t,void 0,p,r,"genseg"+getGlobalId$$1());C=void 0,h(n,i&&i.edge,o&&o.edge)&&(u($||i,g||o),u(t&&t.used&&t||i,e&&e.used&&e||o))}}if(a&&c&&x!==s.tMax){const t=s.tMax;p=s.tangentAt(x),x>t&&(p=p.negated());let e=s.tangentAt(t);x>t&&(e=e.negated());const r=Edge$$1.create(s,C,s.at(t),x,t,void 0,p,e,"genseg"+getGlobalId$$1());h(r,i&&i.edge,o&&o.edge)&&u($||i,g||o)}}l.getAllEdges().forEach(e=>{o.add(new Pair(e.getCanon(),t))}),t.getAllEdges().forEach(t=>{o.add(new Pair(t.getCanon(),l))})}}edgeISPsWithSurface(t,e){const s=this.surface,r=this.holes.concat([this.contour]),n=[];for(const i of r){const r=i.map(e=>e.curve.isColinearTo(t));for(let o=0;o0&&n.push({p:c.b,insideDir:a.aDir.negated(),t:h,edge:c,edgeT:c.bT,colinear:!1}),n.push({p:a.a,insideDir:a.aDir,t:h,edge:a,edgeT:a.aT,colinear:!0})}if(t.containsPoint(a.b)){const e=t.pointT(a.b),i=a.bDir.cross(s.normalP(a.b));!r[c]&&dotCurve2$$1(h.curve,h.aT,i,sign(h.deltaT()))>0&&n.push({p:a.b,insideDir:a.bDir,t:e,edge:h,edgeT:h.aT,colinear:!1}),n.push({p:a.b,insideDir:a.bDir.negated(),t:e,edge:a,edgeT:a.bT,colinear:!0})}}else{const i=a.edgeISTsWithSurface(e);for(const e of i){const i=a.curve.at(e);if(!t.containsPoint(i))continue;const o=t.pointT(i);assert(!isNaN(o));const h=a.tangentAt(e).cross(s.normalP(i)).negated(),u=t.tangentAt(o);if(e==a.bT){if(!r[c]){if(!eq(o,t.tMax)){const e=this.pointsToInside3(a.b,t,o,1);assert(e!=PointVsFace.ON_EDGE),PointVsFace.INSIDE==e&&n.push({p:a.b,insideDir:u,t:o,edge:a,edgeT:a.bT,colinear:!1})}if(!eq(o,t.tMin)){const e=this.pointsToInside3(a.b,t,o,-1);assert(e!=PointVsFace.ON_EDGE),PointVsFace.INSIDE==e&&n.push({p:a.b,insideDir:u.negated(),t:o,edge:a,edgeT:a.bT,colinear:!1})}}}else if(e!=a.aT)if(eq0(h.dot(u))){const s=sign(u.dot(a.curve.tangentAt(e))),r=1e-4;for(const c of[-1,1]){if(-1==c*s&&e==a.minT||1==c*s&&e==a.maxT||-1==c&&o==t.tMin||1==c&&o==t.tMax)continue;t.at(o).to(t.at(o+c*r)).dot(h)-a.curve.at(e).to(a.curve.at(e+c*s*r)).dot(h)>0&&n.push({p:i,insideDir:u.times(c),t:o,edge:a,edgeT:e,colinear:!1})}}else n.push({p:i,insideDir:h,t:o,edge:a,edgeT:e,colinear:!1})}}}}return n.sort((e,s)=>e.t-s.t||e.insideDir.dot(t.tangentAt(e.t))),n}transform(t){const e=t.isMirroring(),s=Edge$$1.reversePath(this.contour.map(e=>e.transform(t)),e),r=this.holes.map(s=>Edge$$1.reversePath(s.map(e=>e.transform(t)),e));return new this.constructor(this.surface.transform(t),s,r,this.name,this.info)}transform4(t){const e=t.isMirroring(),s=Edge$$1.reversePath(this.contour.map(e=>e.transform4(t)),e),r=this.holes.map(s=>Edge$$1.reversePath(s.map(e=>e.transform4(t)),e));return new this.constructor(this.surface.transform4(t),s,r,this.name,this.info)}flipped(){const t=this.contour.map(t=>t.flipped()).reverse(),e=this.holes.map(t=>t.map(t=>t.flipped()).reverse());return new this.constructor(this.surface.flipped(),t,e,this.name,this.info)}toString(){return"new "+this.constructor.name+"("+this.surface+", ["+this.contour.map(t=>"\n\t"+t).join()+"]"+this.holes.map(t=>"\n\t\thole: "+t.join())+")"}toSource(){return"new "+this.constructor.name+"("+this.surface.toSource()+", ["+this.contour.map(t=>"\n\t"+t.toSource()+",").join("")+"], ["+this.holes.map(t=>"["+t.map(t=>"\n\t"+t.toSource()+",").join("")+"]").join(",")+"])"}equals(t){return this==t||Object.getPrototypeOf(this)==Object.getPrototypeOf(t)&&this.holes.length==t.holes.length&&Edge$$1.loopsEqual(this.contour,t.contour)&&this.holes.every(e=>t.holes.some(t=>Edge$$1.loopsEqual(e,t)))}hashCode(){function t(t){let e=0;for(const s of t)e=31*e+s|0;return e}function e(e){return t(e.map(t=>t.hashCode()).sort(MINUS))}let s=0;return s=31*(s=31*(s=31*s+t(this.holes.map(t=>e(t)).sort(MINUS))|0)+e(this.contour)|0)+this.surface.hashCode()|0}likeFace(t){function e(t,e){return t.length==e.length&&arrayRange(0,t.length,1).some(s=>t.every((r,n)=>r.like(e[(s+n)%t.length])))}return assertInst(Face$$1,t),this.surface.like(t.surface)&&this.holes.length==t.holes.length&&e(this.contour,t.contour)&&this.holes.every(s=>t.holes.some(t=>e(s,t)))}getAllEdges(){return this.allEdges}addEdgeLines(t){assert(!1,"buggy, fix");const e=this.contour.flatMap(t=>t.getVerticesNo0()),s=t.vertices.length;for(let r=0;rthis.surface.loopContainsPoint(e,t)!=PointVsFace.OUTSIDE)}containsPoint2(t){assertVectors(t);const e=this.surface.loopContainsPoint(this.contour,t);if(e!=PointVsFace.INSIDE)return e;for(const e of this.holes){const s=this.surface.loopContainsPoint(e,t);if(s!=PointVsFace.OUTSIDE)return s==PointVsFace.ON_EDGE?PointVsFace.ON_EDGE:PointVsFace.OUTSIDE}return PointVsFace.INSIDE}intersectsLine(t){if(assertInst(L3$$1,t),!this.getAABB().intersectsLine(t))return NaN;const e=this.surface.isTsForLine(t).filter(e=>this.containsPoint(t.at(e))).withMax(t=>-t);return void 0!=e?e:NaN}toMesh(){const t=(new Mesh).addIndexBuffer("TRIANGLES").addIndexBuffer("LINES").addVertexBuffer("normals","ts_Normal");return this.addToMesh(t),t}zDirVolume(){return this.surface.zDirVolume(this.getAllEdges())}calcArea(){return this.surface.calculateArea(this.getAllEdges())}getLoops(){return[this.contour,...this.holes]}getAABB(){return this.aabb||(this.aabb=AABB.forAABBs(this.contour.map(t=>t.getAABB())))}pointsToInside3(t,e,s,r){const n=this.surface.normalP(t),i=e.tangentAt(s).times(r),o=n.cross(i),a=e.at(s).to(e.at(s+1e-6*r)).dot(o);let c,h=1/0,u=!1;for(const s of this.getAllEdges()){const r=s.a.like(t),l=s.b.like(t);if(assert(r==s.a.like(t)),assert(l==s.b.like(t)),!r&&!l)continue;const f=r?s.aDir:s.bDir.negated(),p=i.angleRelativeNormal(f,n);if(eq0(p)){if(e.isColinearTo(s.curve))return PointVsFace.ON_EDGE;const t=r?s.aT:s.bT,n=(r?1:-1)*sign(s.deltaT()),i=s.curve.diff(t,1e-6*n).dot(o)-a;i>0&&(!u||iassert(doubleSignedArea(t,r.plane.normal1)>=0,"doubleSignedArea(vs, planeSurface.plane.normal1) >= 0"));const i=s.map(t=>StraightEdge$$1.chain(t));return new PlaneFace$$1(t,n,i)}addToMesh(t){const e=t.vertices.length,s=this.surface.plane.normal1,r=this.contour.flatMap(t=>t.getVerticesNo0());for(let s=0;s{n.push(r.length),r.push(...t.flatMap(t=>t.getVerticesNo0()))});const i=triangulateVertices$$1(s,r,n).map(t=>t+e);Array.prototype.push.apply(t.vertices,r),Array.prototype.push.apply(t.TRIANGLES,i),Array.prototype.push.apply(t.normals,arrayFromFunction(r.length,()=>s))}intersectsLine(t){assertInst(L3$$1,t);const e=t.isTWithPlane(this.surface.plane);return Number.isFinite(e)&&this.containsPoint(t.at(e))?e:NaN}withHole(t){return new PlaneFace$$1(this.surface,this.contour,[t])}pointsToInside(t,e){return this.containsPoint2(t.plus(e.times(8*NLA_PRECISION)))}edgeISPsWithPlane(t,e){assert(this.surface.plane.containsLine(t)),assert(e.containsLine(t));const s=this.surface.plane,r=[];return[this.contour].concat(this.holes).forEach(n=>{const i=n.map(e=>e.colinearToLine(t)&&-sign(e.aDir.dot(t.dir1))),o=t.dir1.cross(s.normal1);n.forEach((s,n,a)=>{const c=(n+1)%a.length,h=a[c],u=i[n];if(u){const e=t.pointT(s.a),n=t.pointT(s.b);r.push({p:s.a,insideDir:s.aDir,t:e,edge:s,edgeT:s.aT,colinear:!0},{p:s.b,insideDir:s.bDir.negated(),t:n,edge:s,edgeT:s.bT,colinear:!0}),u*(i[c]||dotCurve2$$1(h.curve,h.aT,o,h.deltaTSign()))<0&&r.push({p:h.a,insideDir:s.bDir,t:n,edge:h,edgeT:h.aT,colinear:!1})}else{const n=s.edgeISTsWithPlane(e);assert(n.every(t=>e.containsPoint(s.curve.at(t))),n);for(const a of n)if(a==s.bT){dotCurve2$$1(s.curve,s.bT,o,-s.deltaTSign())*(i[c]||dotCurve2$$1(h.curve,h.aT,o,h.deltaTSign()))<0&&r.push({p:s.b,insideDir:e.normal1.negated(),t:t.pointT(s.b),edge:s,edgeT:s.bT,colinear:!1})}else if(a!=s.aT){const n=s.curve.at(a);assert(e.containsPoint(n),s.toString(),n,a,e.distanceToPoint(n)),assert(t.containsPoint(n),s.toString(),n,a,t.distanceToPoint(n));const i=e.normal1.negated();r.push({p:n,insideDir:i,t:t.pointT(n),edge:s,edgeT:a,colinear:!1})}}})}),r.sort((e,s)=>e.t-s.t||e.insideDir.dot(t.dir1)),r}}class RotationFace$$1 extends Face$$1{constructor(t,e,s,r,n){super(t,e,s,r,n)}static loopDoesNotCrossPlane(t,e){let s=0;function r(t){return 0!=s?!s||s*t<0:(s=t,!1)}for(const s of t){const t=s.edgeISTsWithPlane(e);if(0==t.length){if(!(s.curve instanceof L3$$1)&&r(e.distanceToPointSigned(s.a)))return!1}else for(const n of t){if(s.aT!=n&&r(dotCurve2$$1(s.curve,n,e.normal1,-s.deltaTSign())))return!1;if(s.bT!=n&&r(dotCurve2$$1(s.curve,n,e.normal1,s.deltaTSign())))return!1}}return!0}getAABB(){return this.aabb?this.aabb:(this.aabb=AABB.forAABBs(this.contour.map(t=>t.getAABB())),this.aabb.addPoints(this.surface.getExtremePoints().filter(t=>this.containsPoint(t))),this.aabb)}unrollLoop(t){const e=[],s=this.surface.uvPFunc(),r=t.map(t=>t.getVerticesNo0()),n=r.findIndex(t=>!eq(s(t[0]).x,Math.PI));assert(-1!=n);for(let i=0;i{t.getVerticesNo0().forEach(t=>{e.push(s(t))})}),console.log("vs\n",e.join("\n"),e.length),e}unrollEllipsoidLoops(t){const e=[],s=[],r=[],n=this.surface,i=n.uvPFunc(),o=n instanceof EllipsoidSurface$$1?t=>t.like(n.center.plus(n.f3))||t.like(n.center.minus(n.f3)):t=>t.like(this.surface.center);for(const a of t){r.push(e.length);for(let t=0;ti(t))),o(a[r].a)){const i=n.matrixInverse.transformVector(a[t].bDir),o=n.matrixInverse.transformVector(a[r].aDir),c=Math.atan2(-i.y,-i.x),h=Math.atan2(o.y,o.x),u=e.pop();e.push(new V3(c,u.y,0),new V3(h,u.y,0)),s.push(s.last)}e.forEach(({u:t,v:e})=>{assert(isFinite(t)),assert(isFinite(e))})}}let a;if(this.surface instanceof EllipsoidSurface$$1)a=s.map(t=>n.normalP(t));else{const t=n.normalUVFunc();a=e.map(({u:e,v:s})=>t(e,s))}return assert(s.length==s.length),{verticesUV:e,vertices:s,normals:a,loopStarts:r}}unrollCylinderLoops(t){const e=t.map(t=>t.flatMap(t=>t.getVerticesNo0())),s=this.surface,r=e.concatenated(),n=e.reduce((t,e)=>(t.push(t.last+e.length),t),[0]),i=s.uvPFunc(),o=r.map(t=>i(t)),a=s.normalUVFunc();return{verticesUV:o,vertices:r,normals:o.map(({u:t,v:e})=>a(t,e)),loopStarts:n}}addToMesh(t,e=this.surface.uStep,s=this.surface.vStep){assertf(()=>e>0&&s>0,e,s,"Surface: "+this.surface);const r=[],n=(t,r)=>this.surface.pUVFunc()(t*e,r*s),i=(t,r)=>this.surface.normalUVFunc()(t*e,r*s),o=this.getLoops(),{vertices:a,verticesUV:c,normals:h,loopStarts:u}=this.surface instanceof EllipsoidSurface$$1||this.surface instanceof ConicSurface$$1?this.unrollEllipsoidLoops(o):this.unrollCylinderLoops(o);u.push(a.length);const l=c.map(({u:t,v:r})=>new V3(t/e,r/s,0));for(let e=0;e{assert(isFinite(t)),assert(isFinite(e)),f=min(f,t),p=max(p,t),d=min(d,e),m=max(m,e)}),ParametricSurface$$1.is(this.surface);const $=floor(f+NLA_PRECISION),g=floor(d+NLA_PRECISION),v=ceil(p-NLA_PRECISION)-$,P=ceil(m-NLA_PRECISION)-g;if(console.log(e,s,v,P),1==v&&1==P){const t=triangulateVertices$$1(V3.Z,l,u.slice(1,1+this.holes.length));r.push(...t)}else{const t=new Array(v*P);function C(e,s,r){assert(s0);let o=i;do{t.push(...o);const r=V(o.last),i=a.indexWithMax(t=>-mod(V(t[0])-r,4)),c=a.removeIndex(i);let h=r;const u=V(c[0])>h?V(c[0]):V(c[0])+4;let l=ceil(h+NLA_PRECISION),f=eq0((h+NLA_PRECISION)%1-NLA_PRECISION);for(;lt(l,u);){switch(l%4){case 0:t.push(M(e,n));break;case 1:s=s!=f,t.push(M(e+1,n));break;case 2:t.push(M(e+1,n+1));break;case 3:s=s!=f,t.push(M(e,n+1))}f=!0,l++}s=s!=(f&&l%2==1&&eq(l,u)),h=l,o=c}while(o!=i);if(3==t.length)r.push(...t);else{const e=triangulateVertices$$1(V3.Z,t.map(t=>l[t]),[]).map(e=>t[e]);r.push(...e)}}}else s&&pushQuad(r,!1,M(e,n),M(e+1,n),M(e,n+1),M(e+1,n+1))}}}Array.prototype.push.apply(t.TRIANGLES,r.map(e=>e+t.vertices.length)),Array.prototype.push.apply(t.vertices,a),Array.prototype.push.apply(t.normals,h),enableConsole()}addToMesh2(t){const e=[];let s=1/0,r=-1/0;const n=this.surface.pUVFunc(),i=this.surface.normalUVFunc(),o=this.holes.concat([this.contour]).map(t=>this.unrollLoop(t));o.forEach(t=>{t.forEach(({x:t,y:n})=>{const i=e.binaryIndexOf(t,(t,e)=>snap(t.value-e,0));i<0&&e.splice(-i-1,0,{value:t,left:[],right:[]}),s=min(s,n),r=max(r,n)})}),console.log("zzzs",s,r,o[0].toSource().replace(/\), /g,",\n"));o.forEach(t=>{t.forEach((t,s,r)=>{let n=r[(s+1)%r.length],i=n.x-t.x;if(eq0(i))return;i<0&&([t,n]=[n,t],i=-i);const o=e.binaryIndexOf(t.x,(t,e)=>snap(t.value-e,0)),a=e.binaryIndexOf(n.x,(t,e)=>snap(t.value-e,0));e[o].right.binaryInsert(t.y);for(let s=(o+1)%e.length;s!=a;s=(s+1)%e.length){const r=(e[s].value-t.x)/i,o=n.y*r+t.y*(1-r);e[s].left.binaryInsert(o),e[s].right.binaryInsert(o)}e[a].left.binaryInsert(n.y)})});const a=[],c=[],h=[];for(let t=0;ts+(1+t)*l);console.log("detailsZs",f);for(let t=0;te+t.vertices.length);Array.prototype.push.apply(t.vertices,a),Array.prototype.push.apply(t.TRIANGLES,m),Array.prototype.push.apply(t.normals,h)}}const EPS$$1=1e-5;let globalId=0;function getGlobalId$$1(){return globalId++}function addLikeSurfaceFaces$$1(t,e,s){for(let r=0;r!r.has(t));){o=i;const s=[];let a=0;do{r.add(o),s.push(o);const n=t.filter(t=>o.b.like(t.a)),i=e.normalP(o.b),a=n.indexWithMax(t=>o.bDir.angleRelativeNormal(t.aDir,i));o=n[a]}while(i!=o&&a++<200);assert(201!=a),n.push(s)}const a=BRep$$1.assembleFacesFromLoops(n,e,s);return assertf(()=>1==a.length),a[0]}function calcNextEdgeIndex$$1(t,e,s){let r=-20,n=!1,i=Number.MAX_SAFE_INTEGER;const o=t.bDir.cross(s),a=sign(t.deltaT()),c=t.curve.diff(t.bT,1e-4*-a).dot(o);for(let a=e.length;a--;){const h=e[a],u=(t.bDir.negated().angleRelativeNormal(h.aDir,s)+TAU+NLA_PRECISION)%TAU-NLA_PRECISION;if(eq0(u)){if(t.curve.isColinearTo(h.curve))continue;const e=sign(h.deltaT()),s=h.curve.diff(h.aT,1e-4*e).dot(o)-c;s<0&&(!n||s>r)&&(n=!0,r=s,i=a)}else n||gt(u,r)&&(r=u,i=a)}return i==Number.MAX_SAFE_INTEGER?0:i}class BRep$$1 extends Transformable{constructor(t,e,s,r){super(),this.faces=t,assertInst(Face$$1,...t),this.infiniteVolume=e,assert(!this.infiniteVolume||!0===this.infiniteVolume),this.generator=s,this.vertexNames=r,this.edgeFaces=void 0}static loop1ContainsLoop2(t,e,s,r,n){for(const e of s){const s=n.loopContainsPoint(t,e.a);if(PointVsFace.ON_EDGE!=s)return PointVsFace.INSIDE==s}for(const e of s){const s=e.curve.at(.2*e.aT+.8*e.bT),r=n.loopContainsPoint(t,s);if(PointVsFace.ON_EDGE!=r)return PointVsFace.INSIDE==r}if(e!=r)return r;throw new Error(t.sce+s.sce)}static assembleFacesFromLoops(t,e,s,r){const n=[],i=[];return t.forEach(t=>(function t(s,r){if(0==r.length)r.push(s);else{const n=r.find(t=>BRep$$1.loop1ContainsLoop2(t.loop,t.ccw,s.loop,s.ccw,e));if(n)t(s,n.subloops);else{for(let t=r.length;--t>=0;){const n=r[t];BRep$$1.loop1ContainsLoop2(s.loop,s.ccw,n.loop,n.ccw,e)&&(s.subloops.push(n),r.splice(t,1))}r.push(s)}}})({loop:t,ccw:e.edgeLoopCCW(t),subloops:[]},i)),i.forEach(t=>(function t(i){if(i.ccw)if(i.subloops.every(t=>!t.ccw)){const o=i.subloops.map(t=>t.loop),a=r&&r.newSubFace(s,e,i.loop,o),c=new s.constructor(e,i.loop,o,"genface"+getGlobalId$$1(),a);n.push(c),i.subloops.forEach(e=>e.subloops.forEach(e=>e.ccw&&t(e)))}else i.subloops.forEach(e=>e.ccw&&t(e))})(t)),n}static join(t,e){return new BRep$$1(t.flatMap(t=>t.faces),!1,e)}containsPoint(t,e=!1){const s=[V(-.3920414696448526,-.12936136783391444,-.9108068525164064),V(.6520650903544943,-.07151288645511984,-.7547827667692488),V(.9433494201061395,-.2402757256238473,-.22882186797013926),V(.13678704228501923,-.04480387361087783,.9895867410047372),V(.0662057922721913,-.5865836917435423,.8071780259955845),V(-.7322576567870621,-.12953393611526787,.6685953061989045),V(.6579719127258273,-.012300218400456116,.7529420075219719),V(-.5576497966736425,.8006695748324647,.2189861552871446)];t:for(const r of s){const s=new L3$$1(t,r);let n=this.infiniteVolume;for(const t of this.faces){assert(!t.surface.containsCurve(s));const r=t.surface.isTsForLine(s);for(const i of r){const r=s.at(i),o=t.containsPoint2(r);if(!e&&assert(!eq0(i)),i>0){if(o==PointVsFace.ON_EDGE)continue t;o==PointVsFace.INSIDE&&(n=!n)}}}return n}return!1}withMergedFaces(){const t=[];for(let e=0;et.includes(this.faces[r]));n&&(n.push(this.faces[e]),s=!0)}!s&&t.push([this.faces[e]])}if(console.log("likeSurfaceFaces",t),t.every(t=>1==t.length))return this;const e=[];let s=0;for(const r of t)if(console.log(r),1==r.length)e.push(r[0]);else{const t=r.flatMap(t=>t.getAllEdges());for(let e=t.length;e-- >0;)for(let r=0;r=0&&r>=0&&s++<500,e+" "+r+" "+s),t[e].isCoEdge(t[r])){t.splice(e,1),t.splice(r,1),e--;break}const n=assembleFaceFromLooseEdges$$1(t,r[0].surface,r[0]);e.push(n)}return new BRep$$1(e,this.infiniteVolume,this.generator&&this.generator+".withMergedFaces()",this.vertexNames)}calculateVolume(){return this.faces.map(t=>t.zDirVolume().volume).sum()}toMesh(){const t=(new Mesh).addVertexBuffer("normals","ts_Normal").addIndexBuffer("TRIANGLES").addIndexBuffer("LINES");t.faceIndexes=new Map;for(const e of this.faces){const s=t.TRIANGLES.length;e.addToMesh(t),t.faceIndexes.set(e,{start:s,count:t.TRIANGLES.length-s})}return t}minus(t,e){const s=this.generator&&t.generator&&this.generator+".minus("+t.generator+")";return this.intersection(t.flipped(),!0,!0,s,e)}plus(t,e){const s=this.generator&&t.generator&&this.generator+".plus("+t.generator+")";return this.flipped().intersection(t.flipped(),!0,!0,s,e).flipped()}and(t,e){const s=this.generator&&t.generator&&this.generator+".and("+t.generator+")";return this.intersection(t,!0,!0,s,e)}xor(t,e){const s=this.generator&&t.generator&&this.generator+".xor("+t.generator+")";return new BRep$$1(this.minus(t,e).faces.concat(t.minus(this,e).faces),this.infiniteVolume!=t.infiniteVolume,s)}equals(t){return this.faces.length==t.faces.length&&this.faces.every(e=>t.faces.some(t=>e.equals(t)))}like(t){return this.faces.length==t.faces.length&&this.faces.every(e=>t.faces.some(t=>e.likeFace(t)))}toString(){return`new BRep([\n${this.faces.join(",\n").replace(/^/gm,"\t")}], ${this.infiniteVolume})`}getConstructorParameters(){return[this.faces,this.infiniteVolume]}toSource(t=!0){return t&&this.generator||`new BRep([\n${this.faces.map(SCE).join(",\n").replace(/^/gm,"\t")}], ${this.infiniteVolume})`}reconstituteFaces(t,e,s,r,n){const i=new Map,o=[];for(const c of t){const t=c.getAllEdges().filter(t=>!e.get(t)),h=c.getAllEdges().mapFilter(t=>e.get(t)).concatenated(),u=s.get(c)||[];if(u.length||h.length){i.set(c,"partial");const e=[];function a(){return u.find(t=>!s.has(t))||h.find(t=>!s.has(t))||t.find(t=>!s.has(t))}const s=new Set;let l;for(;l=a();){const r=l,n=[];let i=0;do{s.add(l),n.push(l);const e=t.filter(t=>l.b.like(t.a)),i=h.filter(t=>l.b.like(t.a)),o=u.filter(t=>l.b.like(t.a)),a=e.concat(i,o);if(0==a.length)break;assert(0c.sce);const f=c.surface.normalP(l.b),p=calcNextEdgeIndex$$1(l,a,f);if(l=a[p],s.has(l))break;assert(l),assert(l!=r)}while(++i<400);400==i&&assert(!1,"too many"),n.length>1&&l==r&&e.push(n)}const f=BRep$$1.assembleFacesFromLoops(e,c.surface,c,n);r.push(...f);const p=f.flatMap(t=>t.getAllEdges());o.push(...t.filter(t=>p.includes(t)))}}for(;0!=o.length;){const t=o.pop();this.edgeFaces.get(t.getCanon()).forEach(t=>{i.has(t.face)||(i.set(t.face,"inside"),o.push.apply(o,t.face.getAllEdges()))})}r.push(...t.filter(t=>"inside"==i.get(t)))}static getLooseEdgeSegments(t,e){const s=new JavaMap;for(const[n,i]of t){if(0==i.length)continue;const t=e.get(n);i.sort((t,e)=>snap0(t.edgeT-e.edgeT)||0);let o,a=n.a,c=n.aDir,h=n.aT;function r(e,r,i){for(let e=0;e{t.faces.forEach(o=>{i.intersectFace(o,this,t,e,s,r,n)})}),Array.from(e.values()).concatenated()}shellCount(){const t=new Set;let e,s=0;for(;e=this.faces.find(e=>!t.has(e));){s++;const r=[e];for(;e=r.pop();)for(const s of e.getAllEdges())for(const{face:n}of this.edgeFaces.get(s.getCanon()))e===n||t.has(n)||(t.add(n),r.push(n))}return s}getAABB(){return AABB.forAABBs(this.faces.map(t=>t.getAABB()))}assertSanity(){if(NLA_DEBUG){this.buildAdjacencies();for(const[t,e]of this.edgeFaces)assert(e.length%2==0,()=>t+e.sce)}}buildAdjacencies(){if(this.edgeFaces)return this;this.edgeFaces=new JavaMap;for(const t of this.faces)for(const e of t.getAllEdges()){const s=e.getCanon(),r=t.surface.normalP(s.a),n=r.cross(s==e?e.aDir:e.bDir);mapPush(this.edgeFaces,s,{face:t,edge:e,normalAtCanonA:r,reversed:s!=e,inside:n,angle:0})}for(const[t,e]of this.edgeFaces){const s=e.find(t=>t.reversed);s?(e.forEach(e=>{e!=s&&(e.angle=s.inside.angleRelativeNormal(e.inside,t.aDir.unit()),e.angle<0&&(e.angle+=2*Math.PI))}),e.sort((t,e)=>snap(t.angle-e.angle,0))):console.warn("invalid brep")}return this}intersection(t,e,s,r,n){this.assertSanity(),t.assertSanity(),this.buildAdjacencies(),t.buildAdjacencies();const i=new Map,o=new JavaMap,a=new JavaMap,c=new JavaSet;for(const e of this.faces)for(const s of t.faces)e.intersectFace(s,this,t,i,o,a,c);for(const t of o.keys())assert(this.edgeFaces.get(t));for(const e of a.keys())assert(t.edgeFaces.get(e));const h=[];if(0==i.size&&0==o.size&&0==a.size){const e=t.containsPoint(this.faces[0].contour[0].a,!0)!==t.infiniteVolume,s=!e&&this.containsPoint(t.faces[0].contour[0].a)!==this.infiniteVolume;if(e||s){const[s,r]=e?[this,t]:[t,this];return s.infiniteVolume?r.infiniteVolume?r:BRep$$1.join([s,r]):r.infiniteVolume?BRep$$1.EMPTY:s}return this.infiniteVolume?t.infiniteVolume?BRep$$1.join([this,t]):BRep$$1.EMPTY:t.infiniteVolume?this:BRep$$1.EMPTY}if(e){const t=BRep$$1.getLooseEdgeSegments(o,this.edgeFaces);this.faces.map(e=>[e,Array.from(t.entries()).flatMap(([t,s])=>e.getAllEdges().some(e=>e.equals(t))?s:[])]);this.reconstituteFaces(this.faces,t,i,h,n)}if(s){const e=BRep$$1.getLooseEdgeSegments(a,t.edgeFaces);t.faces.map(t=>[t,Array.from(e.entries()).flatMap(([e,s])=>t.getAllEdges().some(t=>t.equals(e))?s:[])]);t.reconstituteFaces(t.faces,e,i,h,n)}return new BRep$$1(h,this.infiniteVolume&&t.infiniteVolume,r)}transform(t,e){let s;return this.vertexNames&&(s=new Map,this.vertexNames.forEach((r,n)=>s.set(t.transformPoint(n),r+e))),new BRep$$1(this.faces.map(e=>e.transform(t)),this.infiniteVolume,this.generator&&e&&this.generator+e,s)}transform4(t,e){let s;return this.vertexNames&&(s=new Map,this.vertexNames.forEach((r,n)=>s.set(t.transformPoint(n),r+e))),new BRep$$1(this.faces.map(e=>e.transform4(t)),this.infiniteVolume,this.generator&&e&&this.generator+e,s)}flipped(){return new BRep$$1(this.faces.map(t=>t.flipped()),!this.infiniteVolume,this.generator&&this.generator+".flipped()",this.vertexNames)}}function dotCurve$$1(t,e,s){let r=t.dot(e);return eq0(r)&&(r=t.dot(s)),assert(!eq0(r)),r}function dotCurve2$$1(t,e,s,r){assert(1==r||-1==r,r);const n=t.tangentAt(e).dot(s);if(!eq0(n))return r*n;if(t.ddt){const r=t.ddt(e).dot(s);if(!eq0(r))return r}const i=t.at(e).to(t.at(e+4*r*NLA_PRECISION)).dot(s);return assert(!(t instanceof L3$$1)),i}BRep$$1.EMPTY=new BRep$$1([],!1,"BRep.EMPTY",new Map).buildAdjacencies(),BRep$$1.R3=new BRep$$1([],!0,"BRep.R3",new Map).buildAdjacencies();const INSIDE$$1=0,OUTSIDE$$1=1,COPLANAR_SAME$$1=2,COPLANAR_OPPOSITE$$1=3,ALONG_EDGE_OR_PLANE$$1=4;function splitsVolumeEnclosingFaces$$1(t,e,s,r){assert(4==arguments.length),assert(e==e.getCanon());const n=t.edgeFaces.get(e);assertf(()=>n.length%2==0),assertf(()=>t.edgeFaces);const i=n[0],o=e.aDir.unit(),a=(i.inside.angleRelativeNormal(s,o)+2*Math.PI+NLA_PRECISION)%(2*Math.PI)-NLA_PRECISION,c=n.findIndex(t=>lt(a,t.angle)),h=n[-1==c?n.length-1:c-1];if(eq(h.angle,a)){return h.normalAtCanonA.dot(r)>0?COPLANAR_SAME$$1:COPLANAR_OPPOSITE$$1}return h.reversed?INSIDE$$1:OUTSIDE$$1}function splitsVolumeEnclosingFacesP$$1(t,e,s,r,n){assert(5==arguments.length),assert(e==e.getCanon()),assertf(()=>t.edgeFaces);const i=t.edgeFaces.get(e);assertf(()=>i.length%2==0);const o=e.tangentAt(e.curve.pointT(s)).unit(),a=t=>{const e=t.edge.getCanon()==t.edge?o:o.negated(),n=t.face.surface.normalP(s).cross(e);return-((r.angleRelativeNormal(n,o)+TAU+NLA_PRECISION)%TAU-NLA_PRECISION)},c=i.withMax(a);if(eq0(a(c))){return c.face.surface.normalP(s).dot(n)>0?COPLANAR_SAME$$1:COPLANAR_OPPOSITE$$1}return c.reversed?OUTSIDE$$1:INSIDE$$1}function splitsVolumeEnclosingFacesP2$$1(t,e,s,r,n,i,o){assert(e==e.getCanon()),assertf(()=>t.edgeFaces);const a=t.edgeFaces.get(e);assertf(()=>a.length%2==0);const c=e.tangentAt(e.curve.pointT(s)).unit();let h=r.tangentAt(n).times(i);h.isParallelTo(c)&&(h=(h=r.diff(n,1e-4*i/r.tangentAt(n).length()).rejectedFrom(c)).div(h.length()));let u=20,l=!1,f=OUTSIDE$$1;for(const t of a){const e=t.edge.getCanon()==t.edge?c:c.negated(),a=t.face.surface.normalP(s).cross(e),p=(h.angleRelativeNormal(a,c)+TAU+NLA_PRECISION)%TAU-NLA_PRECISION;if(eq0(p)){const e=t.face.surface.normalP(s);if(t.face.surface.containsCurve(r)){return e.dot(o)>0?COPLANAR_SAME$$1:COPLANAR_OPPOSITE$$1}const a=P3$$1.normalOnAnchor(c,s),p=t.face.surface.isCurvesWithPlane(a)[0],d=p.pointT(s),m=sign(p.tangentAt(d).dot(h)),$=1e-4,g=(p.at(d).to(p.at(d+i*m*$)).dot(e)-r.at(n).to(r.at(n+i*$)).dot(e))*(t.reversed?-1:1);g>0&&(!l||go instanceof PlaneFace$$1),o.getAllEdges().some(t=>t.a.like(e)))if(r.isParallelToPlane(o.surface.plane)){if(o.pointsToInside(e,s)!=PointVsFace.OUTSIDE)return ALONG_EDGE_OR_PLANE$$1}else{const t=L3$$1.fromPlanes(r,o.surface.plane),i=o.edgeISPsWithPlane(t,r);let a=0;for(;at.angle-e.angle),eq0(n[0].angle)?ALONG_EDGE_OR_PLANE$$1:n[0].out?OUTSIDE$$1:INSIDE$$1}function splitsVolumeEnclosingCone2$$1(t,e,s,r,n){assert(s.containsPoint(e));const i=t.faces.filter(t=>t.getAllEdges().some(t=>t.a.like(e)));for(let t=0;t4&&(!n(l.x,l.y)||!i(f.x,f.y)))break;u=u.plus(m)}return{points:o,tangents:a,st1s:c,st2s:h}}function followAlgorithm2d$$1(t,e,s=.5,r,n,i,o){assertNumbers(s,t(0,0)),assertVectors(e),o||(o=new V3(-t.y(e.x,e.y),t.x(e.x,e.y),0).toLength(s)),assertVectors(o);const a=[],c=[];assert(eq0(t(e.x,e.y),.01),"isZero(implicitCurve(startPoint.x, startPoint.y))",t(e.x,e.y));let h=0,u=e,l=o,f=!1;do{a.push(u),c.push(l);const o=u.plus(l);assert(o);const p=curvePointMF$$1(t,o),d=t.x(p.x,p.y),m=t.y(p.x,p.y),$=new V3(-m,d,0).toLength(s);if(assert(!u.equals(p)),l.dot($)<0){const e=newtonIterate2d(t.x,t.y,u.x,u.y);if(eq0(t(e.x,e.y))&&e.distanceTo(u)abs(s)){a.pop(),c.pop(),assert(a.last.distanceTo(e)<=abs(s));break}}else h>4&&u.distanceTo(e)<=abs(s)&&(f=!0);if(h>1&&!uvInAABB2$$1(r,u.x,u.y)){const e=figureOutBorderPoint(r,u,t);a.pop(),c.pop(),a.last.distanceTo(e)4&&!n(u.x,u.y))break;assert(eq0(t(p.x,p.y),2*NLA_PRECISION),u,p,o,t(p.x,p.y)),l=$,u=p}while(++h<1e3);return assert(h<1e3),{points:a,tangents:c}}function figureOutBorderPoint(t,e,s){if(e.xs(r,t),e.y,4,t=>s.y(r,t));if(uvInAABB2$$1(t,r,n))return new V3(r,n,0)}if(e.ys(t,r),e.x,4,t=>s.x(t,r));return assert(uvInAABB2$$1(t,n,r)),new V3(n,r,0)}throw new Error(e+" "+t)}function followAlgorithm2dAdjustable$$1(t,e,s=.5,r,n=e){assertNumbers(s,t(0,0)),assertVectors(e);const i=[],o=[];assert(eq0(t(e.x,e.y),.01),"isZero(implicitCurve(startPoint.x, startPoint.y))");let a=e,c=a,h=0;do{const e=t.x(a.x,a.y),s=t.y(a.x,a.y),r=t.xx(a.x,a.y),n=t.yy(a.x,a.y),h=t.xy(a.x,a.y),u=abs((Math.pow(s,2)*r-2*e*s*h+Math.pow(e,2)*n)/Math.pow(Math.pow(e,2)+Math.pow(s,2),2)),l=new V3(e,s,0).times(u),f=1/16/l.length(),p=new V3(-s,e,0).unit(),d=a.plus(p.times(f).plus(l.times(Math.pow(f,2)/2)));i.push(a),o.push(p),c=a;const m=curvePointMF$$1(t,d);m.equals(a)&&assertNever(),console.log(a.to(m).length()),assert(eq0(t((a=m).x,a.y)))}while(h++<1e3&&(h<4||c.distanceTo(n)>s)&&r(a.x,a.y));assert(1e3!=h);const u=h<4||c.distanceTo(n)>s?a:n,l=new V3(-t.y(u.x,u.y),t.x(u.x,u.y),0).toLength(s);return i.push(u),o.push(l),{points:i,tangents:o}}function intersectionICurveICurve$$1(t,e,s,r,n,i){assertNumbers(n,t(0,0),i(0,0)),assertVectors(e,s),assert(!r||r instanceof V3);const o=[];assert(eq0(t(e.x,e.y))),n=n||.5;let a=e,c=a,h=0;for(;h++<1e3&&(h<4||a.distanceTo(s)>1.1*n);){const e=t(a.x,a.y),s=(t(a.x+1e-5,a.y)-e)/1e-5,r=(t(a.x,a.y+1e-5)-e)/1e-5;let i=new V3(-r,s,0).toLength(n);a.minus(c).dot(i)<0&&(i=i.negated()),c=a,a=curvePointMF$$1(t,a.plus(i)),o.push(a)}return o}function intersectionICurveICurve2$$1(t,e,s){let r,n=e[0],i=s(n.x,n.y);const o=[];for(let a=0;a(s*s+r*r)*(s*s+r*r)-2*e*e*(s*s-r*r)-(Math.pow(t,4)-Math.pow(e,4))}var MathFunctionR2R;!function(t){t.forNerdamer=function(t,e=["x","y"]){const s=nerdamer(t),r=nerdamer.diff(s,e[0]),n=nerdamer.diff(s,e[1]),i=s.buildFunction(e);return i.x=r.buildFunction(e),i.y=n.buildFunction(e),i.xx=nerdamer.diff(r,e[0]).buildFunction(e),i.xy=nerdamer.diff(r,e[1]).buildFunction(e),i.yy=nerdamer.diff(n,e[1]).buildFunction(e),i},t.nerdamerToR2_R=function(t,e=["x","y"]){return t.buildFunction(e)},t.forFFxFy=function(t,e,s){return t.x=e,t.y=s,t}}(MathFunctionR2R||(MathFunctionR2R={}));const cas2$$1=cassini$$1(.9,1.02);function arrayLerp$$1(t,e,s){return 0==s%1?e[s]:t(e[Math.floor(s)],e[Math.ceil(s)],s%1)}function doNotSerialize$$1(t,e){(t.__SERIALIZATION_BLACKLIST||(t.__SERIALIZATION_BLACKLIST={}))[e]="no"}class ClassSerializer$$1{constructor(){this.CLASS_NAMES=new Map,this.NAME_CLASSES=new Map,this.addClass("Object",Object)}addClass(t,e){if(this.NAME_CLASSES.has(t))throw new Error(t);return this.NAME_CLASSES.set(t,e),this.CLASS_NAMES.set(e,t),this}addNamespace(t,e){return Object.keys(t).forEach(s=>{const r=t[s];"function"==typeof r&&r.name&&this.addClass((e?e+".":"")+s,r)}),this}setUpdater(t){return this.updater=t,this}serialize(t){return JSON.stringify(this.serializeObj(t))}serializeObj(t){const e=t=>{if(void 0!==t&&t.hasOwnProperty("constructor")&&this.CLASS_NAMES.has(t.constructor));else if(Array.isArray(t))if(r.has(t))n.has(t)||(n.set(t,i.length),i.push(t));else{r.add(t);for(let s=0;s{if("string"==typeof t||"number"==typeof t||"boolean"==typeof t||null===t)return t;if(void 0===t)return{"#REF":-1};if(t.hasOwnProperty("constructor")&&this.CLASS_NAMES.has(t.constructor))return{"#REF":this.CLASS_NAMES.get(t.constructor)};let i;if(e&&!r&&void 0!==(i=n.get(t)))return{"#REF":i};if(Array.isArray(t))return t.map(t=>s(t,e));if("object"==typeof t){if(t.getConstructorParameters)return{"#CONSTRUCTOR":this.CLASS_NAMES.get(t.constructor),"#ARGS":s(t.getConstructorParameters(),!1)};const r={};Object.prototype!==Object.getPrototypeOf(t)&&(r["#PROTO"]=s(Object.getPrototypeOf(t),e));for(const n of Object.keys(t))"__noxProxy"!=n&&"__noxTarget"!=n&&(t.__SERIALIZATION_BLACKLIST&&t.__SERIALIZATION_BLACKLIST[n]||(r[n]=s(t[n],e)));return r}throw new Error("?"+typeof t+t.toString())},r=new Set,n=new Map;let i=[];return n.set(t,0),i.push(t),e(t),i=i.map(t=>s(t,!0,!0))}unserialize(t){let e=0;const s=(t,i)=>{if(++e>100)throw new Error;if(t&&t.constructor===Array){i(t);for(let e=0;et[e]=s)}else if("object"==typeof t&&void 0!=t)if("#CONSTRUCTOR"in t){const e=t["#CONSTRUCTOR"],r=this.NAME_CLASSES.get(e);assert(r,e+" Missing ");let n=void 0;s(t["#ARGS"],t=>n=t),i(new r(...n))}else if("#REF"in t){const e=t["#REF"];"string"==typeof e?i(this.NAME_CLASSES.get(e).prototype):"number"==typeof e&&(-1==e?i(void 0):n[e]?i(n[e]):s(r[e],t=>i(n[e]=t)))}else{let e;"#PROTO"in t?s(t["#PROTO"],t=>{e=Object.create(t),i(e)}):i(e=t);const r=Object.keys(t);for(let n=0;ne[r[n]]=t);Object.defineProperty(e,"loadID",{value:getGlobalId$$1(),enumerable:!1,writable:!1}),this.updater&&this.updater(e)}else i(t);e--},r=JSON.parse(t),n=new Array(r.length);return s({"#REF":0},()=>{}),n[0]}}const fragmentShaderLighting="\n\tprecision highp float;\n\tuniform vec4 color;\n\tuniform vec3 camPos;\n\tvarying vec3 normal;\n\tvarying vec4 vPosition;\n\tvoid main() {\n\t\tvec3 normal1 = normalize(normal);\n\t\tvec3 lightPos = vec3(1000, 2000, 4000);\n\t\tvec3 lightDir = normalize(vPosition.xyz - lightPos);\n vec3 reflectionDirection = reflect(lightDir, normal1);\n vec3 eyeDirection = normalize(camPos.xyz-vPosition.xyz);\n float uMaterialShininess = 256.0;\n\t\tfloat specularLightWeighting = pow(max(dot(reflectionDirection, eyeDirection), 0.0), uMaterialShininess);\n\t\tfloat lightIntensity = 0.6 + 0.2 * max(0.0, -dot(lightDir, normal1)) + 0.2*specularLightWeighting;\n\t\tgl_FragColor = vec4(vec3(color) * lightIntensity, 1);\n\t}\n",vertexShaderLighting="\n\tuniform mat4 ts_ModelViewProjectionMatrix;\n\tuniform mat4 ts_ModelViewMatrix;\n\tattribute vec4 ts_Vertex;\n\tuniform mat3 ts_NormalMatrix;\n\tattribute vec3 ts_Normal;\n\tuniform vec4 color;\n\tvarying vec3 normal;\n\tvarying vec4 vPosition;\n\tvoid main() {\n\t\tgl_Position = ts_ModelViewProjectionMatrix * ts_Vertex;\n vPosition = ts_ModelViewMatrix * ts_Vertex;\n\t\tnormal = normalize(ts_NormalMatrix * ts_Normal);\n\t}\n",vertexShaderWaves="\n\tuniform mat4 ts_ModelViewProjectionMatrix;\n\tuniform mat4 ts_ModelViewMatrix;\n\tattribute vec4 ts_Vertex;\n\tuniform mat3 ts_NormalMatrix;\n\tattribute vec3 ts_Normal;\n\tuniform vec4 color;\n\tvarying vec3 normal;\n\tvarying vec4 vPosition;\n\tvoid main() {\n\t\tnormal = normalize(ts_NormalMatrix * ts_Normal);\n\t\tfloat offset = mod (((ts_Vertex.x + ts_Vertex.y + ts_Vertex.z) * 31.0), 20.0) - 10.0;\n\t\tvec4 modPos = ts_Vertex + vec4(normal * offset, 0);\n\t\tgl_Position = ts_ModelViewProjectionMatrix * modPos;\n vPosition = ts_ModelViewMatrix * modPos;\n\t}\n",vertexShaderBasic="\n\tuniform mat4 ts_ModelViewProjectionMatrix;\n\tattribute vec4 ts_Vertex;\n\tvoid main() {\n\t\tgl_Position = ts_ModelViewProjectionMatrix * ts_Vertex;\n\t}\n",vertexShaderColor="\n\tuniform mat4 ts_ModelViewProjectionMatrix;\n\tattribute vec4 ts_Vertex;\n\tattribute vec4 ts_Color;\n\tvarying vec4 fragColor;\n\tvoid main() {\n\t\tgl_Position = ts_ModelViewProjectionMatrix * ts_Vertex;\n\t\tfragColor = ts_Color;\n\t}\n",vertexShaderArc="\n\tuniform mat4 ts_ModelViewProjectionMatrix;\n\tattribute vec4 ts_Vertex;\n\tuniform float step, offset;\n\tuniform float radius, width;\n\tvoid main() {\n\t\tfloat r = radius;\n\t\tfloat t = offset + ts_Vertex.x * step;\n\t\tfloat pRadius = r - ts_Vertex.y * width;\n\t\tvec4 p = vec4(pRadius * cos(t), pRadius * sin(t), 0, 1);\n\t\tgl_Position = ts_ModelViewProjectionMatrix * p;\n}\n",vertexShaderConic3d="\n\tuniform mat4 ts_ModelViewProjectionMatrix;\n\tattribute vec4 ts_Vertex;\n\tuniform float startT, endT, scale;\n\tuniform vec3 center, f1, f2;\n\tuniform int mode;\n\tfloat sinh(float x) { return (exp(x) - exp(-x)) / 2.0; }\n\tfloat cosh(float x) { return (exp(x) + exp(-x)) / 2.0; }\n\tvoid main() {\n\t\tfloat t = startT + ts_Vertex.x * (endT - startT);\n\n\t\tvec3 normal = normalize(cross(f1, f2));\n\n\t\tvec3 p, tangent;\n\t\tif (0 == mode) { // ellipse\n\t\t\tp = center + f1 * cos(t) + f2 * sin(t);\n\t\t\ttangent = f1 * -sin(t) + f2 * cos(t);\n\t\t}\n\t\tif (1 == mode) { // parabola\n\t\t\tp = center + f1 * t + f2 * t * t;\n\t\t\ttangent = f1 + 2.0 * f2 * t;\n\t\t}\n\t\tif (2 == mode) { // hyperbola\n\t\t\tp = center + f1 * cosh(t) + f2 * sinh(t);\n\t\t\ttangent = f1 * sinh(t) + f2 * cosh(t);\n\t\t}\n\t\tvec3 outDir = normalize(cross(normal, tangent));\n\t\tvec3 p2 = p + scale * (outDir * ts_Vertex.y + normal * ts_Vertex.z);\n\t\tgl_Position = ts_ModelViewProjectionMatrix * vec4(p2, 1);\n\t}\n",vertexShaderNURBS="#version 300 es\n\tuniform mat4 ts_ModelViewProjectionMatrix;\n\tin vec4 ts_Vertex;\n\tuniform float startT, endT, scale;\n\tuniform vec4 points[32];\n\tuniform int pointCount, degree;\n\tuniform float knots[40];\n\tuniform vec3 normal;\n\tconst int MIN_DEGREE = 1;\n\tconst int MAX_DEGREE = 6;\n\t\n\tint tInterval(float t) {\n\t\tfor (int s = degree; s < 40 - 1 - degree; s++) {\n\t\t\tif (t >= knots[s] && t <= knots[s + 1]) {\n\t\t\t\treturn s;\n\t\t\t}\n\t\t}\n\t}\n\t\n\tvec4 stepp(int k, int i, vec4 dkMinus1iMinus1, vec4 dkMinus1i) {\n\t return dkMinus1i - dkMinus1iMinus1 * float(k) / (knots[i + degree - k] - knots[i - 1]);\n\t}\n\t\n\tvoid main() {\n\t\t// ts_Vertex.x is in [0, 1]\n\t\tfloat t = startT + ts_Vertex.x * (endT - startT);\n\t\t\n\t\tint s = tInterval(t);\n\t\t\n\t\tvec4 v[MAX_DEGREE + 1];\n\t\tfor (int i = 0; i < degree + 1; i++) {\n\t\t v[i] = points[s - degree + i];\n\t\t}\n\t\t\n\t\tvec4 pTangent4, ddt4 = vec4(0, 0, 1, 0);\n\t\tfor (int level = 0; level < degree; level++) {\n\t\t\tif (level == degree - 2) {\n\t\t\t\t// see https://www.globalspec.com/reference/61012/203279/10-8-derivatives\n\t\t\t\tvec4 a = v[degree];\n\t\t\t\tvec4 b = v[degree - 1];\n\t\t\t\tvec4 c = v[degree - 2];\n\t\t\t\tddt4 = stepp(degree, s + 1, stepp(degree - 1, s + 1, a, b), stepp(degree - 1, s, b, c));\n\t\t\t}\n\t\t\tif (level == degree - 1) {\n\t\t\t\tvec4 a = v[degree];\n\t\t\t\tvec4 b = v[degree - 1];\n\t\t\t\tpTangent4 = (b - a) * (float(degree) / (knots[s] - knots[s + 1]));\n\t\t\t}\n\t\t\tfor (int i = degree; i > level; i--) {\n\t\t\t\tfloat alpha = (t - knots[i + s - degree]) / (knots[i + s - level] - knots[i + s - degree]);\n\n\t\t\t\t// interpolate each component\n v[i] = (1.0 - alpha) * v[i - 1] + alpha * v[i];\n\t\t\t}\n\t\t}\n\t\t\n\t\tvec4 p4 = v[degree];\n\t\t\n\t\tvec3 p = p4.xyz / p4.w;\n\t\tvec3 pTangent = ((pTangent4.xyz * p4.w) - (p4.xyz * pTangent4.w)) / (p4.w * p4.w);\n\t\tvec3 ddt = (\n\t\t p4.xyz * (-p4.w * ddt4.w + 2.0 * pow(pTangent4.w, 2.0))\n\t\t + pTangent4.xyz * (-2.0 * p4.w * pTangent4.w) \n\t\t + ddt4.xyz * pow(p4.w, 2.0)\n ) / pow(p4.w, 3.0);\n\t\t\n\t\tvec3 outDir = normalize(cross(ddt, pTangent));\n\t\tvec3 correctNormal = normalize(cross(pTangent, outDir));\n\t\tvec3 p2 = p + scale * (outDir * ts_Vertex.y + correctNormal * ts_Vertex.z);\n\t\tgl_Position = ts_ModelViewProjectionMatrix * vec4(p2, 1);\n }\n",vertexShaderBezier="\n // calculates a bezier curve using ts_Vertex.x as the (t) parameter of the curve\n\tuniform mat4 ts_ModelViewProjectionMatrix;\n\tattribute vec4 ts_Vertex;\n\tuniform float width, startT, endT;\n\tuniform vec3 p0, p1, p2, p3;\n\tvoid main() {\n\t\t// ts_Vertex.x is in [0, 1]\n\t\tfloat t = startT + ts_Vertex.x * (endT - startT), s = 1.0 - t;\n\t\tfloat c0 = s * s * s, c1 = 3.0 * s * s * t, c2 = 3.0 * s * t * t, c3 = t * t * t;\n\t\tvec3 pPos = p0 * c0 + p1 * c1 + p2 * c2 + p3 * c3;\n\t\tfloat c01 = 3.0 * s * s, c12 = 6.0 * s * t, c23 = 3.0 * t * t;\n\t\tvec3 pTangent = (p1 - p0) * c01 + (p2 - p1) * c12 + (p3 - p2) * c23;\n\t\tvec3 pNormal = normalize(vec3(pTangent.y, -pTangent.x, 0));\n\t\tvec4 p = vec4(pPos - ts_Vertex.y * width * pNormal, 1);\n\t\tgl_Position = ts_ModelViewProjectionMatrix * p;\n\t}\n",vertexShaderBezier3d="\n precision highp float;\n // calculates a bezier curve using ts_Vertex.x as the (t) parameter of the curve\n\tuniform float scale, startT, endT;\n\tuniform vec3 ps[4];\n\tuniform vec3 p0, p1, p2, p3, normal;\n\tuniform mat4 ts_ModelViewProjectionMatrix;\n\tattribute vec4 ts_Vertex;\n\tvoid main() {\n\t\t// ts_Vertex.y is in [0, 1]\n\t\tvec3 p5 = ps[0];\n\t\tfloat t = startT * (1.0 - ts_Vertex.x) + endT * ts_Vertex.x, s = 1.0 - t;\n\t\tfloat c0 = s * s * s, \n\t\t c1 = 3.0 * s * s * t, \n\t\t c2 = 3.0 * s * t * t, c3 = t * t * t;\n\t\tvec3 p = (p0 * c0 + p1 * c1) + (p2 * c2 + p3 * c3);\n\t\tfloat c01 = 3.0 * s * s, \n\t\t c12 = 6.0 * s * t, \n\t\t c23 = 3.0 * t * t;\n\t\tvec3 pTangent = (p1 - p0) * c01 + (p2 - p1) * c12 + (p3 - p2) * c23;\n\t\tvec3 outDir = normalize(cross(normal, pTangent));\n\t\tvec3 correctNormal = normalize(cross(pTangent, outDir));\n\t\tvec3 p2 = p + scale * (outDir * ts_Vertex.y + correctNormal * ts_Vertex.z);\n\t\tgl_Position = ts_ModelViewProjectionMatrix * vec4(p2, 1);\n\t}\n",vertexShaderGeneric="\n\tuniform float scale;\n\tuniform mat4 ts_ModelViewProjectionMatrix;\n\tattribute vec4 ts_Vertex;\n\tuniform mat3 ts_NormalMatrix;\n\tattribute vec3 ts_Normal;\n\tvoid main() {\n\t\tvec3 normal = normalize(ts_NormalMatrix * ts_Normal);\n\t\tvec4 vertexPos = ts_Vertex + vec4(normal * scale, 0);\n\t\tgl_Position = ts_ModelViewProjectionMatrix * vertexPos;\n\t}\n",vertexShaderRing="\n\t#define M_PI 3.1415926535897932384626433832795\n\tuniform float step;\n\tuniform float innerRadius, outerRadius;\n\tattribute float index;\n\tuniform mat4 ts_ModelViewProjectionMatrix;\n\tattribute vec4 ts_Vertex;\n\tvoid main() {\n\t\tgl_Position = ts_ModelViewProjectionMatrix * vec4(index, index, index, 1);\n\t\tfloat id = atan(ts_Vertex.x, ts_Vertex.y) / M_PI * 32.0;\n\t\tfloat radius = mod(id, 2.0) < 1.0 ? outerRadius : innerRadius;\n\t\tgl_Position = ts_ModelViewProjectionMatrix * vec4(radius * cos(index * step), radius * sin(index * step), 0, 1);\n\t}\n",fragmentShaderColor="\n\tprecision highp float;\n\tuniform vec4 color;\n\tvoid main() {\n\t\tgl_FragColor = color;\n\t}\n",fragmentShaderColor3="#version 300 es\n\tprecision highp float;\n\tuniform vec4 color;\n\tout vec4 fragColor;\n\tvoid main() {\n\t\tfragColor = color;\n\t}\n",fragmentShaderVaryingColor="\n\tprecision highp float;\n\tvarying vec4 fragColor;\n\tvoid main() {\n\t\tgl_FragColor = fragColor;\n\t}\n",fragmentShaderColorHighlight="\n\tprecision highp float;\n\tuniform vec4 color;\n\tvoid main() {\n\t\tfloat diagonal = (gl_FragCoord.x + 2.0 * gl_FragCoord.y);\n\t\tif (mod(diagonal, 50.0) > 40.0) { // mod(diagonal, 2.0) > 1.0\n\t\t\tdiscard;\n\t\t\t//gl_FragColor = color + vec4(0.2,0.2,0.2,0);\n\t\t} else {\n\t\t\tgl_FragColor = color - vec4(0.2,0.2,0.2,0);\n\t\t}\n\t}\n",vertexShaderTexture="\n\tvarying vec2 texturePos;\n\tattribute vec4 ts_Vertex;\n\tuniform mat4 ts_ModelViewProjectionMatrix;\n\tvoid main() {\n\t\ttexturePos = ts_Vertex.xy;\n\t\tgl_Position = ts_ModelViewProjectionMatrix * ts_Vertex;\n\t}\n",fragmentShaderTextureColor="\n\tprecision highp float;\n\tvarying vec2 texturePos;\n\tuniform vec4 color;\n\tuniform sampler2D texture;\n\tvoid main() {\n\t\tgl_FragColor = texture2D(texture, texturePos) * color;\n\t}\n";function parseGetParams$$1(t){const e={};return t.split("&").forEach(function(t){const s=t.indexOf("=");-1==s?e[t]=t:e[t.substr(0,s)]=decodeURI(t.substr(s+1))}),e}const COLORS$$1={RD_FILL:chroma("#9EDBF9"),RD_STROKE:chroma("#77B0E0"),TS_FILL:chroma("#D19FE3"),TS_STROKE:chroma("#A76BC2"),PP_FILL:chroma("#F3B6CF"),PP_STROKE:chroma("#EB81B4")};class BREPGLContext$$1{constructor(t){this.cachedMeshes=new WeakMap,this.shaders=initShaders$$1(t),initMeshes$$1(this.meshes={},t)}static create(t){return addOwnProperties(t,BREPGLContext$$1.prototype),addOwnProperties(t,new BREPGLContext$$1(t)),t}drawPoint(t,e=GL_COLOR_BLACK,s=5){this.pushMatrix(),this.translate(t),this.scale(s/2,s/2,s/2),this.shaders.singleColor.uniforms({color:e}).draw(this.meshes.sphere1),this.popMatrix()}drawEdge(t,e=GL_COLOR_BLACK,s=2){CURVE_PAINTERS$$1[t.curve.constructor.name](this,t.curve,e,t.minT,t.maxT,s)}drawCurve(t,e=GL_COLOR_BLACK,s=2,r,n){CURVE_PAINTERS$$1[t.constructor.name](this,t,e,r,n,s)}drawVector(t,e,s=GL_COLOR_BLACK,r=1){if(t.likeO())return;this.pushMatrix();const n=4*r;if(n>t.length())return;const i=t.getPerpendicular().unit();this.multMatrix(M4.forSys(t.unit(),i,t.cross(i).unit(),e)),this.scale(t.length()-n,r/2,r/2),this.shaders.singleColor.uniforms({color:s}).draw(this.meshes.vectorShaft),this.scale(1/(t.length()-n),1,1),this.translate(t.length()-n,0,0),this.scale(n/2,1,1),this.shaders.singleColor.draw(this.meshes.vectorHead),this.popMatrix()}drawVectors(t,e){this.drawVector(V3.X,V3.O,chroma("red").gl(),e),this.drawVector(V3.Y,V3.O,chroma("green").gl(),e),this.drawVector(V3.Z,V3.O,chroma("blue").gl(),e),t.forEach(t=>this.drawVector(t.v,t.anchor,t.color,e))}drawPlane(t,e,s=!1){this.pushMatrix(),this.multMatrix(M4.forSys(t.right,t.up,t.normal1)),this.translate(t.uMin,t.vMin,t.w),this.scale(t.uMax-t.uMin,t.vMax-t.vMin,1);const r=s?this.meshes.xyDottedLinePlane:this.meshes.xyLinePlane;this.shaders.singleColor.uniforms({color:e}).draw(r,this.LINES),this.popMatrix()}drawBox(t,e){this.pushMatrix(),this.multMatrix(t),e?this.shaders.singleColor.uniforms({color:e}).draw(this.meshes.cube,this.LINES):this.shaders.multiColor.draw(this.meshes.cube,this.LINES),this.popMatrix()}}function conicPainter(t,e,s,r,n,i,o=2){e.shaders.ellipse3d.uniforms({f1:s.f1,f2:s.f2,center:s.center,color:r,startT:n,endT:i,scale:o,mode:t}).draw(e.meshes.pipe)}const CURVE_PAINTERS$$1={[EllipseCurve$$1.name]:conicPainter.bind(void 0,0),[ParabolaCurve$$1.name]:conicPainter.bind(void 0,1),[HyperbolaCurve$$1.name]:conicPainter.bind(void 0,2),[ImplicitCurve$$1.name](t,e,s,r,n,i=2){let o=t.cachedMeshes.get(e);o||(o=(new Mesh).addIndexBuffer("TRIANGLES").addVertexBuffer("normals","ts_Normal"),e.addToMesh(o,4),o.compile(),t.cachedMeshes.set(e,o));const a=ceil(r),c=floor(n);if(a<=c){const h=24;if(t.shaders.generic3d.uniforms({color:s,scale:i}).draw(o,t.TRIANGLES,a*h,(floor(n)-a)*h),r%1!=0){const n=e.at(r);t.pushMatrix();const c=M4.forSys(n.to(e.points[a]),o.normals[4*a].toLength(i),o.normals[4*a+1].toLength(i),n);t.multMatrix(c),t.shaders.singleColor.uniforms({color:s}).draw(t.meshes.pipeSegmentForICurve),console.log(t.meshes.pipeSegmentForICurve),t.popMatrix()}if(n%1!=0){const r=e.at(n);t.pushMatrix();const a=M4.forSys(e.points[c].to(r),o.normals[4*c].toLength(i),o.normals[4*c+1].toLength(i),e.points[c]);t.multMatrix(a),t.shaders.singleColor.uniforms({color:s}).draw(t.meshes.pipeSegmentForICurve),t.popMatrix()}}else{const o=e.at(r),a=e.at(n);t.pushMatrix();const c=o.to(a),h=c.getPerpendicular().toLength(i),u=c.cross(h).toLength(i),l=M4.forSys(c,h,u,o);t.multMatrix(l),t.shaders.singleColor.uniforms({color:s}).draw(t.meshes.pipeSegmentForICurve),t.popMatrix()}},[BezierCurve$$1.name](t,e,s,r,n,i=2,o=V3.Z){t.shaders.bezier3d.uniforms({p0:e.p0,p1:e.p1,p2:e.p2,p3:e.p3,color:s,startT:r,endT:n,scale:i,normal:o}).draw(t.meshes.pipe)},[NURBS$$1.name](t,e,s,r,n,i=2,o=V3.Z){t.shaders.nurbs.uniforms({"points[0]":Vector.pack(e.points),degree:e.degree,"knots[0]":e.knots,color:s,startT:r,endT:n,scale:i,normal:o}).draw(t.meshes.pipe)},[L3$$1.name](t,e,s,r,n,i=2,o=V3.Z){t.pushMatrix();const a=e.at(r),c=e.at(n).minus(a),h=c.getPerpendicular().unit(),u=M4.forSys(c,h,c.cross(h).unit(),a);t.multMatrix(u),t.scale(1,i,i),t.shaders.singleColor.uniforms({color:s}).draw(t.meshes.pipe),t.popMatrix()}};function initMeshes$$1(t,e){e.makeCurrent(),t.cube=(()=>{const t=B2T.box().toMesh().addVertexBuffer("colors","ts_Color");return t.colors=t.vertices.map(t=>[t.x,t.y,t.z,1].map(t=>.9*t)),t.compile(),t})(),t.sphere1=Mesh.sphere(2),t.segment=Mesh.plane({startY:-.5,height:1,detailX:128}),t.text=Mesh.plane(),t.vector=Mesh.rotation([V3.O,V(0,.05,0),V(.8,.05),V(.8,.1),V(1,0)],L3$$1.X,TAU,16,!0),t.vectorShaft=Mesh.rotation([V3.O,V3.Y,V3.XY],L3$$1.X,TAU,8,!0),t.vectorHead=Mesh.rotation([V3.Y,V(0,2,0),V(2,0,0)],L3$$1.X,TAU,8,!0),t.pipe=Mesh.rotation(arrayFromFunction(512,(t,e)=>new V3(t/(e-1),-.5,0)),L3$$1.X,TAU,8,!0),t.xyLinePlane=Mesh.plane(),t.xyDottedLinePlane=makeDottedLinePlane(),t.pipeSegmentForICurve=Mesh.offsetVertices(M4.rotateY(90*DEG).transformedPoints(arrayFromFunction(4,t=>V3.polar(1,TAU*t/4))),V3.X,!0)}function initShaders$$1(t){return t.makeCurrent(),{singleColor:Shader.create(vertexShaderBasic,fragmentShaderColor),multiColor:Shader.create(vertexShaderColor,fragmentShaderVaryingColor),singleColorHighlight:Shader.create(vertexShaderBasic,fragmentShaderColorHighlight),textureColor:Shader.create(vertexShaderTexture,fragmentShaderTextureColor),arc:Shader.create(vertexShaderRing,fragmentShaderColor),arc2:Shader.create(vertexShaderArc,fragmentShaderColor),ellipse3d:Shader.create(vertexShaderConic3d,fragmentShaderColor),generic3d:Shader.create(vertexShaderGeneric,fragmentShaderColor),bezier3d:Shader.create(vertexShaderBezier3d,fragmentShaderColor),nurbs:Shader.create(vertexShaderNURBS,fragmentShaderColor3),bezier:Shader.create(vertexShaderBezier,fragmentShaderColor),lighting:Shader.create(vertexShaderLighting,fragmentShaderLighting),waves:Shader.create(vertexShaderWaves,fragmentShaderLighting)}}function makeDottedLinePlane(t=128){const e=(new Mesh).addIndexBuffer("LINES"),s=arrayFromFunction(t,e=>new V3(e/t,0,0));return e.vertices.push(...s),e.vertices.push(...M4.forSys(V3.Y,V3.O,V3.O,V3.X).transformedPoints(s)),e.vertices.push(...M4.forSys(V3.X.negated(),V3.O,V3.O,new V3(1,1,0)).transformedPoints(s)),e.vertices.push(...M4.forSys(V3.Y.negated(),V3.O,V3.O,V3.Y).transformedPoints(s)),e.LINES=arrayFromFunction(4*t,e=>e-(e>=2*t?1:0)),e.compile(),e}function initNavigationEvents$$1(t,e,s){const r=t.canvas;let n=V3.O;r.addEventListener("mousemove",r=>{const i=V(r.pageX,r.pageY),o=n.to(i);if(4&r.buttons){const r=V(2*-o.x/t.canvas.width,2*o.y/t.canvas.height),n=t.projectionMatrix.inversed().transformVector(r);e.pos=e.pos.plus(n),e.focus=e.focus.plus(n),setupCamera$$1(e,t),s()}if(2&r.buttons){const r=-o.x/6*DEG,n=-o.y/6*DEG;let i=M4.rotateLine(e.focus,e.up,r);const a=e.up.cross(e.pos.minus(e.focus));i=i.times(M4.rotateLine(e.focus,a,n)),e.pos=i.transformPoint(e.pos),e.up=i.transformVector(e.up),setupCamera$$1(e,t),s()}n=i}),r.addEventListener("wheel",r=>{const n=2*-sign(r.deltaY);e.zoomFactor*=pow(.9,-n);const i=getPosOnTarget$$1(r),o=V(2*i.x/t.canvas.offsetWidth-1,2*-i.y/t.canvas.offsetHeight+1,0),a=o.times(1-1/pow(.9,-n)),c=t.projectionMatrix.inversed(),h=c.transformVector(a);e.pos=e.pos.plus(h),e.focus=e.focus.plus(h);const u=c.transformPoint(o),l=M4.rotateLine(u,e.pos.to(e.focus),10*-sign(r.deltaX)*DEG);e.up=l.transformVector(e.up),e.pos=l.transformPoint(e.pos),e.focus=l.transformPoint(e.focus),setupCamera$$1(e,t),s(),r.preventDefault()})}function getMouseLine$$1(t,e){const s=V(2*t.x/e.canvas.width-1,2*-t.y/e.canvas.height+1,0),r=V(2*t.x/e.canvas.width-1,2*-t.y/e.canvas.height+1,1),n=e.projectionMatrix.inversed(),i=n.transformPoint(s),o=n.transformPoint(r).minus(i);return L3$$1.anchorDirection(i,o)}function getPosOnTarget$$1(t){const e=t.target.getBoundingClientRect();return{x:t.clientX-e.left,y:t.clientY-e.top}}function setupCamera$$1(t,e,s=!1){const{pos:r,focus:n,up:i,zoomFactor:o}=t;e.matrixMode(e.PROJECTION),e.loadIdentity();const a=e.canvas.width/2/o,c=e.canvas.height/2/o;e.ortho(-a,a,-c,c,-1e4,1e4),e.lookAt(r,n,i),e.matrixMode(e.MODELVIEW),!s&&cameraChangeListeners$$1.forEach(e=>e(t))}CURVE_PAINTERS$$1[PICurve$$1.name]=CURVE_PAINTERS$$1[ImplicitCurve$$1.name],CURVE_PAINTERS$$1[PPCurve$$1.name]=CURVE_PAINTERS$$1[ImplicitCurve$$1.name];const cameraChangeListeners$$1=[],SHADERS_TYPE_VAR$$1=!1;export{Curve$$1 as Curve,breakDownPPCurves$$1 as breakDownPPCurves,AABB2$$1 as AABB2,uvInAABB2$$1 as uvInAABB2,curvePoint$$1 as curvePoint,curvePointMF$$1 as curvePointMF,XiEtaCurve$$1 as XiEtaCurve,parabola4Projection$$1 as parabola4Projection,ImplicitCurve$$1 as ImplicitCurve,surfaceIsICurveIsInfosWithLine$$1 as surfaceIsICurveIsInfosWithLine,BezierCurve$$1 as BezierCurve,HyperbolaCurve$$1 as HyperbolaCurve,L3$$1 as L3,PICurve$$1 as PICurve,PPCurve$$1 as PPCurve,ParabolaCurve$$1 as ParabolaCurve,EllipseCurve$$1 as EllipseCurve,NURBS$$1 as NURBS,P3$$1 as P3,Surface$$1 as Surface,PointVsFace,ImplicitSurface$$1 as ImplicitSurface,ParametricSurface$$1 as ParametricSurface,ConicSurface$$1 as ConicSurface,ProjectedCurveSurface$$1 as ProjectedCurveSurface,RotatedCurveSurface$$1 as RotatedCurveSurface,getExtremePointsHelper$$1 as getExtremePointsHelper,CylinderSurface$$1 as CylinderSurface,EllipsoidSurface$$1 as EllipsoidSurface,PlaneSurface$$1 as PlaneSurface,PointProjectedSurface$$1 as PointProjectedSurface,NURBSSurface$$1 as NURBSSurface,ZDirVolumeVisitor$$1 as ZDirVolumeVisitor,glqV3$$1 as glqV3,glqArray$$1 as glqArray,CalculateAreaVisitor$$1 as CalculateAreaVisitor,projectCurve$$1 as projectCurve,projectPointCurve$$1 as projectPointCurve,rotateCurve$$1 as rotateCurve,B2T,CustomPlane$$1 as CustomPlane,Edge$$1 as Edge,PCurveEdge$$1 as PCurveEdge,StraightEdge$$1 as StraightEdge,FaceInfoFactory,Face$$1 as Face,PlaneFace$$1 as PlaneFace,RotationFace$$1 as RotationFace,EPS$$1 as EPS,getGlobalId$$1 as getGlobalId,addLikeSurfaceFaces$$1 as addLikeSurfaceFaces,assembleFaceFromLooseEdges$$1 as assembleFaceFromLooseEdges,calcNextEdgeIndex$$1 as calcNextEdgeIndex,BRep$$1 as BRep,dotCurve$$1 as dotCurve,dotCurve2$$1 as dotCurve2,INSIDE$$1 as INSIDE,OUTSIDE$$1 as OUTSIDE,COPLANAR_SAME$$1 as COPLANAR_SAME,COPLANAR_OPPOSITE$$1 as COPLANAR_OPPOSITE,ALONG_EDGE_OR_PLANE$$1 as ALONG_EDGE_OR_PLANE,splitsVolumeEnclosingFaces$$1 as splitsVolumeEnclosingFaces,splitsVolumeEnclosingFacesP$$1 as splitsVolumeEnclosingFacesP,splitsVolumeEnclosingFacesP2$$1 as splitsVolumeEnclosingFacesP2,splitsVolumeEnclosingCone$$1 as splitsVolumeEnclosingCone,splitsVolumeEnclosingCone2$$1 as splitsVolumeEnclosingCone2,fff$$1 as fff,triangulateVertices$$1 as triangulateVertices,intersectionUnitCircleLine$$1 as intersectionUnitCircleLine,intersectionUnitCircleLine2$$1 as intersectionUnitCircleLine2,intersectionCircleLine$$1 as intersectionCircleLine,intersectionUnitHyperbolaLine$$1 as intersectionUnitHyperbolaLine,curvePointPP$$1 as curvePointPP,followAlgorithmPP$$1 as followAlgorithmPP,followAlgorithm2d$$1 as followAlgorithm2d,followAlgorithm2dAdjustable$$1 as followAlgorithm2dAdjustable,intersectionICurveICurve$$1 as intersectionICurveICurve,intersectionICurveICurve2$$1 as intersectionICurveICurve2,cassini$$1 as cassini,MathFunctionR2R,cas2$$1 as cas2,arrayLerp$$1 as arrayLerp,doNotSerialize$$1 as doNotSerialize,ClassSerializer$$1 as ClassSerializer,parseGetParams$$1 as parseGetParams,COLORS$$1 as COLORS,BREPGLContext$$1 as BREPGLContext,CURVE_PAINTERS$$1 as CURVE_PAINTERS,initMeshes$$1 as initMeshes,initShaders$$1 as initShaders,initNavigationEvents$$1 as initNavigationEvents,getMouseLine$$1 as getMouseLine,getPosOnTarget$$1 as getPosOnTarget,setupCamera$$1 as setupCamera,cameraChangeListeners$$1 as cameraChangeListeners,SHADERS_TYPE_VAR$$1 as SHADERS_TYPE_VAR}; \ No newline at end of file diff --git a/dist/demo.js b/dist/demo.js deleted file mode 100644 index 7f0596d..0000000 --- a/dist/demo.js +++ /dev/null @@ -1,76928 +0,0 @@ - -(function(l, r) { if (l.getElementById('livereloadscript')) return; r = l.createElement('script'); r.async = 1; r.src = '//' + (window.location.host || 'localhost').split(':')[0] + ':35729/livereload.js?snipver=1'; r.id = 'livereloadscript'; l.getElementsByTagName('head')[0].appendChild(r) })(window.document); -var demo = (function (exports, hljs) { - 'use strict'; - - /*! ***************************************************************************** - Copyright (c) Microsoft Corporation. - - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH - REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY - AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, - INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM - LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR - OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - PERFORMANCE OF THIS SOFTWARE. - ***************************************************************************** */ - - function __rest(s, e) { - var t = {}; - for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) - t[p] = s[p]; - if (s != null && typeof Object.getOwnPropertySymbols === "function") - for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) { - if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) - t[p[i]] = s[p[i]]; - } - return t; - } - - function __awaiter(thisArg, _arguments, P, generator) { - function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); - } - - /** - * @license - * - * js - JavaScript library for color conversions - * - * Copyright (c) 2011-2017, Gregor Aisch - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * 3. The name Gregor Aisch may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL GREGOR AISCH OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - // tslint:disable:no-unnecessary-qualifier - const { abs, atan2, cos, floor, log, min, max, round, sign, sin, sqrt, cbrt, PI, hypot } = Math; - function lerp(a, b, f) { - return a + (b - a) * f; - } - function lerpInv(a, b, f) { - return (f - a) / (b - a); - } - function clamp(x, min = 0, max = 1) { - return x < min ? min : x > max ? max : x; - } - function newtonIterate1d(f, xStart, max_steps, eps = 1e-8) { - let x = xStart, fx; - while (max_steps-- && abs((fx = f(x))) > eps) { - const dfdx = (f(x + eps) - fx) / eps; - console.log("fx / dfdx", fx / dfdx, "fx", fx, "x", x); - x = x - fx / dfdx; - } - return x; - } - function bisect(f, a, b, steps) { - //assert(a < b) - let fA = f(a); - // let fB = f(b) - //assert(fA * fB < 0) - while (steps--) { - const c = (a + b) / 2; - const fC = f(c); - // console.log("fC", fC, "c", c) - if (sign(fA) == sign(fC)) { - a = c; - fA = fC; - } - else { - b = c; - // fB = fC - } - } - //assert(a <= (b + a) / 2) - //assert(b >= (b + a) / 2) - return (a + b) / 2; - } - const DEG2RAD = PI / 180; - const RAD2DEG = 180 / PI; - function color(...args) { - if (args[0] instanceof Color) { - return args[0]; - } - if (args.length > 1 && "string" == typeof args[args.length - 1]) { - return guess(args.slice(0, args.length - 1), args[args.length - 1]); - } - else if (Array.isArray(args[0])) { - return guess(args[0]); - } - else { - return guess(args); - } - } - class Color { - /** @internal */ - constructor(r, g, b, a = 1) { - this.r = r; - this.g = g; - this.b = b; - this.a = a; - } - // public shade() { - // const shades: [string, string, number][] = [ - // ["ff0000", "red"], - // ["ffa500", "orange"], - // ["ffff00", "yellow"], - // ["008000", "green"], - // ["0000ff", "blue"], - // ["ee82ee", "violet"], - // ["a52a2a", "brown"], - // ["000000", "black"], - // ["808080", "grey"], - // ["ffffff", "white"], - // ] as any - // function angleDiff(a: number, b: number) { - // const d = (a - b) % 360 - // if (d > 180) return d - 360 - // if (d < -180) return d + 360 - // return d - // } - // shades.forEach(arr => arr.push(color(arr[0]).hsl()[0])) - // const [h, s, l] = this.hsl() - // if (l > 0.9) return "white" - // if (l > 0.8 && s < 0.2) return "white" - // if (s < 0.1) return "grey" - // if (s < 0.4 && h > 0 && h < 48) return "brown" - // const distanceInXYZ: { [hue: number]: number } = { 0: 0 } - // for (let i = 60; i <= 360; i += 60) { - // distanceInXYZ[i] = - // distanceInXYZ[i - 60] + distance(hsl(i - 60, 1, 0.5), hsl(i, 1, 0.5), "xyz") - // } - // // console.log(distanceInXYZ) - // const shadeEnds: { [hue: number]: number } = { - // 0: 9, - // 38: 48, - // 60: 65, - // 120: 165, - // 240: 245, - // 300: 338, - // 360: 369, - // } - // const getColorDistanceAlongXYZHue = (hueDegrees: number) => { - // const base = hueDegrees - (hueDegrees % 60) - // return ( - // distanceInXYZ[base] + distance(hsl(base, 1, 0.5), hsl(hueDegrees, 1, 0.5), "xyz") - // ) - // } - // const colorXYZD = getColorDistanceAlongXYZHue(this.hsl()[0]) - // const md = distanceInXYZ[360] - // const shadeHue = - // (Object.keys(shadeEnds) as any[]).find(shadeHue => shadeEnds[shadeHue | 0] >= this.hsl()[0])! % 360 - // return shades.find(([_hex, _name, _hue]) => (_hue | 0) === shadeHue)![1] - // // process.exit() - // return withMax(shades, ([_hex, _name, _hue]) => { - // return -abs(angleDiff(this.hsl()[0], _hue)) - // })[1] - // return withMax(shades, ([_hex, _name, _hue]) => { - // const [thisL, thisA, thisB] = this.lab() - // const [L, A, B] = color(_hex).lab() - // return -hypot(thisL - L, thisA - A, thisB - B) - // })[1] - // } - /** - * @see [[mix]] - */ - mix(col2, f, m = "rgb") { - return mix(this, col2, f, m); - } - rgb(doRound = true, clamp_ = true) { - const f = (t) => { - if (doRound) - t = round(t); - if (clamp_) - t = clamp(t, 0, 255); - return t; - }; - const { r, g, b } = this; - return [f(r), f(g), f(b)]; - } - rgba(doRound = true, clamp_ = true) { - const f = (t) => { - if (doRound) - t = round(t); - if (clamp_) - t = clamp(t, 0, 255); - return t; - }; - const { r, g, b, a } = this; - return [f(r), f(g), f(b), a]; - } - /** - * Return a hex-string representation of this color. - * - * @param mode - * @see #num for a hex-number representation. - * @example chroma.color('yellow').alpha(0.7).hex() - * @example chroma.color('yellow').alpha(0.7).hex('rgba') - * @example chroma.color('yellow').alpha(0.7).hex('argb') - */ - hex(mode = "rgb") { - const { r, g, b, a } = this; - return rgb2hex(r, g, b, a, mode); - } - /** - * Returns the [HSL] representation of this color. hue will always be in [0;360). Values are never NaN. - * - * @example chroma.color('purple').hsl() - */ - hsl() { - const { r, g, b } = this; - return rgb2hsl(r, g, b); - } - /** - * Returns the [HSL] representation of this color. hue will always be in [0;360). Values are never NaN. - * - * @example chroma.color('purple').hsv() - */ - hsv() { - const { r, g, b } = this; - return rgb2hsv(r, g, b); - } - /** - * Returns the [HSL] representation of this color. hue will always be in [0;360). Values are never NaN. - * - * @example chroma.color('purple').hcg() - */ - hcg() { - const { r, g, b } = this; - return rgb2hcg(r, g, b); - } - /** - * Returns a CSS `rgb(...)` or `hsl(...)` string representation that can be used as CSS-color definition. The alpha - * value is not output if it 1. - * @example chroma.color('teal').css() // == "rgb(0,128,128)" - * @example chroma.color('teal').alpha(0.5).css() // == "rgba(0,128,128,0.5)" - * @example chroma.color('teal').css('hsl') // == "hsl(180,100%,25.1%)" - */ - css(mode = "rgb") { - if ("rgb" == mode) { - const { r, g, b, a } = this; - return rgb2css(r, g, b, a); - } - else if ("hsl" == mode) { - return hsl2css(this.hsl(), this.alpha()); - } - else { - throw new Error(); - } - } - name(closest = false) { - const thisNum = this.num(); - const name = Object.keys(w3cx11).find((name) => w3cx11[name] == thisNum); - if (!name && closest) { - const [thisLStar, thisAStar, thisBStar] = this.lab(); - return withMax(Object.keys(w3cx11), (name) => { - const [lStar, aStar, bStar] = num(w3cx11[name]).lab(); - return -hypot(thisLStar - lStar, thisAStar - aStar, thisBStar - bStar); - }); - } - return name; - } - /** - * Get the [CMYK](#CMYK) representation of this color. - * - * @example chroma.color('red').cmyk() - */ - cmyk() { - const { r, g, b } = this; - return rgb2cmyk(r, g, b); - } - /** - * Returns the [GL] representation of this color. - * @example chroma.color('33cc00').gl() - */ - gl() { - const { r, g, b, a } = this; - return [r / 255, g / 255, b / 255, a]; - } - luminance(lum1) { - const { r, g, b, a } = this; - const [, Y] = rgb2xyz(r, g, b); - if (undefined === lum1) { - return Y; - } - const inverseLerp = (a, b, val) => (val - a) / (b - a); - if (lum1 > Y) { - // lerp to white - return mix(this, white, inverseLerp(Y, 1, lum1), "xyz").alpha(a); - } - else { - // lerp to black - return mix(black, this, inverseLerp(0, Y, lum1), "xyz").alpha(a); - } - } - /** - * Get color temperature of this color in Kelvin. This only makes sense for colors close to those output by - * kelvin - * - * @example [c = chroma.color('#ff3300'), c.temperature()] - * @example [c = chroma.color('#ffe3cd'), c.temperature()] - * @example [c = chroma.color('#b3ccff'), c.temperature()] - */ - temperature() { - const { r, g, b } = this; - return rgb2kelvin(r, g, b); - } - /** - * Returns a new [Color] with a channel changed. - * @example chroma.color('skyblue').set('hsl.h', 0) // change hue to 0 deg (=red) - * @example chroma.color('hotpink').set('lch.c', 30) // set chromaticity to 30 - * @example chroma.color('orangered').set('lab.l', x => x / 2) // half Lab lightness - * @example chroma.color('darkseagreen').set('lch.c', x => x * 2) // double Lch saturation - */ - set(modeAndChannel, value) { - const [mode, channel] = modeAndChannel.split("."); - const src = this[mode](); - const i = mode.indexOf(channel); - if (-1 == i) - throw new Error("invalid channel"); - src[i] = "number" == typeof value ? value : value(src[i]); - return color(src, mode).alpha(this.a); - } - /** - * Returns whether this color is outside the RGB color cube and will be clipped/clamped when calling .rgb() - * - * @example [c = chroma.lch( 20, 40, 50), c.clipped()] - * @example [c = chroma.lch( 40, 40, 50), c.clipped()] - * @example [c = chroma.lch( 60, 40, 50), c.clipped()] - * @example [c = chroma.lch( 80, 40, 50), c.clipped()] - * @example [c = chroma.lch(100, 40, 50), c.clipped()] - */ - clipped() { - const { r, g, b } = this; - return !(0 <= r && r <= 255 && 0 <= g && g <= 255 && 0 <= b && b <= 255); - } - /** - * Returns black or white, whichever has the highest contrast to `this`. - * In the readme you should see the result of this. - * - * @example chroma.color('red') - * @example chroma.color('yellow') - */ - textColor() { - return this.luminance() > 0.5 ? black : white; - } - alpha(alpha1) { - if (undefined === alpha1) { - return this.a; - } - const { r, g, b } = this; - return rgb(r, g, b, alpha1); - } - darker(amount = 1) { - const [l, a, b] = this.lab(); - return lab(l - LAB_Kn * amount, a, b, this.alpha()); - } - /** - * - * @param amount - * @example chroma.color('hotpink') - * @example chroma.color('hotpink').brighter() - * @example chroma.color('hotpink').brighter(2) - * @example chroma.color('hotpink').brighter(3) - */ - brighter(amount = 1) { - return this.darker(-amount); - } - /** - * Returns a new [Color] with increased saturation. - * @param amount How much. - * @example chroma.color('slategray') - * @example chroma.color('slategray').saturate() - * @example chroma.color('slategray').saturate(2) - * @example chroma.color('slategray').saturate(3) - */ - saturate(amount = 1) { - const [l, c, h] = this.lch(); - return lch(l, max(0, c + amount * LAB_Kn), h, this.alpha()); - } - /** - * Equivalent to `saturate(-amount)`. - * @see #saturate - */ - desaturate(amount = 1) { - return this.saturate(-amount); - } - premultiplied() { - const { r, g, b, a } = this; - return rgb(r * a, g * a, b * a, a); - } - /** - * Returns the [HSI] representation of this color. hue will always be in [0; 360). Values are never NaN. - * - * @example chroma.color('purple').hsi() - */ - hsi() { - const { r, g, b } = this; - return rgb2hsi(r, g, b); - } - /** - * Returns the [LAB] representation of this color. - * - * @example chroma.color('purple').lab() - */ - lab() { - const { r, g, b } = this; - return rgb2lab(r, g, b); - } - /** - * Return a hex-num of this color. - * - * @param mode - * @see #num for a hex-number representation. - * @example chroma.color('yellow').alpha(0.7).hex() - * @example chroma.color('yellow').alpha(0.7).hex('rgba') - * @example chroma.color('yellow').alpha(0.7).hex('argb') - */ - num(mode = "rgb") { - const { r, g, b, a } = this; - return rgb2num(r, g, b, a, mode); - } - /** - * Returns the [LCH] representation of this color. hue will always be in [0; 360). Values are never NaN. - * - * @example chroma.color('purple').lch() - */ - lch() { - const { r, g, b } = this; - return rgb2lch(r, g, b); - } - /** - * Returns the [XYZ] representation of this color. hue will always be in [0; 360). Values are never NaN. - * - * @example chroma.color('purple').xyz() - */ - xyz() { - const { r, g, b } = this; - return rgb2xyz(r, g, b); - } - /** - * Whether this [Color](#Color) is identical (strict equality of r, g, b, a) to `color`. - */ - equals(color) { - const { r, g, b, a } = this; - const { r: r2, g: g2, b: b2, a: a2 } = color; - return r == r2 && g == g2 && b == b2 && a == a2; - } - hashCode() { - return this.num("rgba"); - } - /** - * @example chroma.color('red').toSource() // == "rgb(255, 0, 0)" - * @example chroma.rgb(-2, 100.02, 200, 0.5).toSource() // == "rgb(-2, 100.02, 200, 0.5)" - */ - toSource() { - const { r, g, b, a } = this; - return "chroma.rgb(" + r + ", " + g + ", " + b + (a === 1 ? ")" : ", " + a + ")"); - } - } - Color.prototype.toString = Color.prototype.css; - Color.prototype.kelvin = Color.prototype.temperature; - /** - * @example chroma.black - */ - const black = new Color(0, 0, 0, 1); - /** - * @example chroma.black - */ - const white = new Color(255, 255, 255, 1); - const brewer = { - OrRd: [0xfff7ec, 0xfee8c8, 0xfdd49e, 0xfdbb84, 0xfc8d59, 0xef6548, 0xd7301f, 0xb30000, 0x7f0000], - PuBu: [0xfff7fb, 0xece7f2, 0xd0d1e6, 0xa6bddb, 0x74a9cf, 0x3690c0, 0x0570b0, 0x045a8d, 0x023858], - BuPu: [0xf7fcfd, 0xe0ecf4, 0xbfd3e6, 0x9ebcda, 0x8c96c6, 0x8c6bb1, 0x88419d, 0x810f7c, 0x4d004b], - Oranges: [0xfff5eb, 0xfee6ce, 0xfdd0a2, 0xfdae6b, 0xfd8d3c, 0xf16913, 0xd94801, 0xa63603, 0x7f2704], - BuGn: [0xf7fcfd, 0xe5f5f9, 0xccece6, 0x99d8c9, 0x66c2a4, 0x41ae76, 0x238b45, 0x006d2c, 0x00441b], - YlOrBr: [0xffffe5, 0xfff7bc, 0xfee391, 0xfec44f, 0xfe9929, 0xec7014, 0xcc4c02, 0x993404, 0x662506], - YlGn: [0xffffe5, 0xf7fcb9, 0xd9f0a3, 0xaddd8e, 0x78c679, 0x41ab5d, 0x238443, 0x006837, 0x004529], - Reds: [0xfff5f0, 0xfee0d2, 0xfcbba1, 0xfc9272, 0xfb6a4a, 0xef3b2c, 0xcb181d, 0xa50f15, 0x67000d], - RdPu: [0xfff7f3, 0xfde0dd, 0xfcc5c0, 0xfa9fb5, 0xf768a1, 0xdd3497, 0xae017e, 0x7a0177, 0x49006a], - Greens: [0xf7fcf5, 0xe5f5e0, 0xc7e9c0, 0xa1d99b, 0x74c476, 0x41ab5d, 0x238b45, 0x006d2c, 0x00441b], - YlGnBu: [0xffffd9, 0xedf8b1, 0xc7e9b4, 0x7fcdbb, 0x41b6c4, 0x1d91c0, 0x225ea8, 0x253494, 0x081d58], - Purples: [0xfcfbfd, 0xefedf5, 0xdadaeb, 0xbcbddc, 0x9e9ac8, 0x807dba, 0x6a51a3, 0x54278f, 0x3f007d], - GnBu: [0xf7fcf0, 0xe0f3db, 0xccebc5, 0xa8ddb5, 0x7bccc4, 0x4eb3d3, 0x2b8cbe, 0x0868ac, 0x084081], - Greys: [0xffffff, 0xf0f0f0, 0xd9d9d9, 0xbdbdbd, 0x969696, 0x737373, 0x525252, 0x252525, 0x000000], - YlOrRd: [0xffffcc, 0xffeda0, 0xfed976, 0xfeb24c, 0xfd8d3c, 0xfc4e2a, 0xe31a1c, 0xbd0026, 0x800026], - PuRd: [0xf7f4f9, 0xe7e1ef, 0xd4b9da, 0xc994c7, 0xdf65b0, 0xe7298a, 0xce1256, 0x980043, 0x67001f], - Blues: [0xf7fbff, 0xdeebf7, 0xc6dbef, 0x9ecae1, 0x6baed6, 0x4292c6, 0x2171b5, 0x08519c, 0x08306b], - PuBuGn: [0xfff7fb, 0xece2f0, 0xd0d1e6, 0xa6bddb, 0x67a9cf, 0x3690c0, 0x02818a, 0x016c59, 0x014636], - Viridis: [0x440154, 0x482777, 0x3f4a8a, 0x31678e, 0x26838f, 0x1f9d8a, 0x6cce5a, 0xb6de2b, 0xfee825], - Spectral: [ - 0x9e0142, - 0xd53e4f, - 0xf46d43, - 0xfdae61, - 0xfee08b, - 0xffffbf, - 0xe6f598, - 0xabdda4, - 0x66c2a5, - 0x3288bd, - 0x5e4fa2, - ], - RdYlGn: [ - 0xa50026, - 0xd73027, - 0xf46d43, - 0xfdae61, - 0xfee08b, - 0xffffbf, - 0xd9ef8b, - 0xa6d96a, - 0x66bd63, - 0x1a9850, - 0x006837, - ], - RdBu: [ - 0x67001f, - 0xb2182b, - 0xd6604d, - 0xf4a582, - 0xfddbc7, - 0xf7f7f7, - 0xd1e5f0, - 0x92c5de, - 0x4393c3, - 0x2166ac, - 0x053061, - ], - PiYG: [ - 0x8e0152, - 0xc51b7d, - 0xde77ae, - 0xf1b6da, - 0xfde0ef, - 0xf7f7f7, - 0xe6f5d0, - 0xb8e186, - 0x7fbc41, - 0x4d9221, - 0x276419, - ], - PRGn: [ - 0x40004b, - 0x762a83, - 0x9970ab, - 0xc2a5cf, - 0xe7d4e8, - 0xf7f7f7, - 0xd9f0d3, - 0xa6dba0, - 0x5aae61, - 0x1b7837, - 0x00441b, - ], - RdYlBu: [ - 0xa50026, - 0xd73027, - 0xf46d43, - 0xfdae61, - 0xfee090, - 0xffffbf, - 0xe0f3f8, - 0xabd9e9, - 0x74add1, - 0x4575b4, - 0x313695, - ], - BrBG: [ - 0x543005, - 0x8c510a, - 0xbf812d, - 0xdfc27d, - 0xf6e8c3, - 0xf5f5f5, - 0xc7eae5, - 0x80cdc1, - 0x35978f, - 0x01665e, - 0x003c30, - ], - RdGy: [ - 0x67001f, - 0xb2182b, - 0xd6604d, - 0xf4a582, - 0xfddbc7, - 0xffffff, - 0xe0e0e0, - 0xbababa, - 0x878787, - 0x4d4d4d, - 0x1a1a1a, - ], - PuOr: [ - 0x7f3b08, - 0xb35806, - 0xe08214, - 0xfdb863, - 0xfee0b6, - 0xf7f7f7, - 0xd8daeb, - 0xb2abd2, - 0x8073ac, - 0x542788, - 0x2d004b, - ], - Set2: [0x66c2a5, 0xfc8d62, 0x8da0cb, 0xe78ac3, 0xa6d854, 0xffd92f, 0xe5c494, 0xb3b3b3], - Accent: [0x7fc97f, 0xbeaed4, 0xfdc086, 0xffff99, 0x386cb0, 0xf0027f, 0xbf5b17, 0x666666], - Set1: [0xe41a1c, 0x377eb8, 0x4daf4a, 0x984ea3, 0xff7f00, 0xffff33, 0xa65628, 0xf781bf, 0x999999], - Set3: [ - 0x8dd3c7, - 0xffffb3, - 0xbebada, - 0xfb8072, - 0x80b1d3, - 0xfdb462, - 0xb3de69, - 0xfccde5, - 0xd9d9d9, - 0xbc80bd, - 0xccebc5, - 0xffed6f, - ], - Dark2: [0x1b9e77, 0xd95f02, 0x7570b3, 0xe7298a, 0x66a61e, 0xe6ab02, 0xa6761d, 0x666666], - Paired: [ - 0xa6cee3, - 0x1f78b4, - 0xb2df8a, - 0x33a02c, - 0xfb9a99, - 0xe31a1c, - 0xfdbf6f, - 0xff7f00, - 0xcab2d6, - 0x6a3d9a, - 0xffff99, - 0xb15928, - ], - Pastel2: [0xb3e2cd, 0xfdcdac, 0xcbd5e8, 0xf4cae4, 0xe6f5c9, 0xfff2ae, 0xf1e2cc, 0xcccccc], - Pastel1: [0xfbb4ae, 0xb3cde3, 0xccebc5, 0xdecbe4, 0xfed9a6, 0xffffcc, 0xe5d8bd, 0xfddaec, 0xf2f2f2], - }; - /** - * X11 color names - * http://www.w3.org/TR/css3-color/#svg-color - * - * @example chroma.Object.keys(w3cx11).slice(0, 4) - */ - const w3cx11 = { - aliceblue: 0xf0f8ff, - antiquewhite: 0xfaebd7, - aqua: 0x00ffff, - aquamarine: 0x7fffd4, - azure: 0xf0ffff, - beige: 0xf5f5dc, - bisque: 0xffe4c4, - black: 0x000000, - blanchedalmond: 0xffebcd, - blue: 0x0000ff, - blueviolet: 0x8a2be2, - brown: 0xa52a2a, - burlywood: 0xdeb887, - cadetblue: 0x5f9ea0, - chartreuse: 0x7fff00, - chocolate: 0xd2691e, - coral: 0xff7f50, - cornflower: 0x6495ed, - cornflowerblue: 0x6495ed, - cornsilk: 0xfff8dc, - crimson: 0xdc143c, - cyan: 0x00ffff, - darkblue: 0x00008b, - darkcyan: 0x008b8b, - darkgoldenrod: 0xb8860b, - darkgray: 0xa9a9a9, - darkgreen: 0x006400, - darkgrey: 0xa9a9a9, - darkkhaki: 0xbdb76b, - darkmagenta: 0x8b008b, - darkolivegreen: 0x556b2f, - darkorange: 0xff8c00, - darkorchid: 0x9932cc, - darkred: 0x8b0000, - darksalmon: 0xe9967a, - darkseagreen: 0x8fbc8f, - darkslateblue: 0x483d8b, - darkslategray: 0x2f4f4f, - darkslategrey: 0x2f4f4f, - darkturquoise: 0x00ced1, - darkviolet: 0x9400d3, - deeppink: 0xff1493, - deepskyblue: 0x00bfff, - dimgray: 0x696969, - dimgrey: 0x696969, - dodgerblue: 0x1e90ff, - firebrick: 0xb22222, - floralwhite: 0xfffaf0, - forestgreen: 0x228b22, - fuchsia: 0xff00ff, - gainsboro: 0xdcdcdc, - ghostwhite: 0xf8f8ff, - gold: 0xffd700, - goldenrod: 0xdaa520, - gray: 0x808080, - green: 0x008000, - greenyellow: 0xadff2f, - grey: 0x808080, - honeydew: 0xf0fff0, - hotpink: 0xff69b4, - indianred: 0xcd5c5c, - indigo: 0x4b0082, - ivory: 0xfffff0, - khaki: 0xf0e68c, - laserlemon: 0xffff54, - lavender: 0xe6e6fa, - lavenderblush: 0xfff0f5, - lawngreen: 0x7cfc00, - lemonchiffon: 0xfffacd, - lightblue: 0xadd8e6, - lightcoral: 0xf08080, - lightcyan: 0xe0ffff, - lightgoldenrod: 0xfafad2, - lightgoldenrodyellow: 0xfafad2, - lightgray: 0xd3d3d3, - lightgreen: 0x90ee90, - lightgrey: 0xd3d3d3, - lightpink: 0xffb6c1, - lightsalmon: 0xffa07a, - lightseagreen: 0x20b2aa, - lightskyblue: 0x87cefa, - lightslategray: 0x778899, - lightslategrey: 0x778899, - lightsteelblue: 0xb0c4de, - lightyellow: 0xffffe0, - lime: 0x00ff00, - limegreen: 0x32cd32, - linen: 0xfaf0e6, - magenta: 0xff00ff, - maroon: 0x800000, - maroon2: 0x7f0000, - maroon3: 0xb03060, - mediumaquamarine: 0x66cdaa, - mediumblue: 0x0000cd, - mediumorchid: 0xba55d3, - mediumpurple: 0x9370db, - mediumseagreen: 0x3cb371, - mediumslateblue: 0x7b68ee, - mediumspringgreen: 0x00fa9a, - mediumturquoise: 0x48d1cc, - mediumvioletred: 0xc71585, - midnightblue: 0x191970, - mintcream: 0xf5fffa, - mistyrose: 0xffe4e1, - moccasin: 0xffe4b5, - navajowhite: 0xffdead, - navy: 0x000080, - oldlace: 0xfdf5e6, - olive: 0x808000, - olivedrab: 0x6b8e23, - orange: 0xffa500, - orangered: 0xff4500, - orchid: 0xda70d6, - palegoldenrod: 0xeee8aa, - palegreen: 0x98fb98, - paleturquoise: 0xafeeee, - palevioletred: 0xdb7093, - papayawhip: 0xffefd5, - peachpuff: 0xffdab9, - peru: 0xcd853f, - pink: 0xffc0cb, - plum: 0xdda0dd, - powderblue: 0xb0e0e6, - purple: 0x800080, - purple2: 0x7f007f, - purple3: 0xa020f0, - rebeccapurple: 0x663399, - red: 0xff0000, - rosybrown: 0xbc8f8f, - royalblue: 0x4169e1, - saddlebrown: 0x8b4513, - salmon: 0xfa8072, - sandybrown: 0xf4a460, - seagreen: 0x2e8b57, - seashell: 0xfff5ee, - sienna: 0xa0522d, - silver: 0xc0c0c0, - skyblue: 0x87ceeb, - slateblue: 0x6a5acd, - slategray: 0x708090, - slategrey: 0x708090, - snow: 0xfffafa, - springgreen: 0x00ff7f, - steelblue: 0x4682b4, - tan: 0xd2b48c, - teal: 0x008080, - thistle: 0xd8bfd8, - tomato: 0xff6347, - turquoise: 0x40e0d0, - violet: 0xee82ee, - wheat: 0xf5deb3, - white: 0xffffff, - whitesmoke: 0xf5f5f5, - yellow: 0xffff00, - yellowgreen: 0x9acd32, - }; - /** - * Create a new random [Color] from a random point in the RGB color space. - * @param randomSource A function which returns random `number`s in the interval [0; 1). Useful if you want to - * create a deterministic sequence of "random" colors. Defaults to `Math.random`. - */ - function random(randomSource = Math.random) { - return num((randomSource() * 16777216) | 0); - } - /** - * Create a valid RGB color (`.clipped() == false`) from a random point in the CIELAB color space. This results in - * more colors in the RGB color space where humans can perceive more differences. - * @param randomSource A function which returns random `number`s in the interval [0; 1). Useful if you want to - * create a deterministic sequence of "random" colors. Defaults to `Math.random`. - * @example chroma.random((() => { let i = 0; return () => (i = (i *Math.SQRT2) % 1); })()) - */ - // export function randomLab(randomSource = Math.random) { - // const labAMin = -87, - // labAMax = 99, - // labBMin = -108, - // labBMax = 95 - // let maxIterations = 100 - // while (maxIterations--) { - // const u = randomSource(), - // v = randomSource(), - // w = randomSource() - // // The following matrix multiplication transform the random point (u v w) in the unit cube into the - // // oriented bounding box (OBB) of the projection of the RGB space into the LAB space. This is necessary to - // // avoid a huge number of misses. - // const color = lab( - // u * -53.903 + v * -88.755 + w * 71.7 + 99.707, - // u * -82.784 + v * 187.036 + w * -2.422 + -28.17, - // u * -75.813 + v * -141.406 + w * -48.261 + 152.469, - // ) - // console.log(color.lab()) - // console.log(color.rgba(false, false)) - // if (!color.clipped()) return color - // } - // throw new Error("Could find a random color in 100 iterations") - // } - /** - * Mixes two colors. The mix ratio is a value between 0 and 1. - * The color mixing produces different results based the color space used for interpolation. - * - * @param col2 - * @param f - * @param m - * @example chroma.mix('red', 'blue') - * @example chroma.mix('red', 'blue', 0.25) - * @example chroma.mix('red', 'blue', 0.75) - * - * @example chroma.mix('red', 'blue', 0.5, 'rgb') - * @example chroma.mix('red', 'blue', 0.5, 'hsl') - * @example chroma.mix('red', 'blue', 0.5, 'lab') - * @example chroma.mix('red', 'blue', 0.5, 'lch') - * @example chroma.mix('red', 'blue', 0.5, 'lrgb') - */ - function mix(col1, col2, f = 0.5, m = "rgb") { - const c1 = color(col1); - const c2 = color(col2); - const res = interpolators[m] && interpolators[m](c1, c2, f, m); - if (!res) { - throw new Error("color mode " + m + " is not supported"); - } - return res.alpha(lerp(c1.alpha(), c2.alpha(), f)); - } - function lch(...args) { - return guess(args, "lch"); - } - function hsl(...args) { - return guess(args, "hsl"); - } - function lab(...args) { - return guess(args, "lab"); - } - /** - * @example chroma.num(0x663399) // rebeccapurple - */ - function num(num) { - const [r, g, b] = num2rgb(num); - return new Color(r, g, b); - } - function rgb(...args) { - return guess(args, "rgb"); - } - function scale(...args) { - const f = ((t) => f._at(t)); - Object.getOwnPropertyNames(Scale.prototype).forEach((key) => (f[key] = Scale.prototype[key])); - if (Array.isArray(args[0])) - args = args[0]; - if (args.length == 1 && "string" == typeof args[0]) - args = brewer[args[0]]; - f._init("function" == typeof args[0] ? args[0] : args.map((a) => color(a))); - //f.setColors(args.length > 1 ? args : args[0]) - return f; - } - class Scale { - classes(classes) { - if (undefined === classes) { - return this._classes; - } - if (Array.isArray(classes)) { - this._classes = classes; - this.domain(classes[0], classes[classes.length - 1]); - } - else { - if (classes % 1 != 0 || classes < 1) - throw new Error("invalid classes param"); - // const d = analyze(this.domain()) - this._classes = limits(this.domain(), "e", classes); - } - return this; - } - domain(...domain) { - if (undefined === domain[0]) { - return "function" !== typeof this._colors - ? this._pos.map((p) => lerp(this._min, this._max, p)) - : [this._min, this._max]; - } - this._min = domain[0]; - this._max = domain[domain.length - 1]; - if (2 == domain.length) { - if ("function" !== typeof this._colors) { - // equidistant positions - this._pos = this._colors.map((_, c) => c / (this._colors.length - 1)); - } - } - else if ("function" !== typeof this._colors && domain.length == this._colors.length) { - this._pos = domain.map((d) => lerpInv(this._min, this._max, d)); - } - else { - throw new Error("invalid domain " + domain); - } - return this; - } - mode(mode) { - if (undefined === mode) { - return this._mode; - } - this._mode = mode; - this._resetCache(); - return this; - } - /** - * Set the output format return by `this(x)` and `this.colors(n)`. - * @param outputFormat The color format to use. Pass `undefined` to return [Color] objects. - * @return `this` - * @example chroma.scale("red", "white").out("hex")(0) // == "#ff0000" - * @example chroma.scale("red", "white").out("num").colors(2) // == [0xff0000, 0xffffff] - */ - out(outputFormat) { - this._out = outputFormat; - return this; - } - /** - * This makes sure the lightness range is spread evenly across a color scale. Especially useful when working - * with [multi-hue color scales](https://www.vis4.net/blog/2013/09/mastering-multi-hued-color-scales/), where - * simple gamma correction can't help you very much. - * - * @example chroma.scale('black','red','yellow','white') - * @example chroma.scale('black','red','yellow','white').correctLightness() - */ - correctLightness(enableCorrectLightness = true) { - if (this._correctLightness != enableCorrectLightness) { - this._resetCache(); - const colors = this._colors; - if (enableCorrectLightness && "function" !== typeof colors) { - // make sure that the colors have ascending or descending lightnesses - let sign = 0; - for (let i = 1; i < colors.length; i++) { - const sign2 = colors[i].lab()[0] - colors[i - 1].lab()[0]; - if (0 == sign) { - sign = sign2; - } - else if (sign * sign2 < 0) { - throw new Error("scale color lightnesses must be monotonic"); - } - } - } - } - this._correctLightness = enableCorrectLightness; - return this; - } - padding(paddingLeft, paddingRight = paddingLeft) { - if (!paddingLeft) { - return [this._paddingLeft, this._paddingRight]; - } - this._paddingLeft = paddingLeft; - this._paddingRight = paddingRight; - return this; - } - /** - * Get a number of equidistant colors. - * @param numColors The number of colors to return. - * @param format Output format. Defaults to `"hex"`. Pass `"color"` to get {@link Color} objects. - * @returns If `numColors` is `undefined`, the colors which define this [Scale]. If `numColors` is 1, - * `[this((min + max) / 2)]`. Otherwise, an array where the first element is `this(min)`, the last one is - * `this(max)` and the rest are equidistant samples between min and max. - * @example chroma.scale('OrRd').colors(5) - * @example chroma.scale(['white', 'black']).colors(12) - */ - colors(numColors, format = "hex") { - let result; - if (undefined === numColors) { - result = this._colors.slice(); - } - else if (numColors == 1) { - result = [this._color((this._min + this._max) / 2)]; - } - else if (numColors > 1) { - result = Array.from({ length: numColors }, (_, i) => this._color(lerp(this._min, this._max, i / (numColors - 1)))); - } - else { - // returns all colors based on the defined classes - let samples; - if (this._classes && this._classes.length > 2) { - samples = Array.from({ length: this._classes.length - 1 }, (_, i) => (this._classes[i] + this._classes[i + 1]) * 0.5); - } - else { - samples = this.domain(); // TODO?! - } - result = samples.map((s) => this._color(s)); - } - return (format != "color" ? result.map((c) => c[format]()) : result); - } - cache(enableCache) { - if (undefined === enableCache) { - return !!this._cache; - } - this._cache = enableCache ? this._cache || new Map() : undefined; - return this; - } - gamma(gamma) { - if (undefined === gamma) { - return this._gamma; - } - this._gamma = gamma; - return this; - } - /** - * @ignore - */ - _at(t) { - const c = this._color(t); - return this._out ? c[this._out]() : c; - } - /** - * @ignore - */ - _init(colorsOrFunction) { - this._colors = colorsOrFunction; - if ("function" != typeof colorsOrFunction) { - this._pos = colorsOrFunction.map((_, i) => i / (colorsOrFunction.length - 1)); - } - this._mode = "rgb"; - this.domain(0, 1); - this._paddingLeft = 0; - this._paddingRight = 0; - this._correctLightness = false; - this._cache = new Map(); - this._gamma = 1; - } - _getClass(value) { - return this._classes.findIndex((cls) => value <= cls) - 1; - } - _color(val, bypassMap = false) { - let t; - if (!bypassMap) { - const min = this._min, max = this._max; - if (this._classes && this._classes.length > 2) { - const c = this._getClass(val); - t = c / (this._classes.length - 2); - } - else if (max !== min) { - t = (val - min) / (max - min); - } - else { - t = 1; - } - if (this._correctLightness) { - t = this._tCorrectedLightness(t); - } - } - else { - t = val; - } - t = t ** this._gamma; - t = (this._paddingLeft + t) / (1 + this._paddingLeft + this._paddingRight); - // t = this._paddingLeft + t * (1 - this._paddingLeft - this._paddingRight) - t = clamp(t, 0, 1); - const tHash = t; - const cacheResult = this._cache && this._cache.get(tHash); - if (cacheResult) { - return cacheResult; - } - else { - let col; - if (Array.isArray(this._colors)) { - for (let i = 0; i < this._pos.length; i++) { - const p = this._pos[i]; - if (t <= p) { - col = this._colors[i]; - break; - } - if (t >= p && i == this._pos.length - 1) { - col = this._colors[i]; - break; - } - if (t > p && t < this._pos[i + 1]) { - t = (t - p) / (this._pos[i + 1] - p); - col = mix(this._colors[i], this._colors[i + 1], t, this._mode); - break; - } - } - } - else { - col = this._colors(t); - } - if (this._cache) { - // tslint:disable-next-line - this._cache.set(tHash, col); - } - // tslint:disable-next-line - return col; - } - } - _tCorrectedLightness(t0_1) { - const L0 = this._color(0, true).lab()[0]; - const L1 = this._color(1, true).lab()[0]; - const L_ideal = lerp(L0, L1, t0_1); - return bisect((t) => this._color(t, true).lab()[0] - L_ideal, 0, 1, 8); - } - _resetCache() { - if (this._cache) - this._cache.clear(); - } - } - var scales; - (function (scales) { - /** - * @example chroma.scales.cool() - */ - function cool() { - return scale([hsl(180, 1, 0.9), hsl(250, 0.7, 0.4)]); - } - scales.cool = cool; - /** - * @example chroma.scales.hot() - */ - function hot() { - return scale(["#000", "#f00", "#ff0", "#fff"]).mode("rgb"); - } - scales.hot = hot; - })(scales || (scales = {})); - function analyze(data) { - const r = { - min: Infinity, - max: -Infinity, - sum: 0, - values: [], - count: 0, - }; - function add(val) { - if (val != undefined && !isNaN(val)) { - r.values.push(val); - r.sum += val; - if (val < r.min) - r.min = val; - if (val > r.max) - r.max = val; - r.count += 1; - } - } - data.forEach((val) => add(val)); - r.domain = [r.min, r.max]; - r.limits = function (mode, num) { - return limits(this, mode, num); - }; - return r; - } - function limits(data, mode = "e", num = 7) { - const info = Array.isArray(data) ? analyze(data) : data; - const { min, max, values } = info; - values.sort((a, b) => a - b); - if (num == 1) { - return [min, max]; - } - if (mode.startsWith("c")) { - return [min, max]; - } - else if (mode.startsWith("e")) { - return Array.from({ length: num + 1 }, (_, i) => lerp(min, max, i / num)); - } - else if (mode.startsWith("l")) { - if (min <= 0) { - throw new Error("Logarithmic scales are only possible for values > 0"); - } - const min_log = Math.LOG10E * log(min); - const max_log = Math.LOG10E * log(max); - return Array.from({ length: num + 1 }, (_, i) => 10 ** lerp(min_log, max_log, i / num)); - } - else if (mode.startsWith("q")) { - return Array.from({ length: num + 1 }, (_, i) => { - const p = ((values.length - 1) * i) / num; - const pb = floor(p); - return pb == p ? values[pb] : lerp(values[pb], values[pb + 1], p - pb); - }); - } - else if (mode.startsWith("k")) { - // implementation based on - // http://code.google.com/p/figue/source/browse/trunk/figue.js#336 - // simplified for 1-d input values - const n = values.length; - const assignments = new Array(n); - const clusterSizes = new Array(num); - let repeat = true; - let nb_iters = 0; - let centroids = Array.from({ length: num + 1 }, (_, i) => lerp(min, max, i / num)); - do { - // assignment step - clusterSizes.fill(0); - for (let i = 0; i < values.length; i++) { - const value = values[i]; - const minDistIndex = indexOfMax(centroids, (c) => -abs(c - value)); - clusterSizes[minDistIndex]++; - assignments[i] = minDistIndex; - } - // update centroids step - const newCentroids = new Array(num).fill(0); - for (let i = 0; i < assignments.length; i++) { - const cluster = assignments[i]; - newCentroids[cluster] += values[i]; - } - for (let j = 0; j < newCentroids.length; j++) { - newCentroids[j] /= clusterSizes[j]; - } - // check convergence - repeat = newCentroids.some((nc, j) => nc != centroids[j]); - centroids = newCentroids; - } while (nb_iters++ < 200 && repeat); - // finished k-means clustering - // the next part is borrowed from gabrielflor.it - const kClusters = Array.from({ length: num }, () => []); - for (let i = 0; i < assignments.length; i++) { - const cluster = assignments[i]; - kClusters[cluster].push(values[i]); - } - const tmpKMeansBreaks = []; - for (const kCluster of kClusters) { - tmpKMeansBreaks.push(kCluster[0], kCluster[kCluster.length - 1]); - } - tmpKMeansBreaks.sort((a, b) => a - b); - const limits = []; - limits.push(tmpKMeansBreaks[0]); - for (let i = 1; i < tmpKMeansBreaks.length; i += 2) { - const v = tmpKMeansBreaks[i]; - if (!isNaN(v) && limits.indexOf(v) == -1) { - limits.push(v); - } - } - return limits; - } - else { - throw new Error("unknown mode"); - } - } - const interpolators = {}; - // const _guess_formats: { p: number; test: (args: any[]) => ColorFormat | undefined }[] = [] - const _input = {}; - function linear_interpolator(col1, col2, f, m) { - const xyz1 = col1[m](); - const xyz2 = col2[m](); - return guess([ - lerp(xyz1[0], xyz2[0], f), - lerp(xyz1[1], xyz2[1], f), - lerp(xyz1[2], xyz2[2], f), - lerp(col1.alpha(), col2.alpha(), f), - ], m); - } - interpolators.xyz = interpolators.rgb = interpolators.lab = linear_interpolator; - interpolators.num = function (col1, col2, f) { - const n1 = col1.num(); - const n2 = col2.num(); - return num(lerp(n1, n2, f)); - }; - interpolators.lrgb = function (col1, col2, f) { - const [r1, g1, b1, a1] = col1.rgba(false, false); - const [r2, g2, b2, a2] = col2.rgba(false, false); - return new Color(sqrt(r1 ** 2 * (1 - f) + r2 ** 2 * f), sqrt(g1 ** 2 * (1 - f) + g2 ** 2 * f), sqrt(b1 ** 2 * (1 - f) + b2 ** 2 * f), lerp(a1, a2, f)); - }; - function guess(args, mode) { - if (Array.isArray(args[0])) - args = args[0]; - if (!mode) { - if (args.length == 1 && args[0] in w3cx11) { - mode = "name"; - } - else if (args.length == 1 && "string" == typeof args[0]) { - mode = "css"; - } - else if (args.length == 3) { - mode = "rgb"; - } - else if (args.length == 4 && "number" == typeof args[3] && args[3] >= 0 && args[3] <= 1) { - mode = "rgb"; - } - else if (args.length == 1 && "number" == typeof args[0] && args[0] >= 0 && args[0] <= 0xffffff) { - mode = "num"; - } - else - throw new Error("could not guess mode. args " + JSON.stringify(args)); - } - const channels = _input[mode](...args); - return new Color(channels[0], channels[1], channels[2], undefined !== channels[3] ? channels[3] : 1); - } - function hex2rgb(hex) { - let m; - if ((m = hex.match(/^#?([A-F\d]{2})([A-F\d]{2})([A-F\d]{2})([A-F\d]{2})?$/i))) { - return [parseInt(m[1], 16), parseInt(m[2], 16), parseInt(m[3], 16), m[4] ? parseInt(m[4], 16) / 255 : 1]; - } - else if ((m = hex.match(/^#?([A-F\d])([A-F\d])([A-F\d])([A-F\d])?$/i))) { - return [ - parseInt(m[1], 16) * 0x11, - parseInt(m[2], 16) * 0x11, - parseInt(m[3], 16) * 0x11, - m[4] ? (parseInt(m[4], 16) * 0x11) / 255 : 1, - ]; - } - throw new Error("invalid hex color: " + hex); - } - // interface ColorModes { - // cmyk: CMYK - // gl: GL - // rgb: RGB - // rgba: RGBA - // lab: LAB - // hsl: HSL - // hsv: HSV - // hsi: HSI - // xyz: XYZ - // hcg: HCG - // lch: LCH - // hex: string - // num: number - // name: string - // kelvin: number - // css: string - // } - function rgb2hex(r255, g255, b255, a1, mode = "rgb") { - r255 = clamp(round(r255), 0, 255); - g255 = clamp(round(g255), 0, 255); - b255 = clamp(round(b255), 0, 255); - const rgb = (r255 << 16) | (g255 << 8) | b255; - const rgbString = rgb.toString(16).padStart(6, "0"); - const alphaString = round(clamp(a1) * 255) - .toString(16) - .padStart(2, "0"); - return "#" + ("argb" == mode ? alphaString + rgbString : "rgba" == mode ? rgbString + alphaString : rgbString); - } - _input.lrgb = _input.rgb; - _input.hex = hex2rgb; - _input.hsl = hsl2rgb; - function norm360(degrees) { - return ((degrees % 360) + 360) % 360; - } - _input.hsv = hsv2rgb; - function num2rgb(num) { - if (!("number" == typeof num && num >= 0 && num <= 0xffffff)) { - throw new Error("unknown num color: " + num); - } - const r = num >> 16; - const g = (num >> 8) & 0xff; - const b = num & 0xff; - return [r, g, b, 1]; - } - function rgb2num(r255, g255, b255, a1 = 1, mode = "rgb") { - const rgbNum = (round(r255) << 16) | (round(g255) << 8) | round(b255); - if ("rgb" === mode) { - return rgbNum; - } - else if ("rgba" === mode) { - return (rgbNum << 8) | (round(a1 * 255) << 24); - } - else { - return (round(a1 * 255) << 24) | rgbNum; - } - } - _input.num = num2rgb; - const WS = "\\s*"; - const FLOAT = "([+-]?(?:\\d*\\.?)?\\d+(?:[eE][+-]?\\d+)?)"; - const CSS_RGB_REGEX = new RegExp(["^rgba?\\(", FLOAT, ",", FLOAT, ",", FLOAT, "(?:,", FLOAT + "(%)?", ")?\\)$"].join(WS), "i"); - const CSS_RGB_WS_REGEX = new RegExp(["^rgba?\\(", FLOAT, FLOAT, FLOAT, "(?:/", FLOAT + "(%)?", ")?\\)$"].join(WS), "i"); - const CSS_RGB_PERCENT_REGEX = new RegExp(["^rgba?\\(", FLOAT + "%", ",", FLOAT + "%", ",", FLOAT + "%", "(?:,", FLOAT + "(%)?", ")?\\)$"].join(WS), "i"); - const CSS_RGB_WS_PERCENT_REGEX = new RegExp(["^rgba?\\(", FLOAT + "%", FLOAT + "%", FLOAT + "%", "(?:/", FLOAT + "(%)?", ")?\\)$"].join(WS), "i"); - const CSS_HSL_REGEX = new RegExp(["^hsla?\\(", FLOAT + "(deg|rad|turn)?", ",", FLOAT + "%", ",", FLOAT + "%", "(?:,", FLOAT + "(%)?", ")?\\)$"].join(WS), "i"); - const CSS_HSL_WS_REGEX = new RegExp(["^hsla?\\(", FLOAT + "(deg|rad|turn)?\\s+" + FLOAT + "%", FLOAT + "%", "(?:/", FLOAT + "(%)?", ")?\\)$"].join(WS), "i"); - function css2rgb(css) { - if (w3cx11 && w3cx11.hasOwnProperty(css)) { - return num2rgb(w3cx11[css.toLowerCase()]); - } - let m; - if ((m = css.match(CSS_RGB_REGEX) || css.match(CSS_RGB_WS_REGEX))) { - return [ - clamp(+m[1], 0, 255), - clamp(+m[2], 0, 255), - clamp(+m[3], 0, 255), - m[4] ? clamp(m[5] ? +m[4] / 100 : +m[4]) : 1, - ]; - } - else if ((m = css.match(CSS_RGB_PERCENT_REGEX) || css.match(CSS_RGB_WS_PERCENT_REGEX))) { - return [ - clamp(+m[1] / 100) * 255, - clamp(+m[2] / 100) * 255, - clamp(+m[3] / 100) * 255, - m[4] ? clamp(m[5] ? +m[4] / 100 : +m[4]) : 1, - ]; - } - else if ((m = css.match(CSS_HSL_REGEX) || css.match(CSS_HSL_WS_REGEX))) { - const CONVERSION = { deg: 1, rad: RAD2DEG, turn: 360 }; - const angleUnit = (m[2] ? m[2].toLowerCase() : "deg"); - return hsl2rgb((((+m[1] * CONVERSION[angleUnit]) % 360) + 360) % 360, clamp(+m[3] / 100), clamp(+m[4] / 100), m[5] ? clamp(m[6] ? +m[5] / 100 : +m[5]) : 1); - } - else { - return hex2rgb(css); - } - } - function rgb2css(r, g, b, a = 1) { - if (a >= 1) { - return "rgb(" + [r, g, b].map(round).join(",") + ")"; - } - else { - return "rgba(" + [r, g, b].map(round).join(",") + "," + a + ")"; - } - } - function rnd(a) { - return round(a * 100) / 100; - } - function hsl2css([h, s, l], alpha) { - const mode = alpha < 1 ? "hsla" : "hsl"; - return (mode + - "(" + - rnd(h) + - "," + - rnd(s * 100) + - "%" + - "," + - rnd(l * 100) + - "%" + - ("hsla" == mode ? "," + rnd(alpha) : "") + - ")"); - } - _input.css = css2rgb; - _input.name = function (name) { - return num2rgb(w3cx11[name]); - }; - function lch2lab(l, c, hueDegrees) { - /* - Convert from a qualitative parameter h and a quantitative parameter l to a 24-bit pixel. - These formulas were invented by David Dalrymple to obtain maximum contrast without going - out of gamut if the parameters are in the range 0-1. - - A saturation multiplier was added by Gregor Aisch - */ - return [l, cos(hueDegrees * DEG2RAD) * c, sin(hueDegrees * DEG2RAD) * c]; - } - function lch2rgb(l, c, hDegrees, alpha1 = 1) { - const [, a, b] = lch2lab(l, c, hDegrees); - return cielab2rgb(l, a, b, alpha1); - } - function lab2lch(l, a, b) { - const c = hypot(a, b); - const h = (atan2(b, a) * RAD2DEG + 360) % 360; - return [l, c, h]; - } - function rgb2lch(r255, g255, b255) { - const [l, a, b2] = rgb2lab(r255, g255, b255); - return lab2lch(l, a, b2); - } - _input.lch = lch2rgb; - function rgb2cmyk(r255, g255, b255) { - r255 /= 255; - g255 /= 255; - b255 /= 255; - const k = 1 - max(r255, g255, b255); - if (1 == k) - return [0, 0, 0, 1]; - const c = (1 - r255 - k) / (1 - k); - const m = (1 - g255 - k) / (1 - k); - const y = (1 - b255 - k) / (1 - k); - return [c, m, y, k]; - } - function cmyk2rgb(c1, m1, y1, k1, alpha1 = 1) { - if (k1 == 1) { - return [0, 0, 0, alpha1]; - } - const r255 = 255 * (1 - c1) * (1 - k1); - const g255 = 255 * (1 - m1) * (1 - k1); - const b255 = 255 * (1 - y1) * (1 - k1); - return [r255, g255, b255, alpha1]; - } - _input.cmyk = cmyk2rgb; - _input.gl = function (r, g, b, a = 1) { - return [r * 255, g * 255, b * 255, a]; - }; - //function rgb2luminance(r: number, g: number, b: number) { - // // https://en.wikipedia.org/wiki/Relative_luminance - // const [, Y] = rgb2xyz(r, g, b) - // return Y - //} - function rgbChannel2RgbLinear(x255) { - const x1 = x255 / 255; - // http://entropymine.com/imageworsener/srgbformula/ - if (x1 <= 0.04045) { - return x1 / 12.92; - } - else { - return ((x1 + 0.055) / 1.055) ** 2.4; - } - } - function rgbLinearChannel2Rgb(xLinear1) { - if (xLinear1 <= 0.0031308) { - return 255 * (12.92 * xLinear1); - } - else { - return 255 * ((1 + 0.055) * xLinear1 ** (1 / 2.4) - 0.055); - } - } - function kelvin2rgb(kelvin) { - const t = kelvin / 100; - let r, g, b; - if (t < 66) { - r = 255; - g = -155.25485562709179 - 0.44596950469579133 * (t - 2) + 104.49216199393888 * log(t - 2); - b = t < 20 ? 0 : -254.76935184120902 + 0.8274096064007395 * (t - 10) + 115.67994401066147 * log(t - 10); - } - else { - r = 351.97690566805693 + 0.114206453784165 * (t - 55) - 40.25366309332127 * log(t - 55); - g = 325.4494125711974 + 0.07943456536662342 * (t - 50) - 28.0852963507957 * log(t - 50); - b = 255; - } - return [r, g, b]; - } - _input.rgb = (...args) => args; - function rgb2kelvin(r255, g255, b255) { - console.log(b255 - r255); - if (g255 + b255 < 158.61) { - console.log("0 < t < 20"); - // calc from green - return round(newtonIterate1d((t) => g255 - (-155.25485562709179 - 0.44596950469579133 * (t - 2) + 104.49216199393888 * log(t - 2)), 15, 4) * 100); - } - else if (b255 - r255 < 0) { - console.log("20 < t < 66"); - return round(newtonIterate1d((t) => b255 - (-254.76935184120902 + 0.8274096064007395 * (t - 10) + 115.67994401066147 * log(t - 10)), 43, 4) * 100); - } - else { - console.log("0 < t < 400, start= " + (-1.4 * (r255 + g255) + 755)); - return round(newtonIterate1d((t) => r255 - (351.97690566805693 + 0.114206453784165 * (t - 55) - 40.25366309332127 * log(t - 55)), -1.4 * (r255 + g255) + 755, 8) * 100); - } - } - _input.temperature = _input.kelvin = _input.K = kelvin2rgb; - /** - * r, g, b can be in any interval (0-1 or 0-255) - * @param r - * @param g - * @param b - */ - function rgb2hexhue(r, g, b) { - const m = min(r, g, b); - const M = max(r, g, b); - const delta = M - m; - let hueTurnX6; // angle as value between 0 and 6 - if (0 == delta) { - hueTurnX6 = 0; - } - else if (r == M) { - // second term to make sure the value is > 0 - hueTurnX6 = (g - b) / delta + (g < b ? 6 : 0); - } - else if (g == M) { - hueTurnX6 = 2 + (b - r) / delta; - } - else { - hueTurnX6 = 4 + (r - g) / delta; - } - return [hueTurnX6 * 60, m, M]; - } - function hcxm2rgb(hueDegrees, c1, x1, m1, alpha1) { - const m255 = m1 * 255; - const cm255 = c1 * 255 + m255; - const xm255 = x1 * 255 + m255; - if (hueDegrees < 60) { - return [cm255, xm255, m255, alpha1]; - } - else if (hueDegrees < 120) { - return [xm255, cm255, m255, alpha1]; - } - else if (hueDegrees < 180) { - return [m255, cm255, xm255, alpha1]; - } - else if (hueDegrees < 240) { - return [m255, xm255, cm255, alpha1]; - } - else if (hueDegrees < 300) { - return [xm255, m255, cm255, alpha1]; - } - else { - return [cm255, m255, xm255, alpha1]; - } - } - /** - * https://en.wikipedia.org/w/index.php?title=HSL_and_HSV&oldid=856714654#From_HSL - */ - function hsl2rgb(hueDegrees, s1, l1, alpha1 = 1) { - hueDegrees = norm360(hueDegrees); - const c1 = (1 - abs(2 * l1 - 1)) * s1; - return hcxm2rgb(hueDegrees, c1, c1 * (1 - abs(((hueDegrees / 60) % 2) - 1)), l1 - c1 / 2, alpha1); - } - function rgb2hsl(r255, g255, b255) { - const [hue, min1, max1] = rgb2hexhue(r255 / 255, g255 / 255, b255 / 255); - const l1 = (max1 + min1) / 2; - let s1; - if (max1 == min1) { - s1 = 0; - } - else { - s1 = l1 < 0.5 ? (max1 - min1) / (max1 + min1) : (max1 - min1) / (2 - max1 - min1); - } - return [hue, s1, l1]; - } - function hsv2rgb(hueDegrees, s1, v1, alpha1 = 1) { - hueDegrees = norm360(hueDegrees); - const c1 = v1 * s1; - return hcxm2rgb(hueDegrees, c1, c1 * (1 - abs(((hueDegrees / 60) % 2) - 1)), v1 - c1, alpha1); - } - function rgb2hsv(r255, g255, b255) { - const [hue, min255, max255] = rgb2hexhue(r255, g255, b255); - const delta255 = max255 - min255; - const v1 = max255 / 255.0; - const s1 = max255 == 0 ? 0 : delta255 / max255; - return [hue, s1, v1]; - } - function hcg2rgb(hueDegrees, c1, g1, alpha1 = 1) { - hueDegrees = norm360(hueDegrees); - const p = g1 * (1 - c1); - return hcxm2rgb(hueDegrees, c1, c1 * (1 - abs(((hueDegrees / 60) % 2) - 1)), p, alpha1); - } - function rgb2hcg(r255, g255, b255) { - const [hue, min255, max255] = rgb2hexhue(r255, g255, b255); - const c1 = (max255 - min255) / 255; - const _g1 = c1 < 1 ? min255 / 255 / (1 - c1) : 0; - return [hue, c1, _g1]; - } - _input.hcg = hcg2rgb; - function cielab2rgb(LStar100, aStar, bStar, alpha = 1) { - const [x, y, z] = cielab2xyz(LStar100, aStar, bStar); - return xyz2rgb(x, y, z, alpha); - } - function cielab2xyz(LStar100, aStar, bStar) { - function fInv(t) { - if (t > LAB_delta) { - return t ** 3; - } - else { - return LAB_3DeltaPow2 * (t - 4 / 29); - } - } - return [ - LAB_Xn * fInv((LStar100 + 16) / 116 + aStar / 500), - LAB_Yn * fInv((LStar100 + 16) / 116), - LAB_Zn * fInv((LStar100 + 16) / 116 - bStar / 200), - ]; - } - function xyz2cielab(x, y, z) { - // https://en.wikipedia.org/w/index.php?title=CIELAB_color_space&oldid=849576085#Forward_transformation - function f(t) { - if (t > LAB_deltaPow3) { - return cbrt(t); - } - else { - return t / LAB_3DeltaPow2 + 4 / 29; - } - } - return [116 * f(y / LAB_Yn) - 16, 500 * (f(x / LAB_Xn) - f(y / LAB_Yn)), 200 * (f(y / LAB_Yn) - f(z / LAB_Zn))]; - } - // const LAB_CONSTANTS = { - const LAB_Kn = 18; - const LAB_Xn = 0.95047; - const LAB_Yn = 1; - const LAB_Zn = 1.08883; - const LAB_delta = 0.206896552; // delta = 6 / 29 - const LAB_3DeltaPow2 = 0.12841855; // 3 * delta ** 2 - const LAB_deltaPow3 = 0.008856452; // delta ** 3 - // } - function rgb2lab(r255, g255, b255) { - const [x, y, z] = rgb2xyz(r255, g255, b255); - return xyz2cielab(x, y, z); - } - function rgb2xyz(r255, g255, b255) { - // https://en.wikipedia.org/wiki/SRGB#The_reverse_transformation - const r1Linear = rgbChannel2RgbLinear(r255); - const g1Linear = rgbChannel2RgbLinear(g255); - const b1Linear = rgbChannel2RgbLinear(b255); - const X = 0.4124564 * r1Linear + 0.3575761 * g1Linear + 0.1804375 * b1Linear; - const Y = 0.2126729 * r1Linear + 0.7151522 * g1Linear + 0.072175 * b1Linear; - const Z = 0.0193339 * r1Linear + 0.119192 * g1Linear + 0.9503041 * b1Linear; - return [X, Y, Z]; - } - function xyz2rgb(X1, Y1, Z1, alpha1 = 1) { - // https://en.wikipedia.org/wiki/SRGB#The_forward_transformation_(CIE_XYZ_to_sRGB) - const r1Linear = 3.2404542 * X1 - 1.5371385 * Y1 - 0.4985314 * Z1; - const g1Linear = -0.969266 * X1 + 1.8760108 * Y1 + 0.041556 * Z1; - const b1Linear = 0.0556434 * X1 - 0.2040259 * Y1 + 1.0572252 * Z1; - return [rgbLinearChannel2Rgb(r1Linear), rgbLinearChannel2Rgb(g1Linear), rgbLinearChannel2Rgb(b1Linear), alpha1]; - } - _input.xyz = xyz2rgb; - _input.lab = cielab2rgb; - /** - * For HSI, we use the direct angle calculation. I.e. atan2(beta, alpha). See wikipedia link. This is why we don't use - * hcxm2rgb. - */ - function hsi2rgb(hueDegrees, s1, i1, alpha1 = 1) { - /* - borrowed from here: - http://hummer.stanford.edu/museinfo/doc/examples/humdrum/keyscape2/hsi2rgb.cpp - */ - let r, g, b; - let hRad = hueDegrees * DEG2RAD; - if (hRad < (2 * PI) / 3) { - b = (1 - s1) / 3; - r = (1 + (s1 * cos(hRad)) / cos(PI / 3 - hRad)) / 3; - g = 1 - (b + r); - } - else if (hRad < (4 * PI) / 3) { - hRad -= (2 * PI) / 3; - r = (1 - s1) / 3; - g = (1 + (s1 * cos(hRad)) / cos(PI / 3 - hRad)) / 3; - b = 1 - (r + g); - } - else { - hRad -= (4 * PI) / 3; - g = (1 - s1) / 3; - b = (1 + (s1 * cos(hRad)) / cos(PI / 3 - hRad)) / 3; - r = 1 - (g + b); - } - return [3 * i1 * r * 255, 3 * i1 * g * 255, 3 * i1 * b * 255, alpha1]; - } - /** - * For HSI, we use the direct angle calculation. I.e. atan2(beta, alpha). See wikipedia link. This is why we don't use - * rgb2hexhue. - */ - function rgb2hsi(r255, g255, b255) { - // See https://en.wikipedia.org/wiki/HSL_and_HSV#Hue_and_chroma - // See https://en.wikipedia.org/wiki/HSL_and_HSV#Lightness - const r1 = r255 / 255; - const g1 = g255 / 255; - const b1 = b255 / 255; - const i1 = (r1 + g1 + b1) / 3; - if (r1 == g1 && g1 == b1) { - return [0, 0, i1]; - } - else { - const alpha = (1 / 2) * (2 * r1 - g1 - b1); - const beta = (sqrt(3) / 2) * (g1 - b1); - const hRad = atan2(beta, alpha); - const min1 = min(r1, g1, b1); - const s1 = 1 - min1 / i1; - return [(hRad < 0 ? 2 * PI + hRad : hRad) * RAD2DEG, s1, i1]; - } - } - _input.hsi = hsi2rgb; - interpolators.hsv = interpolators.hsl = interpolators.hsi = interpolators.lch = interpolators.hcg = function interpolate_hsx(color1, color2, f, m) { - const [a1, b1, c1] = color1[m](); - const [a2, b2, c2] = color2[m](); - function lerpHue(hue1, hue2, f) { - const dh = norm360(hue2 - hue1 + 180) - 180; - return hue1 + f * dh; - } - return color(("h" == m.charAt(0) ? lerpHue : lerp)(a1, a2, f), lerp(b1, b2, f), ("h" == m.charAt(2) ? lerpHue : lerp)(c1, c2, f), m); - }; - function indexOfMax(arr, f) { - let maxValue = -Infinity, maxValueIndex = -1; - for (let i = 0; i < arr.length; i++) { - const value = f(arr[i]); - if (value > maxValue) { - maxValue = value; - maxValueIndex = i; - } - } - return maxValueIndex; - } - function withMax(arr, f) { - return arr[indexOfMax(arr, f)]; - } - - function createCommonjsModule(fn, module) { - return module = { exports: {} }, fn(module, module.exports), module.exports; - } - - var classnames = createCommonjsModule(function (module) { - /*! - Copyright (c) 2017 Jed Watson. - Licensed under the MIT License (MIT), see - http://jedwatson.github.io/classnames - */ - /* global define */ - - (function () { - - var hasOwn = {}.hasOwnProperty; - - function classNames () { - var classes = []; - - for (var i = 0; i < arguments.length; i++) { - var arg = arguments[i]; - if (!arg) continue; - - var argType = typeof arg; - - if (argType === 'string' || argType === 'number') { - classes.push(arg); - } else if (Array.isArray(arg) && arg.length) { - var inner = classNames.apply(null, arg); - if (inner) { - classes.push(inner); - } - } else if (argType === 'object') { - for (var key in arg) { - if (hasOwn.call(arg, key) && arg[key]) { - classes.push(key); - } - } - } - } - - return classes.join(' '); - } - - if ( module.exports) { - classNames.default = classNames; - module.exports = classNames; - } else { - window.classNames = classNames; - } - }()); - }); - - /* - object-assign - (c) Sindre Sorhus - @license MIT - */ - /* eslint-disable no-unused-vars */ - var getOwnPropertySymbols = Object.getOwnPropertySymbols; - var hasOwnProperty = Object.prototype.hasOwnProperty; - var propIsEnumerable = Object.prototype.propertyIsEnumerable; - - function toObject(val) { - if (val === null || val === undefined) { - throw new TypeError('Object.assign cannot be called with null or undefined'); - } - - return Object(val); - } - - function shouldUseNative() { - try { - if (!Object.assign) { - return false; - } - - // Detect buggy property enumeration order in older V8 versions. - - // https://bugs.chromium.org/p/v8/issues/detail?id=4118 - var test1 = new String('abc'); // eslint-disable-line no-new-wrappers - test1[5] = 'de'; - if (Object.getOwnPropertyNames(test1)[0] === '5') { - return false; - } - - // https://bugs.chromium.org/p/v8/issues/detail?id=3056 - var test2 = {}; - for (var i = 0; i < 10; i++) { - test2['_' + String.fromCharCode(i)] = i; - } - var order2 = Object.getOwnPropertyNames(test2).map(function (n) { - return test2[n]; - }); - if (order2.join('') !== '0123456789') { - return false; - } - - // https://bugs.chromium.org/p/v8/issues/detail?id=3056 - var test3 = {}; - 'abcdefghijklmnopqrst'.split('').forEach(function (letter) { - test3[letter] = letter; - }); - if (Object.keys(Object.assign({}, test3)).join('') !== - 'abcdefghijklmnopqrst') { - return false; - } - - return true; - } catch (err) { - // We don't expect any of the above to throw, but better to be safe. - return false; - } - } - - var objectAssign = shouldUseNative() ? Object.assign : function (target, source) { - var from; - var to = toObject(target); - var symbols; - - for (var s = 1; s < arguments.length; s++) { - from = Object(arguments[s]); - - for (var key in from) { - if (hasOwnProperty.call(from, key)) { - to[key] = from[key]; - } - } - - if (getOwnPropertySymbols) { - symbols = getOwnPropertySymbols(from); - for (var i = 0; i < symbols.length; i++) { - if (propIsEnumerable.call(from, symbols[i])) { - to[symbols[i]] = from[symbols[i]]; - } - } - } - } - - return to; - }; - - function C(a){for(var b="https://reactjs.org/docs/error-decoder.html?invariant="+a,c=1;c 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { - args[_key - 1] = arguments[_key]; - } - - printWarning('warn', format, args); - } - } - function error(format) { - { - for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) { - args[_key2 - 1] = arguments[_key2]; - } - - printWarning('error', format, args); - } - } - - function printWarning(level, format, args) { - // When changing this logic, you might want to also - // update consoleWithStackDev.www.js as well. - { - var hasExistingStack = args.length > 0 && typeof args[args.length - 1] === 'string' && args[args.length - 1].indexOf('\n in') === 0; - - if (!hasExistingStack) { - var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame; - var stack = ReactDebugCurrentFrame.getStackAddendum(); - - if (stack !== '') { - format += '%s'; - args = args.concat([stack]); - } - } - - var argsWithFormat = args.map(function (item) { - return '' + item; - }); // Careful: RN currently depends on this prefix - - argsWithFormat.unshift('Warning: ' + format); // We intentionally don't use spread (or .apply) directly because it - // breaks IE9: https://github.com/facebook/react/issues/13610 - // eslint-disable-next-line react-internal/no-production-logging - - Function.prototype.apply.call(console[level], console, argsWithFormat); - - try { - // --- Welcome to debugging React --- - // This error was thrown as a convenience so that you can use this stack - // to find the callsite that caused this warning to fire. - var argIndex = 0; - var message = 'Warning: ' + format.replace(/%s/g, function () { - return args[argIndex++]; - }); - throw new Error(message); - } catch (x) {} - } - } - - var didWarnStateUpdateForUnmountedComponent = {}; - - function warnNoop(publicInstance, callerName) { - { - var _constructor = publicInstance.constructor; - var componentName = _constructor && (_constructor.displayName || _constructor.name) || 'ReactClass'; - var warningKey = componentName + "." + callerName; - - if (didWarnStateUpdateForUnmountedComponent[warningKey]) { - return; - } - - error("Can't call %s on a component that is not yet mounted. " + 'This is a no-op, but it might indicate a bug in your application. ' + 'Instead, assign to `this.state` directly or define a `state = {};` ' + 'class property with the desired state in the %s component.', callerName, componentName); - - didWarnStateUpdateForUnmountedComponent[warningKey] = true; - } - } - /** - * This is the abstract API for an update queue. - */ - - - var ReactNoopUpdateQueue = { - /** - * Checks whether or not this composite component is mounted. - * @param {ReactClass} publicInstance The instance we want to test. - * @return {boolean} True if mounted, false otherwise. - * @protected - * @final - */ - isMounted: function (publicInstance) { - return false; - }, - - /** - * Forces an update. This should only be invoked when it is known with - * certainty that we are **not** in a DOM transaction. - * - * You may want to call this when you know that some deeper aspect of the - * component's state has changed but `setState` was not called. - * - * This will not invoke `shouldComponentUpdate`, but it will invoke - * `componentWillUpdate` and `componentDidUpdate`. - * - * @param {ReactClass} publicInstance The instance that should rerender. - * @param {?function} callback Called after component is updated. - * @param {?string} callerName name of the calling function in the public API. - * @internal - */ - enqueueForceUpdate: function (publicInstance, callback, callerName) { - warnNoop(publicInstance, 'forceUpdate'); - }, - - /** - * Replaces all of the state. Always use this or `setState` to mutate state. - * You should treat `this.state` as immutable. - * - * There is no guarantee that `this.state` will be immediately updated, so - * accessing `this.state` after calling this method may return the old value. - * - * @param {ReactClass} publicInstance The instance that should rerender. - * @param {object} completeState Next state. - * @param {?function} callback Called after component is updated. - * @param {?string} callerName name of the calling function in the public API. - * @internal - */ - enqueueReplaceState: function (publicInstance, completeState, callback, callerName) { - warnNoop(publicInstance, 'replaceState'); - }, - - /** - * Sets a subset of the state. This only exists because _pendingState is - * internal. This provides a merging strategy that is not available to deep - * properties which is confusing. TODO: Expose pendingState or don't use it - * during the merge. - * - * @param {ReactClass} publicInstance The instance that should rerender. - * @param {object} partialState Next partial state to be merged with state. - * @param {?function} callback Called after component is updated. - * @param {?string} Name of the calling function in the public API. - * @internal - */ - enqueueSetState: function (publicInstance, partialState, callback, callerName) { - warnNoop(publicInstance, 'setState'); - } - }; - - var emptyObject = {}; - - { - Object.freeze(emptyObject); - } - /** - * Base class helpers for the updating state of a component. - */ - - - function Component(props, context, updater) { - this.props = props; - this.context = context; // If a component has string refs, we will assign a different object later. - - this.refs = emptyObject; // We initialize the default updater but the real one gets injected by the - // renderer. - - this.updater = updater || ReactNoopUpdateQueue; - } - - Component.prototype.isReactComponent = {}; - /** - * Sets a subset of the state. Always use this to mutate - * state. You should treat `this.state` as immutable. - * - * There is no guarantee that `this.state` will be immediately updated, so - * accessing `this.state` after calling this method may return the old value. - * - * There is no guarantee that calls to `setState` will run synchronously, - * as they may eventually be batched together. You can provide an optional - * callback that will be executed when the call to setState is actually - * completed. - * - * When a function is provided to setState, it will be called at some point in - * the future (not synchronously). It will be called with the up to date - * component arguments (state, props, context). These values can be different - * from this.* because your function may be called after receiveProps but before - * shouldComponentUpdate, and this new state, props, and context will not yet be - * assigned to this. - * - * @param {object|function} partialState Next partial state or function to - * produce next partial state to be merged with current state. - * @param {?function} callback Called after state is updated. - * @final - * @protected - */ - - Component.prototype.setState = function (partialState, callback) { - if (!(typeof partialState === 'object' || typeof partialState === 'function' || partialState == null)) { - { - throw Error( "setState(...): takes an object of state variables to update or a function which returns an object of state variables." ); - } - } - - this.updater.enqueueSetState(this, partialState, callback, 'setState'); - }; - /** - * Forces an update. This should only be invoked when it is known with - * certainty that we are **not** in a DOM transaction. - * - * You may want to call this when you know that some deeper aspect of the - * component's state has changed but `setState` was not called. - * - * This will not invoke `shouldComponentUpdate`, but it will invoke - * `componentWillUpdate` and `componentDidUpdate`. - * - * @param {?function} callback Called after update is complete. - * @final - * @protected - */ - - - Component.prototype.forceUpdate = function (callback) { - this.updater.enqueueForceUpdate(this, callback, 'forceUpdate'); - }; - /** - * Deprecated APIs. These APIs used to exist on classic React classes but since - * we would like to deprecate them, we're not going to move them over to this - * modern base class. Instead, we define a getter that warns if it's accessed. - */ - - - { - var deprecatedAPIs = { - isMounted: ['isMounted', 'Instead, make sure to clean up subscriptions and pending requests in ' + 'componentWillUnmount to prevent memory leaks.'], - replaceState: ['replaceState', 'Refactor your code to use setState instead (see ' + 'https://github.com/facebook/react/issues/3236).'] - }; - - var defineDeprecationWarning = function (methodName, info) { - Object.defineProperty(Component.prototype, methodName, { - get: function () { - warn('%s(...) is deprecated in plain JavaScript React classes. %s', info[0], info[1]); - - return undefined; - } - }); - }; - - for (var fnName in deprecatedAPIs) { - if (deprecatedAPIs.hasOwnProperty(fnName)) { - defineDeprecationWarning(fnName, deprecatedAPIs[fnName]); - } - } - } - - function ComponentDummy() {} - - ComponentDummy.prototype = Component.prototype; - /** - * Convenience component with default shallow equality check for sCU. - */ - - function PureComponent(props, context, updater) { - this.props = props; - this.context = context; // If a component has string refs, we will assign a different object later. - - this.refs = emptyObject; - this.updater = updater || ReactNoopUpdateQueue; - } - - var pureComponentPrototype = PureComponent.prototype = new ComponentDummy(); - pureComponentPrototype.constructor = PureComponent; // Avoid an extra prototype jump for these methods. - - _assign(pureComponentPrototype, Component.prototype); - - pureComponentPrototype.isPureReactComponent = true; - - // an immutable object with a single mutable value - function createRef() { - var refObject = { - current: null - }; - - { - Object.seal(refObject); - } - - return refObject; - } - - var hasOwnProperty = Object.prototype.hasOwnProperty; - var RESERVED_PROPS = { - key: true, - ref: true, - __self: true, - __source: true - }; - var specialPropKeyWarningShown, specialPropRefWarningShown, didWarnAboutStringRefs; - - { - didWarnAboutStringRefs = {}; - } - - function hasValidRef(config) { - { - if (hasOwnProperty.call(config, 'ref')) { - var getter = Object.getOwnPropertyDescriptor(config, 'ref').get; - - if (getter && getter.isReactWarning) { - return false; - } - } - } - - return config.ref !== undefined; - } - - function hasValidKey(config) { - { - if (hasOwnProperty.call(config, 'key')) { - var getter = Object.getOwnPropertyDescriptor(config, 'key').get; - - if (getter && getter.isReactWarning) { - return false; - } - } - } - - return config.key !== undefined; - } - - function defineKeyPropWarningGetter(props, displayName) { - var warnAboutAccessingKey = function () { - { - if (!specialPropKeyWarningShown) { - specialPropKeyWarningShown = true; - - error('%s: `key` is not a prop. Trying to access it will result ' + 'in `undefined` being returned. If you need to access the same ' + 'value within the child component, you should pass it as a different ' + 'prop. (https://fb.me/react-special-props)', displayName); - } - } - }; - - warnAboutAccessingKey.isReactWarning = true; - Object.defineProperty(props, 'key', { - get: warnAboutAccessingKey, - configurable: true - }); - } - - function defineRefPropWarningGetter(props, displayName) { - var warnAboutAccessingRef = function () { - { - if (!specialPropRefWarningShown) { - specialPropRefWarningShown = true; - - error('%s: `ref` is not a prop. Trying to access it will result ' + 'in `undefined` being returned. If you need to access the same ' + 'value within the child component, you should pass it as a different ' + 'prop. (https://fb.me/react-special-props)', displayName); - } - } - }; - - warnAboutAccessingRef.isReactWarning = true; - Object.defineProperty(props, 'ref', { - get: warnAboutAccessingRef, - configurable: true - }); - } - - function warnIfStringRefCannotBeAutoConverted(config) { - { - if (typeof config.ref === 'string' && ReactCurrentOwner.current && config.__self && ReactCurrentOwner.current.stateNode !== config.__self) { - var componentName = getComponentName(ReactCurrentOwner.current.type); - - if (!didWarnAboutStringRefs[componentName]) { - error('Component "%s" contains the string ref "%s". ' + 'Support for string refs will be removed in a future major release. ' + 'This case cannot be automatically converted to an arrow function. ' + 'We ask you to manually fix this case by using useRef() or createRef() instead. ' + 'Learn more about using refs safely here: ' + 'https://fb.me/react-strict-mode-string-ref', getComponentName(ReactCurrentOwner.current.type), config.ref); - - didWarnAboutStringRefs[componentName] = true; - } - } - } - } - /** - * Factory method to create a new React element. This no longer adheres to - * the class pattern, so do not use new to call it. Also, instanceof check - * will not work. Instead test $$typeof field against Symbol.for('react.element') to check - * if something is a React Element. - * - * @param {*} type - * @param {*} props - * @param {*} key - * @param {string|object} ref - * @param {*} owner - * @param {*} self A *temporary* helper to detect places where `this` is - * different from the `owner` when React.createElement is called, so that we - * can warn. We want to get rid of owner and replace string `ref`s with arrow - * functions, and as long as `this` and owner are the same, there will be no - * change in behavior. - * @param {*} source An annotation object (added by a transpiler or otherwise) - * indicating filename, line number, and/or other information. - * @internal - */ - - - var ReactElement = function (type, key, ref, self, source, owner, props) { - var element = { - // This tag allows us to uniquely identify this as a React Element - $$typeof: REACT_ELEMENT_TYPE, - // Built-in properties that belong on the element - type: type, - key: key, - ref: ref, - props: props, - // Record the component responsible for creating this element. - _owner: owner - }; - - { - // The validation flag is currently mutative. We put it on - // an external backing store so that we can freeze the whole object. - // This can be replaced with a WeakMap once they are implemented in - // commonly used development environments. - element._store = {}; // To make comparing ReactElements easier for testing purposes, we make - // the validation flag non-enumerable (where possible, which should - // include every environment we run tests in), so the test framework - // ignores it. - - Object.defineProperty(element._store, 'validated', { - configurable: false, - enumerable: false, - writable: true, - value: false - }); // self and source are DEV only properties. - - Object.defineProperty(element, '_self', { - configurable: false, - enumerable: false, - writable: false, - value: self - }); // Two elements created in two different places should be considered - // equal for testing purposes and therefore we hide it from enumeration. - - Object.defineProperty(element, '_source', { - configurable: false, - enumerable: false, - writable: false, - value: source - }); - - if (Object.freeze) { - Object.freeze(element.props); - Object.freeze(element); - } - } - - return element; - }; - /** - * Create and return a new ReactElement of the given type. - * See https://reactjs.org/docs/react-api.html#createelement - */ - - function createElement(type, config, children) { - var propName; // Reserved names are extracted - - var props = {}; - var key = null; - var ref = null; - var self = null; - var source = null; - - if (config != null) { - if (hasValidRef(config)) { - ref = config.ref; - - { - warnIfStringRefCannotBeAutoConverted(config); - } - } - - if (hasValidKey(config)) { - key = '' + config.key; - } - - self = config.__self === undefined ? null : config.__self; - source = config.__source === undefined ? null : config.__source; // Remaining properties are added to a new props object - - for (propName in config) { - if (hasOwnProperty.call(config, propName) && !RESERVED_PROPS.hasOwnProperty(propName)) { - props[propName] = config[propName]; - } - } - } // Children can be more than one argument, and those are transferred onto - // the newly allocated props object. - - - var childrenLength = arguments.length - 2; - - if (childrenLength === 1) { - props.children = children; - } else if (childrenLength > 1) { - var childArray = Array(childrenLength); - - for (var i = 0; i < childrenLength; i++) { - childArray[i] = arguments[i + 2]; - } - - { - if (Object.freeze) { - Object.freeze(childArray); - } - } - - props.children = childArray; - } // Resolve default props - - - if (type && type.defaultProps) { - var defaultProps = type.defaultProps; - - for (propName in defaultProps) { - if (props[propName] === undefined) { - props[propName] = defaultProps[propName]; - } - } - } - - { - if (key || ref) { - var displayName = typeof type === 'function' ? type.displayName || type.name || 'Unknown' : type; - - if (key) { - defineKeyPropWarningGetter(props, displayName); - } - - if (ref) { - defineRefPropWarningGetter(props, displayName); - } - } - } - - return ReactElement(type, key, ref, self, source, ReactCurrentOwner.current, props); - } - function cloneAndReplaceKey(oldElement, newKey) { - var newElement = ReactElement(oldElement.type, newKey, oldElement.ref, oldElement._self, oldElement._source, oldElement._owner, oldElement.props); - return newElement; - } - /** - * Clone and return a new ReactElement using element as the starting point. - * See https://reactjs.org/docs/react-api.html#cloneelement - */ - - function cloneElement(element, config, children) { - if (!!(element === null || element === undefined)) { - { - throw Error( "React.cloneElement(...): The argument must be a React element, but you passed " + element + "." ); - } - } - - var propName; // Original props are copied - - var props = _assign({}, element.props); // Reserved names are extracted - - - var key = element.key; - var ref = element.ref; // Self is preserved since the owner is preserved. - - var self = element._self; // Source is preserved since cloneElement is unlikely to be targeted by a - // transpiler, and the original source is probably a better indicator of the - // true owner. - - var source = element._source; // Owner will be preserved, unless ref is overridden - - var owner = element._owner; - - if (config != null) { - if (hasValidRef(config)) { - // Silently steal the ref from the parent. - ref = config.ref; - owner = ReactCurrentOwner.current; - } - - if (hasValidKey(config)) { - key = '' + config.key; - } // Remaining properties override existing props - - - var defaultProps; - - if (element.type && element.type.defaultProps) { - defaultProps = element.type.defaultProps; - } - - for (propName in config) { - if (hasOwnProperty.call(config, propName) && !RESERVED_PROPS.hasOwnProperty(propName)) { - if (config[propName] === undefined && defaultProps !== undefined) { - // Resolve default props - props[propName] = defaultProps[propName]; - } else { - props[propName] = config[propName]; - } - } - } - } // Children can be more than one argument, and those are transferred onto - // the newly allocated props object. - - - var childrenLength = arguments.length - 2; - - if (childrenLength === 1) { - props.children = children; - } else if (childrenLength > 1) { - var childArray = Array(childrenLength); - - for (var i = 0; i < childrenLength; i++) { - childArray[i] = arguments[i + 2]; - } - - props.children = childArray; - } - - return ReactElement(element.type, key, ref, self, source, owner, props); - } - /** - * Verifies the object is a ReactElement. - * See https://reactjs.org/docs/react-api.html#isvalidelement - * @param {?object} object - * @return {boolean} True if `object` is a ReactElement. - * @final - */ - - function isValidElement(object) { - return typeof object === 'object' && object !== null && object.$$typeof === REACT_ELEMENT_TYPE; - } - - var SEPARATOR = '.'; - var SUBSEPARATOR = ':'; - /** - * Escape and wrap key so it is safe to use as a reactid - * - * @param {string} key to be escaped. - * @return {string} the escaped key. - */ - - function escape(key) { - var escapeRegex = /[=:]/g; - var escaperLookup = { - '=': '=0', - ':': '=2' - }; - var escapedString = ('' + key).replace(escapeRegex, function (match) { - return escaperLookup[match]; - }); - return '$' + escapedString; - } - /** - * TODO: Test that a single child and an array with one item have the same key - * pattern. - */ - - - var didWarnAboutMaps = false; - var userProvidedKeyEscapeRegex = /\/+/g; - - function escapeUserProvidedKey(text) { - return ('' + text).replace(userProvidedKeyEscapeRegex, '$&/'); - } - - var POOL_SIZE = 10; - var traverseContextPool = []; - - function getPooledTraverseContext(mapResult, keyPrefix, mapFunction, mapContext) { - if (traverseContextPool.length) { - var traverseContext = traverseContextPool.pop(); - traverseContext.result = mapResult; - traverseContext.keyPrefix = keyPrefix; - traverseContext.func = mapFunction; - traverseContext.context = mapContext; - traverseContext.count = 0; - return traverseContext; - } else { - return { - result: mapResult, - keyPrefix: keyPrefix, - func: mapFunction, - context: mapContext, - count: 0 - }; - } - } - - function releaseTraverseContext(traverseContext) { - traverseContext.result = null; - traverseContext.keyPrefix = null; - traverseContext.func = null; - traverseContext.context = null; - traverseContext.count = 0; - - if (traverseContextPool.length < POOL_SIZE) { - traverseContextPool.push(traverseContext); - } - } - /** - * @param {?*} children Children tree container. - * @param {!string} nameSoFar Name of the key path so far. - * @param {!function} callback Callback to invoke with each child found. - * @param {?*} traverseContext Used to pass information throughout the traversal - * process. - * @return {!number} The number of children in this subtree. - */ - - - function traverseAllChildrenImpl(children, nameSoFar, callback, traverseContext) { - var type = typeof children; - - if (type === 'undefined' || type === 'boolean') { - // All of the above are perceived as null. - children = null; - } - - var invokeCallback = false; - - if (children === null) { - invokeCallback = true; - } else { - switch (type) { - case 'string': - case 'number': - invokeCallback = true; - break; - - case 'object': - switch (children.$$typeof) { - case REACT_ELEMENT_TYPE: - case REACT_PORTAL_TYPE: - invokeCallback = true; - } - - } - } - - if (invokeCallback) { - callback(traverseContext, children, // If it's the only child, treat the name as if it was wrapped in an array - // so that it's consistent if the number of children grows. - nameSoFar === '' ? SEPARATOR + getComponentKey(children, 0) : nameSoFar); - return 1; - } - - var child; - var nextName; - var subtreeCount = 0; // Count of children found in the current subtree. - - var nextNamePrefix = nameSoFar === '' ? SEPARATOR : nameSoFar + SUBSEPARATOR; - - if (Array.isArray(children)) { - for (var i = 0; i < children.length; i++) { - child = children[i]; - nextName = nextNamePrefix + getComponentKey(child, i); - subtreeCount += traverseAllChildrenImpl(child, nextName, callback, traverseContext); - } - } else { - var iteratorFn = getIteratorFn(children); - - if (typeof iteratorFn === 'function') { - - { - // Warn about using Maps as children - if (iteratorFn === children.entries) { - if (!didWarnAboutMaps) { - warn('Using Maps as children is deprecated and will be removed in ' + 'a future major release. Consider converting children to ' + 'an array of keyed ReactElements instead.'); - } - - didWarnAboutMaps = true; - } - } - - var iterator = iteratorFn.call(children); - var step; - var ii = 0; - - while (!(step = iterator.next()).done) { - child = step.value; - nextName = nextNamePrefix + getComponentKey(child, ii++); - subtreeCount += traverseAllChildrenImpl(child, nextName, callback, traverseContext); - } - } else if (type === 'object') { - var addendum = ''; - - { - addendum = ' If you meant to render a collection of children, use an array ' + 'instead.' + ReactDebugCurrentFrame.getStackAddendum(); - } - - var childrenString = '' + children; - - { - { - throw Error( "Objects are not valid as a React child (found: " + (childrenString === '[object Object]' ? 'object with keys {' + Object.keys(children).join(', ') + '}' : childrenString) + ")." + addendum ); - } - } - } - } - - return subtreeCount; - } - /** - * Traverses children that are typically specified as `props.children`, but - * might also be specified through attributes: - * - * - `traverseAllChildren(this.props.children, ...)` - * - `traverseAllChildren(this.props.leftPanelChildren, ...)` - * - * The `traverseContext` is an optional argument that is passed through the - * entire traversal. It can be used to store accumulations or anything else that - * the callback might find relevant. - * - * @param {?*} children Children tree object. - * @param {!function} callback To invoke upon traversing each child. - * @param {?*} traverseContext Context for traversal. - * @return {!number} The number of children in this subtree. - */ - - - function traverseAllChildren(children, callback, traverseContext) { - if (children == null) { - return 0; - } - - return traverseAllChildrenImpl(children, '', callback, traverseContext); - } - /** - * Generate a key string that identifies a component within a set. - * - * @param {*} component A component that could contain a manual key. - * @param {number} index Index that is used if a manual key is not provided. - * @return {string} - */ - - - function getComponentKey(component, index) { - // Do some typechecking here since we call this blindly. We want to ensure - // that we don't block potential future ES APIs. - if (typeof component === 'object' && component !== null && component.key != null) { - // Explicit key - return escape(component.key); - } // Implicit key determined by the index in the set - - - return index.toString(36); - } - - function forEachSingleChild(bookKeeping, child, name) { - var func = bookKeeping.func, - context = bookKeeping.context; - func.call(context, child, bookKeeping.count++); - } - /** - * Iterates through children that are typically specified as `props.children`. - * - * See https://reactjs.org/docs/react-api.html#reactchildrenforeach - * - * The provided forEachFunc(child, index) will be called for each - * leaf child. - * - * @param {?*} children Children tree container. - * @param {function(*, int)} forEachFunc - * @param {*} forEachContext Context for forEachContext. - */ - - - function forEachChildren(children, forEachFunc, forEachContext) { - if (children == null) { - return children; - } - - var traverseContext = getPooledTraverseContext(null, null, forEachFunc, forEachContext); - traverseAllChildren(children, forEachSingleChild, traverseContext); - releaseTraverseContext(traverseContext); - } - - function mapSingleChildIntoContext(bookKeeping, child, childKey) { - var result = bookKeeping.result, - keyPrefix = bookKeeping.keyPrefix, - func = bookKeeping.func, - context = bookKeeping.context; - var mappedChild = func.call(context, child, bookKeeping.count++); - - if (Array.isArray(mappedChild)) { - mapIntoWithKeyPrefixInternal(mappedChild, result, childKey, function (c) { - return c; - }); - } else if (mappedChild != null) { - if (isValidElement(mappedChild)) { - mappedChild = cloneAndReplaceKey(mappedChild, // Keep both the (mapped) and old keys if they differ, just as - // traverseAllChildren used to do for objects as children - keyPrefix + (mappedChild.key && (!child || child.key !== mappedChild.key) ? escapeUserProvidedKey(mappedChild.key) + '/' : '') + childKey); - } - - result.push(mappedChild); - } - } - - function mapIntoWithKeyPrefixInternal(children, array, prefix, func, context) { - var escapedPrefix = ''; - - if (prefix != null) { - escapedPrefix = escapeUserProvidedKey(prefix) + '/'; - } - - var traverseContext = getPooledTraverseContext(array, escapedPrefix, func, context); - traverseAllChildren(children, mapSingleChildIntoContext, traverseContext); - releaseTraverseContext(traverseContext); - } - /** - * Maps children that are typically specified as `props.children`. - * - * See https://reactjs.org/docs/react-api.html#reactchildrenmap - * - * The provided mapFunction(child, key, index) will be called for each - * leaf child. - * - * @param {?*} children Children tree container. - * @param {function(*, int)} func The map function. - * @param {*} context Context for mapFunction. - * @return {object} Object containing the ordered map of results. - */ - - - function mapChildren(children, func, context) { - if (children == null) { - return children; - } - - var result = []; - mapIntoWithKeyPrefixInternal(children, result, null, func, context); - return result; - } - /** - * Count the number of children that are typically specified as - * `props.children`. - * - * See https://reactjs.org/docs/react-api.html#reactchildrencount - * - * @param {?*} children Children tree container. - * @return {number} The number of children. - */ - - - function countChildren(children) { - return traverseAllChildren(children, function () { - return null; - }, null); - } - /** - * Flatten a children object (typically specified as `props.children`) and - * return an array with appropriately re-keyed children. - * - * See https://reactjs.org/docs/react-api.html#reactchildrentoarray - */ - - - function toArray(children) { - var result = []; - mapIntoWithKeyPrefixInternal(children, result, null, function (child) { - return child; - }); - return result; - } - /** - * Returns the first child in a collection of children and verifies that there - * is only one child in the collection. - * - * See https://reactjs.org/docs/react-api.html#reactchildrenonly - * - * The current implementation of this function assumes that a single child gets - * passed without a wrapper, but the purpose of this helper function is to - * abstract away the particular structure of children. - * - * @param {?object} children Child collection structure. - * @return {ReactElement} The first and only `ReactElement` contained in the - * structure. - */ - - - function onlyChild(children) { - if (!isValidElement(children)) { - { - throw Error( "React.Children.only expected to receive a single React element child." ); - } - } - - return children; - } - - function createContext(defaultValue, calculateChangedBits) { - if (calculateChangedBits === undefined) { - calculateChangedBits = null; - } else { - { - if (calculateChangedBits !== null && typeof calculateChangedBits !== 'function') { - error('createContext: Expected the optional second argument to be a ' + 'function. Instead received: %s', calculateChangedBits); - } - } - } - - var context = { - $$typeof: REACT_CONTEXT_TYPE, - _calculateChangedBits: calculateChangedBits, - // As a workaround to support multiple concurrent renderers, we categorize - // some renderers as primary and others as secondary. We only expect - // there to be two concurrent renderers at most: React Native (primary) and - // Fabric (secondary); React DOM (primary) and React ART (secondary). - // Secondary renderers store their context values on separate fields. - _currentValue: defaultValue, - _currentValue2: defaultValue, - // Used to track how many concurrent renderers this context currently - // supports within in a single renderer. Such as parallel server rendering. - _threadCount: 0, - // These are circular - Provider: null, - Consumer: null - }; - context.Provider = { - $$typeof: REACT_PROVIDER_TYPE, - _context: context - }; - var hasWarnedAboutUsingNestedContextConsumers = false; - var hasWarnedAboutUsingConsumerProvider = false; - - { - // A separate object, but proxies back to the original context object for - // backwards compatibility. It has a different $$typeof, so we can properly - // warn for the incorrect usage of Context as a Consumer. - var Consumer = { - $$typeof: REACT_CONTEXT_TYPE, - _context: context, - _calculateChangedBits: context._calculateChangedBits - }; // $FlowFixMe: Flow complains about not setting a value, which is intentional here - - Object.defineProperties(Consumer, { - Provider: { - get: function () { - if (!hasWarnedAboutUsingConsumerProvider) { - hasWarnedAboutUsingConsumerProvider = true; - - error('Rendering is not supported and will be removed in ' + 'a future major release. Did you mean to render instead?'); - } - - return context.Provider; - }, - set: function (_Provider) { - context.Provider = _Provider; - } - }, - _currentValue: { - get: function () { - return context._currentValue; - }, - set: function (_currentValue) { - context._currentValue = _currentValue; - } - }, - _currentValue2: { - get: function () { - return context._currentValue2; - }, - set: function (_currentValue2) { - context._currentValue2 = _currentValue2; - } - }, - _threadCount: { - get: function () { - return context._threadCount; - }, - set: function (_threadCount) { - context._threadCount = _threadCount; - } - }, - Consumer: { - get: function () { - if (!hasWarnedAboutUsingNestedContextConsumers) { - hasWarnedAboutUsingNestedContextConsumers = true; - - error('Rendering is not supported and will be removed in ' + 'a future major release. Did you mean to render instead?'); - } - - return context.Consumer; - } - } - }); // $FlowFixMe: Flow complains about missing properties because it doesn't understand defineProperty - - context.Consumer = Consumer; - } - - { - context._currentRenderer = null; - context._currentRenderer2 = null; - } - - return context; - } - - function lazy(ctor) { - var lazyType = { - $$typeof: REACT_LAZY_TYPE, - _ctor: ctor, - // React uses these fields to store the result. - _status: -1, - _result: null - }; - - { - // In production, this would just set it on the object. - var defaultProps; - var propTypes; - Object.defineProperties(lazyType, { - defaultProps: { - configurable: true, - get: function () { - return defaultProps; - }, - set: function (newDefaultProps) { - error('React.lazy(...): It is not supported to assign `defaultProps` to ' + 'a lazy component import. Either specify them where the component ' + 'is defined, or create a wrapping component around it.'); - - defaultProps = newDefaultProps; // Match production behavior more closely: - - Object.defineProperty(lazyType, 'defaultProps', { - enumerable: true - }); - } - }, - propTypes: { - configurable: true, - get: function () { - return propTypes; - }, - set: function (newPropTypes) { - error('React.lazy(...): It is not supported to assign `propTypes` to ' + 'a lazy component import. Either specify them where the component ' + 'is defined, or create a wrapping component around it.'); - - propTypes = newPropTypes; // Match production behavior more closely: - - Object.defineProperty(lazyType, 'propTypes', { - enumerable: true - }); - } - } - }); - } - - return lazyType; - } - - function forwardRef(render) { - { - if (render != null && render.$$typeof === REACT_MEMO_TYPE) { - error('forwardRef requires a render function but received a `memo` ' + 'component. Instead of forwardRef(memo(...)), use ' + 'memo(forwardRef(...)).'); - } else if (typeof render !== 'function') { - error('forwardRef requires a render function but was given %s.', render === null ? 'null' : typeof render); - } else { - if (render.length !== 0 && render.length !== 2) { - error('forwardRef render functions accept exactly two parameters: props and ref. %s', render.length === 1 ? 'Did you forget to use the ref parameter?' : 'Any additional parameter will be undefined.'); - } - } - - if (render != null) { - if (render.defaultProps != null || render.propTypes != null) { - error('forwardRef render functions do not support propTypes or defaultProps. ' + 'Did you accidentally pass a React component?'); - } - } - } - - return { - $$typeof: REACT_FORWARD_REF_TYPE, - render: render - }; - } - - function isValidElementType(type) { - return typeof type === 'string' || typeof type === 'function' || // Note: its typeof might be other than 'symbol' or 'number' if it's a polyfill. - type === REACT_FRAGMENT_TYPE || type === REACT_CONCURRENT_MODE_TYPE || type === REACT_PROFILER_TYPE || type === REACT_STRICT_MODE_TYPE || type === REACT_SUSPENSE_TYPE || type === REACT_SUSPENSE_LIST_TYPE || typeof type === 'object' && type !== null && (type.$$typeof === REACT_LAZY_TYPE || type.$$typeof === REACT_MEMO_TYPE || type.$$typeof === REACT_PROVIDER_TYPE || type.$$typeof === REACT_CONTEXT_TYPE || type.$$typeof === REACT_FORWARD_REF_TYPE || type.$$typeof === REACT_FUNDAMENTAL_TYPE || type.$$typeof === REACT_RESPONDER_TYPE || type.$$typeof === REACT_SCOPE_TYPE || type.$$typeof === REACT_BLOCK_TYPE); - } - - function memo(type, compare) { - { - if (!isValidElementType(type)) { - error('memo: The first argument must be a component. Instead ' + 'received: %s', type === null ? 'null' : typeof type); - } - } - - return { - $$typeof: REACT_MEMO_TYPE, - type: type, - compare: compare === undefined ? null : compare - }; - } - - function resolveDispatcher() { - var dispatcher = ReactCurrentDispatcher.current; - - if (!(dispatcher !== null)) { - { - throw Error( "Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:\n1. You might have mismatching versions of React and the renderer (such as React DOM)\n2. You might be breaking the Rules of Hooks\n3. You might have more than one copy of React in the same app\nSee https://fb.me/react-invalid-hook-call for tips about how to debug and fix this problem." ); - } - } - - return dispatcher; - } - - function useContext(Context, unstable_observedBits) { - var dispatcher = resolveDispatcher(); - - { - if (unstable_observedBits !== undefined) { - error('useContext() second argument is reserved for future ' + 'use in React. Passing it is not supported. ' + 'You passed: %s.%s', unstable_observedBits, typeof unstable_observedBits === 'number' && Array.isArray(arguments[2]) ? '\n\nDid you call array.map(useContext)? ' + 'Calling Hooks inside a loop is not supported. ' + 'Learn more at https://fb.me/rules-of-hooks' : ''); - } // TODO: add a more generic warning for invalid values. - - - if (Context._context !== undefined) { - var realContext = Context._context; // Don't deduplicate because this legitimately causes bugs - // and nobody should be using this in existing code. - - if (realContext.Consumer === Context) { - error('Calling useContext(Context.Consumer) is not supported, may cause bugs, and will be ' + 'removed in a future major release. Did you mean to call useContext(Context) instead?'); - } else if (realContext.Provider === Context) { - error('Calling useContext(Context.Provider) is not supported. ' + 'Did you mean to call useContext(Context) instead?'); - } - } - } - - return dispatcher.useContext(Context, unstable_observedBits); - } - function useState(initialState) { - var dispatcher = resolveDispatcher(); - return dispatcher.useState(initialState); - } - function useReducer(reducer, initialArg, init) { - var dispatcher = resolveDispatcher(); - return dispatcher.useReducer(reducer, initialArg, init); - } - function useRef(initialValue) { - var dispatcher = resolveDispatcher(); - return dispatcher.useRef(initialValue); - } - function useEffect(create, deps) { - var dispatcher = resolveDispatcher(); - return dispatcher.useEffect(create, deps); - } - function useLayoutEffect(create, deps) { - var dispatcher = resolveDispatcher(); - return dispatcher.useLayoutEffect(create, deps); - } - function useCallback(callback, deps) { - var dispatcher = resolveDispatcher(); - return dispatcher.useCallback(callback, deps); - } - function useMemo(create, deps) { - var dispatcher = resolveDispatcher(); - return dispatcher.useMemo(create, deps); - } - function useImperativeHandle(ref, create, deps) { - var dispatcher = resolveDispatcher(); - return dispatcher.useImperativeHandle(ref, create, deps); - } - function useDebugValue(value, formatterFn) { - { - var dispatcher = resolveDispatcher(); - return dispatcher.useDebugValue(value, formatterFn); - } - } - - var propTypesMisspellWarningShown; - - { - propTypesMisspellWarningShown = false; - } - - function getDeclarationErrorAddendum() { - if (ReactCurrentOwner.current) { - var name = getComponentName(ReactCurrentOwner.current.type); - - if (name) { - return '\n\nCheck the render method of `' + name + '`.'; - } - } - - return ''; - } - - function getSourceInfoErrorAddendum(source) { - if (source !== undefined) { - var fileName = source.fileName.replace(/^.*[\\\/]/, ''); - var lineNumber = source.lineNumber; - return '\n\nCheck your code at ' + fileName + ':' + lineNumber + '.'; - } - - return ''; - } - - function getSourceInfoErrorAddendumForProps(elementProps) { - if (elementProps !== null && elementProps !== undefined) { - return getSourceInfoErrorAddendum(elementProps.__source); - } - - return ''; - } - /** - * Warn if there's no key explicitly set on dynamic arrays of children or - * object keys are not valid. This allows us to keep track of children between - * updates. - */ - - - var ownerHasKeyUseWarning = {}; - - function getCurrentComponentErrorInfo(parentType) { - var info = getDeclarationErrorAddendum(); - - if (!info) { - var parentName = typeof parentType === 'string' ? parentType : parentType.displayName || parentType.name; - - if (parentName) { - info = "\n\nCheck the top-level render call using <" + parentName + ">."; - } - } - - return info; - } - /** - * Warn if the element doesn't have an explicit key assigned to it. - * This element is in an array. The array could grow and shrink or be - * reordered. All children that haven't already been validated are required to - * have a "key" property assigned to it. Error statuses are cached so a warning - * will only be shown once. - * - * @internal - * @param {ReactElement} element Element that requires a key. - * @param {*} parentType element's parent's type. - */ - - - function validateExplicitKey(element, parentType) { - if (!element._store || element._store.validated || element.key != null) { - return; - } - - element._store.validated = true; - var currentComponentErrorInfo = getCurrentComponentErrorInfo(parentType); - - if (ownerHasKeyUseWarning[currentComponentErrorInfo]) { - return; - } - - ownerHasKeyUseWarning[currentComponentErrorInfo] = true; // Usually the current owner is the offender, but if it accepts children as a - // property, it may be the creator of the child that's responsible for - // assigning it a key. - - var childOwner = ''; - - if (element && element._owner && element._owner !== ReactCurrentOwner.current) { - // Give the component that originally created this child. - childOwner = " It was passed a child from " + getComponentName(element._owner.type) + "."; - } - - setCurrentlyValidatingElement(element); - - { - error('Each child in a list should have a unique "key" prop.' + '%s%s See https://fb.me/react-warning-keys for more information.', currentComponentErrorInfo, childOwner); - } - - setCurrentlyValidatingElement(null); - } - /** - * Ensure that every element either is passed in a static location, in an - * array with an explicit keys property defined, or in an object literal - * with valid key property. - * - * @internal - * @param {ReactNode} node Statically passed child of any type. - * @param {*} parentType node's parent's type. - */ - - - function validateChildKeys(node, parentType) { - if (typeof node !== 'object') { - return; - } - - if (Array.isArray(node)) { - for (var i = 0; i < node.length; i++) { - var child = node[i]; - - if (isValidElement(child)) { - validateExplicitKey(child, parentType); - } - } - } else if (isValidElement(node)) { - // This element was passed in a valid location. - if (node._store) { - node._store.validated = true; - } - } else if (node) { - var iteratorFn = getIteratorFn(node); - - if (typeof iteratorFn === 'function') { - // Entry iterators used to provide implicit keys, - // but now we print a separate warning for them later. - if (iteratorFn !== node.entries) { - var iterator = iteratorFn.call(node); - var step; - - while (!(step = iterator.next()).done) { - if (isValidElement(step.value)) { - validateExplicitKey(step.value, parentType); - } - } - } - } - } - } - /** - * Given an element, validate that its props follow the propTypes definition, - * provided by the type. - * - * @param {ReactElement} element - */ - - - function validatePropTypes(element) { - { - var type = element.type; - - if (type === null || type === undefined || typeof type === 'string') { - return; - } - - var name = getComponentName(type); - var propTypes; - - if (typeof type === 'function') { - propTypes = type.propTypes; - } else if (typeof type === 'object' && (type.$$typeof === REACT_FORWARD_REF_TYPE || // Note: Memo only checks outer props here. - // Inner props are checked in the reconciler. - type.$$typeof === REACT_MEMO_TYPE)) { - propTypes = type.propTypes; - } else { - return; - } - - if (propTypes) { - setCurrentlyValidatingElement(element); - checkPropTypes(propTypes, element.props, 'prop', name, ReactDebugCurrentFrame.getStackAddendum); - setCurrentlyValidatingElement(null); - } else if (type.PropTypes !== undefined && !propTypesMisspellWarningShown) { - propTypesMisspellWarningShown = true; - - error('Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?', name || 'Unknown'); - } - - if (typeof type.getDefaultProps === 'function' && !type.getDefaultProps.isReactClassApproved) { - error('getDefaultProps is only used on classic React.createClass ' + 'definitions. Use a static property named `defaultProps` instead.'); - } - } - } - /** - * Given a fragment, validate that it can only be provided with fragment props - * @param {ReactElement} fragment - */ - - - function validateFragmentProps(fragment) { - { - setCurrentlyValidatingElement(fragment); - var keys = Object.keys(fragment.props); - - for (var i = 0; i < keys.length; i++) { - var key = keys[i]; - - if (key !== 'children' && key !== 'key') { - error('Invalid prop `%s` supplied to `React.Fragment`. ' + 'React.Fragment can only have `key` and `children` props.', key); - - break; - } - } - - if (fragment.ref !== null) { - error('Invalid attribute `ref` supplied to `React.Fragment`.'); - } - - setCurrentlyValidatingElement(null); - } - } - function createElementWithValidation(type, props, children) { - var validType = isValidElementType(type); // We warn in this case but don't throw. We expect the element creation to - // succeed and there will likely be errors in render. - - if (!validType) { - var info = ''; - - if (type === undefined || typeof type === 'object' && type !== null && Object.keys(type).length === 0) { - info += ' You likely forgot to export your component from the file ' + "it's defined in, or you might have mixed up default and named imports."; - } - - var sourceInfo = getSourceInfoErrorAddendumForProps(props); - - if (sourceInfo) { - info += sourceInfo; - } else { - info += getDeclarationErrorAddendum(); - } - - var typeString; - - if (type === null) { - typeString = 'null'; - } else if (Array.isArray(type)) { - typeString = 'array'; - } else if (type !== undefined && type.$$typeof === REACT_ELEMENT_TYPE) { - typeString = "<" + (getComponentName(type.type) || 'Unknown') + " />"; - info = ' Did you accidentally export a JSX literal instead of a component?'; - } else { - typeString = typeof type; - } - - { - error('React.createElement: type is invalid -- expected a string (for ' + 'built-in components) or a class/function (for composite ' + 'components) but got: %s.%s', typeString, info); - } - } - - var element = createElement.apply(this, arguments); // The result can be nullish if a mock or a custom function is used. - // TODO: Drop this when these are no longer allowed as the type argument. - - if (element == null) { - return element; - } // Skip key warning if the type isn't valid since our key validation logic - // doesn't expect a non-string/function type and can throw confusing errors. - // We don't want exception behavior to differ between dev and prod. - // (Rendering will throw with a helpful message and as soon as the type is - // fixed, the key warnings will appear.) - - - if (validType) { - for (var i = 2; i < arguments.length; i++) { - validateChildKeys(arguments[i], type); - } - } - - if (type === REACT_FRAGMENT_TYPE) { - validateFragmentProps(element); - } else { - validatePropTypes(element); - } - - return element; - } - var didWarnAboutDeprecatedCreateFactory = false; - function createFactoryWithValidation(type) { - var validatedFactory = createElementWithValidation.bind(null, type); - validatedFactory.type = type; - - { - if (!didWarnAboutDeprecatedCreateFactory) { - didWarnAboutDeprecatedCreateFactory = true; - - warn('React.createFactory() is deprecated and will be removed in ' + 'a future major release. Consider using JSX ' + 'or use React.createElement() directly instead.'); - } // Legacy hook: remove it - - - Object.defineProperty(validatedFactory, 'type', { - enumerable: false, - get: function () { - warn('Factory.type is deprecated. Access the class directly ' + 'before passing it to createFactory.'); - - Object.defineProperty(this, 'type', { - value: type - }); - return type; - } - }); - } - - return validatedFactory; - } - function cloneElementWithValidation(element, props, children) { - var newElement = cloneElement.apply(this, arguments); - - for (var i = 2; i < arguments.length; i++) { - validateChildKeys(arguments[i], newElement.type); - } - - validatePropTypes(newElement); - return newElement; - } - - { - - try { - var frozenObject = Object.freeze({}); - var testMap = new Map([[frozenObject, null]]); - var testSet = new Set([frozenObject]); // This is necessary for Rollup to not consider these unused. - // https://github.com/rollup/rollup/issues/1771 - // TODO: we can remove these if Rollup fixes the bug. - - testMap.set(0, 0); - testSet.add(0); - } catch (e) { - } - } - - var createElement$1 = createElementWithValidation ; - var cloneElement$1 = cloneElementWithValidation ; - var createFactory = createFactoryWithValidation ; - var Children = { - map: mapChildren, - forEach: forEachChildren, - count: countChildren, - toArray: toArray, - only: onlyChild - }; - - exports.Children = Children; - exports.Component = Component; - exports.Fragment = REACT_FRAGMENT_TYPE; - exports.Profiler = REACT_PROFILER_TYPE; - exports.PureComponent = PureComponent; - exports.StrictMode = REACT_STRICT_MODE_TYPE; - exports.Suspense = REACT_SUSPENSE_TYPE; - exports.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED = ReactSharedInternals; - exports.cloneElement = cloneElement$1; - exports.createContext = createContext; - exports.createElement = createElement$1; - exports.createFactory = createFactory; - exports.createRef = createRef; - exports.forwardRef = forwardRef; - exports.isValidElement = isValidElement; - exports.lazy = lazy; - exports.memo = memo; - exports.useCallback = useCallback; - exports.useContext = useContext; - exports.useDebugValue = useDebugValue; - exports.useEffect = useEffect; - exports.useImperativeHandle = useImperativeHandle; - exports.useLayoutEffect = useLayoutEffect; - exports.useMemo = useMemo; - exports.useReducer = useReducer; - exports.useRef = useRef; - exports.useState = useState; - exports.version = ReactVersion; - })(); - } - }); - var react_development_1 = react_development.Children; - var react_development_2 = react_development.Component; - var react_development_3 = react_development.Fragment; - var react_development_4 = react_development.Profiler; - var react_development_5 = react_development.PureComponent; - var react_development_6 = react_development.StrictMode; - var react_development_7 = react_development.Suspense; - var react_development_8 = react_development.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED; - var react_development_9 = react_development.cloneElement; - var react_development_10 = react_development.createContext; - var react_development_11 = react_development.createElement; - var react_development_12 = react_development.createFactory; - var react_development_13 = react_development.createRef; - var react_development_14 = react_development.forwardRef; - var react_development_15 = react_development.isValidElement; - var react_development_16 = react_development.lazy; - var react_development_17 = react_development.memo; - var react_development_18 = react_development.useCallback; - var react_development_19 = react_development.useContext; - var react_development_20 = react_development.useDebugValue; - var react_development_21 = react_development.useEffect; - var react_development_22 = react_development.useImperativeHandle; - var react_development_23 = react_development.useLayoutEffect; - var react_development_24 = react_development.useMemo; - var react_development_25 = react_development.useReducer; - var react_development_26 = react_development.useRef; - var react_development_27 = react_development.useState; - var react_development_28 = react_development.version; - - var react = createCommonjsModule(function (module) { - - { - module.exports = react_development; - } - }); - var react_1 = react.Component; - - var scheduler_production_min = createCommonjsModule(function (module, exports) { - var f,g,h,k,l; - if("undefined"===typeof window||"function"!==typeof MessageChannel){var p=null,q=null,t=function(){if(null!==p)try{var a=exports.unstable_now();p(!0,a);p=null;}catch(b){throw setTimeout(t,0),b;}},u=Date.now();exports.unstable_now=function(){return Date.now()-u};f=function(a){null!==p?setTimeout(f,0,a):(p=a,setTimeout(t,0));};g=function(a,b){q=setTimeout(a,b);};h=function(){clearTimeout(q);};k=function(){return !1};l=exports.unstable_forceFrameRate=function(){};}else {var w=window.performance,x=window.Date, - y=window.setTimeout,z=window.clearTimeout;if("undefined"!==typeof console){var A=window.cancelAnimationFrame;"function"!==typeof window.requestAnimationFrame&&console.error("This browser doesn't support requestAnimationFrame. Make sure that you load a polyfill in older browsers. https://fb.me/react-polyfills");"function"!==typeof A&&console.error("This browser doesn't support cancelAnimationFrame. Make sure that you load a polyfill in older browsers. https://fb.me/react-polyfills");}if("object"=== - typeof w&&"function"===typeof w.now)exports.unstable_now=function(){return w.now()};else {var B=x.now();exports.unstable_now=function(){return x.now()-B};}var C=!1,D=null,E=-1,F=5,G=0;k=function(){return exports.unstable_now()>=G};l=function(){};exports.unstable_forceFrameRate=function(a){0>a||125>>1,e=a[d];if(void 0!==e&&0K(n,c))void 0!==r&&0>K(r,n)?(a[d]=r,a[v]=c,d=v):(a[d]=n,a[m]=c,d=m);else if(void 0!==r&&0>K(r,c))a[d]=r,a[v]=c,d=v;else break a}}return b}return null}function K(a,b){var c=a.sortIndex-b.sortIndex;return 0!==c?c:a.id-b.id}var N=[],O=[],P=1,Q=null,R=3,S=!1,T=!1,U=!1; - function V(a){for(var b=L(O);null!==b;){if(null===b.callback)M(O);else if(b.startTime<=a)M(O),b.sortIndex=b.expirationTime,J(N,b);else break;b=L(O);}}function W(a){U=!1;V(a);if(!T)if(null!==L(N))T=!0,f(X);else {var b=L(O);null!==b&&g(W,b.startTime-a);}} - function X(a,b){T=!1;U&&(U=!1,h());S=!0;var c=R;try{V(b);for(Q=L(N);null!==Q&&(!(Q.expirationTime>b)||a&&!k());){var d=Q.callback;if(null!==d){Q.callback=null;R=Q.priorityLevel;var e=d(Q.expirationTime<=b);b=exports.unstable_now();"function"===typeof e?Q.callback=e:Q===L(N)&&M(N);V(b);}else M(N);Q=L(N);}if(null!==Q)var m=!0;else {var n=L(O);null!==n&&g(W,n.startTime-b);m=!1;}return m}finally{Q=null,R=c,S=!1;}} - function Y(a){switch(a){case 1:return -1;case 2:return 250;case 5:return 1073741823;case 4:return 1E4;default:return 5E3}}var Z=l;exports.unstable_IdlePriority=5;exports.unstable_ImmediatePriority=1;exports.unstable_LowPriority=4;exports.unstable_NormalPriority=3;exports.unstable_Profiling=null;exports.unstable_UserBlockingPriority=2;exports.unstable_cancelCallback=function(a){a.callback=null;};exports.unstable_continueExecution=function(){T||S||(T=!0,f(X));}; - exports.unstable_getCurrentPriorityLevel=function(){return R};exports.unstable_getFirstCallbackNode=function(){return L(N)};exports.unstable_next=function(a){switch(R){case 1:case 2:case 3:var b=3;break;default:b=R;}var c=R;R=b;try{return a()}finally{R=c;}};exports.unstable_pauseExecution=function(){};exports.unstable_requestPaint=Z;exports.unstable_runWithPriority=function(a,b){switch(a){case 1:case 2:case 3:case 4:case 5:break;default:a=3;}var c=R;R=a;try{return b()}finally{R=c;}}; - exports.unstable_scheduleCallback=function(a,b,c){var d=exports.unstable_now();if("object"===typeof c&&null!==c){var e=c.delay;e="number"===typeof e&&0d?(a.sortIndex=e,J(O,a),null===L(N)&&a===L(O)&&(U?h():U=!0,g(W,e-d))):(a.sortIndex=c,J(N,a),T||S||(T=!0,f(X)));return a}; - exports.unstable_shouldYield=function(){var a=exports.unstable_now();V(a);var b=L(N);return b!==Q&&null!==Q&&null!==b&&null!==b.callback&&b.startTime<=a&&b.expirationTime= deadline; - }; // Since we yield every frame regardless, `requestPaint` has no effect. - - - requestPaint = function () {}; - } - - exports.unstable_forceFrameRate = function (fps) { - if (fps < 0 || fps > 125) { - // Using console['error'] to evade Babel and ESLint - console['error']('forceFrameRate takes a positive int between 0 and 125, ' + 'forcing framerates higher than 125 fps is not unsupported'); - return; - } - - if (fps > 0) { - yieldInterval = Math.floor(1000 / fps); - } else { - // reset the framerate - yieldInterval = 5; - } - }; - - var performWorkUntilDeadline = function () { - if (scheduledHostCallback !== null) { - var currentTime = exports.unstable_now(); // Yield after `yieldInterval` ms, regardless of where we are in the vsync - // cycle. This means there's always time remaining at the beginning of - // the message event. - - deadline = currentTime + yieldInterval; - var hasTimeRemaining = true; - - try { - var hasMoreWork = scheduledHostCallback(hasTimeRemaining, currentTime); - - if (!hasMoreWork) { - isMessageLoopRunning = false; - scheduledHostCallback = null; - } else { - // If there's more work, schedule the next message event at the end - // of the preceding one. - port.postMessage(null); - } - } catch (error) { - // If a scheduler task throws, exit the current browser task so the - // error can be observed. - port.postMessage(null); - throw error; - } - } else { - isMessageLoopRunning = false; - } // Yielding to the browser will give it a chance to paint, so we can - }; - - var channel = new MessageChannel(); - var port = channel.port2; - channel.port1.onmessage = performWorkUntilDeadline; - - requestHostCallback = function (callback) { - scheduledHostCallback = callback; - - if (!isMessageLoopRunning) { - isMessageLoopRunning = true; - port.postMessage(null); - } - }; - - requestHostTimeout = function (callback, ms) { - taskTimeoutID = _setTimeout(function () { - callback(exports.unstable_now()); - }, ms); - }; - - cancelHostTimeout = function () { - _clearTimeout(taskTimeoutID); - - taskTimeoutID = -1; - }; - } - - function push(heap, node) { - var index = heap.length; - heap.push(node); - siftUp(heap, node, index); - } - function peek(heap) { - var first = heap[0]; - return first === undefined ? null : first; - } - function pop(heap) { - var first = heap[0]; - - if (first !== undefined) { - var last = heap.pop(); - - if (last !== first) { - heap[0] = last; - siftDown(heap, last, 0); - } - - return first; - } else { - return null; - } - } - - function siftUp(heap, node, i) { - var index = i; - - while (true) { - var parentIndex = index - 1 >>> 1; - var parent = heap[parentIndex]; - - if (parent !== undefined && compare(parent, node) > 0) { - // The parent is larger. Swap positions. - heap[parentIndex] = node; - heap[index] = parent; - index = parentIndex; - } else { - // The parent is smaller. Exit. - return; - } - } - } - - function siftDown(heap, node, i) { - var index = i; - var length = heap.length; - - while (index < length) { - var leftIndex = (index + 1) * 2 - 1; - var left = heap[leftIndex]; - var rightIndex = leftIndex + 1; - var right = heap[rightIndex]; // If the left or right node is smaller, swap with the smaller of those. - - if (left !== undefined && compare(left, node) < 0) { - if (right !== undefined && compare(right, left) < 0) { - heap[index] = right; - heap[rightIndex] = node; - index = rightIndex; - } else { - heap[index] = left; - heap[leftIndex] = node; - index = leftIndex; - } - } else if (right !== undefined && compare(right, node) < 0) { - heap[index] = right; - heap[rightIndex] = node; - index = rightIndex; - } else { - // Neither child is smaller. Exit. - return; - } - } - } - - function compare(a, b) { - // Compare sort index first, then task id. - var diff = a.sortIndex - b.sortIndex; - return diff !== 0 ? diff : a.id - b.id; - } - - // TODO: Use symbols? - var NoPriority = 0; - var ImmediatePriority = 1; - var UserBlockingPriority = 2; - var NormalPriority = 3; - var LowPriority = 4; - var IdlePriority = 5; - - var runIdCounter = 0; - var mainThreadIdCounter = 0; - var profilingStateSize = 4; - var sharedProfilingBuffer = // $FlowFixMe Flow doesn't know about SharedArrayBuffer - typeof SharedArrayBuffer === 'function' ? new SharedArrayBuffer(profilingStateSize * Int32Array.BYTES_PER_ELEMENT) : // $FlowFixMe Flow doesn't know about ArrayBuffer - typeof ArrayBuffer === 'function' ? new ArrayBuffer(profilingStateSize * Int32Array.BYTES_PER_ELEMENT) : null // Don't crash the init path on IE9 - ; - var profilingState = sharedProfilingBuffer !== null ? new Int32Array(sharedProfilingBuffer) : []; // We can't read this but it helps save bytes for null checks - - var PRIORITY = 0; - var CURRENT_TASK_ID = 1; - var CURRENT_RUN_ID = 2; - var QUEUE_SIZE = 3; - - { - profilingState[PRIORITY] = NoPriority; // This is maintained with a counter, because the size of the priority queue - // array might include canceled tasks. - - profilingState[QUEUE_SIZE] = 0; - profilingState[CURRENT_TASK_ID] = 0; - } // Bytes per element is 4 - - - var INITIAL_EVENT_LOG_SIZE = 131072; - var MAX_EVENT_LOG_SIZE = 524288; // Equivalent to 2 megabytes - - var eventLogSize = 0; - var eventLogBuffer = null; - var eventLog = null; - var eventLogIndex = 0; - var TaskStartEvent = 1; - var TaskCompleteEvent = 2; - var TaskErrorEvent = 3; - var TaskCancelEvent = 4; - var TaskRunEvent = 5; - var TaskYieldEvent = 6; - var SchedulerSuspendEvent = 7; - var SchedulerResumeEvent = 8; - - function logEvent(entries) { - if (eventLog !== null) { - var offset = eventLogIndex; - eventLogIndex += entries.length; - - if (eventLogIndex + 1 > eventLogSize) { - eventLogSize *= 2; - - if (eventLogSize > MAX_EVENT_LOG_SIZE) { - // Using console['error'] to evade Babel and ESLint - console['error']("Scheduler Profiling: Event log exceeded maximum size. Don't " + 'forget to call `stopLoggingProfilingEvents()`.'); - stopLoggingProfilingEvents(); - return; - } - - var newEventLog = new Int32Array(eventLogSize * 4); - newEventLog.set(eventLog); - eventLogBuffer = newEventLog.buffer; - eventLog = newEventLog; - } - - eventLog.set(entries, offset); - } - } - - function startLoggingProfilingEvents() { - eventLogSize = INITIAL_EVENT_LOG_SIZE; - eventLogBuffer = new ArrayBuffer(eventLogSize * 4); - eventLog = new Int32Array(eventLogBuffer); - eventLogIndex = 0; - } - function stopLoggingProfilingEvents() { - var buffer = eventLogBuffer; - eventLogSize = 0; - eventLogBuffer = null; - eventLog = null; - eventLogIndex = 0; - return buffer; - } - function markTaskStart(task, ms) { - { - profilingState[QUEUE_SIZE]++; - - if (eventLog !== null) { - // performance.now returns a float, representing milliseconds. When the - // event is logged, it's coerced to an int. Convert to microseconds to - // maintain extra degrees of precision. - logEvent([TaskStartEvent, ms * 1000, task.id, task.priorityLevel]); - } - } - } - function markTaskCompleted(task, ms) { - { - profilingState[PRIORITY] = NoPriority; - profilingState[CURRENT_TASK_ID] = 0; - profilingState[QUEUE_SIZE]--; - - if (eventLog !== null) { - logEvent([TaskCompleteEvent, ms * 1000, task.id]); - } - } - } - function markTaskCanceled(task, ms) { - { - profilingState[QUEUE_SIZE]--; - - if (eventLog !== null) { - logEvent([TaskCancelEvent, ms * 1000, task.id]); - } - } - } - function markTaskErrored(task, ms) { - { - profilingState[PRIORITY] = NoPriority; - profilingState[CURRENT_TASK_ID] = 0; - profilingState[QUEUE_SIZE]--; - - if (eventLog !== null) { - logEvent([TaskErrorEvent, ms * 1000, task.id]); - } - } - } - function markTaskRun(task, ms) { - { - runIdCounter++; - profilingState[PRIORITY] = task.priorityLevel; - profilingState[CURRENT_TASK_ID] = task.id; - profilingState[CURRENT_RUN_ID] = runIdCounter; - - if (eventLog !== null) { - logEvent([TaskRunEvent, ms * 1000, task.id, runIdCounter]); - } - } - } - function markTaskYield(task, ms) { - { - profilingState[PRIORITY] = NoPriority; - profilingState[CURRENT_TASK_ID] = 0; - profilingState[CURRENT_RUN_ID] = 0; - - if (eventLog !== null) { - logEvent([TaskYieldEvent, ms * 1000, task.id, runIdCounter]); - } - } - } - function markSchedulerSuspended(ms) { - { - mainThreadIdCounter++; - - if (eventLog !== null) { - logEvent([SchedulerSuspendEvent, ms * 1000, mainThreadIdCounter]); - } - } - } - function markSchedulerUnsuspended(ms) { - { - if (eventLog !== null) { - logEvent([SchedulerResumeEvent, ms * 1000, mainThreadIdCounter]); - } - } - } - - /* eslint-disable no-var */ - // Math.pow(2, 30) - 1 - // 0b111111111111111111111111111111 - - var maxSigned31BitInt = 1073741823; // Times out immediately - - var IMMEDIATE_PRIORITY_TIMEOUT = -1; // Eventually times out - - var USER_BLOCKING_PRIORITY = 250; - var NORMAL_PRIORITY_TIMEOUT = 5000; - var LOW_PRIORITY_TIMEOUT = 10000; // Never times out - - var IDLE_PRIORITY = maxSigned31BitInt; // Tasks are stored on a min heap - - var taskQueue = []; - var timerQueue = []; // Incrementing id counter. Used to maintain insertion order. - - var taskIdCounter = 1; // Pausing the scheduler is useful for debugging. - var currentTask = null; - var currentPriorityLevel = NormalPriority; // This is set while performing work, to prevent re-entrancy. - - var isPerformingWork = false; - var isHostCallbackScheduled = false; - var isHostTimeoutScheduled = false; - - function advanceTimers(currentTime) { - // Check for tasks that are no longer delayed and add them to the queue. - var timer = peek(timerQueue); - - while (timer !== null) { - if (timer.callback === null) { - // Timer was cancelled. - pop(timerQueue); - } else if (timer.startTime <= currentTime) { - // Timer fired. Transfer to the task queue. - pop(timerQueue); - timer.sortIndex = timer.expirationTime; - push(taskQueue, timer); - - { - markTaskStart(timer, currentTime); - timer.isQueued = true; - } - } else { - // Remaining timers are pending. - return; - } - - timer = peek(timerQueue); - } - } - - function handleTimeout(currentTime) { - isHostTimeoutScheduled = false; - advanceTimers(currentTime); - - if (!isHostCallbackScheduled) { - if (peek(taskQueue) !== null) { - isHostCallbackScheduled = true; - requestHostCallback(flushWork); - } else { - var firstTimer = peek(timerQueue); - - if (firstTimer !== null) { - requestHostTimeout(handleTimeout, firstTimer.startTime - currentTime); - } - } - } - } - - function flushWork(hasTimeRemaining, initialTime) { - { - markSchedulerUnsuspended(initialTime); - } // We'll need a host callback the next time work is scheduled. - - - isHostCallbackScheduled = false; - - if (isHostTimeoutScheduled) { - // We scheduled a timeout but it's no longer needed. Cancel it. - isHostTimeoutScheduled = false; - cancelHostTimeout(); - } - - isPerformingWork = true; - var previousPriorityLevel = currentPriorityLevel; - - try { - if (enableProfiling) { - try { - return workLoop(hasTimeRemaining, initialTime); - } catch (error) { - if (currentTask !== null) { - var currentTime = exports.unstable_now(); - markTaskErrored(currentTask, currentTime); - currentTask.isQueued = false; - } - - throw error; - } - } - } finally { - currentTask = null; - currentPriorityLevel = previousPriorityLevel; - isPerformingWork = false; - - { - var _currentTime = exports.unstable_now(); - - markSchedulerSuspended(_currentTime); - } - } - } - - function workLoop(hasTimeRemaining, initialTime) { - var currentTime = initialTime; - advanceTimers(currentTime); - currentTask = peek(taskQueue); - - while (currentTask !== null && !(enableSchedulerDebugging )) { - if (currentTask.expirationTime > currentTime && (!hasTimeRemaining || shouldYieldToHost())) { - // This currentTask hasn't expired, and we've reached the deadline. - break; - } - - var callback = currentTask.callback; - - if (callback !== null) { - currentTask.callback = null; - currentPriorityLevel = currentTask.priorityLevel; - var didUserCallbackTimeout = currentTask.expirationTime <= currentTime; - markTaskRun(currentTask, currentTime); - var continuationCallback = callback(didUserCallbackTimeout); - currentTime = exports.unstable_now(); - - if (typeof continuationCallback === 'function') { - currentTask.callback = continuationCallback; - markTaskYield(currentTask, currentTime); - } else { - { - markTaskCompleted(currentTask, currentTime); - currentTask.isQueued = false; - } - - if (currentTask === peek(taskQueue)) { - pop(taskQueue); - } - } - - advanceTimers(currentTime); - } else { - pop(taskQueue); - } - - currentTask = peek(taskQueue); - } // Return whether there's additional work - - - if (currentTask !== null) { - return true; - } else { - var firstTimer = peek(timerQueue); - - if (firstTimer !== null) { - requestHostTimeout(handleTimeout, firstTimer.startTime - currentTime); - } - - return false; - } - } - - function unstable_runWithPriority(priorityLevel, eventHandler) { - switch (priorityLevel) { - case ImmediatePriority: - case UserBlockingPriority: - case NormalPriority: - case LowPriority: - case IdlePriority: - break; - - default: - priorityLevel = NormalPriority; - } - - var previousPriorityLevel = currentPriorityLevel; - currentPriorityLevel = priorityLevel; - - try { - return eventHandler(); - } finally { - currentPriorityLevel = previousPriorityLevel; - } - } - - function unstable_next(eventHandler) { - var priorityLevel; - - switch (currentPriorityLevel) { - case ImmediatePriority: - case UserBlockingPriority: - case NormalPriority: - // Shift down to normal priority - priorityLevel = NormalPriority; - break; - - default: - // Anything lower than normal priority should remain at the current level. - priorityLevel = currentPriorityLevel; - break; - } - - var previousPriorityLevel = currentPriorityLevel; - currentPriorityLevel = priorityLevel; - - try { - return eventHandler(); - } finally { - currentPriorityLevel = previousPriorityLevel; - } - } - - function unstable_wrapCallback(callback) { - var parentPriorityLevel = currentPriorityLevel; - return function () { - // This is a fork of runWithPriority, inlined for performance. - var previousPriorityLevel = currentPriorityLevel; - currentPriorityLevel = parentPriorityLevel; - - try { - return callback.apply(this, arguments); - } finally { - currentPriorityLevel = previousPriorityLevel; - } - }; - } - - function timeoutForPriorityLevel(priorityLevel) { - switch (priorityLevel) { - case ImmediatePriority: - return IMMEDIATE_PRIORITY_TIMEOUT; - - case UserBlockingPriority: - return USER_BLOCKING_PRIORITY; - - case IdlePriority: - return IDLE_PRIORITY; - - case LowPriority: - return LOW_PRIORITY_TIMEOUT; - - case NormalPriority: - default: - return NORMAL_PRIORITY_TIMEOUT; - } - } - - function unstable_scheduleCallback(priorityLevel, callback, options) { - var currentTime = exports.unstable_now(); - var startTime; - var timeout; - - if (typeof options === 'object' && options !== null) { - var delay = options.delay; - - if (typeof delay === 'number' && delay > 0) { - startTime = currentTime + delay; - } else { - startTime = currentTime; - } - - timeout = typeof options.timeout === 'number' ? options.timeout : timeoutForPriorityLevel(priorityLevel); - } else { - timeout = timeoutForPriorityLevel(priorityLevel); - startTime = currentTime; - } - - var expirationTime = startTime + timeout; - var newTask = { - id: taskIdCounter++, - callback: callback, - priorityLevel: priorityLevel, - startTime: startTime, - expirationTime: expirationTime, - sortIndex: -1 - }; - - { - newTask.isQueued = false; - } - - if (startTime > currentTime) { - // This is a delayed task. - newTask.sortIndex = startTime; - push(timerQueue, newTask); - - if (peek(taskQueue) === null && newTask === peek(timerQueue)) { - // All tasks are delayed, and this is the task with the earliest delay. - if (isHostTimeoutScheduled) { - // Cancel an existing timeout. - cancelHostTimeout(); - } else { - isHostTimeoutScheduled = true; - } // Schedule a timeout. - - - requestHostTimeout(handleTimeout, startTime - currentTime); - } - } else { - newTask.sortIndex = expirationTime; - push(taskQueue, newTask); - - { - markTaskStart(newTask, currentTime); - newTask.isQueued = true; - } // Schedule a host callback, if needed. If we're already performing work, - // wait until the next time we yield. - - - if (!isHostCallbackScheduled && !isPerformingWork) { - isHostCallbackScheduled = true; - requestHostCallback(flushWork); - } - } - - return newTask; - } - - function unstable_pauseExecution() { - } - - function unstable_continueExecution() { - - if (!isHostCallbackScheduled && !isPerformingWork) { - isHostCallbackScheduled = true; - requestHostCallback(flushWork); - } - } - - function unstable_getFirstCallbackNode() { - return peek(taskQueue); - } - - function unstable_cancelCallback(task) { - { - if (task.isQueued) { - var currentTime = exports.unstable_now(); - markTaskCanceled(task, currentTime); - task.isQueued = false; - } - } // Null out the callback to indicate the task has been canceled. (Can't - // remove from the queue because you can't remove arbitrary nodes from an - // array based heap, only the first one.) - - - task.callback = null; - } - - function unstable_getCurrentPriorityLevel() { - return currentPriorityLevel; - } - - function unstable_shouldYield() { - var currentTime = exports.unstable_now(); - advanceTimers(currentTime); - var firstTask = peek(taskQueue); - return firstTask !== currentTask && currentTask !== null && firstTask !== null && firstTask.callback !== null && firstTask.startTime <= currentTime && firstTask.expirationTime < currentTask.expirationTime || shouldYieldToHost(); - } - - var unstable_requestPaint = requestPaint; - var unstable_Profiling = { - startLoggingProfilingEvents: startLoggingProfilingEvents, - stopLoggingProfilingEvents: stopLoggingProfilingEvents, - sharedProfilingBuffer: sharedProfilingBuffer - } ; - - exports.unstable_IdlePriority = IdlePriority; - exports.unstable_ImmediatePriority = ImmediatePriority; - exports.unstable_LowPriority = LowPriority; - exports.unstable_NormalPriority = NormalPriority; - exports.unstable_Profiling = unstable_Profiling; - exports.unstable_UserBlockingPriority = UserBlockingPriority; - exports.unstable_cancelCallback = unstable_cancelCallback; - exports.unstable_continueExecution = unstable_continueExecution; - exports.unstable_getCurrentPriorityLevel = unstable_getCurrentPriorityLevel; - exports.unstable_getFirstCallbackNode = unstable_getFirstCallbackNode; - exports.unstable_next = unstable_next; - exports.unstable_pauseExecution = unstable_pauseExecution; - exports.unstable_requestPaint = unstable_requestPaint; - exports.unstable_runWithPriority = unstable_runWithPriority; - exports.unstable_scheduleCallback = unstable_scheduleCallback; - exports.unstable_shouldYield = unstable_shouldYield; - exports.unstable_wrapCallback = unstable_wrapCallback; - })(); - } - }); - var scheduler_development_1 = scheduler_development.unstable_now; - var scheduler_development_2 = scheduler_development.unstable_forceFrameRate; - var scheduler_development_3 = scheduler_development.unstable_IdlePriority; - var scheduler_development_4 = scheduler_development.unstable_ImmediatePriority; - var scheduler_development_5 = scheduler_development.unstable_LowPriority; - var scheduler_development_6 = scheduler_development.unstable_NormalPriority; - var scheduler_development_7 = scheduler_development.unstable_Profiling; - var scheduler_development_8 = scheduler_development.unstable_UserBlockingPriority; - var scheduler_development_9 = scheduler_development.unstable_cancelCallback; - var scheduler_development_10 = scheduler_development.unstable_continueExecution; - var scheduler_development_11 = scheduler_development.unstable_getCurrentPriorityLevel; - var scheduler_development_12 = scheduler_development.unstable_getFirstCallbackNode; - var scheduler_development_13 = scheduler_development.unstable_next; - var scheduler_development_14 = scheduler_development.unstable_pauseExecution; - var scheduler_development_15 = scheduler_development.unstable_requestPaint; - var scheduler_development_16 = scheduler_development.unstable_runWithPriority; - var scheduler_development_17 = scheduler_development.unstable_scheduleCallback; - var scheduler_development_18 = scheduler_development.unstable_shouldYield; - var scheduler_development_19 = scheduler_development.unstable_wrapCallback; - - var scheduler = createCommonjsModule(function (module) { - - { - module.exports = scheduler_development; - } - }); - - function u(a){for(var b="https://reactjs.org/docs/error-decoder.html?invariant="+a,c=1;cb}return !1}function v(a,b,c,d,e,f){this.acceptsBooleans=2===b||3===b||4===b;this.attributeName=d;this.attributeNamespace=e;this.mustUseProperty=c;this.propertyName=a;this.type=b;this.sanitizeURL=f;}var C$1={}; - "children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(a){C$1[a]=new v(a,0,!1,a,null,!1);});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(a){var b=a[0];C$1[b]=new v(b,1,!1,a[1],null,!1);});["contentEditable","draggable","spellCheck","value"].forEach(function(a){C$1[a]=new v(a,2,!1,a.toLowerCase(),null,!1);}); - ["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(a){C$1[a]=new v(a,2,!1,a,null,!1);});"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(a){C$1[a]=new v(a,3,!1,a.toLowerCase(),null,!1);}); - ["checked","multiple","muted","selected"].forEach(function(a){C$1[a]=new v(a,3,!0,a,null,!1);});["capture","download"].forEach(function(a){C$1[a]=new v(a,4,!1,a,null,!1);});["cols","rows","size","span"].forEach(function(a){C$1[a]=new v(a,6,!1,a,null,!1);});["rowSpan","start"].forEach(function(a){C$1[a]=new v(a,5,!1,a.toLowerCase(),null,!1);});var Ua=/[\-:]([a-z])/g;function Va(a){return a[1].toUpperCase()} - "accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(a){var b=a.replace(Ua, - Va);C$1[b]=new v(b,1,!1,a,null,!1);});"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(a){var b=a.replace(Ua,Va);C$1[b]=new v(b,1,!1,a,"http://www.w3.org/1999/xlink",!1);});["xml:base","xml:lang","xml:space"].forEach(function(a){var b=a.replace(Ua,Va);C$1[b]=new v(b,1,!1,a,"http://www.w3.org/XML/1998/namespace",!1);});["tabIndex","crossOrigin"].forEach(function(a){C$1[a]=new v(a,1,!1,a.toLowerCase(),null,!1);}); - C$1.xlinkHref=new v("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0);["src","href","action","formAction"].forEach(function(a){C$1[a]=new v(a,1,!1,a.toLowerCase(),null,!0);});var Wa=react.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;Wa.hasOwnProperty("ReactCurrentDispatcher")||(Wa.ReactCurrentDispatcher={current:null});Wa.hasOwnProperty("ReactCurrentBatchConfig")||(Wa.ReactCurrentBatchConfig={suspense:null}); - function Xa(a,b,c,d){var e=C$1.hasOwnProperty(b)?C$1[b]:null;var f=null!==e?0===e.type:d?!1:!(2"+b.valueOf().toString()+"";for(b=Pb.firstChild;a.firstChild;)a.removeChild(a.firstChild);for(;b.firstChild;)a.appendChild(b.firstChild);}}); - function Sb(a,b){var c={};c[a.toLowerCase()]=b.toLowerCase();c["Webkit"+a]="webkit"+b;c["Moz"+a]="moz"+b;return c}var Tb={animationend:Sb("Animation","AnimationEnd"),animationiteration:Sb("Animation","AnimationIteration"),animationstart:Sb("Animation","AnimationStart"),transitionend:Sb("Transition","TransitionEnd")},Ub={},Vb={}; - ya&&(Vb=document.createElement("div").style,"AnimationEvent"in window||(delete Tb.animationend.animation,delete Tb.animationiteration.animation,delete Tb.animationstart.animation),"TransitionEvent"in window||delete Tb.transitionend.transition);function Wb(a){if(Ub[a])return Ub[a];if(!Tb[a])return a;var b=Tb[a],c;for(c in b)if(b.hasOwnProperty(c)&&c in Vb)return Ub[a]=b[c];return a} - var Xb=Wb("animationend"),Yb=Wb("animationiteration"),Zb=Wb("animationstart"),$b=Wb("transitionend"),bc=new ("function"===typeof WeakMap?WeakMap:Map);function cc(a){var b=bc.get(a);void 0===b&&(b=new Map,bc.set(a,b));return b} - function dc(a){var b=a,c=a;if(a.alternate)for(;b.return;)b=b.return;else {a=b;do b=a,0!==(b.effectTag&1026)&&(c=b.return),a=b.return;while(a)}return 3===b.tag?c:null}function fc(a){if(dc(a)!==a)throw Error(u(188));} - function gc(a){var b=a.alternate;if(!b){b=dc(a);if(null===b)throw Error(u(188));return b!==a?null:a}for(var c=a,d=b;;){var e=c.return;if(null===e)break;var f=e.alternate;if(null===f){d=e.return;if(null!==d){c=d;continue}break}if(e.child===f.child){for(f=e.child;f;){if(f===c)return fc(e),a;if(f===d)return fc(e),b;f=f.sibling;}throw Error(u(188));}if(c.return!==d.return)c=e,d=f;else {for(var g=!1,h=e.child;h;){if(h===c){g=!0;c=e;d=f;break}if(h===d){g=!0;d=e;c=f;break}h=h.sibling;}if(!g){for(h=f.child;h;){if(h=== - c){g=!0;c=f;d=e;break}if(h===d){g=!0;d=f;c=e;break}h=h.sibling;}if(!g)throw Error(u(189));}}if(c.alternate!==d)throw Error(u(190));}if(3!==c.tag)throw Error(u(188));return c.stateNode.current===c?a:b}function hc(a){a=gc(a);if(!a)return null;for(var b=a;;){if(5===b.tag||6===b.tag)return b;if(b.child)b.child.return=b,b=b.child;else {if(b===a)break;for(;!b.sibling;){if(!b.return||b.return===a)return null;b=b.return;}b.sibling.return=b.return;b=b.sibling;}}return null} - function ic(a,b){if(null==b)throw Error(u(30));if(null==a)return b;if(Array.isArray(a)){if(Array.isArray(b))return a.push.apply(a,b),a;a.push(b);return a}return Array.isArray(b)?[a].concat(b):[a,b]}function jc(a,b,c){Array.isArray(a)?a.forEach(b,c):a&&b.call(c,a);}var kc=null; - function lc(a){if(a){var b=a._dispatchListeners,c=a._dispatchInstances;if(Array.isArray(b))for(var d=0;dthis.eventPool.length&&this.eventPool.push(a);}function de(a){a.eventPool=[];a.getPooled=ee;a.release=fe;}var ge=G$1.extend({data:null}),he=G$1.extend({data:null}),ie=[9,13,27,32],je=ya&&"CompositionEvent"in window,ke=null;ya&&"documentMode"in document&&(ke=document.documentMode); - var le=ya&&"TextEvent"in window&&!ke,me=ya&&(!je||ke&&8=ke),ne=String.fromCharCode(32),oe={beforeInput:{phasedRegistrationNames:{bubbled:"onBeforeInput",captured:"onBeforeInputCapture"},dependencies:["compositionend","keypress","textInput","paste"]},compositionEnd:{phasedRegistrationNames:{bubbled:"onCompositionEnd",captured:"onCompositionEndCapture"},dependencies:"blur compositionend keydown keypress keyup mousedown".split(" ")},compositionStart:{phasedRegistrationNames:{bubbled:"onCompositionStart", - captured:"onCompositionStartCapture"},dependencies:"blur compositionstart keydown keypress keyup mousedown".split(" ")},compositionUpdate:{phasedRegistrationNames:{bubbled:"onCompositionUpdate",captured:"onCompositionUpdateCapture"},dependencies:"blur compositionupdate keydown keypress keyup mousedown".split(" ")}},pe=!1; - function qe(a,b){switch(a){case "keyup":return -1!==ie.indexOf(b.keyCode);case "keydown":return 229!==b.keyCode;case "keypress":case "mousedown":case "blur":return !0;default:return !1}}function re(a){a=a.detail;return "object"===typeof a&&"data"in a?a.data:null}var se=!1;function te(a,b){switch(a){case "compositionend":return re(b);case "keypress":if(32!==b.which)return null;pe=!0;return ne;case "textInput":return a=b.data,a===ne&&pe?null:a;default:return null}} - function ue(a,b){if(se)return "compositionend"===a||!je&&qe(a,b)?(a=ae(),$d=Zd=Yd=null,se=!1,a):null;switch(a){case "paste":return null;case "keypress":if(!(b.ctrlKey||b.altKey||b.metaKey)||b.ctrlKey&&b.altKey){if(b.char&&1=document.documentMode,df={select:{phasedRegistrationNames:{bubbled:"onSelect",captured:"onSelectCapture"},dependencies:"blur contextmenu dragend focus keydown keyup mousedown mouseup selectionchange".split(" ")}},ef=null,ff=null,gf=null,hf=!1; - function jf(a,b){var c=b.window===b?b.document:9===b.nodeType?b:b.ownerDocument;if(hf||null==ef||ef!==td(c))return null;c=ef;"selectionStart"in c&&yd(c)?c={start:c.selectionStart,end:c.selectionEnd}:(c=(c.ownerDocument&&c.ownerDocument.defaultView||window).getSelection(),c={anchorNode:c.anchorNode,anchorOffset:c.anchorOffset,focusNode:c.focusNode,focusOffset:c.focusOffset});return gf&&bf(gf,c)?null:(gf=c,a=G$1.getPooled(df.select,ff,a,b),a.type="select",a.target=ef,Xd(a),a)} - var kf={eventTypes:df,extractEvents:function(a,b,c,d,e,f){e=f||(d.window===d?d.document:9===d.nodeType?d:d.ownerDocument);if(!(f=!e)){a:{e=cc(e);f=wa.onSelect;for(var g=0;g 3 && arguments[3] !== undefined ? arguments[3] : DEFAULT_THREAD_ID; - - var interaction = { - __count: 1, - id: interactionIDCounter++, - name: name, - timestamp: timestamp - }; - var prevInteractions = exports.__interactionsRef.current; // Traced interactions should stack/accumulate. - // To do that, clone the current interactions. - // The previous set will be restored upon completion. - - var interactions = new Set(prevInteractions); - interactions.add(interaction); - exports.__interactionsRef.current = interactions; - var subscriber = exports.__subscriberRef.current; - var returnValue; - - try { - if (subscriber !== null) { - subscriber.onInteractionTraced(interaction); - } - } finally { - try { - if (subscriber !== null) { - subscriber.onWorkStarted(interactions, threadID); - } - } finally { - try { - returnValue = callback(); - } finally { - exports.__interactionsRef.current = prevInteractions; - - try { - if (subscriber !== null) { - subscriber.onWorkStopped(interactions, threadID); - } - } finally { - interaction.__count--; // If no async work was scheduled for this interaction, - // Notify subscribers that it's completed. - - if (subscriber !== null && interaction.__count === 0) { - subscriber.onInteractionScheduledWorkCompleted(interaction); - } - } - } - } - } - - return returnValue; - } - function unstable_wrap(callback) { - var threadID = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : DEFAULT_THREAD_ID; - - var wrappedInteractions = exports.__interactionsRef.current; - var subscriber = exports.__subscriberRef.current; - - if (subscriber !== null) { - subscriber.onWorkScheduled(wrappedInteractions, threadID); - } // Update the pending async work count for the current interactions. - // Update after calling subscribers in case of error. - - - wrappedInteractions.forEach(function (interaction) { - interaction.__count++; - }); - var hasRun = false; - - function wrapped() { - var prevInteractions = exports.__interactionsRef.current; - exports.__interactionsRef.current = wrappedInteractions; - subscriber = exports.__subscriberRef.current; - - try { - var returnValue; - - try { - if (subscriber !== null) { - subscriber.onWorkStarted(wrappedInteractions, threadID); - } - } finally { - try { - returnValue = callback.apply(undefined, arguments); - } finally { - exports.__interactionsRef.current = prevInteractions; - - if (subscriber !== null) { - subscriber.onWorkStopped(wrappedInteractions, threadID); - } - } - } - - return returnValue; - } finally { - if (!hasRun) { - // We only expect a wrapped function to be executed once, - // But in the event that it's executed more than once– - // Only decrement the outstanding interaction counts once. - hasRun = true; // Update pending async counts for all wrapped interactions. - // If this was the last scheduled async work for any of them, - // Mark them as completed. - - wrappedInteractions.forEach(function (interaction) { - interaction.__count--; - - if (subscriber !== null && interaction.__count === 0) { - subscriber.onInteractionScheduledWorkCompleted(interaction); - } - }); - } - } - } - - wrapped.cancel = function cancel() { - subscriber = exports.__subscriberRef.current; - - try { - if (subscriber !== null) { - subscriber.onWorkCanceled(wrappedInteractions, threadID); - } - } finally { - // Update pending async counts for all wrapped interactions. - // If this was the last scheduled async work for any of them, - // Mark them as completed. - wrappedInteractions.forEach(function (interaction) { - interaction.__count--; - - if (subscriber && interaction.__count === 0) { - subscriber.onInteractionScheduledWorkCompleted(interaction); - } - }); - } - }; - - return wrapped; - } - - var subscribers = null; - - { - subscribers = new Set(); - } - - function unstable_subscribe(subscriber) { - { - subscribers.add(subscriber); - - if (subscribers.size === 1) { - exports.__subscriberRef.current = { - onInteractionScheduledWorkCompleted: onInteractionScheduledWorkCompleted, - onInteractionTraced: onInteractionTraced, - onWorkCanceled: onWorkCanceled, - onWorkScheduled: onWorkScheduled, - onWorkStarted: onWorkStarted, - onWorkStopped: onWorkStopped - }; - } - } - } - function unstable_unsubscribe(subscriber) { - { - subscribers.delete(subscriber); - - if (subscribers.size === 0) { - exports.__subscriberRef.current = null; - } - } - } - - function onInteractionTraced(interaction) { - var didCatchError = false; - var caughtError = null; - subscribers.forEach(function (subscriber) { - try { - subscriber.onInteractionTraced(interaction); - } catch (error) { - if (!didCatchError) { - didCatchError = true; - caughtError = error; - } - } - }); - - if (didCatchError) { - throw caughtError; - } - } - - function onInteractionScheduledWorkCompleted(interaction) { - var didCatchError = false; - var caughtError = null; - subscribers.forEach(function (subscriber) { - try { - subscriber.onInteractionScheduledWorkCompleted(interaction); - } catch (error) { - if (!didCatchError) { - didCatchError = true; - caughtError = error; - } - } - }); - - if (didCatchError) { - throw caughtError; - } - } - - function onWorkScheduled(interactions, threadID) { - var didCatchError = false; - var caughtError = null; - subscribers.forEach(function (subscriber) { - try { - subscriber.onWorkScheduled(interactions, threadID); - } catch (error) { - if (!didCatchError) { - didCatchError = true; - caughtError = error; - } - } - }); - - if (didCatchError) { - throw caughtError; - } - } - - function onWorkStarted(interactions, threadID) { - var didCatchError = false; - var caughtError = null; - subscribers.forEach(function (subscriber) { - try { - subscriber.onWorkStarted(interactions, threadID); - } catch (error) { - if (!didCatchError) { - didCatchError = true; - caughtError = error; - } - } - }); - - if (didCatchError) { - throw caughtError; - } - } - - function onWorkStopped(interactions, threadID) { - var didCatchError = false; - var caughtError = null; - subscribers.forEach(function (subscriber) { - try { - subscriber.onWorkStopped(interactions, threadID); - } catch (error) { - if (!didCatchError) { - didCatchError = true; - caughtError = error; - } - } - }); - - if (didCatchError) { - throw caughtError; - } - } - - function onWorkCanceled(interactions, threadID) { - var didCatchError = false; - var caughtError = null; - subscribers.forEach(function (subscriber) { - try { - subscriber.onWorkCanceled(interactions, threadID); - } catch (error) { - if (!didCatchError) { - didCatchError = true; - caughtError = error; - } - } - }); - - if (didCatchError) { - throw caughtError; - } - } - - exports.unstable_clear = unstable_clear; - exports.unstable_getCurrent = unstable_getCurrent; - exports.unstable_getThreadID = unstable_getThreadID; - exports.unstable_subscribe = unstable_subscribe; - exports.unstable_trace = unstable_trace; - exports.unstable_unsubscribe = unstable_unsubscribe; - exports.unstable_wrap = unstable_wrap; - })(); - } - }); - var schedulerTracing_development_1 = schedulerTracing_development.__interactionsRef; - var schedulerTracing_development_2 = schedulerTracing_development.__subscriberRef; - var schedulerTracing_development_3 = schedulerTracing_development.unstable_clear; - var schedulerTracing_development_4 = schedulerTracing_development.unstable_getCurrent; - var schedulerTracing_development_5 = schedulerTracing_development.unstable_getThreadID; - var schedulerTracing_development_6 = schedulerTracing_development.unstable_subscribe; - var schedulerTracing_development_7 = schedulerTracing_development.unstable_trace; - var schedulerTracing_development_8 = schedulerTracing_development.unstable_unsubscribe; - var schedulerTracing_development_9 = schedulerTracing_development.unstable_wrap; - - var tracing = createCommonjsModule(function (module) { - - { - module.exports = schedulerTracing_development; - } - }); - - var reactDom_development = createCommonjsModule(function (module, exports) { - - - - { - (function() { - - var React = react; - var _assign = objectAssign; - var Scheduler = scheduler; - var checkPropTypes = checkPropTypes_1; - var tracing$1 = tracing; - - var ReactSharedInternals = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED; // Prevent newer renderers from RTE when used with older react package versions. - // Current owner and dispatcher used to share the same ref, - // but PR #14548 split them out to better support the react-debug-tools package. - - if (!ReactSharedInternals.hasOwnProperty('ReactCurrentDispatcher')) { - ReactSharedInternals.ReactCurrentDispatcher = { - current: null - }; - } - - if (!ReactSharedInternals.hasOwnProperty('ReactCurrentBatchConfig')) { - ReactSharedInternals.ReactCurrentBatchConfig = { - suspense: null - }; - } - - // by calls to these methods by a Babel plugin. - // - // In PROD (or in packages without access to React internals), - // they are left as they are instead. - - function warn(format) { - { - for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { - args[_key - 1] = arguments[_key]; - } - - printWarning('warn', format, args); - } - } - function error(format) { - { - for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) { - args[_key2 - 1] = arguments[_key2]; - } - - printWarning('error', format, args); - } - } - - function printWarning(level, format, args) { - // When changing this logic, you might want to also - // update consoleWithStackDev.www.js as well. - { - var hasExistingStack = args.length > 0 && typeof args[args.length - 1] === 'string' && args[args.length - 1].indexOf('\n in') === 0; - - if (!hasExistingStack) { - var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame; - var stack = ReactDebugCurrentFrame.getStackAddendum(); - - if (stack !== '') { - format += '%s'; - args = args.concat([stack]); - } - } - - var argsWithFormat = args.map(function (item) { - return '' + item; - }); // Careful: RN currently depends on this prefix - - argsWithFormat.unshift('Warning: ' + format); // We intentionally don't use spread (or .apply) directly because it - // breaks IE9: https://github.com/facebook/react/issues/13610 - // eslint-disable-next-line react-internal/no-production-logging - - Function.prototype.apply.call(console[level], console, argsWithFormat); - - try { - // --- Welcome to debugging React --- - // This error was thrown as a convenience so that you can use this stack - // to find the callsite that caused this warning to fire. - var argIndex = 0; - var message = 'Warning: ' + format.replace(/%s/g, function () { - return args[argIndex++]; - }); - throw new Error(message); - } catch (x) {} - } - } - - if (!React) { - { - throw Error( "ReactDOM was loaded before React. Make sure you load the React package before loading ReactDOM." ); - } - } - - var invokeGuardedCallbackImpl = function (name, func, context, a, b, c, d, e, f) { - var funcArgs = Array.prototype.slice.call(arguments, 3); - - try { - func.apply(context, funcArgs); - } catch (error) { - this.onError(error); - } - }; - - { - // In DEV mode, we swap out invokeGuardedCallback for a special version - // that plays more nicely with the browser's DevTools. The idea is to preserve - // "Pause on exceptions" behavior. Because React wraps all user-provided - // functions in invokeGuardedCallback, and the production version of - // invokeGuardedCallback uses a try-catch, all user exceptions are treated - // like caught exceptions, and the DevTools won't pause unless the developer - // takes the extra step of enabling pause on caught exceptions. This is - // unintuitive, though, because even though React has caught the error, from - // the developer's perspective, the error is uncaught. - // - // To preserve the expected "Pause on exceptions" behavior, we don't use a - // try-catch in DEV. Instead, we synchronously dispatch a fake event to a fake - // DOM node, and call the user-provided callback from inside an event handler - // for that fake event. If the callback throws, the error is "captured" using - // a global event handler. But because the error happens in a different - // event loop context, it does not interrupt the normal program flow. - // Effectively, this gives us try-catch behavior without actually using - // try-catch. Neat! - // Check that the browser supports the APIs we need to implement our special - // DEV version of invokeGuardedCallback - if (typeof window !== 'undefined' && typeof window.dispatchEvent === 'function' && typeof document !== 'undefined' && typeof document.createEvent === 'function') { - var fakeNode = document.createElement('react'); - - var invokeGuardedCallbackDev = function (name, func, context, a, b, c, d, e, f) { - // If document doesn't exist we know for sure we will crash in this method - // when we call document.createEvent(). However this can cause confusing - // errors: https://github.com/facebookincubator/create-react-app/issues/3482 - // So we preemptively throw with a better message instead. - if (!(typeof document !== 'undefined')) { - { - throw Error( "The `document` global was defined when React was initialized, but is not defined anymore. This can happen in a test environment if a component schedules an update from an asynchronous callback, but the test has already finished running. To solve this, you can either unmount the component at the end of your test (and ensure that any asynchronous operations get canceled in `componentWillUnmount`), or you can change the test itself to be asynchronous." ); - } - } - - var evt = document.createEvent('Event'); // Keeps track of whether the user-provided callback threw an error. We - // set this to true at the beginning, then set it to false right after - // calling the function. If the function errors, `didError` will never be - // set to false. This strategy works even if the browser is flaky and - // fails to call our global error handler, because it doesn't rely on - // the error event at all. - - var didError = true; // Keeps track of the value of window.event so that we can reset it - // during the callback to let user code access window.event in the - // browsers that support it. - - var windowEvent = window.event; // Keeps track of the descriptor of window.event to restore it after event - // dispatching: https://github.com/facebook/react/issues/13688 - - var windowEventDescriptor = Object.getOwnPropertyDescriptor(window, 'event'); // Create an event handler for our fake event. We will synchronously - // dispatch our fake event using `dispatchEvent`. Inside the handler, we - // call the user-provided callback. - - var funcArgs = Array.prototype.slice.call(arguments, 3); - - function callCallback() { - // We immediately remove the callback from event listeners so that - // nested `invokeGuardedCallback` calls do not clash. Otherwise, a - // nested call would trigger the fake event handlers of any call higher - // in the stack. - fakeNode.removeEventListener(evtType, callCallback, false); // We check for window.hasOwnProperty('event') to prevent the - // window.event assignment in both IE <= 10 as they throw an error - // "Member not found" in strict mode, and in Firefox which does not - // support window.event. - - if (typeof window.event !== 'undefined' && window.hasOwnProperty('event')) { - window.event = windowEvent; - } - - func.apply(context, funcArgs); - didError = false; - } // Create a global error event handler. We use this to capture the value - // that was thrown. It's possible that this error handler will fire more - // than once; for example, if non-React code also calls `dispatchEvent` - // and a handler for that event throws. We should be resilient to most of - // those cases. Even if our error event handler fires more than once, the - // last error event is always used. If the callback actually does error, - // we know that the last error event is the correct one, because it's not - // possible for anything else to have happened in between our callback - // erroring and the code that follows the `dispatchEvent` call below. If - // the callback doesn't error, but the error event was fired, we know to - // ignore it because `didError` will be false, as described above. - - - var error; // Use this to track whether the error event is ever called. - - var didSetError = false; - var isCrossOriginError = false; - - function handleWindowError(event) { - error = event.error; - didSetError = true; - - if (error === null && event.colno === 0 && event.lineno === 0) { - isCrossOriginError = true; - } - - if (event.defaultPrevented) { - // Some other error handler has prevented default. - // Browsers silence the error report if this happens. - // We'll remember this to later decide whether to log it or not. - if (error != null && typeof error === 'object') { - try { - error._suppressLogging = true; - } catch (inner) {// Ignore. - } - } - } - } // Create a fake event type. - - - var evtType = "react-" + (name ? name : 'invokeguardedcallback'); // Attach our event handlers - - window.addEventListener('error', handleWindowError); - fakeNode.addEventListener(evtType, callCallback, false); // Synchronously dispatch our fake event. If the user-provided function - // errors, it will trigger our global error handler. - - evt.initEvent(evtType, false, false); - fakeNode.dispatchEvent(evt); - - if (windowEventDescriptor) { - Object.defineProperty(window, 'event', windowEventDescriptor); - } - - if (didError) { - if (!didSetError) { - // The callback errored, but the error event never fired. - error = new Error('An error was thrown inside one of your components, but React ' + "doesn't know what it was. This is likely due to browser " + 'flakiness. React does its best to preserve the "Pause on ' + 'exceptions" behavior of the DevTools, which requires some ' + "DEV-mode only tricks. It's possible that these don't work in " + 'your browser. Try triggering the error in production mode, ' + 'or switching to a modern browser. If you suspect that this is ' + 'actually an issue with React, please file an issue.'); - } else if (isCrossOriginError) { - error = new Error("A cross-origin error was thrown. React doesn't have access to " + 'the actual error object in development. ' + 'See https://fb.me/react-crossorigin-error for more information.'); - } - - this.onError(error); - } // Remove our event listeners - - - window.removeEventListener('error', handleWindowError); - }; - - invokeGuardedCallbackImpl = invokeGuardedCallbackDev; - } - } - - var invokeGuardedCallbackImpl$1 = invokeGuardedCallbackImpl; - - var hasError = false; - var caughtError = null; // Used by event system to capture/rethrow the first error. - - var hasRethrowError = false; - var rethrowError = null; - var reporter = { - onError: function (error) { - hasError = true; - caughtError = error; - } - }; - /** - * Call a function while guarding against errors that happens within it. - * Returns an error if it throws, otherwise null. - * - * In production, this is implemented using a try-catch. The reason we don't - * use a try-catch directly is so that we can swap out a different - * implementation in DEV mode. - * - * @param {String} name of the guard to use for logging or debugging - * @param {Function} func The function to invoke - * @param {*} context The context to use when calling the function - * @param {...*} args Arguments for function - */ - - function invokeGuardedCallback(name, func, context, a, b, c, d, e, f) { - hasError = false; - caughtError = null; - invokeGuardedCallbackImpl$1.apply(reporter, arguments); - } - /** - * Same as invokeGuardedCallback, but instead of returning an error, it stores - * it in a global so it can be rethrown by `rethrowCaughtError` later. - * TODO: See if caughtError and rethrowError can be unified. - * - * @param {String} name of the guard to use for logging or debugging - * @param {Function} func The function to invoke - * @param {*} context The context to use when calling the function - * @param {...*} args Arguments for function - */ - - function invokeGuardedCallbackAndCatchFirstError(name, func, context, a, b, c, d, e, f) { - invokeGuardedCallback.apply(this, arguments); - - if (hasError) { - var error = clearCaughtError(); - - if (!hasRethrowError) { - hasRethrowError = true; - rethrowError = error; - } - } - } - /** - * During execution of guarded functions we will capture the first error which - * we will rethrow to be handled by the top level error handler. - */ - - function rethrowCaughtError() { - if (hasRethrowError) { - var error = rethrowError; - hasRethrowError = false; - rethrowError = null; - throw error; - } - } - function hasCaughtError() { - return hasError; - } - function clearCaughtError() { - if (hasError) { - var error = caughtError; - hasError = false; - caughtError = null; - return error; - } else { - { - { - throw Error( "clearCaughtError was called but no error was captured. This error is likely caused by a bug in React. Please file an issue." ); - } - } - } - } - - var getFiberCurrentPropsFromNode = null; - var getInstanceFromNode = null; - var getNodeFromInstance = null; - function setComponentTree(getFiberCurrentPropsFromNodeImpl, getInstanceFromNodeImpl, getNodeFromInstanceImpl) { - getFiberCurrentPropsFromNode = getFiberCurrentPropsFromNodeImpl; - getInstanceFromNode = getInstanceFromNodeImpl; - getNodeFromInstance = getNodeFromInstanceImpl; - - { - if (!getNodeFromInstance || !getInstanceFromNode) { - error('EventPluginUtils.setComponentTree(...): Injected ' + 'module is missing getNodeFromInstance or getInstanceFromNode.'); - } - } - } - var validateEventDispatches; - - { - validateEventDispatches = function (event) { - var dispatchListeners = event._dispatchListeners; - var dispatchInstances = event._dispatchInstances; - var listenersIsArr = Array.isArray(dispatchListeners); - var listenersLen = listenersIsArr ? dispatchListeners.length : dispatchListeners ? 1 : 0; - var instancesIsArr = Array.isArray(dispatchInstances); - var instancesLen = instancesIsArr ? dispatchInstances.length : dispatchInstances ? 1 : 0; - - if (instancesIsArr !== listenersIsArr || instancesLen !== listenersLen) { - error('EventPluginUtils: Invalid `event`.'); - } - }; - } - /** - * Dispatch the event to the listener. - * @param {SyntheticEvent} event SyntheticEvent to handle - * @param {function} listener Application-level callback - * @param {*} inst Internal component instance - */ - - - function executeDispatch(event, listener, inst) { - var type = event.type || 'unknown-event'; - event.currentTarget = getNodeFromInstance(inst); - invokeGuardedCallbackAndCatchFirstError(type, listener, undefined, event); - event.currentTarget = null; - } - /** - * Standard/simple iteration through an event's collected dispatches. - */ - - function executeDispatchesInOrder(event) { - var dispatchListeners = event._dispatchListeners; - var dispatchInstances = event._dispatchInstances; - - { - validateEventDispatches(event); - } - - if (Array.isArray(dispatchListeners)) { - for (var i = 0; i < dispatchListeners.length; i++) { - if (event.isPropagationStopped()) { - break; - } // Listeners and Instances are two parallel arrays that are always in sync. - - - executeDispatch(event, dispatchListeners[i], dispatchInstances[i]); - } - } else if (dispatchListeners) { - executeDispatch(event, dispatchListeners, dispatchInstances); - } - - event._dispatchListeners = null; - event._dispatchInstances = null; - } - - var FunctionComponent = 0; - var ClassComponent = 1; - var IndeterminateComponent = 2; // Before we know whether it is function or class - - var HostRoot = 3; // Root of a host tree. Could be nested inside another node. - - var HostPortal = 4; // A subtree. Could be an entry point to a different renderer. - - var HostComponent = 5; - var HostText = 6; - var Fragment = 7; - var Mode = 8; - var ContextConsumer = 9; - var ContextProvider = 10; - var ForwardRef = 11; - var Profiler = 12; - var SuspenseComponent = 13; - var MemoComponent = 14; - var SimpleMemoComponent = 15; - var LazyComponent = 16; - var IncompleteClassComponent = 17; - var DehydratedFragment = 18; - var SuspenseListComponent = 19; - var FundamentalComponent = 20; - var ScopeComponent = 21; - var Block = 22; - - /** - * Injectable ordering of event plugins. - */ - var eventPluginOrder = null; - /** - * Injectable mapping from names to event plugin modules. - */ - - var namesToPlugins = {}; - /** - * Recomputes the plugin list using the injected plugins and plugin ordering. - * - * @private - */ - - function recomputePluginOrdering() { - if (!eventPluginOrder) { - // Wait until an `eventPluginOrder` is injected. - return; - } - - for (var pluginName in namesToPlugins) { - var pluginModule = namesToPlugins[pluginName]; - var pluginIndex = eventPluginOrder.indexOf(pluginName); - - if (!(pluginIndex > -1)) { - { - throw Error( "EventPluginRegistry: Cannot inject event plugins that do not exist in the plugin ordering, `" + pluginName + "`." ); - } - } - - if (plugins[pluginIndex]) { - continue; - } - - if (!pluginModule.extractEvents) { - { - throw Error( "EventPluginRegistry: Event plugins must implement an `extractEvents` method, but `" + pluginName + "` does not." ); - } - } - - plugins[pluginIndex] = pluginModule; - var publishedEvents = pluginModule.eventTypes; - - for (var eventName in publishedEvents) { - if (!publishEventForPlugin(publishedEvents[eventName], pluginModule, eventName)) { - { - throw Error( "EventPluginRegistry: Failed to publish event `" + eventName + "` for plugin `" + pluginName + "`." ); - } - } - } - } - } - /** - * Publishes an event so that it can be dispatched by the supplied plugin. - * - * @param {object} dispatchConfig Dispatch configuration for the event. - * @param {object} PluginModule Plugin publishing the event. - * @return {boolean} True if the event was successfully published. - * @private - */ - - - function publishEventForPlugin(dispatchConfig, pluginModule, eventName) { - if (!!eventNameDispatchConfigs.hasOwnProperty(eventName)) { - { - throw Error( "EventPluginRegistry: More than one plugin attempted to publish the same event name, `" + eventName + "`." ); - } - } - - eventNameDispatchConfigs[eventName] = dispatchConfig; - var phasedRegistrationNames = dispatchConfig.phasedRegistrationNames; - - if (phasedRegistrationNames) { - for (var phaseName in phasedRegistrationNames) { - if (phasedRegistrationNames.hasOwnProperty(phaseName)) { - var phasedRegistrationName = phasedRegistrationNames[phaseName]; - publishRegistrationName(phasedRegistrationName, pluginModule, eventName); - } - } - - return true; - } else if (dispatchConfig.registrationName) { - publishRegistrationName(dispatchConfig.registrationName, pluginModule, eventName); - return true; - } - - return false; - } - /** - * Publishes a registration name that is used to identify dispatched events. - * - * @param {string} registrationName Registration name to add. - * @param {object} PluginModule Plugin publishing the event. - * @private - */ - - - function publishRegistrationName(registrationName, pluginModule, eventName) { - if (!!registrationNameModules[registrationName]) { - { - throw Error( "EventPluginRegistry: More than one plugin attempted to publish the same registration name, `" + registrationName + "`." ); - } - } - - registrationNameModules[registrationName] = pluginModule; - registrationNameDependencies[registrationName] = pluginModule.eventTypes[eventName].dependencies; - - { - var lowerCasedName = registrationName.toLowerCase(); - possibleRegistrationNames[lowerCasedName] = registrationName; - - if (registrationName === 'onDoubleClick') { - possibleRegistrationNames.ondblclick = registrationName; - } - } - } - /** - * Registers plugins so that they can extract and dispatch events. - */ - - /** - * Ordered list of injected plugins. - */ - - - var plugins = []; - /** - * Mapping from event name to dispatch config - */ - - var eventNameDispatchConfigs = {}; - /** - * Mapping from registration name to plugin module - */ - - var registrationNameModules = {}; - /** - * Mapping from registration name to event name - */ - - var registrationNameDependencies = {}; - /** - * Mapping from lowercase registration names to the properly cased version, - * used to warn in the case of missing event handlers. Available - * only in true. - * @type {Object} - */ - - var possibleRegistrationNames = {} ; // Trust the developer to only use possibleRegistrationNames in true - - /** - * Injects an ordering of plugins (by plugin name). This allows the ordering - * to be decoupled from injection of the actual plugins so that ordering is - * always deterministic regardless of packaging, on-the-fly injection, etc. - * - * @param {array} InjectedEventPluginOrder - * @internal - */ - - function injectEventPluginOrder(injectedEventPluginOrder) { - if (!!eventPluginOrder) { - { - throw Error( "EventPluginRegistry: Cannot inject event plugin ordering more than once. You are likely trying to load more than one copy of React." ); - } - } // Clone the ordering so it cannot be dynamically mutated. - - - eventPluginOrder = Array.prototype.slice.call(injectedEventPluginOrder); - recomputePluginOrdering(); - } - /** - * Injects plugins to be used by plugin event system. The plugin names must be - * in the ordering injected by `injectEventPluginOrder`. - * - * Plugins can be injected as part of page initialization or on-the-fly. - * - * @param {object} injectedNamesToPlugins Map from names to plugin modules. - * @internal - */ - - function injectEventPluginsByName(injectedNamesToPlugins) { - var isOrderingDirty = false; - - for (var pluginName in injectedNamesToPlugins) { - if (!injectedNamesToPlugins.hasOwnProperty(pluginName)) { - continue; - } - - var pluginModule = injectedNamesToPlugins[pluginName]; - - if (!namesToPlugins.hasOwnProperty(pluginName) || namesToPlugins[pluginName] !== pluginModule) { - if (!!namesToPlugins[pluginName]) { - { - throw Error( "EventPluginRegistry: Cannot inject two different event plugins using the same name, `" + pluginName + "`." ); - } - } - - namesToPlugins[pluginName] = pluginModule; - isOrderingDirty = true; - } - } - - if (isOrderingDirty) { - recomputePluginOrdering(); - } - } - - var canUseDOM = !!(typeof window !== 'undefined' && typeof window.document !== 'undefined' && typeof window.document.createElement !== 'undefined'); - - var PLUGIN_EVENT_SYSTEM = 1; - var IS_REPLAYED = 1 << 5; - var IS_FIRST_ANCESTOR = 1 << 6; - - var restoreImpl = null; - var restoreTarget = null; - var restoreQueue = null; - - function restoreStateOfTarget(target) { - // We perform this translation at the end of the event loop so that we - // always receive the correct fiber here - var internalInstance = getInstanceFromNode(target); - - if (!internalInstance) { - // Unmounted - return; - } - - if (!(typeof restoreImpl === 'function')) { - { - throw Error( "setRestoreImplementation() needs to be called to handle a target for controlled events. This error is likely caused by a bug in React. Please file an issue." ); - } - } - - var stateNode = internalInstance.stateNode; // Guard against Fiber being unmounted. - - if (stateNode) { - var _props = getFiberCurrentPropsFromNode(stateNode); - - restoreImpl(internalInstance.stateNode, internalInstance.type, _props); - } - } - - function setRestoreImplementation(impl) { - restoreImpl = impl; - } - function enqueueStateRestore(target) { - if (restoreTarget) { - if (restoreQueue) { - restoreQueue.push(target); - } else { - restoreQueue = [target]; - } - } else { - restoreTarget = target; - } - } - function needsStateRestore() { - return restoreTarget !== null || restoreQueue !== null; - } - function restoreStateIfNeeded() { - if (!restoreTarget) { - return; - } - - var target = restoreTarget; - var queuedTargets = restoreQueue; - restoreTarget = null; - restoreQueue = null; - restoreStateOfTarget(target); - - if (queuedTargets) { - for (var i = 0; i < queuedTargets.length; i++) { - restoreStateOfTarget(queuedTargets[i]); - } - } - } - - var enableProfilerTimer = true; // Trace which interactions trigger each commit. - - var enableDeprecatedFlareAPI = false; // Experimental Host Component support. - - var enableFundamentalAPI = false; // Experimental Scope support. - var warnAboutStringRefs = false; - - // the renderer. Such as when we're dispatching events or if third party - // libraries need to call batchedUpdates. Eventually, this API will go away when - // everything is batched by default. We'll then have a similar API to opt-out of - // scheduled work and instead do synchronous work. - // Defaults - - var batchedUpdatesImpl = function (fn, bookkeeping) { - return fn(bookkeeping); - }; - - var discreteUpdatesImpl = function (fn, a, b, c, d) { - return fn(a, b, c, d); - }; - - var flushDiscreteUpdatesImpl = function () {}; - - var batchedEventUpdatesImpl = batchedUpdatesImpl; - var isInsideEventHandler = false; - var isBatchingEventUpdates = false; - - function finishEventHandler() { - // Here we wait until all updates have propagated, which is important - // when using controlled components within layers: - // https://github.com/facebook/react/issues/1698 - // Then we restore state of any controlled component. - var controlledComponentsHavePendingUpdates = needsStateRestore(); - - if (controlledComponentsHavePendingUpdates) { - // If a controlled event was fired, we may need to restore the state of - // the DOM node back to the controlled value. This is necessary when React - // bails out of the update without touching the DOM. - flushDiscreteUpdatesImpl(); - restoreStateIfNeeded(); - } - } - - function batchedUpdates(fn, bookkeeping) { - if (isInsideEventHandler) { - // If we are currently inside another batch, we need to wait until it - // fully completes before restoring state. - return fn(bookkeeping); - } - - isInsideEventHandler = true; - - try { - return batchedUpdatesImpl(fn, bookkeeping); - } finally { - isInsideEventHandler = false; - finishEventHandler(); - } - } - function batchedEventUpdates(fn, a, b) { - if (isBatchingEventUpdates) { - // If we are currently inside another batch, we need to wait until it - // fully completes before restoring state. - return fn(a, b); - } - - isBatchingEventUpdates = true; - - try { - return batchedEventUpdatesImpl(fn, a, b); - } finally { - isBatchingEventUpdates = false; - finishEventHandler(); - } - } // This is for the React Flare event system - function discreteUpdates(fn, a, b, c, d) { - var prevIsInsideEventHandler = isInsideEventHandler; - isInsideEventHandler = true; - - try { - return discreteUpdatesImpl(fn, a, b, c, d); - } finally { - isInsideEventHandler = prevIsInsideEventHandler; - - if (!isInsideEventHandler) { - finishEventHandler(); - } - } - } - function flushDiscreteUpdatesIfNeeded(timeStamp) { - // event.timeStamp isn't overly reliable due to inconsistencies in - // how different browsers have historically provided the time stamp. - // Some browsers provide high-resolution time stamps for all events, - // some provide low-resolution time stamps for all events. FF < 52 - // even mixes both time stamps together. Some browsers even report - // negative time stamps or time stamps that are 0 (iOS9) in some cases. - // Given we are only comparing two time stamps with equality (!==), - // we are safe from the resolution differences. If the time stamp is 0 - // we bail-out of preventing the flush, which can affect semantics, - // such as if an earlier flush removes or adds event listeners that - // are fired in the subsequent flush. However, this is the same - // behaviour as we had before this change, so the risks are low. - if (!isInsideEventHandler && (!enableDeprecatedFlareAPI )) { - flushDiscreteUpdatesImpl(); - } - } - function setBatchingImplementation(_batchedUpdatesImpl, _discreteUpdatesImpl, _flushDiscreteUpdatesImpl, _batchedEventUpdatesImpl) { - batchedUpdatesImpl = _batchedUpdatesImpl; - discreteUpdatesImpl = _discreteUpdatesImpl; - flushDiscreteUpdatesImpl = _flushDiscreteUpdatesImpl; - batchedEventUpdatesImpl = _batchedEventUpdatesImpl; - } - - var DiscreteEvent = 0; - var UserBlockingEvent = 1; - var ContinuousEvent = 2; - - // A reserved attribute. - // It is handled by React separately and shouldn't be written to the DOM. - var RESERVED = 0; // A simple string attribute. - // Attributes that aren't in the whitelist are presumed to have this type. - - var STRING = 1; // A string attribute that accepts booleans in React. In HTML, these are called - // "enumerated" attributes with "true" and "false" as possible values. - // When true, it should be set to a "true" string. - // When false, it should be set to a "false" string. - - var BOOLEANISH_STRING = 2; // A real boolean attribute. - // When true, it should be present (set either to an empty string or its name). - // When false, it should be omitted. - - var BOOLEAN = 3; // An attribute that can be used as a flag as well as with a value. - // When true, it should be present (set either to an empty string or its name). - // When false, it should be omitted. - // For any other value, should be present with that value. - - var OVERLOADED_BOOLEAN = 4; // An attribute that must be numeric or parse as a numeric. - // When falsy, it should be removed. - - var NUMERIC = 5; // An attribute that must be positive numeric or parse as a positive numeric. - // When falsy, it should be removed. - - var POSITIVE_NUMERIC = 6; - - /* eslint-disable max-len */ - var ATTRIBUTE_NAME_START_CHAR = ":A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD"; - /* eslint-enable max-len */ - - var ATTRIBUTE_NAME_CHAR = ATTRIBUTE_NAME_START_CHAR + "\\-.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040"; - var ROOT_ATTRIBUTE_NAME = 'data-reactroot'; - var VALID_ATTRIBUTE_NAME_REGEX = new RegExp('^[' + ATTRIBUTE_NAME_START_CHAR + '][' + ATTRIBUTE_NAME_CHAR + ']*$'); - var hasOwnProperty = Object.prototype.hasOwnProperty; - var illegalAttributeNameCache = {}; - var validatedAttributeNameCache = {}; - function isAttributeNameSafe(attributeName) { - if (hasOwnProperty.call(validatedAttributeNameCache, attributeName)) { - return true; - } - - if (hasOwnProperty.call(illegalAttributeNameCache, attributeName)) { - return false; - } - - if (VALID_ATTRIBUTE_NAME_REGEX.test(attributeName)) { - validatedAttributeNameCache[attributeName] = true; - return true; - } - - illegalAttributeNameCache[attributeName] = true; - - { - error('Invalid attribute name: `%s`', attributeName); - } - - return false; - } - function shouldIgnoreAttribute(name, propertyInfo, isCustomComponentTag) { - if (propertyInfo !== null) { - return propertyInfo.type === RESERVED; - } - - if (isCustomComponentTag) { - return false; - } - - if (name.length > 2 && (name[0] === 'o' || name[0] === 'O') && (name[1] === 'n' || name[1] === 'N')) { - return true; - } - - return false; - } - function shouldRemoveAttributeWithWarning(name, value, propertyInfo, isCustomComponentTag) { - if (propertyInfo !== null && propertyInfo.type === RESERVED) { - return false; - } - - switch (typeof value) { - case 'function': // $FlowIssue symbol is perfectly valid here - - case 'symbol': - // eslint-disable-line - return true; - - case 'boolean': - { - if (isCustomComponentTag) { - return false; - } - - if (propertyInfo !== null) { - return !propertyInfo.acceptsBooleans; - } else { - var prefix = name.toLowerCase().slice(0, 5); - return prefix !== 'data-' && prefix !== 'aria-'; - } - } - - default: - return false; - } - } - function shouldRemoveAttribute(name, value, propertyInfo, isCustomComponentTag) { - if (value === null || typeof value === 'undefined') { - return true; - } - - if (shouldRemoveAttributeWithWarning(name, value, propertyInfo, isCustomComponentTag)) { - return true; - } - - if (isCustomComponentTag) { - return false; - } - - if (propertyInfo !== null) { - switch (propertyInfo.type) { - case BOOLEAN: - return !value; - - case OVERLOADED_BOOLEAN: - return value === false; - - case NUMERIC: - return isNaN(value); - - case POSITIVE_NUMERIC: - return isNaN(value) || value < 1; - } - } - - return false; - } - function getPropertyInfo(name) { - return properties.hasOwnProperty(name) ? properties[name] : null; - } - - function PropertyInfoRecord(name, type, mustUseProperty, attributeName, attributeNamespace, sanitizeURL) { - this.acceptsBooleans = type === BOOLEANISH_STRING || type === BOOLEAN || type === OVERLOADED_BOOLEAN; - this.attributeName = attributeName; - this.attributeNamespace = attributeNamespace; - this.mustUseProperty = mustUseProperty; - this.propertyName = name; - this.type = type; - this.sanitizeURL = sanitizeURL; - } // When adding attributes to this list, be sure to also add them to - // the `possibleStandardNames` module to ensure casing and incorrect - // name warnings. - - - var properties = {}; // These props are reserved by React. They shouldn't be written to the DOM. - - var reservedProps = ['children', 'dangerouslySetInnerHTML', // TODO: This prevents the assignment of defaultValue to regular - // elements (not just inputs). Now that ReactDOMInput assigns to the - // defaultValue property -- do we need this? - 'defaultValue', 'defaultChecked', 'innerHTML', 'suppressContentEditableWarning', 'suppressHydrationWarning', 'style']; - - reservedProps.forEach(function (name) { - properties[name] = new PropertyInfoRecord(name, RESERVED, false, // mustUseProperty - name, // attributeName - null, // attributeNamespace - false); - }); // A few React string attributes have a different name. - // This is a mapping from React prop names to the attribute names. - - [['acceptCharset', 'accept-charset'], ['className', 'class'], ['htmlFor', 'for'], ['httpEquiv', 'http-equiv']].forEach(function (_ref) { - var name = _ref[0], - attributeName = _ref[1]; - properties[name] = new PropertyInfoRecord(name, STRING, false, // mustUseProperty - attributeName, // attributeName - null, // attributeNamespace - false); - }); // These are "enumerated" HTML attributes that accept "true" and "false". - // In React, we let users pass `true` and `false` even though technically - // these aren't boolean attributes (they are coerced to strings). - - ['contentEditable', 'draggable', 'spellCheck', 'value'].forEach(function (name) { - properties[name] = new PropertyInfoRecord(name, BOOLEANISH_STRING, false, // mustUseProperty - name.toLowerCase(), // attributeName - null, // attributeNamespace - false); - }); // These are "enumerated" SVG attributes that accept "true" and "false". - // In React, we let users pass `true` and `false` even though technically - // these aren't boolean attributes (they are coerced to strings). - // Since these are SVG attributes, their attribute names are case-sensitive. - - ['autoReverse', 'externalResourcesRequired', 'focusable', 'preserveAlpha'].forEach(function (name) { - properties[name] = new PropertyInfoRecord(name, BOOLEANISH_STRING, false, // mustUseProperty - name, // attributeName - null, // attributeNamespace - false); - }); // These are HTML boolean attributes. - - ['allowFullScreen', 'async', // Note: there is a special case that prevents it from being written to the DOM - // on the client side because the browsers are inconsistent. Instead we call focus(). - 'autoFocus', 'autoPlay', 'controls', 'default', 'defer', 'disabled', 'disablePictureInPicture', 'formNoValidate', 'hidden', 'loop', 'noModule', 'noValidate', 'open', 'playsInline', 'readOnly', 'required', 'reversed', 'scoped', 'seamless', // Microdata - 'itemScope'].forEach(function (name) { - properties[name] = new PropertyInfoRecord(name, BOOLEAN, false, // mustUseProperty - name.toLowerCase(), // attributeName - null, // attributeNamespace - false); - }); // These are the few React props that we set as DOM properties - // rather than attributes. These are all booleans. - - ['checked', // Note: `option.selected` is not updated if `select.multiple` is - // disabled with `removeAttribute`. We have special logic for handling this. - 'multiple', 'muted', 'selected' // NOTE: if you add a camelCased prop to this list, - // you'll need to set attributeName to name.toLowerCase() - // instead in the assignment below. - ].forEach(function (name) { - properties[name] = new PropertyInfoRecord(name, BOOLEAN, true, // mustUseProperty - name, // attributeName - null, // attributeNamespace - false); - }); // These are HTML attributes that are "overloaded booleans": they behave like - // booleans, but can also accept a string value. - - ['capture', 'download' // NOTE: if you add a camelCased prop to this list, - // you'll need to set attributeName to name.toLowerCase() - // instead in the assignment below. - ].forEach(function (name) { - properties[name] = new PropertyInfoRecord(name, OVERLOADED_BOOLEAN, false, // mustUseProperty - name, // attributeName - null, // attributeNamespace - false); - }); // These are HTML attributes that must be positive numbers. - - ['cols', 'rows', 'size', 'span' // NOTE: if you add a camelCased prop to this list, - // you'll need to set attributeName to name.toLowerCase() - // instead in the assignment below. - ].forEach(function (name) { - properties[name] = new PropertyInfoRecord(name, POSITIVE_NUMERIC, false, // mustUseProperty - name, // attributeName - null, // attributeNamespace - false); - }); // These are HTML attributes that must be numbers. - - ['rowSpan', 'start'].forEach(function (name) { - properties[name] = new PropertyInfoRecord(name, NUMERIC, false, // mustUseProperty - name.toLowerCase(), // attributeName - null, // attributeNamespace - false); - }); - var CAMELIZE = /[\-\:]([a-z])/g; - - var capitalize = function (token) { - return token[1].toUpperCase(); - }; // This is a list of all SVG attributes that need special casing, namespacing, - // or boolean value assignment. Regular attributes that just accept strings - // and have the same names are omitted, just like in the HTML whitelist. - // Some of these attributes can be hard to find. This list was created by - // scraping the MDN documentation. - - - ['accent-height', 'alignment-baseline', 'arabic-form', 'baseline-shift', 'cap-height', 'clip-path', 'clip-rule', 'color-interpolation', 'color-interpolation-filters', 'color-profile', 'color-rendering', 'dominant-baseline', 'enable-background', 'fill-opacity', 'fill-rule', 'flood-color', 'flood-opacity', 'font-family', 'font-size', 'font-size-adjust', 'font-stretch', 'font-style', 'font-variant', 'font-weight', 'glyph-name', 'glyph-orientation-horizontal', 'glyph-orientation-vertical', 'horiz-adv-x', 'horiz-origin-x', 'image-rendering', 'letter-spacing', 'lighting-color', 'marker-end', 'marker-mid', 'marker-start', 'overline-position', 'overline-thickness', 'paint-order', 'panose-1', 'pointer-events', 'rendering-intent', 'shape-rendering', 'stop-color', 'stop-opacity', 'strikethrough-position', 'strikethrough-thickness', 'stroke-dasharray', 'stroke-dashoffset', 'stroke-linecap', 'stroke-linejoin', 'stroke-miterlimit', 'stroke-opacity', 'stroke-width', 'text-anchor', 'text-decoration', 'text-rendering', 'underline-position', 'underline-thickness', 'unicode-bidi', 'unicode-range', 'units-per-em', 'v-alphabetic', 'v-hanging', 'v-ideographic', 'v-mathematical', 'vector-effect', 'vert-adv-y', 'vert-origin-x', 'vert-origin-y', 'word-spacing', 'writing-mode', 'xmlns:xlink', 'x-height' // NOTE: if you add a camelCased prop to this list, - // you'll need to set attributeName to name.toLowerCase() - // instead in the assignment below. - ].forEach(function (attributeName) { - var name = attributeName.replace(CAMELIZE, capitalize); - properties[name] = new PropertyInfoRecord(name, STRING, false, // mustUseProperty - attributeName, null, // attributeNamespace - false); - }); // String SVG attributes with the xlink namespace. - - ['xlink:actuate', 'xlink:arcrole', 'xlink:role', 'xlink:show', 'xlink:title', 'xlink:type' // NOTE: if you add a camelCased prop to this list, - // you'll need to set attributeName to name.toLowerCase() - // instead in the assignment below. - ].forEach(function (attributeName) { - var name = attributeName.replace(CAMELIZE, capitalize); - properties[name] = new PropertyInfoRecord(name, STRING, false, // mustUseProperty - attributeName, 'http://www.w3.org/1999/xlink', false); - }); // String SVG attributes with the xml namespace. - - ['xml:base', 'xml:lang', 'xml:space' // NOTE: if you add a camelCased prop to this list, - // you'll need to set attributeName to name.toLowerCase() - // instead in the assignment below. - ].forEach(function (attributeName) { - var name = attributeName.replace(CAMELIZE, capitalize); - properties[name] = new PropertyInfoRecord(name, STRING, false, // mustUseProperty - attributeName, 'http://www.w3.org/XML/1998/namespace', false); - }); // These attribute exists both in HTML and SVG. - // The attribute name is case-sensitive in SVG so we can't just use - // the React name like we do for attributes that exist only in HTML. - - ['tabIndex', 'crossOrigin'].forEach(function (attributeName) { - properties[attributeName] = new PropertyInfoRecord(attributeName, STRING, false, // mustUseProperty - attributeName.toLowerCase(), // attributeName - null, // attributeNamespace - false); - }); // These attributes accept URLs. These must not allow javascript: URLS. - // These will also need to accept Trusted Types object in the future. - - var xlinkHref = 'xlinkHref'; - properties[xlinkHref] = new PropertyInfoRecord('xlinkHref', STRING, false, // mustUseProperty - 'xlink:href', 'http://www.w3.org/1999/xlink', true); - ['src', 'href', 'action', 'formAction'].forEach(function (attributeName) { - properties[attributeName] = new PropertyInfoRecord(attributeName, STRING, false, // mustUseProperty - attributeName.toLowerCase(), // attributeName - null, // attributeNamespace - true); - }); - - var ReactDebugCurrentFrame = null; - - { - ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame; - } // A javascript: URL can contain leading C0 control or \u0020 SPACE, - // and any newline or tab are filtered out as if they're not part of the URL. - // https://url.spec.whatwg.org/#url-parsing - // Tab or newline are defined as \r\n\t: - // https://infra.spec.whatwg.org/#ascii-tab-or-newline - // A C0 control is a code point in the range \u0000 NULL to \u001F - // INFORMATION SEPARATOR ONE, inclusive: - // https://infra.spec.whatwg.org/#c0-control-or-space - - /* eslint-disable max-len */ - - - var isJavaScriptProtocol = /^[\u0000-\u001F ]*j[\r\n\t]*a[\r\n\t]*v[\r\n\t]*a[\r\n\t]*s[\r\n\t]*c[\r\n\t]*r[\r\n\t]*i[\r\n\t]*p[\r\n\t]*t[\r\n\t]*\:/i; - var didWarn = false; - - function sanitizeURL(url) { - { - if (!didWarn && isJavaScriptProtocol.test(url)) { - didWarn = true; - - error('A future version of React will block javascript: URLs as a security precaution. ' + 'Use event handlers instead if you can. If you need to generate unsafe HTML try ' + 'using dangerouslySetInnerHTML instead. React was passed %s.', JSON.stringify(url)); - } - } - } - - /** - * Get the value for a property on a node. Only used in DEV for SSR validation. - * The "expected" argument is used as a hint of what the expected value is. - * Some properties have multiple equivalent values. - */ - function getValueForProperty(node, name, expected, propertyInfo) { - { - if (propertyInfo.mustUseProperty) { - var propertyName = propertyInfo.propertyName; - return node[propertyName]; - } else { - if ( propertyInfo.sanitizeURL) { - // If we haven't fully disabled javascript: URLs, and if - // the hydration is successful of a javascript: URL, we - // still want to warn on the client. - sanitizeURL('' + expected); - } - - var attributeName = propertyInfo.attributeName; - var stringValue = null; - - if (propertyInfo.type === OVERLOADED_BOOLEAN) { - if (node.hasAttribute(attributeName)) { - var value = node.getAttribute(attributeName); - - if (value === '') { - return true; - } - - if (shouldRemoveAttribute(name, expected, propertyInfo, false)) { - return value; - } - - if (value === '' + expected) { - return expected; - } - - return value; - } - } else if (node.hasAttribute(attributeName)) { - if (shouldRemoveAttribute(name, expected, propertyInfo, false)) { - // We had an attribute but shouldn't have had one, so read it - // for the error message. - return node.getAttribute(attributeName); - } - - if (propertyInfo.type === BOOLEAN) { - // If this was a boolean, it doesn't matter what the value is - // the fact that we have it is the same as the expected. - return expected; - } // Even if this property uses a namespace we use getAttribute - // because we assume its namespaced name is the same as our config. - // To use getAttributeNS we need the local name which we don't have - // in our config atm. - - - stringValue = node.getAttribute(attributeName); - } - - if (shouldRemoveAttribute(name, expected, propertyInfo, false)) { - return stringValue === null ? expected : stringValue; - } else if (stringValue === '' + expected) { - return expected; - } else { - return stringValue; - } - } - } - } - /** - * Get the value for a attribute on a node. Only used in DEV for SSR validation. - * The third argument is used as a hint of what the expected value is. Some - * attributes have multiple equivalent values. - */ - - function getValueForAttribute(node, name, expected) { - { - if (!isAttributeNameSafe(name)) { - return; - } - - if (!node.hasAttribute(name)) { - return expected === undefined ? undefined : null; - } - - var value = node.getAttribute(name); - - if (value === '' + expected) { - return expected; - } - - return value; - } - } - /** - * Sets the value for a property on a node. - * - * @param {DOMElement} node - * @param {string} name - * @param {*} value - */ - - function setValueForProperty(node, name, value, isCustomComponentTag) { - var propertyInfo = getPropertyInfo(name); - - if (shouldIgnoreAttribute(name, propertyInfo, isCustomComponentTag)) { - return; - } - - if (shouldRemoveAttribute(name, value, propertyInfo, isCustomComponentTag)) { - value = null; - } // If the prop isn't in the special list, treat it as a simple attribute. - - - if (isCustomComponentTag || propertyInfo === null) { - if (isAttributeNameSafe(name)) { - var _attributeName = name; - - if (value === null) { - node.removeAttribute(_attributeName); - } else { - node.setAttribute(_attributeName, '' + value); - } - } - - return; - } - - var mustUseProperty = propertyInfo.mustUseProperty; - - if (mustUseProperty) { - var propertyName = propertyInfo.propertyName; - - if (value === null) { - var type = propertyInfo.type; - node[propertyName] = type === BOOLEAN ? false : ''; - } else { - // Contrary to `setAttribute`, object properties are properly - // `toString`ed by IE8/9. - node[propertyName] = value; - } - - return; - } // The rest are treated as attributes with special cases. - - - var attributeName = propertyInfo.attributeName, - attributeNamespace = propertyInfo.attributeNamespace; - - if (value === null) { - node.removeAttribute(attributeName); - } else { - var _type = propertyInfo.type; - var attributeValue; - - if (_type === BOOLEAN || _type === OVERLOADED_BOOLEAN && value === true) { - // If attribute type is boolean, we know for sure it won't be an execution sink - // and we won't require Trusted Type here. - attributeValue = ''; - } else { - // `setAttribute` with objects becomes only `[object]` in IE8/9, - // ('' + value) makes it output the correct toString()-value. - { - attributeValue = '' + value; - } - - if (propertyInfo.sanitizeURL) { - sanitizeURL(attributeValue.toString()); - } - } - - if (attributeNamespace) { - node.setAttributeNS(attributeNamespace, attributeName, attributeValue); - } else { - node.setAttribute(attributeName, attributeValue); - } - } - } - - var BEFORE_SLASH_RE = /^(.*)[\\\/]/; - function describeComponentFrame (name, source, ownerName) { - var sourceInfo = ''; - - if (source) { - var path = source.fileName; - var fileName = path.replace(BEFORE_SLASH_RE, ''); - - { - // In DEV, include code for a common special case: - // prefer "folder/index.js" instead of just "index.js". - if (/^index\./.test(fileName)) { - var match = path.match(BEFORE_SLASH_RE); - - if (match) { - var pathBeforeSlash = match[1]; - - if (pathBeforeSlash) { - var folderName = pathBeforeSlash.replace(BEFORE_SLASH_RE, ''); - fileName = folderName + '/' + fileName; - } - } - } - } - - sourceInfo = ' (at ' + fileName + ':' + source.lineNumber + ')'; - } else if (ownerName) { - sourceInfo = ' (created by ' + ownerName + ')'; - } - - return '\n in ' + (name || 'Unknown') + sourceInfo; - } - - // The Symbol used to tag the ReactElement-like types. If there is no native Symbol - // nor polyfill, then a plain number is used for performance. - var hasSymbol = typeof Symbol === 'function' && Symbol.for; - var REACT_ELEMENT_TYPE = hasSymbol ? Symbol.for('react.element') : 0xeac7; - var REACT_PORTAL_TYPE = hasSymbol ? Symbol.for('react.portal') : 0xeaca; - var REACT_FRAGMENT_TYPE = hasSymbol ? Symbol.for('react.fragment') : 0xeacb; - var REACT_STRICT_MODE_TYPE = hasSymbol ? Symbol.for('react.strict_mode') : 0xeacc; - var REACT_PROFILER_TYPE = hasSymbol ? Symbol.for('react.profiler') : 0xead2; - var REACT_PROVIDER_TYPE = hasSymbol ? Symbol.for('react.provider') : 0xeacd; - var REACT_CONTEXT_TYPE = hasSymbol ? Symbol.for('react.context') : 0xeace; // TODO: We don't use AsyncMode or ConcurrentMode anymore. They were temporary - var REACT_CONCURRENT_MODE_TYPE = hasSymbol ? Symbol.for('react.concurrent_mode') : 0xeacf; - var REACT_FORWARD_REF_TYPE = hasSymbol ? Symbol.for('react.forward_ref') : 0xead0; - var REACT_SUSPENSE_TYPE = hasSymbol ? Symbol.for('react.suspense') : 0xead1; - var REACT_SUSPENSE_LIST_TYPE = hasSymbol ? Symbol.for('react.suspense_list') : 0xead8; - var REACT_MEMO_TYPE = hasSymbol ? Symbol.for('react.memo') : 0xead3; - var REACT_LAZY_TYPE = hasSymbol ? Symbol.for('react.lazy') : 0xead4; - var REACT_BLOCK_TYPE = hasSymbol ? Symbol.for('react.block') : 0xead9; - var MAYBE_ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator; - var FAUX_ITERATOR_SYMBOL = '@@iterator'; - function getIteratorFn(maybeIterable) { - if (maybeIterable === null || typeof maybeIterable !== 'object') { - return null; - } - - var maybeIterator = MAYBE_ITERATOR_SYMBOL && maybeIterable[MAYBE_ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL]; - - if (typeof maybeIterator === 'function') { - return maybeIterator; - } - - return null; - } - - var Uninitialized = -1; - var Pending = 0; - var Resolved = 1; - var Rejected = 2; - function refineResolvedLazyComponent(lazyComponent) { - return lazyComponent._status === Resolved ? lazyComponent._result : null; - } - function initializeLazyComponentType(lazyComponent) { - if (lazyComponent._status === Uninitialized) { - lazyComponent._status = Pending; - var ctor = lazyComponent._ctor; - var thenable = ctor(); - lazyComponent._result = thenable; - thenable.then(function (moduleObject) { - if (lazyComponent._status === Pending) { - var defaultExport = moduleObject.default; - - { - if (defaultExport === undefined) { - error('lazy: Expected the result of a dynamic import() call. ' + 'Instead received: %s\n\nYour code should look like: \n ' + "const MyComponent = lazy(() => import('./MyComponent'))", moduleObject); - } - } - - lazyComponent._status = Resolved; - lazyComponent._result = defaultExport; - } - }, function (error) { - if (lazyComponent._status === Pending) { - lazyComponent._status = Rejected; - lazyComponent._result = error; - } - }); - } - } - - function getWrappedName(outerType, innerType, wrapperName) { - var functionName = innerType.displayName || innerType.name || ''; - return outerType.displayName || (functionName !== '' ? wrapperName + "(" + functionName + ")" : wrapperName); - } - - function getComponentName(type) { - if (type == null) { - // Host root, text node or just invalid type. - return null; - } - - { - if (typeof type.tag === 'number') { - error('Received an unexpected object in getComponentName(). ' + 'This is likely a bug in React. Please file an issue.'); - } - } - - if (typeof type === 'function') { - return type.displayName || type.name || null; - } - - if (typeof type === 'string') { - return type; - } - - switch (type) { - case REACT_FRAGMENT_TYPE: - return 'Fragment'; - - case REACT_PORTAL_TYPE: - return 'Portal'; - - case REACT_PROFILER_TYPE: - return "Profiler"; - - case REACT_STRICT_MODE_TYPE: - return 'StrictMode'; - - case REACT_SUSPENSE_TYPE: - return 'Suspense'; - - case REACT_SUSPENSE_LIST_TYPE: - return 'SuspenseList'; - } - - if (typeof type === 'object') { - switch (type.$$typeof) { - case REACT_CONTEXT_TYPE: - return 'Context.Consumer'; - - case REACT_PROVIDER_TYPE: - return 'Context.Provider'; - - case REACT_FORWARD_REF_TYPE: - return getWrappedName(type, type.render, 'ForwardRef'); - - case REACT_MEMO_TYPE: - return getComponentName(type.type); - - case REACT_BLOCK_TYPE: - return getComponentName(type.render); - - case REACT_LAZY_TYPE: - { - var thenable = type; - var resolvedThenable = refineResolvedLazyComponent(thenable); - - if (resolvedThenable) { - return getComponentName(resolvedThenable); - } - - break; - } - } - } - - return null; - } - - var ReactDebugCurrentFrame$1 = ReactSharedInternals.ReactDebugCurrentFrame; - - function describeFiber(fiber) { - switch (fiber.tag) { - case HostRoot: - case HostPortal: - case HostText: - case Fragment: - case ContextProvider: - case ContextConsumer: - return ''; - - default: - var owner = fiber._debugOwner; - var source = fiber._debugSource; - var name = getComponentName(fiber.type); - var ownerName = null; - - if (owner) { - ownerName = getComponentName(owner.type); - } - - return describeComponentFrame(name, source, ownerName); - } - } - - function getStackByFiberInDevAndProd(workInProgress) { - var info = ''; - var node = workInProgress; - - do { - info += describeFiber(node); - node = node.return; - } while (node); - - return info; - } - var current = null; - var isRendering = false; - function getCurrentFiberOwnerNameInDevOrNull() { - { - if (current === null) { - return null; - } - - var owner = current._debugOwner; - - if (owner !== null && typeof owner !== 'undefined') { - return getComponentName(owner.type); - } - } - - return null; - } - function getCurrentFiberStackInDev() { - { - if (current === null) { - return ''; - } // Safe because if current fiber exists, we are reconciling, - // and it is guaranteed to be the work-in-progress version. - - - return getStackByFiberInDevAndProd(current); - } - } - function resetCurrentFiber() { - { - ReactDebugCurrentFrame$1.getCurrentStack = null; - current = null; - isRendering = false; - } - } - function setCurrentFiber(fiber) { - { - ReactDebugCurrentFrame$1.getCurrentStack = getCurrentFiberStackInDev; - current = fiber; - isRendering = false; - } - } - function setIsRendering(rendering) { - { - isRendering = rendering; - } - } - - // Flow does not allow string concatenation of most non-string types. To work - // around this limitation, we use an opaque type that can only be obtained by - // passing the value through getToStringValue first. - function toString(value) { - return '' + value; - } - function getToStringValue(value) { - switch (typeof value) { - case 'boolean': - case 'number': - case 'object': - case 'string': - case 'undefined': - return value; - - default: - // function, symbol are assigned as empty strings - return ''; - } - } - - var ReactDebugCurrentFrame$2 = null; - var ReactControlledValuePropTypes = { - checkPropTypes: null - }; - - { - ReactDebugCurrentFrame$2 = ReactSharedInternals.ReactDebugCurrentFrame; - var hasReadOnlyValue = { - button: true, - checkbox: true, - image: true, - hidden: true, - radio: true, - reset: true, - submit: true - }; - var propTypes = { - value: function (props, propName, componentName) { - if (hasReadOnlyValue[props.type] || props.onChange || props.readOnly || props.disabled || props[propName] == null || enableDeprecatedFlareAPI ) { - return null; - } - - return new Error('You provided a `value` prop to a form field without an ' + '`onChange` handler. This will render a read-only field. If ' + 'the field should be mutable use `defaultValue`. Otherwise, ' + 'set either `onChange` or `readOnly`.'); - }, - checked: function (props, propName, componentName) { - if (props.onChange || props.readOnly || props.disabled || props[propName] == null || enableDeprecatedFlareAPI ) { - return null; - } - - return new Error('You provided a `checked` prop to a form field without an ' + '`onChange` handler. This will render a read-only field. If ' + 'the field should be mutable use `defaultChecked`. Otherwise, ' + 'set either `onChange` or `readOnly`.'); - } - }; - /** - * Provide a linked `value` attribute for controlled forms. You should not use - * this outside of the ReactDOM controlled form components. - */ - - ReactControlledValuePropTypes.checkPropTypes = function (tagName, props) { - checkPropTypes(propTypes, props, 'prop', tagName, ReactDebugCurrentFrame$2.getStackAddendum); - }; - } - - function isCheckable(elem) { - var type = elem.type; - var nodeName = elem.nodeName; - return nodeName && nodeName.toLowerCase() === 'input' && (type === 'checkbox' || type === 'radio'); - } - - function getTracker(node) { - return node._valueTracker; - } - - function detachTracker(node) { - node._valueTracker = null; - } - - function getValueFromNode(node) { - var value = ''; - - if (!node) { - return value; - } - - if (isCheckable(node)) { - value = node.checked ? 'true' : 'false'; - } else { - value = node.value; - } - - return value; - } - - function trackValueOnNode(node) { - var valueField = isCheckable(node) ? 'checked' : 'value'; - var descriptor = Object.getOwnPropertyDescriptor(node.constructor.prototype, valueField); - var currentValue = '' + node[valueField]; // if someone has already defined a value or Safari, then bail - // and don't track value will cause over reporting of changes, - // but it's better then a hard failure - // (needed for certain tests that spyOn input values and Safari) - - if (node.hasOwnProperty(valueField) || typeof descriptor === 'undefined' || typeof descriptor.get !== 'function' || typeof descriptor.set !== 'function') { - return; - } - - var get = descriptor.get, - set = descriptor.set; - Object.defineProperty(node, valueField, { - configurable: true, - get: function () { - return get.call(this); - }, - set: function (value) { - currentValue = '' + value; - set.call(this, value); - } - }); // We could've passed this the first time - // but it triggers a bug in IE11 and Edge 14/15. - // Calling defineProperty() again should be equivalent. - // https://github.com/facebook/react/issues/11768 - - Object.defineProperty(node, valueField, { - enumerable: descriptor.enumerable - }); - var tracker = { - getValue: function () { - return currentValue; - }, - setValue: function (value) { - currentValue = '' + value; - }, - stopTracking: function () { - detachTracker(node); - delete node[valueField]; - } - }; - return tracker; - } - - function track(node) { - if (getTracker(node)) { - return; - } // TODO: Once it's just Fiber we can move this to node._wrapperState - - - node._valueTracker = trackValueOnNode(node); - } - function updateValueIfChanged(node) { - if (!node) { - return false; - } - - var tracker = getTracker(node); // if there is no tracker at this point it's unlikely - // that trying again will succeed - - if (!tracker) { - return true; - } - - var lastValue = tracker.getValue(); - var nextValue = getValueFromNode(node); - - if (nextValue !== lastValue) { - tracker.setValue(nextValue); - return true; - } - - return false; - } - - var didWarnValueDefaultValue = false; - var didWarnCheckedDefaultChecked = false; - var didWarnControlledToUncontrolled = false; - var didWarnUncontrolledToControlled = false; - - function isControlled(props) { - var usesChecked = props.type === 'checkbox' || props.type === 'radio'; - return usesChecked ? props.checked != null : props.value != null; - } - /** - * Implements an host component that allows setting these optional - * props: `checked`, `value`, `defaultChecked`, and `defaultValue`. - * - * If `checked` or `value` are not supplied (or null/undefined), user actions - * that affect the checked state or value will trigger updates to the element. - * - * If they are supplied (and not null/undefined), the rendered element will not - * trigger updates to the element. Instead, the props must change in order for - * the rendered element to be updated. - * - * The rendered element will be initialized as unchecked (or `defaultChecked`) - * with an empty value (or `defaultValue`). - * - * See http://www.w3.org/TR/2012/WD-html5-20121025/the-input-element.html - */ - - - function getHostProps(element, props) { - var node = element; - var checked = props.checked; - - var hostProps = _assign({}, props, { - defaultChecked: undefined, - defaultValue: undefined, - value: undefined, - checked: checked != null ? checked : node._wrapperState.initialChecked - }); - - return hostProps; - } - function initWrapperState(element, props) { - { - ReactControlledValuePropTypes.checkPropTypes('input', props); - - if (props.checked !== undefined && props.defaultChecked !== undefined && !didWarnCheckedDefaultChecked) { - error('%s contains an input of type %s with both checked and defaultChecked props. ' + 'Input elements must be either controlled or uncontrolled ' + '(specify either the checked prop, or the defaultChecked prop, but not ' + 'both). Decide between using a controlled or uncontrolled input ' + 'element and remove one of these props. More info: ' + 'https://fb.me/react-controlled-components', getCurrentFiberOwnerNameInDevOrNull() || 'A component', props.type); - - didWarnCheckedDefaultChecked = true; - } - - if (props.value !== undefined && props.defaultValue !== undefined && !didWarnValueDefaultValue) { - error('%s contains an input of type %s with both value and defaultValue props. ' + 'Input elements must be either controlled or uncontrolled ' + '(specify either the value prop, or the defaultValue prop, but not ' + 'both). Decide between using a controlled or uncontrolled input ' + 'element and remove one of these props. More info: ' + 'https://fb.me/react-controlled-components', getCurrentFiberOwnerNameInDevOrNull() || 'A component', props.type); - - didWarnValueDefaultValue = true; - } - } - - var node = element; - var defaultValue = props.defaultValue == null ? '' : props.defaultValue; - node._wrapperState = { - initialChecked: props.checked != null ? props.checked : props.defaultChecked, - initialValue: getToStringValue(props.value != null ? props.value : defaultValue), - controlled: isControlled(props) - }; - } - function updateChecked(element, props) { - var node = element; - var checked = props.checked; - - if (checked != null) { - setValueForProperty(node, 'checked', checked, false); - } - } - function updateWrapper(element, props) { - var node = element; - - { - var controlled = isControlled(props); - - if (!node._wrapperState.controlled && controlled && !didWarnUncontrolledToControlled) { - error('A component is changing an uncontrolled input of type %s to be controlled. ' + 'Input elements should not switch from uncontrolled to controlled (or vice versa). ' + 'Decide between using a controlled or uncontrolled input ' + 'element for the lifetime of the component. More info: https://fb.me/react-controlled-components', props.type); - - didWarnUncontrolledToControlled = true; - } - - if (node._wrapperState.controlled && !controlled && !didWarnControlledToUncontrolled) { - error('A component is changing a controlled input of type %s to be uncontrolled. ' + 'Input elements should not switch from controlled to uncontrolled (or vice versa). ' + 'Decide between using a controlled or uncontrolled input ' + 'element for the lifetime of the component. More info: https://fb.me/react-controlled-components', props.type); - - didWarnControlledToUncontrolled = true; - } - } - - updateChecked(element, props); - var value = getToStringValue(props.value); - var type = props.type; - - if (value != null) { - if (type === 'number') { - if (value === 0 && node.value === '' || // We explicitly want to coerce to number here if possible. - // eslint-disable-next-line - node.value != value) { - node.value = toString(value); - } - } else if (node.value !== toString(value)) { - node.value = toString(value); - } - } else if (type === 'submit' || type === 'reset') { - // Submit/reset inputs need the attribute removed completely to avoid - // blank-text buttons. - node.removeAttribute('value'); - return; - } - - { - // When syncing the value attribute, the value comes from a cascade of - // properties: - // 1. The value React property - // 2. The defaultValue React property - // 3. Otherwise there should be no change - if (props.hasOwnProperty('value')) { - setDefaultValue(node, props.type, value); - } else if (props.hasOwnProperty('defaultValue')) { - setDefaultValue(node, props.type, getToStringValue(props.defaultValue)); - } - } - - { - // When syncing the checked attribute, it only changes when it needs - // to be removed, such as transitioning from a checkbox into a text input - if (props.checked == null && props.defaultChecked != null) { - node.defaultChecked = !!props.defaultChecked; - } - } - } - function postMountWrapper(element, props, isHydrating) { - var node = element; // Do not assign value if it is already set. This prevents user text input - // from being lost during SSR hydration. - - if (props.hasOwnProperty('value') || props.hasOwnProperty('defaultValue')) { - var type = props.type; - var isButton = type === 'submit' || type === 'reset'; // Avoid setting value attribute on submit/reset inputs as it overrides the - // default value provided by the browser. See: #12872 - - if (isButton && (props.value === undefined || props.value === null)) { - return; - } - - var initialValue = toString(node._wrapperState.initialValue); // Do not assign value if it is already set. This prevents user text input - // from being lost during SSR hydration. - - if (!isHydrating) { - { - // When syncing the value attribute, the value property should use - // the wrapperState._initialValue property. This uses: - // - // 1. The value React property when present - // 2. The defaultValue React property when present - // 3. An empty string - if (initialValue !== node.value) { - node.value = initialValue; - } - } - } - - { - // Otherwise, the value attribute is synchronized to the property, - // so we assign defaultValue to the same thing as the value property - // assignment step above. - node.defaultValue = initialValue; - } - } // Normally, we'd just do `node.checked = node.checked` upon initial mount, less this bug - // this is needed to work around a chrome bug where setting defaultChecked - // will sometimes influence the value of checked (even after detachment). - // Reference: https://bugs.chromium.org/p/chromium/issues/detail?id=608416 - // We need to temporarily unset name to avoid disrupting radio button groups. - - - var name = node.name; - - if (name !== '') { - node.name = ''; - } - - { - // When syncing the checked attribute, both the checked property and - // attribute are assigned at the same time using defaultChecked. This uses: - // - // 1. The checked React property when present - // 2. The defaultChecked React property when present - // 3. Otherwise, false - node.defaultChecked = !node.defaultChecked; - node.defaultChecked = !!node._wrapperState.initialChecked; - } - - if (name !== '') { - node.name = name; - } - } - function restoreControlledState(element, props) { - var node = element; - updateWrapper(node, props); - updateNamedCousins(node, props); - } - - function updateNamedCousins(rootNode, props) { - var name = props.name; - - if (props.type === 'radio' && name != null) { - var queryRoot = rootNode; - - while (queryRoot.parentNode) { - queryRoot = queryRoot.parentNode; - } // If `rootNode.form` was non-null, then we could try `form.elements`, - // but that sometimes behaves strangely in IE8. We could also try using - // `form.getElementsByName`, but that will only return direct children - // and won't include inputs that use the HTML5 `form=` attribute. Since - // the input might not even be in a form. It might not even be in the - // document. Let's just use the local `querySelectorAll` to ensure we don't - // miss anything. - - - var group = queryRoot.querySelectorAll('input[name=' + JSON.stringify('' + name) + '][type="radio"]'); - - for (var i = 0; i < group.length; i++) { - var otherNode = group[i]; - - if (otherNode === rootNode || otherNode.form !== rootNode.form) { - continue; - } // This will throw if radio buttons rendered by different copies of React - // and the same name are rendered into the same form (same as #1939). - // That's probably okay; we don't support it just as we don't support - // mixing React radio buttons with non-React ones. - - - var otherProps = getFiberCurrentPropsFromNode$1(otherNode); - - if (!otherProps) { - { - throw Error( "ReactDOMInput: Mixing React and non-React radio inputs with the same `name` is not supported." ); - } - } // We need update the tracked value on the named cousin since the value - // was changed but the input saw no event or value set - - - updateValueIfChanged(otherNode); // If this is a controlled radio button group, forcing the input that - // was previously checked to update will cause it to be come re-checked - // as appropriate. - - updateWrapper(otherNode, otherProps); - } - } - } // In Chrome, assigning defaultValue to certain input types triggers input validation. - // For number inputs, the display value loses trailing decimal points. For email inputs, - // Chrome raises "The specified value is not a valid email address". - // - // Here we check to see if the defaultValue has actually changed, avoiding these problems - // when the user is inputting text - // - // https://github.com/facebook/react/issues/7253 - - - function setDefaultValue(node, type, value) { - if ( // Focused number inputs synchronize on blur. See ChangeEventPlugin.js - type !== 'number' || node.ownerDocument.activeElement !== node) { - if (value == null) { - node.defaultValue = toString(node._wrapperState.initialValue); - } else if (node.defaultValue !== toString(value)) { - node.defaultValue = toString(value); - } - } - } - - var didWarnSelectedSetOnOption = false; - var didWarnInvalidChild = false; - - function flattenChildren(children) { - var content = ''; // Flatten children. We'll warn if they are invalid - // during validateProps() which runs for hydration too. - // Note that this would throw on non-element objects. - // Elements are stringified (which is normally irrelevant - // but matters for ). - - React.Children.forEach(children, function (child) { - if (child == null) { - return; - } - - content += child; // Note: we don't warn about invalid children here. - // Instead, this is done separately below so that - // it happens during the hydration codepath too. - }); - return content; - } - /** - * Implements an