The rl_RayLib library includes a class encapsulating a basic ray consisting of position and direction information, ray energy, and a ray id number.
The ray is nominally defined in a standard coordinate system (STD) which serves as a default global coordinate system. The ray can be transformed into a local ``body-centered'' coordinate system (BCS) (e.g., attached to a piece of hardware such as a mirror).
In transforming from the STD system to the BCS system, the ray is first translated by the difference between the BCS origin and the STD origin, then transformed to the orientation of the BCS system relative to the STD system by rotation about the BCS origin.
To transform back to the STD system the operations are performed in reverse: first ``derotate'' the vector about the BCS origin to account for the different orientation, then ``detranslate'' the position by the difference between the BCS and STD origins.
Other operations on a basic ray include projection (moving the ray position by a given distance in the direction specified by the ray direction vector) and reflection of the ray direction vector about a surface normal provided by the user. In the reflection operation, it is assumed that the ray position is at the surface about which the reflection takes place.