Skip to content

Commit

Permalink
Prepare for making GenPolyline object-safe
Browse files Browse the repository at this point in the history
  • Loading branch information
hannobraun committed Sep 13, 2024
1 parent 2ab3734 commit 0ca08d3
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions crates/fj-core/src/geometry/curve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ pub trait GenPolyline<const D: usize> {
/// provided point.
fn line_segment_at(
&self,
point: impl Into<Point<1>>,
point: Point<1>,
tolerance: impl Into<Tolerance>,
) -> [Point<D>; 2];
}
Expand All @@ -80,10 +80,9 @@ impl<const D: usize> GenPolyline<D> for Circle<D> {

fn line_segment_at(
&self,
point: impl Into<Point<1>>,
point: Point<1>,
tolerance: impl Into<Tolerance>,
) -> [Point<D>; 2] {
let point = point.into();
let params = PathApproxParams::for_circle(self, tolerance);

[point.t - params.increment(), point.t + params.increment()]
Expand All @@ -98,11 +97,9 @@ impl<const D: usize> GenPolyline<D> for Line<D> {

fn line_segment_at(
&self,
point: impl Into<Point<1>>,
point: Point<1>,
_: impl Into<Tolerance>,
) -> [Point<D>; 2] {
let point = point.into();

// Collapse line segment into a point, as per documentation.
let point = self.origin() + self.direction() * point.t;

Expand All @@ -122,7 +119,7 @@ impl<const D: usize> GenPolyline<D> for Path<D> {

fn line_segment_at(
&self,
point: impl Into<Point<1>>,
point: Point<1>,
tolerance: impl Into<Tolerance>,
) -> [Point<D>; 2] {
match self {
Expand Down

0 comments on commit 0ca08d3

Please sign in to comment.