use std::f64::consts::PI;
use springrep::{
Error,
blend::{chamfer, fillet},
boolean::{difference, union},
check,
math::{Frame, Vec2, Vec3},
measure,
mesh::{self, MeshOptions},
profile::{NamedSegment, Profile, ProfileLoop, Segment},
sweep::extrude,
topo::Brep,
};
const COARSE: MeshOptions = MeshOptions {
linear: 0.2,
angular: 0.5,
};
fn at_z(z: f64) -> Frame {
Frame::new(Vec3::new(0.0, 0.0, z), Vec3::Z, Vec3::X).unwrap()
}
fn block(id: &str, w: f64, d: f64, h: f64) -> Brep {
extrude(
&Profile::rect(Vec2::new(w / 2.0, d / 2.0), w, d),
&at_z(0.0),
h,
id,
)
.unwrap()
}
fn disc(id: &str, z: f64, diameter: f64, h: f64) -> Brep {
extrude(&Profile::circle(Vec2::ZERO, diameter), &at_z(z), h, id).unwrap()
}
fn assert_solid(b: &Brep, volume: f64, area: f64) {
let issues = check::check(b);
assert!(issues.is_empty(), "{issues:?}");
let v = measure::volume(b);
let a = measure::area(b);
assert!(
(v - volume).abs() <= 1e-9 * volume,
"volume {v} vs {volume}"
);
assert!((a - area).abs() <= 1e-9 * area, "area {a} vs {area}");
let m = mesh::tessellate(b, &COARSE).unwrap();
for s in b.solid_ids() {
assert!(mesh::report(b, &m, s).watertight());
}
}
fn names(b: &Brep, name: &str) -> usize {
b.name_counts().get(name).copied().unwrap_or(0)
}
fn kinds(b: &Brep, kind: &str) -> usize {
b.face_ids()
.filter(|&f| b.face(f).surface.kind() == kind)
.count()
}
#[test]
fn a_straight_convex_edge_takes_a_cylinder_fillet() {
let b = fillet(
&block("box", 40.0, 30.0, 20.0),
&[("box.end", "box.v_min")],
5.0,
"f",
)
.unwrap();
let spandrel = 25.0 * (1.0 - PI / 4.0);
let area = 5200.0 - 2.0 * 5.0 * 40.0 - 2.0 * spandrel + PI / 2.0 * 5.0 * 40.0;
assert_solid(&b, 24000.0 - spandrel * 40.0, area);
assert_eq!(b.face_count(), 7);
assert_eq!(kinds(&b, "cylinder"), 1);
assert_eq!(names(&b, "f.round_0"), 1);
assert_eq!(names(&b, "box.end"), 1);
}
#[test]
fn a_straight_concave_edge_takes_a_fillet_that_adds_material() {
let pts = [
Vec2::new(0.0, 0.0),
Vec2::new(40.0, 0.0),
Vec2::new(40.0, 10.0),
Vec2::new(10.0, 10.0),
Vec2::new(10.0, 30.0),
Vec2::new(0.0, 30.0),
];
let names_in = ["e0", "e1", "e2", "e3", "e4", "e5"];
let ell = extrude(&Profile::polygon(&pts, &names_in), &at_z(0.0), 20.0, "l").unwrap();
let b = fillet(&ell, &[("l.e2", "l.e3")], 4.0, "f").unwrap();
let spandrel = 16.0 * (1.0 - PI / 4.0);
let area = 2.0 * (600.0 + spandrel) + 20.0 * (140.0 - 8.0 + 2.0 * PI);
assert_solid(&b, 600.0 * 20.0 + spandrel * 20.0, area);
assert_eq!(names(&b, "f.round_0"), 1);
assert_eq!(names(&b, "l.e2"), 1);
}
#[test]
fn a_circular_edge_takes_a_cone_chamfer() {
let b = chamfer(
&disc("c", 0.0, 40.0, 20.0),
&[("c.end", "c.side")],
2.0,
"ch",
)
.unwrap();
let volume = PI * 400.0 * 18.0 + PI * 2.0 / 3.0 * (400.0 + 360.0 + 324.0);
let area = 400.0 * PI + 2.0 * PI * 20.0 * 18.0 + 324.0 * PI + PI * 38.0 * 2.0 * 2f64.sqrt();
assert_solid(&b, volume, area);
assert_eq!(kinds(&b, "cone"), 1);
assert_eq!(names(&b, "ch.bevel_0"), 1);
}
#[test]
fn a_concave_circular_edge_takes_a_torus_fillet() {
let plate = extrude(
&Profile::rect(Vec2::ZERO, 60.0, 60.0),
&at_z(0.0),
10.0,
"plate",
)
.unwrap();
let body = union(&plate, &disc("boss", 10.0, 20.0, 10.0)).unwrap();
let b = fillet(&body, &[("plate.end", "boss.side")], 3.0, "f").unwrap();
let spandrel = 9.0 * (1.0 - PI / 4.0);
let offset = 3.0 * (10.0 - 3.0 * PI) / (12.0 - 3.0 * PI);
let volume = 36000.0 + PI * 1000.0 + 2.0 * PI * (10.0 + offset) * spandrel;
let area = (3600.0 - PI * 169.0)
+ 3600.0
+ 2400.0
+ 2.0 * PI * 70.0
+ PI * 100.0
+ 2.0 * PI * (13.0 - 6.0 / PI) * (1.5 * PI);
assert_solid(&b, volume, area);
assert_eq!(kinds(&b, "torus"), 1);
assert_eq!(names(&b, "f.round_0"), 1);
}
#[test]
fn three_fillets_at_a_corner_close_with_a_sphere() {
let pairs = [
("box.end", "box.u_max"),
("box.end", "box.v_max"),
("box.u_max", "box.v_max"),
];
let b = fillet(&block("box", 20.0, 20.0, 20.0), &pairs, 4.0, "f").unwrap();
let spandrel = 16.0 * (1.0 - PI / 4.0);
let volume = 8000.0 - 3.0 * 16.0 * spandrel - (64.0 - PI * 64.0 / 6.0);
let area = 2400.0 - 3.0 * 4.0 * 16.0 * 2.0 - 3.0 * 16.0 - 3.0 * spandrel
+ 3.0 * PI / 2.0 * 4.0 * 16.0
+ PI * 16.0 / 2.0;
assert_solid(&b, volume, area);
assert_eq!(kinds(&b, "sphere"), 1);
assert_eq!(names(&b, "f.corner"), 1);
for i in 0..3 {
assert_eq!(names(&b, &format!("f.round_{i}")), 1);
}
}
#[test]
fn a_blend_wider_than_its_face_is_refused() {
let r = chamfer(
&block("box", 40.0, 30.0, 4.0),
&[("box.end", "box.v_min")],
5.0,
"ch",
);
assert!(matches!(r, Err(Error::InvalidInput(_))), "{r:?}");
}
fn assert_dies_into(body: &Brep, side: f64, r: f64, from: f64, x1: f64, w0: impl Fn(f64) -> f64) {
use springrep::{blend::fillet_edges, measure::edge_at};
let (edge, _) = edge_at(body, Vec3::new(30.0, side, 4.0)).unwrap();
let b = fillet_edges(body, &[edge], r, "f").unwrap();
let g = |v: f64| v / 2.0 * (r * r - v * v).max(0.0).sqrt() + r * r / 2.0 * (v / r).asin();
let s = |u: f64| r * u - (g(r) - g(r - u));
let n = 4000;
let h = (x1 - from) / n as f64;
let simpson: f64 = (0..=n)
.map(|i| {
let weight = if i == 0 || i == n {
1.0
} else {
[2.0, 4.0][i % 2]
};
weight * s(w0(from + h * i as f64).clamp(0.0, r))
})
.sum::<f64>()
* h
/ 3.0;
let removed = simpson + (60.0 - x1) * s(r);
let issues = check::check(&b);
assert!(issues.is_empty(), "{issues:?}");
let taken = measure::volume(body) - measure::volume(&b);
assert!(
(taken - removed).abs() <= 1e-6 * removed,
"took {taken} vs {removed}"
);
assert_eq!(b.face_count(), body.face_count() + 1);
assert_eq!(names(&b, "f.round_0"), 1);
}
#[test]
fn a_fillet_ending_on_a_hub_it_meets_at_a_glancing_angle_dies_into_it() {
let d = 624f64.sqrt();
let bar = extrude(
&Profile::rect(Vec2::new(30.0, 0.0), 60.0, 2.0 * d),
&at_z(0.0),
4.0,
"bar",
)
.unwrap();
let body = union(&disc("hub", 0.0, 50.0, 4.0), &bar).unwrap();
let x1 = (625.0 - (d - 2.0) * (d - 2.0)).sqrt();
assert_dies_into(&body, -d, 2.0, 1.0, x1, |x| d - (625.0 - x * x).sqrt());
}
#[test]
fn a_fillet_end_whose_rim_bows_out_behind_its_edge_runs_no_further() {
let (c, radius, lift) = (Vec2::new(-1.0, 50.0), 2501f64.sqrt(), 5e-8);
let end = Vec2::new(c.x - (radius * radius - (c.y - lift).powi(2)).sqrt(), lift);
let at = |p: Vec2| (p.y - c.y).atan2(p.x - c.x);
let line = |a: Vec2, b: Vec2, name: &str| seg(Segment::Line { a, b }, name);
let corners = [
Vec2::new(0.0, 0.0),
Vec2::new(60.0, 0.0),
Vec2::new(60.0, 20.0),
Vec2::new(-10.0, 20.0),
Vec2::new(-10.0, -0.5),
];
let mut segments = vec![seg(
Segment::Arc {
center: c,
radius,
start: at(end),
sweep: at(corners[0]) - at(end),
},
"rim",
)];
for (i, name) in ["side", "end", "back", "heel"].iter().enumerate() {
segments.push(line(corners[i], corners[i + 1], name));
}
segments.push(line(corners[4], end, "toe"));
let profile = Profile {
loops: vec![ProfileLoop { segments }],
};
let body = extrude(&profile, &at_z(0.0), 4.0, "p").unwrap();
let x1 = (2501.0f64 - 48.0 * 48.0).sqrt() - 1.0;
assert_dies_into(&body, 0.0, 2.0, 0.0, x1, |x| {
50.0 - (2501.0 - (x + 1.0) * (x + 1.0)).sqrt()
});
}
#[test]
fn a_boss_fillet_wider_than_its_ledge_ends_on_the_ledge_side() {
let body = union(&disc("base", 0.0, 20.0, 4.0), &disc("boss", 4.0, 16.0, 6.0)).unwrap();
let b = fillet(&body, &[("base.end", "boss.side")], 3.0, "f").unwrap();
let j = 9.0 * PI / 4.0 - 2f64.sqrt() - 4.5 * (1.0f64 / 3.0).asin();
let (kept, moment) = (6.0 - j, 6.0 - 3.0 * j + 16.0 * 2f64.sqrt() / 3.0);
let turn = (1.0f64 / 3.0).acos();
let volume = 784.0 * PI + 2.0 * PI * (8.0 * kept + moment);
let area = (376.0 - 36.0 - 48.0) * PI
+ 20.0 * PI * (3.0 - 8f64.sqrt())
+ 2.0 * PI * (33.0 * turn - 6.0 * 2f64.sqrt());
assert_solid(&b, volume, area);
assert_eq!(b.face_count(), 5);
assert_eq!(kinds(&b, "torus"), 1);
assert_eq!(names(&b, "f.round_0"), 1);
assert_eq!(names(&b, "base.end"), 0);
}
#[test]
fn a_concave_fillet_wider_than_its_ledge_ends_on_the_ledge_face() {
let ledge = extrude(
&Profile::rect(Vec2::new(5.0, 2.0), 10.0, 4.0),
&at_z(0.0),
30.0,
"ledge",
)
.unwrap();
let wall = extrude(
&Profile::rect(Vec2::new(4.0, 7.0), 4.0, 6.0),
&at_z(0.0),
20.0,
"wall",
)
.unwrap();
let body = union(&ledge, &wall).unwrap();
let b = fillet(&body, &[("ledge.v_max", "wall.u_min")], 3.0, "f").unwrap();
let kept = 6.0 - 9.0 * PI / 4.0 + 2f64.sqrt() + 4.5 * (1.0f64 / 3.0).asin();
let rise = 3.0 - 8f64.sqrt();
let area = 1208.0 + 2.0 * kept + 20.0 * rise - 40.0 - 60.0 + 60.0 * (1.0f64 / 3.0).acos();
assert_solid(&b, 1680.0 + 20.0 * kept, area);
assert_eq!(b.face_count(), 11);
assert_eq!(names(&b, "f.round_0"), 1);
assert_eq!(names(&b, "ledge.u_min"), 1);
}
#[test]
fn a_pair_that_names_no_edge_is_invalid() {
let r = fillet(
&block("box", 4.0, 4.0, 4.0),
&[("box.end", "box.start")],
1.0,
"f",
);
assert!(matches!(r, Err(Error::InvalidInput(_))), "{r:?}");
}
fn seg(segment: Segment, name: &str) -> NamedSegment {
NamedSegment::new(segment, name)
}
fn rounded(w: f64, d: f64, r: f64) -> Profile {
let (x, y) = (w / 2.0 - r, d / 2.0 - r);
let (hw, hd) = (w / 2.0, d / 2.0);
let arc = |cx: f64, cy: f64, start: f64, name: &str| {
let center = Vec2::new(cx, cy);
let sweep = PI / 2.0;
seg(
Segment::Arc {
center,
radius: r,
start,
sweep,
},
name,
)
};
let line = |a: (f64, f64), b: (f64, f64), name: &str| {
let (a, b) = (Vec2::new(a.0, a.1), Vec2::new(b.0, b.1));
seg(Segment::Line { a, b }, name)
};
let segments = vec![
line((-x, -hd), (x, -hd), "s0"),
arc(x, -y, -PI / 2.0, "c0"),
line((hw, -y), (hw, y), "s1"),
arc(x, y, 0.0, "c1"),
line((x, hd), (-x, hd), "s2"),
arc(-x, y, PI / 2.0, "c2"),
line((-hw, y), (-hw, -y), "s3"),
arc(-x, -y, PI, "c3"),
];
Profile {
loops: vec![ProfileLoop { segments }],
}
}
#[test]
fn a_chamfer_follows_a_tangent_chain_round_a_pocket() {
let plate = extrude(
&Profile::rect(Vec2::ZERO, 60.0, 40.0),
&at_z(0.0),
10.0,
"plate",
);
let slot = extrude(&rounded(30.0, 12.0, 5.0), &at_z(0.0), 10.0, "slot");
let body = difference(&plate.unwrap(), &slot.unwrap()).unwrap();
let d = 1.0;
let pairs = [("plate.end", "slot.s0"), ("plate.end", "slot.s2")];
let b = chamfer(&body, &pairs, d, "ch").unwrap();
let l = 2.0 * 20.0 + 2.0 * 2.0 + 2.0 * PI * 5.0;
let hole = 30.0 * 12.0 - (4.0 - PI) * 25.0;
let volume = (2400.0 - hole) * 10.0 - (l * d * d / 2.0 + PI * d * d * d / 3.0);
let area = 2.0 * (2400.0 - hole) + 10.0 * (200.0 + l) - (l * d + PI * d * d) - l * d
+ 2f64.sqrt() * (l * d + PI * d * d);
assert_solid(&b, volume, area);
assert_eq!(kinds(&b, "cone"), 4);
assert_eq!(names(&b, "ch.bevel_0") + names(&b, "ch.bevel_1"), 8);
}
#[test]
fn an_edge_two_pairs_pick_is_blended_once() {
let pairs = [("box.end", "box.v_min"), ("box.v_min", "box.end")];
let b = fillet(&block("box", 40.0, 30.0, 20.0), &pairs, 5.0, "f").unwrap();
let spandrel = 25.0 * (1.0 - PI / 4.0);
assert!((measure::volume(&b) - (24000.0 - spandrel * 40.0)).abs() <= 1e-9 * 24000.0);
assert_eq!(names(&b, "f.round_0"), 1);
assert_eq!(names(&b, "f.round_1"), 1);
assert_eq!(kinds(&b, "cylinder"), 1);
}
#[test]
fn chamfers_meeting_at_corners_are_mitred() {
let (w, d, h, c) = (20.0, 12.0, 8.0, 1.5);
let pairs = [
("box.end", "box.u_min"),
("box.end", "box.u_max"),
("box.end", "box.v_min"),
("box.end", "box.v_max"),
];
let b = chamfer(&block("box", w, d, h), &pairs, c, "ch").unwrap();
let volume = w * d * h - (c * c * (w + d) - 4.0 * c * c * c / 3.0);
let area = (w - 2.0 * c) * (d - 2.0 * c)
+ w * d
+ 2.0 * (w + d) * (h - c)
+ 2.0 * 2f64.sqrt() * c * (w - c + d - c);
assert_solid(&b, volume, area);
assert_eq!(b.face_count(), 10);
}
#[test]
fn a_chamfer_ending_under_an_overhang_stops_at_its_end_face() {
let rect = |id: &str, w: f64, d: f64, z: f64, h: f64| {
extrude(
&Profile::rect(Vec2::new(w / 2.0, d / 2.0), w, d),
&at_z(z),
h,
id,
)
.unwrap()
};
let body = union(
&rect("bar", 14.0, 20.0, 0.0, 40.0),
&rect("web", 14.0, 19.0, 40.0, 10.0),
)
.unwrap();
let b = chamfer(&body, &[("bar.u_max", "bar.v_max")], 4.0, "ch").unwrap();
let area = 3940.0 - 320.0 + 160.0 * 2f64.sqrt() - 8.0 - 3.5 + 4.5;
assert_solid(&b, 13860.0 - 320.0, area);
assert_eq!(b.face_count(), 10);
assert_eq!(names(&b, "ch.bevel_0"), 1);
}
#[test]
fn a_chamfer_ending_on_a_slanted_face_is_trimmed_by_it() {
let (l, s, hh, t, d) = (30.0, 6.0, 10.0, 8.0, 1.0);
let pts = [
Vec2::new(0.0, 0.0),
Vec2::new(l, 0.0),
Vec2::new(l - s, hh),
Vec2::new(0.0, hh),
];
let outline = Profile::polygon(&pts, &["bottom", "slant", "top", "left"]);
let body = extrude(&outline, &at_z(0.0), t, "p").unwrap();
let b = chamfer(&body, &[("p.top", "p.end")], d, "ch").unwrap();
let tri = d * d / 2.0;
let reach = |y: f64| l - s * y / hh;
let volume = (l + l - s) / 2.0 * hh * t - tri * reach(hh - d / 3.0);
let slant = (s * s + hh * hh).sqrt();
let a0 = (l + l - s) * hh + t * (l + (l - s) + hh + slant);
let cap_strip = d * l - s * (hh * hh - (hh - d) * (hh - d)) / (2.0 * hh);
let area = a0 - d * (l - s) - cap_strip - tri * slant / hh - tri
+ d * 2f64.sqrt() * reach(hh - d / 2.0);
assert_solid(&b, volume, area);
assert_eq!(names(&b, "ch.bevel_0"), 1);
}
fn arc_green(o: Vec2, r: f64, a: Vec2, b: Vec2) -> (f64, f64) {
let (sa, sb) = ((a - o).y.atan2((a - o).x), (b - o).y.atan2((b - o).x));
let sw = (sb - sa + PI).rem_euclid(2.0 * PI) - PI;
let chord = o.x * (sb.sin() - sa.sin()) - o.y * (sb.cos() - sa.cos());
(0.5 * (r * r * sw + r * chord), r * sw.abs())
}
#[test]
fn a_straight_edge_between_a_plane_and_a_bore_takes_a_fillet() {
let plate = extrude(
&Profile::rect(Vec2::ZERO, 60.0, 60.0),
&at_z(0.0),
10.0,
"plate",
);
let bore = extrude(&Profile::circle(Vec2::ZERO, 40.0), &at_z(0.0), 10.0, "bore");
let key = extrude(
&Profile::rect(Vec2::new(18.0, 0.0), 6.0, 6.0),
&at_z(0.0),
10.0,
"key",
);
let body = union(
&difference(&plate.unwrap(), &bore.unwrap()).unwrap(),
&key.unwrap(),
)
.unwrap();
let r = 1.0;
let pairs = [("key.v_max", "bore.side"), ("key.v_min", "bore.side")];
let b = fillet(&body, &pairs, r, "f").unwrap();
let p = Vec2::new(391f64.sqrt(), 3.0);
let c = Vec2::new(345f64.sqrt(), 4.0);
let (t0, t1) = (Vec2::new(c.x, 3.0), c * (20.0 / 19.0));
let (g_round, round_len) = arc_green(c, r, t0, t1);
let (g_bore, bore_len) = arc_green(Vec2::ZERO, 20.0, t1, p);
let spandrel = (0.5 * p.cross(t0) + g_round + g_bore).abs();
let in_bore = |y: f64| y / 2.0 * (400.0 - y * y).sqrt() + 200.0 * (y / 20.0).asin();
let key_in_bore = in_bore(3.0) - in_bore(-3.0) - 15.0 * 6.0;
let volume = 10.0 * (3600.0 - 400.0 * PI + key_in_bore + 2.0 * spandrel);
let area =
measure::area(&body) + 4.0 * spandrel + 20.0 * (round_len - (t0 - p).norm() - bore_len);
assert_solid(&b, volume, area);
assert_eq!(names(&b, "f.round_0"), 1);
assert_eq!(names(&b, "f.round_1"), 1);
assert_eq!(kinds(&b, "cylinder"), 3);
}
#[test]
fn a_fillet_as_round_as_its_corners_closes_them_with_spheres() {
let (w, d, h, r) = (20.0, 12.0, 6.0, 2.0);
let body = extrude(&rounded(w, d, r), &at_z(0.0), h, "b").unwrap();
let b = fillet(&body, &[("b.end", "b.s1")], r, "f").unwrap();
let straight = 2.0 * (w - 2.0 * r) + 2.0 * (d - 2.0 * r);
let spandrel = r * r * (1.0 - PI / 4.0);
let off = r * (10.0 - 3.0 * PI) / (12.0 - 3.0 * PI);
let top = w * d - (4.0 - PI) * r * r;
let volume = top * h - spandrel * straight - 2.0 * PI * (r - off) * spandrel;
let perimeter = straight + 2.0 * PI * r;
let area = 2.0 * top + perimeter * h - (straight * r + PI * r * r) - perimeter * r
+ PI / 2.0 * r * straight
+ 2.0 * PI * r * r;
assert_solid(&b, volume, area);
assert_eq!(kinds(&b, "sphere"), 4);
assert_eq!(names(&b, "f.round_0"), 8);
}
#[test]
fn a_chamfer_as_wide_as_its_corner_arcs_narrows_them_to_points() {
let (w, d, h, r) = (40.0, 20.0, 10.0, 5.0);
let body = extrude(&rounded(w, d, r), &at_z(0.0), h, "rr").unwrap();
let b = chamfer(&body, &[("rr.end", "rr.s0")], r, "c").unwrap();
let straight = 2.0 * (w - 2.0 * r) + 2.0 * (d - 2.0 * r);
let section = w * d - (4.0 - PI) * r * r;
let volume = section * h - r * r / 2.0 * (straight + 2.0 * PI * (r - r / 3.0));
let area = section
+ (w - 2.0 * r) * (d - 2.0 * r)
+ (straight + 2.0 * PI * r) * (h - r)
+ 2f64.sqrt() * r * (straight + PI * r);
assert_solid(&b, volume, area);
assert_eq!(kinds(&b, "cone"), 4);
}
#[test]
fn a_chamfer_of_two_distances_sets_the_first_back_on_the_face_named() {
use springrep::{
blend::chamfer_two_edges,
measure::{edge_at, face_at},
primitive,
};
let b = primitive::block(&Frame::WORLD, Vec3::new(10.0, 8.0, 6.0), "blk").unwrap();
let (edge, _) = edge_at(&b, Vec3::new(10.0, 4.0, 6.0)).unwrap();
let (top, _) = face_at(&b, Vec3::new(5.0, 4.0, 6.0)).unwrap();
let (side, _) = face_at(&b, Vec3::new(10.0, 4.0, 3.0)).unwrap();
for (first, on_top, on_side) in [(top, 2.0, 1.0), (side, 1.0, 2.0)] {
let cut = chamfer_two_edges(&b, edge, first, 2.0, 1.0, "cha").unwrap();
assert!(check::check(&cut).is_empty());
let volume = 480.0 - 0.5 * 2.0 * 1.0 * 8.0;
assert!((measure::volume(&cut) - volume).abs() < 1e-9);
let on = |p: Vec3| face_at(&cut, p).is_some_and(|(_, d)| d < 1e-9);
assert!(on(Vec3::new(10.0 - on_top - 0.01, 4.0, 6.0)));
assert!(!on(Vec3::new(10.0 - on_top + 0.01, 4.0, 6.0)));
assert!(on(Vec3::new(10.0, 4.0, 6.0 - on_side - 0.01)));
assert!(!on(Vec3::new(10.0, 4.0, 6.0 - on_side + 0.01)));
}
let (bottom, _) = face_at(&b, Vec3::new(5.0, 4.0, 0.0)).unwrap();
assert!(chamfer_two_edges(&b, edge, bottom, 2.0, 1.0, "cha").is_err());
}