Changed the semantic of the look_at method.
Before, the `look_at` method aligned the `z` axis with the look_at direction. This will be problematic in the future if we want to generalize that on n-dimension (the z axis could not axis at all when n < 3). Now, the `look_at` method aligns the `x` axis with the look_at direction. Thus we have a chance for it to be generalizable on n-dimension, `n >= 1`.
This commit is contained in:
parent
4ea1dd92e6
commit
8634b9037d
|
@ -78,8 +78,8 @@ impl<N: Clone + DivisionRing + Algebraic> Rotmat<Mat3<N>>
|
||||||
{
|
{
|
||||||
pub fn look_at(&mut self, at: &Vec3<N>, up: &Vec3<N>)
|
pub fn look_at(&mut self, at: &Vec3<N>, up: &Vec3<N>)
|
||||||
{
|
{
|
||||||
let zaxis = at.normalized();
|
let xaxis = at.normalized();
|
||||||
let xaxis = up.cross(&zaxis).normalized();
|
let zaxis = up.cross(&xaxis).normalized();
|
||||||
let yaxis = zaxis.cross(&xaxis);
|
let yaxis = zaxis.cross(&xaxis);
|
||||||
|
|
||||||
self.submat = Mat3::new(xaxis.x.clone(), yaxis.x.clone(), zaxis.x.clone(),
|
self.submat = Mat3::new(xaxis.x.clone(), yaxis.x.clone(), zaxis.x.clone(),
|
||||||
|
|
Loading…
Reference in New Issue