00001 #ifndef OPENTISSUE_CORE_GEOMETRY_GEOMETRY_RAY_H 00002 #define OPENTISSUE_CORE_GEOMETRY_GEOMETRY_RAY_H 00003 // 00004 // OpenTissue Template Library 00005 // - A generic toolbox for physics-based modeling and simulation. 00006 // Copyright (C) 2008 Department of Computer Science, University of Copenhagen. 00007 // 00008 // OTTL is licensed under zlib: http://opensource.org/licenses/zlib-license.php 00009 // 00010 #include <OpenTissue/configuration.h> 00011 00012 namespace OpenTissue 00013 { 00014 00015 namespace geometry 00016 { 00017 00028 template< typename math_types_ > 00029 class Ray 00030 { 00031 public: 00032 00033 typedef math_types_ math_types; 00034 typedef typename math_types::real_type real_type; 00035 typedef typename math_types::vector3_type vector3_type; 00036 typedef typename math_types::value_traits value_traits; 00037 00038 protected: 00039 00040 vector3_type m_p; 00041 vector3_type m_r; 00042 00043 public: 00044 00045 Ray() 00046 : m_p(value_traits::zero(),value_traits::zero(),value_traits::zero()) 00047 , m_r(value_traits::one(),value_traits::zero(),value_traits::zero()) 00048 {} 00049 00050 public: 00051 00052 vector3_type & p() { return m_p; } 00053 vector3_type const & p() const { return m_p; } 00054 vector3_type & r() { return m_r; } 00055 vector3_type const & r() const { return m_r; } 00056 00057 public: 00058 00059 void compute_point(real_type const & t) 00060 { 00061 assert(t>=value_traits::zero() || !"Ray::compute_point(): t<0, point not on ray" ); 00062 return m_p + m_r*t; 00063 } 00064 00065 }; 00066 00067 } // namespace geometry 00068 00069 } // namespace OpenTissue 00070 00071 //OPENTISSUE_CORE_GEOMETRY_GEOMETRY_RAY_H 00072 #endif