Line

Struct Line 

Source
pub struct Line<N: Num = f32>(pub Point<N>, pub Point<N>);

Tuple Fields§

§0: Point<N>§1: Point<N>

Implementations§

Source§

impl<N: Num> Line<N>

Source

pub fn new_from_points(points: &[N]) -> Self

Source

pub fn new_zero_value() -> Self

Source

pub fn start(self) -> Point<N>

Source

pub fn end(self) -> Point<N>

Source

pub fn min_point(self) -> Point<N>

Source

pub fn max_point(self) -> Point<N>

Source

pub fn left_x(self) -> N

Source

pub fn right_x(self) -> N

Source

pub fn bottom_y(self) -> N

Source

pub fn top_y(self) -> N

Source

pub fn is_empty(self) -> bool

Source

pub fn is_horizontal(self) -> bool

Source

pub fn is_vertical(self) -> bool

Source

pub fn is_straight(self) -> bool

Source

pub fn to<T: Num + From<N>>(&self) -> Line<T>

This is to allow creating a new Point, with a new type, from the type given. i.e. Point::new(1 as u8, 1 as u8)::to::<u32>()

Source

pub fn to_rect(self) -> Rect<N>

Source

pub fn interpolation_point(self, n: N) -> Point<N>

Where n is a valid from 0.0 to 1.0, this will return a point on the length of the line.

Source

pub fn reverse(self) -> Self

This swaps the start and end points.

Source

pub fn is_direction_negative_x(self) -> bool

Source

pub fn is_direction_positive_x(self) -> bool

Source

pub fn is_direction_negative_y(self) -> bool

Source

pub fn is_direction_positive_y(self) -> bool

Source

pub fn abs(&self) -> Self

Source

pub fn min(self, other: Self) -> Self

Source

pub fn max(self, other: Self) -> Self

Source

pub fn min_x(self) -> N

Source

pub fn min_y(self) -> N

Source

pub fn max_x(self) -> N

Source

pub fn max_y(self) -> N

Source

pub fn overlaps_line(self, other: Line<N>) -> bool

Source

pub fn overlaps_circle(self, other: Circle<N>) -> bool

Source

pub fn intersect_line(self, other: Line<N>) -> Option<Point<N>>

Source

pub fn intersect_rect(self, rect: Rect<N>) -> Option<Line<N>>

Calculates if this overlaps another rectangle. If it does, it will return the part of the line that intersects within that rectangle.

None is returned when no intersection is found.

Source

pub fn angle(self) -> N

Returns the atan2( y dist, x dist )

Source

pub fn direction(self) -> Size<f32>

Source

pub fn hypot(self) -> N

Source

pub fn hypot_sqrd(self) -> N

Source

pub fn rotate(self, angle: f32) -> Self

Source

pub fn rotate_around_zero(self, angle: f32) -> Self

Source

pub fn rotate_around_point(self, angle: f32, target: Point<N>) -> Self

Source

pub fn rotate_around_start(self, angle: f32) -> Self

Source

pub fn rotate_around_end(self, angle: f32) -> Self

Source

pub fn midpoint(self) -> Point<N>

Source

pub fn flip(self) -> Self

Returns a line where the start is at the end, and the end is at the start.

Source

pub fn into_iter_with_step(self, step: N) -> LineIterator<N>

Source

pub fn into_iter_inclusive(self) -> LineIterator<N>

Source

pub fn into_iter_inclusive_with_step(self, step: N) -> LineIterator<N>

Source

pub fn into_slice(self) -> [N; 4]

Source§

impl<N: Num + Signed> Line<N>

Source

pub fn direction_sign(&self) -> Point<N>

Source§

impl<N: Num + ToSignedClamped> Line<N>
where <N as ToSignedClamped>::Output: Signed,

Source

pub fn to_signed_clamped(self) -> Line<<N as ToSignedClamped>::Output>

Source

pub fn diff(self) -> Size<<N as ToSignedClamped>::Output>

Source

pub fn x_diff(self) -> <N as ToSignedClamped>::Output

Source

pub fn y_diff(self) -> <N as ToSignedClamped>::Output

Source

pub fn slope(self) -> <N as ToSignedClamped>::Output

Source

pub fn inverse_slope(self) -> <N as ToSignedClamped>::Output

Source

pub fn step_direction(self) -> Point<<N as ToSignedClamped>::Output>

Trait Implementations§

Source§

impl<N> Add<Line<N>> for Transform<N>
where N: Num,

