Rotations and orientations in Unity are represented by unit quaternions.
That means a quaternion \$(w, x, y, z)\$ where:
$$w^2 + x^2 + y^2 + z^2 = 1$$
You can see this means each component is in the range from -1 to 1, and if any one component is near the edge of that range, the rest of the components will be closer to zero so the sum of their squares doesn't exceed 1.
If you can visualize 4 dimensions, unit quaternions are points on the surface of a 4-dimensional sphere. If your math ends up producing a quaternion outside this range, you can normalize it to snap it back onto the sphere. (Quaternion.Lerp()
does this to get a quick & dirty blend between quaternions that stays on the unit sphere, more cheaply than a true uniform Slerp
)
Usually the w component will be greater than 0. This corresponds to the shortest rotation from the initial orientation to the destination orientation. If you negate the whole quarternion so that w is negative (and the axis is reversed), you get the rotation that goes "the long way around" to get to the same output, say turning 270° to the left instead of 90° to the right. If the w component is exactly zero, that's a 180° rotation, so it's the same distance in either direction.
Most quaternion methods will give you a w greater than or equal to zero by default, but if you do a bunch of math to transform quaternions you can sometimes end up with a negative w. If you're using the quarternion as an orientation rather than a relative rotation to travel through, it won't make a difference since you still end up in the same place. But if you're lerping / slerping / rotateTowards-ing then keeping the w positive can ensure you get the shortest travel consistently.
As Almo says, you should almost never need to inspect or manipulate a quaternion's individual components directly. But if you find a need to do so, it can help to understand how they're calculated:
(x, y, z) = axis of rotation (unit vector) times the sine of half the angle of rotation
w = cosine of half the angle of rotation
So if a quaternion \$q\$ is representing a rotation about axis \$ \vec a \$ by an angle \$\Theta\$ then...
$$q_w = \cos \frac \Theta 2\\
q_x = a_x \cdot \sin \frac \Theta 2\\
q_y = a_y \cdot \sin \frac \Theta 2\\
q_z = a_z \cdot \sin \frac \Theta 2 $$
So an identity rotation (angle = 0) is just (w = 1, x = 0, y = 0, z = 0)
A rotation of 180 degrees around the y axis is (0, 0, 1, 0)
And a rotation halfway between these two extremes — 90 degrees around the y axis — is \$( \frac 1 {\sqrt 2}, 0, \frac 1 {\sqrt 2}, 0)\$
Something you'll notice here is that to invert a quaternion - to make a quaternion that represents the opposite rotation and "undoes" the original rotation - all you have to do is negate the rotation axis components x, y, z, while keeping w unchanged. That makes Quaternion.Inverse()
dirt cheap compared to inverting an arbitrary matrix - maybe even cheaper than transposing an orthonormal rotation matrix, since you have to touch just three variables, not six. So don't be afraid to invert quaternions on demand. ;)