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"
24 IMPCORE_BEGIN_NAMESPACE
26 IMP_DECORATORS_DECL(RigidMember, RigidMembers);
103 void setup_score_states();
117 IMPCORE_DEPRECATED_FUNCTION_DECL(2.2)
119 IMPCORE_DEPRECATED_FUNCTION_DEF(2.2,
"Use get_rigid_members() instead.");
120 return get_rigid_members();
129 if (
get_model()->get_has_attribute(internal::rigid_body_data().members_,
154 return get_member_particle_indexes() + get_body_member_particle_indexes();
177 static void teardown_particle(
RigidBody rb);
179 IMP_CXX11_DEFAULT_COPY_CONSTRUCTOR(
RigidBody);
184 return internal::get_has_required_attributes_for_body(m, pi);
194 get_model()->get_attribute(internal::rigid_body_data().quaternion_[0],
196 get_model()->get_attribute(internal::rigid_body_data().quaternion_[1],
198 get_model()->get_attribute(internal::rigid_body_data().quaternion_[2],
200 get_model()->get_attribute(internal::rigid_body_data().quaternion_[3],
203 "Rotation is not a unit vector: " << v);
209 bool assume_normalized =
true;
263 for (
unsigned int i = 0; i < 3; ++i) {
279 void normalize_rotation();
283 void update_members();
289 unsigned int get_number_of_members()
const {
290 return get_body_member_particle_indexes().size() +
291 get_member_particle_indexes().size();
294 RigidMember get_member(
unsigned int i)
const;
328 const algebra::Rotation3D &rot,
332 algebra::VectorD<4> q(0, 0, 0, 0);
333 for (
unsigned int j = 0; j < 4; ++j) {
335 q[j] = deriv_global * v;
337 XYZ::add_to_derivatives(deriv_global, da);
338 for (
unsigned int j = 0; j < 4; ++j) {
339 get_model()->add_to_derivative(internal::rigid_body_data().quaternion_[j],
340 get_particle_index(), q[j], da);
343 for (
unsigned int i = 0; i < 3; ++i) {
344 get_model()->add_to_derivative(internal::rigid_body_data().torque_[i],
345 get_particle_index(), torque[i], da);
353 algebra::Rotation3D rot =
354 get_reference_frame().get_transformation_to().get_rotation();
356 add_to_derivatives(deriv_local, deriv_global, local, rot, da);
396 "Can only set the internal transformation if member is"
397 <<
" a rigid body itself.");
424 "Can only set the internal transformation if member is a "
425 <<
"rigid body itself.");
429 get_model()->get_attribute(internal::rigid_body_data().lquaternion_[0],
431 get_model()->get_attribute(internal::rigid_body_data().lquaternion_[1],
433 get_model()->get_attribute(internal::rigid_body_data().lquaternion_[2],
435 get_model()->get_attribute(internal::rigid_body_data().lquaternion_[3],
454 IMP_CXX11_DEFAULT_COPY_CONSTRUCTOR(RigidBodyMember);
458 return internal::get_has_required_attributes_for_member(m, p);
461 static FloatKeys get_internal_coordinate_keys() {
462 return internal::rigid_body_data().child_keys_;
486 return internal::get_has_required_attributes_for_rigid_member(m, p);
506 return internal::get_has_required_attributes_for_non_member(m, p);
512 class IMPCOREEXPORT RigidMembersRefiner :
public Refiner {
514 RigidMembersRefiner(std::string name =
"RigidMembersRefiner%d")
528 IMPCOREEXPORT RigidMembersRefiner *get_rigid_members_refiner();
554 return get_initial_reference_frame(ps[0]->get_model(),
571 IMP_DECORATORS_DEF(RigidMember, RigidMembers);
576 base::TextOutput out =
577 base::TextOutput(std::cout));
583 IMPCORE_END_NAMESPACE
void add_to_derivatives(const algebra::Vector3D &v, DerivativeAccumulator &d)
Add something to the derivative of the coordinates.
void set_internal_coordinates(const algebra::Vector3D &v) const
set the internal (local) coordinates for this member
Import IMP/kernel/SingletonModifier.h in the namespace.
ParticleIndex get_particle_index() const
Returns the particle index decorated by this decorator.
ParticleIndexes get_indexes(const ParticlesTemp &ps)
Class for adding derivatives from restraints to the model.
virtual const ParticlesTemp get_refined(Particle *a) const =0
Refine the passed particle into a set of particles.
A member of a rigid body, it has internal (local) coordinates.
IMP::base::Vector< IMP::base::WeakPointer< kernel::ModelObject > > ModelObjectsTemp
Import IMP/kernel/SingletonContainer.h in the namespace.
IMP::kernel::DerivativeAccumulator DerivativeAccumulator
#define IMP_USAGE_CHECK_FLOAT_EQUAL(expra, exprb, message)
algebra::Vector3D get_coordinates() const
Get the coordinates of the particle.
static bool get_is_setup(kernel::Model *m, kernel::ParticleIndex pi)
Return true if the particle is a rigid body.
#define IMP_OBJECT_METHODS(Name)
Define the basic things needed by any Object.
const kernel::ParticleIndexes & get_member_particle_indexes() const
#define IMP_DECORATOR_METHODS(Name, Parent)
Model * get_model() const
Returns the Model containing the particle.
bool get_coordinates_are_optimized() const
Get whether the coordinates are optimized.
void add_rigid_body_cache_key(ObjectKey k)
Type get_attribute(TypeKey attribute_key, ParticleIndex particle)
const Vector4D & get_quaternion() const
Return the quaternion so that it can be stored.
virtual bool get_can_refine(Particle *) const
Return true if this refiner can refine that particle.
algebra::Vector3D get_torque() const
Vector3D get_vector_product(const Vector3D &p1, const Vector3D &p2)
Returns the vector product (cross product) of two vectors.
void set_reference_frame(const IMP::algebra::ReferenceFrame3D &tr)
Set the current reference frame.
A Cartesian vector in D-dimensions.
Import IMP/kernel/Refiner.h in the namespace.
void set_coordinates(const algebra::Vector3D &v)
set all coordinates from a vector
kernel::ParticleIndexes get_member_indexes() const
Represent an XYZR particle with a sphere.
A decorator for a particle with x,y,z coordinates.
void set_attribute(TypeKey attribute_key, ParticleIndex particle, Type value)
static bool get_is_setup(kernel::Model *m, kernel::ParticleIndexAdaptor p)
return true if it is a rigid member
const algebra::Vector3D & get_coordinates() const
Convert it to a vector.
Class to handle individual model particles.
A decorator for a particle that is part of a rigid body but not rigid.
Simple 3D rotation class.
void set_internal_transformation(const algebra::Transformation3D &v)
void set_coordinates_are_optimized(bool tf) const
Set whether the coordinates are optimized.
static bool get_is_setup(kernel::Model *m, kernel::ParticleIndexAdaptor p)
return true if it is a rigid member
base::Index< ParticleIndexTag > ParticleIndex
Key< 4, true > ObjectKey
The type used to identify an Object attribute.
void set_coordinates(const algebra::Vector3D ¢er)
sets the global coordinates of this member using XYZ::set_coordinates()
IMP::kernel::Particle Particle
static bool get_is_setup(kernel::Model *m, kernel::ParticleIndex p)
return true if it is a rigid member
void show_rigid_body_hierarchy(RigidBody rb, base::TextOutput out=base::TextOutput(std::cout))
kernel::ParticlesTemp create_rigid_bodies(kernel::Model *m, unsigned int n, bool no_members=false)
kernel::ParticleIndex get_root_rigid_body(RigidMember m)
Return the index of the outer-most rigid body containing the member.
#define IMP_USAGE_CHECK(expr, message)
A runtime test for incorrect usage of a class or method.
void transform(RigidBody a, const algebra::Transformation3D &tr)
Transform a rigid body.
Simple 3D rotation class.
void clear_particle_caches(ParticleIndex pi)
A decorator for a rigid body.
algebra::Transformation3D get_internal_transformation() const
Abstract class to implement hierarchical methods.
#define IMP_DECORATOR_SETUP_1(Name, FirstArgumentType, first_argument_name)
Decorator for a sphere-like particle.
const kernel::ParticleIndexes & get_body_member_particle_indexes() const
#define IMP_DECORATORS(Name, PluralName, Parent)
Define the types for storing sets of decorators.
#define IMP_OVERRIDE
Cause a compile error if this method does not override a parent method.
const algebra::Vector3D & get_internal_coordinates() const
Return the internal (local) coordinates of this member.
Class for storing model, its restraints, constraints, and particles.
IMP::algebra::ReferenceFrame3D get_reference_frame() const
Get the reference frame for the local coordinates.