1
/*************************************************************************
2
* Copyright (C) 2004 by Olivier Galizzi *
3
* olivier.galizzi@imag.fr *
5
* This program is free software; it is licensed under the terms of the *
6
* GNU General Public License v2 or later. See file LICENSE for details. *
7
*************************************************************************/
9
#include "Bo1_Box_Aabb.hpp"
10
#include<yade/pkg/common/Box.hpp>
11
#include<yade/pkg/common/Aabb.hpp>
14
void Bo1_Box_Aabb::go( const shared_ptr<Shape>& cm,
15
shared_ptr<Bound>& bv,
19
Box* box = static_cast<Box*>(cm.get());
20
if(!bv){ bv=shared_ptr<Bound>(new Aabb); }
21
Aabb* aabb=static_cast<Aabb*>(bv.get());
23
if(scene->isPeriodic && scene->cell->hasShear()) throw logic_error(__FILE__ "Boxes not (yet?) supported in sheared cell.");
25
Matrix3r r=se3.orientation.toRotationMatrix();
26
Vector3r halfSize(Vector3r::Zero());
27
for( int i=0; i<3; ++i )
28
for( int j=0; j<3; ++j )
29
halfSize[i] += fabs( r(i,j) * box->extents[j] );
31
aabb->min = se3.position-halfSize;
32
aabb->max = se3.position+halfSize;
35
YADE_PLUGIN((Bo1_Box_Aabb));