pub struct TernaryPoint { /* private fields */ }Expand description
A ternary composition in semantic A/B/C order.
TernaryPoint::new performs no validation or normalisation. Call
TernaryPoint::validate before projecting a user-provided point.
Implementations§
Source§impl TernaryPoint
impl TernaryPoint
Sourcepub const fn new(a: f64, b: f64, c: f64) -> Self
pub const fn new(a: f64, b: f64, c: f64) -> Self
Construct an unvalidated composition without normalising it.
use plotters_ternary::{Normalization, TernaryPoint, Tolerance};
let raw = TernaryPoint::new(0.2, 0.3, 0.5);
let point = raw.validate(Normalization::RequireUnitSum, Tolerance::default())?;
assert_eq!(point.component(plotters_ternary::Component::C), 0.5);Sourcepub const fn component(self, component: Component) -> f64
pub const fn component(self, component: Component) -> f64
Return a component value selected by its semantic name.
Sourcepub fn validate(
self,
normalization: Normalization,
tolerance: Tolerance,
) -> Result<Self, Error>
pub fn validate( self, normalization: Normalization, tolerance: Tolerance, ) -> Result<Self, Error>
Validate this composition under an explicit sum policy.
Tiny finite negatives in [-tolerance.absolute, 0.0) become exactly
zero before the sum is evaluated. Larger negatives, non-finite values,
and near-zero sums fail. Normalization::Normalize then scales the
cleaned values to unit sum.
use plotters_ternary::{Normalization, TernaryPoint, Tolerance};
let point = TernaryPoint::new(2.0, 3.0, 5.0)
.validate(Normalization::Normalize, Tolerance::default())?;
assert!((point.sum() - 1.0).abs() < 1.0e-12);Trait Implementations§
Source§impl Clone for TernaryPoint
impl Clone for TernaryPoint
impl Copy for TernaryPoint
Source§impl Debug for TernaryPoint
impl Debug for TernaryPoint
Source§impl From<TernaryPoint> for [f64; 3]
impl From<TernaryPoint> for [f64; 3]
Source§fn from(point: TernaryPoint) -> Self
fn from(point: TernaryPoint) -> Self
Converts to this type from the input type.
Source§impl From<TernaryPoint> for (f64, f64, f64)
impl From<TernaryPoint> for (f64, f64, f64)
Source§fn from(point: TernaryPoint) -> Self
fn from(point: TernaryPoint) -> Self
Converts to this type from the input type.
Source§impl PartialEq for TernaryPoint
impl PartialEq for TernaryPoint
impl StructuralPartialEq for TernaryPoint
Auto Trait Implementations§
impl Freeze for TernaryPoint
impl RefUnwindSafe for TernaryPoint
impl Send for TernaryPoint
impl Sync for TernaryPoint
impl Unpin for TernaryPoint
impl UnsafeUnpin for TernaryPoint
impl UnwindSafe for TernaryPoint
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