From: Mikko Rasa Date: Sat, 22 Nov 2014 09:35:31 +0000 (+0200) Subject: Always explicitly construct values of type T X-Git-Url: http://git.tdb.fi/?p=libs%2Fmath.git;a=commitdiff_plain;h=fb9e6b5ff48e10ea2217cf539e0461956abf02cf Always explicitly construct values of type T --- diff --git a/source/geometry/extrudedshape.h b/source/geometry/extrudedshape.h index 400c52b..bacea7c 100644 --- a/source/geometry/extrudedshape.h +++ b/source/geometry/extrudedshape.h @@ -41,7 +41,7 @@ template inline ExtrudedShape::ExtrudedShape(const Shape &b, T l): length(l) { - if(l<=0) + if(l<=T(0)) throw std::invalid_argument("ExtrudedShape::ExtrudedShape"); base = b.clone(); diff --git a/source/geometry/halfspace.h b/source/geometry/halfspace.h index 5fdea34..f671629 100644 --- a/source/geometry/halfspace.h +++ b/source/geometry/halfspace.h @@ -33,7 +33,7 @@ public: template inline HalfSpace::HalfSpace() { - normal[0] = 1; + normal[0] = T(1); } template @@ -57,7 +57,7 @@ inline BoundingBox HalfSpace::get_axis_aligned_bounding_box() const template inline bool HalfSpace::contains(const LinAl::Vector &point) const { - return inner_product(point, normal)<=0; + return inner_product(point, normal)<=T(0); } template diff --git a/source/geometry/hypersphere.h b/source/geometry/hypersphere.h index e2e3102..4df03fe 100644 --- a/source/geometry/hypersphere.h +++ b/source/geometry/hypersphere.h @@ -70,7 +70,7 @@ inline unsigned HyperSphere::get_intersections(const Ray &ray, Surfa T mid = -inner_product(ray.get_direction(), ray.get_start()); LinAl::Vector nearest = ray.get_start()+ray.get_direction()*mid; T offset_sq = radius*radius-inner_product(nearest, nearest); - if(offset_sq<0) + if(offset_sq inline Ray::Ray(): limit(0) { - direction[0] = 1; + direction[0] = T(1); } template @@ -46,14 +46,14 @@ inline Ray::Ray(const LinAl::Vector &s, const LinAl::Vector &d direction(normalize(d)), limit(l) { - if(l<0) + if(l inline bool Ray::check_limits(T x) const { - return x>=0 && (!limit || x<=limit); + return x>=T(0) && (!limit || x<=limit); } } // namespace Geometry