diff --git a/nalgebra-glm/src/ext/matrix_projection.rs b/nalgebra-glm/src/ext/matrix_projection.rs index 50f08371..b5d2f393 100644 --- a/nalgebra-glm/src/ext/matrix_projection.rs +++ b/nalgebra-glm/src/ext/matrix_projection.rs @@ -26,6 +26,14 @@ pub fn pick_matrix(center: &TVec2, delta: &TVec2, viewport: &TVec /// * `model` - Specifies the current modelview matrix. /// * `proj` - Specifies the current projection matrix. /// * `viewport` - Specifies the current viewport. +/// +/// # See also: +/// +/// * [`project_no`](fn.project_no.html) +/// * [`project_zo`](fn.project_zo.html) +/// * [`unproject`](fn.unproject.html) +/// * [`unproject_no`](fn.unproject_no.html) +/// * [`unproject_zo`](fn.unproject_zo.html) pub fn project(obj: &TVec3, model: &TMat4, proj: &TMat4, viewport: TVec4) -> TVec3 { project_no(obj, model, proj, viewport) } @@ -39,6 +47,14 @@ pub fn project(obj: &TVec3, model: &TMat4, proj: &TMat4, viewp /// * `model` - Specifies the current modelview matrix. /// * `proj` - Specifies the current projection matrix. /// * `viewport` - Specifies the current viewport. +/// +/// # See also: +/// +/// * [`project`](fn.project.html) +/// * [`project_zo`](fn.project_zo.html) +/// * [`unproject`](fn.unproject.html) +/// * [`unproject_no`](fn.unproject_no.html) +/// * [`unproject_zo`](fn.unproject_zo.html) pub fn project_no(obj: &TVec3, model: &TMat4, proj: &TMat4, viewport: TVec4) -> TVec3 { let proj = project_zo(obj, model, proj, viewport); TVec3::new(proj.x, proj.y, proj.z * na::convert(0.5) + na::convert(0.5)) @@ -53,6 +69,14 @@ pub fn project_no(obj: &TVec3, model: &TMat4, proj: &TMat4, vi /// * `model` - Specifies the current modelview matrix. /// * `proj` - Specifies the current projection matrix. /// * `viewport` - Specifies the current viewport. +/// +/// # See also: +/// +/// * [`project`](fn.project.html) +/// * [`project_no`](fn.project_no.html) +/// * [`unproject`](fn.unproject.html) +/// * [`unproject_no`](fn.unproject_no.html) +/// * [`unproject_zo`](fn.unproject_zo.html) pub fn project_zo(obj: &TVec3, model: &TMat4, proj: &TMat4, viewport: TVec4) -> TVec3 { let normalized = proj * model * TVec4::new(obj.x, obj.y, obj.z, N::one()); let scale = N::one() / normalized.w; @@ -71,6 +95,14 @@ pub fn project_zo(obj: &TVec3, model: &TMat4, proj: &TMat4, vi /// * `model` - Specifies the current modelview matrix. /// * `proj` - Specifies the current projection matrix. /// * `viewport` - Specifies the current viewport. +/// +/// # See also: +/// +/// * [`project`](fn.project.html) +/// * [`project_no`](fn.project_no.html) +/// * [`project_zo`](fn.project_zo.html) +/// * [`unproject_no`](fn.unproject_no.html) +/// * [`unproject_zo`](fn.unproject_zo.html) pub fn unproject(win: &TVec3, model: &TMat4, proj: &TMat4, viewport: TVec4) -> TVec3 { unproject_no(win, model, proj, viewport) } @@ -84,6 +116,14 @@ pub fn unproject(win: &TVec3, model: &TMat4, proj: &TMat4, vie /// * `model` - Specifies the current modelview matrix. /// * `proj` - Specifies the current projection matrix. /// * `viewport` - Specifies the current viewport. +/// +/// # See also: +/// +/// * [`project`](fn.project.html) +/// * [`project_no`](fn.project_no.html) +/// * [`project_zo`](fn.project_zo.html) +/// * [`unproject`](fn.unproject.html) +/// * [`unproject_zo`](fn.unproject_zo.html) pub fn unproject_no(win: &TVec3, model: &TMat4, proj: &TMat4, viewport: TVec4) -> TVec3 { let _2: N = na::convert(2.0); let transform = (proj * model).try_inverse().unwrap_or_else(TMat4::zeros); @@ -107,6 +147,14 @@ pub fn unproject_no(win: &TVec3, model: &TMat4, proj: &TMat4, /// * `model` - Specifies the current modelview matrix. /// * `proj` - Specifies the current projection matrix. /// * `viewport` - Specifies the current viewport. +/// +/// # See also: +/// +/// * [`project`](fn.project.html) +/// * [`project_no`](fn.project_no.html) +/// * [`project_zo`](fn.project_zo.html) +/// * [`unproject`](fn.unproject.html) +/// * [`unproject_no`](fn.unproject_no.html) pub fn unproject_zo(win: &TVec3, model: &TMat4, proj: &TMat4, viewport: TVec4) -> TVec3 { let _2: N = na::convert(2.0); let transform = (proj * model).try_inverse().unwrap_or_else(TMat4::zeros); diff --git a/nalgebra-glm/src/ext/matrix_transform.rs b/nalgebra-glm/src/ext/matrix_transform.rs index 80cf81fe..420718f9 100644 --- a/nalgebra-glm/src/ext/matrix_transform.rs +++ b/nalgebra-glm/src/ext/matrix_transform.rs @@ -15,6 +15,11 @@ pub fn identity() -> TMat /// * `eye` − Position of the camera /// * `center` − Position where the camera is looking at /// * `u` − Normalized up vector, how the camera is oriented. Typically `(0, 1, 0)` +/// +/// # See also: +/// +/// * [`look_at_lh`](fn.look_at_lh.html) +/// * [`look_at_rh`](fn.look_at_rh.html) pub fn look_at(eye: &TVec3, center: &TVec3, up: &TVec3) -> TMat4 { look_at_rh(eye, center, up) } @@ -25,6 +30,11 @@ pub fn look_at(eye: &TVec3, center: &TVec3, up: &TVec3) -> TMa /// * `eye` − Position of the camera /// * `center` − Position where the camera is looking at /// * `u` − Normalized up vector, how the camera is oriented. Typically `(0, 1, 0)` +/// +/// # See also: +/// +/// * [`look_at`](fn.look_at.html) +/// * [`look_at_rh`](fn.look_at_rh.html) pub fn look_at_lh(eye: &TVec3, center: &TVec3, up: &TVec3) -> TMat4 { TMat::look_at_lh(&Point3::from_coordinates(*eye), &Point3::from_coordinates(*center), up) } @@ -35,6 +45,11 @@ pub fn look_at_lh(eye: &TVec3, center: &TVec3, up: &TVec3) -> /// * `eye` − Position of the camera /// * `center` − Position where the camera is looking at /// * `u` − Normalized up vector, how the camera is oriented. Typically `(0, 1, 0)` +/// +/// # See also: +/// +/// * [`look_at`](fn.look_at.html) +/// * [`look_at_lh`](fn.look_at_lh.html) pub fn look_at_rh(eye: &TVec3, center: &TVec3, up: &TVec3) -> TMat4 { TMat::look_at_rh(&Point3::from_coordinates(*eye), &Point3::from_coordinates(*center), up) } @@ -45,6 +60,14 @@ pub fn look_at_rh(eye: &TVec3, center: &TVec3, up: &TVec3) -> /// * `m` − Input matrix multiplied by this rotation matrix. /// * `angle` − Rotation angle expressed in radians. /// * `axis` − Rotation axis, recommended to be normalized. +/// +/// # See also: +/// +/// * [`rotate_x`](fn.rotate_x.html) +/// * [`rotate_y`](fn.rotate_y.html) +/// * [`rotate_z`](fn.rotate_z.html) +/// * [`scale`](fn.scale.html) +/// * [`translate`](fn.translate.html) pub fn rotate(m: &TMat4, angle: N, axis: &TVec3) -> TMat4 { m * Rotation3::from_axis_angle(&Unit::new_normalize(*axis), angle).to_homogeneous() } @@ -54,6 +77,14 @@ pub fn rotate(m: &TMat4, angle: N, axis: &TVec3) -> TMat4 { /// # Parameters /// * `m` − Input matrix multiplied by this rotation matrix. /// * `angle` − Rotation angle expressed in radians. +/// +/// # See also: +/// +/// * [`rotate`](fn.rotate.html) +/// * [`rotate_y`](fn.rotate_y.html) +/// * [`rotate_z`](fn.rotate_z.html) +/// * [`scale`](fn.scale.html) +/// * [`translate`](fn.translate.html) pub fn rotate_x(m: &TMat4, angle: N) -> TMat4 { rotate(m, angle, &TVec::x()) } @@ -63,6 +94,14 @@ pub fn rotate_x(m: &TMat4, angle: N) -> TMat4 { /// # Parameters /// * `m` − Input matrix multiplied by this rotation matrix. /// * `angle` − Rotation angle expressed in radians. +/// +/// # See also: +/// +/// * [`rotate`](fn.rotate.html) +/// * [`rotate_x`](fn.rotate_x.html) +/// * [`rotate_z`](fn.rotate_z.html) +/// * [`scale`](fn.scale.html) +/// * [`translate`](fn.translate.html) pub fn rotate_y(m: &TMat4, angle: N) -> TMat4 { rotate(m, angle, &TVec::y()) } @@ -72,6 +111,14 @@ pub fn rotate_y(m: &TMat4, angle: N) -> TMat4 { /// # Parameters /// * `m` − Input matrix multiplied by this rotation matrix. /// * `angle` − Rotation angle expressed in radians. +/// +/// # See also: +/// +/// * [`rotate`](fn.rotate.html) +/// * [`rotate_x`](fn.rotate_x.html) +/// * [`rotate_y`](fn.rotate_y.html) +/// * [`scale`](fn.scale.html) +/// * [`translate`](fn.translate.html) pub fn rotate_z(m: &TMat4, angle: N) -> TMat4 { rotate(m, angle, &TVec::z()) } @@ -81,6 +128,14 @@ pub fn rotate_z(m: &TMat4, angle: N) -> TMat4 { /// # Parameters /// * `m` − Input matrix multiplied by this scale matrix. /// * `v` − Ratio of scaling for each axis. +/// +/// # See also: +/// +/// * [`rotate`](fn.rotate.html) +/// * [`rotate_x`](fn.rotate_x.html) +/// * [`rotate_y`](fn.rotate_y.html) +/// * [`rotate_z`](fn.rotate_z.html) +/// * [`translate`](fn.translate.html) pub fn scale(m: &TMat4, v: &TVec3) -> TMat4 { m.prepend_nonuniform_scaling(v) } @@ -90,6 +145,14 @@ pub fn scale(m: &TMat4, v: &TVec3) -> TMat4 { /// # Parameters /// * `m` − Input matrix multiplied by this translation matrix. /// * `v` − Coordinates of a translation vector. +/// +/// # See also: +/// +/// * [`rotate`](fn.rotate.html) +/// * [`rotate_x`](fn.rotate_x.html) +/// * [`rotate_y`](fn.rotate_y.html) +/// * [`rotate_z`](fn.rotate_z.html) +/// * [`scale`](fn.scale.html) pub fn translate(m: &TMat4, v: &TVec3) -> TMat4 { m.prepend_translation(v) } diff --git a/nalgebra-glm/src/ext/vector_relational.rs b/nalgebra-glm/src/ext/vector_relational.rs index 7312dcf4..cfd8649b 100644 --- a/nalgebra-glm/src/ext/vector_relational.rs +++ b/nalgebra-glm/src/ext/vector_relational.rs @@ -4,24 +4,48 @@ use traits::{Alloc, Number, Dimension}; use aliases::TVec; /// Component-wise approximate equality of two vectors, using a scalar epsilon. +/// +/// # See also: +/// +/// * [`equal_eps_vec`](fn.equal_eps_vec.html) +/// * [`not_equal_eps`](fn.not_equal_eps.html) +/// * [`not_equal_eps_vec`](fn.not_equal_eps_vec.html) pub fn equal_eps(x: &TVec, y: &TVec, epsilon: N) -> TVec where DefaultAllocator: Alloc { x.zip_map(y, |x, y| abs_diff_eq!(x, y, epsilon = epsilon)) } /// Component-wise approximate equality of two vectors, using a per-component epsilon. +/// +/// # See also: +/// +/// * [`equal_eps`](fn.equal_eps.html) +/// * [`not_equal_eps`](fn.not_equal_eps.html) +/// * [`not_equal_eps_vec`](fn.not_equal_eps_vec.html) pub fn equal_eps_vec(x: &TVec, y: &TVec, epsilon: &TVec) -> TVec where DefaultAllocator: Alloc { x.zip_zip_map(y, epsilon, |x, y, eps| abs_diff_eq!(x, y, epsilon = eps)) } /// Component-wise approximate non-equality of two vectors, using a scalar epsilon. +/// +/// # See also: +/// +/// * [`equal_eps`](fn.equal_eps.html) +/// * [`equal_eps_vec`](fn.equal_eps_vec.html) +/// * [`not_equal_eps_vec`](fn.not_equal_eps_vec.html) pub fn not_equal_eps(x: &TVec, y: &TVec, epsilon: N) -> TVec where DefaultAllocator: Alloc { x.zip_map(y, |x, y| abs_diff_ne!(x, y, epsilon = epsilon)) } /// Component-wise approximate non-equality of two vectors, using a per-component epsilon. +/// +/// # See also: +/// +/// * [`equal_eps`](fn.equal_eps.html) +/// * [`equal_eps_vec`](fn.equal_eps_vec.html) +/// * [`not_equal_eps`](fn.not_equal_eps.html) pub fn not_equal_eps_vec(x: &TVec, y: &TVec, epsilon: &TVec) -> TVec where DefaultAllocator: Alloc { x.zip_zip_map(y, epsilon, |x, y, eps| abs_diff_ne!(x, y, epsilon = eps)) diff --git a/nalgebra-glm/src/gtx/handed_coordinate_space.rs b/nalgebra-glm/src/gtx/handed_coordinate_space.rs index 9b0e1c9e..e499207f 100644 --- a/nalgebra-glm/src/gtx/handed_coordinate_space.rs +++ b/nalgebra-glm/src/gtx/handed_coordinate_space.rs @@ -2,11 +2,19 @@ use traits::Number; use aliases::TVec3; /// Returns `true` if `{a, b, c}` forms a left-handed trihedron. +/// +/// # See also: +/// +/// * [`right_handed`](fn.right_handed.html) pub fn left_handed(a: &TVec3, b: &TVec3, c: &TVec3) -> bool { a.cross(b).dot(c) < N::zero() } /// Returns `true` if `{a, b, c}` forms a right-handed trihedron. +/// +/// # See also: +/// +/// * [`left_handed`](fn.left_handed.html) pub fn right_handed(a: &TVec3, b: &TVec3, c: &TVec3) -> bool { a.cross(b).dot(c) > N::zero() } diff --git a/nalgebra-glm/src/gtx/matrix_cross_product.rs b/nalgebra-glm/src/gtx/matrix_cross_product.rs index 482127dd..7d70d438 100644 --- a/nalgebra-glm/src/gtx/matrix_cross_product.rs +++ b/nalgebra-glm/src/gtx/matrix_cross_product.rs @@ -3,11 +3,19 @@ use na::Real; use aliases::{TMat3, TMat4, TVec3}; /// Builds a 3x3 matrix `m` such that for any `v`: `m * v == cross(x, v)`. +/// +/// # See also: +/// +/// * [`matrix_cross`](fn.matrix_cross.html) pub fn matrix_cross3(x: &TVec3) -> TMat3 { x.cross_matrix() } /// Builds a 4x4 matrix `m` such that for any `v`: `m * v == cross(x, v)`. +/// +/// # See also: +/// +/// * [`matrix_cross3`](fn.matrix_cross3.html) pub fn matrix_cross(x: &TVec3) -> TMat4 { ::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 bba7bc88..17ea4bb9 100644 --- a/nalgebra-glm/src/gtx/matrix_operation.rs +++ b/nalgebra-glm/src/gtx/matrix_operation.rs @@ -2,46 +2,145 @@ use traits::Number; use aliases::{TVec2, TVec3, TVec4, TMat2, TMat2x3, TMat2x4, TMat3, TMat3x2, TMat3x4, TMat4, TMat4x2, TMat4x3}; /// Builds a 2x2 diagonal matrix. +/// +/// # See also: +/// +/// * [`diagonal2x3`](fn.diagonal2x3.html) +/// * [`diagonal2x4`](fn.diagonal2x4.html) +/// * [`diagonal3x2`](fn.diagonal3x2.html) +/// * [`diagonal3x3`](fn.diagonal3x3.html) +/// * [`diagonal3x4`](fn.diagonal3x4.html) +/// * [`diagonal4x2`](fn.diagonal4x2.html) +/// * [`diagonal4x3`](fn.diagonal4x3.html) +/// * [`diagonal4x4`](fn.diagonal4x4.html) pub fn diagonal2x2(v: &TVec2) -> TMat2 { TMat2::from_diagonal(v) } /// Builds a 2x3 diagonal matrix. +/// +/// # See also: +/// +/// * [`diagonal2x2`](fn.diagonal2x2.html) +/// * [`diagonal2x4`](fn.diagonal2x4.html) +/// * [`diagonal3x2`](fn.diagonal3x2.html) +/// * [`diagonal3x3`](fn.diagonal3x3.html) +/// * [`diagonal3x4`](fn.diagonal3x4.html) +/// * [`diagonal4x2`](fn.diagonal4x2.html) +/// * [`diagonal4x3`](fn.diagonal4x3.html) +/// * [`diagonal4x4`](fn.diagonal4x4.html) pub fn diagonal2x3(v: &TVec2) -> TMat2x3 { TMat2x3::from_partial_diagonal(v.as_slice()) } /// Builds a 2x4 diagonal matrix. +/// +/// # See also: +/// +/// * [`diagonal2x2`](fn.diagonal2x2.html) +/// * [`diagonal2x3`](fn.diagonal2x3.html) +/// * [`diagonal3x2`](fn.diagonal3x2.html) +/// * [`diagonal3x3`](fn.diagonal3x3.html) +/// * [`diagonal3x4`](fn.diagonal3x4.html) +/// * [`diagonal4x2`](fn.diagonal4x2.html) +/// * [`diagonal4x3`](fn.diagonal4x3.html) +/// * [`diagonal4x4`](fn.diagonal4x4.html) pub fn diagonal2x4(v: &TVec2) -> TMat2x4 { TMat2x4::from_partial_diagonal(v.as_slice()) } /// Builds a 3x2 diagonal matrix. +/// +/// # See also: +/// +/// * [`diagonal2x2`](fn.diagonal2x2.html) +/// * [`diagonal2x3`](fn.diagonal2x3.html) +/// * [`diagonal2x4`](fn.diagonal2x4.html) +/// * [`diagonal3x3`](fn.diagonal3x3.html) +/// * [`diagonal3x4`](fn.diagonal3x4.html) +/// * [`diagonal4x2`](fn.diagonal4x2.html) +/// * [`diagonal4x3`](fn.diagonal4x3.html) +/// * [`diagonal4x4`](fn.diagonal4x4.html) pub fn diagonal3x2(v: &TVec2) -> TMat3x2 { TMat3x2::from_partial_diagonal(v.as_slice()) } /// Builds a 3x3 diagonal matrix. +/// +/// # See also: +/// +/// * [`diagonal2x2`](fn.diagonal2x2.html) +/// * [`diagonal2x3`](fn.diagonal2x3.html) +/// * [`diagonal2x4`](fn.diagonal2x4.html) +/// * [`diagonal3x2`](fn.diagonal3x2.html) +/// * [`diagonal3x4`](fn.diagonal3x4.html) +/// * [`diagonal4x2`](fn.diagonal4x2.html) +/// * [`diagonal4x3`](fn.diagonal4x3.html) +/// * [`diagonal4x4`](fn.diagonal4x4.html) pub fn diagonal3x3(v: &TVec3) -> TMat3 { TMat3::from_diagonal(v) } /// Builds a 3x4 diagonal matrix. +/// +/// # See also: +/// +/// * [`diagonal2x2`](fn.diagonal2x2.html) +/// * [`diagonal2x3`](fn.diagonal2x3.html) +/// * [`diagonal2x4`](fn.diagonal2x4.html) +/// * [`diagonal3x2`](fn.diagonal3x2.html) +/// * [`diagonal3x3`](fn.diagonal3x3.html) +/// * [`diagonal4x2`](fn.diagonal4x2.html) +/// * [`diagonal4x3`](fn.diagonal4x3.html) +/// * [`diagonal4x4`](fn.diagonal4x4.html) pub fn diagonal3x4(v: &TVec3) -> TMat3x4 { TMat3x4::from_partial_diagonal(v.as_slice()) } /// Builds a 4x2 diagonal matrix. +/// +/// # See also: +/// +/// * [`diagonal2x2`](fn.diagonal2x2.html) +/// * [`diagonal2x3`](fn.diagonal2x3.html) +/// * [`diagonal2x4`](fn.diagonal2x4.html) +/// * [`diagonal3x2`](fn.diagonal3x2.html) +/// * [`diagonal3x3`](fn.diagonal3x3.html) +/// * [`diagonal3x4`](fn.diagonal3x4.html) +/// * [`diagonal4x3`](fn.diagonal4x3.html) +/// * [`diagonal4x4`](fn.diagonal4x4.html) pub fn diagonal4x2(v: &TVec2) -> TMat4x2 { TMat4x2::from_partial_diagonal(v.as_slice()) } /// Builds a 4x3 diagonal matrix. +/// +/// # See also: +/// +/// * [`diagonal2x2`](fn.diagonal2x2.html) +/// * [`diagonal2x3`](fn.diagonal2x3.html) +/// * [`diagonal2x4`](fn.diagonal2x4.html) +/// * [`diagonal3x2`](fn.diagonal3x2.html) +/// * [`diagonal3x3`](fn.diagonal3x3.html) +/// * [`diagonal3x4`](fn.diagonal3x4.html) +/// * [`diagonal4x2`](fn.diagonal4x2.html) +/// * [`diagonal4x4`](fn.diagonal4x4.html) pub fn diagonal4x3(v: &TVec3) -> TMat4x3 { TMat4x3::from_partial_diagonal(v.as_slice()) } /// Builds a 4x4 diagonal matrix. +/// +/// # See also: +/// +/// * [`diagonal2x2`](fn.diagonal2x2.html) +/// * [`diagonal2x3`](fn.diagonal2x3.html) +/// * [`diagonal2x4`](fn.diagonal2x4.html) +/// * [`diagonal3x2`](fn.diagonal3x2.html) +/// * [`diagonal3x3`](fn.diagonal3x3.html) +/// * [`diagonal3x4`](fn.diagonal3x4.html) +/// * [`diagonal4x2`](fn.diagonal4x2.html) +/// * [`diagonal4x3`](fn.diagonal4x3.html) pub fn diagonal4x4(v: &TVec4) -> TMat4 { TMat4::from_diagonal(v) } diff --git a/nalgebra-glm/src/gtx/normalize_dot.rs b/nalgebra-glm/src/gtx/normalize_dot.rs index 1aa2f0c3..4c67aee3 100644 --- a/nalgebra-glm/src/gtx/normalize_dot.rs +++ b/nalgebra-glm/src/gtx/normalize_dot.rs @@ -4,6 +4,12 @@ use traits::{Dimension, Alloc}; use aliases::TVec; /// The dot product of the normalized version of `x` and `y`. +/// +/// This is currently the same as [`normalize_dot`](fn.normalize_dot.html). +/// +/// # See also: +/// +/// * [`normalize_dot`](fn.normalize_dot.html`) pub fn fast_normalize_dot(x: &TVec, y: &TVec) -> N where DefaultAllocator: Alloc { // XXX: improve those. @@ -11,8 +17,12 @@ pub fn fast_normalize_dot(x: &TVec, y: &TVec) } /// The dot product of the normalized version of `x` and `y`. +/// +/// # See also: +/// +/// * [`fast_normalize_dot`](fn.fast_normalize_dot.html`) pub fn normalize_dot(x: &TVec, y: &TVec) -> N where DefaultAllocator: Alloc { // XXX: improve those. x.normalize().dot(&y.normalize()) -} \ No newline at end of file +} diff --git a/nalgebra-glm/src/gtx/transform.rs b/nalgebra-glm/src/gtx/transform.rs index 0299dfe6..3ebc958d 100644 --- a/nalgebra-glm/src/gtx/transform.rs +++ b/nalgebra-glm/src/gtx/transform.rs @@ -4,32 +4,80 @@ use traits::Number; use aliases::{TVec3, TVec2, TMat3, TMat4}; /// A rotation 4 * 4 matrix created from an axis of 3 scalars and an angle expressed in radians. +/// +/// # See also: +/// +/// * [`scaling`](fn.scaling.html) +/// * [`translation`](fn.translation.html) +/// * [`rotation2d`](fn.rotation2d.html) +/// * [`scaling2d`](fn.scaling2d.html) +/// * [`translation2d`](fn.translation2d.html) pub fn rotation(angle: N, v: &TVec3) -> TMat4 { Rotation3::from_axis_angle(&Unit::new_normalize(*v), angle).to_homogeneous() } /// A 4 * 4 scale matrix created from a vector of 3 components. +/// +/// # See also: +/// +/// * [`rotation`](fn.rotation.html) +/// * [`translation`](fn.translation.html) +/// * [`rotation2d`](fn.rotation2d.html) +/// * [`scaling2d`](fn.scaling2d.html) +/// * [`translation2d`](fn.translation2d.html) pub fn scaling(v: &TVec3) -> TMat4 { TMat4::new_nonuniform_scaling(v) } /// A 4 * 4 translation matrix created from the scaling factor on each axis. +/// +/// # See also: +/// +/// * [`rotation`](fn.rotation.html) +/// * [`scaling`](fn.scaling.html) +/// * [`rotation2d`](fn.rotation2d.html) +/// * [`scaling2d`](fn.scaling2d.html) +/// * [`translation2d`](fn.translation2d.html) pub fn translation(v: &TVec3) -> TMat4 { TMat4::new_translation(v) } /// A rotation 3 * 3 matrix created from an angle expressed in radians. +/// +/// # See also: +/// +/// * [`rotation`](fn.rotation.html) +/// * [`scaling`](fn.scaling.html) +/// * [`translation`](fn.translation.html) +/// * [`scaling2d`](fn.scaling2d.html) +/// * [`translation2d`](fn.translation2d.html) pub fn rotation2d(angle: N) -> TMat3 { Rotation2::new(angle).to_homogeneous() } /// A 3 * 3 scale matrix created from a vector of 2 components. +/// +/// # See also: +/// +/// * [`rotation`](fn.rotation.html) +/// * [`scaling`](fn.scaling.html) +/// * [`translation`](fn.translation.html) +/// * [`rotation2d`](fn.rotation2d.html) +/// * [`translation2d`](fn.translation2d.html) pub fn scaling2d(v: &TVec2) -> TMat3 { TMat3::new_nonuniform_scaling(v) } /// A 3 * 3 translation matrix created from the scaling factor on each axis. +/// +/// # See also: +/// +/// * [`rotation`](fn.rotation.html) +/// * [`scaling`](fn.scaling.html) +/// * [`translation`](fn.translation.html) +/// * [`rotation2d`](fn.rotation2d.html) +/// * [`scaling2d`](fn.scaling2d.html) pub fn translation2d(v: &TVec2) -> TMat3 { TMat3::new_translation(v) } diff --git a/nalgebra-glm/src/gtx/transform2d.rs b/nalgebra-glm/src/gtx/transform2d.rs index b1e7e3e4..92aa7709 100644 --- a/nalgebra-glm/src/gtx/transform2d.rs +++ b/nalgebra-glm/src/gtx/transform2d.rs @@ -4,16 +4,40 @@ use traits::Number; use aliases::{TMat3, TVec2}; /// Builds a 2D rotation matrix from an angle and right-multiply it to `m`. +/// +/// # See also: +/// +/// * [`rotation2d`](fn.rotation2d.html) +/// * [`scale2d`](fn.scale2d.html) +/// * [`scaling2d`](fn.scaling2d.html) +/// * [`translate2d`](fn.translate2d.html) +/// * [`translation2d`](fn.translation2d.html) pub fn rotate2d(m: &TMat3, angle: N) -> TMat3 { m * UnitComplex::new(angle).to_homogeneous() } /// Builds a 2D scaling matrix and right-multiply it to `m`. +/// +/// # See also: +/// +/// * [`rotate2d`](fn.rotate2d.html) +/// * [`rotation2d`](fn.rotation2d.html) +/// * [`scaling2d`](fn.scaling2d.html) +/// * [`translate2d`](fn.translate2d.html) +/// * [`translation2d`](fn.translation2d.html) pub fn scale2d(m: &TMat3, v: &TVec2) -> TMat3 { m.prepend_nonuniform_scaling(v) } /// Builds a translation matrix and right-multiply it to `m`. +/// +/// # See also: +/// +/// * [`rotate2d`](fn.rotate2d.html) +/// * [`rotation2d`](fn.rotation2d.html) +/// * [`scale2d`](fn.scale2d.html) +/// * [`scaling2d`](fn.scaling2d.html) +/// * [`translation2d`](fn.translation2d.html) pub fn translate2d(m: &TMat3, v: &TVec2) -> TMat3 { m.prepend_translation(v) -} \ No newline at end of file +} diff --git a/nalgebra-glm/src/gtx/vector_query.rs b/nalgebra-glm/src/gtx/vector_query.rs index f73f2a1e..c4517803 100644 --- a/nalgebra-glm/src/gtx/vector_query.rs +++ b/nalgebra-glm/src/gtx/vector_query.rs @@ -4,11 +4,19 @@ use traits::{Number, Dimension, Alloc}; use aliases::{TVec, TVec2, TVec3}; /// Returns `true` if two vectors are collinear (up to an epsilon). +/// +/// # See also: +/// +/// * [`are_collinear2d`](fn.are_collinear2d.html) pub fn are_collinear(v0: &TVec3, v1: &TVec3, epsilon: N) -> bool { is_null(&v0.cross(v1), epsilon) } /// Returns `true` if two 2D vectors are collinear (up to an epsilon). +/// +/// # See also: +/// +/// * [`are_collinear`](fn.are_collinear.html) pub fn are_collinear2d(v0: &TVec2, v1: &TVec2, epsilon: N) -> bool { abs_diff_eq!(v0.perp(v1), N::zero(), epsilon = epsilon) }