pub struct Segment {
pub q0: f64,
pub q1: f64,
pub p0: f64,
pub p1: f64,
}Expand description
A single line segment satisfying q0 ≤ 0 ≤ q1 and p1 ≤ p0
Fields§
§q0: f64The supply associated to this segment (q0 ≤ 0)
q1: f64The demand associated to this segment (q1 ≥ 0)
p0: f64The bidding price for the supply
p1: f64The asking price for the demand
Implementations§
Source§impl Segment
impl Segment
Sourcepub unsafe fn new_unchecked(a: Point, b: Point) -> (Self, f64)
pub unsafe fn new_unchecked(a: Point, b: Point) -> (Self, f64)
Construct a simple demand segment from two neighboring points on a demand curve.
Does not check if the points are properly ordered. Additionally returns the amount the points were translated.
Sourcepub fn new(a: Point, b: Point) -> Result<(Self, f64), (Self, f64)>
pub fn new(a: Point, b: Point) -> Result<(Self, f64), (Self, f64)>
Construct a simple demand segment from two neighboring points on a demand curve, performing validation to ensure the result is valid.
Additionally returns the amount the points were translated.
Sourcepub fn slope_intercept(&self) -> (f64, f64)
pub fn slope_intercept(&self) -> (f64, f64)
Compute the slope and p-intercept of the line segment.
Sourcepub unsafe fn clip_unchecked(self, qmin: f64, qmax: f64) -> Self
pub unsafe fn clip_unchecked(self, qmin: f64, qmax: f64) -> Self
Clip the segment to the provided interval.
Does not validate the requested interval.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Segment
impl RefUnwindSafe for Segment
impl Send for Segment
impl Sync for Segment
impl Unpin for Segment
impl UnwindSafe for Segment
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§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