From e4ccbf4f2149b7ba845d33cc6db964643180bf0f Mon Sep 17 00:00:00 2001 From: Brian Schwind Date: Sat, 14 Sep 2024 14:13:18 +0900 Subject: [PATCH] Add dx and dy functions to Sketch --- crates/opencascade/src/workplane.rs | 33 +++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/crates/opencascade/src/workplane.rs b/crates/opencascade/src/workplane.rs index 6a4d76f6..ab5c0f54 100644 --- a/crates/opencascade/src/workplane.rs +++ b/crates/opencascade/src/workplane.rs @@ -251,6 +251,39 @@ impl Sketch { self } + pub fn line_dx(mut self, dx: f64) -> Self { + let cursor = self.workplane.to_local_pos(self.cursor); + let new_point = self.workplane.to_world_pos(dvec3(cursor.x + dx, cursor.y, 0.0)); + let new_edge = Edge::segment(self.cursor, new_point); + self.cursor = new_point; + + self.add_edge(new_edge); + + self + } + + pub fn line_dy(mut self, dy: f64) -> Self { + let cursor = self.workplane.to_local_pos(self.cursor); + let new_point = self.workplane.to_world_pos(dvec3(cursor.x, cursor.y + dy, 0.0)); + let new_edge = Edge::segment(self.cursor, new_point); + self.cursor = new_point; + + self.add_edge(new_edge); + + self + } + + pub fn line_dx_dy(mut self, dx: f64, dy: f64) -> Self { + let cursor = self.workplane.to_local_pos(self.cursor); + let new_point = self.workplane.to_world_pos(dvec3(cursor.x + dx, cursor.y + dy, 0.0)); + let new_edge = Edge::segment(self.cursor, new_point); + self.cursor = new_point; + + self.add_edge(new_edge); + + self + } + pub fn arc(mut self, (x1, y1): (f64, f64), (x2, y2): (f64, f64), (x3, y3): (f64, f64)) -> Self { let p1 = self.workplane.to_world_pos(dvec3(x1, y1, 0.0)); let p2 = self.workplane.to_world_pos(dvec3(x2, y2, 0.0));