IMP  2.1.0
The Integrative Modeling Platform
rigid_body_geometries.h
Go to the documentation of this file.
1 /**
2  * \file IMP/core/rigid_body_geometries.h
3  * \brief functionality for defining rigid bodies
4  *
5  * Copyright 2007-2013 IMP Inventors. All rights reserved.
6  */
7 
8 #ifndef IMPCORE_RIGID_BODY_GEOMETRIES_H
9 #define IMPCORE_RIGID_BODY_GEOMETRIES_H
10 
11 #include <IMP/core/core_config.h>
12 #include "rigid_bodies.h"
13 #include "internal/rigid_body_tree.h"
15 
16 IMPCORE_BEGIN_NAMESPACE
17 
18 /** Show the collision detection hierarchy for a rigid body.*/
19 class IMPCOREEXPORT RigidBodyHierarchyGeometry
22  unsigned int node_, layer_;
23  RigidBodyHierarchyGeometry(internal::RigidBodyHierarchy *h, unsigned int node,
24  unsigned int layer);
25 
26  public:
28  const kernel::ParticlesTemp &constituents);
31 };
32 
33 IMP_PARTICLE_GEOMETRY(RigidBodyDerivative, core::RigidBody, {
34  kernel::Particles ms = get_as<kernel::Particles>(d.get_members());
36  d.get_reference_frame().get_transformation_to();
37  algebra::VectorD<4> rderiv = d.get_rotational_derivatives();
38  algebra::Vector3D tderiv = d.get_derivatives();
39  algebra::VectorD<4> rot = otr.get_rotation().get_quaternion();
40  IMP_LOG_TERSE("Old rotation was " << rot << std::endl);
41  Float scale = .1;
42  algebra::VectorD<4> dv = rderiv;
43  if (dv.get_squared_magnitude() > 0.00001) {
44  dv = scale * dv.get_unit_vector();
45  }
46  rot += dv;
47  rot = rot.get_unit_vector();
48  algebra::Rotation3D r(rot[0], rot[1], rot[2], rot[3]);
49  IMP_LOG_TERSE("Derivative was " << tderiv << std::endl);
50  IMP_LOG_TERSE("New rotation is " << rot << std::endl);
51  FloatRange xr =
52  d.get_particle()->get_model()->get_range(core::XYZ::get_xyz_keys()[0]);
53  Float wid = xr.second - xr.first;
54  algebra::Vector3D stderiv = scale * tderiv * wid;
56  algebra::Rotation3D(rot[0], rot[1], rot[2], rot[3]),
57  stderiv + otr.get_translation());
58  for (unsigned int i = 0; i < ms.size(); ++i) {
59  core::RigidMember dm(ms[i]);
61  algebra::Segment3D(dm.get_coordinates(), dm.get_coordinates() + tderiv),
62  /*xyzcolor_*/
63  display::Color(1, 0, 0));
64  ret.push_back(tr);
66  r.get_rotated(dm.get_internal_coordinates()) + d.get_coordinates();
68  algebra::Segment3D(dm.get_coordinates(), ic), display::Color(0, 1, 0));
69  ret.push_back(rtr);
71  algebra::Segment3D(dm.get_coordinates(),
72  ntr.get_transformed(dm.get_internal_coordinates())),
73  display::Color(0, 0, 1));
74  ret.push_back(nrtr);
75  }
76 });
77 
78 IMP_PARTICLE_GEOMETRY(RigidBodyFrame, core::RigidBody, {
79  ret.push_back(new display::ReferenceFrameGeometry(d.get_reference_frame()));
80 });
81 
82 /** Display the torque on a rigid body as a line segment.*/
83 class IMPCOREEXPORT RigidBodyTorque : public display::SegmentGeometry {
85  mutable algebra::Segment3D cache_;
86  static algebra::Segment3D extract_geometry(kernel::Particle *p);
87 
88  public:
90  const algebra::Segment3D &get_geometry() const;
91 };
92 
93 IMPCORE_END_NAMESPACE
94 
95 #endif /* IMPCORE_RIGID_BODY_GEOMETRIES_H */
A base class for geometry contained in particles.
Simple 3D transformation class.
Represent an RGB color.
Definition: Color.h:24
A decorator for a particle that is part of a rigid body.
Definition: rigid_bodies.h:349
std::pair< Float, Float > FloatRange
A pair representing the allowed range for a Float attribute.
Definition: base/types.h:31
#define IMP_LOG_TERSE(expr)
functionality for defining rigid bodies
Represent an XYZR particle with a sphere.
#define IMP_OBJECT_METHODS(Name)
Define the basic things needed by any Object.
Class to handle individual model particles.
3D rotation class.
Definition: Rotation3D.h:45
virtual Geometries get_components() const
Return a set of geometry composing this one.
double Float
Basic floating-point value (could be float, double...)
Definition: base/types.h:20
VectorD get_unit_vector() const
Definition: VectorD.h:204
A decorator for a rigid body.
Definition: rigid_bodies.h:75