Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Circle::radius #1088

Merged
merged 1 commit into from
Sep 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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