From 187fe9ca394626d8edd1839f9f7337e80aeff7f5 Mon Sep 17 00:00:00 2001 From: Bruce Mitchener Date: Mon, 8 Oct 2018 21:56:34 +0700 Subject: [PATCH] Start to cross-link vector contructors / conversions. --- nalgebra-glm/src/gtc/type_ptr.rs | 159 +++++++++++++++++++++++++++++++ 1 file changed, 159 insertions(+) diff --git a/nalgebra-glm/src/gtc/type_ptr.rs b/nalgebra-glm/src/gtc/type_ptr.rs index c4beaa58..96f87ef2 100644 --- a/nalgebra-glm/src/gtc/type_ptr.rs +++ b/nalgebra-glm/src/gtc/type_ptr.rs @@ -133,21 +133,54 @@ pub fn make_quat(ptr: &[N]) -> Qua { } /// Creates a 1D vector from a slice. +/// +/// # See also: +/// +/// * [`make_vec2`](fn.make_vec2.html) +/// * [`make_vec3`](fn.make_vec3.html) +/// * [`make_vec4`](fn.make_vec4.html) pub fn make_vec1(v: &TVec1) -> TVec1 { *v } /// Creates a 1D vector from another vector. +/// +/// # See also: +/// +/// * [`vec1_to_vec1`](fn.vec1_to_vec1.html) +/// * [`vec3_to_vec1`](fn.vec3_to_vec1.html) +/// * [`vec4_to_vec1`](fn.vec4_to_vec1.html) +/// * [`vec1_to_vec2`](fn.vec1_to_vec2.html) +/// * [`vec1_to_vec3`](fn.vec1_to_vec3.html) +/// * [`vec1_to_vec4`](fn.vec1_to_vec4.html) pub fn vec2_to_vec1(v: &TVec2) -> TVec1 { TVec1::new(v.x) } /// Creates a 1D vector from another vector. +/// +/// # See also: +/// +/// * [`vec1_to_vec1`](fn.vec1_to_vec1.html) +/// * [`vec2_to_vec1`](fn.vec2_to_vec1.html) +/// * [`vec4_to_vec1`](fn.vec4_to_vec1.html) +/// * [`vec1_to_vec2`](fn.vec1_to_vec2.html) +/// * [`vec1_to_vec3`](fn.vec1_to_vec3.html) +/// * [`vec1_to_vec4`](fn.vec1_to_vec4.html) pub fn vec3_to_vec1(v: &TVec3) -> TVec1 { TVec1::new(v.x) } /// Creates a 1D vector from another vector. +/// +/// # See also: +/// +/// * [`vec1_to_vec1`](fn.vec1_to_vec1.html) +/// * [`vec2_to_vec1`](fn.vec2_to_vec1.html) +/// * [`vec3_to_vec1`](fn.vec3_to_vec1.html) +/// * [`vec1_to_vec2`](fn.vec1_to_vec2.html) +/// * [`vec1_to_vec3`](fn.vec1_to_vec3.html) +/// * [`vec1_to_vec4`](fn.vec1_to_vec4.html) pub fn vec4_to_vec1(v: &TVec4) -> TVec1 { TVec1::new(v.x) } @@ -155,26 +188,69 @@ pub fn vec4_to_vec1(v: &TVec4) -> TVec1 { /// Creates a 2D vector from another vector. /// /// Missing components, if any, are set to 0. +/// +/// # See also: +/// +/// * [`vec3_to_vec2`](fn.vec3_to_vec2.html) +/// * [`vec4_to_vec2`](fn.vec4_to_vec2.html) +/// * [`vec2_to_vec1`](fn.vec2_to_vec1.html) +/// * [`vec2_to_vec2`](fn.vec2_to_vec2.html) +/// * [`vec2_to_vec3`](fn.vec2_to_vec3.html) +/// * [`vec2_to_vec4`](fn.vec2_to_vec4.html) pub fn vec1_to_vec2(v: &TVec1) -> TVec2 { TVec2::new(v.x, N::zero()) } /// Creates a 2D vector from another vector. +/// +/// # See also: +/// +/// * [`vec1_to_vec2`](fn.vec1_to_vec2.html) +/// * [`vec3_to_vec2`](fn.vec3_to_vec2.html) +/// * [`vec4_to_vec2`](fn.vec4_to_vec2.html) +/// * [`vec2_to_vec1`](fn.vec2_to_vec1.html) +/// * [`vec2_to_vec2`](fn.vec2_to_vec2.html) +/// * [`vec2_to_vec3`](fn.vec2_to_vec3.html) +/// * [`vec2_to_vec4`](fn.vec2_to_vec4.html) pub fn vec2_to_vec2(v: &TVec2) -> TVec2 { *v } /// Creates a 2D vector from another vector. +/// +/// # See also: +/// +/// * [`vec1_to_vec2`](fn.vec1_to_vec2.html) +/// * [`vec4_to_vec2`](fn.vec4_to_vec2.html) +/// * [`vec2_to_vec1`](fn.vec2_to_vec1.html) +/// * [`vec2_to_vec2`](fn.vec2_to_vec2.html) +/// * [`vec2_to_vec3`](fn.vec2_to_vec3.html) +/// * [`vec2_to_vec4`](fn.vec2_to_vec4.html) pub fn vec3_to_vec2(v: &TVec3) -> TVec2 { TVec2::new(v.x, v.y) } /// Creates a 2D vector from another vector. +/// +/// # See also: +/// +/// * [`vec1_to_vec2`](fn.vec1_to_vec2.html) +/// * [`vec3_to_vec2`](fn.vec4_to_vec2.html) +/// * [`vec2_to_vec1`](fn.vec2_to_vec1.html) +/// * [`vec2_to_vec2`](fn.vec2_to_vec2.html) +/// * [`vec2_to_vec3`](fn.vec2_to_vec3.html) +/// * [`vec2_to_vec4`](fn.vec2_to_vec4.html) pub fn vec4_to_vec2(v: &TVec4) -> TVec2 { TVec2::new(v.x, v.y) } /// Creates a 2D vector from a slice. +/// +/// # See also: +/// +/// * [`make_vec1`](fn.make_vec1.html) +/// * [`make_vec3`](fn.make_vec3.html) +/// * [`make_vec4`](fn.make_vec4.html) pub fn make_vec2(ptr: &[N]) -> TVec2 { TVec2::from_column_slice(ptr) } @@ -182,6 +258,14 @@ pub fn make_vec2(ptr: &[N]) -> TVec2 { /// Creates a 3D vector from another vector. /// /// Missing components, if any, are set to 0. +/// +/// # See also: +/// +/// * [`vec2_to_vec3`](fn.vec2_to_vec3.html) +/// * [`vec3_to_vec3`](fn.vec3_to_vec3.html) +/// * [`vec4_to_vec3`](fn.vec4_to_vec3.html) +/// * [`vec1_to_vec2`](fn.vec1_to_vec2.html) +/// * [`vec1_to_vec4`](fn.vec1_to_vec4.html) pub fn vec1_to_vec3(v: &TVec1) -> TVec3 { TVec3::new(v.x, N::zero(), N::zero()) } @@ -189,21 +273,54 @@ pub fn vec1_to_vec3(v: &TVec1) -> TVec3 { /// Creates a 3D vector from another vector. /// /// Missing components, if any, are set to 0. +/// +/// # See also: +/// +/// * [`vec1_to_vec3`](fn.vec1_to_vec3.html) +/// * [`vec3_to_vec3`](fn.vec3_to_vec3.html) +/// * [`vec4_to_vec3`](fn.vec4_to_vec3.html) +/// * [`vec3_to_vec1`](fn.vec3_to_vec1.html) +/// * [`vec3_to_vec2`](fn.vec3_to_vec2.html) +/// * [`vec3_to_vec4`](fn.vec3_to_vec4.html) pub fn vec2_to_vec3(v: &TVec2) -> TVec3 { TVec3::new(v.x, v.y, N::zero()) } /// Creates a 3D vector from another vector. +/// +/// # See also: +/// +/// * [`vec1_to_vec3`](fn.vec1_to_vec3.html) +/// * [`vec2_to_vec3`](fn.vec2_to_vec3.html) +/// * [`vec4_to_vec3`](fn.vec4_to_vec3.html) +/// * [`vec3_to_vec1`](fn.vec3_to_vec1.html) +/// * [`vec3_to_vec2`](fn.vec3_to_vec2.html) +/// * [`vec3_to_vec4`](fn.vec3_to_vec4.html) pub fn vec3_to_vec3(v: &TVec3) -> TVec3 { *v } /// Creates a 3D vector from another vector. +/// +/// # See also: +/// +/// * [`vec1_to_vec3`](fn.vec1_to_vec3.html) +/// * [`vec2_to_vec3`](fn.vec2_to_vec3.html) +/// * [`vec3_to_vec3`](fn.vec3_to_vec3.html) +/// * [`vec3_to_vec1`](fn.vec3_to_vec1.html) +/// * [`vec3_to_vec2`](fn.vec3_to_vec2.html) +/// * [`vec3_to_vec4`](fn.vec3_to_vec4.html) pub fn vec4_to_vec3(v: &TVec4) -> TVec3 { TVec3::new(v.x, v.y, v.z) } /// Creates a 3D vector from another vector. +/// +/// # See also: +/// +/// * [`make_vec1`](fn.make_vec1.html) +/// * [`make_vec2`](fn.make_vec2.html) +/// * [`make_vec4`](fn.make_vec4.html) pub fn make_vec3(ptr: &[N]) -> TVec3 { TVec3::from_column_slice(ptr) } @@ -211,6 +328,15 @@ pub fn make_vec3(ptr: &[N]) -> TVec3 { /// Creates a 4D vector from another vector. /// /// Missing components, if any, are set to 0. +/// +/// # See also: +/// +/// * [`vec2_to_vec4`](fn.vec2_to_vec4.html) +/// * [`vec3_to_vec4`](fn.vec3_to_vec4.html) +/// * [`vec4_to_vec4`](fn.vec4_to_vec4.html) +/// * [`vec1_to_vec2`](fn.vec1_to_vec2.html) +/// * [`vec1_to_vec3`](fn.vec1_to_vec3.html) +/// * [`vec1_to_vec4`](fn.vec1_to_vec4.html) pub fn vec1_to_vec4(v: &TVec1) -> TVec4 { TVec4::new(v.x, N::zero(), N::zero(), N::zero()) } @@ -218,6 +344,15 @@ pub fn vec1_to_vec4(v: &TVec1) -> TVec4 { /// Creates a 4D vector from another vector. /// /// Missing components, if any, are set to 0. +/// +/// # See also: +/// +/// * [`vec1_to_vec4`](fn.vec1_to_vec4.html) +/// * [`vec3_to_vec4`](fn.vec3_to_vec4.html) +/// * [`vec4_to_vec4`](fn.vec4_to_vec4.html) +/// * [`vec2_to_vec1`](fn.vec2_to_vec1.html) +/// * [`vec2_to_vec2`](fn.vec2_to_vec2.html) +/// * [`vec2_to_vec3`](fn.vec2_to_vec3.html) pub fn vec2_to_vec4(v: &TVec2) -> TVec4 { TVec4::new(v.x, v.y, N::zero(), N::zero()) } @@ -225,16 +360,40 @@ pub fn vec2_to_vec4(v: &TVec2) -> TVec4 { /// Creates a 4D vector from another vector. /// /// Missing components, if any, are set to 0. +/// +/// # See also: +/// +/// * [`vec1_to_vec4`](fn.vec1_to_vec4.html) +/// * [`vec2_to_vec4`](fn.vec2_to_vec4.html) +/// * [`vec4_to_vec4`](fn.vec4_to_vec4.html) +/// * [`vec3_to_vec1`](fn.vec3_to_vec1.html) +/// * [`vec3_to_vec2`](fn.vec3_to_vec2.html) +/// * [`vec3_to_vec3`](fn.vec3_to_vec3.html) pub fn vec3_to_vec4(v: &TVec3) -> TVec4 { TVec4::new(v.x, v.y, v.z, N::zero()) } /// Creates a 4D vector from another vector. +/// +/// # See also: +/// +/// * [`vec1_to_vec4`](fn.vec1_to_vec4.html) +/// * [`vec2_to_vec4`](fn.vec2_to_vec4.html) +/// * [`vec3_to_vec4`](fn.vec3_to_vec4.html) +/// * [`vec4_to_vec1`](fn.vec4_to_vec1.html) +/// * [`vec4_to_vec2`](fn.vec4_to_vec2.html) +/// * [`vec4_to_vec3`](fn.vec4_to_vec3.html) pub fn vec4_to_vec4(v: &TVec4) -> TVec4 { *v } /// Creates a 4D vector from another vector. +/// +/// # See also: +/// +/// * [`make_vec1`](fn.make_vec1.html) +/// * [`make_vec2`](fn.make_vec2.html) +/// * [`make_vec3`](fn.make_vec3.html) pub fn make_vec4(ptr: &[N]) -> TVec4 { TVec4::from_column_slice(ptr) }