diff --git a/src/adaptors/rotmat.rs b/src/adaptors/rotmat.rs index 1bef1a86..86a51438 100644 --- a/src/adaptors/rotmat.rs +++ b/src/adaptors/rotmat.rs @@ -86,6 +86,17 @@ impl Rotmat> xaxis.y.clone(), yaxis.y.clone(), zaxis.y.clone(), xaxis.z , yaxis.z , zaxis.z) } + + pub fn look_at_z(&mut self, at: &Vec3, up: &Vec3) + { + let zaxis = at.normalized(); + let xaxis = up.cross(&zaxis).normalized(); + let yaxis = zaxis.cross(&xaxis); + + self.submat = Mat3::new(xaxis.x.clone(), yaxis.x.clone(), zaxis.x.clone(), + xaxis.y.clone(), yaxis.y.clone(), zaxis.y.clone(), + xaxis.z , yaxis.z , zaxis.z) + } } impl diff --git a/src/adaptors/transform.rs b/src/adaptors/transform.rs index 00dba499..da3422bc 100644 --- a/src/adaptors/transform.rs +++ b/src/adaptors/transform.rs @@ -47,6 +47,12 @@ impl Transform>, Vec3> self.submat.look_at(&(*at - *eye), up); self.subtrans = eye.clone(); } + + pub fn look_at_z(&mut self, eye: &Vec3, at: &Vec3, up: &Vec3) + { + self.submat.look_at_z(&(*at - *eye), up); + self.subtrans = eye.clone(); + } } impl Dim for Transform