For example ray sphere intersection test is using for aiming to some objects in scene. Ray origin is camera position and ray direction is infinite position by camera direction vector. If ray intersect object bounding sphere that camera takes aim to the object.
1. Ray and sphere class:
class K3dRay{// Ray is R(t) = P+t*D for t >= 0. D is not necessarily unit length. K3dVector3 m_kOrigin; // P K3dVector3 m_kDirection; // Dpublic: K3dRay(K3dVector3 &_rkOrigin, K3dVector3 &_rkDirection) { m_kOrigin = _rkOrigin; m_kDirection = _rkDirection; } K3dRay() { m_kOrigin.Reset(); m_kDirection.Reset(); } ~K3dRay() {} K3dVector3& GetOrigin() {return m_kOrigin; }const K3dVector3& GetOrigin() const {return m_kOrigin; } K3dVector3& GetDirection() {return m_kDirection; }const K3dVector3& GetDirection() const {return m_kDirection; }};