Skip to content

Commit

Permalink
Update docs of look_* functions
Browse files Browse the repository at this point in the history
This change clarifies the meaning of the _lh and _rh suffixes.
  • Loading branch information
elrnv committed Aug 11, 2020
1 parent 1a007f2 commit 46713c9
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 12 deletions.
24 changes: 16 additions & 8 deletions src/matrix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -366,8 +366,10 @@ impl<S: BaseFloat> Matrix4<S> {
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<S>, dir: Vector3<S>, up: Vector3<S>) -> Matrix4<S> {
let f = dir.normalize();
let s = f.cross(up).normalize();
Expand All @@ -382,8 +384,10 @@ impl<S: BaseFloat> Matrix4<S> {
)
}

/// 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<S>, dir: Vector3<S>, up: Vector3<S>) -> Matrix4<S> {
Matrix4::look_to_rh(eye, -dir, up)
}
Expand All @@ -395,14 +399,18 @@ impl<S: BaseFloat> Matrix4<S> {
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<S>, center: Point3<S>, up: Vector3<S>) -> Matrix4<S> {
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<S>, center: Point3<S>, up: Vector3<S>) -> Matrix4<S> {
Matrix4::look_to_lh(eye, center - eye, up)
}
Expand Down
1 change: 1 addition & 0 deletions src/rotation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,7 @@ impl<'a, S: 'a + BaseFloat> iter::Product<&'a Basis3<S>> for Basis3<S> {
}

impl<S: BaseFloat> Rotation<Point3<S>> for Basis3<S> {
/// Construct a look-at view matrix assuming a left-handed coordinate system.
#[inline]
fn look_to(dir: Vector3<S>, up: Vector3<S>) -> Basis3<S> {
Basis3 {
Expand Down
12 changes: 8 additions & 4 deletions src/transform.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,16 @@ pub trait Transform<P: EuclideanSpace>: Sized {
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.
Expand Down

0 comments on commit 46713c9

Please sign in to comment.