8 #ifndef IMPCORE_RIGID_BODIES_H
9 #define IMPCORE_RIGID_BODIES_H
11 #include <IMP/core/core_config.h>
12 #include "internal/rigid_bodies.h"
25 IMPCORE_BEGIN_NAMESPACE
27 IMP_DECORATORS_DECL(RigidMember, RigidMembers);
82 void add_member_internal(
Particle *p,
85 static void teardown_constraints(
Particle *p);
90 RigidMembers get_members()
const;
97 if (
get_model()->get_has_attribute(internal::rigid_body_data().members_,
98 get_particle_index())) {
100 get_particle_index());
109 ->get_has_attribute(internal::rigid_body_data().body_members_,
110 get_particle_index())) {
113 get_particle_index());
131 const ParticlesTemp &ps);
136 const algebra::ReferenceFrame3D &rf);
139 static void teardown_particle(RigidBody rb);
145 return internal::get_has_required_attributes_for_body(p->get_model(),
151 return internal::get_has_required_attributes_for_body(m, pi);
163 v(
get_particle()->get_value(internal::rigid_body_data().quaternion_[0]),
164 get_particle()->get_value(internal::rigid_body_data().quaternion_[1]),
165 get_particle()->get_value(internal::rigid_body_data().quaternion_[2]),
166 get_particle()->get_value(internal::rigid_body_data().quaternion_[3]));
168 "Rotation is not a unit vector: " << v);
223 for (
unsigned int i=0; i< 3; ++i) {
226 ->get_derivative(internal::rigid_body_data().torque_[i]);
237 void normalize_rotation();
240 void update_members();
246 unsigned int get_number_of_members()
const {
247 return get_body_member_particle_indexes().size()
248 + get_member_particle_indexes().size();
251 RigidMember get_member(
unsigned int i)
const;
291 return get_model()->get_internal_coordinates(get_particle_index());
296 get_model()->get_internal_coordinates(get_particle_index())=v;
302 get_particle()->has_attribute(internal::rigid_body_data().lquaternion_[0]),
303 "Can only set the internal transformation if member is"
304 <<
" a rigid body itself.");
305 set_internal_coordinates(v.get_translation());
307 get_particle()->set_value(internal::rigid_body_data().lquaternion_[0],
309 get_particle()->set_value(internal::rigid_body_data().lquaternion_[1],
311 get_particle()->set_value(internal::rigid_body_data().lquaternion_[2],
313 get_particle()->set_value(internal::rigid_body_data().lquaternion_[3],
320 get_particle()->has_attribute(internal::rigid_body_data().lquaternion_[0]),
321 "Can only set the internal transformation if member is a "
322 <<
"rigid body itself.");
324 =
get_model()->get_internal_coordinates(get_particle_index());
326 rot(
get_particle()->get_value(internal::rigid_body_data()
352 return particle_is_instance(p->get_model(), p->get_index());
356 return internal::get_has_required_attributes_for_member(m, p);
359 static FloatKeys get_internal_coordinate_keys() {
360 return internal::rigid_body_data().child_keys_;
383 return get_model()->get_internal_coordinates(get_particle_index());
388 get_model()->get_internal_coordinates(get_particle_index())=v;
395 get_particle()->has_attribute(internal::rigid_body_data().lquaternion_[0]),
396 "Can only set the internal transformation if member is"
397 <<
" a rigid body itself.");
398 set_internal_coordinates(v.get_translation());
400 get_particle()->set_value(internal::rigid_body_data().lquaternion_[0],
402 get_particle()->set_value(internal::rigid_body_data().lquaternion_[1],
404 get_particle()->set_value(internal::rigid_body_data().lquaternion_[2],
406 get_particle()->set_value(internal::rigid_body_data().lquaternion_[3],
413 get_particle()->has_attribute(internal::rigid_body_data().lquaternion_[0]),
414 "Can only set the internal transformation if member is a "
415 <<
"rigid body itself.");
417 =
get_model()->get_internal_coordinates(get_particle_index());
419 rot(
get_particle()->get_value(internal::rigid_body_data()
446 return particle_is_instance(p->get_model(), p->get_index());
450 return internal::get_has_required_attributes_for_non_member(m, p);
453 static FloatKeys get_internal_coordinate_keys() {
454 return internal::rigid_body_data().child_keys_;
460 class IMPCOREEXPORT RigidMembersRefiner:
public Refiner {
462 RigidMembersRefiner(std::string name=
"RigidMembersRefiner%d"):
Refiner(name){}
467 IMPCOREEXPORT RigidMembersRefiner* get_rigid_members_refiner();
498 bool no_members=
false);
501 IMP_DECORATORS_DEF(RigidMember,RigidMembers);
504 IMPCORE_END_NAMESPACE