pub struct Line2 {
pub slope: f64,
pub intercept: f64,
pub is_vertical: bool,
pub x_const: f64,
}Expand description
A 2-D line in slope-intercept form. Vertical lines have is_vertical = true
and use x_const instead of slope/intercept.
Fields§
§slope: f64Slope m in y = m·x + b. Unused for vertical lines.
intercept: f64Intercept b in y = m·x + b. Unused for vertical lines.
is_vertical: boolTrue for a vertical line x = x_const.
x_const: f64For vertical lines: the constant x-value.
Implementations§
Source§impl Line2
impl Line2
Sourcepub fn new(slope: f64, intercept: f64) -> Self
pub fn new(slope: f64, intercept: f64) -> Self
Create a non-vertical line y = slope·x + intercept.
Sourcepub fn through_points(a: Point2, b: Point2) -> Self
pub fn through_points(a: Point2, b: Point2) -> Self
Create a line through two points.
Sourcepub fn y_at(&self, x: f64) -> f64
pub fn y_at(&self, x: f64) -> f64
Evaluate the line at x: returns y = slope·x + intercept, or x_const
for vertical lines (in which case x should equal x_const).
Sourcepub fn x_at(&self, y: f64) -> f64
pub fn x_at(&self, y: f64) -> f64
Evaluate the x-value at a given y: returns x = (y - b) / m, or
x_const for vertical lines.
Sourcepub fn is_parallel(&self, other: &Line2) -> bool
pub fn is_parallel(&self, other: &Line2) -> bool
Is this line parallel to other?
Trait Implementations§
impl Copy for Line2
impl StructuralPartialEq for Line2
Auto Trait Implementations§
impl Freeze for Line2
impl RefUnwindSafe for Line2
impl Send for Line2
impl Sync for Line2
impl Unpin for Line2
impl UnsafeUnpin for Line2
impl UnwindSafe for Line2
Blanket Implementations§
§impl<S, A> Aggregate<Result<S, Error>> for Awhere
A: Aggregate<S>,
impl<S, A> Aggregate<Result<S, Error>> for Awhere
A: Aggregate<S>,
Aggregate shares in an MPC protocol.
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more