Hi, I am having trouble understanding how quaternions work. Is there a conversion from degrees to quaternions? I was just creating a flashlight for an FPS game where the flashlight’s pitch changes with the player. I went into the MouseLook script (imported with the default FPS controller) and found this code:
void Update ()
{
if (axes == RotationAxes.MouseXAndY)
{
float rotationX = transform.localEulerAngles.y + Input.GetAxis("Mouse X") * sensitivityX;
rotationY += Input.GetAxis("Mouse Y") * sensitivityY;
rotationY = Mathf.Clamp (rotationY, minimumY, maximumY);
transform.localEulerAngles = new Vector3(-rotationY, rotationX, 0);
}
else if (axes == RotationAxes.MouseX)
{
transform.Rotate(0, Input.GetAxis("Mouse X") * sensitivityX, 0);
}
else
{
rotationY += Input.GetAxis("Mouse Y") * sensitivityY;
rotationY = Mathf.Clamp (rotationY, minimumY, maximumY);
transform.localEulerAngles = new Vector3(-rotationY, transform.localEulerAngles.y, 0);
}
}
What confused me was “transform.localEulerAngles = new Vector3(-rotationY, transform.localEulerAngles.y, 0);” and “transform.Rotate(0, Input.GetAxis(“Mouse X”) * sensitivityX, 0);” because the parameters for Vector3 were (Y, X, Z) rather than (X, Y, Z). Is this because up/down pitch is based around the X axis whereas left/right yaw is based around the Y axis?

http://en.wikipedia.org/wiki/File:Rollpitchyawplain.png
Is this relationship between pitch, yaw and roll also the reason for the reference to “localEulerAngles?”
What are Euler angles? What are quaternions?
An explanation would be greatly appreciated. Thanks in advance.