Skip to content

feat: Add translateByVector2 method to Matrix4 #349

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

luanpotter
Copy link

@luanpotter luanpotter commented Aug 5, 2025

Before the deprecation of the dynamic translate method, since the z variable had default value of 0, you could translate by a vector two by doing:

matrix4.translate(vector2.x, vector2.y)

Here is an example "in the wild" of such usage.

With the new methods, this becomes even less ergonomic, as it would require either calling translateByDouble with 2 extra parameters, or converting the Vector2 to a Vector3.

So I propose we introduce a translateByVector2 which behaves exactly as translate(x, y) would before.


for (var i = 0; i < inputA.length; i++) {
relativeTest(output1[i], output2[i]);
relativeTest(outputA[i], outputB[i]);
}
Copy link
Author

Choose a reason for hiding this comment

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

note: I shifted the variable names a bit here to make it match some sort of logic with the new names, but please lmk if there is a preferred naming convention.

tbh this test feels like two tests in one but I don't want to change the structure too much.

@coveralls
Copy link

Coverage Status

coverage: 26.711% (+0.009%) from 26.702%
when pulling 6017083 on luanpotter:luan.translateByVector2
into 3939545 on google:master.

@spydon
Copy link
Collaborator

spydon commented Aug 15, 2025

@kevmoo could we have a review of this one? :)

@spydon
Copy link
Collaborator

spydon commented Aug 15, 2025

@luanpotter tool/generate_vector_math_64.dart needs to be run so that it generates the vector_math_64 file too.

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.

3 participants