Implement Add/Sub of Translation* for Point*#507
Conversation
Like servo#506, these exist for the vector types. There doesn't seem to be any reason there shouldn't also work for translation types. The existing `translate` methods could be used for subtraction with `inv`, but that requires a complicated bound involving `Inv` and `Add` instead of a `Sub` bound.
nical
left a comment
There was a problem hiding this comment.
Why not. If you are adding these then please also implement the equivalent Add/Sub Rect and Box2D
|
|
||
| /// Translate a point by inverse and cast its unit. | ||
| #[inline] | ||
| pub(crate) fn transform_point_inv(&self, p: Point2D<T, Dst>) -> Point2D<T::Output, Src> |
There was a problem hiding this comment.
Let's not add _inv methods like this. You could relax the requirements on inverse or simply do the math manually in sub.
There was a problem hiding this comment.
These functions are pub(crate) since I wasn't sure they made sense in the public API or what to name them. Having them alongside the transformations in the opposite direction make it easier to see that they're correct, but the body of the function could definitely be moved directly into the Sub implementation.
There was a problem hiding this comment.
but the body of the function could definitely be moved directly into the Sub implementation.
This would be my preference.
Like #506, these exist for the vector types. There doesn't seem to be any reason there shouldn't also work for translation types.
The existing
translatemethods could be used for subtraction withinv, but that requires a complicated bound involvingInvandAddinstead of aSubbound.