servo / euclid

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

Constructors: splat, one #473

Closed dhardy closed 3 years ago

dhardy commented 3 years ago

I don't see any constructor for equal values (splat/repeat/uniform/square). Seems like an obvious enough addition that it barely needs any justification? (I've found a few uses myself, even if some of them are for zero/one.) It might be best to use SIMD notation (splat)?

Also I see there are zero constructors over num-traits::Zero. I think it would be worth adding one in analogous fashion?

nical commented 3 years ago

Sounds good to me. splat makes sense.

dhardy commented 3 years ago

On second thoughts, there doesn't seem to be much point adding one given the strict unit system — the exception being Vector which supports dot and cross products.

I'm a bit confused why Size and Vector both exist — the differences are that Vector has a few extra methods and that Size has much longer component names. Is Size just something that exists for historical reasons?

nical commented 3 years ago

From a pure mathematical point of view Vector and Size are more or less the same thing, but in practice when you are building a browser engine with tons of layout and graphics code, having both x/y vectors and width/height sizes to match the higher level semantics of what you are doing is very nice. That's definitely something I would not change in euclid.