Implement Default for Quaternion and UnitQuaternion.

This commit is contained in:
Mara Bos 2019-04-16 10:12:09 +02:00
parent e6265da980
commit 85c931520a
1 changed files with 14 additions and 0 deletions

View File

@ -30,6 +30,14 @@ pub struct Quaternion<N: RealField> {
pub coords: Vector4<N>,
}
impl<N: RealField> Default for Quaternion<N> {
fn default() -> Self {
Quaternion {
coords: Vector4::zeros()
}
}
}
#[cfg(feature = "abomonation-serialize")]
impl<N: RealField> Abomonation for Quaternion<N>
where Vector4<N>: Abomonation
@ -1422,6 +1430,12 @@ impl<N: RealField> UnitQuaternion<N> {
}
}
impl<N: RealField> Default for UnitQuaternion<N> {
fn default() -> Self {
Self::identity()
}
}
impl<N: RealField + fmt::Display> fmt::Display for UnitQuaternion<N> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
if let Some(axis) = self.axis() {