It seems like an easy problem but I somehow didnt got to the solution. I need the Maths to change the Vector based on Euler angles.

Example Problem:

I have an direction Vector- for example: Showing Forward: (0,0,1)

I have 3 Euler Angles (X,Y,Z) for example like this: (0°,180°,0)

Which means: It rotates back -

Now if I add that to the direction Vector- I want my direction Vector to show Backward (0,0,-1)

I tried last night and did not came up to a solution how to do the maths for this.

Anyone here knows the math to solve this?


The general solution is to unpack your angular representation to a transformation matrix or quaternion, then multiply your vector by that transformation.

The exact matrix math will depend on the conventions used for your angular representation. In games we often call any 3-angle representation "Euler" but often we really use roll-pitch-yaw or pitch-roll-yaw systems that aren't mathematically equivalent. For an example of how to derive this matrix for your rotation conventions, check this related answer. We won't be able to offer a more explicit answer without knowing what your angles represent in your environment's rotation conventions.

For special cases where the vector is aligned with one of the coordinate axes (like your (0, 0, 1) example), it suffices to compute just one column of the transformation matrix, and scale it by the nonzero component of your vector to generate its transformed version - so that can be a shortcut if you only care about one or two axes. Similarly, we can simplify the matrix math if you know in advance that one of your angles will always be zero or some other constant.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.