#Getting axis based off of camera forward

4 messages · Page 1 of 1 (latest)

elfin moat
#

Calling .abs() on the dot product is probably not right

pearl shoal
#

I think you want maximum. dot should be larger when the angle is smaller.

#

what's this about? num - 0.0

elfin moat
#

This appears to work :)

let east_dot = forward.dot(Vec3::X);
let west_dot = forward.dot(Vec3::NEG_X);
let north_dot = forward.dot(Vec3::NEG_Z);
let south_dot = forward.dot(Vec3::Z);
let numbers = [east_dot, west_dot, north_dot, south_dot];
let closest = numbers.into_iter().max_by_key(|&num| FloatOrd(num)).unwrap();
if closest == east_dot {
    println!("East");
} else if closest == west_dot {
    println!("West");
} else if closest == north_dot {
    println!("North");
} else {
    println!("South");
};