Skip to content

Comments

Add scaling, with_scaling, skewing, with_skewing to Affine#547

Open
laurenz-canva wants to merge 1 commit intomainfrom
laurenz/affine
Open

Add scaling, with_scaling, skewing, with_skewing to Affine#547
laurenz-canva wants to merge 1 commit intomainfrom
laurenz/affine

Conversation

@laurenz-canva
Copy link

scale (and skew) would be better IMO, but that name's already taken. :(


/// Replaces the scaling portion of this affine map.
///
/// The scaling can be seen as being applied after the linear part of the map.
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this sentence also apply here? Not sure I fully understand it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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].

Copy link
Member

@jneem jneem Feb 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This name was pretty confusing to me... maybe scale_factor and skew_factor ? I don't know.

Copy link
Member

@tomcur tomcur left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants