mathrotationlinear-algebraeuler-anglesvectormath

Calculating Forward Vector Given Rotation in 3D


Given a Vector 3 of Euler Angles, how could one mathematically find the direction that object is facing.

In other words, how does Unity calculate the 'transform.forward' vector?


Solution

  • You should read up on spherical polar coordinates, noting the difference between conventional polar and Euler angles. But anyway the formula is (cos(pitch)cos(yaw), cos(pitch)sin(yaw), sin(pitch)). Note that the roll has no effect here.