pub fn look_towards(dir: &Vector3<f32>, up: &Vector3<f32>) -> UnitQuat
Expand description

Creates a UnitQuat that corresponds to the local frame of an observer standing at the origin and looking toward dir. This is a version of UnitQuat::face_towards() that better matches our mathematical conventions.

It maps forward_vec() (-Z axis) to the direction dir.

Arguments

  • dir - The look direction. It does not need to be normalized.
  • up - The vertical direction. It does not need to be normalized. The only requirement of this parameter is to not be collinear to dir. Non-collinearity is not guaranteed to be checked.

Example

let dir = Vector3::new(1.0, 2.0, 3.0);
let q = look_towards(&dir, &up_vec());

// Make `dir` have a length of one, also known as a unit vector.
let unit_dir = Unit::new_normalize(dir);
assert_relative_eq!((q * forward_vec()), unit_dir);