From dcac249aa306c5d7ba77468e7c8b10b691b83c09 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Thu, 15 Sep 2022 11:51:22 +0200 Subject: [PATCH] Add `Circle::radius` --- crates/fj-kernel/src/path.rs | 7 +++++-- crates/fj-math/src/circle.rs | 5 +++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/crates/fj-kernel/src/path.rs b/crates/fj-kernel/src/path.rs index aef057a0c..0d1153d94 100644 --- a/crates/fj-kernel/src/path.rs +++ b/crates/fj-kernel/src/path.rs @@ -172,7 +172,6 @@ fn approx_circle( ) -> Vec> { let mut points = Vec::new(); - let radius = circle.a().magnitude(); let range = range.into(); // To approximate the circle, we use a regular polygon for which @@ -181,7 +180,11 @@ fn approx_circle( // and the circle. This is the same as the difference between // the circumscribed circle and the incircle. - let n = number_of_vertices_for_circle(tolerance, radius, range.length()); + let n = number_of_vertices_for_circle( + tolerance, + circle.radius(), + range.length(), + ); for i in 1..n { let angle = range.start().t diff --git a/crates/fj-math/src/circle.rs b/crates/fj-math/src/circle.rs index bdae2d0ac..9190650a6 100644 --- a/crates/fj-math/src/circle.rs +++ b/crates/fj-math/src/circle.rs @@ -75,6 +75,11 @@ impl Circle { self.center } + /// Access the radius of the circle + pub fn radius(&self) -> Scalar { + self.a().magnitude() + } + /// Access the vector that defines the starting point of the circle /// /// The point where this vector points from the circle center, is the zero