servo / euclid

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

Scale::inverse negates the scale instead of inversing it. #438

Closed klotzambein closed 4 years ago

klotzambein commented 4 years ago

There are two inverse functions for the Scale type. One called "inv" and another called "inverse". The first function ("inv") properly inverses the scale. While the second function just negates the scale. If this is the desired behavior it probably should be noted in the documentation.

This is an example of how we can end up with a wrong identity scale:

struct A;
struct B;
let scale: Scale<f32, A, B> = Scale::new(2.);
let identity_scale = scale * scale.inverse();
assert_eq!(identity_scale.get(), -4);
nical commented 4 years ago

For some reason I missed this notification. The behavior of inverse indeed sounds quite bad to me.