pub struct PeriodicBox { /* private fields */ }Expand description
An invertible unit-cell basis and its inverse.
Implementations§
Source§impl PeriodicBox
impl PeriodicBox
Sourcepub fn from_cell(cell: UnitCell) -> Result<Self, SpatialError>
pub fn from_cell(cell: UnitCell) -> Result<Self, SpatialError>
Builds a periodic box from crystallographic lengths and angles.
§Errors
Returns SpatialError::InvalidCell when any parameter is non-finite,
an edge is not positive, or the vectors are coplanar.
Sourcepub fn displacement(&self, left: [f32; 3], right: [f32; 3]) -> [f32; 3]
pub fn displacement(&self, left: [f32; 3], right: [f32; 3]) -> [f32; 3]
The shortest periodic displacement from left to right.
The nearest rounded fractional image is sufficient for an orthogonal cell. In a skewed cell a neighbouring lattice translation can be shorter, so a lattice-reduced basis is searched over a provably sufficient neighbourhood and the result is exact.
Sourcepub fn minimum_image(&self, left: [f32; 3], right: [f32; 3]) -> PeriodicImage
pub fn minimum_image(&self, left: [f32; 3], right: [f32; 3]) -> PeriodicImage
The shortest displacement and exact lattice image selected for it.
Exact distance ties retain the deposited image. Triclinic candidates are visited in a fixed order, so the selected image is deterministic.
Sourcepub fn displacement_f64(&self, left: [f64; 3], right: [f64; 3]) -> [f64; 3]
pub fn displacement_f64(&self, left: [f64; 3], right: [f64; 3]) -> [f64; 3]
Minimum-image displacement without rounding generated sample positions
to stored-coordinate precision. Image selection matches minimum_image.
Sourcepub fn distance_squared(&self, left: [f32; 3], right: [f32; 3]) -> f32
pub fn distance_squared(&self, left: [f32; 3], right: [f32; 3]) -> f32
Squared minimum-image separation.
Sourcepub fn fractional(&self, position: [f32; 3]) -> [f64; 3]
pub fn fractional(&self, position: [f32; 3]) -> [f64; 3]
Converts a Cartesian position to fractional cell coordinates.
Sourcepub fn cartesian(&self, fractional: [f64; 3]) -> [f32; 3]
pub fn cartesian(&self, fractional: [f64; 3]) -> [f32; 3]
Converts fractional cell coordinates to Cartesian ångström.
Sourcepub fn wrap(&self, position: [f32; 3]) -> [f32; 3]
pub fn wrap(&self, position: [f32; 3]) -> [f32; 3]
Wraps one position into the primary fractional interval [0, 1).
Sourcepub fn interpolate(
&self,
left: [f32; 3],
right: [f32; 3],
amount: f64,
) -> Option<[f32; 3]>
pub fn interpolate( &self, left: [f32; 3], right: [f32; 3], amount: f64, ) -> Option<[f32; 3]>
Interpolates along the shortest periodic geodesic and wraps the result.
Returns None for a non-finite interpolation parameter. Values outside
[0, 1] extrapolate along the same selected image.
Sourcepub fn contains_cutoff_sphere(&self, cutoff: f32) -> bool
pub fn contains_cutoff_sphere(&self, cutoff: f32) -> bool
Whether a sphere of radius cutoff around any point reaches no periodic
image of that same point.
When it holds, every pair within cutoff has exactly one image inside the
cutoff, so the minimum-image distance and the all-image neighbourhood
coincide. It fails once the cutoff exceeds half the shortest perpendicular
width of the cell.
Trait Implementations§
Source§impl Clone for PeriodicBox
impl Clone for PeriodicBox
impl Copy for PeriodicBox
Source§impl Debug for PeriodicBox
impl Debug for PeriodicBox
Source§impl PartialEq for PeriodicBox
impl PartialEq for PeriodicBox
impl StructuralPartialEq for PeriodicBox
Auto Trait Implementations§
impl Freeze for PeriodicBox
impl RefUnwindSafe for PeriodicBox
impl Send for PeriodicBox
impl Sync for PeriodicBox
impl Unpin for PeriodicBox
impl UnsafeUnpin for PeriodicBox
impl UnwindSafe for PeriodicBox
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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> ⓘ
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> ⓘ
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