pdbtbx/read/pdb/
temporary_structs.rs1use crate::TransformationMatrix;
2
3pub struct BuildUpMatrix {
5 pub row0: Option<[f64; 4]>,
7 pub row1: Option<[f64; 4]>,
9 pub row2: Option<[f64; 4]>,
11}
12
13impl BuildUpMatrix {
14 pub const fn empty() -> Self {
16 BuildUpMatrix {
17 row0: None,
18 row1: None,
19 row2: None,
20 }
21 }
22 pub const fn get_matrix(&self) -> Option<TransformationMatrix> {
24 match self {
25 BuildUpMatrix {
26 row0: Some(r1),
27 row1: Some(r2),
28 row2: Some(r3),
29 } => Some(TransformationMatrix::from_matrix([*r1, *r2, *r3])),
30 _ => None,
31 }
32 }
33 pub const fn is_set(&self) -> bool {
35 matches!(
36 self,
37 BuildUpMatrix {
38 row0: Some(_),
39 row1: Some(_),
40 row2: Some(_),
41 }
42 )
43 }
44 pub const fn is_partly_set(&self) -> bool {
46 self.row0.is_some() || self.row1.is_some() || self.row2.is_some()
47 }
48 pub fn set_row(&mut self, row: usize, data: [f64; 4]) {
50 match row {
51 0 => self.row0 = Some(data),
52 1 => self.row1 = Some(data),
53 2 => self.row2 = Some(data),
54 _ => panic!("Invalid value in 'set_row' on a BuildUpMatrix"),
55 }
56 }
57}