dymokomi/luce-cad
Source of release 0.9.3
0.9.3 / tests / regressions / fusion_roll_tests.luc
## Rolled balls checked against Fusion 2705 itself (probes 8 to 11 of
## 2026-10-12, luce_work/cad/fusion): G1 variable fillets at a Tangency
## weight of exactly 1.
## - Where the envelope folds: radii 2, x at the middle, 2 along a 20 box's
## edge; Fusion rolls the ball up to x = 10 and scales the section from 12
## (its face then ends flush, its knots inside the edge), as ours does
## (rolled_folds): Fusion's volumes within the law's own difference
## (natural spline, 0.8 at x = 14), the rolled and scaled 30 apart at 10.
## - A slanted end (a prism's ridge ending at a 45° face): the sweep (or the
## balls' envelope) carried on and trimmed by the end face, as Fusion's.
## Fusion's faces, sampled from its NURBS, lie within 2e-3 of ours (points
## a hair either side of each are inside and outside ours): G1 at 0.5 and
## G2 straight 2 to 4, G2 and the rolled G1 through 3.5 at the middle.
## (Mesh volumes of these sheared strips converge too slowly to compare.)
## - Loops: a rounded box's top loop and a dome's rim, the law Fusion's own
## (its G2 face's radius read back at 63 points: Fusion's law round a
## loop is not decoded, nearly a smooth step between extremes), so the
## rolled ball alone is compared: G1 at 1 (rolled) and 0.5 and G2 take
## Fusion's volumes within 0.03 on the box, 0.08 on the dome (whose
## rolled rim's limit is 0.04 and 0.07 under Fusion's; an older check, a
## difference from the bare dome at 64 divisions, passed by the two
## meshes' errors cancelling).
from luce_cad.modeling import CadModeling
from luce_cad.model import CadModel
from luce_cad.solids import CadSolids
from luce_cad.sketch import CadSketch
from luce_geocore.geocore import Vector3
from checks import closed, volume
from luce_std import math
pub func fusion_roll_tests() -> unit!:
folds()
slanted()
loops()
print("PASS Fusion rolled balls: folding laws scale as Fusion's (rolled to 10, scaled from 12); slanted ends match Fusion's faces within 2e-3; a rounded box's loop and a dome's rim with Fusion's laws, rolled at weight 1, within 0.03 and 0.08 of Fusion's volumes")
func refined(model: CadModel) -> float!:
let coarse = volume(model.tessellate(32))
let mesh = model.tessellate(64)
closed(mesh)
let fine = volume(mesh)
return fine + (fine - coarse) / 3.0
func edges_where(model: CadModel, keep: func(Vector3, Vector3) -> bool) -> list[int]!:
let found: list[int] = []
for face in 0..<model.face_count():
for use in 0..<model.face_edge_count(face):
let id = model.face_edge_id(face, use)
if keep(model.face_edge_point(face, use, 0.0), model.face_edge_point(face, use, 0.5)) and not (id in found):
found.append(id)
return found
## A prism of `corners` (on XY) 20 deep.
func prism(corners: list[Vector3]) -> CadModel!:
let s = CadSketch.parse("")
let ids: list[int] = []
for p in corners:
ids.append(s.add_point(p.x, p.y))
for k in 0..<corners.length:
_ = s.add_line(ids[k], ids[(k + 1) % corners.length])
return CadModeling.extruded_sides(s.curves(Vector3(), Vector3(1.0, 0.0, 0.0), Vector3(0.0, 1.0, 0.0)), 20.0, 0.0, "p")
func folds() -> unit!:
let p = prism([Vector3(0.0, 0.0, 0.0), Vector3(20.0, 0.0, 0.0), Vector3(20.0, 20.0, 0.0), Vector3(0.0, 20.0, 0.0)])
let corner = func (a: Vector3, b: Vector3) -> bool:
return math.abs(a.x - 20.0) < 1e-6 and math.abs(a.y - 20.0) < 1e-6 and math.abs(b.x - 20.0) < 1e-6 and math.abs(b.y - 20.0) < 1e-6
let edge = CadModeling.edge_references(p, edges_where(p, corner))
for (x, fusion) in [(4.0, 7953.639872761905), (8.0, 7857.110578012691), (10.0, 7797.289960469852), (12.0, 7667.594623066025), (14.0, 7554.611924271657)]:
let v = refined(CadModeling.variable_filleted(p, edge, [0.0, 0.5, 1.0], [2.0, x, 2.0], "v", false, 1, false, 1.0))
if math.abs(v - fusion) > 0.8: print(f"fold {x}: {v}, Fusion {fusion}")
assert(math.abs(v - fusion) <= 0.8)
func slanted() -> unit!:
let slab = prism([Vector3(0.0, 0.0, 0.0), Vector3(40.0, 0.0, 0.0), Vector3(30.0, 10.0, 0.0), Vector3(0.0, 10.0, 0.0)])
let ridge = func (a: Vector3, b: Vector3) -> bool:
return math.abs(a.y - 10.0) < 1e-9 and math.abs(b.y - 10.0) < 1e-9 and math.abs(a.z - 20.0) < 1e-9 and math.abs(b.z - 20.0) < 1e-9
let edge = CadModeling.edge_references(slab, edges_where(slab, ridge))
# Fusion's laws start at the slanted end (its edge runs from x = 30).
let settings = [([0.0, 1.0], [2.0, 4.0], 1, 0.5), ([0.0, 0.5, 1.0], [2.0, 3.5, 4.0], 2, 1.0), ([0.0, 0.5, 1.0], [2.0, 3.5, 4.0], 1, 1.0), ([0.0, 1.0], [2.0, 4.0], 2, 1.0)]
let samples = [
("slant_line_g1_w0.5", [Vector3(29.218746, 8.344128, 19.896508), Vector3(29.218746, 8.928891, 19.523951), Vector3(29.218746, 9.523951, 18.928891), Vector3(29.218746, 9.896508, 18.344128), Vector3(26.562496, 8.201235, 19.887577), Vector3(26.562496, 8.836460, 19.482871), Vector3(26.562496, 9.482871, 18.836460), Vector3(26.562496, 9.887577, 18.201235), Vector3(23.906248, 8.058343, 19.878646), Vector3(23.906248, 8.744029, 19.441791), Vector3(23.906248, 9.441791, 18.744029), Vector3(23.906248, 9.878646, 18.058343), Vector3(21.249999, 7.915451, 19.869716), Vector3(21.249999, 8.651599, 19.400710), Vector3(21.249999, 9.400710, 18.651599), Vector3(21.249999, 9.869716, 17.915451), Vector3(18.593750, 7.772558, 19.860785), Vector3(18.593750, 8.559168, 19.359630), Vector3(18.593750, 9.359630, 18.559168), Vector3(18.593750, 9.860785, 17.772558), Vector3(15.937500, 7.629666, 19.851854), Vector3(15.937500, 8.466737, 19.318550), Vector3(15.937500, 9.318550, 18.466737), Vector3(15.937500, 9.851854, 17.629666), Vector3(13.281250, 7.486773, 19.842923), Vector3(13.281250, 8.374306, 19.277470), Vector3(13.281250, 9.277470, 18.374306), Vector3(13.281250, 9.842923, 17.486773), Vector3(10.625000, 7.343881, 19.833993), Vector3(10.625000, 8.281876, 19.236389), Vector3(10.625000, 9.236389, 18.281876), Vector3(10.625000, 9.833993, 17.343881), Vector3(7.968750, 7.200988, 19.825062), Vector3(7.968750, 8.189445, 19.195309), Vector3(7.968750, 9.195309, 18.189445), Vector3(7.968750, 9.825062, 17.200988), Vector3(5.312500, 7.058096, 19.816131), Vector3(5.312500, 8.097014, 19.154229), Vector3(5.312500, 9.154229, 18.097014), Vector3(5.312500, 9.816131, 17.058096), Vector3(2.656250, 6.915203, 19.807200), Vector3(2.656250, 8.004583, 19.113148), Vector3(2.656250, 9.113148, 18.004583), Vector3(2.656250, 9.807200, 16.915203)], [Vector3(-0.025166, 0.410860, 0.911351), Vector3(-0.033874, 0.627874, 0.777578), Vector3(-0.033874, 0.777578, 0.627874), Vector3(-0.025166, 0.911351, 0.410860), Vector3(-0.025166, 0.410860, 0.911351), Vector3(-0.033874, 0.627874, 0.777578), Vector3(-0.033874, 0.777578, 0.627874), Vector3(-0.025166, 0.911351, 0.410860), Vector3(-0.025166, 0.410860, 0.911351), Vector3(-0.033874, 0.627874, 0.777578), Vector3(-0.033874, 0.777578, 0.627874), Vector3(-0.025166, 0.911351, 0.410860), Vector3(-0.025166, 0.410860, 0.911351), Vector3(-0.033874, 0.627874, 0.777578), Vector3(-0.033874, 0.777578, 0.627874), Vector3(-0.025166, 0.911351, 0.410860), Vector3(-0.025166, 0.410860, 0.911351), Vector3(-0.033874, 0.627874, 0.777578), Vector3(-0.033874, 0.777578, 0.627874), Vector3(-0.025166, 0.911351, 0.410860), Vector3(-0.025166, 0.410860, 0.911351), Vector3(-0.033874, 0.627874, 0.777578), Vector3(-0.033874, 0.777578, 0.627874), Vector3(-0.025166, 0.911351, 0.410860), Vector3(-0.025166, 0.410860, 0.911351), Vector3(-0.033874, 0.627874, 0.777578), Vector3(-0.033874, 0.777578, 0.627874), Vector3(-0.025166, 0.911351, 0.410860), Vector3(-0.025166, 0.410860, 0.911351), Vector3(-0.033874, 0.627874, 0.777578), Vector3(-0.033874, 0.777578, 0.627874), Vector3(-0.025166, 0.911351, 0.410860), Vector3(-0.025166, 0.410860, 0.911351), Vector3(-0.033874, 0.627874, 0.777578), Vector3(-0.033874, 0.777578, 0.627874), Vector3(-0.025166, 0.911351, 0.410860), Vector3(-0.025166, 0.410860, 0.911351), Vector3(-0.033874, 0.627874, 0.777578), Vector3(-0.033874, 0.777578, 0.627874), Vector3(-0.025166, 0.911351, 0.410860), Vector3(-0.025166, 0.410860, 0.911351), Vector3(-0.033874, 0.627874, 0.777578), Vector3(-0.033874, 0.777578, 0.627874), Vector3(-0.025166, 0.911351, 0.410860)]),
("slant_mid_g2_w1.0", [Vector3(29.142289, 8.552681, 19.951988), Vector3(29.142289, 9.178263, 19.686331), Vector3(29.142289, 9.686331, 19.178263), Vector3(29.142289, 9.951988, 18.552681), Vector3(26.492990, 8.342002, 19.944999), Vector3(26.492990, 9.058647, 19.640671), Vector3(26.492990, 9.640671, 19.058647), Vector3(26.492990, 9.944999, 18.342002), Vector3(23.843691, 8.138898, 19.938261), Vector3(23.843691, 8.943332, 19.596654), Vector3(23.843691, 9.596654, 18.943332), Vector3(23.843691, 9.938261, 18.138898), Vector3(21.194392, 7.948851, 19.931957), Vector3(21.194392, 8.835429, 19.555466), Vector3(21.194392, 9.555466, 18.835429), Vector3(21.194392, 9.931957, 17.948851), Vector3(18.545093, 7.777427, 19.926270), Vector3(18.545093, 8.738101, 19.518314), Vector3(18.545093, 9.518314, 18.738101), Vector3(18.545093, 9.926270, 17.777427), Vector3(15.895794, 7.630695, 19.921402), Vector3(15.895794, 8.654792, 19.486514), Vector3(15.895794, 9.486514, 18.654792), Vector3(15.895794, 9.921402, 17.630695), Vector3(13.246495, 7.513970, 19.917530), Vector3(13.246495, 8.588519, 19.461216), Vector3(13.246495, 9.461216, 18.588519), Vector3(13.246495, 9.917530, 17.513970), Vector3(10.597196, 7.425926, 19.914610), Vector3(10.597196, 8.538531, 19.442135), Vector3(10.597196, 9.442135, 18.538531), Vector3(10.597196, 9.914610, 17.425926), Vector3(7.947897, 7.360560, 19.912441), Vector3(7.947897, 8.501419, 19.427969), Vector3(7.947897, 9.427969, 18.501419), Vector3(7.947897, 9.912441, 17.360560), Vector3(5.298598, 7.311963, 19.910829), Vector3(5.298598, 8.473827, 19.417437), Vector3(5.298598, 9.417437, 18.473827), Vector3(5.298598, 9.910829, 17.311963), Vector3(2.649299, 7.274672, 19.909592), Vector3(2.649299, 8.452654, 19.409355), Vector3(2.649299, 9.409355, 18.452654), Vector3(2.649299, 9.909592, 17.274672)], [Vector3(-0.019033, 0.204767, 0.978626), Vector3(-0.039933, 0.561016, 0.826841), Vector3(-0.039933, 0.826841, 0.561016), Vector3(-0.019033, 0.978626, 0.204767), Vector3(-0.018610, 0.204769, 0.978633), Vector3(-0.039046, 0.561036, 0.826870), Vector3(-0.039046, 0.826870, 0.561036), Vector3(-0.018610, 0.978633, 0.204769), Vector3(-0.017683, 0.204772, 0.978650), Vector3(-0.037103, 0.561078, 0.826931), Vector3(-0.037103, 0.826931, 0.561078), Vector3(-0.017683, 0.978650, 0.204772), Vector3(-0.016272, 0.204777, 0.978673), Vector3(-0.034146, 0.561137, 0.827018), Vector3(-0.034146, 0.827018, 0.561137), Vector3(-0.016272, 0.978673, 0.204777), Vector3(-0.014341, 0.204783, 0.978702), Vector3(-0.030097, 0.561210, 0.827126), Vector3(-0.030097, 0.827126, 0.561210), Vector3(-0.014341, 0.978702, 0.204783), Vector3(-0.011851, 0.204790, 0.978734), Vector3(-0.024874, 0.561290, 0.827245), Vector3(-0.024874, 0.827245, 0.561290), Vector3(-0.011851, 0.978734, 0.204790), Vector3(-0.009091, 0.204796, 0.978763), Vector3(-0.019082, 0.561362, 0.827350), Vector3(-0.019082, 0.827350, 0.561362), Vector3(-0.009091, 0.978763, 0.204796), Vector3(-0.006778, 0.204799, 0.978780), Vector3(-0.014229, 0.561407, 0.827417), Vector3(-0.014229, 0.827417, 0.561407), Vector3(-0.006778, 0.978780, 0.204799), Vector3(-0.005019, 0.204802, 0.978791), Vector3(-0.010535, 0.561433, 0.827455), Vector3(-0.010535, 0.827455, 0.561433), Vector3(-0.005019, 0.978791, 0.204802), Vector3(-0.003765, 0.204803, 0.978796), Vector3(-0.007904, 0.561447, 0.827475), Vector3(-0.007904, 0.827475, 0.561447), Vector3(-0.003765, 0.978796, 0.204803), Vector3(-0.002997, 0.204803, 0.978799), Vector3(-0.006291, 0.561453, 0.827485), Vector3(-0.006291, 0.827485, 0.561453), Vector3(-0.002997, 0.978799, 0.204803)]),
("slant_mid_g1_w1.0", [Vector3(29.081566, 8.514564, 19.907160), Vector3(29.046143, 9.118020, 19.608009), Vector3(29.046143, 9.608009, 19.118020), Vector3(29.081566, 9.907160, 18.514564), Vector3(26.424955, 8.298461, 19.893654), Vector3(26.385272, 8.989750, 19.551000), Vector3(26.385272, 9.551000, 18.989750), Vector3(26.424955, 9.893654, 18.298461), Vector3(23.771096, 8.090319, 19.880645), Vector3(23.728764, 8.866274, 19.496122), Vector3(23.728764, 9.496122, 18.866274), Vector3(23.771096, 9.880645, 18.090319), Vector3(21.120725, 7.895775, 19.868486), Vector3(21.077783, 8.750939, 19.444862), Vector3(21.077783, 9.444862, 18.750939), Vector3(21.120725, 9.868486, 17.895775), Vector3(18.474665, 7.720536, 19.857534), Vector3(18.433629, 8.647132, 19.398725), Vector3(18.433629, 9.398725, 18.647132), Vector3(18.474665, 9.857534, 17.720536), Vector3(15.833757, 7.570785, 19.848174), Vector3(15.797626, 8.558509, 19.359337), Vector3(15.797626, 9.359337, 18.558509), Vector3(15.833757, 9.848174, 17.570785), Vector3(13.196481, 7.451789, 19.840737), Vector3(13.167365, 8.488132, 19.328059), Vector3(13.167365, 9.328059, 18.488132), Vector3(13.196481, 9.840737, 17.451789), Vector3(10.558594, 7.361995, 19.835125), Vector3(10.536128, 8.435013, 19.304450), Vector3(10.536128, 9.304450, 18.435013), Vector3(10.558594, 9.835125, 17.361995), Vector3(7.918550, 7.295267, 19.830954), Vector3(7.901474, 8.395517, 19.286896), Vector3(7.901474, 9.286896, 18.395517), Vector3(7.918550, 9.830954, 17.295267), Vector3(5.276187, 7.245609, 19.827851), Vector3(5.263146, 8.366108, 19.273826), Vector3(5.263146, 9.273826, 18.366108), Vector3(5.276187, 9.827851, 17.245609), Vector3(2.631210, 7.207465, 19.825467), Vector3(2.620685, 8.343504, 19.263780), Vector3(2.620685, 9.263780, 18.343504), Vector3(2.631210, 9.825467, 17.207465)], [Vector3(-0.028918, 0.292627, 0.955789), Vector3(-0.045786, 0.579996, 0.813332), Vector3(-0.045786, 0.813332, 0.579996), Vector3(-0.028918, 0.955789, 0.292627), Vector3(-0.028281, 0.292679, 0.955792), Vector3(-0.044776, 0.580045, 0.813353), Vector3(-0.044776, 0.813353, 0.580045), Vector3(-0.028281, 0.955792, 0.292679), Vector3(-0.026884, 0.292788, 0.955799), Vector3(-0.042561, 0.580147, 0.813399), Vector3(-0.042561, 0.813399, 0.580147), Vector3(-0.026884, 0.955799, 0.292788), Vector3(-0.024755, 0.292944, 0.955809), Vector3(-0.039185, 0.580294, 0.813464), Vector3(-0.039185, 0.813464, 0.580294), Vector3(-0.024755, 0.955809, 0.292944), Vector3(-0.021835, 0.293137, 0.955821), Vector3(-0.034558, 0.580475, 0.813544), Vector3(-0.034558, 0.813544, 0.580475), Vector3(-0.021835, 0.955821, 0.293137), Vector3(-0.018060, 0.293350, 0.955834), Vector3(-0.028578, 0.580675, 0.813633), Vector3(-0.028578, 0.813633, 0.580675), Vector3(-0.018060, 0.955834, 0.293350), Vector3(-0.013864, 0.293540, 0.955846), Vector3(-0.021935, 0.580853, 0.813713), Vector3(-0.021935, 0.813713, 0.580853), Vector3(-0.013864, 0.955846, 0.293540), Vector3(-0.010342, 0.293660, 0.955854), Vector3(-0.016361, 0.580967, 0.813763), Vector3(-0.016361, 0.813763, 0.580967), Vector3(-0.010342, 0.955854, 0.293660), Vector3(-0.007660, 0.293729, 0.955858), Vector3(-0.012117, 0.581031, 0.813791), Vector3(-0.012117, 0.813791, 0.581031), Vector3(-0.007660, 0.955858, 0.293729), Vector3(-0.005747, 0.293765, 0.955860), Vector3(-0.009091, 0.581065, 0.813807), Vector3(-0.009091, 0.813807, 0.581065), Vector3(-0.005747, 0.955860, 0.293765), Vector3(-0.004575, 0.293782, 0.955861), Vector3(-0.007236, 0.581081, 0.813814), Vector3(-0.007236, 0.813814, 0.581081), Vector3(-0.004575, 0.955861, 0.293782)]),
("slant_line_g2_w1.0", [Vector3(29.218746, 8.585660, 19.953082), Vector3(29.218746, 9.196988, 19.693478), Vector3(29.218746, 9.693478, 19.196988), Vector3(29.218746, 9.953082, 18.585660), Vector3(26.562496, 8.463611, 19.949033), Vector3(26.562496, 9.127692, 19.667027), Vector3(26.562496, 9.667027, 19.127692), Vector3(26.562496, 9.949033, 18.463611), Vector3(23.906248, 8.341561, 19.944984), Vector3(23.906248, 9.058397, 19.640576), Vector3(23.906248, 9.640576, 19.058397), Vector3(23.906248, 9.944984, 18.341561), Vector3(21.249999, 8.219512, 19.940935), Vector3(21.249999, 8.989101, 19.614125), Vector3(21.249999, 9.614125, 18.989101), Vector3(21.249999, 9.940935, 18.219512), Vector3(18.593750, 8.097462, 19.936887), Vector3(18.593750, 8.919806, 19.587674), Vector3(18.593750, 9.587674, 18.919806), Vector3(18.593750, 9.936887, 18.097462), Vector3(15.937500, 7.975413, 19.932838), Vector3(15.937500, 8.850510, 19.561222), Vector3(15.937500, 9.561222, 18.850510), Vector3(15.937500, 9.932838, 17.975413), Vector3(13.281250, 7.853363, 19.928789), Vector3(13.281250, 8.781215, 19.534771), Vector3(13.281250, 9.534771, 18.781215), Vector3(13.281250, 9.928789, 17.853363), Vector3(10.625000, 7.731313, 19.924740), Vector3(10.625000, 8.711919, 19.508320), Vector3(10.625000, 9.508320, 18.711919), Vector3(10.625000, 9.924740, 17.731313), Vector3(7.968750, 7.609264, 19.920691), Vector3(7.968750, 8.642624, 19.481869), Vector3(7.968750, 9.481869, 18.642624), Vector3(7.968750, 9.920691, 17.609264), Vector3(5.312500, 7.487214, 19.916643), Vector3(5.312500, 8.573328, 19.455418), Vector3(5.312500, 9.455418, 18.573328), Vector3(5.312500, 9.916643, 17.487214), Vector3(2.656250, 7.365165, 19.912594), Vector3(2.656250, 8.504033, 19.428967), Vector3(2.656250, 9.428967, 18.504033), Vector3(2.656250, 9.912594, 17.365165)], [Vector3(-0.010902, 0.204792, 0.978745), Vector3(-0.022882, 0.561317, 0.827284), Vector3(-0.022882, 0.827284, 0.561317), Vector3(-0.010902, 0.978745, 0.204792), Vector3(-0.010902, 0.204792, 0.978745), Vector3(-0.022882, 0.561317, 0.827284), Vector3(-0.022882, 0.827284, 0.561317), Vector3(-0.010902, 0.978745, 0.204792), Vector3(-0.010902, 0.204792, 0.978745), Vector3(-0.022882, 0.561317, 0.827284), Vector3(-0.022882, 0.827284, 0.561317), Vector3(-0.010902, 0.978745, 0.204792), Vector3(-0.010902, 0.204792, 0.978745), Vector3(-0.022882, 0.561317, 0.827284), Vector3(-0.022882, 0.827284, 0.561317), Vector3(-0.010902, 0.978745, 0.204792), Vector3(-0.010902, 0.204792, 0.978745), Vector3(-0.022882, 0.561317, 0.827284), Vector3(-0.022882, 0.827284, 0.561317), Vector3(-0.010902, 0.978745, 0.204792), Vector3(-0.010902, 0.204792, 0.978745), Vector3(-0.022882, 0.561317, 0.827284), Vector3(-0.022882, 0.827284, 0.561317), Vector3(-0.010902, 0.978745, 0.204792), Vector3(-0.010902, 0.204792, 0.978745), Vector3(-0.022882, 0.561317, 0.827284), Vector3(-0.022882, 0.827284, 0.561317), Vector3(-0.010902, 0.978745, 0.204792), Vector3(-0.010902, 0.204792, 0.978745), Vector3(-0.022882, 0.561317, 0.827284), Vector3(-0.022882, 0.827284, 0.561317), Vector3(-0.010902, 0.978745, 0.204792), Vector3(-0.010902, 0.204792, 0.978745), Vector3(-0.022882, 0.561317, 0.827284), Vector3(-0.022882, 0.827284, 0.561317), Vector3(-0.010902, 0.978745, 0.204792), Vector3(-0.010902, 0.204792, 0.978745), Vector3(-0.022882, 0.561317, 0.827284), Vector3(-0.022882, 0.827284, 0.561317), Vector3(-0.010902, 0.978745, 0.204792), Vector3(-0.010902, 0.204792, 0.978745), Vector3(-0.022882, 0.561317, 0.827284), Vector3(-0.022882, 0.827284, 0.561317), Vector3(-0.010902, 0.978745, 0.204792)])
]
for k in 0..<samples.length:
let (name, points, normals) = samples[k]
let (positions, radii, continuity, weight) = settings[k]
let made = CadModeling.variable_filleted(slab, edge, positions, radii, "v", false, continuity, false, weight)
closed(made.tessellate(32))
for i in 0..<points.length:
let a = CadModeling.inside(made, points[i].add(normals[i].multiply_scalar(0.002)))
let b = CadModeling.inside(made, points[i].subtract(normals[i].multiply_scalar(0.002)))
assert(a != b, f"{name}: Fusion's point {points[i]} off ours by more than 0.002")
func loops() -> unit!:
let p = prism([Vector3(0.0, 0.0, 0.0), Vector3(20.0, 0.0, 0.0), Vector3(20.0, 20.0, 0.0), Vector3(0.0, 20.0, 0.0)])
let upright = func (a: Vector3, b: Vector3) -> bool:
return math.abs(a.x - b.x) < 1e-9 and math.abs(a.y - b.y) < 1e-9
let rounded = CadModeling.filleted(p, CadModeling.edge_references(p, edges_where(p, upright)), 4.0, "u", 1, false)
let first = func (a: Vector3, b: Vector3) -> bool:
return math.abs(a.x) < 1e-9 and math.abs(b.x) < 1e-9 and math.abs(a.z - 20.0) < 1e-9 and math.abs(b.z - 20.0) < 1e-9
let edge = CadModeling.edge_references(rounded, edges_where(rounded, first))
let loop_positions = [0.0, 0.015625, 0.031250, 0.046875, 0.062500, 0.078125, 0.093750, 0.109375, 0.125000, 0.140625, 0.156250, 0.171875, 0.187500, 0.203125, 0.218750, 0.234375, 0.250000, 0.265625, 0.281250, 0.296875, 0.312500, 0.328125, 0.343750, 0.359375, 0.375000, 0.390625, 0.406250, 0.421875, 0.437500, 0.453125, 0.468750, 0.484375, 0.500000, 0.515625, 0.531250, 0.546875, 0.562500, 0.578125, 0.593750, 0.609375, 0.625000, 0.640625, 0.656250, 0.671875, 0.687500, 0.703125, 0.718750, 0.734375, 0.750000, 0.765625, 0.781250, 0.796875, 0.812500, 0.828125, 0.843750, 0.859375, 0.875000, 0.890625, 0.906250, 0.921875, 0.937500, 0.953125, 0.968750, 0.984375, 1.0]
let loop_radii = [1.966843153, 1.966843153, 1.912006771, 1.858093380, 1.805710660, 1.755433384, 1.707841838, 1.663555763, 1.623195941, 1.587419997, 1.556881828, 1.536553088, 1.523968576, 1.513619129, 1.506286873, 1.501650918, 1.500000000, 1.504209844, 1.516496863, 1.536337494, 1.563195195, 1.596522288, 1.635610864, 1.679509618, 1.727471561, 1.778748147, 1.832585714, 1.875201673, 1.905146899, 1.934710224, 1.964567637, 1.993315550, 2.021891416, 2.079271161, 2.135833946, 2.190870132, 2.243678640, 2.293601910, 2.339905566, 2.381833205, 2.418618882, 2.449435541, 2.473487333, 2.485771500, 2.491020076, 2.494938158, 2.497826029, 2.499483832, 2.500000000, 2.496006340, 2.484401876, 2.465760596, 2.440668396, 2.409721174, 2.373541147, 2.332823180, 2.288209366, 2.240341856, 2.189868422, 2.151676441, 2.127402018, 2.101583953, 2.075780847, 2.048974185, 1.966843153]
for (continuity, weight, fusion) in [(1, 1.0, 7662.519871703669), (1, 0.5, 7635.223651268879), (2, 1.0, 7675.829481275169)]:
let v = refined(CadModeling.variable_filleted(rounded, edge, loop_positions, loop_radii, "v", false, continuity, true, weight))
if math.abs(v - fusion) > 0.03: print(f"loop G{continuity} weight {weight}: {v}, Fusion {fusion}")
assert(math.abs(v - fusion) <= 0.03)
# The dome: a ball of 10 cut at its middle, its rim rolled; volumes
# extrapolated from 32 and 64 divisions, which Fusion's own are 0.04
# (at weight 1) and 0.07 (at 0.5) above.
let ball = CadModeling.tagged(CadSolids.sphere(10.0), "ball")
let below = CadModeling.tagged(CadSolids.box(30.0, 30.0, 30.0), "cut").transformed(Vector3(0.0, -15.0, 0.0), Vector3(), Vector3(1.0, 1.0, 1.0))
let dome = CadModeling.combined(ball, below, 1)
let on_rim = func (a: Vector3, b: Vector3) -> bool:
return math.abs(a.y) < 1e-9 and math.abs(b.y) < 1e-9 and math.abs(math.hypot(a.x, a.z) - 10.0) < 1e-6
let rim = CadModeling.edge_references(dome, edges_where(dome, on_rim))
let dome_positions = [0.0, 0.015625, 0.031250, 0.046875, 0.062500, 0.078125, 0.093750, 0.109375, 0.125000, 0.140625, 0.156250, 0.171875, 0.187500, 0.203125, 0.218750, 0.234375, 0.250000, 0.265625, 0.281250, 0.296875, 0.312500, 0.328125, 0.343750, 0.359375, 0.375000, 0.390625, 0.406250, 0.421875, 0.437500, 0.453125, 0.468750, 0.484375, 0.500000, 0.515625, 0.531250, 0.546875, 0.562500, 0.578125, 0.593750, 0.609375, 0.625000, 0.640625, 0.656250, 0.671875, 0.687500, 0.703125, 0.718750, 0.734375, 0.750000, 0.765625, 0.781250, 0.796875, 0.812500, 0.828125, 0.843750, 0.859375, 0.875000, 0.890625, 0.906250, 0.921875, 0.937500, 0.953125, 0.968750, 0.984375, 1.0]
let dome_radii = [1.992121639, 1.992121639, 1.945066596, 1.897876496, 1.851331938, 1.805732840, 1.761181891, 1.718404314, 1.678116434, 1.640386355, 1.605818369, 1.576036202, 1.551309501, 1.530920552, 1.514896101, 1.504064409, 1.500000046, 1.503344235, 1.512815898, 1.528148699, 1.549324282, 1.575393896, 1.605820366, 1.640841578, 1.679326342, 1.719927438, 1.762019644, 1.805666946, 1.851412329, 1.898638395, 1.946017097, 1.992842498, 2.039026663, 2.084977339, 2.130422067, 2.174399890, 2.216488751, 2.256779624, 2.295301620, 2.331280744, 2.364245059, 2.394190795, 2.421572432, 2.445878322, 2.466099032, 2.481627089, 2.492262721, 2.498200529, 2.499999962, 2.497787181, 2.490985697, 2.479627980, 2.464101882, 2.444623134, 2.421192324, 2.394190953, 2.364297892, 2.331424050, 2.295486874, 2.256866656, 2.216405121, 2.174434145, 2.130659648, 2.085216129, 1.992121639]
for (continuity, weight, fusion) in [(1, 1.0, 2014.531548088535), (1, 0.5, 1976.9585104417026)]:
let v = refined(CadModeling.variable_filleted(dome, rim, dome_positions, dome_radii, "v", false, continuity, true, weight))
if math.abs(v - fusion) > 0.08: print(f"dome G{continuity} weight {weight}: {v}, Fusion {fusion}")
assert(math.abs(v - fusion) <= 0.08)