37 void AngularEulerIntegrator::
39 AngularForceVector& forces,
47 PhysicsObject::Vector::const_iterator current_object_iter;
48 current_object_iter = physical->get_object_vector().begin();
49 for (; current_object_iter != physical->get_object_vector().end();
50 ++current_object_iter) {
54 if (current_object ==
nullptr) {
62 LRotation accum_quat(0, 0, 0, 0);
65 AngularForceVector::const_iterator f_cur;
70 f_cur = forces.begin();
72 for (; f_cur != forces.end(); ++f_cur) {
76 if (cur_force->get_active() ==
false) {
81 f = cur_force->
get_quat(current_object);
87 f_cur = physical->get_angular_forces().begin();
88 for (; f_cur != physical->get_angular_forces().end(); ++f_cur) {
92 if (cur_force->get_active() ==
false) {
96 f = cur_force->
get_quat(current_object);
100 accum_quat += orientation.xform(f);
111 rot_quat += accum_quat * dt;
113 if (rot_quat.normalize()) {
115 LOrientation new_orientation = old_orientation * rot_quat;
116 new_orientation.normalize();
119 current_object->set_orientation(new_orientation);
127 orientation = orientation * ((rot_quat * dt) * (accum_quat * (0.5 * dt * dt)));
129 rot_quat = rot_quat + (accum_quat * dt);
132 if (orientation.normalize() && rot_quat.normalize()) {
134 current_object->set_orientation(orientation);
147 out<<
"AngularEulerIntegrator (id "<<
this<<
")";
157 out.width(
indent); out<<
""; out<<
"AngularEulerIntegrator:\n";
LOrientation get_orientation() const
get current orientation.
virtual void write(std::ostream &out, int indent=0) const
Write a string representation of this instance to <out>.
bool get_active() const
Process Flag Query.
A body on which physics will be applied.
virtual void write(std::ostream &out, int indent=0) const
Write a string representation of this instance to <out>.
AngularEulerIntegrator()
constructor
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
LRotation get_rotation() const
get rotation per second.
std::ostream & indent(std::ostream &out, int indent_level)
A handy function for doing text formatting.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
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
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
LRotation get_quat(const PhysicsObject *po)
access query
pure virtual parent of all quat-based forces.
virtual void output(std::ostream &out) const
Write a string representation of this instance to <out>.
void set_rotation(const LRotation &rotation)
set rotation as a quaternion delta per second.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.