Add look_at_z.
Having a look_at which aligns the z-axis with the look_at direction is useful for cameras. It will exist only in 3d.
This commit is contained in:
parent
8634b9037d
commit
93597f0ef9
@ -86,6 +86,17 @@ impl<N: Clone + DivisionRing + Algebraic> Rotmat<Mat3<N>>
|
||||
xaxis.y.clone(), yaxis.y.clone(), zaxis.y.clone(),
|
||||
xaxis.z , yaxis.z , zaxis.z)
|
||||
}
|
||||
|
||||
pub fn look_at_z(&mut self, at: &Vec3<N>, up: &Vec3<N>)
|
||||
{
|
||||
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<N: Trigonometric + DivisionRing + Clone>
|
||||
|
@ -47,6 +47,12 @@ impl<N: Clone + DivisionRing + Algebraic> Transform<Rotmat<Mat3<N>>, Vec3<N>>
|
||||
self.submat.look_at(&(*at - *eye), up);
|
||||
self.subtrans = eye.clone();
|
||||
}
|
||||
|
||||
pub fn look_at_z(&mut self, eye: &Vec3<N>, at: &Vec3<N>, up: &Vec3<N>)
|
||||
{
|
||||
self.submat.look_at_z(&(*at - *eye), up);
|
||||
self.subtrans = eye.clone();
|
||||
}
|
||||
}
|
||||
|
||||
impl<M: Dim, V> Dim for Transform<M, V>
|
||||
|
Loading…
Reference in New Issue
Block a user