Struct geom::Line[][src]

pub struct Line(Pt2D, Pt2D);

A line segment.

Implementations

impl Line[src]

pub fn new(pt1: Pt2D, pt2: Pt2D) -> Option<Line>[src]

Creates a line segment between two points. None if the points are the same.

pub fn must_new(pt1: Pt2D, pt2: Pt2D) -> Line[src]

Equivalent to Line::new(pt1, pt2).unwrap(). Use this to effectively document an assertion at the call-site.

pub fn infinite(&self) -> InfiniteLine[src]

Returns an infinite line passing through this line’s two points.

pub fn pt1(&self) -> Pt2D[src]

Returns the first point in this line segment.

pub fn pt2(&self) -> Pt2D[src]

Returns the second point in this line segment.

pub fn points(&self) -> Vec<Pt2D>[src]

Returns the two points in this line segment.

pub fn to_polyline(&self) -> PolyLine[src]

Returns a polyline containing these two points.

pub fn make_polygons(&self, thickness: Distance) -> Polygon[src]

Returns a thick line segment.

pub fn length(&self) -> Distance[src]

Length of the line segment

pub fn intersection(&self, other: &Line) -> Option<Pt2D>[src]

If two line segments intersect – including endpoints – return the point where they hit. Undefined if the two lines have more than one intersection point!

pub fn crosses(&self, other: &Line) -> bool[src]

Determine if two line segments intersect, but more so than just two endpoints touching.

pub fn intersection_infinite(&self, other: &InfiniteLine) -> Option<Pt2D>[src]

If the line segment intersects with an infinite line – including endpoints – return the point where they hit. Undefined if the segment and infinite line intersect at more than one point!

pub fn shift_right(&self, width: Distance) -> Line[src]

Perpendicularly shifts the line over to the right. Width must be non-negative.

pub fn shift_left(&self, width: Distance) -> Line[src]

Perpendicularly shifts the line over to the left. Width must be non-negative.

pub fn shift_either_direction(&self, width: Distance) -> Line[src]

Perpendicularly shifts the line to the right if positive or left if negative.

pub fn reverse(&self) -> Line[src]

Returns a reversed line segment

pub fn angle(&self) -> Angle[src]

The angle of the line segment, from the first to the second point

pub fn dist_along(&self, dist: Distance) -> Option<Pt2D>[src]

Returns a point along the line segment, unless the distance exceeds the segment’s length.

pub fn must_dist_along(&self, dist: Distance) -> Pt2D[src]

Equivalent to self.dist_along(dist).unwrap(). Use this to document an assertion at the call-site.

pub fn unbounded_dist_along(&self, dist: Distance) -> Pt2D[src]

pub fn unbounded_percent_along(&self, percent: f64) -> Pt2D[src]

pub fn percent_along(&self, percent: f64) -> Option<Pt2D>[src]

pub fn slice(&self, from: Distance, to: Distance) -> Option<Line>[src]

pub fn middle(&self) -> Option<Pt2D>[src]

pub fn contains_pt(&self, pt: Pt2D) -> bool[src]

pub fn dist_along_of_point(&self, pt: Pt2D) -> Option<Distance>[src]

pub fn percent_along_of_point(&self, pt: Pt2D) -> Option<f64>[src]

Trait Implementations

impl Clone for Line[src]

impl Debug for Line[src]

impl<'de> Deserialize<'de> for Line[src]

impl Display for Line[src]

impl PartialEq<Line> for Line[src]

impl Serialize for Line[src]

impl StructuralPartialEq for Line[src]

Auto Trait Implementations

impl RefUnwindSafe for Line

impl Send for Line

impl Sync for Line

impl Unpin for Line

impl UnwindSafe for Line

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> DeserializeOwned for T where
    T: for<'de> Deserialize<'de>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.