pub struct Line(pub [Point; 2]);
Expand description
Line segment curve
Tuple Fields§
§0: [Point; 2]
Implementations§
source§impl Line
impl Line
pub fn new(p0: impl Into<Point>, p1: impl Into<Point>) -> Self
pub fn ends(&self) -> (Line, Line)
sourcepub fn intersect(&self, other: Line) -> Option<(Scalar, Scalar)>
pub fn intersect(&self, other: Line) -> Option<(Scalar, Scalar)>
Find intersection of two lines
Returns pair of t
parameters for this line and the other line.
Found by solving self.at(t0) == other.at(t1)
. Actual intersection of
line segments can be found by making sure that 0.0 <= t0 <= 1.0 && 0.0 <= t1 <= 1.0
sourcepub fn intersect_point(&self, other: Line) -> Option<Point>
pub fn intersect_point(&self, other: Line) -> Option<Point>
Find intersection point between two line segments
Trait Implementations§
source§impl Curve for Line
impl Curve for Line
source§fn flatness(&self) -> Scalar
fn flatness(&self) -> Scalar
Correspond to maximum deviation of the curve from the straight line
f = max |curve(t) - line(curve_start, curve_end)(t)|
. This function
actually returns 16.0 * f^2
to avoid unneeded division and square root.source§fn deriv(&self) -> Segment
fn deriv(&self) -> Segment
Derivative with respect to t,
deriv(t) = [curve'(t)_x, curve'(t)_y]
source§fn split_at(&self, t: Scalar) -> (Self, Self)
fn split_at(&self, t: Scalar) -> (Self, Self)
Split the curve at parameter value
t
source§fn cut(&self, a: Scalar, b: Scalar) -> Self
fn cut(&self, a: Scalar, b: Scalar) -> Self
Create sub-curve specified starting at parameter value
a
and ending at value b
source§fn bbox(&self, init: Option<BBox>) -> BBox
fn bbox(&self, init: Option<BBox>) -> BBox
Extend provided
init
bounding box with the bounding box of the curvesource§fn offset(&self, dist: Scalar, out: &mut impl Extend<Segment>)
fn offset(&self, dist: Scalar, out: &mut impl Extend<Segment>)
Offset the curve by distance
dist
, result is inserted into out
containersource§fn reverse(&self) -> Self
fn reverse(&self) -> Self
Identical curve but directed from end to start, instead of start to end.
source§fn roots(&self) -> CurveRoots
fn roots(&self) -> CurveRoots
Find roots of the equation
curve(t)_y = 0
. Values of the parameter at which curve
crosses y axis.source§fn extremities(&self) -> CurveExtremities
fn extremities(&self) -> CurveExtremities
Find all extremities of the curve
curve'(t)_x = 0 || curve'(t)_y = 0
source§fn length(&self, t0: Scalar, t1: Scalar) -> Scalar
fn length(&self, t0: Scalar, t1: Scalar) -> Scalar
Calculate length of the curve from
t0
to t1
source§fn flatten(&self, tr: Transform, flatness: Scalar) -> CurveFlattenIter ⓘ
fn flatten(&self, tr: Transform, flatness: Scalar) -> CurveFlattenIter ⓘ
Convert curve to an iterator over line segments with desired flatness
source§fn split(&self) -> (Self, Self)
fn split(&self) -> (Self, Self)
Optimized version of
Curve::split_at(0.5)
source§impl PartialEq for Line
impl PartialEq for Line
impl Copy for Line
impl StructuralPartialEq for Line
Auto Trait Implementations§
impl Freeze for Line
impl RefUnwindSafe for Line
impl Send for Line
impl Sync for Line
impl Unpin for Line
impl UnwindSafe for Line
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more