forked from 1b-agent/opencadstudio-upstream
Support planar circle tangent snapping
This commit is contained in:
1 parent
5b4c1da881
commit
390d42a63a
4 files changed
+121
-3
No files matched your search
Vendored
+33
-1
@@ -1227,7 +1227,8 @@ fn translated_prototype_wire(
|
||||
p2[axis] += delta_f32[axis];
|
||||
}
|
||||
}
|
||||
TangentGeom::Circle { center, .. } => {
|
||||
TangentGeom::Circle { center, .. }
|
||||
| TangentGeom::PlanarCircle { center, .. } => {
|
||||
for axis in 0..3 {
|
||||
center[axis] += delta_f32[axis];
|
||||
}
|
||||
@@ -2282,6 +2283,37 @@ fn transform_tangent(
|
||||
radius: radius * s,
|
||||
}
|
||||
}
|
||||
TangentGeom::PlanarCircle {
|
||||
center,
|
||||
axis_x,
|
||||
axis_y,
|
||||
radius,
|
||||
} => {
|
||||
let c = t.apply(Vector3::new(
|
||||
center[0] as f64,
|
||||
center[1] as f64,
|
||||
center[2] as f64,
|
||||
));
|
||||
let x = t.apply_rotation(Vector3::new(
|
||||
axis_x[0] as f64,
|
||||
axis_x[1] as f64,
|
||||
axis_x[2] as f64,
|
||||
));
|
||||
let y = t.apply_rotation(Vector3::new(
|
||||
axis_y[0] as f64,
|
||||
axis_y[1] as f64,
|
||||
axis_y[2] as f64,
|
||||
));
|
||||
let scale = (x.length() + y.length()) * 0.5;
|
||||
let x = x.normalize();
|
||||
let y = y.normalize();
|
||||
TangentGeom::PlanarCircle {
|
||||
center: [c.x as f32, c.y as f32, c.z as f32],
|
||||
axis_x: [x.x as f32, x.y as f32, x.z as f32],
|
||||
axis_y: [y.x as f32, y.y as f32, y.z as f32],
|
||||
radius: radius * scale as f32,
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -29,8 +29,15 @@ pub enum SnapHint {
|
||||
pub enum TangentGeom {
|
||||
/// Infinite line through these two world-space points.
|
||||
Line { p1: [f32; 3], p2: [f32; 3] },
|
||||
/// Circle/arc.
|
||||
/// Round geometry in the world XY plane.
|
||||
Circle { center: [f32; 3], radius: f32 },
|
||||
/// Complete circle in an arbitrary world-space plane.
|
||||
PlanarCircle {
|
||||
center: [f32; 3],
|
||||
axis_x: [f32; 3],
|
||||
axis_y: [f32; 3],
|
||||
radius: f32,
|
||||
},
|
||||
}
|
||||
|
||||
/// A 1-D entity (line, arc, polyline) represented as an ordered set of
|
||||
|
||||
Reference in new issue
Block a user