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

Fix edge approximation ignoring vertices #1028

Merged
merged 2 commits into from
Sep 1, 2022
Merged
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
35 changes: 18 additions & 17 deletions crates/fj-kernel/src/algorithms/approx/edge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,26 +14,27 @@ impl Approx for Edge {
(): Self::Params,
) -> Self::Approximation {
// The range is only used for circles right now.
let range = {
let start_curve = Point::from([Scalar::ZERO]);
let end_curve = Point::from([Scalar::TAU]);

// We're dealing with a circle here. Start and end are identical
// points, in global coordinates.
let point_global = self
.global()
.curve()
.kind()
.point_from_curve_coords(start_curve);

RangeOnCurve {
boundary: [
(start_curve, point_global),
(end_curve, point_global),
],
let boundary = match self.vertices().get() {
Some(vertices) => vertices
.map(|vertex| (vertex.position(), vertex.global().position())),
None => {
let start_curve = Point::from([Scalar::ZERO]);
let end_curve = Point::from([Scalar::TAU]);

// We're dealing with a circle here. Start and end are identical
// points, in global coordinates.
let point_global = self
.global()
.curve()
.kind()
.point_from_curve_coords(start_curve);

[(start_curve, point_global), (end_curve, point_global)]
}
};

let range = RangeOnCurve { boundary };

self.curve().approx(tolerance, range)
}
}