Various documentation fixes.

This commit is contained in:
sebcrozet 2018-09-23 15:59:24 +02:00 committed by Sébastien Crozet
parent 41fb5403b5
commit b8b86e72b5
9 changed files with 13 additions and 21 deletions

View File

@ -134,5 +134,5 @@ pub fn mat4<N: Scalar>(m11: N, m12: N, m13: N, m14: N, m21: N, m22: N, m23: N, m
/// Creates a new quaternion.
pub fn quat<N: Real>(x: N, y: N, z: N, w: N) -> Qua<N> {
Qua::new(x, y, z, w)
Qua::new(w, x, y, z)
}

View File

@ -12,12 +12,12 @@ pub fn max4_scalar<N: Number>(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<N: Number>(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<N: Number>(a: N, b: N, c: N, d: N) -> N {
na::inf(&na::inf(&a, &b), &na::inf(&c, &d))
}

View File

@ -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: AbsDiffEq<Epsilon = N>>() -> N {
N::default_epsilon()
}

View File

@ -78,7 +78,7 @@ pub fn root_half_pi<N: Real>() -> N {
/// Returns `sqrt(ln(4))`.
pub fn root_ln_four<N: Real>() -> 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: Real>() -> N {
/// Returns `1 / 3`.
pub fn third<N: Real>() -> 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: Real>() -> N {
/// Returns `2 / sqrt(pi)`.
pub fn two_over_root_pi<N: Real>() -> N {
N::frac_2_pi()
N::frac_2_sqrt_pi()
}
/// Returns `2pi`.

View File

@ -34,6 +34,7 @@ pub fn quat_less_than_equal<N: Real>(x: &Qua<N>, y: &Qua<N>) -> TVec<bool, U4> {
pub fn quat_cast<N: Real>(x: &Qua<N>) -> TMat4<N> {
::quat_to_mat4(x)
}
/// Computes a right-handed look-at quaternion (equivalent to a right-handed look-at matrix).
pub fn quat_look_at<N: Real>(direction: &TVec3<N>, up: &TVec3<N>) -> Qua<N> {
quat_look_at_rh(direction, up)

View File

@ -9,13 +9,5 @@ pub fn matrix_cross3<N: Real>(x: &TVec3<N>) -> TMat3<N> {
/// Builds a 4x4 matrix `m` such that for any `v`: `m * v == cross(x, v)`.
pub fn matrix_cross<N: Real>(x: &TVec3<N>) -> TMat4<N> {
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())
}

View File

@ -17,7 +17,7 @@ pub fn diagonal2x4<N: Number>(v: &TVec2<N>) -> TMat2x4<N> {
}
/// Builds a 3x2 diagonal matrix.
pub fn diagonal3x2<N: Number>(v: &TVec3<N>) -> TMat3x2<N> {
pub fn diagonal3x2<N: Number>(v: &TVec2<N>) -> TMat3x2<N> {
TMat3x2::from_partial_diagonal(v.as_slice())
}
@ -32,12 +32,12 @@ pub fn diagonal3x4<N: Number>(v: &TVec3<N>) -> TMat3x4<N> {
}
/// Builds a 4x2 diagonal matrix.
pub fn diagonal4x2<N: Number>(v: &TVec4<N>) -> TMat4x2<N> {
pub fn diagonal4x2<N: Number>(v: &TVec2<N>) -> TMat4x2<N> {
TMat4x2::from_partial_diagonal(v.as_slice())
}
/// Builds a 4x3 diagonal matrix.
pub fn diagonal4x3<N: Number>(v: &TVec4<N>) -> TMat4x3<N> {
pub fn diagonal4x3<N: Number>(v: &TVec3<N>) -> TMat4x3<N> {
TMat4x3::from_partial_diagonal(v.as_slice())
}

View File

@ -12,7 +12,7 @@ pub fn distance2<N: Real, D: Dimension>(p0: &TVec<N, D>, p1: &TVec<N, D>) -> N
/// The l1-norm of `x - y`.
pub fn l1_distance<N: Real, D: Dimension>(x: &TVec<N, D>, y: &TVec<N, D>) -> N
where DefaultAllocator: Alloc<N, D> {
l1_norm(&(x - y))
l1_norm(&(y - x))
}
/// The l1-norm of `v`.

View File

@ -48,7 +48,6 @@ pub fn quat_rotate_vec3<N: Real>(q: &Qua<N>, v: &TVec3<N>) -> TVec3<N> {
/// Rotates a vector in homogeneous coordinates by a quaternion assumed to be normalized.
pub fn quat_rotate_vec<N: Real>(q: &Qua<N>, v: &TVec4<N>) -> TVec4<N> {
// UnitQuaternion::new_unchecked(*q) * v
let rotated = Unit::new_unchecked(*q) * v.fixed_rows::<U3>(0);
TVec4::new(rotated.x, rotated.y, rotated.z, v.w)
}