Source§

type Output = Line<N>

The resulting type after applying the + operator.
Source§

fn add(self, line: Self::Output) -> Self::Output

Performs the + operation. Read more
Source§

impl Add<Line> for Random

Source§

type Output = Line

The resulting type after applying the + operator.
Source§

fn add(self, Line: Line) -> Line

Performs the + operation. Read more
Source§

impl<N: Num> Add<Point<N>> for Line<N>

Source§

type Output = Line<N>

The resulting type after applying the + operator.
Source§

fn add(self, other: Point<N>) -> Self

Performs the + operation. Read more
Source§

impl Add<Random> for Line

Source§

type Output = Line

The resulting type after applying the + operator.
Source§

fn add(self, rnd: Random) -> Self

Performs the + operation. Read more
Source§

impl<N> Add<Transform<N>> for Line<N>
where N: Num,

Source§

type Output = Line<N>

The resulting type after applying the + operator.
Source§

fn add(self, transform: Transform<N>) -> Self::Output

Performs the + operation. Read more
Source§

impl<N: Num> Add for Line<N>

Source§

type Output = Line<N>

The resulting type after applying the + operator.
Source§

fn add(self, other: Line<N>) -> Self

Performs the + operation. Read more
Source§

impl<N: Num> AddAssign<Point<N>> for Line<N>

Source§

fn add_assign(&mut self, other: Point<N>)

Performs the += operation. Read more
Source§

impl<N: Num> AddAssign for Line<N>

Source§

fn add_assign(&mut self, other: Line<N>)

Performs the += operation. Read more
Source§

impl<N: Clone + Num> Clone for Line<N>

Source§

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

Returns a duplicate 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<N: Debug + Num> Debug for Line<N>

Source§

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

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

impl<N: Num> Div<N> for Line<N>

Source§

type Output = Line<N>

The resulting type after applying the / operator.
Source§

fn div(self, other: N) -> Self

Performs the / operation. Read more
Source§

impl<N: Num> Div<Point<N>> for Line<N>

Source§

type Output = Line<N>

The resulting type after applying the / operator.
Source§

fn div(self, other: Point<N>) -> Self

Performs the / operation. Read more
Source§

impl<N: Num> Div<Size<N>> for Line<N>

Source§

type Output = Line<N>

The resulting type after applying the / operator.
Source§

fn div(self, other: Size<N>) -> Self

Performs the / operation. Read more
Source§

impl<N: Num> Div for Line<N>

Source§

type Output = Line<N>

The resulting type after applying the / operator.
Source§

fn div(self, other: Line<N>) -> Self

Performs the / operation. Read more
Source§

impl<N: Num> DivAssign<N> for Line<N>

Source§

fn div_assign(&mut self, other: N)

Performs the /= operation. Read more
Source§

impl<N: Num> DivAssign<Point<N>> for Line<N>

Source§

fn div_assign(&mut self, other: Point<N>)

Performs the /= operation. Read more
Source§

impl<N: Num> DivAssign<Size<N>> for Line<N>

Source§

fn div_assign(&mut self, other: Size<N>)

Performs the /= operation. Read more
Source§

impl<N: Num> DivAssign for Line<N>

Source§

fn div_assign(&mut self, other: Line<N>)

Performs the /= operation. Read more
Source§

impl<N: Num> From<(Point<N>, Point<N>)> for Line<N>

Source§

fn from((start, end): (Point<N>, Point<N>)) -> Self

Converts to this type from the input type.
Source§

impl<N: Num> Into<(Point<N>, Point<N>)> for Line<N>

Source§

fn into(self) -> (Point<N>, Point<N>)

Converts this type into the (usually inferred) input type.
Source§

impl<const N: usize> Into<Line> for BCurve<N>

Source§

fn into(self) -> Line

Converts this type into the (usually inferred) input type.
Source§

impl<N: Num> IntoIterator for Line<N>

Source§

type Item = Point<N>

The type of the elements being iterated over.
Source§

type IntoIter = LineIterator<N>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
Source§

impl<N: Num> Mul<N> for Line<N>

Source§

type Output = Line<N>

The resulting type after applying the * operator.
Source§

fn mul(self, other: N) -> Self

Performs the * operation. Read more
Source§

impl<N: Num> Mul<Point<N>> for Line<N>

Source§

type Output = Line<N>

The resulting type after applying the * operator.
Source§

fn mul(self, other: Point<N>) -> Self

Performs the * operation. Read more
Source§

