servo / euclid

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

Should Vector2D<T,U>::length() return Length<T,U> #396

Open btrepp opened 4 years ago

btrepp commented 4 years ago

Not sure If I'm misunderstanding something, but shouldn't this try and preserve the unit?. It's easy enough to handle, in your own code, but I did like the strong types this library provided.

nical commented 4 years ago

In practice we found out that people often don't use the units much when dealing with the scalar values (while they do with vectors and other types), so we want to have the default set of common accessors like x,y,length work with raw scalars. We even had *_typed() equivalents for all methods that return scalars but it was apparently too cumbersome to be used in practice so they were removed a little while ago.

I'm keen on adding them back with a less awkward naming scheme, for example get_length(&self) -> Length<T, U>, get_x(&self) -> Length<T, U>, etc. See also #388.