From d9d89deb04cbfcfeea053b1b9b40e208cf44942a Mon Sep 17 00:00:00 2001 From: Egor Larionov Date: Mon, 10 Aug 2020 17:42:02 -0700 Subject: [PATCH] Update docs of look_* functions This change clarifies the meaning of the _lh and _rh suffixes. --- src/matrix.rs | 24 ++++++++++++++++-------- src/rotation.rs | 1 + src/transform.rs | 12 ++++++++---- 3 files changed, 25 insertions(+), 12 deletions(-) diff --git a/src/matrix.rs b/src/matrix.rs index eb668cf2..62335820 100644 --- a/src/matrix.rs +++ b/src/matrix.rs @@ -366,8 +366,10 @@ impl Matrix4 { Self::look_to_rh(eye, dir, up) } - /// Create a homogeneous transformation matrix that will cause a vector to point at - /// `dir`, using `up` for orientation. + /// Creates a homogeneous right-handed look-at transformation matrix. + /// + /// This matrix will transform a vector to point in `dir` direction, using `up` for orientation + /// assuming a right-handed corrdinate system. pub fn look_to_rh(eye: Point3, dir: Vector3, up: Vector3) -> Matrix4 { let f = dir.normalize(); let s = f.cross(up).normalize(); @@ -382,8 +384,10 @@ impl Matrix4 { ) } - /// Create a homogeneous transformation matrix that will cause a vector to point at - /// `dir`, using `up` for orientation. + /// Creates a homogeneous left-handed look-at transformation matrix. + /// + /// This matrix will transform a vector to point in `dir` direction, using `up` for orientation + /// assuming a left-handed corrdinate system. pub fn look_to_lh(eye: Point3, dir: Vector3, up: Vector3) -> Matrix4 { Matrix4::look_to_rh(eye, -dir, up) } @@ -395,14 +399,18 @@ impl Matrix4 { Matrix4::look_to_rh(eye, center - eye, up) } - /// Create a homogeneous transformation matrix that will cause a vector to point at - /// `center`, using `up` for orientation. + /// Creates a homogeneous right-handed look-at transformation matrix. + /// + /// This matrix will transform a vector to point at `center`, using `up` for orientation + /// assuming a right-handed corrdinate system. pub fn look_at_rh(eye: Point3, center: Point3, up: Vector3) -> Matrix4 { Matrix4::look_to_rh(eye, center - eye, up) } - /// Create a homogeneous transformation matrix that will cause a vector to point at - /// `center`, using `up` for orientation. + /// Creates a homogeneous left-handed look-at transformation matrix. + /// + /// This matrix will transform a vector to point at `center`, using `up` for orientation + /// assuming a left-handed corrdinate system. pub fn look_at_lh(eye: Point3, center: Point3, up: Vector3) -> Matrix4 { Matrix4::look_to_lh(eye, center - eye, up) } diff --git a/src/rotation.rs b/src/rotation.rs index c39f6ea8..27f5b7b2 100644 --- a/src/rotation.rs +++ b/src/rotation.rs @@ -371,6 +371,7 @@ impl<'a, S: 'a + BaseFloat> iter::Product<&'a Basis3> for Basis3 { impl Rotation for Basis3 { type Space = Point3; + /// Construct a look-at view matrix assuming a left-handed coordinate system. #[inline] fn look_to(dir: Vector3, up: Vector3) -> Basis3 { Basis3 { diff --git a/src/transform.rs b/src/transform.rs index 9b0f55ca..0fae55a9 100644 --- a/src/transform.rs +++ b/src/transform.rs @@ -35,12 +35,16 @@ pub trait Transform: Sized + One { Self::look_at_lh(eye, center, up) } - /// Create a transformation that rotates a vector to look at `center` from - /// `eye`, using `up` for orientation. + /// Creates a right-handed look-at view transform. + /// + /// This transform rotates a vector to look at `center` from `eye`, using `up` for orientation + /// assuming a right-handed coordinate system. fn look_at_rh(eye: P, center: P, up: P::Diff) -> Self; - /// Create a transformation that rotates a vector to look at `center` from - /// `eye`, using `up` for orientation. + /// Creates a right-handed look-at view transform. + /// + /// This transform rotates a vector to look at `center` from `eye`, using `up` for orientation + /// assuming a left-handed coordinate system. fn look_at_lh(eye: P, center: P, up: P::Diff) -> Self; /// Transform a vector using this transform.