use crate::TransformationMatrix;
pub struct BuildUpMatrix {
pub row0: Option<[f64; 4]>,
pub row1: Option<[f64; 4]>,
pub row2: Option<[f64; 4]>,
}
impl BuildUpMatrix {
pub const fn empty() -> Self {
BuildUpMatrix {
row0: None,
row1: None,
row2: None,
}
}
pub const fn get_matrix(&self) -> Option<TransformationMatrix> {
match self {
BuildUpMatrix {
row0: Some(r1),
row1: Some(r2),
row2: Some(r3),
} => Some(TransformationMatrix::from_matrix([*r1, *r2, *r3])),
_ => None,
}
}
pub const fn is_set(&self) -> bool {
matches!(
self,
BuildUpMatrix {
row0: Some(_),
row1: Some(_),
row2: Some(_),
}
)
}
pub const fn is_partly_set(&self) -> bool {
self.row0.is_some() || self.row1.is_some() || self.row2.is_some()
}
pub fn set_row(&mut self, row: usize, data: [f64; 4]) {
match row {
0 => self.row0 = Some(data),
1 => self.row1 = Some(data),
2 => self.row2 = Some(data),
_ => panic!("Invalid value in 'set_row' on a BuildUpMatrix"),
}
}
}