diff --git a/ray.cpp b/ray.cpp index 23218c35..7b269735 100644 --- a/ray.cpp +++ b/ray.cpp @@ -32,6 +32,19 @@ ray::ray (util::point _origin, } +//----------------------------------------------------------------------------- +template +ray +ray::make (util::point origin, + util::point target) +{ + return { + origin, + (target - origin).normalised () + }; +} + + /////////////////////////////////////////////////////////////////////////////// /// returns the distance along the ray in a ray-plane intersection /// diff --git a/ray.hpp b/ray.hpp index ac95cabf..caca6810 100644 --- a/ray.hpp +++ b/ray.hpp @@ -32,6 +32,10 @@ namespace util { ray (point origin, vector direction); + static + ray make (point origin, + point target); + // intersection tests T intersect (plane) const; T intersect (AABB) const;