servo / euclid

Geometry primitives (basic linear algebra) for Rust
Other
463 stars 102 forks source link

Add Transform2D::invertible() -> bool #378

Closed pbor closed 4 years ago

pbor commented 4 years ago

Right now I have the following code, but calculating the inverse just to throw it away looks confusing

        match t.inverse() {
            Some(_) => Ok(t),
            _ => Err(ValueErrorKind::Value("invalid transformation matrix".to_string())),
        }

I know I could use t.determinant() != 0.0, but that is less clear, also if we do it euclid itself we could have a generic implementation for each T: Zero

nical commented 4 years ago

Sounds good to me. Would you like to submit a PR for this?

nical commented 4 years ago

(nitpick) I would prefer is_invertible over invertible.