diff --git a/CHANGELOG.md b/CHANGELOG.md index cf67592..899a0f7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,10 @@ This project adheres to [Semantic Versioning](http://semver.org/). default_fn! macro to reduce code duplication and complexity. Currently only needed for non-functional SIMD feature. - Refactored SIMD code into separate source files. See README.md for details. + - **Breaking**: Quaternion memory layout changed to `[x, y, z, w]`. The + `From` and `Into` impls for `[S; 4]` and `(S, S, S, S)` have been changed + accordingly. + ### Added diff --git a/src/quaternion.rs b/src/quaternion.rs index 6a48b52..6ef034b 100644 --- a/src/quaternion.rs +++ b/src/quaternion.rs @@ -46,10 +46,10 @@ use mint; #[derive(Copy, Clone, Debug, PartialEq)] #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] pub struct Quaternion { - /// The scalar part of the quaternion. - pub s: S, /// The vector part of the quaternion. pub v: Vector3, + /// The scalar part of the quaternion. + pub s: S, } impl Quaternion { @@ -542,7 +542,7 @@ impl Into<[S; 4]> for Quaternion { #[inline] fn into(self) -> [S; 4] { match self.into() { - (w, xi, yj, zk) => [w, xi, yj, zk], + (xi, yj, zk, w) => [xi, yj, zk, w], } } } @@ -564,7 +564,7 @@ impl AsMut<[S; 4]> for Quaternion { impl From<[S; 4]> for Quaternion { #[inline] fn from(v: [S; 4]) -> Quaternion { - Quaternion::new(v[0], v[1], v[2], v[3]) + Quaternion::new(v[3], v[0], v[1], v[2]) } } @@ -589,7 +589,7 @@ impl Into<(S, S, S, S)> for Quaternion { Quaternion { s, v: Vector3 { x, y, z }, - } => (s, x, y, z), + } => (x, y, z, s), } } } @@ -612,7 +612,7 @@ impl From<(S, S, S, S)> for Quaternion { #[inline] fn from(v: (S, S, S, S)) -> Quaternion { match v { - (w, xi, yj, zk) => Quaternion::new(w, xi, yj, zk), + (xi, yj, zk, w) => Quaternion::new(w, xi, yj, zk), } } } @@ -698,12 +698,12 @@ mod tests { use vector::*; const QUATERNION: Quaternion = Quaternion { - s: 1.0, v: Vector3 { - x: 2.0, - y: 3.0, - z: 4.0, + x: 1.0, + y: 2.0, + z: 3.0, }, + s: 4.0, }; #[test]