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)