Add rotated_around for Vector2, Vector3 to GDScript and C# #82589
+147
−0
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Related to: godotengine/godot-proposals#235
Implements helper functions to rotate a vector around a specific origin to Vector2 and Vector3.
Additions
Vector2::rotated_around
, which rotates a vector around a specific origin, by an angle.Vector3::rotated_around_axis
, which rotates a vector around a specific origin given a rotation axis and angle.Vector3::rotated_around
, which rotates a vector around a specific origin given a rotation represented as a quaternion.Implemented for GDScript and C#, includes documentation changes and tests.
I think this change should be compatible with 3.x as well, but I'm not 100%.
... I added this mostly because I wanted it for myself, and I figure others might find it useful :)
(and it also happens to be readily available in eg. Unity)
I was considering adding a... Added it after all, seems useful.rotated_around
for Vector3 that takes a Quat as well, so it's more generally useful (and that's the version I'd personally implement on my own projects), but maybe that's a bit much?