fix(doc): To Object takes the face at the pick, not the first body near it (#429)
object_height, curved_target and curved_target_any took the first solid body with any face within its pick tolerance of the To Object point. That tolerance is 5 % of the body's size, so a large body beside a small target took picks made on the target: a ridge extruded up to a post 2 mm above a plate treated the plate as the target, nothing trimmed the tool, and it ran past the post (to x 9.08 instead of -2.31). They now share face_at: the nearest face over every solid body, still within that body's tolerance. appearance gains nearest_face (the face and its distance) and pick_tolerance, which face_index_at now uses as well. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
968a22897c
commit
1d7450b04c
3 files changed
+76
-35
No files matched your search
@@ -104,3 +104,24 @@ fn revolve_to_a_cylinder_follows_it() {
|
||||
}
|
||||
panic!("neither post was reached");
|
||||
}
|
||||
|
||||
/// To Object picks the face that is at the picked point, not the first body with any face
|
||||
/// near it. Here the pick is on a post (r 2.75) only 2 mm above a plate: the ridge must end
|
||||
/// on the post. Before, the plate (within 5 % of its size of the pick) was taken as the
|
||||
/// target, nothing trimmed the tool, and the ridge ran past the post.
|
||||
#[test]
|
||||
fn extrude_to_a_cylinder_beside_another_body() {
|
||||
let mut s = Session::default();
|
||||
run(&mut s, "solid.box", json!({"corner": [-98, -5, 0], "length": 101, "width": 10, "height": 3, "body_name": "Plate"}));
|
||||
run(&mut s, "solid.cylinder", json!({"base": [0, 0, 0], "axis": [0, 0, 1], "radius": 2.75, "height": 10, "body_name": "Post"}));
|
||||
// A ridge above the plate, y -1.5..0, z 4..7, from the plate's far end towards the post.
|
||||
run(&mut s, "sketch.create", json!({"plane": {"origin": [-98, 0, 0], "x_dir": [0, 1, 0], "y_dir": [0, 0, 1]}, "name": "End"}));
|
||||
run(&mut s, "sketch.rectangle.two_point", json!({"p0": [-1.5, 4], "p1": [0, 7]}));
|
||||
run(&mut s, "sketch.finish", json!({}));
|
||||
run(&mut s, "solid.extrude", json!({"sketch": "End", "to": [-2.75, 0, 5], "operation": "new", "body_name": "Ridge"}));
|
||||
let b = body(&mut s, "Ridge");
|
||||
// Its end follows the post: farthest at the ridge's edge y = -1.5, x = -√(2.75² − 1.5²).
|
||||
let end = b["bbox"]["max"][0].as_f64().unwrap_or(f64::MAX);
|
||||
assert!((end + (2.75f64 * 2.75 - 1.5 * 1.5).sqrt()).abs() < 1e-3, "{b}");
|
||||
assert!((b["bbox"]["min"][0].as_f64().unwrap_or(0.0) + 98.0).abs() < 1e-6, "{b}");
|
||||
}
|
||||
Reference in new issue
Block a user