X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;ds=sidebyside;f=source%2Fgeometry%2Ftransformedshape.h;h=58e571a9db389a058cdb8ab3de1343b4ee87cb3e;hb=09cc3a8648dd20e9a07d669b353c4a120b67c1c4;hp=02587bfd87877efac86f365d39e1a68e072a7020;hpb=f7dcf3f0be55316bf20ac0c318dd90cb78a75c80;p=libs%2Fmath.git diff --git a/source/geometry/transformedshape.h b/source/geometry/transformedshape.h index 02587bf..58e571a 100644 --- a/source/geometry/transformedshape.h +++ b/source/geometry/transformedshape.h @@ -2,6 +2,7 @@ #define MSP_GEOMETRY_TRANSFORMEDSHAPE_H_ #include "affinetransformation.h" +#include "boundingbox.h" #include "ray.h" #include "shape.h" @@ -30,7 +31,7 @@ public: const Shape &get_shape() const { return *shape; } const AffineTransformation &get_transformation() const { return transformation; } - virtual HyperBox get_axis_aligned_bounding_box() const; + virtual BoundingBox get_axis_aligned_bounding_box() const; virtual bool contains(const LinAl::Vector &) const; private: Ray make_local_ray(const Ray &) const; @@ -75,10 +76,28 @@ inline TransformedShape *TransformedShape::clone() const } template -inline HyperBox TransformedShape::get_axis_aligned_bounding_box() const +inline BoundingBox TransformedShape::get_axis_aligned_bounding_box() const { - // XXX This is not correct for most shapes - return shape->get_axis_aligned_bounding_box(); + BoundingBox inner_bbox = shape->get_axis_aligned_bounding_box(); + + LinAl::Vector min_pt; + LinAl::Vector max_pt; + for(unsigned i=0; i<(1< point; + for(unsigned j=0; j>j)&1 ? inner_bbox.get_maximum_coordinate(j) : inner_bbox.get_minimum_coordinate(j)); + + point = transformation.transform(point); + + for(unsigned j=0; j(min_pt, max_pt); } template