vector_math.dart icon indicating copy to clipboard operation
vector_math.dart copied to clipboard

feat: Add leftTranslateByVector2 method to Matrix4

Open luanpotter opened this issue 4 months ago • 5 comments

As a follow-up of https://github.com/google/vector_math.dart/pull/349, we might want to support leftTranslateByVector2, for the same reasons.

Note: there were no tests that I could find for the other broken down methods, so I added some assertions. Please let me know if they should be somewhere else or if we want more exhaustive tests.

Note: I am not implementing an equivalent for the scale method because the default implementation of falling back y and z to x felt less intuitive when using a Vector2. It would mean that scaling by a Vector2 v would be equivalent to scale by v.x, v.y, v.x, 1.0, which isn't quite as clear as the translation case. But I'd be happy to add the helper if desired.

luanpotter avatar Sep 11 '25 00:09 luanpotter

@kevmoo updated this one with rebase + changelog entry 🙇

luanpotter avatar Nov 14 '25 19:11 luanpotter

Would you include more details? I don't know what "left" means here.

kevmoo avatar Nov 14 '25 20:11 kevmoo

Coverage Status

coverage: 27.015% (+0.2%) from 26.849% when pulling 708eb84f5e258e1f673c87fd83c9790a643cce1d on luanpotter:luan.leftTranslateByVector2 into be9974e7c6590b44e01d6f7cf77267f06d1ac677 on google:master.

coveralls avatar Nov 14 '25 20:11 coveralls

@kevmoo this is mostly for consistent with the existing leftTranslate series of methods, so they match the (right) translate. The direction here is whether this matrix is multiplied from the left or from the right with the resulting translation matrix, which can have different results. I added a bit more detail to the changelog, please let me know if you want me to elaborate more (but this is in line with how all the existing methods are named and described in the docs).

luanpotter avatar Nov 14 '25 21:11 luanpotter

This is also parallel to https://github.com/google/vector_math.dart/pull/354 btw

luanpotter avatar Nov 25 '25 19:11 luanpotter