-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
2697 lines (2445 loc) · 140 KB
/
Copy pathindex.html
File metadata and controls
2697 lines (2445 loc) · 140 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="MathSurface — Interactive 3D math surface generator for 3D printing. Visualize and export z = f(x,y) equations as STL files. / Generador interactivo de superficies matemáticas 3D para impresión 3D.">
<meta name="author" content="Sebastián Duarte Villanueva">
<meta property="og:title" content="MathSurface">
<meta property="og:description" content="Visualize and export 3D math surfaces for 3D printing. Enter any z = f(x,y) equation and download as STL.">
<meta property="og:type" content="website">
<meta property="og:url" content="https://sebasdv.github.io/MathSurface/">
<title>MathSurface — by sebasdv</title>
<!-- DEC Typography: Inter + JetBrains Mono -->
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<!-- Deliberately no integrity attribute here. Google generates this
stylesheet per request, varying the @font-face rules by User-Agent, so
a pinned hash would fail on any browser served a different variant. The
page degrades to system-ui if it never arrives, which is why it is safe
to leave unpinned while the two scripts are not. -->
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;600;700;900&family=JetBrains+Mono:wght@400;700&display=swap" rel="stylesheet">
<link rel="stylesheet" href="dec-design-system.css">
</head>
<body>
<div id="app-container">
<!-- HEADER / NAVBAR -->
<div id="header">
<div class="brand">
Math<span class="text-blue">Surface</span>
<!-- The only place the version is written. Bump it together with
CHANGELOG.md and a matching git tag; it sat at v1.0 through 24
commits because nothing tied the three together. -->
<span class="brand-tag">v2.0</span>
</div>
<div style="display:flex; align-items:center; gap:0.75rem;">
<span class="font-mono header-formula" style="font-size:0.65rem; color:var(--dec-text-muted);">z = f(x, y)</span>
<button class="btn btn-ghost btn-icon" id="rotate-toggle" onclick="toggleAutoRotate()" aria-pressed="false" data-i18n-title="pauseRotation" title="Pause rotation">⏸</button>
<button class="btn btn-ghost" id="lang-toggle" style="padding:0.4rem 0.9rem; font-size:0.78rem;" onclick="toggleLang()">ES</button>
<button class="btn btn-ghost" style="padding:0.4rem 0.9rem; font-size:0.78rem;" onclick="openHelp()" data-i18n="help">Help</button>
</div>
</div>
<!-- MAIN CONTENT -->
<div id="main-content">
<!-- 3D CANVAS -->
<div id="canvas-container">
</div>
<!-- CONTROLS SIDEBAR -->
<div id="controls-sidebar">
<!-- MODE SWITCH -->
<div class="mode-switch">
<button class="mode-btn active" id="mode-surfaces" onclick="setMode('surfaces')" data-i18n="modeSurfaces">Surfaces</button>
<button class="mode-btn" id="mode-revolution" onclick="setMode('revolution')" data-i18n="modeRevolution">Revolution</button>
</div>
<!-- SURFACES MODE: equation list -->
<div class="equation-group" id="surfaces-panel">
<div class="section-label">
<span data-i18n="equation">Equations z = f(x, y)</span>
<span class="font-mono text-blue">INPUT</span>
</div>
<div id="surface-list"></div>
<button class="btn btn-ghost btn-add" id="add-surface" onclick="addSurface()" data-i18n="addSurface">+ Add surface</button>
</div>
<!-- REVOLUTION MODE: r = f(x) revolved about the X axis -->
<div class="equation-group" id="revolution-panel" hidden>
<div class="section-label">
<span id="revolution-input-label" data-i18n="revolutionInput">Revolve r = f(x) about X</span>
<span class="font-mono text-blue" id="revolution-method">DISK</span>
</div>
<div class="mode-switch axis-switch">
<button class="mode-btn active" id="axis-x" onclick="setRevAxis('x')" data-i18n="axisX">About X · disk</button>
<button class="mode-btn" id="axis-y" onclick="setRevAxis('y')" data-i18n="axisY">About Y · shell</button>
</div>
<label class="rev-label" id="rev-outer-label" data-i18n="revOuter">Outer radius f(x)</label>
<input type="text" id="rev-outer" class="equation-input-full" value="sqrt(4 - x^2)">
<div class="surface-status" id="rev-outer-status"></div>
<label class="rev-label" id="rev-inner-label" data-i18n="revInner">Inner radius g(x) — empty for a solid disk</label>
<input type="text" id="rev-inner" class="equation-input-full" value="" placeholder="—">
<div class="surface-status" id="rev-inner-status"></div>
<div class="rev-interval">
<label class="rev-label" data-i18n="revInterval">Interval</label>
<span class="font-mono rev-bracket">[</span>
<input type="number" id="rev-a" class="rev-num" value="-2" step="0.1">
<span class="font-mono rev-bracket">,</span>
<input type="number" id="rev-b" class="rev-num" value="2" step="0.1">
<span class="font-mono rev-bracket">]</span>
</div>
</div>
<div class="equation-group">
<div class="button-group">
<button class="btn btn-primary" onclick="regenerateAll()" data-i18n="generate">▶ Generate</button>
<button class="btn btn-ghost" onclick="resetView()" data-i18n="reset">↺ Reset</button>
</div>
</div>
<!-- ACCORDION -->
<div class="accordion accordion-flush">
<!-- Examples (surfaces mode) -->
<div class="accordion-item" id="examples-item">
<button class="accordion-header" onclick="toggleAccordion('examples')">
<span data-i18n="examples">Popular Examples</span>
</button>
<div class="accordion-content" id="examples-accordion">
<div class="accordion-body">
<div class="examples-grid">
<button class="example-btn" onclick="loadExample('A * sin(f*sqrt(x^2 + y^2) + phi)')">A * sin(f*sqrt(x²+y²) + φ)</button>
<button class="example-btn" onclick="loadExample('A * sin(f*x + phi) * cos(f*y)')">A * sin(f*x+φ) * cos(f*y)</button>
<button class="example-btn" onclick="loadExample('A * exp(-(x^2 + y^2) / f)')">A * exp(-(x²+y²) / f)</button>
<button class="example-btn" onclick="loadExample('(y^2 - x^2) / 4')">(y² - x²) / 4</button>
<button class="example-btn" onclick="loadExample('A * cos(f*x + phi) * sin(f*y)')">A * cos(f*x+φ) * sin(f*y)</button>
<button class="example-btn" onclick="loadExample('A * sin(f*x*y + phi)')">A * sin(f*x*y + φ)</button>
</div>
</div>
</div>
</div>
<!-- Examples (revolution mode) — each has a closed-form volume -->
<div class="accordion-item" id="rev-examples-item" hidden>
<button class="accordion-header" onclick="toggleAccordion('rev-examples')">
<span data-i18n="revExamples">Classic Solids</span>
</button>
<div class="accordion-content" id="rev-examples-accordion">
<div class="accordion-body">
<div class="examples-grid">
<button class="example-btn" onclick="loadRevExample('sqrt(4 - x^2)', '', -2, 2, 'x')">Sphere · √(4−x²) · V=32π/3</button>
<button class="example-btn" onclick="loadRevExample('x', '', 0, 3, 'x')">Cone · x · V=9π</button>
<button class="example-btn" onclick="loadRevExample('sqrt(x)', '', 0, 4, 'x')">Paraboloid · √x · V=8π</button>
<button class="example-btn" onclick="loadRevExample('1/x', '', 1, 4, 'x')">Horn · 1/x · V=3π/4</button>
<button class="example-btn" onclick="loadRevExample('sin(x)', '', 0, 3.14159265, 'x')">Bead · sin(x) · V=π²/2</button>
<button class="example-btn" onclick="loadRevExample('2', '1', 0, 4, 'x')">Washer · 2 & 1 · V=12π</button>
<button class="example-btn" onclick="loadRevExample('sqrt(x)', 'x/2', 0, 4, 'x')">Washer · √x & x/2 · V=8π/3</button>
<button class="example-btn" onclick="loadRevExample('2 + cos(f*x)', '', 0, 6, 'x')">Vase · 2+cos(f·x)</button>
<button class="example-btn" onclick="loadRevExample('x', '', 0, 2, 'y')">Shell · x on [0,2] · V=16π/3</button>
<button class="example-btn" onclick="loadRevExample('4 - x^2', '', 0, 2, 'y')">Shell · 4−x² · V=8π</button>
<button class="example-btn" onclick="loadRevExample('4', 'x^2', 0, 2, 'y')">Shell · 4 & x² · V=8π</button>
<button class="example-btn" onclick="loadRevExample('x', '2 - x', 0, 2, 'y')">Shell · crossing · V=4π</button>
</div>
</div>
</div>
</div>
<!-- Examples for the curve and mass properties. Each advertises
the closed form it is famous for, so the second row of the
panel can be read against a known answer. Some reuse a solid
from the list above on purpose: one shape, several
properties is the point. -->
<div class="accordion-item" id="prop-examples-item" hidden>
<button class="accordion-header" onclick="toggleAccordion('prop-examples')">
<span data-i18n="propExamples">Classic Properties</span>
</button>
<div class="accordion-content" id="prop-examples-accordion">
<div class="accordion-body">
<div class="examples-grid">
<button class="example-btn" onclick="loadRevExample('cosh(x)', '', -1, 1, 'x')">Catenary · cosh(x) · L=2·sinh 1</button>
<button class="example-btn" onclick="loadRevExample('(2/3)*x^(3/2)', '', 0, 3, 'x')">Arc · ⅔x^(3/2) · L=14/3</button>
<button class="example-btn" onclick="loadRevExample('sqrt(4 - x^2)', '', 0, 2, 'x')">Hemisphere · x̄=3r/8</button>
<button class="example-btn" onclick="loadRevExample('sqrt(x)', '', 0, 4, 'x')">Paraboloid · x̄=2h/3</button>
<button class="example-btn" onclick="loadRevExample('2 - x', '', 0, 2, 'y')">Cone from base · ȳ=h/4</button>
<button class="example-btn" onclick="loadRevExample('sqrt(4 - x^2)', '', -2, 2, 'x')">Sphere · I=⅖MR²</button>
<button class="example-btn" onclick="loadRevExample('2', '', 0, 5, 'x')">Cylinder · I=½MR²</button>
<button class="example-btn" onclick="loadRevExample('x', '', 0, 3, 'x')">Cone · I=³⁄₁₀MR²</button>
</div>
</div>
</div>
</div>
<!-- Revolution mesh + Riemann controls -->
<div class="accordion-item" id="rev-options-item" hidden>
<button class="accordion-header active" onclick="toggleAccordion('rev-options')">
<span data-i18n="revOptions">Revolution & Riemann</span>
</button>
<div class="accordion-content active" id="rev-options-accordion">
<div class="accordion-body">
<div class="param-slider-inline">
<label data-i18n="revAxial">Axial steps</label>
<input type="range" id="rev-axial" min="10" max="300" step="10" value="120">
<span class="param-value" id="rev-axial-value">120</span>
</div>
<div class="param-slider-inline">
<label data-i18n="revAngular">Angular steps</label>
<input type="range" id="rev-angular" min="8" max="192" step="8" value="64">
<span class="param-value" id="rev-angular-value">64</span>
</div>
<div class="param-slider-inline">
<label data-i18n="revRiemann">Riemann n</label>
<input type="range" id="rev-riemann" min="0" max="40" step="1" value="0">
<span class="param-value" id="rev-riemann-value" data-i18n="off">off</span>
</div>
<p class="rev-hint" id="rev-riemann-hint" data-i18n="revRiemannHint">Draws the n disks or washers the integral sums. Raise n and watch them converge to the smooth solid.</p>
</div>
</div>
</div>
<!-- Wave Parameters -->
<div class="accordion-item">
<button class="accordion-header active" onclick="toggleAccordion('wave-params')">
<span data-i18n="waveParams">Wave Parameters</span>
</button>
<div class="accordion-content active" id="wave-params-accordion">
<div class="accordion-body">
<div class="param-slider-inline">
<label>A (<span data-i18n="amplitude">Amplitude</span>)</label>
<input type="range" id="A" min="0.1" max="5" step="0.1" value="2">
<span class="param-value" id="A-value">2.0</span>
</div>
<div class="param-slider-inline">
<label>f (<span data-i18n="frequency">Frequency</span>)</label>
<input type="range" id="f" min="0.1" max="10" step="0.1" value="2">
<span class="param-value" id="f-value">2.0</span>
</div>
<div class="param-slider-inline">
<label>φ (<span data-i18n="phase">Phase</span>)</label>
<input type="range" id="phi" min="0" max="6.28" step="0.1" value="0">
<span class="param-value" id="phi-value">0.0</span>
</div>
<div class="toggle-row">
<span data-i18n="autoUpdate">Auto-update</span>
<label class="toggle-switch-wrap">
<input type="checkbox" id="auto-update" checked>
<span class="toggle-track"></span>
</label>
</div>
</div>
</div>
</div>
<!-- Polynomial Parameters -->
<div class="accordion-item">
<!-- Collapsed by default: the opening equation is the ripple,
which uses A/f/phi rather than these coefficients, so an
expanded panel of sliders that do nothing yet would read
as broken. -->
<button class="accordion-header" onclick="toggleAccordion('function-params')">
<span id="coeff-header" data-i18n="polynomial">Polynomial f(x,y)</span>
</button>
<div class="accordion-content" id="function-params-accordion">
<div class="accordion-body">
<div class="param-slider-inline">
<label id="a1-label">a1 · x³</label>
<input type="range" id="a1" min="-1" max="1" step="0.01" value="-0.25">
<span class="param-value" id="a1-value">-0.25</span>
</div>
<div class="param-slider-inline">
<label id="a2-label">a2 · y³</label>
<input type="range" id="a2" min="-1" max="1" step="0.01" value="-0.25">
<span class="param-value" id="a2-value">-0.25</span>
</div>
<div class="param-slider-inline">
<label id="a3-label">a3 · x²</label>
<input type="range" id="a3" min="-1" max="1" step="0.01" value="0.5">
<span class="param-value" id="a3-value">0.50</span>
</div>
<div class="param-slider-inline">
<label id="a4-label">a4 · y²</label>
<input type="range" id="a4" min="-1" max="1" step="0.01" value="0.5">
<span class="param-value" id="a4-value">0.50</span>
</div>
<div class="param-slider-inline">
<label id="a5-label">a5 · x²y²</label>
<input type="range" id="a5" min="-1" max="1" step="0.01" value="-0.25">
<span class="param-value" id="a5-value">-0.25</span>
</div>
<p class="rev-hint" id="coeff-hint" hidden data-i18n="coeffHintRev">Plain coefficients here — the x³/y³ labels belong to the default surface polynomial. Revolution equations take only <code>x</code>.</p>
</div>
</div>
</div>
<!-- Visualization Controls -->
<div class="accordion-item">
<button class="accordion-header" onclick="toggleAccordion('viz-controls')">
<span data-i18n="visualization">Visualization</span>
</button>
<div class="accordion-content" id="viz-controls-accordion">
<div class="accordion-body">
<div class="param-slider-inline" id="resolution-row">
<label data-i18n="resolution">Resolution</label>
<input type="range" id="resolution" min="20" max="100" value="50">
<span class="param-value" id="resolution-value">50</span>
</div>
<div class="param-slider-inline">
<label id="range-label" data-i18n="range">Range</label>
<input type="range" id="range" min="1" max="10" value="4">
<span class="param-value" id="range-value">4</span>
</div>
<div id="base-row">
<label class="rev-label" data-i18n="baseLabel">Underside</label>
<div class="mode-switch axis-switch">
<button class="mode-btn active" id="base-flat" onclick="setBaseMode('flat')" data-i18n="baseFlat">Flat base</button>
<button class="mode-btn" id="base-offset" onclick="setBaseMode('offset')" data-i18n="baseOffset">Offset shell</button>
</div>
<div id="base-warning" hidden></div>
</div>
<div class="param-slider-inline" id="thickness-row">
<label data-i18n="thickness">Thickness</label>
<input type="range" id="thickness" min="0.1" max="2" step="0.1" value="0.3">
<span class="param-value" id="thickness-value">0.3</span>
</div>
<div class="param-slider-inline" id="zscale-row">
<label data-i18n="zScale">Z Scale</label>
<input type="range" id="zScale" min="0.1" max="3" step="0.1" value="1">
<span class="param-value" id="zScale-value">1.0</span>
</div>
<div class="param-slider-inline">
<label data-i18n="opacity">Opacity</label>
<input type="range" id="opacity" min="0.1" max="1" step="0.1" value="0.8">
<span class="param-value" id="opacity-value">0.8</span>
</div>
<div class="param-slider-inline">
<label data-i18n="mmPerUnit">mm / unit</label>
<input type="range" id="mmPerUnit" min="1" max="50" step="1" value="10">
<span class="param-value" id="mmPerUnit-value">10 mm</span>
</div>
<div class="toggle-row" id="intersections-row">
<span data-i18n="showIntersections">Intersection curves</span>
<label class="toggle-switch-wrap">
<input type="checkbox" id="show-intersections" checked>
<span class="toggle-track"></span>
</label>
</div>
<div class="action-row">
<button class="btn btn-primary" id="exportSTL" data-i18n="exportSTL">↓ Export STL</button>
<button class="btn btn-ghost" id="exportPNG" data-i18n="exportPNG">↓ Export PNG</button>
</div>
<div class="action-row">
<button class="btn btn-ghost" style="flex:1;" onclick="toggleWireframe()" data-i18n="wireframe">⬡ Wireframe</button>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- Mobile FAB -->
<button id="mobile-controls-toggle" onclick="toggleMobileControls()">⚙</button>
<!-- DIM OVERLAY (outside canvas to avoid overflow:hidden clipping) -->
<div id="dim-overlay">
<span class="dim-label" data-i18n="modelDimensions">Model Dimensions</span>
<div class="dim-row">
<div class="dim-item">
<span class="dim-label" data-i18n="dimWidth">Width (X)</span>
<span class="dim-value" id="dim-x">— mm</span>
</div>
<div class="dim-item">
<span class="dim-label" data-i18n="dimLength">Length (Y)</span>
<span class="dim-value" id="dim-y">— mm</span>
</div>
<div class="dim-item">
<span class="dim-label" data-i18n="dimHeight">Height (Z)</span>
<span class="dim-value" id="dim-z">— mm</span>
</div>
<div class="dim-item">
<span class="dim-label" data-i18n="dimScale">Scale</span>
<span class="dim-value" id="dim-scale">10 mm/u</span>
</div>
</div>
<!-- Revolution mode only: the integral against the mesh it produced -->
<div id="volume-block" hidden>
<span class="dim-label" data-i18n="volumeLabel">Volume of revolution</span>
<div class="dim-row">
<div class="dim-item">
<span class="dim-label" id="vol-integral-label">π ∫ f² dx</span>
<span class="dim-value" id="vol-integral">—</span>
</div>
<div class="dim-item">
<span class="dim-label" data-i18n="volMesh">Mesh</span>
<span class="dim-value" id="vol-mesh">—</span>
</div>
<div class="dim-item">
<span class="dim-label" data-i18n="volPrint">Printed</span>
<span class="dim-value" id="vol-printed">—</span>
</div>
<div class="dim-item">
<span class="dim-label" data-i18n="volArea">Surface area</span>
<span class="dim-value" id="vol-area">—</span>
</div>
</div>
<span class="dim-label" data-i18n="momentsLabel">Curve & mass properties (density 1)</span>
<div class="dim-row">
<div class="dim-item">
<span class="dim-label" data-i18n="arcLength">Arc length</span>
<span class="dim-value" id="vol-arc">—</span>
</div>
<div class="dim-item">
<span class="dim-label" id="centroid-label">x̄</span>
<span class="dim-value" id="vol-centroid">—</span>
</div>
<div class="dim-item">
<span class="dim-label" id="inertia-axis-label">I about X</span>
<span class="dim-value" id="vol-inertia-axis">—</span>
</div>
<div class="dim-item">
<span class="dim-label" data-i18n="inertiaCentroid">I centroidal</span>
<span class="dim-value" id="vol-inertia-centroid">—</span>
</div>
</div>
<div id="pinch-note" hidden></div>
</div>
</div>
<!-- HELP MODAL -->
<div class="modal-overlay" id="helpModal">
<div class="modal">
<h2 class="modal-title">MathSurface</h2>
<div class="modal-content">
<p data-i18n="helpDesc">Interactive 3D math surface generator for 3D printing. Visualize and export z = f(x, y) equations as print-ready STL files.</p>
<h3 data-i18n="helpHowTitle">How to use</h3>
<ol>
<li data-i18n="helpStep1">Enter your equation in the z = f(x, y) field.</li>
<li data-i18n="helpStep2">Click <strong>Generate</strong> or pick a preset example.</li>
<li data-i18n="helpStepSurfaces">Use <strong>+ Add surface</strong> for up to four equations at once. Where two of them cross, the intersection curve is drawn automatically. The colour swatch shows or hides a surface.</li>
<li data-i18n="helpStepRevolution">Switch to <strong>Revolution</strong> for the disk, washer and shell methods. The panel compares the exact integral against the volume of the mesh it built, and the <strong>Riemann n</strong> slider draws the n slices the integral sums.</li>
<li data-i18n="helpStep3">Drag to rotate, scroll to zoom.</li>
<li data-i18n="helpStepBase">Under <strong>Visualization</strong>, <strong>Underside</strong> picks a flat printable base or a constant-thickness shell.</li>
<li data-i18n="helpStep4">Adjust sliders to tune parameters in real time.</li>
<li data-i18n="helpStep5">Click <strong>Export STL</strong> to download for 3D printing.</li>
</ol>
<h3 data-i18n="helpFunctions">Available Functions</h3>
<p><code>sin</code> <code>cos</code> <code>tan</code> <code>exp</code> <code>log</code> <code>sqrt</code> <code>abs</code></p>
<h3 data-i18n="helpConstants">Constants</h3>
<p><code>PI</code> <code>E</code></p>
<h3 data-i18n="helpVariables">Variables</h3>
<p><code>x</code> <code>y</code> <code>A</code> <code>f</code> <code>phi</code> <code>a1</code>…<code>a5</code></p>
<h3 data-i18n="helpOperators">Operators</h3>
<p><code>+</code> <code>-</code> <code>*</code> <code>/</code> <code>^</code> (<span data-i18n="helpPower">power</span>)</p>
</div>
<a href="https://github.com/sebasdv/MathSurface" target="_blank" rel="noopener" class="modal-source-link" data-i18n="viewSource">View source on GitHub →</a>
<button class="btn btn-primary" style="width:100%;" onclick="closeHelp()" data-i18n="close">Close</button>
</div>
</div>
<!-- Subresource Integrity: the browser refuses to run either file if its
hash does not match, so a compromised or swapped CDN response cannot
execute here. `crossorigin` is required for SRI on a cross-origin
script; cdnjs sends Access-Control-Allow-Origin: *.
These digests were computed from the downloaded bytes and independently
confirmed against the values cdnjs publishes at
https://api.cdnjs.com/libraries/<lib>/<version>?fields=sri
If either library is ever version-bumped, the hash MUST be recomputed
or the app will stop loading. -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/three.js/r128/three.min.js"
integrity="sha512-dLxUelApnYxpLt6K2iomGngnHO83iUvZytA3YjDUCjT0HDOHKXnVYdf3hU4JjM8uEhxf9nD1/ey98U3t2vZ0qQ=="
crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/mathjs/11.11.0/math.min.js"
integrity="sha512-VMIzok05yICztVJ0Pu2ZXHHz6Pe+fNONIcepOD3kzgL0SJG3GH4IO3DmBRO766hIWUOHIS/IWdSqRGWWzgzqRw=="
crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<script>
let scene, camera, renderer;
let gridGroup = null; // grupo de la grilla, se recrea al cambiar range/mmPerUnit
let showWireframe = true;
// --- Surfaces ----------------------------------------------------------
// All surfaces share the sliders (A, f, phi, a1…a5) on purpose: moving one
// slider moves the whole family, which is the point when you are comparing
// them. Only the equation, colour and visibility are per-surface.
const SURFACE_COLORS = [
{ solid: 0x009FE3, wire: 0x0077A9, css: '#009FE3' }, // DEC blue
{ solid: 0xFF671F, wire: 0xD64B00, css: '#FF671F' }, // DEC orange
{ solid: 0x22C55E, wire: 0x15803D, css: '#22C55E' }, // green
{ solid: 0xA855F7, wire: 0x7E22CE, css: '#A855F7' } // purple
];
const MAX_SURFACES = SURFACE_COLORS.length;
const INTERSECTION_COLOR = 0x111827;
// { id, equation, colorIndex, visible, mesh, wireMesh, gridZ, error }
let surfaces = [];
let nextSurfaceId = 1;
let activeSurfaceId = null; // last row the user touched; target for examples
let intersectionLines = null; // THREE.LineSegments, rebuilt with the surfaces
// --- Solids of revolution ----------------------------------------------
// A solid of revolution is not a heightfield: revolving r = f(x) gives two
// z values for most (x,y), so it cannot go through createSolidGeometry.
// It is a separate geometry path, selected by mode rather than mixed into
// the surface list.
let appMode = 'surfaces'; // 'surfaces' | 'revolution'
// 'flat' closes the model with one plane underneath, which is what a printer
// bed wants and can never self-intersect. 'offset' is the original
// constant-thickness shell, kept because a thin surface model is a
// legitimate thing to want — it just is not printable as-is.
let baseMode = 'flat'; // 'flat' | 'offset'
const REV_EPS = 1e-9;
let revolution = {
axis: 'x', // 'x' -> disk/washer; 'y' -> shell
outer: 'sqrt(4 - x^2)',
inner: '', // empty -> disk method; set -> washer
a: -2, b: 2,
mesh: null,
wireMesh: null,
riemannGroup: null,
outerError: null,
innerError: null,
metrics: null // { integral, meshVolume, area }
};
let autoRotate = true;
let mmPerUnit = 10; // 1 unidad Three.js = 10 mm por defecto
const DEFAULT_CAMERA_DISTANCE = Math.sqrt(3) * 8;
const MIN_CAMERA_DISTANCE = 2;
const MAX_CAMERA_DISTANCE = 50;
let parameters = {
A: 2.0, f: 2.0, phi: 0.0,
a1: -0.25, a2: -0.25, a3: 0.5, a4: 0.5, a5: -0.25
};
let controls = {
isDragging: false,
lastX: 0, lastY: 0,
rotationX: 0.3, rotationY: 0.5,
distance: DEFAULT_CAMERA_DISTANCE,
pinchSpread: 0
};
// Releases the GPU buffers behind an object tree. Three.js `remove()` only
// detaches from the scene graph, so without this every rebuild leaked a
// geometry, a material and (for the mm labels) a canvas texture.
function disposeObject3D(root) {
root.traverse(node => {
// Sprites share one module-level geometry — disposing it would
// pull the buffer out from under every other sprite.
if (node.geometry && !node.isSprite) node.geometry.dispose();
const materials = Array.isArray(node.material)
? node.material
: node.material ? [node.material] : [];
for (const material of materials) {
if (material.map) material.map.dispose();
material.dispose();
}
});
}
// Initialize Three.js scene
function init() {
const container = document.getElementById('canvas-container');
if (typeof THREE === 'undefined' || typeof math === 'undefined') {
showFatalError('errLibs');
return;
}
scene = new THREE.Scene();
scene.background = new THREE.Color(0xF0F2F5);
camera = new THREE.PerspectiveCamera(75, container.clientWidth / container.clientHeight, 0.1, 1000);
try {
renderer = new THREE.WebGLRenderer({ antialias: true });
} catch (e) {
showFatalError('errWebgl');
return;
}
renderer.setSize(container.clientWidth, container.clientHeight);
renderer.shadowMap.enabled = true;
container.appendChild(renderer.domElement);
updateCameraPosition();
addLights();
addEventListeners();
animate();
setTimeout(() => {
updateAllParameterValues();
buildGrid();
// The old default was the a1..a5 polynomial, which over the default
// range measured 80 x 80 x 1043 mm — a one-metre tower is a strange
// first thing to show in a 3D-printing tool, and it stays unprintable
// at every range (40 x 40 x 83 mm even at range 2). The ripple is
// bounded by A, so it opens as an 80 x 80 x 43 mm plate, and it uses
// the A/f/phi sliders that greet you with Wave Parameters expanded.
addSurface('A * sin(f*sqrt(x^2 + y^2) + phi)');
}, 100);
}
// Kept so the language toggle can redraw it — the header buttons still work
// while a fatal error is on screen.
let fatalErrorKey = null;
function showFatalError(key) {
fatalErrorKey = key;
const container = document.getElementById('canvas-container');
// Replaced, not appended: repeated calls used to stack boxes, leaving
// the first (stale) message as the one actually read.
let box = container.querySelector('.canvas-error');
if (!box) {
box = document.createElement('div');
box.className = 'canvas-error';
container.appendChild(box);
}
box.textContent = tr(key);
}
function addLights() {
const ambientLight = new THREE.AmbientLight(0x404040, 0.4);
scene.add(ambientLight);
const directionalLight = new THREE.DirectionalLight(0xffffff, 0.8);
directionalLight.position.set(10, 10, 5);
directionalLight.castShadow = true;
scene.add(directionalLight);
const pointLight = new THREE.PointLight(0x009FE3, 0.5, 50);
pointLight.position.set(-5, 5, 5);
scene.add(pointLight);
}
const MINOR_STEP_MM = 10; // a grid line every 10 mm
const LABEL_STEPS_MM = [10, 20, 50, 100, 200, 500, 1000, 2000, 5000];
// Coarsest round step that still puts a handful of labels across the
// model. A fixed 50 mm left the default 80 mm view with no labels at all
// and a 1000 mm view with twenty.
function pickLabelStepMm(spanMm) {
for (const step of LABEL_STEPS_MM) {
if (spanMm / step <= 8) return step;
}
return LABEL_STEPS_MM[LABEL_STEPS_MM.length - 1];
}
// Builds the reference grid + axes. Called after init and whenever range/mmPerUnit changes.
function buildGrid() {
if (gridGroup) {
scene.remove(gridGroup);
disposeObject3D(gridGroup);
}
gridGroup = new THREE.Group();
const range = parseInt(document.getElementById('range').value);
const minorStep = MINOR_STEP_MM / mmPerUnit; // in Three.js units
const labelStepMm = pickLabelStepMm(range * 2 * mmPerUnit);
const zFloor = -0.02; // sit just below the z = 0 plane
const EPS = 1e-6;
const minorCoords = [];
const majorCoords = [];
// Walk whole multiples of the step instead of offsets from -range, so
// that lines land on round millimetre values and each label sits on
// the line it names.
const firstIndex = Math.ceil((-range - EPS) / minorStep);
for (let n = firstIndex; n * minorStep <= range + EPS; n++) {
const v = n * minorStep;
const mm = n * MINOR_STEP_MM; // exact: v * mmPerUnit
const onLabelStep = mm % labelStepMm === 0;
// Only draw a heavier line when it actually marks a coarser step
// than the minor grid, otherwise every line would look major.
const coords = (onLabelStep && labelStepMm > MINOR_STEP_MM) ? majorCoords : minorCoords;
coords.push(v, zFloor, -range, v, zFloor, range); // parallel to Y
coords.push(-range, zFloor, v, range, zFloor, v); // parallel to X
if (onLabelStep && mm !== 0) {
addMmLabel(`${mm}`, v, 0, zFloor - 0.05); // along X axis
addMmLabel(`${mm}`, 0, v, zFloor - 0.05); // along Y axis
}
}
// One LineSegments per weight instead of one Line object per segment:
// two draw calls rather than a couple of hundred.
addLineSegments(minorCoords, 0xD1D5DB, 0.6);
addLineSegments(majorCoords, 0x9CA3AF, 0.9);
// Axes coloured in the *model's* frame, which is Z-up: Three.js Y is
// the model's Z (height) and Three.js Z is the model's Y (depth).
const axisLen = range * 1.2;
function addAxis(axis, color) {
const geo = new THREE.CylinderGeometry(0.015, 0.015, axisLen * 2);
const mat = new THREE.MeshBasicMaterial({ color });
const mesh = new THREE.Mesh(geo, mat);
if (axis === 'x') mesh.rotation.z = Math.PI / 2; // along Three.js X
if (axis === 'y') mesh.rotation.x = Math.PI / 2; // along Three.js Z
// 'z' keeps the cylinder's default Y orientation = model height
gridGroup.add(mesh);
}
addAxis('x', 0xEF4444); // red — Width (X)
addAxis('y', 0x22C55E); // green — Length (Y)
addAxis('z', 0x3B82F6); // blue — Height (Z)
scene.add(gridGroup);
}
function addLineSegments(coords, color, opacity) {
if (coords.length === 0) return;
const geo = new THREE.BufferGeometry();
geo.setAttribute('position', new THREE.Float32BufferAttribute(coords, 3));
const mat = new THREE.LineBasicMaterial({ color, transparent: true, opacity });
gridGroup.add(new THREE.LineSegments(geo, mat));
}
function addMmLabel(text, x, y, zPos) {
const canvas = document.createElement('canvas');
canvas.width = 128; canvas.height = 48;
const ctx = canvas.getContext('2d');
ctx.font = 'bold 28px Inter, sans-serif';
ctx.fillStyle = '#6B7280';
ctx.textAlign = 'center';
ctx.textBaseline = 'middle';
ctx.fillText(text + ' mm', 64, 24);
const texture = new THREE.CanvasTexture(canvas);
const mat = new THREE.SpriteMaterial({ map: texture, transparent: true, opacity: 0.7 });
const sprite = new THREE.Sprite(mat);
sprite.scale.set(0.8, 0.3, 1);
sprite.position.set(x, zPos, y);
gridGroup.add(sprite);
}
// Bounding box of everything that will be exported, i.e. the union over
// the visible surfaces.
function updateDimensions() {
const box = new THREE.Box3();
let empty = true;
for (const s of visibleSurfaces()) {
s.mesh.geometry.computeBoundingBox();
box.union(s.mesh.geometry.boundingBox);
empty = false;
}
document.getElementById('dim-scale').textContent = mmPerUnit + ' mm/u';
if (empty) {
document.getElementById('dim-x').textContent = '— mm';
document.getElementById('dim-y').textContent = '— mm';
document.getElementById('dim-z').textContent = '— mm';
return;
}
const mm = v => Math.round(v * mmPerUnit) + ' mm';
document.getElementById('dim-x').textContent = mm(box.max.x - box.min.x);
document.getElementById('dim-y').textContent = mm(box.max.z - box.min.z); // Three.js Z is depth
document.getElementById('dim-z').textContent = mm(box.max.y - box.min.y); // Three.js Y is height
updateVolumeReadout();
// The warning now quotes mm, so a change of scale invalidates its text
// even though the geometry is untouched.
updateBaseWarning();
}
function updateVolumeReadout() {
if (appMode !== 'revolution') return;
const set = (id, text) => { document.getElementById(id).textContent = text; };
const m = revolution.metrics;
if (!m) {
for (const id of ['vol-integral', 'vol-mesh', 'vol-printed', 'vol-area']) set(id, '—');
return;
}
// The integral is exact for the curve; the mesh is the faceted
// approximation that actually gets printed. Showing the gap is the
// point: it shrinks as the angular resolution rises.
const err = m.integral !== 0 ? (m.meshVolume - m.integral) / m.integral * 100 : 0;
set('vol-integral', m.integral.toFixed(3) + ' u³');
set('vol-mesh', m.meshVolume.toFixed(3) + ' u³ (' + (err >= 0 ? '+' : '') + err.toFixed(2) + '%)');
// u³ -> mm³ -> cm³. cm³ is what a slicer quotes for filament.
set('vol-printed', (m.meshVolume * mmPerUnit ** 3 / 1000).toFixed(2) + ' cm³');
set('vol-area', m.area.toFixed(2) + ' u²');
const shell = revolution.axis === 'y';
set('vol-arc', m.arc.toFixed(3) + ' u');
// Only one coordinate survives the rotational symmetry, and it lies on
// the axis of revolution — so name it rather than printing a triple.
document.getElementById('centroid-label').textContent = shell ? 'ȳ' : 'x̄';
// A symmetric solid lands on -0.0000000001 and printed as "-0.000",
// which reads like a defect. Anything below the displayed precision is
// shown as plain zero.
const c = Math.abs(m.centroid) < 5e-4 ? 0 : m.centroid;
set('vol-centroid', c.toFixed(3) + ' u');
document.getElementById('inertia-axis-label').textContent = tr(shell ? 'inertiaAxisY' : 'inertiaAxisX');
set('vol-inertia-axis', m.inertiaAxis.toFixed(2) + ' u⁵');
set('vol-inertia-centroid', m.inertiaCentroid.toFixed(2) + ' u⁵');
// An interior pinch is faithful geometry — the region closes to nothing
// there, so the solid touches itself along a circle — but it leaves a
// non-manifold edge that some slicers complain about, so say so.
const note = document.getElementById('pinch-note');
note.hidden = !m.pinches;
if (m.pinches) note.textContent = tr('pinchNote').replace('{n}', m.pinches);
}
// --- Coalesced rebuilds ------------------------------------------------
// Dragging a slider fires `input` dozens of times per second, and a full
// rebuild at resolution 100 costs far more than the gap between events —
// firing one per event queued work faster than it could be retired. Keep
// at most one rebuild pending and space rebuilds by the cost of the last
// one, so cheap surfaces stay at 60 fps and heavy ones self-throttle.
let rebuildTimer = null;
let pendingGrid = false;
let pendingSurface = false;
let lastBuildMs = 16;
// Equation text gets a plain trailing debounce instead. A slider wants
// continuous feedback, but a half-typed expression is a parse error, so
// rebuilding per keystroke just flashes red while you type `sin(`.
const EQUATION_DEBOUNCE_MS = 350;
let equationTimer = null;
function scheduleEquationRebuild() {
clearTimeout(equationTimer);
equationTimer = setTimeout(() => {
equationTimer = null;
regenerateAll();
}, EQUATION_DEBOUNCE_MS);
}
function scheduleRebuild({ grid = false, surface: wantSurface = false } = {}) {
pendingGrid = pendingGrid || grid;
pendingSurface = pendingSurface || wantSurface;
if (rebuildTimer !== null) return;
const delay = Math.min(Math.max(lastBuildMs, 16), 250);
rebuildTimer = setTimeout(() => {
rebuildTimer = null;
const started = performance.now();
if (pendingGrid) { pendingGrid = false; buildGrid(); }
if (pendingSurface) { pendingSurface = false; regenerateAll(); }
lastBuildMs = performance.now() - started;
}, delay);
}
function addEventListeners() {
const canvas = renderer.domElement;
// Pointer events cover mouse, pen and touch in one path, and capture
// keeps the drag alive when the cursor leaves the canvas.
canvas.addEventListener('pointerdown', onPointerDown);
canvas.addEventListener('pointermove', onPointerMove);
canvas.addEventListener('pointerup', onPointerEnd);
canvas.addEventListener('pointercancel', onPointerEnd);
canvas.addEventListener('wheel', onWheel, { passive: false });
window.addEventListener('resize', onWindowResize);
// Parameter sliders
['A', 'f', 'phi', 'a1', 'a2', 'a3', 'a4', 'a5', 'resolution', 'range', 'thickness', 'zScale', 'opacity', 'mmPerUnit'].forEach(param => {
const slider = document.getElementById(param);
if (slider) {
slider.addEventListener('input', (e) => {
const value = parseFloat(e.target.value);
const valueDisplay = document.getElementById(`${param}-value`);
if (valueDisplay) {
if (param === 'mmPerUnit') {
valueDisplay.textContent = value.toFixed(0) + ' mm';
} else {
const decimals = param.startsWith('a') ? 2 : param === 'phi' ? 2 : 1;
valueDisplay.textContent = value.toFixed(decimals);
}
}
if (param === 'mmPerUnit') {
mmPerUnit = value;
scheduleRebuild({ grid: true });
updateDimensions();
} else if (['A', 'f', 'phi', 'a1', 'a2', 'a3', 'a4', 'a5'].includes(param)) {
parameters[param] = value;
if (document.getElementById('auto-update').checked) {
scheduleRebuild({ surface: true });
}
} else {
scheduleRebuild({ grid: param === 'range', surface: true });
}
});
}
});
// Revolution controls. The interval and the equations use the text
// debounce; the mesh sliders use the adaptive one, same split as the
// surfaces mode.
for (const id of ['rev-outer', 'rev-inner']) {
const el = document.getElementById(id);
el.addEventListener('input', () => {
revolution[id === 'rev-outer' ? 'outer' : 'inner'] = el.value;
scheduleEquationRebuild();
});
el.addEventListener('keypress', e => {
if (e.key === 'Enter') { clearTimeout(equationTimer); equationTimer = null; regenerateAll(); }
});
}
for (const id of ['rev-a', 'rev-b']) {
document.getElementById(id).addEventListener('input', scheduleEquationRebuild);
}
for (const id of ['rev-axial', 'rev-angular', 'rev-riemann']) {
const el = document.getElementById(id);
el.addEventListener('input', () => {
const v = parseInt(el.value);
document.getElementById(id + '-value').textContent =
(id === 'rev-riemann' && v === 0) ? tr('off') : String(v);
scheduleRebuild({ surface: true });
});
}
document.getElementById('show-intersections').addEventListener('change', () => {
buildIntersections(
parseInt(document.getElementById('resolution').value),
parseInt(document.getElementById('range').value)
);
});
document.getElementById('exportSTL').addEventListener('click', exportSTL);
document.getElementById('exportPNG').addEventListener('click', exportPNG);
}
function updateAllParameterValues() {
['A', 'f', 'phi', 'a1', 'a2', 'a3', 'a4', 'a5'].forEach(param => {
const slider = document.getElementById(param);
const valueDisplay = document.getElementById(`${param}-value`);
if (slider && valueDisplay) {
const value = parseFloat(slider.value);
const decimals = param.startsWith('a') ? 2 : param === 'phi' ? 2 : 1;
valueDisplay.textContent = value.toFixed(decimals);
parameters[param] = value;
}
});
}
// Everything downstream — STL, PNG, the dimension readout — consumes this,
// so switching mode needs no changes in any of them.
function visibleSurfaces() {
if (appMode === 'revolution') {
return revolution.mesh ? [{ mesh: revolution.mesh, equation: revolution.outer }] : [];
}
return surfaces.filter(s => s.visible && s.mesh);
}
function surfaceById(id) {
return surfaces.find(s => s.id === id) || null;
}
// Detaches one surface's meshes and frees their GPU buffers.
function clearSurfaceMeshes(s) {
if (s.wireMesh) {
scene.remove(s.wireMesh);
s.wireMesh.material.dispose();
s.wireMesh = null;
}
if (s.mesh) {
scene.remove(s.mesh);
s.mesh.material.dispose();
s.mesh.geometry.dispose(); // shared with the wireframe, so freed once
s.mesh = null;
}
s.gridZ = null;
}
function clearIntersections() {
if (!intersectionLines) return;
scene.remove(intersectionLines);
intersectionLines.geometry.dispose();
intersectionLines.material.dispose();
intersectionLines = null;
}
// Rebuilds every surface plus the intersection curves. This is the single
// entry point used by the Generate button and by scheduleRebuild().
function regenerateAll() {
if (appMode === 'revolution') { regenerateRevolution(); return; }
const resolution = parseInt(document.getElementById('resolution').value);
const range = parseInt(document.getElementById('range').value);
const thickness = parseFloat(document.getElementById('thickness').value);
const zScale = parseFloat(document.getElementById('zScale').value);
const opacity = parseFloat(document.getElementById('opacity').value);
clearIntersections();
let worstDrop = 0;
// Pass 1: sample every surface. Meshing waits because the flat base
// needs a plane shared by all of them.
for (const s of surfaces) {
clearSurfaceMeshes(s);
s.error = null;
const text = s.equation.trim();
if (!text) {
// A blank field is incomplete, not wrong — a freshly added row
// showed a red error before the user had typed anything.
s.error = { key: 'statusEmpty', muted: true };
continue;
}
let compiled;
try {
compiled = math.parse(text).compile();
compiled.evaluate({ x: 1, y: 1, ...parameters });
} catch (error) {
s.error = { key: 'statusInvalid', detail: error.message };
continue;
}
// gridZ is kept so the intersection pass can reuse the samples
// instead of evaluating every equation a second time.