Skip to main content

MapPoint

Trait MapPoint 

Source
pub trait MapPoint<P> {
    // Required method
    fn map_point(&self, point: P, other: &Self) -> Result<P, Error>;
}
Expand description

Map a point from one shape to another.

§Example

use hoomd_geometry::{MapPoint, shape::Circle};
use hoomd_vector::Cartesian;

let closed_a = Circle {
    radius: 10.0.try_into()?,
};
let closed_b = Circle {
    radius: 20.0.try_into()?,
};

let mapped_point =
    closed_a.map_point(Cartesian::from([-1.0, 1.0]), &closed_b);

assert_eq!(mapped_point, Ok(Cartesian::from([-2.0, 2.0])));
assert_eq!(
    closed_a.map_point(Cartesian::from([-100.0, 1.0]), &closed_b),
    Err(hoomd_geometry::Error::PointOutsideShape)
);

Required Methods§

Source

fn map_point(&self, point: P, other: &Self) -> Result<P, Error>

Map a point from one boundary to another.

§Errors

Returns Error::PointOutsideShape when point is outside the shape self.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<const N: usize> MapPoint<Cartesian<N>> for Hypercuboid<N>

Source§

impl<const N: usize> MapPoint<Cartesian<N>> for Hypersphere<N>