From: Mikko Rasa Date: Fri, 21 Nov 2014 12:38:55 +0000 (+0200) Subject: Convert the geometry part to use the new vector slicing API X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=34273ebb7de0a2150061c4e2bfa764e11ce740f7;p=libs%2Fmath.git Convert the geometry part to use the new vector slicing API Everything being templates makes catching subtle compilation errors a bit hard. --- diff --git a/source/geometry/affinetransformation.h b/source/geometry/affinetransformation.h index 15bd926..f01ac3a 100644 --- a/source/geometry/affinetransformation.h +++ b/source/geometry/affinetransformation.h @@ -175,13 +175,13 @@ inline AffineTransformation invert(const AffineTransformation &at) template inline LinAl::Vector AffineTransformation::transform(const LinAl::Vector &v) const { - return LinAl::Vector(matrix*LinAl::Vector(v, T(1))); + return (matrix*compose(v, T(1))).template slice(0); } template inline LinAl::Vector AffineTransformation::transform_linear(const LinAl::Vector &v) const { - return LinAl::Vector(matrix*LinAl::Vector(v, T(0))); + return (matrix*compose(v, T(0))).template slice(0); } template diff --git a/source/geometry/extrudedshape.h b/source/geometry/extrudedshape.h index c00111a..400c52b 100644 --- a/source/geometry/extrudedshape.h +++ b/source/geometry/extrudedshape.h @@ -78,8 +78,8 @@ inline BoundingBox ExtrudedShape::get_axis_aligned_bounding_box() co { BoundingBox base_bbox = base->get_axis_aligned_bounding_box(); T half_length = length/T(2); - return BoundingBox(LinAl::Vector(base_bbox.get_minimum_point(), -half_length), - LinAl::Vector(base_bbox.get_maximum_point(), half_length)); + return BoundingBox(compose(base_bbox.get_minimum_point(), -half_length), + compose(base_bbox.get_maximum_point(), half_length)); } template @@ -90,7 +90,7 @@ inline bool ExtrudedShape::contains(const LinAl::Vector &point) cons if(abs(point[D-1])>length/T(2)) return false; - return base->contains(LinAl::Vector(point)); + return base->contains(point.template slice(0)); } template @@ -108,7 +108,7 @@ inline unsigned ExtrudedShape::get_intersections(const Ray &ray, Sur T half_length = length/T(2); const LinAl::Vector &ray_start = ray.get_start(); const LinAl::Vector &ray_direction = ray.get_direction(); - LinAl::Vector base_dir(ray_direction); + LinAl::Vector base_dir = ray_direction.template slice(0); /* If the ray does not degenerate to a point in the base space, it could intersect the base shape. */ @@ -129,7 +129,7 @@ inline unsigned ExtrudedShape::get_intersections(const Ray &ray, Sur if(limit>=offset) { T distortion = base_dir.norm(); - Ray base_ray(LinAl::Vector(ray_start+ray_direction*offset), + Ray base_ray((ray_start+ray_direction*offset).template slice(0), base_dir, (limit-offset)*distortion); SurfacePoint *base_points = 0; @@ -145,7 +145,7 @@ inline unsigned ExtrudedShape::get_intersections(const Ray &ray, Sur { T x = offset+base_points[i].distance/distortion; points[n].position = ray_start+ray_direction*x; - points[n].normal = LinAl::Vector(base_points[i].normal, T(0)); + points[n].normal = compose(base_points[i].normal, T(0)); points[n].distance = x; } @@ -165,7 +165,7 @@ inline unsigned ExtrudedShape::get_intersections(const Ray &ray, Sur continue; LinAl::Vector p = ray_start+ray_direction*x; - if(base->contains(LinAl::Vector(p))) + if(base->contains(p.template slice(0))) { if(points) {