Go to the documentation of this file.00001 #ifndef OPENTISSUE_DYNAMICS_PSYS_COLLISION_PSYS_PLANE_H
00002 #define OPENTISSUE_DYNAMICS_PSYS_COLLISION_PSYS_PLANE_H
00003
00004
00005
00006
00007
00008
00009
00010 #include <OpenTissue/configuration.h>
00011
00012 #include <cassert>
00013
00014 namespace OpenTissue
00015 {
00016 namespace psys
00017 {
00018
00022 template<typename particle_system_type, typename plane_type, typename contact_point_container>
00023 void collision_psys_plane(
00024 particle_system_type & system
00025 , plane_type const & plane
00026 , contact_point_container & contacts
00027 )
00028 {
00029 typedef typename particle_system_type::real_type real_type;
00030 typedef typename particle_system_type::vector3_type vector3_type;
00031 typedef typename contact_point_container::value_type contact_point_type;
00032 typedef typename particle_system_type::particle_iterator particle_iterator;
00033
00034 particle_iterator p = system.particle_begin();
00035 particle_iterator end = system.particle_end();
00036 for(;p!=end;++p)
00037 {
00038 vector3_type pos = p->position();
00039 real_type dst = plane.signed_distance(pos);
00040 if(dst>0)
00041 continue;
00042 contact_point_type cp;
00043 cp.m_A0 = &(*p);
00044 cp.m_a0 = real_type();
00045 cp.m_p = pos;
00046 cp.m_n = unit(plane.n());
00047 cp.m_distance = -dst;
00048 contacts.push_back(cp);
00049 }
00050 }
00051
00052 }
00053 }
00054
00055
00056 #endif