diff options
author | Marius Kintel <marius@kintel.net> | 2011-12-24 21:04:31 (GMT) |
---|---|---|
committer | Marius Kintel <marius@kintel.net> | 2011-12-24 21:04:31 (GMT) |
commit | 51fada9a585fd6e32843d11e9bf11e85bb89a566 (patch) | |
tree | 34b4f6690012e9a1adc1aac6aa4e155c69a1882f /src | |
parent | 0ab51d2d23045021aed225dec8d3c3003316a124 (diff) | |
parent | 3572251a9139bf95f2217c2e9957668b6c82ccdc (diff) |
Merge branch 'master' into boost_filesystem
Diffstat (limited to 'src')
-rw-r--r-- | src/linalg.cc | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/linalg.cc b/src/linalg.cc new file mode 100644 index 0000000..30f23af --- /dev/null +++ b/src/linalg.cc @@ -0,0 +1,27 @@ +#include "linalg.h" + +// FIXME: We can achieve better pruning by either: +// o Recalculate the box based on the transformed object +// o Store boxes are oriented bounding boxes and implement oriented +// bbox intersection + +// FIXME: This function can be generalized, but we don't need it atm. + +/*! + Transforms the given bounding box by transforming each of its 8 vertices. + Returns a new bounding box. +*/ +BoundingBox operator*(const Transform3d &m, const BoundingBox &box) +{ + BoundingBox newbox; + Vector3d boxvec[2] = { box.min(), box.max() }; + for (int k=0;k<2;k++) { + for (int j=0;j<2;j++) { + for (int i=0;i<2;i++) { + newbox.extend(m * Vector3d(boxvec[i][0], boxvec[j][1], boxvec[k][2])); + } + } + } + return newbox; +} + |