Skip to content

Commit 5f73841

Browse files
committed
Make for loops integers
1 parent 05e6e9e commit 5f73841

File tree

1 file changed

+10
-33
lines changed

1 file changed

+10
-33
lines changed

media/src/objects/Function.svelte

Lines changed: 10 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -341,13 +341,6 @@
341341
$effect(() => (surfaceMesh.visible = graphVisible));
342342
343343
const updateSurface = function () {
344-
// const { a, b, c, d } = params;
345-
// const A = math.parse(a).evaluate();
346-
// const B = math.parse(b).evaluate();
347-
348-
// const C = math.parse(c);
349-
// const D = math.parse(d);
350-
351344
const geometry = new ParametricGeometry(
352345
(u, v, vec) => {
353346
const U = A + (B - A) * u;
@@ -427,7 +420,8 @@
427420
const dx = (B - A) / lcm(nX, cNum);
428421
const points = [];
429422
430-
for (let u = A; u <= B; u += du) {
423+
for (let i = 0; i <= rNum; i++) {
424+
const u = A + i * du;
431425
const cU = C(u);
432426
const dU = D(u);
433427
@@ -436,7 +430,8 @@
436430
// args.y = cU;
437431
438432
points.push(new THREE.Vector3(u, cU, func(u, cU, tVal)));
439-
for (let v = cU + dy; v < dU; v += dy) {
433+
for (let j = 1; j < lcm(nX, rNum); j++) {
434+
const v = cU + j * dy;
440435
// args.y = v;
441436
points.push(new THREE.Vector3(u, v, func(u, v, tVal)));
442437
points.push(new THREE.Vector3(u, v, func(u, v, tVal)));
@@ -449,13 +444,16 @@
449444
// args.x = A;
450445
cMin = C(A);
451446
dMax = D(A);
452-
for (let u = A + dx; u <= B; u += dx) {
447+
for (let i = 1; i <= lcm(nX, cNum); i++) {
448+
const u = A + i * dx;
453449
// args.x = u;
454450
cMin = Math.min(cMin, C(u));
455451
dMax = Math.max(dMax, D(u));
456452
}
457453
458-
for (let v = cMin; v <= dMax; v += (dMax - cMin) / cNum) {
454+
const dv = (dMax - cMin) / cNum;
455+
for (let j = 0; j <= cNum; j++) {
456+
const v = cMin + j * dv;
459457
const zs = marchingSegments(
460458
(x) => (C(x) - v) * (v - D(x)),
461459
A,
@@ -509,6 +507,7 @@
509507
};
510508
511509
function integrateSurface(n = 20) {
510+
// console.log('integrating...');
512511
return gaussLegendre(
513512
(x) => gaussLegendre((y) => func(x, y, tVal), C(x), D(x), n),
514513
A,
@@ -847,28 +846,6 @@
847846
boxMesh.add(boxMeshEdges);
848847
849848
const updateBoxes = function () {
850-
// const { a, b, c, d } = params;
851-
// try {
852-
// [
853-
// math.evaluate(a),
854-
// math.evaluate(b),
855-
// math.evaluate(c),
856-
// math.evaluate(d),
857-
// ];
858-
// } catch (e) {
859-
// console.error("Can't show integral boxes on nonconstant bounds", e);
860-
// return;
861-
// }
862-
863-
// const [A, B, C, D] = [
864-
// math.evaluate(a),
865-
// math.evaluate(b),
866-
// math.evaluate(c),
867-
// math.evaluate(d),
868-
// ];
869-
870-
// const t = T0 + tau * (T1 - T0);
871-
872849
if (boxMesh.geometry) {
873850
boxMesh.geometry.dispose();
874851
boxMeshEdges.geometry.dispose();

0 commit comments

Comments
 (0)