Skip to content

Commit

Permalink
Merge pull request #1088 from hannobraun/circle
Browse files Browse the repository at this point in the history
Add `Circle::radius`
  • Loading branch information
hannobraun authored Sep 15, 2022
2 parents bc1e83f + dcac249 commit f9f85dc
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
7 changes: 5 additions & 2 deletions crates/fj-kernel/src/path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,6 @@ fn approx_circle(
) -> Vec<ApproxPoint<1>> {
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
Expand All @@ -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
Expand Down
5 changes: 5 additions & 0 deletions crates/fj-math/src/circle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,11 @@ impl<const D: usize> Circle<D> {
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
Expand Down

0 comments on commit f9f85dc

Please sign in to comment.