ray: add convenience point-point constructor

This commit is contained in:
Danny Robson 2015-04-15 18:59:28 +10:00
parent b1263e8f14
commit 1be5be38ea
2 changed files with 17 additions and 0 deletions

13
ray.cpp
View File

@ -32,6 +32,19 @@ ray<S,T>::ray (util::point<S,T> _origin,
}
//-----------------------------------------------------------------------------
template <size_t S, typename T>
ray<S,T>
ray<S,T>::make (util::point<S,T> origin,
util::point<S,T> target)
{
return {
origin,
(target - origin).normalised ()
};
}
///////////////////////////////////////////////////////////////////////////////
/// returns the distance along the ray in a ray-plane intersection
///

View File

@ -32,6 +32,10 @@ namespace util {
ray (point<S,T> origin,
vector<S,T> direction);
static
ray<S,T> make (point<S,T> origin,
point<S,T> target);
// intersection tests
T intersect (plane<S,T>) const;
T intersect (AABB<S,T>) const;