~yade-dev/yade/0.80

« back to all changes in this revision

Viewing changes to pkg/common/Bo1_Box_Aabb.cpp

  • Committer: Anton Gladky
  • Date: 2012-05-02 21:50:42 UTC
  • Revision ID: gladky.anton@gmail.com-20120502215042-v1fa9r65usqe7kfk
0.80.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*************************************************************************
 
2
*  Copyright (C) 2004 by Olivier Galizzi                                 *
 
3
*  olivier.galizzi@imag.fr                                               *
 
4
*                                                                        *
 
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
*************************************************************************/
 
8
 
 
9
#include "Bo1_Box_Aabb.hpp"
 
10
#include<yade/pkg/common/Box.hpp>
 
11
#include<yade/pkg/common/Aabb.hpp>
 
12
 
 
13
 
 
14
void Bo1_Box_Aabb::go(  const shared_ptr<Shape>& cm,
 
15
                                shared_ptr<Bound>& bv,
 
16
                                const Se3r& se3,
 
17
                                const Body*     b)
 
18
{
 
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());
 
22
 
 
23
        if(scene->isPeriodic && scene->cell->hasShear()) throw logic_error(__FILE__ "Boxes not (yet?) supported in sheared cell.");
 
24
        
 
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] );
 
30
        
 
31
        aabb->min = se3.position-halfSize;
 
32
        aabb->max = se3.position+halfSize;
 
33
}
 
34
        
 
35
YADE_PLUGIN((Bo1_Box_Aabb));