diff --git a/nalgebra-glm/src/constructors.rs b/nalgebra-glm/src/constructors.rs index 6d0463ce..25a3432f 100644 --- a/nalgebra-glm/src/constructors.rs +++ b/nalgebra-glm/src/constructors.rs @@ -134,5 +134,5 @@ pub fn mat4(m11: N, m12: N, m13: N, m14: N, m21: N, m22: N, m23: N, m /// Creates a new quaternion. pub fn quat(x: N, y: N, z: N, w: N) -> Qua { - Qua::new(x, y, z, w) + Qua::new(w, x, y, z) } diff --git a/nalgebra-glm/src/ext/scalar_common.rs b/nalgebra-glm/src/ext/scalar_common.rs index 6829326d..a94bc294 100644 --- a/nalgebra-glm/src/ext/scalar_common.rs +++ b/nalgebra-glm/src/ext/scalar_common.rs @@ -12,12 +12,12 @@ pub fn max4_scalar(a: N, b: N, c: N, d: N) -> N { na::sup(&na::sup(&a, &b), &na::sup(&c, &d)) } -/// Returns the maximum among three values. +/// Returns the minimum among three values. pub fn min3_scalar(a: N, b: N, c: N) -> N { na::inf(&na::inf(&a, &b), &c) } -/// Returns the maximum among four values. +/// Returns the minimum among four values. pub fn min4_scalar(a: N, b: N, c: N, d: N) -> N { na::inf(&na::inf(&a, &b), &na::inf(&c, &d)) } \ No newline at end of file diff --git a/nalgebra-glm/src/ext/scalar_constants.rs b/nalgebra-glm/src/ext/scalar_constants.rs index 89e3746c..f4a25718 100644 --- a/nalgebra-glm/src/ext/scalar_constants.rs +++ b/nalgebra-glm/src/ext/scalar_constants.rs @@ -1,7 +1,7 @@ use approx::AbsDiffEq; use na::Real; -/// Default epsilon value used for apporximate comparison. +/// Default epsilon value used for approximate comparison. pub fn epsilon>() -> N { N::default_epsilon() } diff --git a/nalgebra-glm/src/gtc/constants.rs b/nalgebra-glm/src/gtc/constants.rs index 39255ecd..92495a4a 100644 --- a/nalgebra-glm/src/gtc/constants.rs +++ b/nalgebra-glm/src/gtc/constants.rs @@ -78,7 +78,7 @@ pub fn root_half_pi() -> N { /// Returns `sqrt(ln(4))`. pub fn root_ln_four() -> N { - na::convert::<_, N>(4.0).sqrt() + na::convert::<_, N>(4.0).ln().sqrt() } /// Returns the square root of pi. @@ -104,7 +104,7 @@ pub fn root_two_pi() -> N { /// Returns `1 / 3`. pub fn third() -> N { - na::convert(1.0 / 2.0) + na::convert(1.0 / 3.0) } /// Returns `3 / (2pi)`. @@ -119,7 +119,7 @@ pub fn two_over_pi() -> N { /// Returns `2 / sqrt(pi)`. pub fn two_over_root_pi() -> N { - N::frac_2_pi() + N::frac_2_sqrt_pi() } /// Returns `2pi`. diff --git a/nalgebra-glm/src/gtc/quaternion.rs b/nalgebra-glm/src/gtc/quaternion.rs index 51bbd968..4487dbc0 100644 --- a/nalgebra-glm/src/gtc/quaternion.rs +++ b/nalgebra-glm/src/gtc/quaternion.rs @@ -34,6 +34,7 @@ pub fn quat_less_than_equal(x: &Qua, y: &Qua) -> TVec { pub fn quat_cast(x: &Qua) -> TMat4 { ::quat_to_mat4(x) } + /// Computes a right-handed look-at quaternion (equivalent to a right-handed look-at matrix). pub fn quat_look_at(direction: &TVec3, up: &TVec3) -> Qua { quat_look_at_rh(direction, up) diff --git a/nalgebra-glm/src/gtx/matrix_cross_product.rs b/nalgebra-glm/src/gtx/matrix_cross_product.rs index de01bcc9..482127dd 100644 --- a/nalgebra-glm/src/gtx/matrix_cross_product.rs +++ b/nalgebra-glm/src/gtx/matrix_cross_product.rs @@ -9,13 +9,5 @@ pub fn matrix_cross3(x: &TVec3) -> TMat3 { /// Builds a 4x4 matrix `m` such that for any `v`: `m * v == cross(x, v)`. pub fn matrix_cross(x: &TVec3) -> TMat4 { - let m = x.cross_matrix(); - - // FIXME: use a dedicated constructor from Matrix3 to Matrix4. - TMat4::new( - m.m11, m.m12, m.m13, N::zero(), - m.m21, m.m22, m.m23, N::zero(), - m.m31, m.m32, m.m33, N::zero(), - N::zero(), N::zero(), N::zero(), N::one(), - ) + ::mat3_to_mat4(&x.cross_matrix()) } diff --git a/nalgebra-glm/src/gtx/matrix_operation.rs b/nalgebra-glm/src/gtx/matrix_operation.rs index bf05cbb9..bba7bc88 100644 --- a/nalgebra-glm/src/gtx/matrix_operation.rs +++ b/nalgebra-glm/src/gtx/matrix_operation.rs @@ -17,7 +17,7 @@ pub fn diagonal2x4(v: &TVec2) -> TMat2x4 { } /// Builds a 3x2 diagonal matrix. -pub fn diagonal3x2(v: &TVec3) -> TMat3x2 { +pub fn diagonal3x2(v: &TVec2) -> TMat3x2 { TMat3x2::from_partial_diagonal(v.as_slice()) } @@ -32,12 +32,12 @@ pub fn diagonal3x4(v: &TVec3) -> TMat3x4 { } /// Builds a 4x2 diagonal matrix. -pub fn diagonal4x2(v: &TVec4) -> TMat4x2 { +pub fn diagonal4x2(v: &TVec2) -> TMat4x2 { TMat4x2::from_partial_diagonal(v.as_slice()) } /// Builds a 4x3 diagonal matrix. -pub fn diagonal4x3(v: &TVec4) -> TMat4x3 { +pub fn diagonal4x3(v: &TVec3) -> TMat4x3 { TMat4x3::from_partial_diagonal(v.as_slice()) } diff --git a/nalgebra-glm/src/gtx/norm.rs b/nalgebra-glm/src/gtx/norm.rs index a532fc3f..a59b50cf 100644 --- a/nalgebra-glm/src/gtx/norm.rs +++ b/nalgebra-glm/src/gtx/norm.rs @@ -12,7 +12,7 @@ pub fn distance2(p0: &TVec, p1: &TVec) -> N /// The l1-norm of `x - y`. pub fn l1_distance(x: &TVec, y: &TVec) -> N where DefaultAllocator: Alloc { - l1_norm(&(x - y)) + l1_norm(&(y - x)) } /// The l1-norm of `v`. diff --git a/nalgebra-glm/src/gtx/quaternion.rs b/nalgebra-glm/src/gtx/quaternion.rs index 290c7150..1023aa76 100644 --- a/nalgebra-glm/src/gtx/quaternion.rs +++ b/nalgebra-glm/src/gtx/quaternion.rs @@ -48,7 +48,6 @@ pub fn quat_rotate_vec3(q: &Qua, v: &TVec3) -> TVec3 { /// Rotates a vector in homogeneous coordinates by a quaternion assumed to be normalized. pub fn quat_rotate_vec(q: &Qua, v: &TVec4) -> TVec4 { -// UnitQuaternion::new_unchecked(*q) * v let rotated = Unit::new_unchecked(*q) * v.fixed_rows::(0); TVec4::new(rotated.x, rotated.y, rotated.z, v.w) }