~ubuntu-branches/debian/jessie/yade/jessie

« back to all changes in this revision

Viewing changes to pkg/common/Bo1_Box_Aabb.cpp

  • Committer: Package Import Robot
  • Author(s): Anton Gladky
  • Date: 2014-08-04 19:34:58 UTC
  • mfrom: (1.1.11)
  • Revision ID: package-import@ubuntu.com-20140804193458-cw8qhnujxe9wzi15
Tags: 1.11.0-1
* [a0600ae] Imported Upstream version 1.11.0
* [a3055e0] Do not use parallel build on kfreebsd-amd64 and s390x.
* [f86b405] Remove applied patches.

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));