servo / euclid

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

Add component-wise ceiling division of 2d and 3d vectors #482

Closed alexkirsz closed 3 years ago

alexkirsz commented 3 years ago

Rest of the fix for #480 (#481 is the first part).

I implemented this in its own PR in case there are issues with this particular API/implementation, while I think #481 is simple enough not to be controversial.

bors-servo commented 3 years ago

:umbrella: The latest upstream changes (presumably #481) made this pull request unmergeable. Please resolve the merge conflicts.

nical commented 3 years ago

I'm a tad scheptical of adding ceiling_division to euclid. What is your use case for it? It's a bit unclear what the semantics should be with negative numbers and more generally what it means in the context of linear algebra.

alexkirsz commented 3 years ago

One use case where I needed this was for filling a grid of size MxN pixels with tiles of size OxP, where you'll need ceiling_div(M, O)xceiling_div(N, P) tiles.

nical commented 3 years ago

IMHO it's a bit too niche for inclusion in euclid and easy enough to implement outside of this crate.

alexkirsz commented 3 years ago

I can totally see that. In fact, now that we have component_div, it can more easily be implemented with:

(a + b - Vector2::one()).component_div(b)

I'll close this PR and the associated issue. Thanks for taking the time to review and discuss this! 😄

nical commented 3 years ago

Thanks for your understanding and contribution.