Struct pointy::Line

source ·
pub struct Line<F>
where F: Float,
{ pub p0: Pt<F>, pub p1: Pt<F>, }
Expand description

A line

use pointy::Line;

let line = Line::new((10.0, 15.0), (0.0, 2.0));

Fields§

§p0: Pt<F>

First point

§p1: Pt<F>

Second point

Implementations§

source§

impl<F> Line<F>
where F: Float,

source

pub fn new<P0, P1>(p0: P0, p1: P1) -> Self
where P0: Into<Pt<F>>, P1: Into<Pt<F>>,

Create a new line

source

pub fn distance<P>(self, pt: P) -> F
where P: Into<Pt<F>>,

Get the distance from the line to a point

source

pub fn intersection(self, rhs: Self) -> Option<Pt<F>>

Get the point where two lines intersect

source

pub fn project<P>(self, pt: P) -> Pt<F>
where P: Into<Pt<F>>,

Project a point onto the line.

Returns the point on the line nearest to the given point.

Trait Implementations§

source§

impl<F> Clone for Line<F>
where F: Float + Clone,

source§

fn clone(&self) -> Line<F>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<F> Debug for Line<F>
where F: Float + Debug,

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<F> Default for Line<F>
where F: Float + Default,

source§

fn default() -> Line<F>

Returns the “default value” for a type. Read more
source§

impl<F> PartialEq for Line<F>
where F: Float + PartialEq,

source§

fn eq(&self, other: &Line<F>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<F> Copy for Line<F>
where F: Float + Copy,

source§

impl<F> Eq for Line<F>
where F: Float + Eq,

source§

impl<F> StructuralEq for Line<F>
where F: Float,

source§

impl<F> StructuralPartialEq for Line<F>
where F: Float,

Auto Trait Implementations§

§

impl<F> RefUnwindSafe for Line<F>
where F: RefUnwindSafe,

§

impl<F> Send for Line<F>
where F: Send,

§

impl<F> Sync for Line<F>
where F: Sync,

§

impl<F> Unpin for Line<F>
where F: Unpin,

§

impl<F> UnwindSafe for Line<F>
where F: UnwindSafe,

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

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

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.