pub struct Slope<T>{ /* private fields */ }Expand description
A simplified slope between two integer points.
Implementations§
Source§impl<T> Slope<T>
impl<T> Slope<T>
Sourcepub fn new(horizontal: T, vertical: T) -> Result<Self>
pub fn new(horizontal: T, vertical: T) -> Result<Self>
Can return an error if horizontal and vertical are both 0.
let slope = aoclib_rs::point::Slope::new(2, 4).unwrap();
assert_eq!(slope.horizontal(), 1);
assert_eq!(slope.vertical(), 2);Sourcepub fn from_points_2d(pov: &Point2d<T>, other: &Point2d<T>) -> Result<Self>
pub fn from_points_2d(pov: &Point2d<T>, other: &Point2d<T>) -> Result<Self>
Can return an error if both points are the same.
use aoclib_rs::point::{Point2d, Slope};
let slope = Slope::from_points_2d(&Point2d::new(0, 0), &Point2d::new(2, 4)).unwrap();
assert_eq!(slope.horizontal(), 1);
assert_eq!(slope.vertical(), 2);pub fn horizontal(&self) -> T
pub fn vertical(&self) -> T
Trait Implementations§
impl<T> Copy for Slope<T>
impl<T> Eq for Slope<T>
impl<T> StructuralPartialEq for Slope<T>
Auto Trait Implementations§
impl<T> Freeze for Slope<T>where
T: Freeze,
impl<T> RefUnwindSafe for Slope<T>where
T: RefUnwindSafe,
impl<T> Send for Slope<T>where
T: Send,
impl<T> Sync for Slope<T>where
T: Sync,
impl<T> Unpin for Slope<T>where
T: Unpin,
impl<T> UnwindSafe for Slope<T>where
T: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more