geom/ray: add matrix multiply operator

This commit is contained in:
Danny Robson 2018-04-16 14:36:39 +10:00
parent 42ab7543a7
commit 05b1c2dd80
2 changed files with 16 additions and 0 deletions

View File

@ -44,6 +44,17 @@ ray<S,T>::at (T t) const
} }
///////////////////////////////////////////////////////////////////////////////
util::geom::ray3f
util::geom::operator* (util::matrix4f lhs, ray3f rhs)
{
return {
(lhs * rhs.origin.homog<4> ()).redim<3> (),
(lhs * rhs.direction.homog<4> ()).redim<3> ()
};
}
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
template <size_t S, typename T> template <size_t S, typename T>
std::ostream& std::ostream&

View File

@ -66,6 +66,11 @@ namespace util::geom {
typedef ray<3,float> ray3f; typedef ray<3,float> ray3f;
///////////////////////////////////////////////////////////////////////////
ray3f
operator* (matrix4f, ray3f);
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
/// returns the distance along the ray in a ray-plane intersection /// returns the distance along the ray in a ray-plane intersection
/// ///