Struct tree_layout::Line

source ·
pub struct Line<T> {
    pub s: Point<T>,
    pub e: Point<T>,
}
Expand description

A lines segment of finite length, determined by a starting points and an ending points.

Fields§

§s: Point<T>

Start points of the lines segment.

§e: Point<T>

End points of the lines segment.

Implementations§

source§

impl<T> Line<T>

source

pub fn new<P>(start: P, end: P) -> Line<T>where Point<T>: From<P>,

Create a new line from two point

source

pub fn from_anchor<S, V>(start: S, v: V) -> Line<T>where T: Clone + Add<Output = T>, S: Into<Point<T>>, V: Into<Vector<T>>,

Create a new line from anchor point and vector

source§

impl<T> Line<T>where T: Clone + Num,

source

pub fn length(&self) -> Twhere T: Real,

Get the length of the line

source

pub fn as_vector(&self) -> Vector<T>

source

pub fn is_parallel(&self, rhs: &Line<T>) -> bool

Check if two line is parallel

source

pub fn is_orthogonal(&self, rhs: &Line<T>) -> bool

Check if two line is orthogonal

Trait Implementations§

source§

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

source§

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

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<T> Debug for Line<T>where T: Debug,

source§

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

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

impl<T> Default for Line<T>where T: Zero + One,

source§

fn default() -> Line<T>

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

impl<T> EuclideanDistance<T, Line<T>> for Point<T>where T: Float,

source§

fn euclidean_distance(&self, rhs: &Line<T>) -> T

source§

fn euclidean_squared(&self, rhs: &Line<T>) -> T

It is especially suitable when only the length needs to be compared Read more
source§

impl<T> Hash for Line<T>where T: Hash,

source§

fn hash<__H>(&self, state: &mut __H)where __H: Hasher,

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl<T> PartialEq for Line<T>where T: PartialEq,

source§

fn eq(&self, other: &Line<T>) -> 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<T> Projective<T> for Line<T>where T: Float,

source§

fn transform(&mut self, matrix: &[&T; 9])

Transform by a 3×3 matrix. Read more
§

fn translate(&mut self, x: &T, y: &T)

Transform by length $\delta x, \delta y$. Read more
§

fn translate_x(&mut self, x: &T)

Transform by length $\delta x$. Read more
§

fn translate_y(&mut self, y: &T)

Transform by length $\delta y$. Read more
§

fn rotate(&mut self, angle: &T)

Transform by rotate degree $\alpha$. Read more
§

fn rotate_point(&mut self, point: &[&T; 2], angle: &T)

Transform by rotate with a point $\alpha$. Read more
§

fn scale(&mut self, x: &T, y: &T)

Transform by scale $x, y$. Read more
§

fn scale_x(&mut self, x: &T)

Transform by scale $x$. Read more
§

fn scale_y(&mut self, y: &T)

Transform by scale $y$. Read more
§

fn reflect(&mut self, x: &T, y: &T)

Transform by skew $x, y$.
§

fn reflect_x(&mut self)

Transform by skew $x$.
§

fn reflect_y(&mut self)

Transform by skew $y$.
§

fn skew(&mut self, a: &T, b: &T)

Transform by angle $\alpha, \beta$. Read more
§

fn skew_x(&mut self, a: &T)

Transform by angle $\alpha$. Read more
§

fn skew_y(&mut self, b: &T)

Transform by angle $\beta$. Read more
source§

impl<T> Copy for Line<T>where T: Copy,

source§

impl<T> Eq for Line<T>where T: Eq,

source§

impl<T> StructuralEq for Line<T>

source§

impl<T> StructuralPartialEq for Line<T>

Auto Trait Implementations§

§

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

§

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

§

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

§

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

§

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

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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 Twhere 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 Twhere 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 Twhere 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.