impl<N: Num> Mul<Size<N>> for Line<N>

Source§

type Output = Line<N>

The resulting type after applying the * operator.
Source§

fn mul(self, other: Size<N>) -> Self

Performs the * operation. Read more
Source§

impl<N: Num> Mul for Line<N>

Source§

type Output = Line<N>

The resulting type after applying the * operator.
Source§

fn mul(self, other: Line<N>) -> Self

Performs the * operation. Read more
Source§

impl<N: Num> MulAssign<N> for Line<N>

Source§

fn mul_assign(&mut self, other: N)

Performs the *= operation. Read more
Source§

impl<N: Num> MulAssign<Point<N>> for Line<N>

Source§

fn mul_assign(&mut self, other: Point<N>)

Performs the *= operation. Read more
Source§

impl<N: Num> MulAssign<Size<N>> for Line<N>

Source§

fn mul_assign(&mut self, other: Size<N>)

Performs the *= operation. Read more
Source§

impl<N: Num> MulAssign for Line<N>

Source§

fn mul_assign(&mut self, other: Line<N>)

Performs the *= operation. Read more
Source§

impl<N: Num + Signed> Neg for Line<N>

Source§

type Output = Line<N>

The resulting type after applying the - operator.
Source§

fn neg(self) -> Self::Output

Performs the unary - operation. Read more
Source§

impl<N: PartialEq + Num> PartialEq for Line<N>

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<N: Num> Rem<Point<N>> for Line<N>

Source§

type Output = Line<N>

The resulting type after applying the % operator.
Source§

fn rem(self, other: Point<N>) -> Self

Performs the % operation. Read more
Source§

impl<N: Num> Rem for Line<N>

Source§

type Output = Line<N>

The resulting type after applying the % operator.
Source§

fn rem(self, other: Line<N>) -> Self

Performs the % operation. Read more
Source§

impl<N: INum> Shl<N> for Line<N>

Source§

type Output = Line<N>

The resulting type after applying the << operator.
Source§

fn shl(self, other: N) -> Self

Performs the << operation. Read more
Source§

impl<N: INum> ShlAssign<N> for Line<N>

Source§

fn shl_assign(&mut self, other: N)

Performs the <<= operation. Read more
Source§

impl<N: INum> Shr<N> for Line<N>

Source§

type Output = Line<N>

The resulting type after applying the >> operator.
Source§

fn shr(self, other: N) -> Self

Performs the >> operation. Read more
Source§

impl<N: INum> ShrAssign<N> for Line<N>

Source§

fn shr_assign(&mut self, other: N)

Performs the >>= operation. Read more
Source§

impl Sub<Line> for Random

Source§

type Output = Line

The resulting type after applying the - operator.
Source§

fn sub(self, Line: Line) -> Line

Performs the - operation. Read more
Source§

impl<N: Num> Sub<Point<N>> for Line<N>

Source§

type Output = Line<N>

The resulting type after applying the - operator.
Source§

fn sub(self, other: Point<N>) -> Self

Performs the - operation. Read more
Source§

impl<N: Num> Sub for Line<N>

Source§

type Output = Line<N>

The resulting type after applying the - operator.
Source§

fn sub(self, other: Line<N>) -> Self

Performs the - operation. Read more
Source§

impl<N: Num> SubAssign<Point<N>> for Line<N>

Source§

fn sub_assign(&mut self, other: Point<N>)

Performs the -= operation. Read more
Source§

impl<N: Num> SubAssign for Line<N>

Source§

fn sub_assign(&mut self, other: Line<N>)

Performs the -= operation. Read more
Source§

impl<O: Num, N: Num + ToRounded<O>> ToRounded<Line<O>> for Line<N>

Source§

fn to_rounded(self) -> Line<O>

Returns the value in the new type, but clamped.
Source§

impl<N: Copy + Num> Copy for Line<N>

Source§

impl<N: Num> StructuralPartialEq for Line<N>

Auto Trait Implementations§

§

impl<N> Freeze for Line<N>
where N: Freeze,

§

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

§

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

§

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

§

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

§

impl<N> UnwindSafe for Line<N>
where N: 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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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,

Source§

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>,

Source§

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>,

Source§

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.
Source§

impl<T, Rhs, Output> NumOps<Rhs, Output> for T
where T: Sub<Rhs, Output = Output> + Mul<Rhs, Output = Output> + Div<Rhs, Output = Output> + Add<Rhs, Output = Output> + Rem<Rhs, Output = Output>,