Add scaling, with_scaling, skewing, with_skewing to Affine#547
Add scaling, with_scaling, skewing, with_skewing to Affine#547laurenz-canva wants to merge 1 commit intomainfrom
scaling, with_scaling, skewing, with_skewing to Affine#547Conversation
|
|
||
| /// Replaces the scaling portion of this affine map. | ||
| /// | ||
| /// The scaling can be seen as being applied after the linear part of the map. |
There was a problem hiding this comment.
Does this sentence also apply here? Not sure I fully understand it.
There was a problem hiding this comment.
No, this sentence does not apply here. The Affine in Kurbo models a linear map plus a translation as an "augmented" matrix. Specifically, the first four components of the affine are the linear map. That can just be applied as the matrix-vector multiplication map * point. The translation is then performed after, i.e. calculating map * point + translation. In augmented form that can be expressed as [transformed; 1] = affine * [point; 1].
There was a problem hiding this comment.
Edit: oops, too slow 😄
No, because scaling (and also skewing, below) is part of the linear part of the map.
In the context of translation (which is affine, but not linear), that sentence is just saying that you can think of this affine map as being "first apply the linear transformation and then translate".
|
|
||
| /// Returns the scaling part of this affine map (`(self.0[0], self.0[3])`). | ||
| #[inline(always)] | ||
| pub const fn scaling(self) -> Vec2 { |
There was a problem hiding this comment.
This name was pretty confusing to me... maybe scale_factor and skew_factor ? I don't know.
tomcur
left a comment
There was a problem hiding this comment.
The effect of these coefficients mixes together in the map, and so coming up with a good name is slightly tricky. I think it's important to make clear these are not a decomposition (we have svd for that).
I'd suggest going with Affine::with_scale_coefficients / Affine::with_skew_coefficients. (Or terms for something shorter, but we already names these values "coefficients" in the docs, so probably go with that.)
Otherwise with_diagonal and with_off_diagonal could work without ascribing an interpretation, but that's not very informative.
scale(andskew) would be better IMO, but that name's already taken. :(