15 #include "angularEulerIntegrator.h" 16 #include "forceNode.h" 17 #include "physicalNode.h" 18 #include "config_physics.h" 45 void AngularEulerIntegrator::
56 PhysicsObject::Vector::const_iterator current_object_iter;
57 current_object_iter = physical->get_object_vector().begin();
58 for (; current_object_iter != physical->get_object_vector().end();
59 ++current_object_iter) {
75 AngularForceVector::const_iterator f_cur;
80 f_cur = forces.begin();
82 for (; f_cur != forces.end(); ++f_cur) {
86 if (cur_force->get_active() ==
false) {
91 f = cur_force->
get_quat(current_object);
97 f_cur = physical->get_angular_forces().begin();
98 for (; f_cur != physical->get_angular_forces().end(); ++f_cur) {
102 if (cur_force->get_active() ==
false) {
106 f = cur_force->
get_quat(current_object);
110 accum_quat += orientation.
xform(f);
121 rot_quat += accum_quat * dt;
123 if (rot_quat.normalize()) {
125 LOrientation new_orientation = old_orientation * rot_quat;
126 new_orientation.normalize();
129 current_object->set_orientation(new_orientation);
138 orientation = orientation * ((rot_quat * dt) * (accum_quat * (0.5 * dt * dt)));
140 rot_quat = rot_quat + (accum_quat * dt);
143 if (orientation.normalize() && rot_quat.normalize()) {
145 current_object->set_orientation(orientation);
161 out<<
"AngularEulerIntegrator (id "<<
this<<
")";
172 write(ostream &out,
unsigned int indent)
const {
174 out.width(indent); out<<
""; out<<
"AngularEulerIntegrator:\n";
LOrientation get_orientation() const
get current orientation.
This is a unit quaternion representing a rotation.
bool get_active() const
Process Flag Query.
virtual void output(ostream &out) const
Write a string representation of this instance to <out>.
A body on which physics will be applied.
This is a unit quaternion representing an orientation.
AngularEulerIntegrator()
constructor
virtual void write(ostream &out, unsigned int indent=0) const
Write a string representation of this instance to <out>.
LRotation get_rotation() const
get rotation per second.
LVecBase3f xform(const LVecBase3f &v) const
Transforms a 3-d vector by the indicated rotation.
Defines a set of physically modeled attributes.
virtual LMatrix4 get_inertial_tensor() const
returns a transform matrix that represents the object's willingness to be forced. ...
virtual ~AngularEulerIntegrator()
destructor
LRotation get_quat(const PhysicsObject *po)
access query
pure virtual parent of all quat-based forces.
void set_rotation(const LRotation &rotation)
set rotation as a quaternion delta per second.
virtual void write(ostream &out, unsigned int indent=0) const
Write a string representation of this instance to <out>.