Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Overhaul Transform2D documentation #94127

Merged
merged 1 commit into from
Jul 10, 2024

Conversation

Mickeon
Copy link
Contributor

@Mickeon Mickeon commented Jul 9, 2024

Continuation of #87334 but on the 2D side.

This PR aims to overhaul the Transform2D type's documentation.
The reasoning and changelog are extremely similar to the "Overhaul Basis documentation" PR, so I'm not sure I should bother repeating them twice.

A lot of wording is ripped straight from Transform3D and Basis's descriptions, with a few exceptions:

  • A lot of things have to be "rerouted" to explain them on the spot, rather than point to Basis, because there's no Basis2D Variant type.
  • basis_xform_inv was reworded quite a bit because it was very, very awkward.

@Mickeon Mickeon added this to the 4.4 milestone Jul 9, 2024
@Mickeon Mickeon requested a review from a team as a code owner July 9, 2024 10:09
@@ -4,8 +4,10 @@
A 2×3 matrix representing a 2D transformation.
</brief_description>
<description>
A 2×3 matrix (2 rows, 3 columns) used for 2D linear transformations. It can represent transformations such as translation, rotation, and scaling. It consists of three [Vector2] values: [member x], [member y], and the [member origin].
The [Transform2D] built-in [Variant] type is a 2×3 [url=https://en.wikipedia.org/wiki/Matrix_(mathematics)]matrix[/url] representing a transformation in 2D space. It contains three [Vector2] values: [member x], [member y], and [member origin]. Together, they can represent translation, rotation, scale, and skew.
The [member x] and [member y] axes form a 2×2 matrix, known as the transform's [b]basis[/b]. The length of each axis ([method Vector2.length]) influences the transform's scale, while the direction of all axes influence the rotation. Usually, both axes are perpendicular to one another. However, when you rotate one axis individually, the transform becomes skewed. Applying a skewed transform to a 2D sprite will make the sprite appear distorted.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Alternative take which resembles Basis's equivalent description:

Suggested change
The [member x] and [member y] axes form a 2×2 matrix, known as the transform's [b]basis[/b]. The length of each axis ([method Vector2.length]) influences the transform's scale, while the direction of all axes influence the rotation. Usually, both axes are perpendicular to one another. However, when you rotate one axis individually, the transform becomes skewed. Applying a skewed transform to a 2D sprite will make the sprite appear distorted.
The [Transform2D]'s basis is composed by 2 axis vectors, each representing a column of the matrix: [member x] and [member y]. The length of each axis ([method Vector2.length]) influences the basis's scale, while the direction of all axes influence the rotation. Usually, these axes are perpendicular to one another. However, when you rotate any axis individually, the basis becomes skewed. Applying a skewed basis to a 2D sprite will make the sprite appear distorted.

Copy link
Member

@mhilbrunner mhilbrunner left a comment

Choose a reason for hiding this comment

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

Great work, LGTM!

@akien-mga akien-mga modified the milestones: 4.4, 4.3 Jul 9, 2024
@akien-mga akien-mga merged commit 284c96d into godotengine:master Jul 10, 2024
18 checks passed
@akien-mga
Copy link
Member

Thanks!

@Mickeon Mickeon deleted the doc-peeves-transform2d branch July 10, 2024 22:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants