Struct chemfiles::UnitCellRef
source · pub struct UnitCellRef<'a> { /* private fields */ }
Expand description
An analog to a reference to an unit cell (&UnitCell
)
Methods from Deref<Target = UnitCell>§
sourcepub fn lengths(&self) -> [f64; 3]
pub fn lengths(&self) -> [f64; 3]
Get the three lengths of the cell, in Angstroms.
Example
let cell = UnitCell::new([30.0, 30.0, 23.0]);
assert_eq!(cell.lengths(), [30.0, 30.0, 23.0]);
sourcepub fn angles(&self) -> [f64; 3]
pub fn angles(&self) -> [f64; 3]
Get the three angles of the cell, in degrees.
Example
let cell = UnitCell::new([20.0, 20.0, 20.0]);
assert_eq!(cell.angles(), [90.0, 90.0, 90.0]);
let cell = UnitCell::triclinic([20.0, 20.0, 20.0], [100.0, 120.0, 90.0]);
assert_eq!(cell.angles()[0], 100.0);
// Rounding errors might occur due to internal representation
assert!((cell.angles()[1] - 120.0).abs() < 1e-12);
assert_eq!(cell.angles()[2], 90.0);
sourcepub fn matrix(&self) -> [[f64; 3]; 3]
pub fn matrix(&self) -> [[f64; 3]; 3]
Get the unit cell matricial representation.
The unit cell representation is obtained by aligning the a vector along the x axis and putting the b vector in the xy plane. This make the matrix an upper triangular matrix:
| a_x b_x c_x |
| 0 b_y c_y |
| 0 0 c_z |
Example
let cell = UnitCell::new([10.0, 20.0, 30.0]);
let matrix = cell.matrix();
assert_eq!(matrix[0][0], 10.0);
assert_eq!(matrix[1][1], 20.0);
assert_eq!(matrix[2][2], 30.0);
assert!(matrix[1][2].abs() < 1e-9);
sourcepub fn shape(&self) -> CellShape
pub fn shape(&self) -> CellShape
Get the shape of the unit cell.
Example
let cell = UnitCell::new([10.0, 20.0, 30.0]);
assert_eq!(cell.shape(), CellShape::Orthorhombic);