From f2bad264ef5eb614d452ab4a67bb130271fad587 Mon Sep 17 00:00:00 2001 From: sebcrozet Date: Sat, 22 Sep 2018 19:05:37 +0200 Subject: [PATCH] Re-export conversion functions. --- nalgebra-glm/src/ext/matrix_transform.rs | 27 ++++++++++++++++++++++++ nalgebra-glm/src/ext/mod.rs | 2 +- nalgebra-glm/src/gtx/mod.rs | 2 +- nalgebra-glm/src/gtx/rotate_vector.rs | 6 +++--- nalgebra-glm/src/lib.rs | 6 ++++-- src/base/swizzle.rs | 3 ++- 6 files changed, 38 insertions(+), 8 deletions(-) diff --git a/nalgebra-glm/src/ext/matrix_transform.rs b/nalgebra-glm/src/ext/matrix_transform.rs index bf1ecd11..5a22b6e9 100644 --- a/nalgebra-glm/src/ext/matrix_transform.rs +++ b/nalgebra-glm/src/ext/matrix_transform.rs @@ -49,6 +49,33 @@ pub fn rotate(m: &Mat, angle: N, axis: &Vec) -> Mat(m: &Mat, angle: N) -> Mat { + rotate(m, angle, &Vec::x()) +} + +/// Builds a rotation 4 * 4 matrix around the Y axis and right-multiply it to `m`. +/// +/// # Parameters +/// * m − Input matrix multiplied by this rotation matrix. +/// * angle − Rotation angle expressed in radians. +pub fn rotate_y(m: &Mat, angle: N) -> Mat { + rotate(m, angle, &Vec::y()) +} + +/// Builds a rotation 4 * 4 matrix around the Z axis and right-multiply it to `m`. +/// +/// # Parameters +/// * m − Input matrix multiplied by this rotation matrix. +/// * angle − Rotation angle expressed in radians. +pub fn rotate_z(m: &Mat, angle: N) -> Mat { + rotate(m, angle, &Vec::z()) +} + /// Builds a scale 4 * 4 matrix created from 3 scalars and right-multiply it to `m`. /// /// # Parameters diff --git a/nalgebra-glm/src/ext/mod.rs b/nalgebra-glm/src/ext/mod.rs index 403f1258..5d8e9d5c 100644 --- a/nalgebra-glm/src/ext/mod.rs +++ b/nalgebra-glm/src/ext/mod.rs @@ -3,7 +3,7 @@ pub use self::matrix_clip_space::{ortho, perspective}; pub use self::matrix_projection::{pick_matrix, project, project_no, project_zo, unproject, unproject_no, unproject_zo}; pub use self::matrix_relationnal::{equal_columns, equal_columns_eps, equal_columns_eps_vec, not_equal_columns, not_equal_columns_eps, not_equal_columns_eps_vec}; -pub use self::matrix_transform::{identity, look_at, look_at_lh, rotate, scale, look_at_rh, translate}; +pub use self::matrix_transform::{identity, look_at, look_at_lh, rotate, scale, look_at_rh, translate, rotate_x, rotate_y, rotate_z}; pub use self::scalar_common::{max3_scalar, max4_scalar, min3_scalar, min4_scalar}; pub use self::scalar_constants::{epsilon, pi}; pub use self::vector_common::{max, max2, max3, max4, min, min2, min3, min4}; diff --git a/nalgebra-glm/src/gtx/mod.rs b/nalgebra-glm/src/gtx/mod.rs index 85300918..ae944dd5 100644 --- a/nalgebra-glm/src/gtx/mod.rs +++ b/nalgebra-glm/src/gtx/mod.rs @@ -11,7 +11,7 @@ pub use self::norm::{distance2, l1_distance, l1_norm, l2_distance, l2_norm, leng pub use self::normal::{triangle_normal}; pub use self::normalize_dot::{fast_normalize_dot, normalize_dot}; pub use self::rotate_normalized_axis::{quat_rotate_normalized_axis, rotate_normalized_axis}; -pub use self::rotate_vector::{orientation, rotate_vec2, rotate_vec3, rotate_vec4, rotate_x, rotate_x_vec3, rotate_y, rotate_y_vec3, rotate_z, rotate_z_vec3, slerp}; +pub use self::rotate_vector::{orientation, rotate_vec2, rotate_vec3, rotate_vec4, rotate_x_vec4, rotate_x_vec3, rotate_y_vec4, rotate_y_vec3, rotate_z_vec4, rotate_z_vec3, slerp}; pub use self::transform::{rotation, scaling, translation}; pub use self::transform2::{proj, proj2d, reflect, reflect2d, scale_bias, scale_bias_matrix, shear2d_x, shear_x, shear_y, shear_y_mat3, shear_z}; pub use self::transform2d::{rotate2d, scale2d, translate2d}; diff --git a/nalgebra-glm/src/gtx/rotate_vector.rs b/nalgebra-glm/src/gtx/rotate_vector.rs index 1b8ce0bb..39c92abc 100644 --- a/nalgebra-glm/src/gtx/rotate_vector.rs +++ b/nalgebra-glm/src/gtx/rotate_vector.rs @@ -32,7 +32,7 @@ pub fn rotate_x_vec3(v: &Vec, angle: N) -> Vec { } /// Rotate a three dimensional vector in homogeneous coordinates around the `X` axis. -pub fn rotate_x(v: &Vec, angle: N) -> Vec { +pub fn rotate_x_vec4(v: &Vec, angle: N) -> Vec { Rotation3::from_axis_angle(&Vector3::x_axis(), angle).to_homogeneous() * v } @@ -42,7 +42,7 @@ pub fn rotate_y_vec3(v: &Vec, angle: N) -> Vec { } /// Rotate a three dimensional vector in homogeneous coordinates around the `Y` axis. -pub fn rotate_y(v: &Vec, angle: N) -> Vec { +pub fn rotate_y_vec4(v: &Vec, angle: N) -> Vec { Rotation3::from_axis_angle(&Vector3::y_axis(), angle).to_homogeneous() * v } @@ -52,7 +52,7 @@ pub fn rotate_z_vec3(v: &Vec, angle: N) -> Vec { } /// Rotate a three dimensional vector in homogeneous coordinates around the `Z` axis. -pub fn rotate_z(v: &Vec, angle: N) -> Vec { +pub fn rotate_z_vec4(v: &Vec, angle: N) -> Vec { Rotation3::from_axis_angle(&Vector3::z_axis(), angle).to_homogeneous() * v } diff --git a/nalgebra-glm/src/lib.rs b/nalgebra-glm/src/lib.rs index 64d08e89..a278eae0 100644 --- a/nalgebra-glm/src/lib.rs +++ b/nalgebra-glm/src/lib.rs @@ -26,7 +26,7 @@ pub use gtx::{ triangle_normal, fast_normalize_dot, normalize_dot, quat_rotate_normalized_axis, rotate_normalized_axis, - orientation, rotate_vec2, rotate_vec3, rotate_vec4, rotate_x, rotate_x_vec3, rotate_y, rotate_y_vec3, rotate_z, rotate_z_vec3, slerp, + orientation, rotate_vec2, rotate_vec3, rotate_vec4, rotate_x_vec4, rotate_x_vec3, rotate_y_vec4, rotate_y_vec3, rotate_z_vec4, rotate_z_vec3, slerp, rotation, scaling, translation, proj, proj2d, reflect, reflect2d, scale_bias, scale_bias_matrix, shear2d_x, shear_x, shear_y, shear_y_mat3, shear_z, rotate2d, scale2d, translate2d, @@ -45,7 +45,7 @@ pub use ext::{ ortho, perspective, pick_matrix, project, project_no, project_zo, unproject, unproject_no, unproject_zo, equal_columns, equal_columns_eps, equal_columns_eps_vec, not_equal_columns, not_equal_columns_eps, not_equal_columns_eps_vec, - identity, look_at, look_at_lh, rotate, scale, look_at_rh, translate, + identity, look_at, look_at_lh, rotate, scale, look_at_rh, translate, rotate_x, rotate_y, rotate_z, max3_scalar, max4_scalar, min3_scalar, min4_scalar, epsilon, pi, max, max2, max3, max4, min, min2, min3, min4, @@ -57,6 +57,8 @@ pub use ext::{ quat_angle, quat_angle_axis, quat_axis }; +pub use na::{convert, convert_ref, convert_unchecked, convert_ref_unchecked, try_convert, try_convert_ref}; + mod aliases; mod constructors; mod common; diff --git a/src/base/swizzle.rs b/src/base/swizzle.rs index c7ea1b12..eaf8b9ff 100644 --- a/src/base/swizzle.rs +++ b/src/base/swizzle.rs @@ -1,4 +1,4 @@ -use base::{Scalar, Vector, DimName, U0, U1, U2, U3, U4, Vector2, Vector3}; +use base::{Scalar, Vector, DimName, U0, U1, U2, Vector2, Vector3}; use storage::Storage; use typenum::{Cmp, Greater}; @@ -7,6 +7,7 @@ macro_rules! impl_swizzle { ($(where $BaseDim: ty: $name: ident() -> $Result: ident[$($i: expr),*]);*) => { $( impl> Vector { + /// Builds a new vector from components of `self`. #[inline] pub fn $name(&self) -> $Result where D::Value: Cmp<$BaseDim, Output=Greater> {