fix Vec3::with_mag to return an Option

and thereby simplify it into just one method.
This commit is contained in:
2022-07-29 21:45:25 -07:00
parent ba6ef3c5c2
commit 349e01ba16
4 changed files with 23 additions and 39 deletions

View File

@@ -54,7 +54,7 @@ fn scale_unsigned_to_u8(x: f32, typ: f32) -> u8 {
/// Scale a vector to have magnitude between [0, 1).
fn scale_vector(x: Vec2<f32>, typical_mag: f32) -> Vec2<f32> {
let new_mag = scale_unsigned(x.mag(), typical_mag);
x.with_mag(new_mag)
x.with_mag(new_mag).unwrap_or_default()
}
fn im_size<S: AbstractSim>(state: &S, max_w: u32, max_h: u32) -> (u32, u32) {