From fa64f43a35caf3bdac3726cfcbf16a7d98016991 Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Wed, 2 Dec 2026 22:28:21 +0100 Subject: [PATCH 01/11] brokkr_kitbash.ram: a zone names a part of a body its pin joins (JOINS), or the record is refused Soul s4 (zone-spans-the-member-and-hides-an-overlap): two zones of 0.51 of its length cover a member, so no radius bound stops a foreign part being let. The record can say which bodies a pin joins: a the parent, the rocker's pivot the parent and rocker, p the rocker and coupler, c the coupler and child, b the child, d the rocker. Mechanism refuses any other zone before measuring it; from_record and a search world's answer pass the same loop. Tests: every (kind, member, pin, body) admitted or refused by a hand table; Soul's parent capsule under the coupler refused three ways; the wall, bead, lug and world cases restated on bodies their pins join. Co-Authored-By: Claude Fable 5.2 --- surfaces/blender/brokkr_kitbash/ram.py | 9 ++ surfaces/blender/tests/test_ram.py | 116 +++++++++++++++++++------ 2 files changed, 99 insertions(+), 26 deletions(-) diff --git a/surfaces/blender/brokkr_kitbash/ram.py b/surfaces/blender/brokkr_kitbash/ram.py index d7cb60f..1383b5e 100644 --- a/surfaces/blender/brokkr_kitbash/ram.py +++ b/surfaces/blender/brokkr_kitbash/ram.py @@ -31,6 +31,9 @@ it turns with: a thigh's core, the bracket that carries the rocker's pivot, a li for each member of MEMBERS[kind], zones (part, pin, radius, depth). Every member meets every part. A zone lowers what the member's samples keep from one part, and only within `radius` of the axis of `pin`, one of the member's own (RIDES), measured across the hinge axis: there a sample may come as near the part as -depth and no nearer. +The part is one of a body that pin joins (JOINS: a the parent; the rocker's pivot the parent and the rocker; p the +rocker and the coupler; c the coupler and the child; b the child; d the rocker), or the record is refused: what a +member meets at a pin is of the bodies pinned there, and a part of any other body is never let near it. depth is 0 for what is stacked beside the member on the pin (a plate, the bracket or horn the pin stands in: the member's axis stays outside it, so a pin whose place along the axis is inside the part it claims to stand beside is refused), the pin's radius for the pin through the member's eye, half the thickness for the member's own plate @@ -68,6 +71,9 @@ MEMBERS = {"direct": ("barrel", "rod"), "four_bar": ("barrel", "rod", "rocker", EYE = {"direct": "b", "four_bar": "d", "bell_crank": "d"} # the pin the rod's eye rides RIDES = {kind: {"barrel": ("a", EYE[kind]), "rod": ("a", EYE[kind]), "rocker": ("rocker", "p"), "coupler": ("p", "c"), "rocker arm": ("rocker", "d")} for kind in KINDS} # member -> the pins at its start and its end +JOINS = {kind: {"a": ("parent",), "b": ("child",)} if kind == "direct" else + {"a": ("parent",), "rocker": ("parent", "rocker"), "p": ("rocker", "coupler"), "c": ("coupler", "child"), "d": ("rocker",)} + for kind in KINDS} # pin -> the bodies it joins: only their parts are zoned about it GATES = ("assembly", "stroke", "toggle", "arm", "load", "clash") SCHEMA, VERSION = "brokkr.ram", 1 ZONE = ("part", "pin", "radius", "depth") # a zone of `touch`, as the record writes it @@ -216,6 +222,9 @@ class Mechanism: radius, depth = _number(self.kind, f"{member} {part} radius", radius, 0.0), _number(self.kind, f"{member} {part} depth", depth) if depth < 0.0: raise RamError(self.kind, "record", f"a depth of 0 or more, got {depth!r}", pin=f"{member} {part} depth") + if self.parts[part] not in JOINS[self.kind][pin]: + raise RamError(self.kind, "record", f"{member} may touch about {pin} a part of a body the pin joins ({', '.join(JOINS[self.kind][pin])}); " + f"{part!r} turns with {self.parts[part]}", pin=f"{member} {part} pin") span = _span(self, member) for name, value in (("radius", radius), ("depth", depth)): if value > span: diff --git a/surfaces/blender/tests/test_ram.py b/surfaces/blender/tests/test_ram.py index 1fbe829..8a8c12d 100644 --- a/surfaces/blender/tests/test_ram.py +++ b/surfaces/blender/tests/test_ram.py @@ -562,8 +562,9 @@ class DeepKnee(unittest.TestCase): def test_a_part_in_the_rams_way_on_each_link(self): # a lug on the rocker, then on the coupler, on the rod's axis 0.12 from the eye at -60: refused naming the part - # and its body. A zone about the eye lets the rod and the barrel by it only if it reaches the lug and is as - # deep as the lug; a zone of another member's changes nothing + # and its body. A zone about the eye lets the rod and the barrel by the rocker's only if it reaches the lug and + # is as deep as the lug; a zone of another member's changes nothing. The coupler's lug is let by no zone of + # the ram's: the eye's pin does not join the coupler m, ram = r3("bell_crank", CRANK), R.Ram(BORE) at = R.pose(m, -60.0) on_rod = (at.eye - 0.12 * at.u)[:, None, :] @@ -574,13 +575,20 @@ class DeepKnee(unittest.TestCase): def zones(radius, depth, members=("rod", "barrel")): return {**touch, **{member: touch[member] + [("lug", "d" if member != "coupler" else "p", radius, depth)] for member in members}} - for label, given in (("nothing let", touch), ("the coupler's zone", zones(0.4, 0.02, ("coupler",))), ("a zone short of the lug", zones(0.1, 0.02)), - ("a zone too shallow", zones(0.4, 0.01))): + if body == "coupler": # d joins the rocker alone: no zone of the ram's names a part of the coupler + with self.assertRaises(R.RamError) as caught: + dressed(m, bodies, zones(0.4, 0.02)) + self.assertEqual((caught.exception.gate, caught.exception.pin), ("record", "barrel lug pin")) + self.assertIn("a body the pin joins (rocker); 'lug' turns with coupler", str(caught.exception)) + for label, given in (("nothing let", touch), ("the coupler's zone", zones(0.4, 0.02, ("coupler",))), + *((("a zone short of the lug", zones(0.1, 0.02)), ("a zone too shallow", zones(0.4, 0.01))) if body == "rocker" else ())): with self.assertRaises(R.RamError) as caught: R.fit(dressed(m, bodies, given), ram, steps=49, distance=bodies) self.assertEqual((caught.exception.gate, caught.exception.fit.clear_at[2]), ("clash", "lug"), (body, label)) self.assertIn(caught.exception.fit.clear_at[1], ("rod[0]", "barrel[0]")) self.assertIn(f"part 'lug' ({body})", str(caught.exception)) + if body == "coupler": + continue f = R.fit(dressed(m, bodies, zones(0.4, 0.02)), ram, steps=49, distance=bodies) self.assertIn(("rod[0]", "lug"), f.allowed) self.assertNotIn(("rocker arm", "lug"), f.allowed) @@ -645,16 +653,16 @@ class DeepKnee(unittest.TestCase): self.assertAlmostEqual(R._span(m, "rocker arm"), 0.24, places=9) self.assertGreaterEqual(R._span(m, "rod"), float(R.pose(m, np.linspace(-125.0, 0.0, 126)).L.max())) self.assertEqual([ram.eye(*of) for of in (("barrel", "a"), ("rod", "a"), ("rod", "d"), ("coupler", "c"))], [ram.e_a, ram.e_a, ram.e_b, ram.link_r]) - for member, pin in (("barrel", "a"), ("rod", "d"), ("rocker", "p"), ("coupler", "c"), ("rocker arm", "rocker")): + for member, pin, part in (("barrel", "a", "thigh"), ("rod", "d", "pin d"), ("rocker", "p", "coupler plates"), ("coupler", "c", "horn"), ("rocker arm", "rocker", "bracket")): span, eye = R._span(m, member), ram.eye(member, pin) def zoned(radius, depth): - return dressed(m, bodies, {member: [("thigh", pin, radius, depth)]}) + return dressed(m, bodies, {member: [(part, pin, radius, depth)]}) zoned(span, 0.0) for radius, depth, field in ((1.2 * span, 0.0, "radius"), (1e308, 0.0, "radius"), (1e9, 1e9, "radius"), (0.1, 1.2 * span, "depth"), (0.1, 1e308, "depth")): with self.assertRaises(R.RamError) as caught: zoned(radius, depth) - self.assertEqual((caught.exception.gate, caught.exception.pin), ("record", f"{member} thigh {field}")) + self.assertEqual((caught.exception.gate, caught.exception.pin), ("record", f"{member} {part} {field}")) self.assertIn(f"{member} is at most {span:.4f} from pin to pin", str(caught.exception)) R.clearance(zoned(0.1, eye), ram, [-60.0], bodies) wrote = R.record(zoned(0.1, eye), ram) @@ -664,19 +672,66 @@ class DeepKnee(unittest.TestCase): lambda: R.from_record(wrote)): with self.assertRaises(R.RamError) as caught: read() - self.assertEqual((caught.exception.gate, caught.exception.pin), ("record", f"{member} thigh depth")) + self.assertEqual((caught.exception.gate, caught.exception.pin), ("record", f"{member} {part} depth")) self.assertIn(f"{member}'s on {pin} is {eye:.4f}", str(caught.exception)) + def test_a_zone_names_a_part_of_a_body_its_pin_joins(self): + # Soul's whole-member zones: two of 0.51 of its length about p and c covered the coupler and let its axis + # 0.0294 into a capsule of the thigh. No bound on a radius stops that; the record says which bodies a pin + # joins, and a part of any other is zoned about it by no member, whatever the radius and depth + joins = {"a": ("parent",), "b": ("child",), "rocker": ("parent", "rocker"), "p": ("rocker", "coupler"), "c": ("coupler", "child"), "d": ("rocker",)} + for m in (R.Mechanism("direct", O, X, -62, 0, a=(0.05, -0.3, 0.8), b=(0.05, -0.3, -0.6)), r3("four_bar", DEEP), r3("bell_crank", CRANK)): + parts = {"of " + body: body for body in R.BODIES[m.kind]} + for member in R.MEMBERS[m.kind]: + for pin in R.RIDES[m.kind][member]: + for part, body in parts.items(): + zone = {member: [(part, pin, 0.01, 0.0)]} + if body in joins[pin]: + self.assertEqual(replace(m, parts=parts, touch=zone).touch[member], ((part, pin, 0.01, 0.0),)) + continue + with self.assertRaises(R.RamError) as caught: + replace(m, parts=parts, touch=zone) + self.assertEqual((caught.exception.gate, caught.exception.pin), ("record", f"{member} {part} pin"), (m.kind, member, pin, body)) + self.assertIn(f"{member} may touch about {pin} a part of a body the pin joins ({', '.join(joins[pin])}); " + f"'{part}' turns with {body}", str(caught.exception)) + # Soul's capsule of the parent under the coupler, zoned as the probe zoned it: refused by the record, by + # from_record and as a world's answer; the shipped zones, each a part of a body its pin joins, are read + m, ram = r3("bell_crank", CRANK), R.Ram(BORE) + bodies, touch = r3_bodies(m, ram) + wire = json.loads(json.dumps(R.record(dressed(m, bodies, touch), ram))) + self.assertEqual(R.from_record(wire)[0].touch, dressed(m, bodies, touch).touch) + bodies.parts["under"], bodies.shapes["under"] = "parent", [("capsule", (X_COUPLER, 0.5, 0.2), (X_COUPLER, 0.6, 0.3), 0.08)] + halves = [("under", "p", 0.51 * m.lc, ram.link_r), ("under", "c", 0.51 * m.lc, ram.link_r)] + wire["parts"]["under"] = "parent" + for k, zone in enumerate(halves): + given = {**touch, "coupler": touch["coupler"] + halves[k:]} + wrote = {**wire, "touch": {**wire["touch"], "coupler": wire["touch"]["coupler"] + [dict(zip(R.ZONE, zone))]}} + hinge, seat = {"pivot": O, "axis": X, "lo": -125, "hi": 0}, {name: [getattr(m, name)] for name in ("a", "rocker", "c")} + for read in (lambda: dressed(m, bodies, given), lambda: R.from_record(wrote), + lambda: R.search("bell_crank", hinge, ram, {**seat, "link": (m.lr, m.lr, 1), "d": (0.24, 0.24, 1)}, world=lambda made: (bodies.parts, given, bodies))): + with self.assertRaises(R.RamError) as caught: + read() + self.assertEqual((caught.exception.gate, caught.exception.pin), ("record", "coupler under pin")) + self.assertIn(f"about {zone[1]} a part of a body the pin joins", str(caught.exception)) + # the body is refused before the zone is measured: a zone both foreign and wider than its member names the pin + with self.assertRaises(R.RamError) as caught: + dressed(m, bodies, {"coupler": [("under", "p", 1e9, 0.0)]}) + self.assertEqual(caught.exception.pin, "coupler under pin") + def test_a_wall_the_axis_crosses_in_a_zone_is_read_whatever_its_thickness(self): - # Soul's tunnel: a wall of the thigh across the coupler, midway between two of its samples, inside a zone - # about p of depth 0. Every sample stands outside it; the segment between them is what crosses + # Soul's tunnel: a wall of the rocker across the coupler, midway between two of its samples, inside a zone + # about p of depth 0. Every sample stands outside it; the segment between them is what crosses. The wall is + # the rocker's, which p joins, and stands in the rocker's frame, where the coupler's samples at -60 are `samples` m, ram = r3("bell_crank", CRANK), R.Ram(BORE) at = R.pose(m, -60.0) start = at.P[0] - np.array(X) * ((at.P[0] - at.C[0]) @ np.array(X)) count = int(math.ceil(m.lc / ram.spacing())) + 1 - samples = start + (at.C[0] - start) * np.linspace(0.0, 1.0, count)[:, None] + + def seen(n): + return R._into(m, at, "rocker", (start + (at.C[0] - start) * np.linspace(0.0, 1.0, n)[:, None])[None])[0] + samples = seen(count) spot = 0.5 * (samples[2] + samples[3]) - along = (at.C[0] - start) / m.lc + along = (samples[-1] - samples[0]) / m.lc k = 1 if abs(along[1]) > abs(along[2]) else 2 def reading(half, shift=0.0): @@ -684,7 +739,7 @@ class DeepKnee(unittest.TestCase): lo[k], hi[k] = spot[k] - half, spot[k] + half lo[0], hi[0] = X_COUPLER - 0.05 + shift, X_COUPLER + 0.05 + shift bodies = r3_parts(m, ram) - bodies.parts["wall"], bodies.shapes["wall"] = "parent", [("box", lo, hi)] + bodies.parts["wall"], bodies.shapes["wall"] = "rocker", [("box", lo, hi)] self.assertGreater(float(bodies("wall", samples).min()), 0.0) return R.clearance(dressed(m, bodies, {"coupler": [("wall", "p", 0.28, 0.0)]}), ram, [-60.0], bodies).pairs[("coupler", "wall")][0] for half in (0.01, 0.003, 1e-4, 1e-7, 1e-10): @@ -697,9 +752,9 @@ class DeepKnee(unittest.TestCase): self.assertGreaterEqual(reading(0.01, 0.05 + 1.2 * ram.spacing() / R.FINE), 0.0) # a segment with one end in the zone is proved as well. Sampled 0.3 apart, the sample beyond the zone keeps its # 0.186 from a bead on the axis 0.008 past the last sample in the zone; the bead is read all the same - wide = start + (at.C[0] - start) * np.linspace(0.0, 1.0, 3)[:, None] + wide = seen(3) bodies, spot = r3_parts(m, ram), wide[1] + 0.012 * along - bodies.parts["bead"], bodies.shapes["bead"] = "parent", [("capsule", spot, spot, 0.004)] + bodies.parts["bead"], bodies.shapes["bead"] = "rocker", [("capsule", spot, spot, 0.004)] self.assertGreater(float(bodies("bead", wide[:2]).min()), 0.0) self.assertGreaterEqual(float(bodies("bead", wide[2:])[0]), near(ram, "coupler", 0.3)) got = R.clearance(dressed(m, bodies, {"coupler": [("bead", "p", 0.25, 0.0)]}), ram, [-60.0], bodies, spacing=0.3) @@ -843,8 +898,13 @@ class OracleRule(unittest.TestCase): lugged = two(a=seats.shapes["a"] and ("parent", seats.shapes["a"]), b=("child", seats.shapes["b"]), **{"b.lug": ("child", seats.shapes["b"])}) got = R.clearance(dressed(m, lugged, zones), ram, 0.0, lugged) self.assertEqual({pair: round(reading[0], 9) for pair, reading in got.pairs.items() if reading[0] < 0.0}, {("rod[0]", "b.lug"): round(-0.03 - near(ram, "rod"), 9)}) - for crossed in ({"barrel": [("b", "b", 0.2, 0.03)], "rod": [("a", "a", 0.2, 0.03)]}, {"barrel": [("a", "b", 0.2, 0.03)], "rod": [("b", "a", 0.2, 0.03)]}): - self.assertLess(float(R.clearance(dressed(m, seats, crossed), ram, 0.0, seats).margin[0]), 0.0) + crossed = {"barrel": [("b", "b", 0.2, 0.03)], "rod": [("a", "a", 0.2, 0.03)]} + self.assertLess(float(R.clearance(dressed(m, seats, crossed), ram, 0.0, seats).margin[0]), 0.0) + # and a part zoned about the pin at the member's other end, which does not join its body, is no zone at all + for crossed, pin in (({"barrel": [("a", "b", 0.2, 0.03)]}, "barrel a pin"), ({"rod": [("b", "a", 0.2, 0.03)]}, "rod b pin")): + with self.assertRaises(R.RamError) as caught: + dressed(m, seats, crossed) + self.assertEqual((caught.exception.gate, caught.exception.pin), ("record", pin)) def test_every_body_owns_a_part(self): ball = Bodies({"ball": ("parent", [("capsule", (0, 0, 0), (0, 0, 0), 0.1)])}) @@ -942,19 +1002,20 @@ class SearchBestFirst(unittest.TestCase): ((ball.parts, {}, None), "search", "world(m) returns"), ((ball.parts, {"rod": ["parent"]}, ball), "record", "zone is (part, pin, radius, depth)"), ((ball.parts, {"rod": [("parent", "c", 1.0, 0.0)]}, ball), "record", "a pin it rides (a, b)"), ((ball.parts, {"rod": [("thigh", "b", 1.0, 0.0)]}, ball), "record", "no part of the record"), - ((ball.parts, {"rod": [("parent", "b", 1e308, 0.0)]}, ball), "record", "rod is at most"), - ((ball.parts, {"rod": [("parent", "b", 0.5, 1e308)]}, ball), "record", "rod is at most"), - ((ball.parts, {"rod": [("parent", "b", 1e9, 1e9)]}, ball), "record", "rod is at most"), - ((ball.parts, {"rod": [("parent", "b", float("inf"), 0.0)]}, ball), "record", "a finite number"), - ((ball.parts, {"rod": [("parent", "b", 0.5, float("nan"))]}, ball), "record", "a finite number"), - ((ball.parts, {"rod": [("parent", "b", 0.5, 1.2 * ram.e_b)]}, ball), "record", "rod's on b is 0.0850"), + ((ball.parts, {"rod": [("child", "b", 1e308, 0.0)]}, ball), "record", "rod is at most"), + ((ball.parts, {"rod": [("parent", "b", 0.5, 0.0)]}, ball), "record", "a body the pin joins (child); 'parent' turns with parent"), + ((ball.parts, {"rod": [("child", "b", 0.5, 1e308)]}, ball), "record", "rod is at most"), + ((ball.parts, {"rod": [("child", "b", 1e9, 1e9)]}, ball), "record", "rod is at most"), + ((ball.parts, {"rod": [("child", "b", float("inf"), 0.0)]}, ball), "record", "a finite number"), + ((ball.parts, {"rod": [("child", "b", 0.5, float("nan"))]}, ball), "record", "a finite number"), + ((ball.parts, {"rod": [("child", "b", 0.5, 1.2 * ram.e_b)]}, ball), "record", "rod's on b is 0.0850"), (({"ball": "rocker"}, {}, ball), "record", "turns with 'rocker'"), (({"ball": "parent"}, {}, ball), "record", "no part turns with body child")): with self.assertRaises(R.RamError) as caught: R.search("direct", self.HINGE, ram, seats, world=lambda m: made) self.assertEqual(caught.exception.gate, gate, said) self.assertIn(said, str(caught.exception)) self.assertTrue(R.search("direct", self.HINGE, ram, seats, world=lambda m: (ball.parts, {}, ball)).found) - self.assertTrue(R.search("direct", self.HINGE, ram, seats, world=lambda m: (ball.parts, {"rod": [("parent", "b", 0.5, ram.e_b)]}, ball)).found) + self.assertTrue(R.search("direct", self.HINGE, ram, seats, world=lambda m: (ball.parts, {"rod": [("child", "b", 0.5, ram.e_b)]}, ball)).found) def test_the_limit_is_refused_naming_the_count(self): seats = {"a": grid((0, -0.5, 0.4), (0, -0.2, 1.2), (1, 3, 5)), "b": grid((0, -0.5, -1.2), (0, -0.2, -0.4), (1, 3, 5))} @@ -1082,7 +1143,8 @@ class RecordDrives(unittest.TestCase): ({"parts": {"knee": "parent"}, "touch": {"rod": "knee"}}, "rod's zones are a list"), ({"parts": {"knee": "parent"}, "touch": {"rod": [{"part": "knee", "pin": "b", "radius": 0.1}]}}, "missing ['depth']"), ({"parts": {"knee": "parent"}, "touch": {"rod": [{"part": "knee", "pin": "b", "radius": 0.1, "depth": 0.0, "whole": True}]}}, "unknown ['whole']"), - ({"parts": {"knee": "parent"}, "touch": {"rod": [{"part": "knee", "pin": "b", "radius": None, "depth": 0.0}]}}, "(pin rod knee radius)")): + ({"parts": {"knee": "parent"}, "touch": {"rod": [{"part": "knee", "pin": "b", "radius": None, "depth": 0.0}]}}, "(pin rod knee radius)"), + ({"parts": {"knee": "parent"}, "touch": {"rod": [{"part": "knee", "pin": "b", "radius": 0.1, "depth": 0.0}]}}, "(pin rod knee pin): rod may touch about b a part of a body the pin joins (child)")): with self.assertRaises(R.RamError) as caught: R.from_record({**data, **change}) self.assertEqual(caught.exception.gate, "record", change) @@ -1090,7 +1152,7 @@ class RecordDrives(unittest.TestCase): with self.assertRaises(R.RamError) as caught: R.from_record([data]) self.assertIn("a record is an object, got list", str(caught.exception)) - zoned = R.from_record({**data, "parts": {"knee": "parent"}, "touch": {"rod": [{"part": "knee", "pin": "b", "radius": 0.1, "depth": 0}]}})[0] + zoned = R.from_record({**data, "parts": {"knee": "child"}, "touch": {"rod": [{"part": "knee", "pin": "b", "radius": 0.1, "depth": 0}]}})[0] self.assertEqual(zoned.touch, {"rod": (("knee", "b", 0.1, 0.0),)}) # a ram refuses the same numbers when built by hand for bad in ({"bore": -0.05}, {"bore": 0.0}, {"bore": None}, {"bore": True}, {"bore": 0.05, "gap": float("nan")}, {"bore": 0.05, "tail": float("inf")}, {"bore": 0.05, "rod": "0.02"}): @@ -1144,6 +1206,8 @@ class Refusals(unittest.TestCase): self.refused("record", "rod knee radius", **knee, touch={"rod": [("knee", "d", "0.1", 0.0)]}) self.refused("record", "rod knee depth", **knee, touch={"rod": [("knee", "d", 0.1, -0.01)]}) self.refused("record", "rod knee depth", **knee, touch={"rod": [("knee", "d", 0.1, float("nan"))]}) + self.assertIn("a body the pin joins (rocker); 'knee' turns with parent", str(self.refused("record", "rod knee pin", **knee, touch={"rod": [("knee", "d", 0.1, 0.0)]}))) + self.assertEqual(R.Mechanism("four_bar", O, X, -125, 0, **{name: yz(DEEP[name]) for name in DEEP}, **knee, touch={"rod": [("knee", "a", 0.1, 0.0)]}).touch["rod"], (("knee", "a", 0.1, 0.0),)) self.refused("record", "a", a=(0, 1)) self.refused("record", "c", c=(0, float("nan"), 1)) self.refused("record", "b", b=(0, 0, -1)) # a four-bar has no b -- 2.47.3 From 60348312885555b99eb1c9075fdaa0850c8f401b Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Wed, 2 Dec 2026 22:39:32 +0100 Subject: [PATCH 02/11] test_ram: Soul s4's surviving mutants die; the two off-margin bounds restated by the margin ruling FINE is read as 64 and the floor's crossover (0.451 of spacing/64) is bounded at 0.319 and 0.638: FINE 128 (0.2255) and FINE 32 (0.902) each fail, as do 8 and 4096. A bead of the shin before the first sample of a zone about c kills the left-only pair. A base 0.1 from the rocker's pivot kills the ram's span taken about the knee's pivot (0.539 against 1.335, bound 0.848). The -0.9 link_r bounds become deviations from hand values (ZONED), the >= 0.02 bound a deviation from the nearest sample's reading (BESIDE, against B1: the proof by the nearer end less the span). Each constant states shipped, mutant and separation. Co-Authored-By: Claude Fable 5.2 --- surfaces/blender/tests/test_ram.py | 59 ++++++++++++++++++++++++------ 1 file changed, 48 insertions(+), 11 deletions(-) diff --git a/surfaces/blender/tests/test_ram.py b/surfaces/blender/tests/test_ram.py index 8a8c12d..1d43a83 100644 --- a/surfaces/blender/tests/test_ram.py +++ b/surfaces/blender/tests/test_ram.py @@ -499,6 +499,15 @@ SWING_BOUND = 0.81 TOGGLE_ARM = 0.0386 +# The clearance gate's zones on the R-3 bell crank. A reading a hand value states is bounded by its deviation from it; +# a shipped deviation of 0 counts as half an ulp of the value (lodur:ruling:deterministic-bound-zero-reading). +ZONED = 2.2e-10 # a rocker sample against its own plates: shipped 0 (half an ulp of link_r, 1.7e-18), W1..W3 (a zone's edge strict, the first zone only, the last zone overriding) 0.0294 and 0.0914 off, separation 1.3e8 each side +BESIDE = 1.2e-10 # a wall 0.02 beside the coupler, read at the nearest sample: shipped 0 (half an ulp of 0.0242, 1.7e-18), B1 (the proof by the nearer end's reading less the span, which halves and reads beside the wall) 0.00423 off, separation 4.9e7 each side +FLOOR_UNDER = 0.319 # how near the axis a wall held outside reads as touched, in spacing / 64: shipped under 0.451, FINE 128 under 0.2255, separation 1.41 each side +FLOOR_OVER = 0.638 # shipped under 0.451, FINE 32 under 0.902, separation 1.41 each side +SPAN_RAM = 0.848 # the ram's span with its base 0.1 from the rocker's pivot: shipped 0.5390 (about that pivot), the span about the knee's pivot 1.3347, separation 1.57 each side + + @unittest.skipIf(np is None, "numpy is not installed") class DeepKnee(unittest.TestCase): """The R-3 knee over 0..-125 (probes P1 to P3).""" @@ -653,6 +662,16 @@ class DeepKnee(unittest.TestCase): self.assertAlmostEqual(R._span(m, "rocker arm"), 0.24, places=9) self.assertGreaterEqual(R._span(m, "rod"), float(R.pose(m, np.linspace(-125.0, 0.0, 126)).L.max())) self.assertEqual([ram.eye(*of) for of in (("barrel", "a"), ("rod", "a"), ("rod", "d"), ("coupler", "c"))], [ram.e_a, ram.e_a, ram.e_b, ram.link_r]) + # a linkage's ram spans from the rocker's pivot, which its eye turns about, not the knee's: a base seated 0.1 + # from the rocker's pivot makes a ram of 0.539 at the most, and a zone between that and the 1.335 the knee's + # pivot would give is refused + seated = replace(m, a=m.rocker + (0.0, 0.0, 0.1), parts=bodies.parts) + self.assertAlmostEqual(R._span(seated, "rod"), 0.1 + math.hypot(X_ROCKER, 0.24), places=12) + for member in ("barrel", "rod"): + replace(seated, touch={member: [("thigh", "a", 0.53, 0.0)]}) + with self.assertRaises(R.RamError) as caught: + replace(seated, touch={member: [("thigh", "a", SPAN_RAM, 0.0)]}) + self.assertEqual((caught.exception.gate, caught.exception.pin), ("record", f"{member} thigh radius")) for member, pin, part in (("barrel", "a", "thigh"), ("rod", "d", "pin d"), ("rocker", "p", "coupler plates"), ("coupler", "c", "horn"), ("rocker arm", "rocker", "bracket")): span, eye = R._span(m, member), ram.eye(member, pin) @@ -727,8 +746,8 @@ class DeepKnee(unittest.TestCase): start = at.P[0] - np.array(X) * ((at.P[0] - at.C[0]) @ np.array(X)) count = int(math.ceil(m.lc / ram.spacing())) + 1 - def seen(n): - return R._into(m, at, "rocker", (start + (at.C[0] - start) * np.linspace(0.0, 1.0, n)[:, None])[None])[0] + def seen(n, body="rocker"): + return R._into(m, at, body, (start + (at.C[0] - start) * np.linspace(0.0, 1.0, n)[:, None])[None])[0] samples = seen(count) spot = 0.5 * (samples[2] + samples[3]) along = (samples[-1] - samples[0]) / m.lc @@ -740,16 +759,22 @@ class DeepKnee(unittest.TestCase): lo[0], hi[0] = X_COUPLER - 0.05 + shift, X_COUPLER + 0.05 + shift bodies = r3_parts(m, ram) bodies.parts["wall"], bodies.shapes["wall"] = "rocker", [("box", lo, hi)] - self.assertGreater(float(bodies("wall", samples).min()), 0.0) + reading.sampled = float(bodies("wall", samples).min()) + self.assertGreater(reading.sampled, 0.0) return R.clearance(dressed(m, bodies, {"coupler": [("wall", "p", 0.28, 0.0)]}), ram, [-60.0], bodies).pairs[("coupler", "wall")][0] for half in (0.01, 0.003, 1e-4, 1e-7, 1e-10): self.assertLess(reading(half), 0.0, half) - # the same walls beside the axis, 0.02 off along the hinge axis: held outside, and let + # the same walls beside the axis, 0.02 off along the hinge axis: held outside, and let. The samples either + # side prove the segment, so the reading is the nearer sample's (0.0242: 0.02 across, 0.0137 along), not the + # 0.02 a point between them would read for half in (0.01, 1e-7): - self.assertGreaterEqual(reading(half, 0.07), 0.02) - # nearer the axis than the floor of the halving, a part the axis is held outside reads as touched - self.assertLess(reading(0.01, 0.05 + 0.2 * ram.spacing() / R.FINE), 0.0) - self.assertGreaterEqual(reading(0.01, 0.05 + 1.2 * ram.spacing() / R.FINE), 0.0) + self.assertLess(abs(reading(half, 0.07) - reading.sampled), BESIDE, half) + self.assertGreater(reading.sampled, 0.024) + # nearer the axis than the floor of the halving, a part the axis is held outside reads as touched. The floor is + # the spacing over 64, written here as the number: the doc's, and what the gate's cost was measured at + self.assertEqual(R.FINE, 64) + self.assertLess(reading(0.01, 0.05 + FLOOR_UNDER * ram.spacing() / 64), 0.0) + self.assertGreaterEqual(reading(0.01, 0.05 + FLOOR_OVER * ram.spacing() / 64), 0.0) # a segment with one end in the zone is proved as well. Sampled 0.3 apart, the sample beyond the zone keeps its # 0.186 from a bead on the axis 0.008 past the last sample in the zone; the bead is read all the same wide = seen(3) @@ -759,6 +784,15 @@ class DeepKnee(unittest.TestCase): self.assertGreaterEqual(float(bodies("bead", wide[2:])[0]), near(ram, "coupler", 0.3)) got = R.clearance(dressed(m, bodies, {"coupler": [("bead", "p", 0.25, 0.0)]}), ram, [-60.0], bodies, spacing=0.3) self.assertLess(got.pairs[("coupler", "bead")][0], 0.0) + # and so is the segment whose far end alone is in the zone: a bead of the shin 0.008 short of the first sample + # in a zone about c, the sample before it out of the zone and keeping its 0.186 + wide = seen(3, "child") + bodies, spot = r3_parts(m, ram), wide[1] - 0.012 * (wide[2] - wide[0]) / m.lc + bodies.parts["bead"], bodies.shapes["bead"] = "child", [("capsule", spot, spot, 0.004)] + self.assertGreater(float(bodies("bead", wide[1:]).min()), 0.0) + self.assertGreaterEqual(float(bodies("bead", wide[:1])[0]), near(ram, "coupler", 0.3)) + got = R.clearance(dressed(m, bodies, {"coupler": [("bead", "c", 0.25, 0.0)]}), ram, [-60.0], bodies, spacing=0.3) + self.assertLess(got.pairs[("coupler", "bead")][0], 0.0) def test_two_zones_of_one_pair_and_a_sample_at_a_zones_radius(self): # Soul's W1..W3. A pair zoned twice: a sample both reach is let the deeper, in either order, and each zone @@ -773,8 +807,11 @@ class DeepKnee(unittest.TestCase): self.assertAlmostEqual(reading(deep, beside, far), 0.0, places=12) self.assertAlmostEqual(reading(beside, deep, far), 0.0, places=12) self.assertAlmostEqual(reading(far, beside, deep), 0.0, places=12) - for short in ((beside, beside, far), (deep, beside), (far, deep[:2] + (0.3 * m.lr, ram.link_r))): - self.assertLess(reading(*short), -0.9 * ram.link_r, short) + # short of that the sample reads what it is: link_r inside its own plate where the zone holds it outside, and + # where no zone reaches it link_r inside and all it keeps short + own = ram.link_r + near(ram, "rocker") + for short, reads in (((beside, beside, far), -ram.link_r), ((deep, beside), -own), ((far, deep[:2] + (0.3 * m.lr, ram.link_r)), -own)): + self.assertLess(abs(reading(*short) - reads), ZONED, short) at = R.pose(m, [-60.0]) end = at.P - np.array(X) * ((at.P - m.rocker) @ np.array(X))[:, None] count = int(math.ceil(m.lr / ram.spacing())) + 1 @@ -782,7 +819,7 @@ class DeepKnee(unittest.TestCase): across = np.linalg.norm(R._flat(pts - m.rocker, np.array(X)), axis=2)[0] edge, beyond = float(across[3]), m.lr - 0.5 * float(across[3] + across[4]) self.assertAlmostEqual(reading(("rocker plates", "rocker", edge, ram.link_r), ("rocker plates", "p", beyond, ram.link_r), degrees=[-60.0]), 0.0, places=12) - self.assertLess(reading(("rocker plates", "rocker", float(np.nextafter(edge, 0.0)), ram.link_r), ("rocker plates", "p", beyond, ram.link_r), degrees=[-60.0]), -0.9 * ram.link_r) + self.assertLess(abs(reading(("rocker plates", "rocker", float(np.nextafter(edge, 0.0)), ram.link_r), ("rocker plates", "p", beyond, ram.link_r), degrees=[-60.0]) + own), ZONED) def test_a_pin_stood_inside_what_it_stands_beside_is_refused(self): # Soul's moved-x probes: the rocker's x moved from its plate's place (0.3675) into the bracket's 0.13..0.35, -- 2.47.3 From 2be27f0c0c34407454de7953ca23c0582f4d8d90 Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Wed, 2 Dec 2026 22:40:57 +0100 Subject: [PATCH 03/11] live ram_knee: the oracle's rays held from inside: 29 points inside the jointlib rocker plates Soul s4 (ray-fixture-pins-above-one-not-three, crossing-proof-needs-a-sign- true-oracle): the fixture held only points outside the plates, which two rays or an axis-aligned pair read as three do. ram_rays.json gains `inside`: points 0.001 or more inside one of the shell's four convex pieces, nine aimed along a ray, x or y, twenty where a side's two bars overlap. The oracle as made reads 0 outside; two rays 16, one ray 10, the second ray the first 10, the second and third along x and y 6. The check asks 0 and at least 2. The fixture's `about` says what this does not show: fed as one shell the overlap is signed by parity, and three rays read 1,906 of 38,448 inside grid points outside; with each piece its own shell, none. Co-Authored-By: Claude Fable 5.2 --- surfaces/blender/tests/fixtures/ram_rays.json | 2 +- surfaces/blender/tests/live/ram_knee.py | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/surfaces/blender/tests/fixtures/ram_rays.json b/surfaces/blender/tests/fixtures/ram_rays.json index 788d9ee..37c414c 100644 --- a/surfaces/blender/tests/fixtures/ram_rays.json +++ b/surfaces/blender/tests/fixtures/ram_rays.json @@ -1 +1 @@ -{"about":"The rocker's twin plates of the R-3 bell crank as Imagination's jointlib builds them (one shell, triangulated, at rest), and points between the plates (|x| under 0.349, the plates begin at 0.35): each stands on the oracle's first ray 0.004 to 0.02 short of a vertex or an edge of the shell. Every point is outside.","verts":[[-0.349999994,0.740011215,0.389170021],[-0.349999994,0.752862871,0.394919485],[-0.349999994,0.763308823,0.404358923],[-0.349999994,0.770326555,0.416564375],[-0.349999994,0.773229182,0.430341005],[-0.349999994,0.77173245,0.444340348],[-0.349999994,0.765982985,0.457191974],[-0.349999994,0.756543517,0.467637926],[-0.349999994,0.744338095,0.474655658],[-0.349999994,0.730561495,0.477558255],[-0.349999994,0.716562152,0.476061553],[-0.349999994,0.305388123,0.365099549],[-0.349999994,0.292536497,0.359350085],[-0.349999994,0.282090545,0.349910617],[-0.349999994,0.275072783,0.337705195],[-0.349999994,0.272170216,0.323928565],[-0.349999994,0.273666918,0.309929222],[-0.349999994,0.279416382,0.297077596],[-0.349999994,0.288855821,0.286631644],[-0.349999994,0.301061243,0.279613912],[-0.349999994,0.314837903,0.276711315],[-0.349999994,0.328837216,0.278208017],[-0.38499999,0.740011215,0.389170021],[-0.38499999,0.752862871,0.394919485],[-0.38499999,0.763308823,0.404358923],[-0.38499999,0.770326555,0.416564375],[-0.38499999,0.773229182,0.430341005],[-0.38499999,0.77173245,0.444340348],[-0.38499999,0.765982985,0.457191974],[-0.38499999,0.756543517,0.467637926],[-0.38499999,0.744338095,0.474655658],[-0.38499999,0.730561495,0.477558255],[-0.38499999,0.716562152,0.476061553],[-0.38499999,0.305388123,0.365099549],[-0.38499999,0.292536497,0.359350085],[-0.38499999,0.282090545,0.349910617],[-0.38499999,0.275072783,0.337705195],[-0.38499999,0.272170216,0.323928565],[-0.38499999,0.273666918,0.309929222],[-0.38499999,0.279416382,0.297077596],[-0.38499999,0.288855821,0.286631644],[-0.38499999,0.301061243,0.279613912],[-0.38499999,0.314837903,0.276711315],[-0.38499999,0.328837216,0.278208017],[-0.349999994,0.514849424,0.463428885],[-0.349999994,0.522187293,0.473566681],[-0.349999994,0.526033282,0.485475808],[-0.349999994,0.526010931,0.497990549],[-0.349999994,0.522122383,0.509885848],[-0.349999994,0.514748275,0.519997358],[-0.349999994,0.504610479,0.527335227],[-0.349999994,0.492701381,0.531181216],[-0.349999994,0.480186641,0.531158805],[-0.349999994,0.468291312,0.527270257],[-0.349999994,0.458179832,0.519896209],[-0.349999994,0.288777888,0.349887431],[-0.349999994,0.28144002,0.339749664],[-0.349999994,0.27759403,0.327840507],[-0.349999994,0.277616382,0.315325767],[-0.349999994,0.281504929,0.303430468],[-0.349999994,0.288879007,0.293318987],[-0.349999994,0.299016804,0.285981119],[-0.349999994,0.310925931,0.282135129],[-0.349999994,0.323440671,0.282157511],[-0.349999994,0.335336,0.286046058],[-0.349999994,0.345447481,0.293420136],[-0.38499999,0.514849424,0.463428885],[-0.38499999,0.522187293,0.473566681],[-0.38499999,0.526033282,0.485475808],[-0.38499999,0.526010931,0.497990549],[-0.38499999,0.522122383,0.509885848],[-0.38499999,0.514748275,0.519997358],[-0.38499999,0.504610479,0.527335227],[-0.38499999,0.492701381,0.531181216],[-0.38499999,0.480186641,0.531158805],[-0.38499999,0.468291312,0.527270257],[-0.38499999,0.458179832,0.519896209],[-0.38499999,0.288777888,0.349887431],[-0.38499999,0.28144002,0.339749664],[-0.38499999,0.27759403,0.327840507],[-0.38499999,0.277616382,0.315325767],[-0.38499999,0.281504929,0.303430468],[-0.38499999,0.288879007,0.293318987],[-0.38499999,0.299016804,0.285981119],[-0.38499999,0.310925931,0.282135129],[-0.38499999,0.323440671,0.282157511],[-0.38499999,0.335336,0.286046058],[-0.38499999,0.345447481,0.293420136],[0.349999994,0.740011215,0.389170021],[0.349999994,0.752862871,0.394919485],[0.349999994,0.763308823,0.404358923],[0.349999994,0.770326555,0.416564375],[0.349999994,0.773229182,0.430341005],[0.349999994,0.77173245,0.444340348],[0.349999994,0.765982985,0.457191974],[0.349999994,0.756543517,0.467637926],[0.349999994,0.744338095,0.474655658],[0.349999994,0.730561495,0.477558255],[0.349999994,0.716562152,0.476061553],[0.349999994,0.305388123,0.365099549],[0.349999994,0.292536497,0.359350085],[0.349999994,0.282090545,0.349910617],[0.349999994,0.275072783,0.337705195],[0.349999994,0.272170216,0.323928565],[0.349999994,0.273666918,0.309929222],[0.349999994,0.279416382,0.297077596],[0.349999994,0.288855821,0.286631644],[0.349999994,0.301061243,0.279613912],[0.349999994,0.314837903,0.276711315],[0.349999994,0.328837216,0.278208017],[0.38499999,0.740011215,0.389170021],[0.38499999,0.752862871,0.394919485],[0.38499999,0.763308823,0.404358923],[0.38499999,0.770326555,0.416564375],[0.38499999,0.773229182,0.430341005],[0.38499999,0.77173245,0.444340348],[0.38499999,0.765982985,0.457191974],[0.38499999,0.756543517,0.467637926],[0.38499999,0.744338095,0.474655658],[0.38499999,0.730561495,0.477558255],[0.38499999,0.716562152,0.476061553],[0.38499999,0.305388123,0.365099549],[0.38499999,0.292536497,0.359350085],[0.38499999,0.282090545,0.349910617],[0.38499999,0.275072783,0.337705195],[0.38499999,0.272170216,0.323928565],[0.38499999,0.273666918,0.309929222],[0.38499999,0.279416382,0.297077596],[0.38499999,0.288855821,0.286631644],[0.38499999,0.301061243,0.279613912],[0.38499999,0.314837903,0.276711315],[0.38499999,0.328837216,0.278208017],[0.349999994,0.514849424,0.463428885],[0.349999994,0.522187293,0.473566681],[0.349999994,0.526033282,0.485475808],[0.349999994,0.526010931,0.497990549],[0.349999994,0.522122383,0.509885848],[0.349999994,0.514748275,0.519997358],[0.349999994,0.504610479,0.527335227],[0.349999994,0.492701381,0.531181216],[0.349999994,0.480186641,0.531158805],[0.349999994,0.468291312,0.527270257],[0.349999994,0.458179832,0.519896209],[0.349999994,0.288777888,0.349887431],[0.349999994,0.28144002,0.339749664],[0.349999994,0.27759403,0.327840507],[0.349999994,0.277616382,0.315325767],[0.349999994,0.281504929,0.303430468],[0.349999994,0.288879007,0.293318987],[0.349999994,0.299016804,0.285981119],[0.349999994,0.310925931,0.282135129],[0.349999994,0.323440671,0.282157511],[0.349999994,0.335336,0.286046058],[0.349999994,0.345447481,0.293420136],[0.38499999,0.514849424,0.463428885],[0.38499999,0.522187293,0.473566681],[0.38499999,0.526033282,0.485475808],[0.38499999,0.526010931,0.497990549],[0.38499999,0.522122383,0.509885848],[0.38499999,0.514748275,0.519997358],[0.38499999,0.504610479,0.527335227],[0.38499999,0.492701381,0.531181216],[0.38499999,0.480186641,0.531158805],[0.38499999,0.468291312,0.527270257],[0.38499999,0.458179832,0.519896209],[0.38499999,0.288777888,0.349887431],[0.38499999,0.28144002,0.339749664],[0.38499999,0.27759403,0.327840507],[0.38499999,0.277616382,0.315325767],[0.38499999,0.281504929,0.303430468],[0.38499999,0.288879007,0.293318987],[0.38499999,0.299016804,0.285981119],[0.38499999,0.310925931,0.282135129],[0.38499999,0.323440671,0.282157511],[0.38499999,0.335336,0.286046058],[0.38499999,0.345447481,0.293420136]],"faces":[[19,21,11],[24,22,32],[22,1,0],[23,2,1],[24,3,2],[25,4,3],[26,5,4],[27,6,5],[28,7,6],[29,8,7],[30,9,8],[31,10,9],[32,11,10],[33,12,11],[34,13,12],[35,14,13],[36,15,14],[37,16,15],[38,17,16],[39,18,17],[40,19,18],[41,20,19],[42,21,20],[43,0,21],[63,65,55],[68,66,76],[66,45,44],[67,46,45],[68,47,46],[69,48,47],[70,49,48],[71,50,49],[72,51,50],[73,52,51],[74,53,52],[75,54,53],[76,55,54],[77,56,55],[78,57,56],[79,58,57],[80,59,58],[81,60,59],[82,61,60],[83,62,61],[84,63,62],[85,64,63],[86,65,64],[87,44,65],[95,93,91],[122,124,128],[89,110,88],[90,111,89],[91,112,90],[92,113,91],[93,114,92],[94,115,93],[95,116,94],[96,117,95],[97,118,96],[98,119,97],[99,120,98],[100,121,99],[101,122,100],[102,123,101],[103,124,102],[104,125,103],[105,126,104],[106,127,105],[107,128,106],[108,129,107],[109,130,108],[88,131,109],[141,139,135],[166,168,172],[133,154,132],[134,155,133],[135,156,134],[136,157,135],[137,158,136],[138,159,137],[139,160,138],[140,161,139],[141,162,140],[142,163,141],[143,164,142],[144,165,143],[145,166,144],[146,167,145],[147,168,146],[148,169,147],[149,170,148],[150,171,149],[151,172,150],[152,173,151],[153,174,152],[132,175,153],[21,0,10],[0,1,10],[1,2,3],[3,4,5],[5,6,7],[7,8,9],[9,10,3],[10,11,21],[3,10,1],[11,12,13],[13,14,15],[15,16,19],[16,17,19],[17,18,19],[19,20,21],[3,5,7],[7,9,3],[11,13,19],[13,15,19],[22,43,33],[43,42,33],[42,41,40],[40,39,38],[38,37,40],[37,36,40],[36,35,34],[34,33,40],[33,32,22],[40,33,42],[32,31,30],[30,29,28],[28,27,26],[26,25,28],[25,24,28],[24,23,22],[36,34,40],[32,30,24],[30,28,24],[22,23,1],[23,24,2],[24,25,3],[25,26,4],[26,27,5],[27,28,6],[28,29,7],[29,30,8],[30,31,9],[31,32,10],[32,33,11],[33,34,12],[34,35,13],[35,36,14],[36,37,15],[37,38,16],[38,39,17],[39,40,18],[40,41,19],[41,42,20],[42,43,21],[43,22,0],[65,44,54],[44,45,54],[45,46,47],[47,48,49],[49,50,47],[50,51,47],[51,52,53],[53,54,47],[54,55,65],[47,54,45],[55,56,57],[57,58,59],[59,60,61],[61,62,63],[63,64,65],[51,53,47],[55,57,63],[57,59,63],[59,61,63],[66,87,77],[87,86,77],[86,85,84],[84,83,80],[83,82,80],[82,81,80],[80,79,78],[78,77,84],[77,76,66],[84,77,86],[76,75,74],[74,73,72],[72,71,68],[71,70,68],[70,69,68],[68,67,66],[80,78,84],[76,74,68],[74,72,68],[66,67,45],[67,68,46],[68,69,47],[69,70,48],[70,71,49],[71,72,50],[72,73,51],[73,74,52],[74,75,53],[75,76,54],[76,77,55],[77,78,56],[78,79,57],[79,80,58],[80,81,59],[81,82,60],[82,83,61],[83,84,62],[84,85,63],[85,86,64],[86,87,65],[87,66,44],[89,88,98],[88,109,99],[109,108,107],[107,106,105],[105,104,107],[104,103,107],[103,102,101],[101,100,99],[99,98,88],[98,97,91],[97,96,95],[95,94,93],[93,92,91],[91,90,89],[109,107,99],[103,101,107],[101,99,107],[98,91,89],[97,95,91],[130,131,121],[131,110,120],[110,111,112],[112,113,116],[113,114,116],[114,115,116],[116,117,118],[118,119,120],[120,121,131],[121,122,128],[122,123,124],[124,125,128],[125,126,128],[126,127,128],[128,129,130],[110,112,120],[116,118,112],[118,120,112],[121,128,130],[89,111,110],[90,112,111],[91,113,112],[92,114,113],[93,115,114],[94,116,115],[95,117,116],[96,118,117],[97,119,118],[98,120,119],[99,121,120],[100,122,121],[101,123,122],[102,124,123],[103,125,124],[104,126,125],[105,127,126],[106,128,127],[107,129,128],[108,130,129],[109,131,130],[88,110,131],[133,132,142],[132,153,143],[153,152,151],[151,150,149],[149,148,147],[147,146,145],[145,144,143],[143,142,132],[142,141,135],[141,140,139],[139,138,135],[138,137,135],[137,136,135],[135,134,133],[153,151,143],[151,149,147],[147,145,151],[145,143,151],[142,135,133],[174,175,165],[175,154,164],[154,155,156],[156,157,158],[158,159,156],[159,160,156],[160,161,162],[162,163,164],[164,165,175],[165,166,172],[166,167,168],[168,169,170],[170,171,168],[171,172,168],[172,173,174],[154,156,164],[160,162,156],[162,164,156],[165,172,174],[133,155,154],[134,156,155],[135,157,156],[136,158,157],[137,159,158],[138,160,159],[139,161,160],[140,162,161],[141,163,162],[142,164,163],[143,165,164],[144,166,165],[145,167,166],[146,168,167],[147,169,168],[148,170,169],[149,171,170],[150,172,171],[151,173,172],[152,174,173],[153,175,174],[132,154,175]],"points":[[0.34569818,0.758339776,0.399797897],[0.34569818,0.765357508,0.412003349],[0.33924546,0.757903937,0.405161809],[0.34569818,0.768260135,0.425779979],[0.343547274,0.765775611,0.423499465],[0.33924546,0.760806564,0.418938439],[0.34569818,0.766763402,0.439779322],[0.343547274,0.764278879,0.437498808],[0.33924546,0.759309832,0.432937782],[0.34569818,0.761013938,0.452630947],[0.343547274,0.758529415,0.450350434],[0.33924546,0.753560368,0.445789407],[0.34569818,0.75157447,0.4630769],[0.343547274,0.749089947,0.460796386],[0.33924546,0.744120899,0.45623536],[0.347849087,0.741853572,0.472375145],[0.34569818,0.739369048,0.470094631],[0.343547274,0.736884525,0.467814118],[0.33924546,0.731915478,0.463253092],[0.347849087,0.728076971,0.475277742],[0.34569818,0.725592448,0.472997229],[0.343547274,0.723107924,0.470716715],[0.33924546,0.718138877,0.466155689],[0.347849087,0.714077628,0.473781039]]} \ No newline at end of file +{"about":"The rocker's twin plates of the R-3 bell crank as Imagination's jointlib builds them (one shell, triangulated, at rest), and points between the plates (|x| under 0.349, the plates begin at 0.35): each stands on the oracle's first ray 0.004 to 0.02 short of a vertex or an edge of the shell. Every point is outside. `inside`: points 0.001 or more inside one of the shell's four pieces (each a convex prism; a side's two bars overlap about the pivot and share their faces' planes): nine aimed along a ray of RAYS, x or y at a vertex or an edge, the rest from a grid where the bars overlap. Fed as one shell, as here, the overlap is where a ray's parity fails: the oracle as it is made reads every one of these inside; two rays, one ray, a second ray equal to the first, or the second and third along x and y each read some outside. They hold the rays. They do not show that the oracle signs this shell truly: of 38,448 grid points inside it, three rays read 1,906 outside with the pieces one shell and none with each piece its own shell.","verts":[[-0.349999994,0.740011215,0.389170021],[-0.349999994,0.752862871,0.394919485],[-0.349999994,0.763308823,0.404358923],[-0.349999994,0.770326555,0.416564375],[-0.349999994,0.773229182,0.430341005],[-0.349999994,0.77173245,0.444340348],[-0.349999994,0.765982985,0.457191974],[-0.349999994,0.756543517,0.467637926],[-0.349999994,0.744338095,0.474655658],[-0.349999994,0.730561495,0.477558255],[-0.349999994,0.716562152,0.476061553],[-0.349999994,0.305388123,0.365099549],[-0.349999994,0.292536497,0.359350085],[-0.349999994,0.282090545,0.349910617],[-0.349999994,0.275072783,0.337705195],[-0.349999994,0.272170216,0.323928565],[-0.349999994,0.273666918,0.309929222],[-0.349999994,0.279416382,0.297077596],[-0.349999994,0.288855821,0.286631644],[-0.349999994,0.301061243,0.279613912],[-0.349999994,0.314837903,0.276711315],[-0.349999994,0.328837216,0.278208017],[-0.38499999,0.740011215,0.389170021],[-0.38499999,0.752862871,0.394919485],[-0.38499999,0.763308823,0.404358923],[-0.38499999,0.770326555,0.416564375],[-0.38499999,0.773229182,0.430341005],[-0.38499999,0.77173245,0.444340348],[-0.38499999,0.765982985,0.457191974],[-0.38499999,0.756543517,0.467637926],[-0.38499999,0.744338095,0.474655658],[-0.38499999,0.730561495,0.477558255],[-0.38499999,0.716562152,0.476061553],[-0.38499999,0.305388123,0.365099549],[-0.38499999,0.292536497,0.359350085],[-0.38499999,0.282090545,0.349910617],[-0.38499999,0.275072783,0.337705195],[-0.38499999,0.272170216,0.323928565],[-0.38499999,0.273666918,0.309929222],[-0.38499999,0.279416382,0.297077596],[-0.38499999,0.288855821,0.286631644],[-0.38499999,0.301061243,0.279613912],[-0.38499999,0.314837903,0.276711315],[-0.38499999,0.328837216,0.278208017],[-0.349999994,0.514849424,0.463428885],[-0.349999994,0.522187293,0.473566681],[-0.349999994,0.526033282,0.485475808],[-0.349999994,0.526010931,0.497990549],[-0.349999994,0.522122383,0.509885848],[-0.349999994,0.514748275,0.519997358],[-0.349999994,0.504610479,0.527335227],[-0.349999994,0.492701381,0.531181216],[-0.349999994,0.480186641,0.531158805],[-0.349999994,0.468291312,0.527270257],[-0.349999994,0.458179832,0.519896209],[-0.349999994,0.288777888,0.349887431],[-0.349999994,0.28144002,0.339749664],[-0.349999994,0.27759403,0.327840507],[-0.349999994,0.277616382,0.315325767],[-0.349999994,0.281504929,0.303430468],[-0.349999994,0.288879007,0.293318987],[-0.349999994,0.299016804,0.285981119],[-0.349999994,0.310925931,0.282135129],[-0.349999994,0.323440671,0.282157511],[-0.349999994,0.335336,0.286046058],[-0.349999994,0.345447481,0.293420136],[-0.38499999,0.514849424,0.463428885],[-0.38499999,0.522187293,0.473566681],[-0.38499999,0.526033282,0.485475808],[-0.38499999,0.526010931,0.497990549],[-0.38499999,0.522122383,0.509885848],[-0.38499999,0.514748275,0.519997358],[-0.38499999,0.504610479,0.527335227],[-0.38499999,0.492701381,0.531181216],[-0.38499999,0.480186641,0.531158805],[-0.38499999,0.468291312,0.527270257],[-0.38499999,0.458179832,0.519896209],[-0.38499999,0.288777888,0.349887431],[-0.38499999,0.28144002,0.339749664],[-0.38499999,0.27759403,0.327840507],[-0.38499999,0.277616382,0.315325767],[-0.38499999,0.281504929,0.303430468],[-0.38499999,0.288879007,0.293318987],[-0.38499999,0.299016804,0.285981119],[-0.38499999,0.310925931,0.282135129],[-0.38499999,0.323440671,0.282157511],[-0.38499999,0.335336,0.286046058],[-0.38499999,0.345447481,0.293420136],[0.349999994,0.740011215,0.389170021],[0.349999994,0.752862871,0.394919485],[0.349999994,0.763308823,0.404358923],[0.349999994,0.770326555,0.416564375],[0.349999994,0.773229182,0.430341005],[0.349999994,0.77173245,0.444340348],[0.349999994,0.765982985,0.457191974],[0.349999994,0.756543517,0.467637926],[0.349999994,0.744338095,0.474655658],[0.349999994,0.730561495,0.477558255],[0.349999994,0.716562152,0.476061553],[0.349999994,0.305388123,0.365099549],[0.349999994,0.292536497,0.359350085],[0.349999994,0.282090545,0.349910617],[0.349999994,0.275072783,0.337705195],[0.349999994,0.272170216,0.323928565],[0.349999994,0.273666918,0.309929222],[0.349999994,0.279416382,0.297077596],[0.349999994,0.288855821,0.286631644],[0.349999994,0.301061243,0.279613912],[0.349999994,0.314837903,0.276711315],[0.349999994,0.328837216,0.278208017],[0.38499999,0.740011215,0.389170021],[0.38499999,0.752862871,0.394919485],[0.38499999,0.763308823,0.404358923],[0.38499999,0.770326555,0.416564375],[0.38499999,0.773229182,0.430341005],[0.38499999,0.77173245,0.444340348],[0.38499999,0.765982985,0.457191974],[0.38499999,0.756543517,0.467637926],[0.38499999,0.744338095,0.474655658],[0.38499999,0.730561495,0.477558255],[0.38499999,0.716562152,0.476061553],[0.38499999,0.305388123,0.365099549],[0.38499999,0.292536497,0.359350085],[0.38499999,0.282090545,0.349910617],[0.38499999,0.275072783,0.337705195],[0.38499999,0.272170216,0.323928565],[0.38499999,0.273666918,0.309929222],[0.38499999,0.279416382,0.297077596],[0.38499999,0.288855821,0.286631644],[0.38499999,0.301061243,0.279613912],[0.38499999,0.314837903,0.276711315],[0.38499999,0.328837216,0.278208017],[0.349999994,0.514849424,0.463428885],[0.349999994,0.522187293,0.473566681],[0.349999994,0.526033282,0.485475808],[0.349999994,0.526010931,0.497990549],[0.349999994,0.522122383,0.509885848],[0.349999994,0.514748275,0.519997358],[0.349999994,0.504610479,0.527335227],[0.349999994,0.492701381,0.531181216],[0.349999994,0.480186641,0.531158805],[0.349999994,0.468291312,0.527270257],[0.349999994,0.458179832,0.519896209],[0.349999994,0.288777888,0.349887431],[0.349999994,0.28144002,0.339749664],[0.349999994,0.27759403,0.327840507],[0.349999994,0.277616382,0.315325767],[0.349999994,0.281504929,0.303430468],[0.349999994,0.288879007,0.293318987],[0.349999994,0.299016804,0.285981119],[0.349999994,0.310925931,0.282135129],[0.349999994,0.323440671,0.282157511],[0.349999994,0.335336,0.286046058],[0.349999994,0.345447481,0.293420136],[0.38499999,0.514849424,0.463428885],[0.38499999,0.522187293,0.473566681],[0.38499999,0.526033282,0.485475808],[0.38499999,0.526010931,0.497990549],[0.38499999,0.522122383,0.509885848],[0.38499999,0.514748275,0.519997358],[0.38499999,0.504610479,0.527335227],[0.38499999,0.492701381,0.531181216],[0.38499999,0.480186641,0.531158805],[0.38499999,0.468291312,0.527270257],[0.38499999,0.458179832,0.519896209],[0.38499999,0.288777888,0.349887431],[0.38499999,0.28144002,0.339749664],[0.38499999,0.27759403,0.327840507],[0.38499999,0.277616382,0.315325767],[0.38499999,0.281504929,0.303430468],[0.38499999,0.288879007,0.293318987],[0.38499999,0.299016804,0.285981119],[0.38499999,0.310925931,0.282135129],[0.38499999,0.323440671,0.282157511],[0.38499999,0.335336,0.286046058],[0.38499999,0.345447481,0.293420136]],"faces":[[19,21,11],[24,22,32],[22,1,0],[23,2,1],[24,3,2],[25,4,3],[26,5,4],[27,6,5],[28,7,6],[29,8,7],[30,9,8],[31,10,9],[32,11,10],[33,12,11],[34,13,12],[35,14,13],[36,15,14],[37,16,15],[38,17,16],[39,18,17],[40,19,18],[41,20,19],[42,21,20],[43,0,21],[63,65,55],[68,66,76],[66,45,44],[67,46,45],[68,47,46],[69,48,47],[70,49,48],[71,50,49],[72,51,50],[73,52,51],[74,53,52],[75,54,53],[76,55,54],[77,56,55],[78,57,56],[79,58,57],[80,59,58],[81,60,59],[82,61,60],[83,62,61],[84,63,62],[85,64,63],[86,65,64],[87,44,65],[95,93,91],[122,124,128],[89,110,88],[90,111,89],[91,112,90],[92,113,91],[93,114,92],[94,115,93],[95,116,94],[96,117,95],[97,118,96],[98,119,97],[99,120,98],[100,121,99],[101,122,100],[102,123,101],[103,124,102],[104,125,103],[105,126,104],[106,127,105],[107,128,106],[108,129,107],[109,130,108],[88,131,109],[141,139,135],[166,168,172],[133,154,132],[134,155,133],[135,156,134],[136,157,135],[137,158,136],[138,159,137],[139,160,138],[140,161,139],[141,162,140],[142,163,141],[143,164,142],[144,165,143],[145,166,144],[146,167,145],[147,168,146],[148,169,147],[149,170,148],[150,171,149],[151,172,150],[152,173,151],[153,174,152],[132,175,153],[21,0,10],[0,1,10],[1,2,3],[3,4,5],[5,6,7],[7,8,9],[9,10,3],[10,11,21],[3,10,1],[11,12,13],[13,14,15],[15,16,19],[16,17,19],[17,18,19],[19,20,21],[3,5,7],[7,9,3],[11,13,19],[13,15,19],[22,43,33],[43,42,33],[42,41,40],[40,39,38],[38,37,40],[37,36,40],[36,35,34],[34,33,40],[33,32,22],[40,33,42],[32,31,30],[30,29,28],[28,27,26],[26,25,28],[25,24,28],[24,23,22],[36,34,40],[32,30,24],[30,28,24],[22,23,1],[23,24,2],[24,25,3],[25,26,4],[26,27,5],[27,28,6],[28,29,7],[29,30,8],[30,31,9],[31,32,10],[32,33,11],[33,34,12],[34,35,13],[35,36,14],[36,37,15],[37,38,16],[38,39,17],[39,40,18],[40,41,19],[41,42,20],[42,43,21],[43,22,0],[65,44,54],[44,45,54],[45,46,47],[47,48,49],[49,50,47],[50,51,47],[51,52,53],[53,54,47],[54,55,65],[47,54,45],[55,56,57],[57,58,59],[59,60,61],[61,62,63],[63,64,65],[51,53,47],[55,57,63],[57,59,63],[59,61,63],[66,87,77],[87,86,77],[86,85,84],[84,83,80],[83,82,80],[82,81,80],[80,79,78],[78,77,84],[77,76,66],[84,77,86],[76,75,74],[74,73,72],[72,71,68],[71,70,68],[70,69,68],[68,67,66],[80,78,84],[76,74,68],[74,72,68],[66,67,45],[67,68,46],[68,69,47],[69,70,48],[70,71,49],[71,72,50],[72,73,51],[73,74,52],[74,75,53],[75,76,54],[76,77,55],[77,78,56],[78,79,57],[79,80,58],[80,81,59],[81,82,60],[82,83,61],[83,84,62],[84,85,63],[85,86,64],[86,87,65],[87,66,44],[89,88,98],[88,109,99],[109,108,107],[107,106,105],[105,104,107],[104,103,107],[103,102,101],[101,100,99],[99,98,88],[98,97,91],[97,96,95],[95,94,93],[93,92,91],[91,90,89],[109,107,99],[103,101,107],[101,99,107],[98,91,89],[97,95,91],[130,131,121],[131,110,120],[110,111,112],[112,113,116],[113,114,116],[114,115,116],[116,117,118],[118,119,120],[120,121,131],[121,122,128],[122,123,124],[124,125,128],[125,126,128],[126,127,128],[128,129,130],[110,112,120],[116,118,112],[118,120,112],[121,128,130],[89,111,110],[90,112,111],[91,113,112],[92,114,113],[93,115,114],[94,116,115],[95,117,116],[96,118,117],[97,119,118],[98,120,119],[99,121,120],[100,122,121],[101,123,122],[102,124,123],[103,125,124],[104,126,125],[105,127,126],[106,128,127],[107,129,128],[108,130,129],[109,131,130],[88,110,131],[133,132,142],[132,153,143],[153,152,151],[151,150,149],[149,148,147],[147,146,145],[145,144,143],[143,142,132],[142,141,135],[141,140,139],[139,138,135],[138,137,135],[137,136,135],[135,134,133],[153,151,143],[151,149,147],[147,145,151],[145,143,151],[142,135,133],[174,175,165],[175,154,164],[154,155,156],[156,157,158],[158,159,156],[159,160,156],[160,161,162],[162,163,164],[164,165,175],[165,166,172],[166,167,168],[168,169,170],[170,171,168],[171,172,168],[172,173,174],[154,156,164],[160,162,156],[162,164,156],[165,172,174],[133,155,154],[134,156,155],[135,157,156],[136,158,157],[137,159,158],[138,160,159],[139,161,160],[140,162,161],[141,163,162],[142,164,163],[143,165,164],[144,166,165],[145,167,166],[146,168,167],[147,169,168],[148,170,169],[149,171,170],[150,172,171],[151,173,172],[152,174,173],[153,175,174],[132,154,175]],"points":[[0.34569818,0.758339776,0.399797897],[0.34569818,0.765357508,0.412003349],[0.33924546,0.757903937,0.405161809],[0.34569818,0.768260135,0.425779979],[0.343547274,0.765775611,0.423499465],[0.33924546,0.760806564,0.418938439],[0.34569818,0.766763402,0.439779322],[0.343547274,0.764278879,0.437498808],[0.33924546,0.759309832,0.432937782],[0.34569818,0.761013938,0.452630947],[0.343547274,0.758529415,0.450350434],[0.33924546,0.753560368,0.445789407],[0.34569818,0.75157447,0.4630769],[0.343547274,0.749089947,0.460796386],[0.33924546,0.744120899,0.45623536],[0.347849087,0.741853572,0.472375145],[0.34569818,0.739369048,0.470094631],[0.343547274,0.736884525,0.467814118],[0.33924546,0.731915478,0.463253092],[0.347849087,0.728076971,0.475277742],[0.34569818,0.725592448,0.472997229],[0.343547274,0.723107924,0.470716715],[0.33924546,0.718138877,0.466155689],[0.347849087,0.714077628,0.473781039]],"inside":[[-0.374881795,0.506437858,0.465394675],[-0.366131796,0.753098523,0.427236497],[0.367678355,0.451073686,0.418925236],[0.367678355,0.479256774,0.475544262],[0.36188077,0.558458164,0.350741692],[0.35499999,0.520441353,0.474452346],[-0.365999994,0.497151121,0.512630403],[-0.376249991,0.504683891,0.465963334],[0.367499992,0.497122383,0.509885848],[0.357,0.405670216,0.383211315],[0.357,0.417670216,0.389211315],[0.357,0.426670216,0.392211315],[-0.378,0.405670216,0.386211315],[-0.378,0.420670216,0.371211315],[-0.378,0.429670216,0.380211315],[-0.357,0.279670216,0.335211315],[-0.357,0.294670216,0.356211315],[0.3675,0.276670216,0.329211315],[0.3675,0.276670216,0.335211315],[-0.3675,0.354670216,0.365211315],[-0.357,0.387670216,0.380211315],[0.378,0.351670216,0.359211315],[-0.3675,0.357670216,0.305211315],[-0.357,0.372670216,0.311211315],[0.378,0.351670216,0.299211315],[-0.3675,0.291670216,0.314211315],[0.357,0.303670216,0.317211315],[-0.3675,0.354670216,0.362211315],[-0.357,0.357670216,0.326211315]]} \ No newline at end of file diff --git a/surfaces/blender/tests/live/ram_knee.py b/surfaces/blender/tests/live/ram_knee.py index 33dc608..a2a31f7 100644 --- a/surfaces/blender/tests/live/ram_knee.py +++ b/surfaces/blender/tests/live/ram_knee.py @@ -12,6 +12,8 @@ without them). is an absolute path; writes .result.json and .r3_ The oracle is ram.Signed, three rays by majority. Its ray count is held by tests/fixtures/ram_rays.json: the rocker plates as Imagination's jointlib builds them and points between the plates that stand on the first ray short of an edge or a vertex. One ray reads them inside a plate they stand clear of; the oracle as it is made reads none inside. +Its rays are held by the fixture's points inside the plates, where the plates' two bars overlap: the oracle as it is +made reads each inside, and two rays, one, a repeated ray or rays along x and y read some outside. A clearance verdict is a sign, the gate's own. FLAT follows lodur:ruling:deterministic-bound-margin. The checks run inside one try: an uncaught error is a failed check that names its section, and the result file is always written. @@ -331,6 +333,23 @@ try: check("ray-count: between the jointlib rocker plates, points on the first ray short of an edge or a vertex read outside by the oracle as it is made, inside by one ray", (np.abs(aimed[:, 0]) < 0.349).all() and (made > 0).all() and (single < 0).sum() >= 5, [int((made < 0).sum()), int((single < 0).sum())]) + # the other way, which the gate's proof between samples leans on: points inside the same plates. The oracle as it is + # made reads every one inside; each change of its rays reads some outside. Counts of points: shipped 0 (half a + # point, lodur:ruling:deterministic-bound-zero-reading), the least mutant 6 (the second and third rays along x + # and y), geometric mean 1.7: the check asks 2 + within = np.array(fixture["inside"]) + + def outside(count=3, rays=None): + oracle = Signed(plates, rays=count) + if rays is not None: + oracle.rays = [Vector(ray).normalized() for ray in rays] + return int((oracle("plates", within) >= 0).sum()) + read = {"as made": outside(), "two rays": outside(2), "one ray": outside(1), "the second ray the first": outside(rays=(R.RAYS[0], R.RAYS[0], R.RAYS[2])), + "the second and third along x and y": outside(rays=(R.RAYS[0], (1, 0, 0), (0, 1, 0)))} + RES["readings"]["jointlib plates: inside points read outside, of %d" % len(within)] = read + check("rays-inside: points inside the jointlib rocker plates all read inside by the oracle as it is made, and some read outside with two rays, with one, with the second ray the first, " + "and with the second and third along x and y", read["as made"] == 0 and min(count for name, count in read.items() if name != "as made") >= 2, read) + SECTION[0] = "seat" seat = np.concatenate([v for v, _ in shells["parent.seat"]]) deepest = float(Signed(shells)("parent.body", seat).min()) -- 2.47.3 From 3c1344d7762e4d6adfa8557a6c3d4b342bf2d177 Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Wed, 2 Dec 2026 22:41:43 +0100 Subject: [PATCH 04/11] brokkr_kitbash.ram: the record is version 2 and holds no settle block The reserved block (stiffness, damping, travel; written null, solved by nothing) leaves the ram record: a load-path cylinder's settle is a slide joint's, in the joint records (cut kit-joint-records). VERSION is 2; a version-1 record is refused as another version's, and the key is refused like any the record does not know. Co-Authored-By: Claude Fable 5.2 --- surfaces/blender/brokkr_kitbash/ram.py | 20 ++++++++------------ surfaces/blender/tests/test_ram.py | 16 ++++++++-------- 2 files changed, 16 insertions(+), 20 deletions(-) diff --git a/surfaces/blender/brokkr_kitbash/ram.py b/surfaces/blender/brokkr_kitbash/ram.py index 1383b5e..48875af 100644 --- a/surfaces/blender/brokkr_kitbash/ram.py +++ b/surfaces/blender/brokkr_kitbash/ram.py @@ -75,9 +75,8 @@ JOINS = {kind: {"a": ("parent",), "b": ("child",)} if kind == "direct" else {"a": ("parent",), "rocker": ("parent", "rocker"), "p": ("rocker", "coupler"), "c": ("coupler", "child"), "d": ("rocker",)} for kind in KINDS} # pin -> the bodies it joins: only their parts are zoned about it GATES = ("assembly", "stroke", "toggle", "arm", "load", "clash") -SCHEMA, VERSION = "brokkr.ram", 1 +SCHEMA, VERSION = "brokkr.ram", 2 ZONE = ("part", "pin", "radius", "depth") # a zone of `touch`, as the record writes it -COMPLIANCE = ("stiffness", "damping", "travel") # reserved: a load-path ram's settle, solved by a later version BAND = 1e-9 # the loop is refused within this of a dead centre of the rocker and coupler FINE = 64 # in a zone a segment between samples is halved down to spacing / FINE RAYS = ((0.5377, 0.6211, 0.5701), (-0.7071, 0.2903, 0.6447), (0.1873, -0.8011, -0.5684)) # Signed's, in order @@ -670,21 +669,20 @@ def search(kind, hinge, ram, seats, world=None, limit=20000, steps=25, spacing=N def record(m, ram): """The mechanism record: plain JSON types, everything a rig or runtime needs to drive the ram from the hinge angle (from_record, then length or extension). It holds what is authored and nothing derived from it: barrel, - closed length and link lengths come from the pins and the ram. `compliance` is reserved for a load-path ram's - settle (COMPLIANCE: stiffness, damping, travel); version 1 writes it null and solves none.""" + closed length and link lengths come from the pins and the ram.""" return {"schema": SCHEMA, "version": VERSION, "kind": m.kind, "hinge": {"pivot": m.pivot.tolist(), "axis": m.axis.tolist(), "lo": m.lo, "hi": m.hi}, "pins": {name: getattr(m, name).tolist() for name in PINS[m.kind]}, "offsets": list(m.offsets), "ram": {f.name: getattr(ram, f.name) for f in fields(Ram)}, - "parts": dict(m.parts), "compliance": None, + "parts": dict(m.parts), "touch": {member: [dict(zip(ZONE, zone)) for zone in zones] for member, zones in m.touch.items()}} def from_record(data): - """(Mechanism, Ram) of a record. A record of another schema or version (the integer 1: not 1.0, not true), with - a key this version does not know or without one it does, with a compliance block, or with a value that is not - its field's type (a finite number, three of them, a name), or with a zone wider or deeper than its member is - refused whole, as a RamError naming the field: nothing is read past and dropped.""" + """(Mechanism, Ram) of a record. A record of another schema or version (the integer 2: not 2.0, not true), with + a key this version does not know or without one it does, or with a value that is not its field's type (a finite + number, three of them, a name), or with a zone of a body its pin does not join, or wider or deeper than its + member, is refused whole, as a RamError naming the field: nothing is read past and dropped.""" if not isinstance(data, dict): raise RamError("None", "record", f"a record is an object, got {type(data).__name__}") kind, version = str(data.get("kind")), data.get("version") @@ -704,13 +702,11 @@ def from_record(data): raise RamError(kind, "record", f"three finite numbers, got {value!r}", pin=name) return [_number(kind, name, x) for x in value] - keys("record", data, ("schema", "version", "kind", "hinge", "pins", "offsets", "ram", "parts", "touch", "compliance")) + keys("record", data, ("schema", "version", "kind", "hinge", "pins", "offsets", "ram", "parts", "touch")) hinge, pins, ram = data["hinge"], data["pins"], data["ram"] keys("hinge", hinge, ("pivot", "axis", "lo", "hi")) keys("pins", pins, PINS[kind]) keys("ram", ram, [f.name for f in fields(Ram)]) - if data["compliance"] is not None: - raise RamError(kind, "record", f"a compliance block ({', '.join(COMPLIANCE)}) is a later version's: version {VERSION} solves none and will not drop it") for name, value in ram.items(): _number(kind, name, value, 0.0 if name == "bore" else None) if not isinstance(data["offsets"], list): diff --git a/surfaces/blender/tests/test_ram.py b/surfaces/blender/tests/test_ram.py index 1d43a83..3c5af6a 100644 --- a/surfaces/blender/tests/test_ram.py +++ b/surfaces/blender/tests/test_ram.py @@ -1119,8 +1119,8 @@ class RecordDrives(unittest.TestCase): data = R.record(m, ram) wire = json.loads(json.dumps(data)) self.assertEqual(wire, data) - self.assertEqual(sorted(data), ["compliance", "hinge", "kind", "offsets", "parts", "pins", "ram", "schema", "touch", "version"]) - self.assertEqual((data["schema"], data["version"], data["compliance"]), ("brokkr.ram", 1, None)) + self.assertEqual(sorted(data), ["hinge", "kind", "offsets", "parts", "pins", "ram", "schema", "touch", "version"]) + self.assertEqual((data["schema"], data["version"]), ("brokkr.ram", 2)) again, ram2 = R.from_record(wire) self.assertEqual(R.record(again, ram2), data) self.assertEqual((again.parts, again.touch), (m.parts, m.touch)) @@ -1151,18 +1151,18 @@ class RecordDrives(unittest.TestCase): def test_a_record_this_version_cannot_read_is_refused_whole(self): data = R.record(R.Mechanism("direct", O, X, -62, 0, a=(0.05, -0.3, 0.8), b=(0.05, -0.3, -0.6)), R.Ram(BORE)) settle = {"stiffness": 2.0e6, "damping": 4.0e3, "travel": 0.02} - self.assertEqual(tuple(settle), R.COMPLIANCE) ram = dict(data["ram"], stiffness=2.0e6) short = {k: v for k, v in data.items() if k != "touch"} - for change, said in (({"version": 2}, "version 2"), ({"version": 2, "compliance": settle}, "version 2"), ({"compliance": settle}, "compliance block"), + for change, said in (({"version": 1}, "reads brokkr.ram version 2; the record is brokkr.ram version 1"), ({"version": 3}, "version 3"), ({"version": 1, "settle": settle}, "version 1"), ({"schema": "brokkr.kit"}, "brokkr.kit"), ({"settle": settle}, "unknown ['settle']"), ({"ram": ram}, "unknown ['stiffness']"), ({"hinge": dict(data["hinge"], rate=1.0)}, "unknown ['rate']"), - # a block that is falsy is a block (S23); the version is the integer 1 - ({"compliance": {}}, "compliance block"), ({"compliance": 0}, "compliance block"), ({"compliance": False}, "compliance block"), - ({"version": 1.0}, "version 1.0"), ({"version": True}, "version True"), ({"version": "1"}, "version '1'"), + # a key the record does not know is refused whatever it holds, null and falsy included (S23): a ram + # record carries no settle. The version is the integer 2 + ({"settle": None}, "unknown ['settle']"), ({"settle": {}}, "unknown ['settle']"), ({"settle": False}, "unknown ['settle']"), + ({"version": 2.0}, "version 2.0"), ({"version": True}, "version True"), ({"version": "2"}, "version '2'"), ({"kind": "scissor"}, "kind is one of"), # a pin this kind has not, or a key that is no pin, is refused by name; so is one missing - ({"pins": dict(data["pins"], q=[0.0, 0.0, 0.0])}, "the pins's keys are not version 1's: unknown ['q']"), + ({"pins": dict(data["pins"], q=[0.0, 0.0, 0.0])}, "the pins's keys are not version 2's: unknown ['q']"), ({"pins": dict(data["pins"], parts={})}, "unknown ['parts']"), ({"pins": {"a": data["pins"]["a"]}}, "missing ['b']"), ({"pins": [1, 2]}, "(pin pins): an object, got list"), ({"ram": None}, "(pin ram): an object, got NoneType"), # every number is a finite number, the bore over 0; three of them make a point -- 2.47.3 From fd1f4ed2c2e796d3a3036a1f5f47127dd175c3a6 Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Wed, 2 Dec 2026 22:42:25 +0100 Subject: [PATCH 05/11] docs/kitbash.md: Rams and linkages: a zone's part is of a body its pin joins; the record is version 2; the rays held from inside Clearance states the body rule and what it gives up (among the joined bodies' parts a whole-member zone still lets the axis in; a third body's plate is never zoned; a four-bar's eye is let near no coupler part). The record is version 2 and holds nothing of a cylinder's settle. Readings: the 29 inside points and the mutants' counts, and that overlapping closed pieces given as one shell are mis-signed (1,906 of 38,448) where piece by piece none are. Co-Authored-By: Claude Fable 5.2 --- surfaces/blender/docs/kitbash.md | 42 ++++++++++++++++++++++---------- 1 file changed, 29 insertions(+), 13 deletions(-) diff --git a/surfaces/blender/docs/kitbash.md b/surfaces/blender/docs/kitbash.md index f82d7c3..6c720db 100644 --- a/surfaces/blender/docs/kitbash.md +++ b/surfaces/blender/docs/kitbash.md @@ -944,7 +944,10 @@ body whose rest frame it turns with), and `touch`: for each member (`barrel`, `r bell crank's `rocker arm`), zones `(part, pin, radius, depth)`. Every member meets every part. A zone changes what the member's samples keep from one part, and only within `radius` of the axis of `pin`, measured across the hinge axis; the pin is one the member rides (the ram `a` and its eye, the rocker its pivot and `p`, the coupler `p` and -`c`, the arm the pivot and `d`). Inside the zone a sample may come as near the part as `-depth`; beyond it the +`c`, the arm the pivot and `d`), and the part is one of a body that pin joins: `a` the parent; the rocker's pivot +the parent and the rocker; `p` the rocker and the coupler; `c` the coupler and the child; a direct ram's `b` the +child; `d` the rocker (`JOINS`). A zone naming a part of any other body is refused by the record, whatever its +radius and depth. Inside the zone a sample may come as near the part as `-depth`; beyond it the pair is checked like any other. Nothing is exempt by a name, by a length cut from a member's end, or by the member's own body: the barrel runs from its back end, the rod to the eye, a bar from pin to pin. Every body of the kind owns at least one part, or the gate refuses the record. @@ -964,7 +967,9 @@ to pin: a bar's length between its pins, and for the barrel and the rod the base the centre the eye turns about, added. A `Mechanism` refuses a zone past that from its pins alone. Its depth is also no more than the member's eye on that pin (`Ram.eye`: `e_a` at the base, `e_b` at the rod's eye, `link_r` on a bar), which `from_record` and the gate refuse, so a world's answer is held to it as well. The record holds no -plate widths, so the radius has no tighter bound than the length. +plate widths, so the radius has no tighter bound than the length, and two zones of half a member's length about +its two pins cover it whole. What the record does hold is which body a part turns with: a member is let near only +what is pinned where it is pinned. Between two samples of which either is in a zone the gate does not rely on the spacing. A distance changes by no more than the way between two points, so along a segment it is at least (g(a) + g(b) - length) / 2. Where that @@ -975,7 +980,12 @@ samples' readings stand, so a burial is read to spacing / 128. This asks of the than the true distance. What it gives up: inside a zone the gate holds only the member's axis `depth` from the part, not its surface a -gap from it, so a link may graze the plate it scissors with anywhere within the stated radius. The members are +gap from it, so a link may graze the plate it scissors with anywhere within the stated radius. Among the parts of +the bodies a pin joins the gate still cannot tell a member's own plate from another: a zone over the whole member +lets its axis `depth` into any of them. A part of a third body is never zoned, so a plate stacked on a pin from a +body the pin does not join is refused where it stands; it is stated as a part of a body the pin joins. A four-bar's +eye rides `d`, which joins the rocker alone, though it stands on `p`: the ram is let near the coupler's plates +there by no zone. The members are round bars; a plate's flat sides are not modelled, which is why stacked plates need a zone at all. The proof between samples costs oracle calls: a depth stated with no slack over the burial (a bar's own plates at `link_r`) is halved to the floor along the whole zone. And it is along the axis at each checked angle; between two angles @@ -996,20 +1006,20 @@ about R, and `d` about R for a bell crank, the eye standing at `a`'s place along least arm; a miss returns the tally by gate and the nearest miss. Clearance takes `world(m) -> (parts, touch, distance)`: a linkage's brackets and links are the candidate's own, so each candidate that reaches the gate is met with the parts its own pins place. What `world` returns is read as a record's: anything but the three, a part on -no body of the kind, a zone that is not a part, a pin the member rides, a radius and a depth, or a zone wider or -deeper than its member is refused. +no body of the kind, a zone that is not a part, a pin the member rides, a radius and a depth, a zone of a body +its pin does not join, or a zone wider or deeper than its member is refused. `swept` gives the ram's swept surface in any body's frame, for a recess. ### The record -`record` and `from_record` carry a mechanism as JSON: `schema` (`brokkr.ram`), `version` (1), `kind`, `hinge`, -`pins`, `offsets`, `ram`, `parts`, `touch` (member -> zones, each `{part, pin, radius, depth}`), and `compliance`. -It holds what is authored; barrel, closed length and link lengths are derived by the reader. `compliance` is -reserved for a load-path ram's settle (stiffness, damping, travel); version 1 writes it null and solves none. A -record of another schema or version (the integer 1: 1.0 and true are not it), with a key version 1 does not know or -without one it does (at the top, in `ram`, `hinge`, `pins` or a zone), with a compliance block, or with a value -that is not its field's (a finite number, the bore over 0, three numbers for a point), or with a zone wider or -deeper than its member is refused whole, as a +`record` and `from_record` carry a mechanism as JSON: `schema` (`brokkr.ram`), `version` (2), `kind`, `hinge`, +`pins`, `offsets`, `ram`, `parts` and `touch` (member -> zones, each `{part, pin, radius, depth}`). +It holds what is authored; barrel, closed length and link lengths are derived by the reader. It holds nothing of +how a load-path cylinder settles: that is a slide joint's, in the joint's own record. A +record of another schema or version (the integer 2: 2.0 and true are not it), with a key version 2 does not know or +without one it does (at the top, in `ram`, `hinge`, `pins` or a zone), or with a value +that is not its field's (a finite number, the bore over 0, three numbers for a point), or with a zone of a body +its pin does not join, or wider or deeper than its member, is refused whole, as a `RamError` that names the field: a reader never reads past what it cannot solve. A `Ram` built by hand refuses the same numbers. @@ -1025,6 +1035,12 @@ for the side. One ray that runs through an edge or a vertex miscounts and signs clear of. `tests/fixtures/ram_rays.json` holds the ray count: the rocker plates as the joint library builds them and 24 points between the plates, each on the first ray short of an edge or a vertex. One ray signs all 24 inside; three sign none. Three rays are not a proof: of 146 such points one ray missigned, two rays missigned 16. +The same file holds 29 points inside the plates, where the gate's proof between samples needs the sign: the oracle +as it is made reads each inside; two rays read 16 outside, one ray 10, the second ray set to the first 10, the +second and third along x and y 6. Most stand where a side's two bars overlap, and the fixture gives the four bars +as one shell: there the parity of a ray counts two skins, and three rays read 1,906 of 38,448 inside grid points +outside. With each bar its own shell, as `Signed` takes a part's shells and as the live knee builds them, they +read none outside: a part whose closed pieces overlap is given piece by piece. | drive | reading | | --- | --- | -- 2.47.3 From d94dace75f511958636e7a87a505248eca2f6fcc Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Wed, 2 Dec 2026 22:57:47 +0100 Subject: [PATCH 06/11] live ram_knee: the inside check reads the oracle as it is made, by Signed's own ray count The check passed rays=3 itself, so Signed's default at two rays kept it green (the mutant survived its first run). It now builds the oracle with no count. Co-Authored-By: Claude Fable 5.2 --- surfaces/blender/tests/live/ram_knee.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/surfaces/blender/tests/live/ram_knee.py b/surfaces/blender/tests/live/ram_knee.py index a2a31f7..28f182f 100644 --- a/surfaces/blender/tests/live/ram_knee.py +++ b/surfaces/blender/tests/live/ram_knee.py @@ -339,8 +339,8 @@ try: # and y), geometric mean 1.7: the check asks 2 within = np.array(fixture["inside"]) - def outside(count=3, rays=None): - oracle = Signed(plates, rays=count) + def outside(count=None, rays=None): + oracle = Signed(plates) if count is None else Signed(plates, rays=count) # as made: the count is Signed's own if rays is not None: oracle.rays = [Vector(ray).normalized() for ray in rays] return int((oracle("plates", within) >= 0).sum()) -- 2.47.3 From 7282c02d4467561f87daede625f871f4bd16d76a Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Wed, 2 Dec 2026 23:05:56 +0100 Subject: [PATCH 07/11] brokkr_kitbash.ram: Signed reads a mesh piece by piece: inside the part is inside any piece Self's ruling on the fork cut-kit-ram-lows.h1 reported: callers feed joined meshes such as jointlib's, whose closed pieces overlap. Parity over the whole mesh reads the overlap as outside, the direction the proof between samples cannot bear. _pieces splits a mesh into the pieces its faces join; each gets its own tree and bounding box. Unit test of the split. Co-Authored-By: Claude Fable 5.2 --- surfaces/blender/brokkr_kitbash/ram.py | 35 ++++++++++++++++++++++---- surfaces/blender/tests/test_ram.py | 13 ++++++++++ 2 files changed, 43 insertions(+), 5 deletions(-) diff --git a/surfaces/blender/brokkr_kitbash/ram.py b/surfaces/blender/brokkr_kitbash/ram.py index 48875af..7799526 100644 --- a/surfaces/blender/brokkr_kitbash/ram.py +++ b/surfaces/blender/brokkr_kitbash/ram.py @@ -24,7 +24,7 @@ the coupler bar at c's, the ram at a's plus each of `offsets`. search(kind, hinge, ram, seats, ...) the best of a seat grid, or the tally and the nearest miss record(m, ram), from_record the JSON record a rig or runtime drives from swept(fit, body, ...) points of the swept ram's surface in a body's rest frame - Signed(shells, cap) the distance oracle over closed meshes, signed by three rays + Signed(shells, cap) the distance oracle over closed meshes, piece by piece, signed by three rays Clearance. The record names the mechanism's `parts`, each a piece of one body (part -> the body whose rest frame it turns with: a thigh's core, the bracket that carries the rocker's pivot, a link's plates, a pin), and `touch`: @@ -749,11 +749,36 @@ def swept(f, body, margin=0.0, steps=13, around=8): return _into(m, p, body, np.concatenate(pts, axis=1)).reshape(-1, 3) +def _pieces(vertices, faces): + """A mesh's pieces, [(vertices, faces)]: each the faces joined to one another through shared vertices.""" + vertices, root = np.asarray(vertices, dtype=float), list(range(len(vertices))) + + def find(i): + while root[i] != i: + root[i] = root[root[i]] + i = root[i] + return i + for face in faces: + for i in face[1:]: + root[find(i)] = find(face[0]) + groups = {} + for face in faces: + groups.setdefault(find(face[0]), []).append(face) + out = [] + for group in groups.values(): + used = sorted({i for face in group for i in face}) + at = {i: k for k, i in enumerate(used)} + out.append((vertices[used], [tuple(at[i] for i in face) for face in group])) + return out + + class Signed: """The distance oracle over closed meshes: distance(part, points) is the nearest face's distance, negative where the point is inside one of the part's shells (its depth below the nearest face), capped at `cap` outside - only. shells: part -> [(vertices (N, 3), faces)], each shell closed, in the rest frame of the part's body. - Inside is the crossing parity of `rays` of RAYS, by majority: one ray that runs through an edge or a vertex + only. shells: part -> [(vertices (N, 3), faces)], in the rest frame of the part's body. A mesh is read piece by + piece (_pieces), each piece closed: a point is inside the part where it is inside any piece, so pieces joined + into one mesh may overlap (parity over the whole mesh would read where two overlap as outside). Inside a + piece is the crossing parity of `rays` of RAYS, by majority: one ray that runs through an edge or a vertex miscounts, and a sample then reads inside a plate it stands clear of. An unknown part raises. Needs Blender's mathutils (BVHTree).""" @@ -762,8 +787,8 @@ class Signed: from mathutils.bvhtree import BVHTree self.cap, self.asked, self.vector = cap, 0, Vector self.rays = [Vector(ray).normalized() for ray in RAYS[:rays]] - self.trees = {part: [(BVHTree.FromPolygons(np.asarray(v, dtype=float).tolist(), [tuple(face) for face in f], epsilon=0.0), - np.min(v, axis=0), np.max(v, axis=0)) for v, f in made] for part, made in shells.items()} + self.trees = {part: [(BVHTree.FromPolygons(v.tolist(), [tuple(face) for face in f], epsilon=0.0), np.min(v, axis=0), np.max(v, axis=0)) + for mesh in made for v, f in _pieces(*mesh)] for part, made in shells.items()} @staticmethod def crossings(tree, v, ray): diff --git a/surfaces/blender/tests/test_ram.py b/surfaces/blender/tests/test_ram.py index 3c5af6a..2a94872 100644 --- a/surfaces/blender/tests/test_ram.py +++ b/surfaces/blender/tests/test_ram.py @@ -1268,6 +1268,19 @@ class Refusals(unittest.TestCase): self.assertEqual((caught.exception.gate, caught.exception.pin), ("arm", "b")) self.assertIn(f"arm at {caught.exception.angle:g} deg (pin b)", str(caught.exception)) + def test_a_mesh_is_read_piece_by_piece(self): + # Signed's split: two tetrahedra in one mesh, the second's vertices listed first and its faces interleaved, + # come back as two closed pieces with their own vertices; a mesh of one piece comes back whole + tet = [(0, 1, 2), (0, 1, 3), (0, 2, 3), (1, 2, 3)] + a, b = np.array([(0, 0, 0), (1, 0, 0), (0, 1, 0), (0, 0, 1)], float), np.array([(0.2, 0.2, 0.2), (5, 0, 0), (0, 5, 0), (0, 0, 5)], float) + faces = [face for pair in zip([tuple(i + 4 for i in f) for f in tet], tet) for face in pair] + pieces = R._pieces(np.concatenate([b, a]), faces) + self.assertEqual(len(pieces), 2) + for (verts, got), want in zip(pieces, (a, b)): + self.assertEqual((verts.tolist(), sorted(got)), (want.tolist(), tet)) + whole = R._pieces(a, tet) + self.assertEqual((len(whole), whole[0][0].tolist(), whole[0][1]), (1, a.tolist(), tet)) + def test_no_blender(self): source = (SURFACE / "brokkr_kitbash" / "ram.py").read_text(encoding="utf-8") for word in ("bpy", "np.gradient"): -- 2.47.3 From c4ac06c2dd0025532b29a21aae126ca380e4e5ae Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Wed, 2 Dec 2026 23:05:57 +0100 Subject: [PATCH 08/11] live ram_knee: no point inside the jointlib plates reads outside (0 of 38,477); the ray count held beside the bars inside-reads-inside replaces rays-inside: a 0.003 grid inside the four bars (truth by each bar's face planes) and the fixture's 29 points, all read inside. Parity over the whole mesh read 1,906 outside. Read bar by bar, the 24 points between the plates fall outside every bar's box and one ray no longer miscounts them; ram_rays.json's `points` are now 14 beside the bars that one ray reads inside and three read outside. Two rays, or a second and third along x and y, read them as three do. ram_knee.result.json regenerated: 21 checks. docs: the piece-by-piece read. Co-Authored-By: Claude Fable 5.2 --- surfaces/blender/docs/kitbash.md | 14 ++--- surfaces/blender/tests/fixtures/ram_rays.json | 2 +- surfaces/blender/tests/live/ram_knee.py | 54 +++++++++++-------- .../blender/tests/live/ram_knee.result.json | 21 +++++--- 4 files changed, 53 insertions(+), 38 deletions(-) diff --git a/surfaces/blender/docs/kitbash.md b/surfaces/blender/docs/kitbash.md index 6c720db..5bb0ad6 100644 --- a/surfaces/blender/docs/kitbash.md +++ b/surfaces/blender/docs/kitbash.md @@ -1033,14 +1033,14 @@ collars at the eye and a base clevis whose foot runs 0.01 into the thigh; 12 par oracle, `ram.Signed(shells, cap)`: the nearest face for the depth, the crossing parity of three rays, by majority, for the side. One ray that runs through an edge or a vertex miscounts and signs a sample inside a plate it stands clear of. `tests/fixtures/ram_rays.json` holds the ray count: the rocker plates as the joint library builds them -and 24 points between the plates, each on the first ray short of an edge or a vertex. One ray signs all 24 +and 14 points beside their bars, each on the first ray short of an edge or a vertex. One ray signs all 14 inside; three sign none. Three rays are not a proof: of 146 such points one ray missigned, two rays missigned 16. -The same file holds 29 points inside the plates, where the gate's proof between samples needs the sign: the oracle -as it is made reads each inside; two rays read 16 outside, one ray 10, the second ray set to the first 10, the -second and third along x and y 6. Most stand where a side's two bars overlap, and the fixture gives the four bars -as one shell: there the parity of a ray counts two skins, and three rays read 1,906 of 38,448 inside grid points -outside. With each bar its own shell, as `Signed` takes a part's shells and as the live knee builds them, they -read none outside: a part whose closed pieces overlap is given piece by piece. +Two rays, or a second and third along x and y, read those 14 as three do: the fixture holds the count above one. +A mesh is read piece by piece: `Signed` splits it into the pieces its faces join, each closed, and a point is +inside the part where it is inside any piece. The joint library's plates are one mesh of four bars, a side's two +overlapping about the pivot; parity over the whole mesh reads the overlap as outside (1,906 of 38,448 grid +points inside the bars, the direction the proof between samples cannot bear), and piece by piece none of them +reads outside, which the live check holds. | drive | reading | | --- | --- | diff --git a/surfaces/blender/tests/fixtures/ram_rays.json b/surfaces/blender/tests/fixtures/ram_rays.json index 37c414c..ab8fd15 100644 --- a/surfaces/blender/tests/fixtures/ram_rays.json +++ b/surfaces/blender/tests/fixtures/ram_rays.json @@ -1 +1 @@ -{"about":"The rocker's twin plates of the R-3 bell crank as Imagination's jointlib builds them (one shell, triangulated, at rest), and points between the plates (|x| under 0.349, the plates begin at 0.35): each stands on the oracle's first ray 0.004 to 0.02 short of a vertex or an edge of the shell. Every point is outside. `inside`: points 0.001 or more inside one of the shell's four pieces (each a convex prism; a side's two bars overlap about the pivot and share their faces' planes): nine aimed along a ray of RAYS, x or y at a vertex or an edge, the rest from a grid where the bars overlap. Fed as one shell, as here, the overlap is where a ray's parity fails: the oracle as it is made reads every one of these inside; two rays, one ray, a second ray equal to the first, or the second and third along x and y each read some outside. They hold the rays. They do not show that the oracle signs this shell truly: of 38,448 grid points inside it, three rays read 1,906 outside with the pieces one shell and none with each piece its own shell.","verts":[[-0.349999994,0.740011215,0.389170021],[-0.349999994,0.752862871,0.394919485],[-0.349999994,0.763308823,0.404358923],[-0.349999994,0.770326555,0.416564375],[-0.349999994,0.773229182,0.430341005],[-0.349999994,0.77173245,0.444340348],[-0.349999994,0.765982985,0.457191974],[-0.349999994,0.756543517,0.467637926],[-0.349999994,0.744338095,0.474655658],[-0.349999994,0.730561495,0.477558255],[-0.349999994,0.716562152,0.476061553],[-0.349999994,0.305388123,0.365099549],[-0.349999994,0.292536497,0.359350085],[-0.349999994,0.282090545,0.349910617],[-0.349999994,0.275072783,0.337705195],[-0.349999994,0.272170216,0.323928565],[-0.349999994,0.273666918,0.309929222],[-0.349999994,0.279416382,0.297077596],[-0.349999994,0.288855821,0.286631644],[-0.349999994,0.301061243,0.279613912],[-0.349999994,0.314837903,0.276711315],[-0.349999994,0.328837216,0.278208017],[-0.38499999,0.740011215,0.389170021],[-0.38499999,0.752862871,0.394919485],[-0.38499999,0.763308823,0.404358923],[-0.38499999,0.770326555,0.416564375],[-0.38499999,0.773229182,0.430341005],[-0.38499999,0.77173245,0.444340348],[-0.38499999,0.765982985,0.457191974],[-0.38499999,0.756543517,0.467637926],[-0.38499999,0.744338095,0.474655658],[-0.38499999,0.730561495,0.477558255],[-0.38499999,0.716562152,0.476061553],[-0.38499999,0.305388123,0.365099549],[-0.38499999,0.292536497,0.359350085],[-0.38499999,0.282090545,0.349910617],[-0.38499999,0.275072783,0.337705195],[-0.38499999,0.272170216,0.323928565],[-0.38499999,0.273666918,0.309929222],[-0.38499999,0.279416382,0.297077596],[-0.38499999,0.288855821,0.286631644],[-0.38499999,0.301061243,0.279613912],[-0.38499999,0.314837903,0.276711315],[-0.38499999,0.328837216,0.278208017],[-0.349999994,0.514849424,0.463428885],[-0.349999994,0.522187293,0.473566681],[-0.349999994,0.526033282,0.485475808],[-0.349999994,0.526010931,0.497990549],[-0.349999994,0.522122383,0.509885848],[-0.349999994,0.514748275,0.519997358],[-0.349999994,0.504610479,0.527335227],[-0.349999994,0.492701381,0.531181216],[-0.349999994,0.480186641,0.531158805],[-0.349999994,0.468291312,0.527270257],[-0.349999994,0.458179832,0.519896209],[-0.349999994,0.288777888,0.349887431],[-0.349999994,0.28144002,0.339749664],[-0.349999994,0.27759403,0.327840507],[-0.349999994,0.277616382,0.315325767],[-0.349999994,0.281504929,0.303430468],[-0.349999994,0.288879007,0.293318987],[-0.349999994,0.299016804,0.285981119],[-0.349999994,0.310925931,0.282135129],[-0.349999994,0.323440671,0.282157511],[-0.349999994,0.335336,0.286046058],[-0.349999994,0.345447481,0.293420136],[-0.38499999,0.514849424,0.463428885],[-0.38499999,0.522187293,0.473566681],[-0.38499999,0.526033282,0.485475808],[-0.38499999,0.526010931,0.497990549],[-0.38499999,0.522122383,0.509885848],[-0.38499999,0.514748275,0.519997358],[-0.38499999,0.504610479,0.527335227],[-0.38499999,0.492701381,0.531181216],[-0.38499999,0.480186641,0.531158805],[-0.38499999,0.468291312,0.527270257],[-0.38499999,0.458179832,0.519896209],[-0.38499999,0.288777888,0.349887431],[-0.38499999,0.28144002,0.339749664],[-0.38499999,0.27759403,0.327840507],[-0.38499999,0.277616382,0.315325767],[-0.38499999,0.281504929,0.303430468],[-0.38499999,0.288879007,0.293318987],[-0.38499999,0.299016804,0.285981119],[-0.38499999,0.310925931,0.282135129],[-0.38499999,0.323440671,0.282157511],[-0.38499999,0.335336,0.286046058],[-0.38499999,0.345447481,0.293420136],[0.349999994,0.740011215,0.389170021],[0.349999994,0.752862871,0.394919485],[0.349999994,0.763308823,0.404358923],[0.349999994,0.770326555,0.416564375],[0.349999994,0.773229182,0.430341005],[0.349999994,0.77173245,0.444340348],[0.349999994,0.765982985,0.457191974],[0.349999994,0.756543517,0.467637926],[0.349999994,0.744338095,0.474655658],[0.349999994,0.730561495,0.477558255],[0.349999994,0.716562152,0.476061553],[0.349999994,0.305388123,0.365099549],[0.349999994,0.292536497,0.359350085],[0.349999994,0.282090545,0.349910617],[0.349999994,0.275072783,0.337705195],[0.349999994,0.272170216,0.323928565],[0.349999994,0.273666918,0.309929222],[0.349999994,0.279416382,0.297077596],[0.349999994,0.288855821,0.286631644],[0.349999994,0.301061243,0.279613912],[0.349999994,0.314837903,0.276711315],[0.349999994,0.328837216,0.278208017],[0.38499999,0.740011215,0.389170021],[0.38499999,0.752862871,0.394919485],[0.38499999,0.763308823,0.404358923],[0.38499999,0.770326555,0.416564375],[0.38499999,0.773229182,0.430341005],[0.38499999,0.77173245,0.444340348],[0.38499999,0.765982985,0.457191974],[0.38499999,0.756543517,0.467637926],[0.38499999,0.744338095,0.474655658],[0.38499999,0.730561495,0.477558255],[0.38499999,0.716562152,0.476061553],[0.38499999,0.305388123,0.365099549],[0.38499999,0.292536497,0.359350085],[0.38499999,0.282090545,0.349910617],[0.38499999,0.275072783,0.337705195],[0.38499999,0.272170216,0.323928565],[0.38499999,0.273666918,0.309929222],[0.38499999,0.279416382,0.297077596],[0.38499999,0.288855821,0.286631644],[0.38499999,0.301061243,0.279613912],[0.38499999,0.314837903,0.276711315],[0.38499999,0.328837216,0.278208017],[0.349999994,0.514849424,0.463428885],[0.349999994,0.522187293,0.473566681],[0.349999994,0.526033282,0.485475808],[0.349999994,0.526010931,0.497990549],[0.349999994,0.522122383,0.509885848],[0.349999994,0.514748275,0.519997358],[0.349999994,0.504610479,0.527335227],[0.349999994,0.492701381,0.531181216],[0.349999994,0.480186641,0.531158805],[0.349999994,0.468291312,0.527270257],[0.349999994,0.458179832,0.519896209],[0.349999994,0.288777888,0.349887431],[0.349999994,0.28144002,0.339749664],[0.349999994,0.27759403,0.327840507],[0.349999994,0.277616382,0.315325767],[0.349999994,0.281504929,0.303430468],[0.349999994,0.288879007,0.293318987],[0.349999994,0.299016804,0.285981119],[0.349999994,0.310925931,0.282135129],[0.349999994,0.323440671,0.282157511],[0.349999994,0.335336,0.286046058],[0.349999994,0.345447481,0.293420136],[0.38499999,0.514849424,0.463428885],[0.38499999,0.522187293,0.473566681],[0.38499999,0.526033282,0.485475808],[0.38499999,0.526010931,0.497990549],[0.38499999,0.522122383,0.509885848],[0.38499999,0.514748275,0.519997358],[0.38499999,0.504610479,0.527335227],[0.38499999,0.492701381,0.531181216],[0.38499999,0.480186641,0.531158805],[0.38499999,0.468291312,0.527270257],[0.38499999,0.458179832,0.519896209],[0.38499999,0.288777888,0.349887431],[0.38499999,0.28144002,0.339749664],[0.38499999,0.27759403,0.327840507],[0.38499999,0.277616382,0.315325767],[0.38499999,0.281504929,0.303430468],[0.38499999,0.288879007,0.293318987],[0.38499999,0.299016804,0.285981119],[0.38499999,0.310925931,0.282135129],[0.38499999,0.323440671,0.282157511],[0.38499999,0.335336,0.286046058],[0.38499999,0.345447481,0.293420136]],"faces":[[19,21,11],[24,22,32],[22,1,0],[23,2,1],[24,3,2],[25,4,3],[26,5,4],[27,6,5],[28,7,6],[29,8,7],[30,9,8],[31,10,9],[32,11,10],[33,12,11],[34,13,12],[35,14,13],[36,15,14],[37,16,15],[38,17,16],[39,18,17],[40,19,18],[41,20,19],[42,21,20],[43,0,21],[63,65,55],[68,66,76],[66,45,44],[67,46,45],[68,47,46],[69,48,47],[70,49,48],[71,50,49],[72,51,50],[73,52,51],[74,53,52],[75,54,53],[76,55,54],[77,56,55],[78,57,56],[79,58,57],[80,59,58],[81,60,59],[82,61,60],[83,62,61],[84,63,62],[85,64,63],[86,65,64],[87,44,65],[95,93,91],[122,124,128],[89,110,88],[90,111,89],[91,112,90],[92,113,91],[93,114,92],[94,115,93],[95,116,94],[96,117,95],[97,118,96],[98,119,97],[99,120,98],[100,121,99],[101,122,100],[102,123,101],[103,124,102],[104,125,103],[105,126,104],[106,127,105],[107,128,106],[108,129,107],[109,130,108],[88,131,109],[141,139,135],[166,168,172],[133,154,132],[134,155,133],[135,156,134],[136,157,135],[137,158,136],[138,159,137],[139,160,138],[140,161,139],[141,162,140],[142,163,141],[143,164,142],[144,165,143],[145,166,144],[146,167,145],[147,168,146],[148,169,147],[149,170,148],[150,171,149],[151,172,150],[152,173,151],[153,174,152],[132,175,153],[21,0,10],[0,1,10],[1,2,3],[3,4,5],[5,6,7],[7,8,9],[9,10,3],[10,11,21],[3,10,1],[11,12,13],[13,14,15],[15,16,19],[16,17,19],[17,18,19],[19,20,21],[3,5,7],[7,9,3],[11,13,19],[13,15,19],[22,43,33],[43,42,33],[42,41,40],[40,39,38],[38,37,40],[37,36,40],[36,35,34],[34,33,40],[33,32,22],[40,33,42],[32,31,30],[30,29,28],[28,27,26],[26,25,28],[25,24,28],[24,23,22],[36,34,40],[32,30,24],[30,28,24],[22,23,1],[23,24,2],[24,25,3],[25,26,4],[26,27,5],[27,28,6],[28,29,7],[29,30,8],[30,31,9],[31,32,10],[32,33,11],[33,34,12],[34,35,13],[35,36,14],[36,37,15],[37,38,16],[38,39,17],[39,40,18],[40,41,19],[41,42,20],[42,43,21],[43,22,0],[65,44,54],[44,45,54],[45,46,47],[47,48,49],[49,50,47],[50,51,47],[51,52,53],[53,54,47],[54,55,65],[47,54,45],[55,56,57],[57,58,59],[59,60,61],[61,62,63],[63,64,65],[51,53,47],[55,57,63],[57,59,63],[59,61,63],[66,87,77],[87,86,77],[86,85,84],[84,83,80],[83,82,80],[82,81,80],[80,79,78],[78,77,84],[77,76,66],[84,77,86],[76,75,74],[74,73,72],[72,71,68],[71,70,68],[70,69,68],[68,67,66],[80,78,84],[76,74,68],[74,72,68],[66,67,45],[67,68,46],[68,69,47],[69,70,48],[70,71,49],[71,72,50],[72,73,51],[73,74,52],[74,75,53],[75,76,54],[76,77,55],[77,78,56],[78,79,57],[79,80,58],[80,81,59],[81,82,60],[82,83,61],[83,84,62],[84,85,63],[85,86,64],[86,87,65],[87,66,44],[89,88,98],[88,109,99],[109,108,107],[107,106,105],[105,104,107],[104,103,107],[103,102,101],[101,100,99],[99,98,88],[98,97,91],[97,96,95],[95,94,93],[93,92,91],[91,90,89],[109,107,99],[103,101,107],[101,99,107],[98,91,89],[97,95,91],[130,131,121],[131,110,120],[110,111,112],[112,113,116],[113,114,116],[114,115,116],[116,117,118],[118,119,120],[120,121,131],[121,122,128],[122,123,124],[124,125,128],[125,126,128],[126,127,128],[128,129,130],[110,112,120],[116,118,112],[118,120,112],[121,128,130],[89,111,110],[90,112,111],[91,113,112],[92,114,113],[93,115,114],[94,116,115],[95,117,116],[96,118,117],[97,119,118],[98,120,119],[99,121,120],[100,122,121],[101,123,122],[102,124,123],[103,125,124],[104,126,125],[105,127,126],[106,128,127],[107,129,128],[108,130,129],[109,131,130],[88,110,131],[133,132,142],[132,153,143],[153,152,151],[151,150,149],[149,148,147],[147,146,145],[145,144,143],[143,142,132],[142,141,135],[141,140,139],[139,138,135],[138,137,135],[137,136,135],[135,134,133],[153,151,143],[151,149,147],[147,145,151],[145,143,151],[142,135,133],[174,175,165],[175,154,164],[154,155,156],[156,157,158],[158,159,156],[159,160,156],[160,161,162],[162,163,164],[164,165,175],[165,166,172],[166,167,168],[168,169,170],[170,171,168],[171,172,168],[172,173,174],[154,156,164],[160,162,156],[162,164,156],[165,172,174],[133,155,154],[134,156,155],[135,157,156],[136,158,157],[137,159,158],[138,160,159],[139,161,160],[140,162,161],[141,163,162],[142,164,163],[143,165,164],[144,166,165],[145,167,166],[146,168,167],[147,169,168],[148,170,169],[149,171,170],[150,172,171],[151,173,172],[152,174,173],[153,175,174],[132,154,175]],"points":[[0.34569818,0.758339776,0.399797897],[0.34569818,0.765357508,0.412003349],[0.33924546,0.757903937,0.405161809],[0.34569818,0.768260135,0.425779979],[0.343547274,0.765775611,0.423499465],[0.33924546,0.760806564,0.418938439],[0.34569818,0.766763402,0.439779322],[0.343547274,0.764278879,0.437498808],[0.33924546,0.759309832,0.432937782],[0.34569818,0.761013938,0.452630947],[0.343547274,0.758529415,0.450350434],[0.33924546,0.753560368,0.445789407],[0.34569818,0.75157447,0.4630769],[0.343547274,0.749089947,0.460796386],[0.33924546,0.744120899,0.45623536],[0.347849087,0.741853572,0.472375145],[0.34569818,0.739369048,0.470094631],[0.343547274,0.736884525,0.467814118],[0.33924546,0.731915478,0.463253092],[0.347849087,0.728076971,0.475277742],[0.34569818,0.725592448,0.472997229],[0.343547274,0.723107924,0.470716715],[0.33924546,0.718138877,0.466155689],[0.347849087,0.714077628,0.473781039]],"inside":[[-0.374881795,0.506437858,0.465394675],[-0.366131796,0.753098523,0.427236497],[0.367678355,0.451073686,0.418925236],[0.367678355,0.479256774,0.475544262],[0.36188077,0.558458164,0.350741692],[0.35499999,0.520441353,0.474452346],[-0.365999994,0.497151121,0.512630403],[-0.376249991,0.504683891,0.465963334],[0.367499992,0.497122383,0.509885848],[0.357,0.405670216,0.383211315],[0.357,0.417670216,0.389211315],[0.357,0.426670216,0.392211315],[-0.378,0.405670216,0.386211315],[-0.378,0.420670216,0.371211315],[-0.378,0.429670216,0.380211315],[-0.357,0.279670216,0.335211315],[-0.357,0.294670216,0.356211315],[0.3675,0.276670216,0.329211315],[0.3675,0.276670216,0.335211315],[-0.3675,0.354670216,0.365211315],[-0.357,0.387670216,0.380211315],[0.378,0.351670216,0.359211315],[-0.3675,0.357670216,0.305211315],[-0.357,0.372670216,0.311211315],[0.378,0.351670216,0.299211315],[-0.3675,0.291670216,0.314211315],[0.357,0.303670216,0.317211315],[-0.3675,0.354670216,0.362211315],[-0.357,0.357670216,0.326211315]]} \ No newline at end of file +{"about":"The rocker's twin plates of the R-3 bell crank as Imagination's jointlib builds them: one mesh, triangulated, at rest, of four closed bars, a side's two overlapping about the pivot and sharing their faces' planes. `points`: 14 points 0.002 or more outside every bar and inside a bar's bounding box, each on the oracle's first ray 0.004 to 0.02 short of a vertex or an edge. One ray reads each inside; three read none inside. `inside`: 29 points 0.001 or more inside a bar, nine aimed along a ray of RAYS, x or y at a vertex or an edge, the rest from a grid where the bars overlap. Parity over the whole mesh reads the overlap outside (1,906 of 38,448 grid points inside the bars); read bar by bar, as ram.Signed reads a mesh, none of them and none of these reads outside.","verts":[[-0.349999994,0.740011215,0.389170021],[-0.349999994,0.752862871,0.394919485],[-0.349999994,0.763308823,0.404358923],[-0.349999994,0.770326555,0.416564375],[-0.349999994,0.773229182,0.430341005],[-0.349999994,0.77173245,0.444340348],[-0.349999994,0.765982985,0.457191974],[-0.349999994,0.756543517,0.467637926],[-0.349999994,0.744338095,0.474655658],[-0.349999994,0.730561495,0.477558255],[-0.349999994,0.716562152,0.476061553],[-0.349999994,0.305388123,0.365099549],[-0.349999994,0.292536497,0.359350085],[-0.349999994,0.282090545,0.349910617],[-0.349999994,0.275072783,0.337705195],[-0.349999994,0.272170216,0.323928565],[-0.349999994,0.273666918,0.309929222],[-0.349999994,0.279416382,0.297077596],[-0.349999994,0.288855821,0.286631644],[-0.349999994,0.301061243,0.279613912],[-0.349999994,0.314837903,0.276711315],[-0.349999994,0.328837216,0.278208017],[-0.38499999,0.740011215,0.389170021],[-0.38499999,0.752862871,0.394919485],[-0.38499999,0.763308823,0.404358923],[-0.38499999,0.770326555,0.416564375],[-0.38499999,0.773229182,0.430341005],[-0.38499999,0.77173245,0.444340348],[-0.38499999,0.765982985,0.457191974],[-0.38499999,0.756543517,0.467637926],[-0.38499999,0.744338095,0.474655658],[-0.38499999,0.730561495,0.477558255],[-0.38499999,0.716562152,0.476061553],[-0.38499999,0.305388123,0.365099549],[-0.38499999,0.292536497,0.359350085],[-0.38499999,0.282090545,0.349910617],[-0.38499999,0.275072783,0.337705195],[-0.38499999,0.272170216,0.323928565],[-0.38499999,0.273666918,0.309929222],[-0.38499999,0.279416382,0.297077596],[-0.38499999,0.288855821,0.286631644],[-0.38499999,0.301061243,0.279613912],[-0.38499999,0.314837903,0.276711315],[-0.38499999,0.328837216,0.278208017],[-0.349999994,0.514849424,0.463428885],[-0.349999994,0.522187293,0.473566681],[-0.349999994,0.526033282,0.485475808],[-0.349999994,0.526010931,0.497990549],[-0.349999994,0.522122383,0.509885848],[-0.349999994,0.514748275,0.519997358],[-0.349999994,0.504610479,0.527335227],[-0.349999994,0.492701381,0.531181216],[-0.349999994,0.480186641,0.531158805],[-0.349999994,0.468291312,0.527270257],[-0.349999994,0.458179832,0.519896209],[-0.349999994,0.288777888,0.349887431],[-0.349999994,0.28144002,0.339749664],[-0.349999994,0.27759403,0.327840507],[-0.349999994,0.277616382,0.315325767],[-0.349999994,0.281504929,0.303430468],[-0.349999994,0.288879007,0.293318987],[-0.349999994,0.299016804,0.285981119],[-0.349999994,0.310925931,0.282135129],[-0.349999994,0.323440671,0.282157511],[-0.349999994,0.335336,0.286046058],[-0.349999994,0.345447481,0.293420136],[-0.38499999,0.514849424,0.463428885],[-0.38499999,0.522187293,0.473566681],[-0.38499999,0.526033282,0.485475808],[-0.38499999,0.526010931,0.497990549],[-0.38499999,0.522122383,0.509885848],[-0.38499999,0.514748275,0.519997358],[-0.38499999,0.504610479,0.527335227],[-0.38499999,0.492701381,0.531181216],[-0.38499999,0.480186641,0.531158805],[-0.38499999,0.468291312,0.527270257],[-0.38499999,0.458179832,0.519896209],[-0.38499999,0.288777888,0.349887431],[-0.38499999,0.28144002,0.339749664],[-0.38499999,0.27759403,0.327840507],[-0.38499999,0.277616382,0.315325767],[-0.38499999,0.281504929,0.303430468],[-0.38499999,0.288879007,0.293318987],[-0.38499999,0.299016804,0.285981119],[-0.38499999,0.310925931,0.282135129],[-0.38499999,0.323440671,0.282157511],[-0.38499999,0.335336,0.286046058],[-0.38499999,0.345447481,0.293420136],[0.349999994,0.740011215,0.389170021],[0.349999994,0.752862871,0.394919485],[0.349999994,0.763308823,0.404358923],[0.349999994,0.770326555,0.416564375],[0.349999994,0.773229182,0.430341005],[0.349999994,0.77173245,0.444340348],[0.349999994,0.765982985,0.457191974],[0.349999994,0.756543517,0.467637926],[0.349999994,0.744338095,0.474655658],[0.349999994,0.730561495,0.477558255],[0.349999994,0.716562152,0.476061553],[0.349999994,0.305388123,0.365099549],[0.349999994,0.292536497,0.359350085],[0.349999994,0.282090545,0.349910617],[0.349999994,0.275072783,0.337705195],[0.349999994,0.272170216,0.323928565],[0.349999994,0.273666918,0.309929222],[0.349999994,0.279416382,0.297077596],[0.349999994,0.288855821,0.286631644],[0.349999994,0.301061243,0.279613912],[0.349999994,0.314837903,0.276711315],[0.349999994,0.328837216,0.278208017],[0.38499999,0.740011215,0.389170021],[0.38499999,0.752862871,0.394919485],[0.38499999,0.763308823,0.404358923],[0.38499999,0.770326555,0.416564375],[0.38499999,0.773229182,0.430341005],[0.38499999,0.77173245,0.444340348],[0.38499999,0.765982985,0.457191974],[0.38499999,0.756543517,0.467637926],[0.38499999,0.744338095,0.474655658],[0.38499999,0.730561495,0.477558255],[0.38499999,0.716562152,0.476061553],[0.38499999,0.305388123,0.365099549],[0.38499999,0.292536497,0.359350085],[0.38499999,0.282090545,0.349910617],[0.38499999,0.275072783,0.337705195],[0.38499999,0.272170216,0.323928565],[0.38499999,0.273666918,0.309929222],[0.38499999,0.279416382,0.297077596],[0.38499999,0.288855821,0.286631644],[0.38499999,0.301061243,0.279613912],[0.38499999,0.314837903,0.276711315],[0.38499999,0.328837216,0.278208017],[0.349999994,0.514849424,0.463428885],[0.349999994,0.522187293,0.473566681],[0.349999994,0.526033282,0.485475808],[0.349999994,0.526010931,0.497990549],[0.349999994,0.522122383,0.509885848],[0.349999994,0.514748275,0.519997358],[0.349999994,0.504610479,0.527335227],[0.349999994,0.492701381,0.531181216],[0.349999994,0.480186641,0.531158805],[0.349999994,0.468291312,0.527270257],[0.349999994,0.458179832,0.519896209],[0.349999994,0.288777888,0.349887431],[0.349999994,0.28144002,0.339749664],[0.349999994,0.27759403,0.327840507],[0.349999994,0.277616382,0.315325767],[0.349999994,0.281504929,0.303430468],[0.349999994,0.288879007,0.293318987],[0.349999994,0.299016804,0.285981119],[0.349999994,0.310925931,0.282135129],[0.349999994,0.323440671,0.282157511],[0.349999994,0.335336,0.286046058],[0.349999994,0.345447481,0.293420136],[0.38499999,0.514849424,0.463428885],[0.38499999,0.522187293,0.473566681],[0.38499999,0.526033282,0.485475808],[0.38499999,0.526010931,0.497990549],[0.38499999,0.522122383,0.509885848],[0.38499999,0.514748275,0.519997358],[0.38499999,0.504610479,0.527335227],[0.38499999,0.492701381,0.531181216],[0.38499999,0.480186641,0.531158805],[0.38499999,0.468291312,0.527270257],[0.38499999,0.458179832,0.519896209],[0.38499999,0.288777888,0.349887431],[0.38499999,0.28144002,0.339749664],[0.38499999,0.27759403,0.327840507],[0.38499999,0.277616382,0.315325767],[0.38499999,0.281504929,0.303430468],[0.38499999,0.288879007,0.293318987],[0.38499999,0.299016804,0.285981119],[0.38499999,0.310925931,0.282135129],[0.38499999,0.323440671,0.282157511],[0.38499999,0.335336,0.286046058],[0.38499999,0.345447481,0.293420136]],"faces":[[19,21,11],[24,22,32],[22,1,0],[23,2,1],[24,3,2],[25,4,3],[26,5,4],[27,6,5],[28,7,6],[29,8,7],[30,9,8],[31,10,9],[32,11,10],[33,12,11],[34,13,12],[35,14,13],[36,15,14],[37,16,15],[38,17,16],[39,18,17],[40,19,18],[41,20,19],[42,21,20],[43,0,21],[63,65,55],[68,66,76],[66,45,44],[67,46,45],[68,47,46],[69,48,47],[70,49,48],[71,50,49],[72,51,50],[73,52,51],[74,53,52],[75,54,53],[76,55,54],[77,56,55],[78,57,56],[79,58,57],[80,59,58],[81,60,59],[82,61,60],[83,62,61],[84,63,62],[85,64,63],[86,65,64],[87,44,65],[95,93,91],[122,124,128],[89,110,88],[90,111,89],[91,112,90],[92,113,91],[93,114,92],[94,115,93],[95,116,94],[96,117,95],[97,118,96],[98,119,97],[99,120,98],[100,121,99],[101,122,100],[102,123,101],[103,124,102],[104,125,103],[105,126,104],[106,127,105],[107,128,106],[108,129,107],[109,130,108],[88,131,109],[141,139,135],[166,168,172],[133,154,132],[134,155,133],[135,156,134],[136,157,135],[137,158,136],[138,159,137],[139,160,138],[140,161,139],[141,162,140],[142,163,141],[143,164,142],[144,165,143],[145,166,144],[146,167,145],[147,168,146],[148,169,147],[149,170,148],[150,171,149],[151,172,150],[152,173,151],[153,174,152],[132,175,153],[21,0,10],[0,1,10],[1,2,3],[3,4,5],[5,6,7],[7,8,9],[9,10,3],[10,11,21],[3,10,1],[11,12,13],[13,14,15],[15,16,19],[16,17,19],[17,18,19],[19,20,21],[3,5,7],[7,9,3],[11,13,19],[13,15,19],[22,43,33],[43,42,33],[42,41,40],[40,39,38],[38,37,40],[37,36,40],[36,35,34],[34,33,40],[33,32,22],[40,33,42],[32,31,30],[30,29,28],[28,27,26],[26,25,28],[25,24,28],[24,23,22],[36,34,40],[32,30,24],[30,28,24],[22,23,1],[23,24,2],[24,25,3],[25,26,4],[26,27,5],[27,28,6],[28,29,7],[29,30,8],[30,31,9],[31,32,10],[32,33,11],[33,34,12],[34,35,13],[35,36,14],[36,37,15],[37,38,16],[38,39,17],[39,40,18],[40,41,19],[41,42,20],[42,43,21],[43,22,0],[65,44,54],[44,45,54],[45,46,47],[47,48,49],[49,50,47],[50,51,47],[51,52,53],[53,54,47],[54,55,65],[47,54,45],[55,56,57],[57,58,59],[59,60,61],[61,62,63],[63,64,65],[51,53,47],[55,57,63],[57,59,63],[59,61,63],[66,87,77],[87,86,77],[86,85,84],[84,83,80],[83,82,80],[82,81,80],[80,79,78],[78,77,84],[77,76,66],[84,77,86],[76,75,74],[74,73,72],[72,71,68],[71,70,68],[70,69,68],[68,67,66],[80,78,84],[76,74,68],[74,72,68],[66,67,45],[67,68,46],[68,69,47],[69,70,48],[70,71,49],[71,72,50],[72,73,51],[73,74,52],[74,75,53],[75,76,54],[76,77,55],[77,78,56],[78,79,57],[79,80,58],[80,81,59],[81,82,60],[82,83,61],[83,84,62],[84,85,63],[85,86,64],[86,87,65],[87,66,44],[89,88,98],[88,109,99],[109,108,107],[107,106,105],[105,104,107],[104,103,107],[103,102,101],[101,100,99],[99,98,88],[98,97,91],[97,96,95],[95,94,93],[93,92,91],[91,90,89],[109,107,99],[103,101,107],[101,99,107],[98,91,89],[97,95,91],[130,131,121],[131,110,120],[110,111,112],[112,113,116],[113,114,116],[114,115,116],[116,117,118],[118,119,120],[120,121,131],[121,122,128],[122,123,124],[124,125,128],[125,126,128],[126,127,128],[128,129,130],[110,112,120],[116,118,112],[118,120,112],[121,128,130],[89,111,110],[90,112,111],[91,113,112],[92,114,113],[93,115,114],[94,116,115],[95,117,116],[96,118,117],[97,119,118],[98,120,119],[99,121,120],[100,122,121],[101,123,122],[102,124,123],[103,125,124],[104,126,125],[105,127,126],[106,128,127],[107,129,128],[108,130,129],[109,131,130],[88,110,131],[133,132,142],[132,153,143],[153,152,151],[151,150,149],[149,148,147],[147,146,145],[145,144,143],[143,142,132],[142,141,135],[141,140,139],[139,138,135],[138,137,135],[137,136,135],[135,134,133],[153,151,143],[151,149,147],[147,145,151],[145,143,151],[142,135,133],[174,175,165],[175,154,164],[154,155,156],[156,157,158],[158,159,156],[159,160,156],[160,161,162],[162,163,164],[164,165,175],[165,166,172],[166,167,168],[168,169,170],[170,171,168],[171,172,168],[172,173,174],[154,156,164],[160,162,156],[162,164,156],[165,172,174],[133,155,154],[134,156,155],[135,157,156],[136,158,157],[137,159,158],[138,160,159],[139,161,160],[140,162,161],[141,163,162],[142,164,163],[143,165,164],[144,166,165],[145,167,166],[146,168,167],[147,169,168],[148,170,169],[149,171,170],[150,172,171],[151,173,172],[152,174,173],[153,175,174],[132,154,175]],"points":[[-0.356452715,0.274636974,0.343069077],[0.378547269,0.274636974,0.343069077],[0.380698176,0.529455168,0.329127992],[0.378547269,0.526970645,0.326847479],[-0.373952713,0.274636974,0.343069077],[0.380698176,0.273612617,0.339246879],[-0.354301808,0.529455168,0.329127992],[-0.356452715,0.526970645,0.326847479],[0.374245455,0.745663229,0.388236637],[0.378547269,0.738983472,0.385203213],[0.361047271,0.274636974,0.343069077],[-0.354301808,0.273612617,0.339246879],[-0.360754529,0.745663229,0.388236637],[-0.356452715,0.738983472,0.385203213]],"inside":[[-0.374881795,0.506437858,0.465394675],[-0.366131796,0.753098523,0.427236497],[0.367678355,0.451073686,0.418925236],[0.367678355,0.479256774,0.475544262],[0.36188077,0.558458164,0.350741692],[0.35499999,0.520441353,0.474452346],[-0.365999994,0.497151121,0.512630403],[-0.376249991,0.504683891,0.465963334],[0.367499992,0.497122383,0.509885848],[0.357,0.405670216,0.383211315],[0.357,0.417670216,0.389211315],[0.357,0.426670216,0.392211315],[-0.378,0.405670216,0.386211315],[-0.378,0.420670216,0.371211315],[-0.378,0.429670216,0.380211315],[-0.357,0.279670216,0.335211315],[-0.357,0.294670216,0.356211315],[0.3675,0.276670216,0.329211315],[0.3675,0.276670216,0.335211315],[-0.3675,0.354670216,0.365211315],[-0.357,0.387670216,0.380211315],[0.378,0.351670216,0.359211315],[-0.3675,0.357670216,0.305211315],[-0.357,0.372670216,0.311211315],[0.378,0.351670216,0.299211315],[-0.3675,0.291670216,0.314211315],[0.357,0.303670216,0.317211315],[-0.3675,0.354670216,0.362211315],[-0.357,0.357670216,0.326211315]]} \ No newline at end of file diff --git a/surfaces/blender/tests/live/ram_knee.py b/surfaces/blender/tests/live/ram_knee.py index 28f182f..e32d3d1 100644 --- a/surfaces/blender/tests/live/ram_knee.py +++ b/surfaces/blender/tests/live/ram_knee.py @@ -10,10 +10,10 @@ without them). is an absolute path; writes .result.json and .r3_ -62.5 and -125) and exits 1 when a check failed. The oracle is ram.Signed, three rays by majority. Its ray count is held by tests/fixtures/ram_rays.json: the rocker -plates as Imagination's jointlib builds them and points between the plates that stand on the first ray short of an +plates as Imagination's jointlib builds them and points beside their bars that stand on the first ray short of an edge or a vertex. One ray reads them inside a plate they stand clear of; the oracle as it is made reads none inside. -Its rays are held by the fixture's points inside the plates, where the plates' two bars overlap: the oracle as it is -made reads each inside, and two rays, one, a repeated ray or rays along x and y read some outside. +The same mesh is four closed bars joined into one, a side's two overlapping: the oracle reads it bar by bar, and no +point of a grid inside the bars, nor of the fixture's 29 inside points, reads outside. A clearance verdict is a sign, the gate's own. FLAT follows lodur:ruling:deterministic-bound-margin. The checks run inside one try: an uncaught error is a failed check that names its section, and the result file is always written. @@ -323,32 +323,40 @@ try: exact = np.maximum.reduce([np.abs(cloud[:, 0]) - 0.13, np.abs(cloud[:, 1]) - 0.14, np.abs(cloud[:, 2] - 0.725) - 0.425]) check("three-rays: 4000 random points about a box are signed as the box signs them", ((core < 0) == (exact < 0)).all(), int(((core < 0) != (exact < 0)).sum())) - # the ray count: the jointlib rocker plates, and points between them aimed along the first ray at an edge or a vertex + # the ray count: the jointlib rocker plates, and points beside a bar, in its bounding box, aimed along the first ray at an edge or a vertex fixture = json.loads((SURFACE / "tests" / "fixtures" / "ram_rays.json").read_text(encoding="utf-8")) plates, aimed = {"plates": [(np.array(fixture["verts"]), fixture["faces"])]}, np.array(fixture["points"]) made, single = Signed(plates)("plates", aimed), Signed(plates, rays=1)("plates", aimed) RES["readings"]["jointlib plates: points one ray signs inside, of %d" % len(aimed)] = int((single < 0).sum()) RES["readings"]["jointlib plates: points the oracle signs inside"] = int((made < 0).sum()) - # one ray reads all 24 inside; the oracle as made reads none. The bound on one ray's count is the geometric mean of 1 and 24 - check("ray-count: between the jointlib rocker plates, points on the first ray short of an edge or a vertex read outside by the oracle as it is made, inside by one ray", - (np.abs(aimed[:, 0]) < 0.349).all() and (made > 0).all() and (single < 0).sum() >= 5, [int((made < 0).sum()), int((single < 0).sum())]) + # one ray reads all 14 inside; the oracle as made reads none. The bound on one ray's count is the geometric mean of 1 and 14 + check("ray-count: beside the jointlib rocker plates' bars, points on the first ray short of an edge or a vertex read outside by the oracle as it is made, inside by one ray", + (made > 0).all() and (single < 0).sum() >= 4, [int((made < 0).sum()), int((single < 0).sum())]) - # the other way, which the gate's proof between samples leans on: points inside the same plates. The oracle as it is - # made reads every one inside; each change of its rays reads some outside. Counts of points: shipped 0 (half a - # point, lodur:ruling:deterministic-bound-zero-reading), the least mutant 6 (the second and third rays along x - # and y), geometric mean 1.7: the check asks 2 - within = np.array(fixture["inside"]) - - def outside(count=None, rays=None): - oracle = Signed(plates) if count is None else Signed(plates, rays=count) # as made: the count is Signed's own - if rays is not None: - oracle.rays = [Vector(ray).normalized() for ray in rays] - return int((oracle("plates", within) >= 0).sum()) - read = {"as made": outside(), "two rays": outside(2), "one ray": outside(1), "the second ray the first": outside(rays=(R.RAYS[0], R.RAYS[0], R.RAYS[2])), - "the second and third along x and y": outside(rays=(R.RAYS[0], (1, 0, 0), (0, 1, 0)))} - RES["readings"]["jointlib plates: inside points read outside, of %d" % len(within)] = read - check("rays-inside: points inside the jointlib rocker plates all read inside by the oracle as it is made, and some read outside with two rays, with one, with the second ray the first, " - "and with the second and third along x and y", read["as made"] == 0 and min(count for name, count in read.items() if name != "as made") >= 2, read) + # the other way, which the gate's proof between samples leans on: no point inside the plates reads outside. The + # fixture's mesh is four closed bars, a side's two overlapping about the pivot; a point is truly inside where it is + # 0.001 or more inside one bar (each a convex prism: inside every face's plane). A grid 0.003 apart at three depths + # of each plate, and the fixture's 29 points. A count of points: shipped 0 (half a point, + # lodur:ruling:deterministic-bound-zero-reading), parity over the whole mesh (M-whole) 1,906; the check asks 0 + hulls = [] + for verts, faces in R._pieces(*plates["plates"][0]): + tri = np.array([[verts[i] for i in face[:3]] for face in faces]) + normal = np.cross(tri[:, 1] - tri[:, 0], tri[:, 2] - tri[:, 0]) + normal /= np.linalg.norm(normal, axis=1)[:, None] + level = (normal * tri[:, 0]).sum(axis=1) + out = (normal @ verts.mean(axis=0) - level) > 0 + normal[out], level[out] = -normal[out], -level[out] + hulls.append((normal, level)) + lo, hi = (np.array(fixture["verts"]).min(axis=0), np.array(fixture["verts"]).max(axis=0)) + cloud = np.array([(s * (SLAB_R[0] + 2 * HALF * f), y, z) for s in (-1.0, 1.0) for f in (0.2, 0.5, 0.8) + for y in np.arange(lo[1] + 0.0015, hi[1], 0.003) for z in np.arange(lo[2] + 0.0015, hi[2], 0.003)]) + deep = np.max([-(cloud @ normal.T - level).max(axis=1) for normal, level in hulls], axis=0) >= 0.001 + within = np.concatenate([cloud[deep], np.array(fixture["inside"])]) + missed = int((Signed(plates)("plates", within) >= 0).sum()) + RES["readings"]["jointlib plates: bars the mesh is read as"] = len(hulls) + RES["readings"]["jointlib plates: inside points read outside, of %d" % len(within)] = missed + check("inside-reads-inside: no point inside the jointlib rocker plates, where its bars overlap or not, reads outside by the oracle as it is made", + len(hulls) == 4 and int(deep.sum()) > 30000 and missed == 0, [len(hulls), int(deep.sum()), missed]) SECTION[0] = "seat" seat = np.concatenate([v for v, _ in shells["parent.seat"]]) diff --git a/surfaces/blender/tests/live/ram_knee.result.json b/surfaces/blender/tests/live/ram_knee.result.json index 8bd0d66..efb906b 100644 --- a/surfaces/blender/tests/live/ram_knee.result.json +++ b/surfaces/blender/tests/live/ram_knee.result.json @@ -17,7 +17,12 @@ "detail": null }, { - "name": "ray-count: between the jointlib rocker plates, points on the first ray short of an edge or a vertex read outside by the oracle as it is made, inside by one ray", + "name": "ray-count: beside the jointlib rocker plates' bars, points on the first ray short of an edge or a vertex read outside by the oracle as it is made, inside by one ray", + "ok": true, + "detail": null + }, + { + "name": "inside-reads-inside: no point inside the jointlib rocker plates, where its bars overlap or not, reads outside by the oracle as it is made", "ok": true, "detail": null }, @@ -108,10 +113,12 @@ "bell crank: least margin of a zoned pair, 251 steps uncapped": 0.000118, "bell crank: pairs": 60, "bell crank: pairs refused with nothing let": 19, - "bell crank: seconds, 49 steps capped": 2.12, + "bell crank: seconds, 49 steps capped": 0.946, "bell crank: zoned pairs": 20, "four bar: barrel inside the shin's clearance": -0.122, - "jointlib plates: points one ray signs inside, of 24": 24, + "jointlib plates: bars the mesh is read as": 4, + "jointlib plates: inside points read outside, of 38477": 0, + "jointlib plates: points one ray signs inside, of 14": 14, "jointlib plates: points the oracle signs inside": 0, "moved x: both": -0.0543, "moved x: the coupler at x 0.25, inside the horn's 0.23..0.31": -0.02, @@ -120,7 +127,7 @@ "search: candidates": 13824, "search: pass the gates before clearance": 78, "search: refused on their own parts": 21, - "search: seconds": 43.3, + "search: seconds": 32.7, "search: worlds built": 22, "the base clevis's foot inside the thigh": -0.01 }, @@ -496,9 +503,9 @@ } }, "renders": [ - "F:/aeth-wt/fable-ramcore/scratch/h4/out/live_h4.r3_0.png", - "F:/aeth-wt/fable-ramcore/scratch/h4/out/live_h4.r3_62p5.png", - "F:/aeth-wt/fable-ramcore/scratch/h4/out/live_h4.r3_125.png" + "F:/aeth-wt/fable-ramlows/scratch/out/live5.r3_0.png", + "F:/aeth-wt/fable-ramlows/scratch/out/live5.r3_62p5.png", + "F:/aeth-wt/fable-ramlows/scratch/out/live5.r3_125.png" ], "ok": true } \ No newline at end of file -- 2.47.3 From 404849a30ee5bc573edb129c2b2f00a95eac61fb Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Thu, 3 Dec 2026 00:12:42 +0100 Subject: [PATCH 09/11] brokkr_kitbash.ram: Signed signs by the generalized winding number; the piece split and the rays are cut Inside is where the winding number of the part's triangles about the point is 0.5 or more (Jacobson, Kavan and Sorkine-Hornung 2013), the plain sum in numpy. Overlapping solids, welded or not, wind by their count; a nonconvex prism winds whole; an open cube reads inside up to its hole's plane. _pieces, RAYS, the rays parameter and the ray fixture's points are gone; ram_rays.json is ram_plates.json and keeps the overlapping bars. Live ram_knee: 20 checks, search 34.5 s (the parity oracle beside it 34.5 s). Closes cut-kit-ram-lows.s1 signed-trusts-closed-and-unwelded and rays-three-pinned-by-no-check. Co-Authored-By: Claude Fable 5.2 --- surfaces/blender/brokkr_kitbash/ram.py | 112 ++++++++---------- surfaces/blender/docs/kitbash.md | 31 +++-- .../blender/tests/fixtures/ram_plates.json | 1 + surfaces/blender/tests/fixtures/ram_rays.json | 1 - surfaces/blender/tests/live/ram_knee.py | 79 ++++++------ .../blender/tests/live/ram_knee.result.json | 31 ++--- surfaces/blender/tests/test_ram.py | 94 +++++++++++++-- 7 files changed, 198 insertions(+), 151 deletions(-) create mode 100644 surfaces/blender/tests/fixtures/ram_plates.json delete mode 100644 surfaces/blender/tests/fixtures/ram_rays.json diff --git a/surfaces/blender/brokkr_kitbash/ram.py b/surfaces/blender/brokkr_kitbash/ram.py index 7799526..f27ac23 100644 --- a/surfaces/blender/brokkr_kitbash/ram.py +++ b/surfaces/blender/brokkr_kitbash/ram.py @@ -24,7 +24,8 @@ the coupler bar at c's, the ram at a's plus each of `offsets`. search(kind, hinge, ram, seats, ...) the best of a seat grid, or the tally and the nearest miss record(m, ram), from_record the JSON record a rig or runtime drives from swept(fit, body, ...) points of the swept ram's surface in a body's rest frame - Signed(shells, cap) the distance oracle over closed meshes, piece by piece, signed by three rays + winding(vertices, triangles, points) the generalized winding number of a triangle soup about points + Signed(shells, cap) the distance oracle over meshes, signed by the winding number Clearance. The record names the mechanism's `parts`, each a piece of one body (part -> the body whose rest frame it turns with: a thigh's core, the bracket that carries the rocker's pivot, a link's plates, a pin), and `touch`: @@ -79,7 +80,6 @@ SCHEMA, VERSION = "brokkr.ram", 2 ZONE = ("part", "pin", "radius", "depth") # a zone of `touch`, as the record writes it BAND = 1e-9 # the loop is refused within this of a dead centre of the rocker and coupler FINE = 64 # in a zone a segment between samples is halved down to spacing / FINE -RAYS = ((0.5377, 0.6211, 0.5701), (-0.7071, 0.2903, 0.6447), (0.1873, -0.8011, -0.5684)) # Signed's, in order class RamError(ValueError): @@ -749,72 +749,64 @@ def swept(f, body, margin=0.0, steps=13, around=8): return _into(m, p, body, np.concatenate(pts, axis=1)).reshape(-1, 3) -def _pieces(vertices, faces): - """A mesh's pieces, [(vertices, faces)]: each the faces joined to one another through shared vertices.""" - vertices, root = np.asarray(vertices, dtype=float), list(range(len(vertices))) - - def find(i): - while root[i] != i: - root[i] = root[root[i]] - i = root[i] - return i - for face in faces: - for i in face[1:]: - root[find(i)] = find(face[0]) - groups = {} - for face in faces: - groups.setdefault(find(face[0]), []).append(face) - out = [] - for group in groups.values(): - used = sorted({i for face in group for i in face}) - at = {i: k for k, i in enumerate(used)} - out.append((vertices[used], [tuple(at[i] for i in face) for face in group])) - return out +def winding(vertices, triangles, points): + """The generalized winding number of a triangle soup about each of `points` (Jacobson, Kavan and Sorkine-Hornung + 2013): the triangles' signed solid angles, summed, over 4 pi. A triangle counts positive from the side its normal + points away from (counterclockwise seen from outside). About a closed mesh it is the whole number of times the + surface wraps the point: 0 outside, 1 inside, 2 where two solids of one mesh overlap, whether they share vertices + or cut through one another. About an open mesh it is a fraction that falls off toward the hole: the closed + mesh's number less the missing faces' share of the sphere about the point, so across a flat hole it passes + through 0.5 on the hole's own plane. The plain sum: a point costs every triangle. The corners' offsets from the + point are taken in double precision and the angles in single (2.4 times the pace): the number is good to 1e-5 a + millimetre off a face and to 1e-2 at 1e-7 off it, and nearer than that its side of the face is not held.""" + v, t, pts = np.asarray(vertices, dtype=float).reshape(-1, 3), np.asarray(triangles, dtype=int).reshape(-1, 3), np.asarray(points, dtype=float).reshape(-1, 3) + A, B, C = (np.ascontiguousarray(v[t[:, k]].T) for k in range(3)) # each (3, F): a corner of every triangle + out, step = np.zeros(len(pts)), max(1, 32768 // max(len(t), 1)) # a block of pairs that stays in cache: 3.1 times the pace of 400,000 + for k in range(0, len(pts), step): + p = pts[k:k + step].T[:, :, None] + (ax, ay, az), (bx, by, bz), (cx, cy, cz) = ((corner[:, None, :] - p).astype(np.float32) for corner in (A, B, C)) + la, lb, lc = np.sqrt(ax * ax + ay * ay + az * az), np.sqrt(bx * bx + by * by + bz * bz), np.sqrt(cx * cx + cy * cy + cz * cz) + volume = ax * (by * cz - bz * cy) + ay * (bz * cx - bx * cz) + az * (bx * cy - by * cx) + out[k:k + step] = np.arctan2(volume, la * lb * lc + (ax * bx + ay * by + az * bz) * lc + (bx * cx + by * cy + bz * cz) * la + (cx * ax + cy * ay + cz * az) * lb).sum(axis=1, dtype=float) + return out / (2.0 * math.pi) class Signed: - """The distance oracle over closed meshes: distance(part, points) is the nearest face's distance, negative - where the point is inside one of the part's shells (its depth below the nearest face), capped at `cap` outside - only. shells: part -> [(vertices (N, 3), faces)], in the rest frame of the part's body. A mesh is read piece by - piece (_pieces), each piece closed: a point is inside the part where it is inside any piece, so pieces joined - into one mesh may overlap (parity over the whole mesh would read where two overlap as outside). Inside a - piece is the crossing parity of `rays` of RAYS, by majority: one ray that runs through an edge or a vertex - miscounts, and a sample then reads inside a plate it stands clear of. An unknown part raises. Needs Blender's - mathutils (BVHTree).""" + """The distance oracle over meshes: distance(part, points) is the nearest face's distance, negative where the + point is inside the part (its depth below the nearest face), capped at `cap` outside only. shells: part -> + [(vertices (N, 3), faces)], in the rest frame of the part's body, faces wound counterclockwise seen from + outside. Inside is where the winding number of all the part's faces (winding; a face of more than three corners + as a fan) is 0.5 or more: solids that overlap, in one mesh or several, welded or not, read inside wherever any + is. A mesh wound inside out reads outside everywhere. An open mesh is read as its faces wind: no point is + refused, and a point inside by a flat hole reads inside up to the hole's plane, where the sign turns with no + face there, so the reading steps by twice the distance to the hole's rim. The depth is to the nearest face of + any of the part's meshes, one buried in another included. An unknown part raises. Needs Blender's mathutils + (BVHTree) for the nearest face.""" - def __init__(self, shells, cap=None, rays=3): + def __init__(self, shells, cap=None): from mathutils import Vector from mathutils.bvhtree import BVHTree - self.cap, self.asked, self.vector = cap, 0, Vector - self.rays = [Vector(ray).normalized() for ray in RAYS[:rays]] - self.trees = {part: [(BVHTree.FromPolygons(v.tolist(), [tuple(face) for face in f], epsilon=0.0), np.min(v, axis=0), np.max(v, axis=0)) - for mesh in made for v, f in _pieces(*mesh)] for part, made in shells.items()} - - @staticmethod - def crossings(tree, v, ray): - count, o = 0, v - for _ in range(64): - loc = tree.ray_cast(o, ray)[0] - if loc is None: - break - count, o = count + 1, loc + ray * 1e-6 - return count - - def inside(self, tree, v): - return 2 * sum(self.crossings(tree, v, ray) % 2 for ray in self.rays) > len(self.rays) + self.cap, self.asked, self.vector, self.parts = cap, 0, Vector, {} + for part, made in shells.items(): + verts, faces, at = [], [], 0 + for v, f in made: + v = np.asarray(v, dtype=float).reshape(-1, 3) + verts.append(v) + faces += [tuple(at + int(i) for i in face) for face in f] + at += len(v) + verts = np.concatenate(verts) + fan = np.array([(face[0], face[k], face[k + 1]) for face in faces for k in range(1, len(face) - 1)], dtype=int) + self.parts[part] = (BVHTree.FromPolygons(verts.tolist(), faces, epsilon=0.0), verts, fan) def __call__(self, part, pts): - pts = np.asarray(pts, dtype=float) + pts = np.asarray(pts, dtype=float).reshape(-1, 3) self.asked += len(pts) + tree, verts, fan = self.parts[part] out = np.full(len(pts), math.inf if self.cap is None else self.cap) - for tree, lo, hi in self.trees[part]: - boxed = ((pts >= lo) & (pts <= hi)).all(axis=1) - for i, p in enumerate(pts): - v = self.vector(p) - if boxed[i] and self.inside(tree, v): - out[i] = min(out[i], -tree.find_nearest(v)[3]) - continue - hit = tree.find_nearest(v, self.cap) if self.cap else tree.find_nearest(v) - if hit[0] is not None and hit[3] < out[i]: - out[i] = hit[3] + for i in np.flatnonzero(winding(verts, fan, pts) >= 0.5): + out[i] = -tree.find_nearest(self.vector(pts[i]))[3] + for i in np.flatnonzero(out >= 0): + hit = tree.find_nearest(self.vector(pts[i]), self.cap) if self.cap else tree.find_nearest(self.vector(pts[i])) + if hit[0] is not None: + out[i] = hit[3] return out diff --git a/surfaces/blender/docs/kitbash.md b/surfaces/blender/docs/kitbash.md index 5bb0ad6..8eb7ab9 100644 --- a/surfaces/blender/docs/kitbash.md +++ b/surfaces/blender/docs/kitbash.md @@ -1030,17 +1030,20 @@ Bore 0.042, range 0..-125. The kinematic rows are tests/test_ram.py's. The clear test generates (thigh with its front plate, shin with caps and armour, the bracket that carries R, the horn that carries `c`, twin link plates stacked 5 mm apart at x 0.31..0.345 and 0.35..0.385, pins through the knee's width, collars at the eye and a base clevis whose foot runs 0.01 into the thigh; 12 parts) and the package's signed BVH -oracle, `ram.Signed(shells, cap)`: the nearest face for the depth, the crossing parity of three rays, by majority, -for the side. One ray that runs through an edge or a vertex miscounts and signs a sample inside a plate it stands -clear of. `tests/fixtures/ram_rays.json` holds the ray count: the rocker plates as the joint library builds them -and 14 points beside their bars, each on the first ray short of an edge or a vertex. One ray signs all 14 -inside; three sign none. Three rays are not a proof: of 146 such points one ray missigned, two rays missigned 16. -Two rays, or a second and third along x and y, read those 14 as three do: the fixture holds the count above one. -A mesh is read piece by piece: `Signed` splits it into the pieces its faces join, each closed, and a point is -inside the part where it is inside any piece. The joint library's plates are one mesh of four bars, a side's two -overlapping about the pivot; parity over the whole mesh reads the overlap as outside (1,906 of 38,448 grid -points inside the bars, the direction the proof between samples cannot bear), and piece by piece none of them -reads outside, which the live check holds. +oracle, `ram.Signed(shells, cap)`: the nearest face for the depth, the generalized winding number for the side +(Jacobson, Kavan and Sorkine-Hornung 2013). `ram.winding` sums the signed solid angle of every triangle of the part +about the point, over 4 pi: about a closed mesh the whole number of times the surface wraps the point, 0 outside, 1 +inside, 2 where two solids overlap. A point is inside the part at 0.5 or more. The joint library's plates are one +mesh of four bars, a side's two overlapping about the pivot (`tests/fixtures/ram_plates.json`, with 29 points +inside them, 13 inside two bars): each reads inside, as does the overlap of two boxes welded at a corner and a +staircase prism a line crosses six times. Faces are wound counterclockwise seen from outside; a mesh wound inside +out reads outside everywhere. An open mesh is answered, not refused: the number is the closed mesh's less the +missing faces' share of the sphere about the point, so a cube with a face open reads inside up to the hole's plane +(0.5009 at 0.001 under the centre of a unit face) and the sign turns on that plane with no face there. The gate's +proof between samples assumes a distance changes by no more than the way between two points, which holds across a +face and not across a hole: a part with a hole the axis may reach is closed before it is given. The depth is to the +nearest face of any of the part's meshes, one buried inside another included, so inside two overlapping solids a +point may read shallower than its depth below their union. | drive | reading | | --- | --- | @@ -1055,8 +1058,10 @@ Cost on Starfire, Python 3.13, 100 repetitions paired and interleaved: one candi 49 steps took 0.79 ms median on the bell crank; its clearance against the analytic parts (50 pairs) took 42 ms (5th to 95th percentile 38 to 57) over 97,875 points, of which 23,520 are the samples and the rest the halving in zones (the own plates, stated with no slack, to the floor); the samples alone took 11 ms. A search without a world ran 1.6 to 1.8 ms a candidate over 3,456, so `limit` -(20,000) is 30 to 40 s. On the meshes the bell crank's 60 pairs at 49 steps took 1.95 to 2.12 s capped (two runs), in a -Python loop of BVH queries with three rays a sample, and the 13,824-candidate search with its 22 worlds 43 s (one run). +(20,000) is 30 to 40 s. On the meshes the bell crank's 60 pairs at 49 steps took 0.80 to 1.00 s capped (two runs), the +winding number as the plain sum over a part's 124 to 408 triangles in numpy (single precision over double offsets, +blocks of 32,768 pairs) and the depth a Python loop of BVH queries, and the 13,824-candidate search with its 22 +worlds 34.5 and 38.5 s (two runs). With the angles in double precision the search took 47.7 to 47.9 s (three runs). ## The actions diff --git a/surfaces/blender/tests/fixtures/ram_plates.json b/surfaces/blender/tests/fixtures/ram_plates.json new file mode 100644 index 0000000..be72f30 --- /dev/null +++ b/surfaces/blender/tests/fixtures/ram_plates.json @@ -0,0 +1 @@ +{"about":"The rocker's twin plates of the R-3 bell crank as Imagination's jointlib builds them: one mesh, triangulated, at rest, of four closed bars, a side's two overlapping about the pivot and sharing their faces' planes. `inside`: 29 points 0.001 or more inside a bar, 13 of them where two bars overlap. The winding number about each is the count of bars it is inside, 1 or 2: ram.Signed reads every one inside. Crossing parity reads the 13 outside.","verts":[[-0.349999994,0.740011215,0.389170021],[-0.349999994,0.752862871,0.394919485],[-0.349999994,0.763308823,0.404358923],[-0.349999994,0.770326555,0.416564375],[-0.349999994,0.773229182,0.430341005],[-0.349999994,0.77173245,0.444340348],[-0.349999994,0.765982985,0.457191974],[-0.349999994,0.756543517,0.467637926],[-0.349999994,0.744338095,0.474655658],[-0.349999994,0.730561495,0.477558255],[-0.349999994,0.716562152,0.476061553],[-0.349999994,0.305388123,0.365099549],[-0.349999994,0.292536497,0.359350085],[-0.349999994,0.282090545,0.349910617],[-0.349999994,0.275072783,0.337705195],[-0.349999994,0.272170216,0.323928565],[-0.349999994,0.273666918,0.309929222],[-0.349999994,0.279416382,0.297077596],[-0.349999994,0.288855821,0.286631644],[-0.349999994,0.301061243,0.279613912],[-0.349999994,0.314837903,0.276711315],[-0.349999994,0.328837216,0.278208017],[-0.38499999,0.740011215,0.389170021],[-0.38499999,0.752862871,0.394919485],[-0.38499999,0.763308823,0.404358923],[-0.38499999,0.770326555,0.416564375],[-0.38499999,0.773229182,0.430341005],[-0.38499999,0.77173245,0.444340348],[-0.38499999,0.765982985,0.457191974],[-0.38499999,0.756543517,0.467637926],[-0.38499999,0.744338095,0.474655658],[-0.38499999,0.730561495,0.477558255],[-0.38499999,0.716562152,0.476061553],[-0.38499999,0.305388123,0.365099549],[-0.38499999,0.292536497,0.359350085],[-0.38499999,0.282090545,0.349910617],[-0.38499999,0.275072783,0.337705195],[-0.38499999,0.272170216,0.323928565],[-0.38499999,0.273666918,0.309929222],[-0.38499999,0.279416382,0.297077596],[-0.38499999,0.288855821,0.286631644],[-0.38499999,0.301061243,0.279613912],[-0.38499999,0.314837903,0.276711315],[-0.38499999,0.328837216,0.278208017],[-0.349999994,0.514849424,0.463428885],[-0.349999994,0.522187293,0.473566681],[-0.349999994,0.526033282,0.485475808],[-0.349999994,0.526010931,0.497990549],[-0.349999994,0.522122383,0.509885848],[-0.349999994,0.514748275,0.519997358],[-0.349999994,0.504610479,0.527335227],[-0.349999994,0.492701381,0.531181216],[-0.349999994,0.480186641,0.531158805],[-0.349999994,0.468291312,0.527270257],[-0.349999994,0.458179832,0.519896209],[-0.349999994,0.288777888,0.349887431],[-0.349999994,0.28144002,0.339749664],[-0.349999994,0.27759403,0.327840507],[-0.349999994,0.277616382,0.315325767],[-0.349999994,0.281504929,0.303430468],[-0.349999994,0.288879007,0.293318987],[-0.349999994,0.299016804,0.285981119],[-0.349999994,0.310925931,0.282135129],[-0.349999994,0.323440671,0.282157511],[-0.349999994,0.335336,0.286046058],[-0.349999994,0.345447481,0.293420136],[-0.38499999,0.514849424,0.463428885],[-0.38499999,0.522187293,0.473566681],[-0.38499999,0.526033282,0.485475808],[-0.38499999,0.526010931,0.497990549],[-0.38499999,0.522122383,0.509885848],[-0.38499999,0.514748275,0.519997358],[-0.38499999,0.504610479,0.527335227],[-0.38499999,0.492701381,0.531181216],[-0.38499999,0.480186641,0.531158805],[-0.38499999,0.468291312,0.527270257],[-0.38499999,0.458179832,0.519896209],[-0.38499999,0.288777888,0.349887431],[-0.38499999,0.28144002,0.339749664],[-0.38499999,0.27759403,0.327840507],[-0.38499999,0.277616382,0.315325767],[-0.38499999,0.281504929,0.303430468],[-0.38499999,0.288879007,0.293318987],[-0.38499999,0.299016804,0.285981119],[-0.38499999,0.310925931,0.282135129],[-0.38499999,0.323440671,0.282157511],[-0.38499999,0.335336,0.286046058],[-0.38499999,0.345447481,0.293420136],[0.349999994,0.740011215,0.389170021],[0.349999994,0.752862871,0.394919485],[0.349999994,0.763308823,0.404358923],[0.349999994,0.770326555,0.416564375],[0.349999994,0.773229182,0.430341005],[0.349999994,0.77173245,0.444340348],[0.349999994,0.765982985,0.457191974],[0.349999994,0.756543517,0.467637926],[0.349999994,0.744338095,0.474655658],[0.349999994,0.730561495,0.477558255],[0.349999994,0.716562152,0.476061553],[0.349999994,0.305388123,0.365099549],[0.349999994,0.292536497,0.359350085],[0.349999994,0.282090545,0.349910617],[0.349999994,0.275072783,0.337705195],[0.349999994,0.272170216,0.323928565],[0.349999994,0.273666918,0.309929222],[0.349999994,0.279416382,0.297077596],[0.349999994,0.288855821,0.286631644],[0.349999994,0.301061243,0.279613912],[0.349999994,0.314837903,0.276711315],[0.349999994,0.328837216,0.278208017],[0.38499999,0.740011215,0.389170021],[0.38499999,0.752862871,0.394919485],[0.38499999,0.763308823,0.404358923],[0.38499999,0.770326555,0.416564375],[0.38499999,0.773229182,0.430341005],[0.38499999,0.77173245,0.444340348],[0.38499999,0.765982985,0.457191974],[0.38499999,0.756543517,0.467637926],[0.38499999,0.744338095,0.474655658],[0.38499999,0.730561495,0.477558255],[0.38499999,0.716562152,0.476061553],[0.38499999,0.305388123,0.365099549],[0.38499999,0.292536497,0.359350085],[0.38499999,0.282090545,0.349910617],[0.38499999,0.275072783,0.337705195],[0.38499999,0.272170216,0.323928565],[0.38499999,0.273666918,0.309929222],[0.38499999,0.279416382,0.297077596],[0.38499999,0.288855821,0.286631644],[0.38499999,0.301061243,0.279613912],[0.38499999,0.314837903,0.276711315],[0.38499999,0.328837216,0.278208017],[0.349999994,0.514849424,0.463428885],[0.349999994,0.522187293,0.473566681],[0.349999994,0.526033282,0.485475808],[0.349999994,0.526010931,0.497990549],[0.349999994,0.522122383,0.509885848],[0.349999994,0.514748275,0.519997358],[0.349999994,0.504610479,0.527335227],[0.349999994,0.492701381,0.531181216],[0.349999994,0.480186641,0.531158805],[0.349999994,0.468291312,0.527270257],[0.349999994,0.458179832,0.519896209],[0.349999994,0.288777888,0.349887431],[0.349999994,0.28144002,0.339749664],[0.349999994,0.27759403,0.327840507],[0.349999994,0.277616382,0.315325767],[0.349999994,0.281504929,0.303430468],[0.349999994,0.288879007,0.293318987],[0.349999994,0.299016804,0.285981119],[0.349999994,0.310925931,0.282135129],[0.349999994,0.323440671,0.282157511],[0.349999994,0.335336,0.286046058],[0.349999994,0.345447481,0.293420136],[0.38499999,0.514849424,0.463428885],[0.38499999,0.522187293,0.473566681],[0.38499999,0.526033282,0.485475808],[0.38499999,0.526010931,0.497990549],[0.38499999,0.522122383,0.509885848],[0.38499999,0.514748275,0.519997358],[0.38499999,0.504610479,0.527335227],[0.38499999,0.492701381,0.531181216],[0.38499999,0.480186641,0.531158805],[0.38499999,0.468291312,0.527270257],[0.38499999,0.458179832,0.519896209],[0.38499999,0.288777888,0.349887431],[0.38499999,0.28144002,0.339749664],[0.38499999,0.27759403,0.327840507],[0.38499999,0.277616382,0.315325767],[0.38499999,0.281504929,0.303430468],[0.38499999,0.288879007,0.293318987],[0.38499999,0.299016804,0.285981119],[0.38499999,0.310925931,0.282135129],[0.38499999,0.323440671,0.282157511],[0.38499999,0.335336,0.286046058],[0.38499999,0.345447481,0.293420136]],"faces":[[19,21,11],[24,22,32],[22,1,0],[23,2,1],[24,3,2],[25,4,3],[26,5,4],[27,6,5],[28,7,6],[29,8,7],[30,9,8],[31,10,9],[32,11,10],[33,12,11],[34,13,12],[35,14,13],[36,15,14],[37,16,15],[38,17,16],[39,18,17],[40,19,18],[41,20,19],[42,21,20],[43,0,21],[63,65,55],[68,66,76],[66,45,44],[67,46,45],[68,47,46],[69,48,47],[70,49,48],[71,50,49],[72,51,50],[73,52,51],[74,53,52],[75,54,53],[76,55,54],[77,56,55],[78,57,56],[79,58,57],[80,59,58],[81,60,59],[82,61,60],[83,62,61],[84,63,62],[85,64,63],[86,65,64],[87,44,65],[95,93,91],[122,124,128],[89,110,88],[90,111,89],[91,112,90],[92,113,91],[93,114,92],[94,115,93],[95,116,94],[96,117,95],[97,118,96],[98,119,97],[99,120,98],[100,121,99],[101,122,100],[102,123,101],[103,124,102],[104,125,103],[105,126,104],[106,127,105],[107,128,106],[108,129,107],[109,130,108],[88,131,109],[141,139,135],[166,168,172],[133,154,132],[134,155,133],[135,156,134],[136,157,135],[137,158,136],[138,159,137],[139,160,138],[140,161,139],[141,162,140],[142,163,141],[143,164,142],[144,165,143],[145,166,144],[146,167,145],[147,168,146],[148,169,147],[149,170,148],[150,171,149],[151,172,150],[152,173,151],[153,174,152],[132,175,153],[21,0,10],[0,1,10],[1,2,3],[3,4,5],[5,6,7],[7,8,9],[9,10,3],[10,11,21],[3,10,1],[11,12,13],[13,14,15],[15,16,19],[16,17,19],[17,18,19],[19,20,21],[3,5,7],[7,9,3],[11,13,19],[13,15,19],[22,43,33],[43,42,33],[42,41,40],[40,39,38],[38,37,40],[37,36,40],[36,35,34],[34,33,40],[33,32,22],[40,33,42],[32,31,30],[30,29,28],[28,27,26],[26,25,28],[25,24,28],[24,23,22],[36,34,40],[32,30,24],[30,28,24],[22,23,1],[23,24,2],[24,25,3],[25,26,4],[26,27,5],[27,28,6],[28,29,7],[29,30,8],[30,31,9],[31,32,10],[32,33,11],[33,34,12],[34,35,13],[35,36,14],[36,37,15],[37,38,16],[38,39,17],[39,40,18],[40,41,19],[41,42,20],[42,43,21],[43,22,0],[65,44,54],[44,45,54],[45,46,47],[47,48,49],[49,50,47],[50,51,47],[51,52,53],[53,54,47],[54,55,65],[47,54,45],[55,56,57],[57,58,59],[59,60,61],[61,62,63],[63,64,65],[51,53,47],[55,57,63],[57,59,63],[59,61,63],[66,87,77],[87,86,77],[86,85,84],[84,83,80],[83,82,80],[82,81,80],[80,79,78],[78,77,84],[77,76,66],[84,77,86],[76,75,74],[74,73,72],[72,71,68],[71,70,68],[70,69,68],[68,67,66],[80,78,84],[76,74,68],[74,72,68],[66,67,45],[67,68,46],[68,69,47],[69,70,48],[70,71,49],[71,72,50],[72,73,51],[73,74,52],[74,75,53],[75,76,54],[76,77,55],[77,78,56],[78,79,57],[79,80,58],[80,81,59],[81,82,60],[82,83,61],[83,84,62],[84,85,63],[85,86,64],[86,87,65],[87,66,44],[89,88,98],[88,109,99],[109,108,107],[107,106,105],[105,104,107],[104,103,107],[103,102,101],[101,100,99],[99,98,88],[98,97,91],[97,96,95],[95,94,93],[93,92,91],[91,90,89],[109,107,99],[103,101,107],[101,99,107],[98,91,89],[97,95,91],[130,131,121],[131,110,120],[110,111,112],[112,113,116],[113,114,116],[114,115,116],[116,117,118],[118,119,120],[120,121,131],[121,122,128],[122,123,124],[124,125,128],[125,126,128],[126,127,128],[128,129,130],[110,112,120],[116,118,112],[118,120,112],[121,128,130],[89,111,110],[90,112,111],[91,113,112],[92,114,113],[93,115,114],[94,116,115],[95,117,116],[96,118,117],[97,119,118],[98,120,119],[99,121,120],[100,122,121],[101,123,122],[102,124,123],[103,125,124],[104,126,125],[105,127,126],[106,128,127],[107,129,128],[108,130,129],[109,131,130],[88,110,131],[133,132,142],[132,153,143],[153,152,151],[151,150,149],[149,148,147],[147,146,145],[145,144,143],[143,142,132],[142,141,135],[141,140,139],[139,138,135],[138,137,135],[137,136,135],[135,134,133],[153,151,143],[151,149,147],[147,145,151],[145,143,151],[142,135,133],[174,175,165],[175,154,164],[154,155,156],[156,157,158],[158,159,156],[159,160,156],[160,161,162],[162,163,164],[164,165,175],[165,166,172],[166,167,168],[168,169,170],[170,171,168],[171,172,168],[172,173,174],[154,156,164],[160,162,156],[162,164,156],[165,172,174],[133,155,154],[134,156,155],[135,157,156],[136,158,157],[137,159,158],[138,160,159],[139,161,160],[140,162,161],[141,163,162],[142,164,163],[143,165,164],[144,166,165],[145,167,166],[146,168,167],[147,169,168],[148,170,169],[149,171,170],[150,172,171],[151,173,172],[152,174,173],[153,175,174],[132,154,175]],"inside":[[-0.374881795,0.506437858,0.465394675],[-0.366131796,0.753098523,0.427236497],[0.367678355,0.451073686,0.418925236],[0.367678355,0.479256774,0.475544262],[0.36188077,0.558458164,0.350741692],[0.35499999,0.520441353,0.474452346],[-0.365999994,0.497151121,0.512630403],[-0.376249991,0.504683891,0.465963334],[0.367499992,0.497122383,0.509885848],[0.357,0.405670216,0.383211315],[0.357,0.417670216,0.389211315],[0.357,0.426670216,0.392211315],[-0.378,0.405670216,0.386211315],[-0.378,0.420670216,0.371211315],[-0.378,0.429670216,0.380211315],[-0.357,0.279670216,0.335211315],[-0.357,0.294670216,0.356211315],[0.3675,0.276670216,0.329211315],[0.3675,0.276670216,0.335211315],[-0.3675,0.354670216,0.365211315],[-0.357,0.387670216,0.380211315],[0.378,0.351670216,0.359211315],[-0.3675,0.357670216,0.305211315],[-0.357,0.372670216,0.311211315],[0.378,0.351670216,0.299211315],[-0.3675,0.291670216,0.314211315],[0.357,0.303670216,0.317211315],[-0.3675,0.354670216,0.362211315],[-0.357,0.357670216,0.326211315]]} \ No newline at end of file diff --git a/surfaces/blender/tests/fixtures/ram_rays.json b/surfaces/blender/tests/fixtures/ram_rays.json deleted file mode 100644 index ab8fd15..0000000 --- a/surfaces/blender/tests/fixtures/ram_rays.json +++ /dev/null @@ -1 +0,0 @@ -{"about":"The rocker's twin plates of the R-3 bell crank as Imagination's jointlib builds them: one mesh, triangulated, at rest, of four closed bars, a side's two overlapping about the pivot and sharing their faces' planes. `points`: 14 points 0.002 or more outside every bar and inside a bar's bounding box, each on the oracle's first ray 0.004 to 0.02 short of a vertex or an edge. One ray reads each inside; three read none inside. `inside`: 29 points 0.001 or more inside a bar, nine aimed along a ray of RAYS, x or y at a vertex or an edge, the rest from a grid where the bars overlap. Parity over the whole mesh reads the overlap outside (1,906 of 38,448 grid points inside the bars); read bar by bar, as ram.Signed reads a mesh, none of them and none of these reads outside.","verts":[[-0.349999994,0.740011215,0.389170021],[-0.349999994,0.752862871,0.394919485],[-0.349999994,0.763308823,0.404358923],[-0.349999994,0.770326555,0.416564375],[-0.349999994,0.773229182,0.430341005],[-0.349999994,0.77173245,0.444340348],[-0.349999994,0.765982985,0.457191974],[-0.349999994,0.756543517,0.467637926],[-0.349999994,0.744338095,0.474655658],[-0.349999994,0.730561495,0.477558255],[-0.349999994,0.716562152,0.476061553],[-0.349999994,0.305388123,0.365099549],[-0.349999994,0.292536497,0.359350085],[-0.349999994,0.282090545,0.349910617],[-0.349999994,0.275072783,0.337705195],[-0.349999994,0.272170216,0.323928565],[-0.349999994,0.273666918,0.309929222],[-0.349999994,0.279416382,0.297077596],[-0.349999994,0.288855821,0.286631644],[-0.349999994,0.301061243,0.279613912],[-0.349999994,0.314837903,0.276711315],[-0.349999994,0.328837216,0.278208017],[-0.38499999,0.740011215,0.389170021],[-0.38499999,0.752862871,0.394919485],[-0.38499999,0.763308823,0.404358923],[-0.38499999,0.770326555,0.416564375],[-0.38499999,0.773229182,0.430341005],[-0.38499999,0.77173245,0.444340348],[-0.38499999,0.765982985,0.457191974],[-0.38499999,0.756543517,0.467637926],[-0.38499999,0.744338095,0.474655658],[-0.38499999,0.730561495,0.477558255],[-0.38499999,0.716562152,0.476061553],[-0.38499999,0.305388123,0.365099549],[-0.38499999,0.292536497,0.359350085],[-0.38499999,0.282090545,0.349910617],[-0.38499999,0.275072783,0.337705195],[-0.38499999,0.272170216,0.323928565],[-0.38499999,0.273666918,0.309929222],[-0.38499999,0.279416382,0.297077596],[-0.38499999,0.288855821,0.286631644],[-0.38499999,0.301061243,0.279613912],[-0.38499999,0.314837903,0.276711315],[-0.38499999,0.328837216,0.278208017],[-0.349999994,0.514849424,0.463428885],[-0.349999994,0.522187293,0.473566681],[-0.349999994,0.526033282,0.485475808],[-0.349999994,0.526010931,0.497990549],[-0.349999994,0.522122383,0.509885848],[-0.349999994,0.514748275,0.519997358],[-0.349999994,0.504610479,0.527335227],[-0.349999994,0.492701381,0.531181216],[-0.349999994,0.480186641,0.531158805],[-0.349999994,0.468291312,0.527270257],[-0.349999994,0.458179832,0.519896209],[-0.349999994,0.288777888,0.349887431],[-0.349999994,0.28144002,0.339749664],[-0.349999994,0.27759403,0.327840507],[-0.349999994,0.277616382,0.315325767],[-0.349999994,0.281504929,0.303430468],[-0.349999994,0.288879007,0.293318987],[-0.349999994,0.299016804,0.285981119],[-0.349999994,0.310925931,0.282135129],[-0.349999994,0.323440671,0.282157511],[-0.349999994,0.335336,0.286046058],[-0.349999994,0.345447481,0.293420136],[-0.38499999,0.514849424,0.463428885],[-0.38499999,0.522187293,0.473566681],[-0.38499999,0.526033282,0.485475808],[-0.38499999,0.526010931,0.497990549],[-0.38499999,0.522122383,0.509885848],[-0.38499999,0.514748275,0.519997358],[-0.38499999,0.504610479,0.527335227],[-0.38499999,0.492701381,0.531181216],[-0.38499999,0.480186641,0.531158805],[-0.38499999,0.468291312,0.527270257],[-0.38499999,0.458179832,0.519896209],[-0.38499999,0.288777888,0.349887431],[-0.38499999,0.28144002,0.339749664],[-0.38499999,0.27759403,0.327840507],[-0.38499999,0.277616382,0.315325767],[-0.38499999,0.281504929,0.303430468],[-0.38499999,0.288879007,0.293318987],[-0.38499999,0.299016804,0.285981119],[-0.38499999,0.310925931,0.282135129],[-0.38499999,0.323440671,0.282157511],[-0.38499999,0.335336,0.286046058],[-0.38499999,0.345447481,0.293420136],[0.349999994,0.740011215,0.389170021],[0.349999994,0.752862871,0.394919485],[0.349999994,0.763308823,0.404358923],[0.349999994,0.770326555,0.416564375],[0.349999994,0.773229182,0.430341005],[0.349999994,0.77173245,0.444340348],[0.349999994,0.765982985,0.457191974],[0.349999994,0.756543517,0.467637926],[0.349999994,0.744338095,0.474655658],[0.349999994,0.730561495,0.477558255],[0.349999994,0.716562152,0.476061553],[0.349999994,0.305388123,0.365099549],[0.349999994,0.292536497,0.359350085],[0.349999994,0.282090545,0.349910617],[0.349999994,0.275072783,0.337705195],[0.349999994,0.272170216,0.323928565],[0.349999994,0.273666918,0.309929222],[0.349999994,0.279416382,0.297077596],[0.349999994,0.288855821,0.286631644],[0.349999994,0.301061243,0.279613912],[0.349999994,0.314837903,0.276711315],[0.349999994,0.328837216,0.278208017],[0.38499999,0.740011215,0.389170021],[0.38499999,0.752862871,0.394919485],[0.38499999,0.763308823,0.404358923],[0.38499999,0.770326555,0.416564375],[0.38499999,0.773229182,0.430341005],[0.38499999,0.77173245,0.444340348],[0.38499999,0.765982985,0.457191974],[0.38499999,0.756543517,0.467637926],[0.38499999,0.744338095,0.474655658],[0.38499999,0.730561495,0.477558255],[0.38499999,0.716562152,0.476061553],[0.38499999,0.305388123,0.365099549],[0.38499999,0.292536497,0.359350085],[0.38499999,0.282090545,0.349910617],[0.38499999,0.275072783,0.337705195],[0.38499999,0.272170216,0.323928565],[0.38499999,0.273666918,0.309929222],[0.38499999,0.279416382,0.297077596],[0.38499999,0.288855821,0.286631644],[0.38499999,0.301061243,0.279613912],[0.38499999,0.314837903,0.276711315],[0.38499999,0.328837216,0.278208017],[0.349999994,0.514849424,0.463428885],[0.349999994,0.522187293,0.473566681],[0.349999994,0.526033282,0.485475808],[0.349999994,0.526010931,0.497990549],[0.349999994,0.522122383,0.509885848],[0.349999994,0.514748275,0.519997358],[0.349999994,0.504610479,0.527335227],[0.349999994,0.492701381,0.531181216],[0.349999994,0.480186641,0.531158805],[0.349999994,0.468291312,0.527270257],[0.349999994,0.458179832,0.519896209],[0.349999994,0.288777888,0.349887431],[0.349999994,0.28144002,0.339749664],[0.349999994,0.27759403,0.327840507],[0.349999994,0.277616382,0.315325767],[0.349999994,0.281504929,0.303430468],[0.349999994,0.288879007,0.293318987],[0.349999994,0.299016804,0.285981119],[0.349999994,0.310925931,0.282135129],[0.349999994,0.323440671,0.282157511],[0.349999994,0.335336,0.286046058],[0.349999994,0.345447481,0.293420136],[0.38499999,0.514849424,0.463428885],[0.38499999,0.522187293,0.473566681],[0.38499999,0.526033282,0.485475808],[0.38499999,0.526010931,0.497990549],[0.38499999,0.522122383,0.509885848],[0.38499999,0.514748275,0.519997358],[0.38499999,0.504610479,0.527335227],[0.38499999,0.492701381,0.531181216],[0.38499999,0.480186641,0.531158805],[0.38499999,0.468291312,0.527270257],[0.38499999,0.458179832,0.519896209],[0.38499999,0.288777888,0.349887431],[0.38499999,0.28144002,0.339749664],[0.38499999,0.27759403,0.327840507],[0.38499999,0.277616382,0.315325767],[0.38499999,0.281504929,0.303430468],[0.38499999,0.288879007,0.293318987],[0.38499999,0.299016804,0.285981119],[0.38499999,0.310925931,0.282135129],[0.38499999,0.323440671,0.282157511],[0.38499999,0.335336,0.286046058],[0.38499999,0.345447481,0.293420136]],"faces":[[19,21,11],[24,22,32],[22,1,0],[23,2,1],[24,3,2],[25,4,3],[26,5,4],[27,6,5],[28,7,6],[29,8,7],[30,9,8],[31,10,9],[32,11,10],[33,12,11],[34,13,12],[35,14,13],[36,15,14],[37,16,15],[38,17,16],[39,18,17],[40,19,18],[41,20,19],[42,21,20],[43,0,21],[63,65,55],[68,66,76],[66,45,44],[67,46,45],[68,47,46],[69,48,47],[70,49,48],[71,50,49],[72,51,50],[73,52,51],[74,53,52],[75,54,53],[76,55,54],[77,56,55],[78,57,56],[79,58,57],[80,59,58],[81,60,59],[82,61,60],[83,62,61],[84,63,62],[85,64,63],[86,65,64],[87,44,65],[95,93,91],[122,124,128],[89,110,88],[90,111,89],[91,112,90],[92,113,91],[93,114,92],[94,115,93],[95,116,94],[96,117,95],[97,118,96],[98,119,97],[99,120,98],[100,121,99],[101,122,100],[102,123,101],[103,124,102],[104,125,103],[105,126,104],[106,127,105],[107,128,106],[108,129,107],[109,130,108],[88,131,109],[141,139,135],[166,168,172],[133,154,132],[134,155,133],[135,156,134],[136,157,135],[137,158,136],[138,159,137],[139,160,138],[140,161,139],[141,162,140],[142,163,141],[143,164,142],[144,165,143],[145,166,144],[146,167,145],[147,168,146],[148,169,147],[149,170,148],[150,171,149],[151,172,150],[152,173,151],[153,174,152],[132,175,153],[21,0,10],[0,1,10],[1,2,3],[3,4,5],[5,6,7],[7,8,9],[9,10,3],[10,11,21],[3,10,1],[11,12,13],[13,14,15],[15,16,19],[16,17,19],[17,18,19],[19,20,21],[3,5,7],[7,9,3],[11,13,19],[13,15,19],[22,43,33],[43,42,33],[42,41,40],[40,39,38],[38,37,40],[37,36,40],[36,35,34],[34,33,40],[33,32,22],[40,33,42],[32,31,30],[30,29,28],[28,27,26],[26,25,28],[25,24,28],[24,23,22],[36,34,40],[32,30,24],[30,28,24],[22,23,1],[23,24,2],[24,25,3],[25,26,4],[26,27,5],[27,28,6],[28,29,7],[29,30,8],[30,31,9],[31,32,10],[32,33,11],[33,34,12],[34,35,13],[35,36,14],[36,37,15],[37,38,16],[38,39,17],[39,40,18],[40,41,19],[41,42,20],[42,43,21],[43,22,0],[65,44,54],[44,45,54],[45,46,47],[47,48,49],[49,50,47],[50,51,47],[51,52,53],[53,54,47],[54,55,65],[47,54,45],[55,56,57],[57,58,59],[59,60,61],[61,62,63],[63,64,65],[51,53,47],[55,57,63],[57,59,63],[59,61,63],[66,87,77],[87,86,77],[86,85,84],[84,83,80],[83,82,80],[82,81,80],[80,79,78],[78,77,84],[77,76,66],[84,77,86],[76,75,74],[74,73,72],[72,71,68],[71,70,68],[70,69,68],[68,67,66],[80,78,84],[76,74,68],[74,72,68],[66,67,45],[67,68,46],[68,69,47],[69,70,48],[70,71,49],[71,72,50],[72,73,51],[73,74,52],[74,75,53],[75,76,54],[76,77,55],[77,78,56],[78,79,57],[79,80,58],[80,81,59],[81,82,60],[82,83,61],[83,84,62],[84,85,63],[85,86,64],[86,87,65],[87,66,44],[89,88,98],[88,109,99],[109,108,107],[107,106,105],[105,104,107],[104,103,107],[103,102,101],[101,100,99],[99,98,88],[98,97,91],[97,96,95],[95,94,93],[93,92,91],[91,90,89],[109,107,99],[103,101,107],[101,99,107],[98,91,89],[97,95,91],[130,131,121],[131,110,120],[110,111,112],[112,113,116],[113,114,116],[114,115,116],[116,117,118],[118,119,120],[120,121,131],[121,122,128],[122,123,124],[124,125,128],[125,126,128],[126,127,128],[128,129,130],[110,112,120],[116,118,112],[118,120,112],[121,128,130],[89,111,110],[90,112,111],[91,113,112],[92,114,113],[93,115,114],[94,116,115],[95,117,116],[96,118,117],[97,119,118],[98,120,119],[99,121,120],[100,122,121],[101,123,122],[102,124,123],[103,125,124],[104,126,125],[105,127,126],[106,128,127],[107,129,128],[108,130,129],[109,131,130],[88,110,131],[133,132,142],[132,153,143],[153,152,151],[151,150,149],[149,148,147],[147,146,145],[145,144,143],[143,142,132],[142,141,135],[141,140,139],[139,138,135],[138,137,135],[137,136,135],[135,134,133],[153,151,143],[151,149,147],[147,145,151],[145,143,151],[142,135,133],[174,175,165],[175,154,164],[154,155,156],[156,157,158],[158,159,156],[159,160,156],[160,161,162],[162,163,164],[164,165,175],[165,166,172],[166,167,168],[168,169,170],[170,171,168],[171,172,168],[172,173,174],[154,156,164],[160,162,156],[162,164,156],[165,172,174],[133,155,154],[134,156,155],[135,157,156],[136,158,157],[137,159,158],[138,160,159],[139,161,160],[140,162,161],[141,163,162],[142,164,163],[143,165,164],[144,166,165],[145,167,166],[146,168,167],[147,169,168],[148,170,169],[149,171,170],[150,172,171],[151,173,172],[152,174,173],[153,175,174],[132,154,175]],"points":[[-0.356452715,0.274636974,0.343069077],[0.378547269,0.274636974,0.343069077],[0.380698176,0.529455168,0.329127992],[0.378547269,0.526970645,0.326847479],[-0.373952713,0.274636974,0.343069077],[0.380698176,0.273612617,0.339246879],[-0.354301808,0.529455168,0.329127992],[-0.356452715,0.526970645,0.326847479],[0.374245455,0.745663229,0.388236637],[0.378547269,0.738983472,0.385203213],[0.361047271,0.274636974,0.343069077],[-0.354301808,0.273612617,0.339246879],[-0.360754529,0.745663229,0.388236637],[-0.356452715,0.738983472,0.385203213]],"inside":[[-0.374881795,0.506437858,0.465394675],[-0.366131796,0.753098523,0.427236497],[0.367678355,0.451073686,0.418925236],[0.367678355,0.479256774,0.475544262],[0.36188077,0.558458164,0.350741692],[0.35499999,0.520441353,0.474452346],[-0.365999994,0.497151121,0.512630403],[-0.376249991,0.504683891,0.465963334],[0.367499992,0.497122383,0.509885848],[0.357,0.405670216,0.383211315],[0.357,0.417670216,0.389211315],[0.357,0.426670216,0.392211315],[-0.378,0.405670216,0.386211315],[-0.378,0.420670216,0.371211315],[-0.378,0.429670216,0.380211315],[-0.357,0.279670216,0.335211315],[-0.357,0.294670216,0.356211315],[0.3675,0.276670216,0.329211315],[0.3675,0.276670216,0.335211315],[-0.3675,0.354670216,0.365211315],[-0.357,0.387670216,0.380211315],[0.378,0.351670216,0.359211315],[-0.3675,0.357670216,0.305211315],[-0.357,0.372670216,0.311211315],[0.378,0.351670216,0.299211315],[-0.3675,0.291670216,0.314211315],[0.357,0.303670216,0.317211315],[-0.3675,0.354670216,0.362211315],[-0.357,0.357670216,0.326211315]]} \ No newline at end of file diff --git a/surfaces/blender/tests/live/ram_knee.py b/surfaces/blender/tests/live/ram_knee.py index e32d3d1..272fe15 100644 --- a/surfaces/blender/tests/live/ram_knee.py +++ b/surfaces/blender/tests/live/ram_knee.py @@ -9,11 +9,10 @@ Run it with private BLENDER_USER_CONFIG, BLENDER_USER_EXTENSIONS and BLENDER_USE without them). is an absolute path; writes .result.json and .r3_.png (the bell crank at 0, -62.5 and -125) and exits 1 when a check failed. -The oracle is ram.Signed, three rays by majority. Its ray count is held by tests/fixtures/ram_rays.json: the rocker -plates as Imagination's jointlib builds them and points beside their bars that stand on the first ray short of an -edge or a vertex. One ray reads them inside a plate they stand clear of; the oracle as it is made reads none inside. -The same mesh is four closed bars joined into one, a side's two overlapping: the oracle reads it bar by bar, and no -point of a grid inside the bars, nor of the fixture's 29 inside points, reads outside. +The oracle is ram.Signed: a point is inside a part where the winding number of the part's faces about it is 0.5 or +more. tests/fixtures/ram_plates.json holds the rocker plates as Imagination's jointlib builds them, four closed bars +joined into one mesh, a side's two overlapping, and 29 points inside them: none reads outside. Nor does a point where +two welded boxes overlap, or inside a cube with a face left open. A clearance verdict is a sign, the gate's own. FLAT follows lodur:ruling:deterministic-bound-margin. The checks run inside one try: an uncaught error is a failed check that names its section, and the result file is always written. @@ -306,57 +305,45 @@ try: # plates and none is inside; where the plate is under the point the reading is the 0.0225 ys, zs = np.meshgrid(np.linspace(0.1, 0.9, 96), np.linspace(0.1, 0.7, 72)) plane = np.stack([np.full(ys.size, X_C), ys.ravel(), zs.ravel()], axis=1) - three, one = Signed(shells)("rocker.plate", plane), Signed(shells, rays=1)("rocker.plate", plane) + off_plates = Signed(shells)("rocker.plate", plane) def off(a, b): # each grid point's distance from the segment a -> b, across the axis a, b = np.array(a), np.array(b) t = np.clip(((plane[:, 1:] - a) @ (b - a)) / ((b - a) @ (b - a)), 0.0, 1.0) return np.linalg.norm(plane[:, 1:] - a - t[:, None] * (b - a), axis=1) under = (off(CRANK["rocker"], CRANK["p"]) < W_ROCKER - 0.005) | (off(CRANK["rocker"], CRANK["d"]) < W_ARM - 0.005) - RES["readings"]["FLAT"] = float(np.abs(three[under] - (SLAB_R[0] - X_C)).max()) - RES["readings"]["one ray: samples signed inside, of %d" % len(plane)] = int((one < 0).sum()) - check("three-rays: on a plane 0.0225 off the rocker plates no sample reads inside or nearer, and under a plate each reads the 0.0225", - (three >= SLAB_R[0] - X_C - FLAT).all() and under.sum() > 500 and RES["readings"]["FLAT"] < FLAT, [float(three.min()), int(under.sum()), RES["readings"]["FLAT"]]) - # against shells whose inside is known in closed form: a box and a disc, random points, each ray's edges and vertices among them + RES["readings"]["FLAT"] = float(np.abs(off_plates[under] - (SLAB_R[0] - X_C)).max()) + check("off-the-plates: on a plane 0.0225 off the rocker plates no sample reads inside or nearer, and under a plate each reads the 0.0225", + (off_plates >= SLAB_R[0] - X_C - FLAT).all() and under.sum() > 500 and RES["readings"]["FLAT"] < FLAT, [float(off_plates.min()), int(under.sum()), RES["readings"]["FLAT"]]) + # against a shell whose inside is known in closed form: a box, random points rng = np.random.default_rng(7) cloud = rng.uniform((-0.2, -0.2, 0.2), (0.2, 0.2, 1.25), (4000, 3)) core = Signed({"core": [box((0, 0, 0.725), (0.26, 0.28, 0.85))]})("core", cloud) exact = np.maximum.reduce([np.abs(cloud[:, 0]) - 0.13, np.abs(cloud[:, 1]) - 0.14, np.abs(cloud[:, 2] - 0.725) - 0.425]) - check("three-rays: 4000 random points about a box are signed as the box signs them", ((core < 0) == (exact < 0)).all(), int(((core < 0) != (exact < 0)).sum())) + check("box: 4000 random points about a box are signed as the box signs them", ((core < 0) == (exact < 0)).all(), int(((core < 0) != (exact < 0)).sum())) - # the ray count: the jointlib rocker plates, and points beside a bar, in its bounding box, aimed along the first ray at an edge or a vertex - fixture = json.loads((SURFACE / "tests" / "fixtures" / "ram_rays.json").read_text(encoding="utf-8")) - plates, aimed = {"plates": [(np.array(fixture["verts"]), fixture["faces"])]}, np.array(fixture["points"]) - made, single = Signed(plates)("plates", aimed), Signed(plates, rays=1)("plates", aimed) - RES["readings"]["jointlib plates: points one ray signs inside, of %d" % len(aimed)] = int((single < 0).sum()) - RES["readings"]["jointlib plates: points the oracle signs inside"] = int((made < 0).sum()) - # one ray reads all 14 inside; the oracle as made reads none. The bound on one ray's count is the geometric mean of 1 and 14 - check("ray-count: beside the jointlib rocker plates' bars, points on the first ray short of an edge or a vertex read outside by the oracle as it is made, inside by one ray", - (made > 0).all() and (single < 0).sum() >= 4, [int((made < 0).sum()), int((single < 0).sum())]) - - # the other way, which the gate's proof between samples leans on: no point inside the plates reads outside. The - # fixture's mesh is four closed bars, a side's two overlapping about the pivot; a point is truly inside where it is - # 0.001 or more inside one bar (each a convex prism: inside every face's plane). A grid 0.003 apart at three depths - # of each plate, and the fixture's 29 points. A count of points: shipped 0 (half a point, - # lodur:ruling:deterministic-bound-zero-reading), parity over the whole mesh (M-whole) 1,906; the check asks 0 - hulls = [] - for verts, faces in R._pieces(*plates["plates"][0]): - tri = np.array([[verts[i] for i in face[:3]] for face in faces]) - normal = np.cross(tri[:, 1] - tri[:, 0], tri[:, 2] - tri[:, 0]) - normal /= np.linalg.norm(normal, axis=1)[:, None] - level = (normal * tri[:, 0]).sum(axis=1) - out = (normal @ verts.mean(axis=0) - level) > 0 - normal[out], level[out] = -normal[out], -level[out] - hulls.append((normal, level)) - lo, hi = (np.array(fixture["verts"]).min(axis=0), np.array(fixture["verts"]).max(axis=0)) - cloud = np.array([(s * (SLAB_R[0] + 2 * HALF * f), y, z) for s in (-1.0, 1.0) for f in (0.2, 0.5, 0.8) - for y in np.arange(lo[1] + 0.0015, hi[1], 0.003) for z in np.arange(lo[2] + 0.0015, hi[2], 0.003)]) - deep = np.max([-(cloud @ normal.T - level).max(axis=1) for normal, level in hulls], axis=0) >= 0.001 - within = np.concatenate([cloud[deep], np.array(fixture["inside"])]) - missed = int((Signed(plates)("plates", within) >= 0).sum()) - RES["readings"]["jointlib plates: bars the mesh is read as"] = len(hulls) - RES["readings"]["jointlib plates: inside points read outside, of %d" % len(within)] = missed - check("inside-reads-inside: no point inside the jointlib rocker plates, where its bars overlap or not, reads outside by the oracle as it is made", - len(hulls) == 4 and int(deep.sum()) > 30000 and missed == 0, [len(hulls), int(deep.sum()), missed]) + # what the gate's proof between samples leans on: no point inside a part reads outside. The jointlib rocker plates + # are four closed bars in one mesh, a side's two overlapping about the pivot (crossing parity read the overlap + # outside); the fixture's 29 points are 0.001 or more inside a bar, 13 of them inside two. A count of points + fixture = json.loads((SURFACE / "tests" / "fixtures" / "ram_plates.json").read_text(encoding="utf-8")) + plates = Signed({"plates": [(np.array(fixture["verts"]), fixture["faces"])]})("plates", np.array(fixture["inside"])) + # two boxes cut through one another and welded at the corner they share; and a cube with its top left open + def wound(lo, hi): + verts = np.array([[x, y, z] for x in (lo[0], hi[0]) for y in (lo[1], hi[1]) for z in (lo[2], hi[2])], float) + return verts, [(0, 1, 3, 2), (4, 6, 7, 5), (0, 4, 5, 1), (2, 3, 7, 6), (0, 2, 6, 4), (1, 5, 7, 3)] + (v1, f1), (v2, f2) = wound((0, 0, 0), (1, 1, 1)), wound((0, 0, 0), (2, 0.5, 0.5)) + welded = (np.concatenate([v1, v2[1:]]), f1 + [tuple(i + 7 if i else 0 for i in face) for face in f2]) + cloud = rng.uniform(-0.2, 2.2, (6000, 3)) + truth = ((cloud >= 0) & (cloud <= 1)).all(axis=1) | ((cloud >= 0) & (cloud <= (2, 0.5, 0.5))).all(axis=1) + both = ((cloud >= 0) & (cloud <= (1, 0.5, 0.5))).all(axis=1) + got = Signed({"welded": [welded]})("welded", cloud) < 0 + inner = rng.uniform(0.001, 0.999, (4000, 3)) + opened = Signed({"open": [(v1, [face for face in f1 if face != (1, 5, 7, 3)])]})("open", inner) + RES["readings"]["jointlib plates: inside points read outside, of %d" % len(plates)] = int((plates >= 0).sum()) + RES["readings"]["welded boxes: points missigned, of %d (%d in the overlap)" % (len(cloud), int(both.sum()))] = int((got != truth).sum()) + RES["readings"]["open cube: inside points read outside, of %d" % len(inner)] = int((opened >= 0).sum()) + check("inside-reads-inside: no point inside the jointlib rocker plates' bars, in two welded boxes' overlap or in a cube with a face open reads outside, and none outside the boxes reads inside", + len(plates) == 29 and int((plates >= 0).sum()) == 0 and int(both.sum()) > 50 and int((got != truth).sum()) == 0 and int((opened >= 0).sum()) == 0, + [int((plates >= 0).sum()), int(both.sum()), int((got != truth).sum()), int((opened >= 0).sum())]) SECTION[0] = "seat" seat = np.concatenate([v for v, _ in shells["parent.seat"]]) diff --git a/surfaces/blender/tests/live/ram_knee.result.json b/surfaces/blender/tests/live/ram_knee.result.json index efb906b..34bb0b1 100644 --- a/surfaces/blender/tests/live/ram_knee.result.json +++ b/surfaces/blender/tests/live/ram_knee.result.json @@ -7,22 +7,17 @@ "detail": null }, { - "name": "three-rays: on a plane 0.0225 off the rocker plates no sample reads inside or nearer, and under a plate each reads the 0.0225", + "name": "off-the-plates: on a plane 0.0225 off the rocker plates no sample reads inside or nearer, and under a plate each reads the 0.0225", "ok": true, "detail": null }, { - "name": "three-rays: 4000 random points about a box are signed as the box signs them", + "name": "box: 4000 random points about a box are signed as the box signs them", "ok": true, "detail": null }, { - "name": "ray-count: beside the jointlib rocker plates' bars, points on the first ray short of an edge or a vertex read outside by the oracle as it is made, inside by one ray", - "ok": true, - "detail": null - }, - { - "name": "inside-reads-inside: no point inside the jointlib rocker plates, where its bars overlap or not, reads outside by the oracle as it is made", + "name": "inside-reads-inside: no point inside the jointlib rocker plates' bars, in two welded boxes' overlap or in a cube with a face open reads outside, and none outside the boxes reads inside", "ok": true, "detail": null }, @@ -113,23 +108,21 @@ "bell crank: least margin of a zoned pair, 251 steps uncapped": 0.000118, "bell crank: pairs": 60, "bell crank: pairs refused with nothing let": 19, - "bell crank: seconds, 49 steps capped": 0.946, + "bell crank: seconds, 49 steps capped": 0.8, "bell crank: zoned pairs": 20, "four bar: barrel inside the shin's clearance": -0.122, - "jointlib plates: bars the mesh is read as": 4, - "jointlib plates: inside points read outside, of 38477": 0, - "jointlib plates: points one ray signs inside, of 14": 14, - "jointlib plates: points the oracle signs inside": 0, + "jointlib plates: inside points read outside, of 29": 0, "moved x: both": -0.0543, "moved x: the coupler at x 0.25, inside the horn's 0.23..0.31": -0.02, "moved x: the rocker at x 0.25, inside the bracket's 0.13..0.35": -0.0543, - "one ray: samples signed inside, of 6912": 0, + "open cube: inside points read outside, of 4000": 0, "search: candidates": 13824, "search: pass the gates before clearance": 78, "search: refused on their own parts": 21, - "search: seconds": 32.7, + "search: seconds": 34.5, "search: worlds built": 22, - "the base clevis's foot inside the thigh": -0.01 + "the base clevis's foot inside the thigh": -0.01, + "welded boxes: points missigned, of 6000 (91 in the overlap)": 0 }, "zones": { "barrel[0] | parent.seat": { @@ -503,9 +496,9 @@ } }, "renders": [ - "F:/aeth-wt/fable-ramlows/scratch/out/live5.r3_0.png", - "F:/aeth-wt/fable-ramlows/scratch/out/live5.r3_62p5.png", - "F:/aeth-wt/fable-ramlows/scratch/out/live5.r3_125.png" + "F:/aeth-wt/fable-ramlows/scratch/out/h3f.r3_0.png", + "F:/aeth-wt/fable-ramlows/scratch/out/h3f.r3_62p5.png", + "F:/aeth-wt/fable-ramlows/scratch/out/h3f.r3_125.png" ], "ok": true } \ No newline at end of file diff --git a/surfaces/blender/tests/test_ram.py b/surfaces/blender/tests/test_ram.py index 2a94872..2074ff8 100644 --- a/surfaces/blender/tests/test_ram.py +++ b/surfaces/blender/tests/test_ram.py @@ -83,6 +83,40 @@ def yz(p, x=0.0): return (x, float(p[0]), float(p[1])) +def block(lo, hi): + """A box as a mesh: 8 vertices and 12 triangles wound counterclockwise seen from outside.""" + lo, hi = np.asarray(lo, float), np.asarray(hi, float) + verts = np.array([[x, y, z] for x in (lo[0], hi[0]) for y in (lo[1], hi[1]) for z in (lo[2], hi[2])]) + quads = ((0, 1, 3, 2), (4, 6, 7, 5), (0, 4, 5, 1), (2, 3, 7, 6), (0, 2, 6, 4), (1, 5, 7, 3)) + return verts, np.array([t for a, b, c, d in quads for t in ((a, b, c), (a, c, d))]) + + +def joined(first, second, weld): + """Two meshes as one; with `weld`, vertices of the second that stand on one of the first take its index.""" + (v1, t1), (v2, t2) = first, second + verts, index = [tuple(p) for p in v1], [] + for p in map(tuple, v2): + if weld and p in verts: + index.append(verts.index(p)) + else: + index.append(len(verts)) + verts.append(p) + return np.array(verts), np.concatenate([t1, np.array(index)[t2]]) + + +def staircase(): + """A prism of three steps along y from 0 to 1: under z = 1 for x in 0..1, z = 2 for 1..2, z = 3 for 2..3.""" + profile = ((0, 0), (3, 0), (3, 3), (2, 3), (2, 2), (1, 2), (1, 1), (0, 1)) # (x, z) + verts = np.array([(x, y, z) for y in (0.0, 1.0) for x, z in profile], float) + tris = [] + for k in range(8): + n = (k + 1) % 8 + tris += [(k, n + 8, n), (k, k + 8, n + 8)] + for a, b, c in ((0, 1, 6), (0, 6, 7), (1, 4, 5), (1, 5, 6), (1, 2, 3), (1, 3, 4)): # the cap at y = 0, and at y = 1 turned over + tris += [(a, b, c), (a + 8, c + 8, b + 8)] + return verts, np.array(tris) + + def grid(lo, hi, counts): lo, hi = np.asarray(lo, float), np.asarray(hi, float) axes = [np.linspace(lo[k], hi[k], n) if n > 1 else np.array([(lo[k] + hi[k]) / 2]) for k, n in enumerate(counts)] @@ -505,6 +539,7 @@ ZONED = 2.2e-10 # a rocker sample against its own plates: shipped 0 (hal BESIDE = 1.2e-10 # a wall 0.02 beside the coupler, read at the nearest sample: shipped 0 (half an ulp of 0.0242, 1.7e-18), B1 (the proof by the nearer end's reading less the span, which halves and reads beside the wall) 0.00423 off, separation 4.9e7 each side FLOOR_UNDER = 0.319 # how near the axis a wall held outside reads as touched, in spacing / 64: shipped under 0.451, FINE 128 under 0.2255, separation 1.41 each side FLOOR_OVER = 0.638 # shipped under 0.451, FINE 32 under 0.902, separation 1.41 each side +WHOLE = 3.8e-4 # a winding number against the count or share a hand value states: shipped 6.3e-6 at most (the plates; the angles are single precision), W1 (the denominator's a.b term without the third length) 0.0224 off on the open cube's axis, separation 60 each side SPAN_RAM = 0.848 # the ram's span with its base 0.1 from the rocker's pivot: shipped 0.5390 (about that pivot), the span about the knee's pivot 1.3347, separation 1.57 each side @@ -1268,18 +1303,53 @@ class Refusals(unittest.TestCase): self.assertEqual((caught.exception.gate, caught.exception.pin), ("arm", "b")) self.assertIn(f"arm at {caught.exception.angle:g} deg (pin b)", str(caught.exception)) - def test_a_mesh_is_read_piece_by_piece(self): - # Signed's split: two tetrahedra in one mesh, the second's vertices listed first and its faces interleaved, - # come back as two closed pieces with their own vertices; a mesh of one piece comes back whole - tet = [(0, 1, 2), (0, 1, 3), (0, 2, 3), (1, 2, 3)] - a, b = np.array([(0, 0, 0), (1, 0, 0), (0, 1, 0), (0, 0, 1)], float), np.array([(0.2, 0.2, 0.2), (5, 0, 0), (0, 5, 0), (0, 0, 5)], float) - faces = [face for pair in zip([tuple(i + 4 for i in f) for f in tet], tet) for face in pair] - pieces = R._pieces(np.concatenate([b, a]), faces) - self.assertEqual(len(pieces), 2) - for (verts, got), want in zip(pieces, (a, b)): - self.assertEqual((verts.tolist(), sorted(got)), (want.tolist(), tet)) - whole = R._pieces(a, tet) - self.assertEqual((len(whole), whole[0][0].tolist(), whole[0][1]), (1, a.tolist(), tet)) + def test_overlapping_solids_wind_by_their_count(self): + # two boxes that cut through one another in one mesh, each with its own vertices, then sharing the one index + # at the corner they have in common (all a merge by distance welds): the winding number is the count of + # boxes about the point, 2 in the overlap, where crossing parity read outside + big, small = block((0, 0, 0), (1, 1, 1)), block((0, 0, 0), (2, 0.5, 0.5)) + pts = np.random.default_rng(1).uniform(-0.2, 2.2, (6000, 3)) + count = sum(((pts >= lo) & (pts <= hi)).all(axis=1).astype(int) for lo, hi in (((0, 0, 0), (1, 1, 1)), ((0, 0, 0), (2, 0.5, 0.5)))) + self.assertGreater(int((count == 2).sum()), 50) + for weld in (False, True): + verts, tris = joined(big, small, weld) + self.assertEqual(len(verts), 15 if weld else 16) + self.assertLess(float(np.abs(R.winding(verts, tris, pts) - count).max()), WHOLE, weld) + + def test_the_plates_overlapping_bars_wind_by_their_count(self): + # the jointlib rocker plates: four closed bars in one mesh, a side's two overlapping. Every inside point of + # the fixture winds 1, or 2 where two bars overlap + fixture = json.loads((SURFACE / "tests" / "fixtures" / "ram_plates.json").read_text(encoding="utf-8")) + w = R.winding(fixture["verts"], fixture["faces"], fixture["inside"]) + self.assertLess(float(np.abs(w - np.round(w)).max()), WHOLE) + self.assertEqual((int((np.round(w) == 1).sum()), int((np.round(w) == 2).sum())), (16, 13)) + + def test_a_staircase_winds_whole(self): + # a nonconvex prism of three steps, which a line crosses up to six times: 1 inside, 0 outside + verts, tris = staircase() + g = np.arange(-0.375, 3.5, 0.25) + pts = np.array([(x, y, z) for x in g for y in (-0.25, 0.125, 0.5, 0.875, 1.25) for z in g]) + truth = (pts[:, 1] > 0) & (pts[:, 1] < 1) & (pts[:, 0] > 0) & (pts[:, 0] < 3) & (pts[:, 2] > 0) & (pts[:, 2] < np.ceil(pts[:, 0])) + self.assertGreater(min(int(truth.sum()), int((~truth).sum())), 200) + self.assertLess(float(np.abs(R.winding(verts, tris, pts) - truth).max()), WHOLE) + + def test_an_open_cube_winds_by_what_its_hole_takes(self): + # a unit cube less its top face: about a point on the hole's axis the winding number is 1 less the hole's + # share of the sphere inside, and that share outside, 4 asin(a^2 / (a^2 + h^2)) of 4 pi for a square of half + # side a seen from h off its centre. So it is over 0.5 everywhere inside and under 0.5 over the hole, and + # passes through 0.5 on the hole's plane, where no face is. Less one triangle of the top it is the same + verts, tris = block((0, 0, 0), (1, 1, 1)) + top = [k for k, t in enumerate(tris) if (verts[t][:, 2] == 1.0).all()] + self.assertEqual(len(top), 2) + z = np.array((0.5, 0.9, 0.999, 1.001, 1.1, 1.5)) + share = np.arcsin(0.25 / (0.25 + (1.0 - z) ** 2)) / math.pi + w = R.winding(verts, np.delete(tris, top, axis=0), np.stack([np.full(6, 0.5), np.full(6, 0.5), z], axis=1)) + self.assertLess(float(np.abs(w - np.where(z < 1, 1.0 - share, share)).max()), WHOLE) + self.assertTrue((w[:3] > 0.5).all() and (w[3:] < 0.5).all(), w.tolist()) # 0.001 under the plane 0.5009, 0.001 over it 0.4991 + # no point inside either open cube, down to 0.001 from its faces and its hole, winds under 0.5: a count + inner = np.random.default_rng(3).uniform(0.001, 0.999, (4000, 3)) + for gone in (top, top[:1]): + self.assertEqual(int((R.winding(verts, np.delete(tris, gone, axis=0), inner) < 0.5).sum()), 0) def test_no_blender(self): source = (SURFACE / "brokkr_kitbash" / "ram.py").read_text(encoding="utf-8") -- 2.47.3 From 3b56cdec6e4eff8bdbe996659729e8ecb53c64a3 Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Thu, 3 Dec 2026 01:35:12 +0100 Subject: [PATCH 10/11] brokkr_kitbash.ram: Signed refuses a part that is open or wound inside out, by its solid; the depth is to exposed faces solids() splits a part into edge-connected solids and refuses one with an edge no face runs the other way (the count) or of negative volume (the solid, its first face, the volume). Nothing is repaired. inside() holds the 0.5 bound, pinned in the unit suite on a test-only open cube (0.527 and 0.473 about the hole). Inside, the depth is read from a tree of the faces whose centroid, set off along the normal, is not inside the part; outside, from all faces as before. Co-Authored-By: Claude Fable 5.2 --- surfaces/blender/brokkr_kitbash/ram.py | 94 ++++++++++++++++++++------ surfaces/blender/tests/test_ram.py | 57 ++++++++++++++++ 2 files changed, 132 insertions(+), 19 deletions(-) diff --git a/surfaces/blender/brokkr_kitbash/ram.py b/surfaces/blender/brokkr_kitbash/ram.py index f27ac23..d5fa6f5 100644 --- a/surfaces/blender/brokkr_kitbash/ram.py +++ b/surfaces/blender/brokkr_kitbash/ram.py @@ -25,6 +25,8 @@ the coupler bar at c's, the ram at a's plus each of `offsets`. record(m, ram), from_record the JSON record a rig or runtime drives from swept(fit, body, ...) points of the swept ram's surface in a body's rest frame winding(vertices, triangles, points) the generalized winding number of a triangle soup about points + inside(vertices, triangles, points) whether points are inside it: the number is 0.5 or more + solids(part, vertices, faces) the closed, outward wound solids of a part, or the refusal Signed(shells, cap) the distance oracle over meshes, signed by the winding number Clearance. The record names the mechanism's `parts`, each a piece of one body (part -> the body whose rest frame @@ -754,11 +756,12 @@ def winding(vertices, triangles, points): 2013): the triangles' signed solid angles, summed, over 4 pi. A triangle counts positive from the side its normal points away from (counterclockwise seen from outside). About a closed mesh it is the whole number of times the surface wraps the point: 0 outside, 1 inside, 2 where two solids of one mesh overlap, whether they share vertices - or cut through one another. About an open mesh it is a fraction that falls off toward the hole: the closed - mesh's number less the missing faces' share of the sphere about the point, so across a flat hole it passes - through 0.5 on the hole's own plane. The plain sum: a point costs every triangle. The corners' offsets from the - point are taken in double precision and the angles in single (2.4 times the pace): the number is good to 1e-5 a - millimetre off a face and to 1e-2 at 1e-7 off it, and nearer than that its side of the face is not held.""" + or cut through one another. About an open mesh it is a fraction that falls off toward the hole (the closed + mesh's number less the missing faces' share of the sphere about the point), and about a mesh wound inside out + it is the negative: neither has an inside to read, and Signed refuses both. The plain sum: a point costs every + triangle. The corners' offsets from the point are taken in double precision and the angles in single (2.4 times + the pace): the number is good to 1e-5 a millimetre off a face and to 1e-2 at 1e-7 off it, and nearer than that + its side of the face is not held.""" v, t, pts = np.asarray(vertices, dtype=float).reshape(-1, 3), np.asarray(triangles, dtype=int).reshape(-1, 3), np.asarray(points, dtype=float).reshape(-1, 3) A, B, C = (np.ascontiguousarray(v[t[:, k]].T) for k in range(3)) # each (3, F): a corner of every triangle out, step = np.zeros(len(pts)), max(1, 32768 // max(len(t), 1)) # a block of pairs that stays in cache: 3.1 times the pace of 400,000 @@ -771,17 +774,61 @@ def winding(vertices, triangles, points): return out / (2.0 * math.pi) +def inside(vertices, triangles, points): + """Whether each of `points` is inside the triangle soup: its winding number is 0.5 or more. About the closed, + outward wound solids `solids` passes the number is whole and any bound over 0 and up to 1 reads the same; 0.5 + is the bound because it is the middle, the farthest from both whole numbers the single-precision sum rounds + about.""" + return winding(vertices, triangles, points) >= 0.5 + + +def solids(part, vertices, faces): + """The solid each face of a part belongs to (faces joined across an edge are one solid), or a RamError where + the part has no inside to sign: a solid with an edge no face runs the other way (a boundary edge, or two faces + wound against each other across it) is open, and a closed solid of negative volume is wound inside out. + Nothing is repaired. A cavity cut as its own inward shell is such a solid and is refused with the rest.""" + v = np.asarray(vertices, dtype=float).reshape(-1, 3) + owner, edges = list(range(len(faces))), {} + + def root(k): + while owner[k] != k: + owner[k] = k = owner[owner[k]] + return k + + for k, face in enumerate(faces): + for i, j in zip(face, tuple(face[1:]) + tuple(face[:1])): + there = edges.setdefault((min(i, j), max(i, j)), [k, 0]) + there[1] += 1 if i < j else -1 + owner[root(k)] = root(there[0]) + of = np.array([root(k) for k in range(len(faces))], dtype=int) + names = {r: n for n, r in enumerate(dict.fromkeys(of.tolist()))} # solids numbered in the order of their first faces + unmatched = {} + for first, balance in edges.values(): + if balance: + unmatched[names[of[first]]] = unmatched.get(names[of[first]], 0) + 1 + for n, count in sorted(unmatched.items()): + raise RamError("mesh", "signed", f"part {part!r} is open: solid {n} of {len(names)} has {count} edge{'s' if count > 1 else ''} no face runs the other way") + of = np.array([names[r] for r in of.tolist()], dtype=int) + fan = np.array([(k, face[0], face[n], face[n + 1]) for k, face in enumerate(faces) for n in range(1, len(face) - 1)], dtype=int).reshape(-1, 4) + volume = np.bincount(of[fan[:, 0]], (v[fan[:, 1]] * np.cross(v[fan[:, 2]], v[fan[:, 3]])).sum(axis=1) / 6.0, len(names)) + for n in np.flatnonzero(volume < 0.0): + raise RamError("mesh", "signed", f"part {part!r} is wound inside out: solid {n} of {len(names)} ({int((of == n).sum())} faces from face {int(np.flatnonzero(of == n)[0])}) has volume {volume[n]:.3g}") + return of + + class Signed: - """The distance oracle over meshes: distance(part, points) is the nearest face's distance, negative where the - point is inside the part (its depth below the nearest face), capped at `cap` outside only. shells: part -> - [(vertices (N, 3), faces)], in the rest frame of the part's body, faces wound counterclockwise seen from - outside. Inside is where the winding number of all the part's faces (winding; a face of more than three corners - as a fan) is 0.5 or more: solids that overlap, in one mesh or several, welded or not, read inside wherever any - is. A mesh wound inside out reads outside everywhere. An open mesh is read as its faces wind: no point is - refused, and a point inside by a flat hole reads inside up to the hole's plane, where the sign turns with no - face there, so the reading steps by twice the distance to the hole's rim. The depth is to the nearest face of - any of the part's meshes, one buried in another included. An unknown part raises. Needs Blender's mathutils - (BVHTree) for the nearest face.""" + """The distance oracle over meshes: distance(part, points) is the distance to the part's surface, negative + where the point is inside the part (its depth), capped at `cap` outside only. shells: part -> [(vertices + (N, 3), faces)], in the rest frame of the part's body. Every solid of a part (`solids`) is closed and wound + counterclockwise seen from outside: a part with an open or an inside-out solid is refused when the oracle is + made, by a RamError that names the part, the solid and the edge count or the volume. Inside is where `inside` + says, by the winding number of all the part's faces (a face of more than three corners as a fan): solids that + overlap, in one mesh or several, welded or not, read inside wherever any is. The depth is to the nearest + exposed face: one whose centroid, set 1e-6 of the part's extent off the face along its normal, is not inside + the part. A face buried in another solid is not the part's surface and is left out. A face that crosses + another solid is taken whole by where its centroid is: left out, the depth by it reads greater than it is; + kept, a point by its buried stretch reads shallower than the part's surface is. Outside, the distance is to + the nearest face of all. An unknown part raises. Needs Blender's mathutils (BVHTree) for the nearest face.""" def __init__(self, shells, cap=None): from mathutils import Vector @@ -795,16 +842,25 @@ class Signed: faces += [tuple(at + int(i) for i in face) for face in f] at += len(v) verts = np.concatenate(verts) + solids(part, verts, faces) fan = np.array([(face[0], face[k], face[k + 1]) for face in faces for k in range(1, len(face) - 1)], dtype=int) - self.parts[part] = (BVHTree.FromPolygons(verts.tolist(), faces, epsilon=0.0), verts, fan) + normal = np.zeros((len(faces), 3)) + np.add.at(normal, np.repeat(np.arange(len(faces)), [len(face) - 2 for face in faces]), np.cross(verts[fan[:, 1]] - verts[fan[:, 0]], verts[fan[:, 2]] - verts[fan[:, 0]])) + size = np.linalg.norm(normal, axis=1) + flat = np.flatnonzero(size > 0.0) # a face of no area has no side to be exposed on + off = np.array([verts[list(faces[k])].mean(axis=0) for k in flat]) + 1e-6 * np.linalg.norm(np.ptp(verts, axis=0)) * normal[flat] / size[flat, None] + exposed = [faces[k] for k in flat[~inside(verts, fan, off)]] + if not exposed: + raise RamError("mesh", "signed", f"part {part!r} has no exposed face") + self.parts[part] = (BVHTree.FromPolygons(verts.tolist(), faces, epsilon=0.0), BVHTree.FromPolygons(verts.tolist(), exposed, epsilon=0.0), verts, fan) def __call__(self, part, pts): pts = np.asarray(pts, dtype=float).reshape(-1, 3) self.asked += len(pts) - tree, verts, fan = self.parts[part] + tree, surface, verts, fan = self.parts[part] out = np.full(len(pts), math.inf if self.cap is None else self.cap) - for i in np.flatnonzero(winding(verts, fan, pts) >= 0.5): - out[i] = -tree.find_nearest(self.vector(pts[i]))[3] + for i in np.flatnonzero(inside(verts, fan, pts)): + out[i] = -surface.find_nearest(self.vector(pts[i]))[3] for i in np.flatnonzero(out >= 0): hit = tree.find_nearest(self.vector(pts[i]), self.cap) if self.cap else tree.find_nearest(self.vector(pts[i])) if hit[0] is not None: diff --git a/surfaces/blender/tests/test_ram.py b/surfaces/blender/tests/test_ram.py index 2074ff8..3cb02f5 100644 --- a/surfaces/blender/tests/test_ram.py +++ b/surfaces/blender/tests/test_ram.py @@ -1351,6 +1351,63 @@ class Refusals(unittest.TestCase): for gone in (top, top[:1]): self.assertEqual(int((R.winding(verts, np.delete(tris, gone, axis=0), inner) < 0.5).sum()), 0) + def test_inside_is_half_a_winding_or_more(self): + # the bound, on a mesh only a test may read: a unit cube less its top winds 0.527 on the hole's axis 0.03 + # under the hole's plane and 0.473 as far over it (1 less, and plainly, asin(0.25 / 0.2509) / pi). A bound + # of 0.45 reads the point over the hole inside and one of 0.55 the point under it outside: 0.473 and 0.527 + # stand at the geometric means of 0.5 and those two, 1.06 from each, all the room there is between them + verts, tris = block((0, 0, 0), (1, 1, 1)) + opened = np.delete(tris, [k for k, t in enumerate(tris) if (verts[t][:, 2] == 1.0).all()], axis=0) + pts = np.array([(0.5, 0.5, 0.97), (0.5, 0.5, 1.03)]) + w = R.winding(verts, opened, pts) + self.assertLess(float(np.abs(w - (0.5270, 0.4730)).max()), 1e-4) + self.assertEqual(R.inside(verts, opened, pts).tolist(), [True, False]) + # about closed solids the number is whole, so there the bound reads as any over 0 and up to 1 would + cloud = np.random.default_rng(5).uniform(-0.2, 1.2, (500, 3)) + self.assertEqual(R.inside(verts, tris, cloud).tolist(), ((cloud > 0) & (cloud < 1)).all(axis=1).tolist()) + + def test_solids_are_the_closed_pieces_of_a_part(self): + # the jointlib rocker plates are four closed bars, each wound outward: none is refused. Two boxes that cut + # through one another are two solids, sharing a corner's index or not + fixture = json.loads((SURFACE / "tests" / "fixtures" / "ram_plates.json").read_text(encoding="utf-8")) + self.assertEqual(np.bincount(R.solids("plates", fixture["verts"], fixture["faces"])).tolist(), [84, 84, 84, 84]) + for weld in (False, True): + verts, tris = joined(block((0, 0, 0), (1, 1, 1)), block((0, 0, 0), (2, 0.5, 0.5)), weld) + self.assertEqual(R.solids("boxes", verts, tris).tolist(), [0] * 12 + [1] * 12) + self.assertEqual(R.solids("stairs", *staircase()).tolist(), [0] * 28) + + def test_an_open_part_is_refused_by_its_edge_count(self): + # a cube less a triangle has 3 edges no face runs back along, less its top 4, less two adjacent faces 6 + # (the edge between them is gone with both); one triangle turned over leaves its 3 edges run twice one way + verts, tris = block((0, 0, 0), (1, 1, 1)) + top = [k for k, t in enumerate(tris) if (verts[t][:, 2] == 1.0).all()] + side = [k for k, t in enumerate(tris) if (verts[t][:, 1] == 1.0).all()] + turned_over = tris.copy() + turned_over[0] = tris[0][::-1] + less = lambda gone: (verts, np.delete(tris, gone, axis=0)) + for name, mesh, count, solid in (("a triangle off", less(top[:1]), 3, "solid 0 of 1"), ("the top off", less(top), 4, "solid 0 of 1"), ("two faces off", less(top + side), 6, "solid 0 of 1"), + ("a triangle turned over", (verts, turned_over), 3, "solid 0 of 1"), ("the second of two open", joined(block((2, 0, 0), (3, 1, 1)), less(top), False), 4, "solid 1 of 2")): + with self.assertRaises(R.RamError, msg=name) as caught: + R.solids("cube", *mesh) + self.assertEqual(caught.exception.gate, "signed", name) + self.assertIn(f"part 'cube' is open: {solid} has {count} edges no face runs the other way", str(caught.exception), name) + + def test_an_inside_out_solid_is_refused_by_name(self): + # a cube with every face turned over, or mirrored with its winding kept, has volume -1. A cube with a bar + # of half its volume turned over beside it has a positive volume in all: the bar is refused as its solid + verts, tris = block((0, 0, 0), (1, 1, 1)) + for name, v, t in (("turned over", verts, tris[:, ::-1]), ("mirrored", verts * (-1, 1, 1), tris)): + with self.assertRaises(R.RamError, msg=name) as caught: + R.solids("cube", v, t) + self.assertIn("part 'cube' is wound inside out: solid 0 of 1 (12 faces from face 0) has volume -1", str(caught.exception), name) + bar_v, bar_t = block((2, 0, 0), (3, 1, 0.5)) + mixed = joined((verts, tris), (bar_v, bar_t[:, ::-1]), False) + self.assertAlmostEqual(sum(float(mixed[0][a] @ np.cross(mixed[0][b], mixed[0][c])) / 6.0 for a, b, c in mixed[1]), 0.5, places=12) + with self.assertRaises(R.RamError) as caught: + R.solids("pair", *mixed) + self.assertIn("part 'pair' is wound inside out: solid 1 of 2 (12 faces from face 12) has volume -0.5", str(caught.exception)) + self.assertEqual(R.solids("pair", *joined((bar_v, bar_t), (verts, tris), False)).tolist(), [0] * 12 + [1] * 12) + def test_no_blender(self): source = (SURFACE / "brokkr_kitbash" / "ram.py").read_text(encoding="utf-8") for word in ("bpy", "np.gradient"): -- 2.47.3 From 18adf73a27836ad4e4c6cfd2f5903659bebaa2f8 Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Thu, 3 Dec 2026 01:35:12 +0100 Subject: [PATCH 11/11] live ram_knee: open and inside-out parts are refused by reason; a buried box does not hide the cube's depth; docs The open cube's reading is cut for five refusals. The search's seconds are a reading, stated in docs/kitbash.md as a quiet-machine figure beside the loaded ones. Co-Authored-By: Claude Fable 5.2 --- surfaces/blender/docs/kitbash.md | 36 +++++++++++---- surfaces/blender/tests/live/ram_knee.py | 46 +++++++++++++++---- .../blender/tests/live/ram_knee.result.json | 43 ++++++++++++++--- 3 files changed, 101 insertions(+), 24 deletions(-) diff --git a/surfaces/blender/docs/kitbash.md b/surfaces/blender/docs/kitbash.md index 8eb7ab9..1f974ed 100644 --- a/surfaces/blender/docs/kitbash.md +++ b/surfaces/blender/docs/kitbash.md @@ -1036,14 +1036,28 @@ about the point, over 4 pi: about a closed mesh the whole number of times the su inside, 2 where two solids overlap. A point is inside the part at 0.5 or more. The joint library's plates are one mesh of four bars, a side's two overlapping about the pivot (`tests/fixtures/ram_plates.json`, with 29 points inside them, 13 inside two bars): each reads inside, as does the overlap of two boxes welded at a corner and a -staircase prism a line crosses six times. Faces are wound counterclockwise seen from outside; a mesh wound inside -out reads outside everywhere. An open mesh is answered, not refused: the number is the closed mesh's less the -missing faces' share of the sphere about the point, so a cube with a face open reads inside up to the hole's plane -(0.5009 at 0.001 under the centre of a unit face) and the sign turns on that plane with no face there. The gate's -proof between samples assumes a distance changes by no more than the way between two points, which holds across a -face and not across a hole: a part with a hole the axis may reach is closed before it is given. The depth is to the -nearest face of any of the part's meshes, one buried inside another included, so inside two overlapping solids a -point may read shallower than its depth below their union. +staircase prism a line crosses six times. + +`Signed` checks what the winding number needs before it answers, and refuses a part by its reason when the oracle is +made (`ram.solids`, a `RamError` at gate `signed`). A part's faces fall into solids, the faces joined across an +edge. Every solid is closed: each edge one face runs is run the other way by another, and a solid with an edge +that is not (a boundary edge, or two faces wound against each other) is refused with the count of such edges. Every +solid is wound counterclockwise seen from outside: one of negative volume is refused with its number, its first +face and its volume, a turned-over bar beside a whole cube included, whose volume in all is positive. Nothing is +repaired or guessed. The shipped plates are four closed solids of 84 faces each, and the 12 parts of both R-3 knees +pass. What it gives up: a part exported open is capped before it is given, a part mirrored by a negative scale has +its faces turned back, and a cavity cut as its own inward shell is refused with the inside-out solids. + +With every solid closed the number is whole, so `ram.inside` reads the same at any bound over 0 and up to 1; 0.5 is +pinned in the unit suite on a test-only open cube, where the number is 0.527 under the hole and 0.473 over it. + +Outside, the distance is to the nearest face of all. Inside, the depth is to the nearest exposed face: one whose +centroid, set 1e-6 of the part's extent off the face along its normal, is not inside the part. A face buried in +another of the part's solids is left out, so a pin sunk 0.056 into a slab with a thin sheet buried along it reads +0.056 and is refused by a zone of depth 0.01. A face that crosses another solid is kept or left whole by where its +centroid is, not split: left out, the depth by it reads greater than it is, which the gate takes as a refusal; +kept, a point by its buried stretch reads shallower than the union's surface is (a boss through a wall: 0.500 for +0.502 and 0.539 for 0.583 in the live readings). | drive | reading | | --- | --- | @@ -1061,7 +1075,11 @@ zones (the own plates, stated with no slack, to the floor); the samples alone to (20,000) is 30 to 40 s. On the meshes the bell crank's 60 pairs at 49 steps took 0.80 to 1.00 s capped (two runs), the winding number as the plain sum over a part's 124 to 408 triangles in numpy (single precision over double offsets, blocks of 32,768 pairs) and the depth a Python loop of BVH queries, and the 13,824-candidate search with its 22 -worlds 34.5 and 38.5 s (two runs). With the angles in double precision the search took 47.7 to 47.9 s (three runs). +worlds 34.5 and 38.5 s (two runs) on a quiet machine. With the angles in double precision the search took 47.7 to +47.9 s (three runs). The live result reports the search's seconds as a reading and no check holds it: beside other +agents' Blenders at full load the same search took 61 to 94 s. With the refusals and +the exposed faces found as each of its 22 worlds is made it took 66.8 s, run after 59.3 s for the oracle before +them under that load (one pair); finding the solids of a 336-face part takes 1.6 ms. ## The actions diff --git a/surfaces/blender/tests/live/ram_knee.py b/surfaces/blender/tests/live/ram_knee.py index 272fe15..d503e2c 100644 --- a/surfaces/blender/tests/live/ram_knee.py +++ b/surfaces/blender/tests/live/ram_knee.py @@ -12,7 +12,8 @@ without them). is an absolute path; writes .result.json and .r3_ The oracle is ram.Signed: a point is inside a part where the winding number of the part's faces about it is 0.5 or more. tests/fixtures/ram_plates.json holds the rocker plates as Imagination's jointlib builds them, four closed bars joined into one mesh, a side's two overlapping, and 29 points inside them: none reads outside. Nor does a point where -two welded boxes overlap, or inside a cube with a face left open. +two welded boxes overlap. A part that is open or wound inside out is refused when the oracle is made, and the depth +is to the part's surface: a face buried in another of the part's solids is not read. A clearance verdict is a sign, the gate's own. FLAT follows lodur:ruling:deterministic-bound-margin. The checks run inside one try: an uncaught error is a failed check that names its section, and the result file is always written. @@ -326,7 +327,7 @@ try: # outside); the fixture's 29 points are 0.001 or more inside a bar, 13 of them inside two. A count of points fixture = json.loads((SURFACE / "tests" / "fixtures" / "ram_plates.json").read_text(encoding="utf-8")) plates = Signed({"plates": [(np.array(fixture["verts"]), fixture["faces"])]})("plates", np.array(fixture["inside"])) - # two boxes cut through one another and welded at the corner they share; and a cube with its top left open + # two boxes cut through one another and welded at the corner they share def wound(lo, hi): verts = np.array([[x, y, z] for x in (lo[0], hi[0]) for y in (lo[1], hi[1]) for z in (lo[2], hi[2])], float) return verts, [(0, 1, 3, 2), (4, 6, 7, 5), (0, 4, 5, 1), (2, 3, 7, 6), (0, 2, 6, 4), (1, 5, 7, 3)] @@ -336,14 +337,43 @@ try: truth = ((cloud >= 0) & (cloud <= 1)).all(axis=1) | ((cloud >= 0) & (cloud <= (2, 0.5, 0.5))).all(axis=1) both = ((cloud >= 0) & (cloud <= (1, 0.5, 0.5))).all(axis=1) got = Signed({"welded": [welded]})("welded", cloud) < 0 - inner = rng.uniform(0.001, 0.999, (4000, 3)) - opened = Signed({"open": [(v1, [face for face in f1 if face != (1, 5, 7, 3)])]})("open", inner) RES["readings"]["jointlib plates: inside points read outside, of %d" % len(plates)] = int((plates >= 0).sum()) RES["readings"]["welded boxes: points missigned, of %d (%d in the overlap)" % (len(cloud), int(both.sum()))] = int((got != truth).sum()) - RES["readings"]["open cube: inside points read outside, of %d" % len(inner)] = int((opened >= 0).sum()) - check("inside-reads-inside: no point inside the jointlib rocker plates' bars, in two welded boxes' overlap or in a cube with a face open reads outside, and none outside the boxes reads inside", - len(plates) == 29 and int((plates >= 0).sum()) == 0 and int(both.sum()) > 50 and int((got != truth).sum()) == 0 and int((opened >= 0).sum()) == 0, - [int((plates >= 0).sum()), int(both.sum()), int((got != truth).sum()), int((opened >= 0).sum())]) + check("inside-reads-inside: no point inside the jointlib rocker plates' bars or in two welded boxes' overlap reads outside, and none outside the boxes reads inside", + len(plates) == 29 and int((plates >= 0).sum()) == 0 and int(both.sum()) > 50 and int((got != truth).sum()) == 0, + [int((plates >= 0).sum()), int(both.sum()), int((got != truth).sum())]) + + # a part with no inside to sign is refused when the oracle is made, by its reason: a cube with its top off, or + # two adjacent faces off, is open; a cube turned over, mirrored, or a turned-over bar beside a whole cube (a + # positive volume in all) is wound inside out. Every part of both knees made here passed the same two checks + turned = [face[::-1] for face in f1] + said = {} + for name, made in (("top off", [(v1, [face for face in f1 if face != (1, 5, 7, 3)])]), ("two faces off", [(v1, [face for face in f1 if face not in ((1, 5, 7, 3), (2, 3, 7, 6))])]), + ("turned over", [(v1, turned)]), ("mirrored", [(v1 * (-1, 1, 1), f1)]), ("a turned-over bar beside a cube", [(v1, f1), (v2 + (0, 2, 0), [face[::-1] for face in f2])])): + try: + Signed({"cube": made}) + said[name] = None + except R.RamError as error: + said[name] = str(error) + RES["refusals"] = said + want = {"top off": "is open: solid 0 of 1 has 4 edges", "two faces off": "is open: solid 0 of 1 has 6 edges", "turned over": "is wound inside out: solid 0 of 1 (6 faces from face 0) has volume -1", + "mirrored": "is wound inside out: solid 0 of 1 (6 faces from face 0) has volume -1", "a turned-over bar beside a cube": "is wound inside out: solid 1 of 2 (6 faces from face 6) has volume -0.5"} + check("no-inside-is-refused: an open part is refused by its solid and edge count, an inside-out one by its solid and volume, a turned-over bar beside a whole cube included", + all(said[name] is not None and "part 'cube' " + text in said[name] for name, text in want.items()), said) + + # the depth is to the part's surface, not to a face buried in another of its solids: a cube of half side 1 with a + # box of side 0.2 buried about (0.5, 0.5, 0.5) reads its own depth by the box and at its centre (the nearest face + # of all is the buried box's: 0.05 and 0.693). A boss through a wall is read, not checked: its side faces cross the + # wall and are kept whole by their centroids, so in the wall by the boss the depth reads to their buried stretch + cube, small = wound((-1, -1, -1), (1, 1, 1)), wound((0.4, 0.4, 0.4), (0.6, 0.6, 0.6)) + boss = wound((0.9, -0.5, -0.5), (1.5, 0.5, 0.5)) + at = np.array([(0.5, 0.5, 0.55), (0.0, 0.0, 0.0), (0.5, 0.5, 0.95), (0.5, 0.5, 0.5), (1.2, 0.0, 0.0)]) + alone, buried, bossed = Signed({"p": [cube]})("p", at), Signed({"p": [cube, small]})("p", at), Signed({"p": [cube, boss]})("p", np.array([(0.95, 0.0, 0.0), (0.7, 0.0, 0.0), (1.2, 0.0, 0.0), (1.6, 0.0, 0.0)])) + RES["readings"]["buried box: depth by it, at the cube's centre, under the cube's face, at the box's centre; outside"] = buried.tolist() + RES["readings"]["boss through a wall (faces that cross a solid are kept or left whole): in both (the surface is 0.502 off), in the wall (0.583), in the boss (0.2), off it (0.1)"] = bossed.tolist() + check("depth-is-to-the-surface: a face buried in another solid of the part is not read: by a buried box the cube reads as the cube alone", + float(np.abs(buried - (-0.45, -1.0, -0.05, -0.5, 0.2)).max()) < FLAT and float(np.abs(buried - alone).max()) < FLAT, + [buried.tolist(), alone.tolist()]) SECTION[0] = "seat" seat = np.concatenate([v for v, _ in shells["parent.seat"]]) diff --git a/surfaces/blender/tests/live/ram_knee.result.json b/surfaces/blender/tests/live/ram_knee.result.json index 34bb0b1..6935ca7 100644 --- a/surfaces/blender/tests/live/ram_knee.result.json +++ b/surfaces/blender/tests/live/ram_knee.result.json @@ -17,7 +17,17 @@ "detail": null }, { - "name": "inside-reads-inside: no point inside the jointlib rocker plates' bars, in two welded boxes' overlap or in a cube with a face open reads outside, and none outside the boxes reads inside", + "name": "inside-reads-inside: no point inside the jointlib rocker plates' bars or in two welded boxes' overlap reads outside, and none outside the boxes reads inside", + "ok": true, + "detail": null + }, + { + "name": "no-inside-is-refused: an open part is refused by its solid and edge count, an inside-out one by its solid and volume, a turned-over bar beside a whole cube included", + "ok": true, + "detail": null + }, + { + "name": "depth-is-to-the-surface: a face buried in another solid of the part is not read: by a buried box the cube reads as the cube alone", "ok": true, "detail": null }, @@ -108,22 +118,41 @@ "bell crank: least margin of a zoned pair, 251 steps uncapped": 0.000118, "bell crank: pairs": 60, "bell crank: pairs refused with nothing let": 19, - "bell crank: seconds, 49 steps capped": 0.8, + "bell crank: seconds, 49 steps capped": 1.34, "bell crank: zoned pairs": 20, + "boss through a wall (faces that cross a solid are kept or left whole): in both (the surface is 0.502 off), in the wall (0.583), in the boss (0.2), off it (0.1)": [ + -0.5, + -0.5385164618492126, + -0.2999999523162842, + 0.10000002384185791 + ], + "buried box: depth by it, at the cube's centre, under the cube's face, at the box's centre; outside": [ + -0.44999998807907104, + -1.0, + -0.050000011920928955, + -0.5, + 0.20000004768371582 + ], "four bar: barrel inside the shin's clearance": -0.122, "jointlib plates: inside points read outside, of 29": 0, "moved x: both": -0.0543, "moved x: the coupler at x 0.25, inside the horn's 0.23..0.31": -0.02, "moved x: the rocker at x 0.25, inside the bracket's 0.13..0.35": -0.0543, - "open cube: inside points read outside, of 4000": 0, "search: candidates": 13824, "search: pass the gates before clearance": 78, "search: refused on their own parts": 21, - "search: seconds": 34.5, + "search: seconds": 66.8, "search: worlds built": 22, "the base clevis's foot inside the thigh": -0.01, "welded boxes: points missigned, of 6000 (91 in the overlap)": 0 }, + "refusals": { + "top off": "mesh ram: signed: part 'cube' is open: solid 0 of 1 has 4 edges no face runs the other way", + "two faces off": "mesh ram: signed: part 'cube' is open: solid 0 of 1 has 6 edges no face runs the other way", + "turned over": "mesh ram: signed: part 'cube' is wound inside out: solid 0 of 1 (6 faces from face 0) has volume -1", + "mirrored": "mesh ram: signed: part 'cube' is wound inside out: solid 0 of 1 (6 faces from face 0) has volume -1", + "a turned-over bar beside a cube": "mesh ram: signed: part 'cube' is wound inside out: solid 1 of 2 (6 faces from face 6) has volume -0.5" + }, "zones": { "barrel[0] | parent.seat": { "stated": [ @@ -496,9 +525,9 @@ } }, "renders": [ - "F:/aeth-wt/fable-ramlows/scratch/out/h3f.r3_0.png", - "F:/aeth-wt/fable-ramlows/scratch/out/h3f.r3_62p5.png", - "F:/aeth-wt/fable-ramlows/scratch/out/h3f.r3_125.png" + "F:/aeth-wt/fable-ramlows/scratch/out/live_h4b.r3_0.png", + "F:/aeth-wt/fable-ramlows/scratch/out/live_h4b.r3_62p5.png", + "F:/aeth-wt/fable-ramlows/scratch/out/live_h4b.r3_125.png" ], "ok": true } \ No newline at end of file -- 2.47.3