Skip to main content

TernaryGeometry

Struct TernaryGeometry 

Source
pub struct TernaryGeometry { /* private fields */ }
Expand description

An equilateral ternary triangle and its component-to-vertex assignment.

Implementations§

Source§

impl TernaryGeometry

Source

pub const fn new( orientation: TriangleOrientation, vertex_order: VertexOrder, ) -> Self

Construct geometry with the given orientation and component order.

Source

pub const fn orientation(self) -> TriangleOrientation

Return the triangle orientation.

Source

pub const fn vertex_order(self) -> VertexOrder

Return the component-to-vertex assignment.

Source

pub fn vertex(self, component: Component) -> TernaryCartesian

Return the logical Cartesian vertex for a semantic component.

Source

pub fn vertices(self) -> [TernaryCartesian; 3]

Return the vertices in stable semantic A/B/C order.

Source

pub fn triangle_edge(self, edge: TriangleEdge) -> CartesianSegment

Return a complete directed geometric triangle edge.

Source

pub fn triangle_edges(self) -> [(TriangleEdge, CartesianSegment); 3]

Return all complete edges in directed boundary order.

Source

pub fn visible_edges( self, viewport: TernaryViewport, tolerance: Tolerance, ) -> Result<Vec<VisibleTriangleEdge>, Error>

Clip every original triangle edge and retain its identity and parameters.

Source

pub fn component_isoline( self, component: Component, value: f64, tolerance: Tolerance, ) -> Result<CartesianSegment, Error>

Construct the full-triangle segment where a semantic component equals value.

Values within tolerance of zero or one are snapped to that boundary. value = 0 returns the opposite edge and value = 1 returns a zero-length segment at the component vertex.

Source

pub fn visible_component_isoline( self, component: Component, value: f64, viewport: TernaryViewport, tolerance: Tolerance, ) -> Result<Option<CartesianSegment>, Error>

Construct and clip one semantic component isoline to a viewport.

Source

pub fn project( self, point: TernaryPoint, normalization: Normalization, tolerance: Tolerance, ) -> Result<TernaryCartesian, Error>

Validate and project a composition into the normalised ternary plane.

The explicit policy permits source data using a non-unit required sum. After validation, the three weights are divided by their validated sum before the barycentric weighted sum is calculated.

use plotters_ternary::{Normalization, TernaryGeometry, TernaryPoint, Tolerance};

let point = TernaryPoint::new(1.0 / 3.0, 1.0 / 3.0, 1.0 / 3.0);
let projected = TernaryGeometry::default().project(
    point,
    Normalization::RequireUnitSum,
    Tolerance::default(),
)?;
assert!((projected.x - 0.5).abs() < 1.0e-12);
Source

pub fn unproject( self, cartesian: TernaryCartesian, tolerance: Tolerance, ) -> Result<TernaryPoint, Error>

Recover unit-sum A/B/C component weights from a Cartesian point.

Points materially outside the full triangle return Error::CartesianOutsideTriangle. Weights whose absolute value is at most the absolute tolerance are set to zero, then the remaining weights are rescaled to sum to one. This admits small boundary round-off without silently clamping external points.

use plotters_ternary::{TernaryCartesian, TernaryGeometry, Tolerance};

let point = TernaryGeometry::default()
    .unproject(TernaryCartesian::new(0.5, 0.0), Tolerance::default())?;
assert_eq!(point.as_array(), [0.0, 0.5, 0.5]);
Source

pub fn classify( self, cartesian: TernaryCartesian, tolerance: Tolerance, ) -> Result<TrianglePointLocation, Error>

Classify a finite Cartesian point against the complete ternary triangle.

Non-finite coordinates are rejected because they have no geometric location. This operation does not consider future rectangular viewports.

Trait Implementations§

Source§

impl Clone for TernaryGeometry

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for TernaryGeometry

Source§

impl Debug for TernaryGeometry

Source§

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

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

impl Default for TernaryGeometry

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Eq for TernaryGeometry

Source§

impl Hash for TernaryGeometry

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for TernaryGeometry

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for TernaryGeometry

Auto Trait Implementations§

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 = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.