#ifndef MSP_GEOMETRY_HALFSPACE_H_
#define MSP_GEOMETRY_HALFSPACE_H_
-#include "boundingbox.h"
#include "shape.h"
namespace Msp {
template<typename T, unsigned D>
inline HalfSpace<T, D>::HalfSpace()
{
- normal[0] = 1;
+ normal[0] = T(1);
}
template<typename T, unsigned D>
template<typename T, unsigned D>
inline bool HalfSpace<T, D>::contains(const LinAl::Vector<T, D> &point) const
{
- return inner_product(point, normal)<=0;
+ return inner_product(point, normal)<=T(0);
}
template<typename T, unsigned D>
inline unsigned HalfSpace<T, D>::get_intersections(const Ray<T, D> &ray, SurfacePoint<T, D> *points, unsigned size) const
{
- T x = -inner_product(ray.get_start(), normal)/inner_product(ray.get_direction(), normal);
+ T d = inner_product(ray.get_start(), normal);
+ T c = inner_product(ray.get_direction(), normal);
+ if(c==T(0))
+ return 0;
+
+ T x = -d/c;
if(ray.check_limits(x))
{
if(points && size>0)