diff --git a/nalgebra-glm/src/common.rs b/nalgebra-glm/src/common.rs index 6e0e5e4d..98c80252 100644 --- a/nalgebra-glm/src/common.rs +++ b/nalgebra-glm/src/common.rs @@ -130,30 +130,6 @@ pub fn int_bits_to_float_vec(v: &Vec) -> Vec // x * (exp).exp2() //} -/// The maximum between each component of `x` and `y`. -pub fn max(x: &Vec, y: N) -> Vec - where DefaultAllocator: Alloc { - x.map(|x| na::sup(&x, &y)) -} - -/// Component-wise maximum between `x` and `y`. -pub fn max_vec(x: &Vec, y: &Vec) -> Vec - where DefaultAllocator: Alloc { - na::sup(x, y) -} - -/// The minimum between each component of `x` and `y`. -pub fn min(x: &Vec, y: N) -> Vec - where DefaultAllocator: Alloc { - x.map(|x| na::inf(&x, &y)) -} - -/// Component-wise minimum between `x` and `y`. -pub fn min_vec(x: &Vec, y: &Vec) -> Vec - where DefaultAllocator: Alloc { - na::inf(x, y) -} - /// Returns `x * (1.0 - a) + y * a`, i.e., the linear blend of x and y using the floating-point value a. /// /// The value for a is not restricted to the range `[0, 1]`. diff --git a/nalgebra-glm/src/ext/mod.rs b/nalgebra-glm/src/ext/mod.rs index 93e9d5fa..403f1258 100644 --- a/nalgebra-glm/src/ext/mod.rs +++ b/nalgebra-glm/src/ext/mod.rs @@ -1,18 +1,18 @@ //! (Reexported) Additional features not specified by GLSL specification -pub use self::matrix_clip_space::*; -pub use self::matrix_projection::*; -pub use self::matrix_relationnal::*; -pub use self::matrix_transform::*; -pub use self::scalar_common::*; -pub use self::scalar_constants::*; -pub use self::vector_common::*; -pub use self::vector_relational::*; -pub use self::quaternion_common::*; -pub use self::quaternion_geometric::*; -pub use self::quaternion_relational::*; -pub use self::quaternion_transform::*; -pub use self::quaternion_trigonometric::*; +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::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}; +pub use self::vector_relational::{equal_eps, equal_eps_vec, not_equal_eps, not_equal_eps_vec}; +pub use self::quaternion_common::{quat_conjugate, quat_inverse, quat_lerp, quat_slerp}; +pub use self::quaternion_geometric::{quat_cross, quat_dot, quat_length, quat_magnitude, quat_normalize}; +pub use self::quaternion_relational::{quat_equal, quat_equal_eps, quat_not_equal, quat_not_equal_eps}; +pub use self::quaternion_transform::{quat_exp, quat_log, quat_pow, quat_rotate}; +pub use self::quaternion_trigonometric::{quat_angle, quat_angle_axis, quat_axis}; mod matrix_clip_space; diff --git a/nalgebra-glm/src/ext/vector_common.rs b/nalgebra-glm/src/ext/vector_common.rs index e0f0c1f3..913fd119 100644 --- a/nalgebra-glm/src/ext/vector_common.rs +++ b/nalgebra-glm/src/ext/vector_common.rs @@ -27,25 +27,25 @@ pub fn max4(a: &Vec, b: &Vec, c: &Vec max2(&max2(a, b), &max2(c, d)) } -/// Component-wise maximum between a vector and a scalar. +/// Component-wise minimum between a vector and a scalar. pub fn min(x: &Vec, y: N) -> Vec where DefaultAllocator: Alloc { x.map(|x| na::inf(&x, &y)) } -/// Component-wise maximum between two vectors. +/// Component-wise minimum between two vectors. pub fn min2(x: &Vec, y: &Vec) -> Vec where DefaultAllocator: Alloc { na::inf(x, y) } -/// Component-wise maximum between three vectors. +/// Component-wise minimum between three vectors. pub fn min3(a: &Vec, b: &Vec, c: &Vec) -> Vec where DefaultAllocator: Alloc { min2(&min2(a, b), c) } -/// Component-wise maximum between four vectors. +/// Component-wise minimum between four vectors. pub fn min4(a: &Vec, b: &Vec, c: &Vec, d: &Vec) -> Vec where DefaultAllocator: Alloc { min2(&min2(a, b), &min2(c, d)) diff --git a/nalgebra-glm/src/geometric.rs b/nalgebra-glm/src/geometric.rs index ad9910db..757899ff 100644 --- a/nalgebra-glm/src/geometric.rs +++ b/nalgebra-glm/src/geometric.rs @@ -49,14 +49,14 @@ pub fn normalize(x: &Vec) -> Vec } /// For the incident vector `i` and surface orientation `n`, returns the reflection direction : `result = i - 2.0 * dot(n, i) * n`. -pub fn reflect(i: &Vec, n: &Vec) -> Vec +pub fn reflect_vec(i: &Vec, n: &Vec) -> Vec where DefaultAllocator: Alloc { let _2 = N::one() + N::one(); i - n * (n.dot(i) * _2) } /// For the incident vector `i` and surface normal `n`, and the ratio of indices of refraction `eta`, return the refraction vector. -pub fn refract(i: &Vec, n: &Vec, eta: N) -> Vec +pub fn refract_vec(i: &Vec, n: &Vec, eta: N) -> Vec where DefaultAllocator: Alloc { let ni = n.dot(i); diff --git a/nalgebra-glm/src/gtc/mod.rs b/nalgebra-glm/src/gtc/mod.rs index 3f0efd7c..3eb84539 100644 --- a/nalgebra-glm/src/gtc/mod.rs +++ b/nalgebra-glm/src/gtc/mod.rs @@ -1,17 +1,16 @@ //! (Reexported) Recommended features not specified by GLSL specification //pub use self::bitfield::*; -pub use self::constants::*; -pub use self::epsilon::*; +pub use self::constants::{e, two_pi, euler, four_over_pi, golden_ratio, half_pi, ln_ln_two, ln_ten, ln_two, one, one_over_pi, one_over_root_two, one_over_two_pi, quarter_pi, root_five, root_half_pi, root_ln_four, root_pi, root_three, root_two, root_two_pi, third, three_over_two_pi, two_over_pi, two_over_root_pi, two_thirds, zero}; //pub use self::integer::*; -pub use self::matrix_access::*; -pub use self::matrix_inverse::*; +pub use self::matrix_access::{column, row, set_column, set_row}; +pub use self::matrix_inverse::{affine_inverse, inverse_transpose}; //pub use self::packing::*; //pub use self::reciprocal::*; //pub use self::round::*; -pub use self::type_ptr::*; +pub use self::type_ptr::{make_mat2, make_mat2x2, make_mat2x3, make_mat2x4, make_mat3, make_mat3x2, make_mat3x3, make_mat3x4, make_mat4, make_mat4x2, make_mat4x3, make_mat4x4, make_quat, make_vec1, make_vec2, make_vec3, make_vec4, value_ptr, value_ptr_mut, vec1_to_vec2, vec1_to_vec3, vec1_to_vec4, vec2_to_vec1, vec2_to_vec2, vec2_to_vec3, vec2_to_vec4, vec3_to_vec1, vec3_to_vec2, vec3_to_vec3, vec3_to_vec4, vec4_to_vec1, vec4_to_vec2, vec4_to_vec3, vec4_to_vec4}; //pub use self::ulp::*; -pub use self::quaternion::*; +pub use self::quaternion::{quat_cast, quat_euler_angles, quat_greater_than, quat_greater_than_equal, quat_less_than, quat_less_than_equal, quat_look_at, quat_look_at_lh, quat_look_at_rh, quat_pitch, quat_roll, quat_yaw}; //mod bitfield; diff --git a/nalgebra-glm/src/gtc/quaternion.rs b/nalgebra-glm/src/gtc/quaternion.rs index 3b170a66..f0b3ec1b 100644 --- a/nalgebra-glm/src/gtc/quaternion.rs +++ b/nalgebra-glm/src/gtc/quaternion.rs @@ -1,4 +1,4 @@ -use na::{Real, U3, U4, UnitQuaternion, Vector3, Rotation3}; +use na::{Real, U3, U4, UnitQuaternion, Vector3}; use aliases::{Qua, Vec, Mat}; @@ -34,13 +34,6 @@ pub fn quat_less_than_equal(x: &Qua, y: &Qua) -> Vec { pub fn quat_cast(x: &Qua) -> Mat { ::quat_to_mat4(x) } - -/// Convert a rotation matrix to a quaternion. -pub fn quat_to_mat3(x: &Mat) -> Qua { - let rot = Rotation3::from_matrix_unchecked(x); - UnitQuaternion::from_rotation_matrix(&rot).unwrap() -} - /// Computes a right-handed look-at quaternion (equivalent to a right-handed look-at matrix). pub fn quat_look_at(direction: &Vec, up: &Vec) -> Qua { quat_look_at_rh(direction, up) diff --git a/nalgebra-glm/src/gtx/mod.rs b/nalgebra-glm/src/gtx/mod.rs index 2fe1f2ff..85300918 100644 --- a/nalgebra-glm/src/gtx/mod.rs +++ b/nalgebra-glm/src/gtx/mod.rs @@ -1,23 +1,23 @@ //! (Reexported) Experimental features not specified by GLSL specification. -pub use self::component_wise::*; +pub use self::component_wise::{comp_add, comp_max, comp_min, comp_mul}; //pub use self::euler_angles::*; -pub use self::exterior_product::*; -pub use self::handed_coordinate_space::*; -pub use self::matrix_cross_product::*; -pub use self::matrix_operation::*; -pub use self::norm::*; -pub use self::normal::*; -pub use self::normalize_dot::*; -pub use self::rotate_normalized_axis::*; -pub use self::rotate_vector::*; -pub use self::transform::*; -pub use self::transform2::*; -pub use self::transform2d::*; -pub use self::vector_angle::*; -pub use self::vector_query::*; -pub use self::quaternion::*; +pub use self::exterior_product::{cross2d}; +pub use self::handed_coordinate_space::{left_handed, right_handed}; +pub use self::matrix_cross_product::{matrix_cross, matrix_cross3}; +pub use self::matrix_operation::{diagonal2x2, diagonal2x3, diagonal2x4, diagonal3x2, diagonal3x3, diagonal3x4, diagonal4x2, diagonal4x3, diagonal4x4}; +pub use self::norm::{distance2, l1_distance, l1_norm, l2_distance, l2_norm, length2, magnitude2}; +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::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}; +pub use self::vector_angle::{angle}; +pub use self::vector_query::{are_collinear, are_collinear2d, are_orthogonal, is_comp_null, is_normalized, is_null}; +pub use self::quaternion::{quat_to_mat3, quat_rotate_vec, quat_cross_vec, mat3_to_quat, quat_extract_real_component, quat_fast_mix, quat_inv_cross_vec, quat_length2, quat_magnitude2, quat_identity, quat_rotate_vec3, quat_rotation, quat_short_mix, quat_to_mat4, to_quat}; diff --git a/nalgebra-glm/src/gtx/quaternion.rs b/nalgebra-glm/src/gtx/quaternion.rs index a8150f8e..696c218c 100644 --- a/nalgebra-glm/src/gtx/quaternion.rs +++ b/nalgebra-glm/src/gtx/quaternion.rs @@ -3,12 +3,12 @@ use na::{Real, Unit, Rotation3, Vector4, UnitQuaternion, U3, U4}; use aliases::{Qua, Vec, Mat}; /// Rotate the vector `v` by the quaternion `q` assumed to be normalized. -pub fn quat_cross(q: &Qua, v: &Vec) -> Vec { +pub fn quat_cross_vec(q: &Qua, v: &Vec) -> Vec { UnitQuaternion::new_unchecked(*q) * v } /// Rotate the vector `v` by the inverse of the quaternion `q` assumed to be normalized. -pub fn quat_inv_cross(v: &Vec, q: &Qua) -> Vec { +pub fn quat_inv_cross_vec(v: &Vec, q: &Qua) -> Vec { UnitQuaternion::new_unchecked(*q).inverse() * v } @@ -37,7 +37,7 @@ pub fn quat_magnitude2(q: &Qua) -> N { } /// The quaternion representing the identity rotation. -pub fn quat_quat_identity() -> Qua { +pub fn quat_identity() -> Qua { UnitQuaternion::identity().unwrap() } @@ -47,7 +47,7 @@ pub fn quat_rotate_vec3(q: &Qua, v: &Vec) -> Vec { } /// Rotates a vector in homogeneous coordinates by a quaternion assumed to be normalized. -pub fn quat_rotate(q: &Qua, v: &Vec) -> Vec { +pub fn quat_rotate_vec(q: &Qua, v: &Vec) -> Vec { // UnitQuaternion::new_unchecked(*q) * v let rotated = Unit::new_unchecked(*q) * v.fixed_rows::(0); Vector4::new(rotated.x, rotated.y, rotated.z, v.w) @@ -86,6 +86,6 @@ pub fn mat3_to_quat(x: &Mat) -> Qua { /// Converts a rotation matrix in homogeneous coordinates to a quaternion. pub fn to_quat(x: &Mat) -> Qua { let rot = x.fixed_slice::(0, 0).into_owned(); - to_quat(&rot) + mat3_to_quat(&rot) } diff --git a/nalgebra-glm/src/gtx/transform2d.rs b/nalgebra-glm/src/gtx/transform2d.rs index 43406694..1f7cc3ac 100644 --- a/nalgebra-glm/src/gtx/transform2d.rs +++ b/nalgebra-glm/src/gtx/transform2d.rs @@ -1,4 +1,4 @@ -use na::{Real, U2, U3, UnitComplex, Matrix3}; +use na::{Real, U2, U3, UnitComplex}; use traits::Number; use aliases::{Mat, Vec}; diff --git a/nalgebra-glm/src/lib.rs b/nalgebra-glm/src/lib.rs index 46d06870..89a29660 100644 --- a/nalgebra-glm/src/lib.rs +++ b/nalgebra-glm/src/lib.rs @@ -1,7 +1,4 @@ -#![allow(dead_code)] - - extern crate num_traits as num; #[macro_use] @@ -11,17 +8,54 @@ extern crate nalgebra as na; pub use aliases::*; pub use constructors::*; -pub use common::*; -pub use geometric::*; -pub use matrix::*; -pub use traits::*; -pub use trigonometric::*; -pub use vector_relational::*; -pub use exponential::*; +pub use common::{abs, ceil, clamp, clamp2, clamp3, float_bits_to_int, float_bits_to_int_vec, float_bits_to_uint, float_bits_to_uint_vec, floor, fract, fract2, int_bits_to_float, int_bits_to_float_vec, mix, modf, modf_vec, round, sign, smoothstep, step, step_scalar, step_vec, trunc, uint_bits_to_float, uint_bits_to_float_scalar}; +pub use geometric::{reflect_vec, cross, distance, dot, faceforward, length, magnitude, normalize, refract_vec}; +pub use matrix::{transpose, determinant, inverse, matrix_comp_mult, outer_product}; +pub use traits::{Dimension, Number, Alloc}; +pub use trigonometric::{acos, acosh, asin, asinh, atan, atan2, atanh, cos, cosh, degrees, radians, sin, sinh, tan, tanh}; +pub use vector_relational::{all, any, equal, greater_than, greater_than_equal, less_than, less_than_equal, not, not_equal}; +pub use exponential::{exp, exp2, inversesqrt, log, log2, pow, sqrt}; -pub use gtx::*; -pub use gtc::*; -pub use ext::*; +pub use gtx::{ + comp_add, comp_max, comp_min, comp_mul, + cross2d, + left_handed, right_handed, + matrix_cross, matrix_cross3, + diagonal2x2, diagonal2x3, diagonal2x4, diagonal3x2, diagonal3x3, diagonal3x4, diagonal4x2, diagonal4x3, diagonal4x4, + distance2, l1_distance, l1_norm, l2_distance, l2_norm, length2, magnitude2, + 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, + 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, + angle, + are_collinear, are_collinear2d, are_orthogonal, is_comp_null, is_normalized, is_null, + quat_to_mat3, quat_rotate_vec, quat_cross_vec, mat3_to_quat, quat_extract_real_component, quat_fast_mix, quat_inv_cross_vec, quat_length2, quat_magnitude2, quat_identity, quat_rotate_vec3, quat_rotation, quat_short_mix, quat_to_mat4, to_quat +}; +pub use gtc::{ + e, two_pi, euler, four_over_pi, golden_ratio, half_pi, ln_ln_two, ln_ten, ln_two, one, one_over_pi, one_over_root_two, one_over_two_pi, quarter_pi, root_five, root_half_pi, root_ln_four, root_pi, root_three, root_two, root_two_pi, third, three_over_two_pi, two_over_pi, two_over_root_pi, two_thirds, zero, + column, row, set_column, set_row, + affine_inverse, inverse_transpose, + make_mat2, make_mat2x2, make_mat2x3, make_mat2x4, make_mat3, make_mat3x2, make_mat3x3, make_mat3x4, make_mat4, make_mat4x2, make_mat4x3, make_mat4x4, make_quat, make_vec1, make_vec2, make_vec3, make_vec4, value_ptr, value_ptr_mut, vec1_to_vec2, vec1_to_vec3, vec1_to_vec4, vec2_to_vec1, vec2_to_vec2, vec2_to_vec3, vec2_to_vec4, vec3_to_vec1, vec3_to_vec2, vec3_to_vec3, vec3_to_vec4, vec4_to_vec1, vec4_to_vec2, vec4_to_vec3, vec4_to_vec4, + quat_cast, quat_euler_angles, quat_greater_than, quat_greater_than_equal, quat_less_than, quat_less_than_equal, quat_look_at, quat_look_at_lh, quat_look_at_rh, quat_pitch, quat_roll, quat_yaw +}; +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, + max3_scalar, max4_scalar, min3_scalar, min4_scalar, + epsilon, pi, + max, max2, max3, max4, min, min2, min3, min4, + equal_eps, equal_eps_vec, not_equal_eps, not_equal_eps_vec, + quat_conjugate, quat_inverse, quat_lerp, quat_slerp, + quat_cross, quat_dot, quat_length, quat_magnitude, quat_normalize, + quat_equal, quat_equal_eps, quat_not_equal, quat_not_equal_eps, + quat_exp, quat_log, quat_pow, quat_rotate, + quat_angle, quat_angle_axis, quat_axis +}; mod aliases; mod constructors; @@ -35,6 +69,6 @@ mod exponential; //mod integer; //mod packing; -pub mod ext; -pub mod gtc; -pub mod gtx; \ No newline at end of file +mod ext; +mod gtc; +mod gtx; \ No newline at end of file