diff --git a/src/matrix.rs b/src/matrix.rs index 2b488b1..ba28843 100644 --- a/src/matrix.rs +++ b/src/matrix.rs @@ -232,8 +232,8 @@ impl Matrix4 { /// Create a homogeneous transformation matrix that will cause a vector to point at /// `dir`, using `up` for orientation. - pub fn look_at(eye: Point3, center: Point3, up: Vector3) -> Matrix4 { - let f = (center - eye).normalize(); + pub fn look_at_dir(eye: Point3, dir: Vector3, up: Vector3) -> Matrix4 { + let f = dir.normalize(); let s = f.cross(up).normalize(); let u = s.cross(f); @@ -243,6 +243,12 @@ impl Matrix4 { -eye.dot(s), -eye.dot(u), eye.dot(f), S::one()) } + /// Create a homogeneous transformation matrix that will cause a vector to point at + /// `center`, using `up` for orientation. + pub fn look_at(eye: Point3, center: Point3, up: Vector3) -> Matrix4 { + Matrix4::look_at_dir(eye, center - eye, up) + } + /// Create a homogeneous transformation matrix from a rotation around the `x` axis (pitch). pub fn from_angle_x>>(theta: A) -> Matrix4 { // http://en.wikipedia.org/wiki/Rotation_matrix#Basic_rotations