mirror of
https://github.com/gittrahan/support-fins.git
synced 2026-10-19 02:10:52 -05:00
tests: stability counts 24 distinct scenes (cube and staircase X40 were listed twice; main flipped 14, not 16), sitePose takes the nudge instead of a copy (review)
This commit is contained in:
1 parent
22069f3749
commit
315526708a
3 files changed
+12
-21
No files matched your search
+1
-1
@@ -26,7 +26,7 @@ UPDATE_GOLDEN=1 deno test -A tests/golden.test.js
|
||||
```
|
||||
|
||||
**`stability.test.js`** -- the same part nudged by 1e-9 rad builds the same supports,
|
||||
on 26 scenes (local issue 023: 16 of them used to change -- an end station dropped one
|
||||
on 24 scenes (local issue 023: 14 of them used to change -- an end station dropped one
|
||||
ulp off surfaceZAt's grid, a part edge in a wall's end-cap plane read as a pierce, a
|
||||
level wall's comb anchored at whichever end noise made lower). Plus the end-cap case on
|
||||
`solidClearance` directly, at nudges where the old parallel test misfired. Builds come
|
||||
|
||||
+5
-2
@@ -34,12 +34,15 @@ export function siteOpts({ material = 'pla', mode = 'auto', sway = false } = {})
|
||||
/** The rotate ring's pose for the readout [x, y, z]: snapped turns about the world
|
||||
* axes (TransformControls premultiplies), as Matrix3 elements like part.js rotM3. */
|
||||
const SNAP = THREE.MathUtils.degToRad(5);
|
||||
export function sitePose(deg) {
|
||||
export function sitePose(deg, eps = 0) {
|
||||
const q = new THREE.Quaternion();
|
||||
const axes = [new THREE.Vector3(1, 0, 0), new THREE.Vector3(0, 1, 0), new THREE.Vector3(0, 0, 1)];
|
||||
deg.forEach((d, i) => {
|
||||
if (d) q.premultiply(new THREE.Quaternion().setFromAxisAngle(axes[i], Math.round(d / 5) * SNAP));
|
||||
if (d) q.premultiply(new THREE.Quaternion().setFromAxisAngle(axes[i], Math.round(d / 5) * SNAP + eps));
|
||||
});
|
||||
// `eps` nudges every turn by that many rad (stability.test.js); an unturned pose
|
||||
// takes it about X
|
||||
if (eps && !deg.some(Boolean)) q.premultiply(new THREE.Quaternion().setFromAxisAngle(axes[0], eps));
|
||||
return new THREE.Matrix3().setFromMatrix4(new THREE.Matrix4().makeRotationFromQuaternion(q)).elements;
|
||||
}
|
||||
|
||||
|
||||
+6
-18
@@ -1,40 +1,28 @@
|
||||
// FLOAT-NOISE STABILITY (local issue 023). The same part nudged by 1e-9 rad -- far below
|
||||
// anything a user, an STL writer or a browser's trig can do on purpose -- must build the
|
||||
// same supports. Before #171 and this file, 16 of these 26 scenes changed under the
|
||||
// same supports. Before #171 and this file, 14 of these 24 scenes changed under the
|
||||
// nudge: an end station dropped one ulp outside surfaceZAt's grid, a part edge lying in
|
||||
// a wall's end-cap plane read as a pierce (segTriHit's absolute parallel test), and a
|
||||
// level wall's comb anchored at whichever end noise made lower.
|
||||
|
||||
import { assert, assertAlmostEquals } from 'jsr:@std/assert';
|
||||
import { blockTopo } from './_util.js';
|
||||
import { run } from './_scene.js';
|
||||
import * as THREE from '../web/vendor/three/three.core.js';
|
||||
import { run, sitePose } from './_scene.js';
|
||||
|
||||
const { solidClearance } = await import('../web/inside.js');
|
||||
|
||||
const SNAP = THREE.MathUtils.degToRad(5);
|
||||
/** The site's pose (golden.test.js sitePose) with every turn nudged by `eps` rad. */
|
||||
function nudged(deg, eps) {
|
||||
const q = new THREE.Quaternion();
|
||||
const axes = [new THREE.Vector3(1, 0, 0), new THREE.Vector3(0, 1, 0), new THREE.Vector3(0, 0, 1)];
|
||||
deg.forEach((d, i) => {
|
||||
if (d) q.premultiply(new THREE.Quaternion().setFromAxisAngle(axes[i], Math.round(d / 5) * SNAP + eps));
|
||||
});
|
||||
if (!deg.some(Boolean)) q.premultiply(new THREE.Quaternion().setFromAxisAngle(axes[0], eps));
|
||||
return new THREE.Matrix3().setFromMatrix4(new THREE.Matrix4().makeRotationFromQuaternion(q)).elements;
|
||||
}
|
||||
|
||||
// golden picks not already in the stress set at X40, plus every stress model at X40
|
||||
const SCENES = [
|
||||
['cube', [40, 0, 0]], ['sphere', [0, 0, 0]], ['lbracket', [35, 0, 0]], ['staircase', [40, 0, 0]],
|
||||
['sphere', [0, 0, 0]], ['lbracket', [35, 0, 0]],
|
||||
...[...Deno.readDirSync(new URL('../prototype/stress/models/', import.meta.url))]
|
||||
.map((e) => e.name.replace(/\.stl$/, '')).sort().map((m) => [m, [40, 0, 0]]),
|
||||
];
|
||||
|
||||
Deno.test('stability: a 1e-9 rad nudge builds the same supports (26 scenes)', () => {
|
||||
Deno.test('stability: a 1e-9 rad nudge builds the same supports (24 scenes)', () => {
|
||||
const flips = [];
|
||||
for (const [model, rot] of SCENES) {
|
||||
const sig = (eps) => {
|
||||
const o = run({ model, rot }, nudged(rot, eps));
|
||||
const o = run({ model, rot }, sitePose(rot, eps));
|
||||
return `${o.walls}w ${o.tines}t ${o.tris.length / 3}tri`;
|
||||
};
|
||||
const base = sig(0);
|
||||
|
||||
Reference in new issue
Block a user