Struct lyon::geom::LineSegment
[−]
pub struct LineSegment<S> { pub from: TypedPoint2D<S, UnknownUnit>, pub to: TypedPoint2D<S, UnknownUnit>, }
A linear segment.
Fields
from: TypedPoint2D<S, UnknownUnit>
to: TypedPoint2D<S, UnknownUnit>
Methods
impl<S> LineSegment<S> where
S: Scalar,
S: Scalar,
pub fn sample(&self, t: S) -> TypedPoint2D<S, UnknownUnit>
Sample the segment at t (expecting t between 0 and 1).
pub fn x(&self, t: S) -> S
Sample the x coordinate of the segment at t (expecting t between 0 and 1).
pub fn y(&self, t: S) -> S
Sample the y coordinate of the segment at t (expecting t between 0 and 1).
pub fn from(&self) -> TypedPoint2D<S, UnknownUnit>
pub fn to(&self) -> TypedPoint2D<S, UnknownUnit>
pub fn solve_t_for_x(&self, x: S) -> S
pub fn solve_t_for_y(&self, y: S) -> S
pub fn solve_y_for_x(&self, x: S) -> S
pub fn solve_x_for_y(&self, y: S) -> S
pub fn flip(&self) -> LineSegment<S>
Returns an inverted version of this segment where the beginning and the end points are swapped.
pub fn split_range(&self, t_range: Range<S>) -> LineSegment<S>
Return the sub-segment inside a given range of t.
This is equivalent splitting at the range's end points.
pub fn split(&self, t: S) -> (LineSegment<S>, LineSegment<S>)
Split this curve into two sub-segments.
pub fn before_split(&self, t: S) -> LineSegment<S>
Return the segment before the split point.
pub fn after_split(&self, t: S) -> LineSegment<S>
Return the segment after the split point.
pub fn split_at_x(&self, x: S) -> (LineSegment<S>, LineSegment<S>)
pub fn bounding_rect(&self) -> TypedRect<S, UnknownUnit>
Return the minimum bounding rectangle
pub fn to_vector(&self) -> TypedVector2D<S, UnknownUnit>
Returns the vector between this segment's from
and to
points.
pub fn to_line(&self) -> Line<S>
Returns the line containing this segment.
pub fn length(&self) -> S
Computes the length of this segment.
pub fn set_length(&mut self, new_length: S)
Changes the segment's length, moving destination point.
pub fn translate(&mut self, by: TypedVector2D<S, UnknownUnit>) -> LineSegment<S>
pub fn transform(
&self,
transform: &TypedTransform2D<S, UnknownUnit, UnknownUnit>
) -> LineSegment<S>
&self,
transform: &TypedTransform2D<S, UnknownUnit, UnknownUnit>
) -> LineSegment<S>
Applies the transform to this segment and returns the results.
pub fn intersection_t(&self, other: &LineSegment<S>) -> Option<(S, S)>
Computes the intersection (if any) between this segment and another one.
The result is provided in the form of the t
parameter of each
segment. To get the intersection point, sample one of the segments
at the corresponding value.
pub fn intersection(
&self,
other: &LineSegment<S>
) -> Option<TypedPoint2D<S, UnknownUnit>>
&self,
other: &LineSegment<S>
) -> Option<TypedPoint2D<S, UnknownUnit>>
pub fn intersects(&self, other: &LineSegment<S>) -> bool
Trait Implementations
impl<S> Copy for LineSegment<S> where
S: Copy,
S: Copy,
impl<S> PartialEq<LineSegment<S>> for LineSegment<S> where
S: PartialEq<S>,
S: PartialEq<S>,
fn eq(&self, __arg_0: &LineSegment<S>) -> bool
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, __arg_0: &LineSegment<S>) -> bool
This method tests for !=
.
impl<S> Segment for LineSegment<S> where
S: Scalar,
S: Scalar,
type Scalar = S
fn from(&self) -> TypedPoint2D<S, UnknownUnit>
Start of the curve.
fn to(&self) -> TypedPoint2D<S, UnknownUnit>
End of the curve.
fn sample(&self, t: S) -> TypedPoint2D<S, UnknownUnit>
Sample the curve at t (expecting t between 0 and 1).
fn x(&self, t: S) -> S
Sample x at t (expecting t between 0 and 1).
fn y(&self, t: S) -> S
Sample y at t (expecting t between 0 and 1).
fn derivative(&self, _t: S) -> TypedVector2D<S, UnknownUnit>
Sample the derivative at t (expecting t between 0 and 1).
fn dx(&self, _t: S) -> S
Sample x derivative at t (expecting t between 0 and 1).
fn dy(&self, _t: S) -> S
Sample y derivative at t (expecting t between 0 and 1).
fn split_range(&self, t_range: Range<S>) -> LineSegment<S>
Return the curve inside a given range of t. Read more
fn split(&self, t: S) -> (LineSegment<S>, LineSegment<S>)
Split this curve into two sub-curves.
fn before_split(&self, t: S) -> LineSegment<S>
Return the curve before the split point.
fn after_split(&self, t: S) -> LineSegment<S>
Return the curve after the split point.
fn flip(&self) -> LineSegment<S>
Swap the direction of the segment.
fn approximate_length(&self, _tolerance: S) -> S
Compute the length of the segment using a flattened approximation.
impl<S> Clone for LineSegment<S> where
S: Clone,
S: Clone,
fn clone(&self) -> LineSegment<S>
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl<S> FlatteningStep for LineSegment<S> where
S: Scalar,
S: Scalar,
fn flattening_step(&self, _tolerance: S) -> S
Find the interval of the begining of the curve that can be approximated with a line segment. Read more
fn flattened(self, tolerance: Self::Scalar) -> Flattened<Self::Scalar, Self>
Returns the flattened representation of the curve as an iterator, starting after the current point. Read more
impl<S> Debug for LineSegment<S> where
S: Debug,
S: Debug,
Auto Trait Implementations
impl<S> Send for LineSegment<S> where
S: Send,
S: Send,
impl<S> Sync for LineSegment<S> where
S: Sync,
S: Sync,