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

Clean up approx module #1003

Merged
merged 11 commits into from
Aug 26, 2022
Prev Previous commit
Next Next commit
Implement Approx for Curve
hannobraun committed Aug 26, 2022

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
commit 20986a6e8e5f6e1be94997da09e5ff29d05dbac8
14 changes: 12 additions & 2 deletions crates/fj-kernel/src/algorithms/approx/curve.rs
Original file line number Diff line number Diff line change
@@ -2,9 +2,19 @@ use std::cmp::max;

use fj_math::{Circle, Point, Scalar};

use crate::objects::{CurveKind, GlobalCurve};
use crate::objects::{Curve, CurveKind, GlobalCurve};

use super::{Local, Tolerance};
use super::{Approx, Local, Tolerance};

impl Approx for Curve {
type Approximation = Vec<Local<Point<1>>>;

fn approx(&self, tolerance: Tolerance) -> Self::Approximation {
let mut points = Vec::new();
approx_curve(self.global(), tolerance, &mut points);
points
}
}

/// Compute an approximation of the curve
///
6 changes: 2 additions & 4 deletions crates/fj-kernel/src/algorithms/approx/edge.rs
Original file line number Diff line number Diff line change
@@ -2,15 +2,13 @@ use fj_math::Point;

use crate::objects::{Edge, Vertex, VerticesOfEdge};

use super::{curve::approx_curve, Approx, Local};
use super::{Approx, Local};

impl Approx for Edge {
type Approximation = Vec<Local<Point<1>>>;

fn approx(&self, tolerance: super::Tolerance) -> Self::Approximation {
let mut points = Vec::new();

approx_curve(self.curve().global(), tolerance, &mut points);
let mut points = self.curve().approx(tolerance);
approx_edge(*self.vertices(), &mut points);

points