How to create a ray with rotation instead of direction?

To create a ray, it needs origin position, direction position and length. How to create it with rotation value (or rotation quaternion) instead of direction value?

Here is one way

The direction depends on the initial position of the box you set for the zero rotation.