- Home /
Question by
zpinner · Sep 15, 2013 at 01:06 PM ·
angletrigonometry
Finding z-axis angle using Mathf.atan2
Hello,
I'm trying to calculate the angle between two vectors and apply to the z rotation of an object. I'm using atan2 for that.
But something seems to be wrong, why should an angle between vector.up and vector.right be 45 degrees (and not 90)? Take a look at this:
Vector3 upVec = Vector3.up;
Vector3 rightVec = Vector3.right;
float deltaY = rightVec.y - upVec.y;
float deltaX = rightVec.x - upVec.x;
float angle = Mathf.Atan2(deltaY, deltaX) * Mathf.Rad2Deg;
Debug.Log("angle " + angle);
Comment