mirror of
https://github.com/hannobraun/Fornjot
synced 2025-05-13 14:28:27 +00:00
Return LineSegment
from line_segment_at
This commit is contained in:
parent
eecfa66461
commit
b61e5025eb
@ -5,7 +5,10 @@ use std::iter;
|
||||
use approx::AbsDiffEq;
|
||||
use fj_math::{Aabb, Point, Scalar, Sign, Transform, Vector};
|
||||
|
||||
use crate::geometry::{traits::GenPolyline, CurveBoundary, Tolerance};
|
||||
use crate::geometry::{
|
||||
traits::{GenPolyline, LineSegment},
|
||||
CurveBoundary, Tolerance,
|
||||
};
|
||||
|
||||
/// An n-dimensional circle
|
||||
///
|
||||
@ -188,7 +191,7 @@ impl<const D: usize> GenPolyline<D> for Circle<D> {
|
||||
&self,
|
||||
point: Point<1>,
|
||||
tolerance: Tolerance,
|
||||
) -> [Point<D>; 2] {
|
||||
) -> LineSegment<D> {
|
||||
let params = CircleApproxParams::new(self, tolerance);
|
||||
|
||||
// The approximation parameters have an increment, in curve coordinates,
|
||||
@ -211,8 +214,10 @@ impl<const D: usize> GenPolyline<D> for Circle<D> {
|
||||
});
|
||||
|
||||
// And finally, convert those into points of the desired dimensionality.
|
||||
points_curve
|
||||
.map(|point_curve| self.point_from_circle_coords([point_curve]))
|
||||
let points = points_curve
|
||||
.map(|point_curve| self.point_from_circle_coords([point_curve]));
|
||||
|
||||
LineSegment { points }
|
||||
}
|
||||
|
||||
fn generate_polyline(
|
||||
|
@ -2,18 +2,23 @@
|
||||
|
||||
use fj_math::{Line, Point};
|
||||
|
||||
use crate::geometry::{traits::GenPolyline, CurveBoundary, Tolerance};
|
||||
use crate::geometry::{
|
||||
traits::{GenPolyline, LineSegment},
|
||||
CurveBoundary, Tolerance,
|
||||
};
|
||||
|
||||
impl<const D: usize> GenPolyline<D> for Line<D> {
|
||||
fn origin(&self) -> Point<D> {
|
||||
self.origin()
|
||||
}
|
||||
|
||||
fn line_segment_at(&self, point: Point<1>, _: Tolerance) -> [Point<D>; 2] {
|
||||
fn line_segment_at(&self, point: Point<1>, _: Tolerance) -> LineSegment<D> {
|
||||
// Collapse line segment into a point, as per documentation.
|
||||
let point = self.origin() + self.direction() * point.t;
|
||||
|
||||
[point, point]
|
||||
LineSegment {
|
||||
points: [point, point],
|
||||
}
|
||||
}
|
||||
|
||||
fn generate_polyline(
|
||||
|
@ -66,6 +66,7 @@ impl SurfaceGeom {
|
||||
let [a, b] = self
|
||||
.u
|
||||
.line_segment_at(Point::from([point_surface.u]), tolerance.into())
|
||||
.points
|
||||
.map(|point_global| point_global + self.v * point_surface.v);
|
||||
|
||||
let c = a + (b - a) / 2.;
|
||||
|
@ -48,7 +48,7 @@ pub trait GenPolyline<const D: usize> {
|
||||
&self,
|
||||
point: Point<1>,
|
||||
tolerance: Tolerance,
|
||||
) -> [Point<D>; 2];
|
||||
) -> LineSegment<D>;
|
||||
|
||||
/// # Generate a polyline within the provided boundary
|
||||
fn generate_polyline(
|
||||
@ -72,7 +72,7 @@ impl<const D: usize> GenPolyline<D> for Path<D> {
|
||||
&self,
|
||||
point: Point<1>,
|
||||
tolerance: Tolerance,
|
||||
) -> [Point<D>; 2] {
|
||||
) -> LineSegment<D> {
|
||||
match self {
|
||||
Self::Circle(circle) => circle.line_segment_at(point, tolerance),
|
||||
Self::Line(line) => line.line_segment_at(point, tolerance),
|
||||
|
Loading…
Reference in New Issue
Block a user