Skip to content

Commit 4500d5c

Browse files
PaulDancesunjay
authored andcommitted
Add circular_arc method on ProtocolClient
Classical implementation for now: splits the arc in many forward movements and rotations. Signed-off-by: Paul Mabileau <[email protected]>
1 parent 1c1c5df commit 4500d5c

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/ipc_protocol/protocol.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,19 @@ impl ProtocolClient {
367367
}
368368
}
369369

370+
pub async fn circular_arc(&self, id: TurtleId, radius: Distance, extent: Radians, direction: RotationDirection) {
371+
if radius.is_normal() && extent.is_normal() {
372+
let steps = 250; // Arbitrary value for now.
373+
let step = radius.abs() * extent.to_radians() / steps as f64;
374+
let rotation = radius.signum() * extent / steps as f64;
375+
376+
for _ in 0..steps {
377+
self.move_forward(id, step).await;
378+
self.rotate_in_place(id, rotation, direction).await;
379+
}
380+
}
381+
}
382+
370383
pub fn begin_fill(&self, id: TurtleId) {
371384
self.client.send(ClientRequest::BeginFill(id))
372385
}

0 commit comments

Comments
 (0)