TEFUNC void computeCorrectValuesForOne() { simulationTime += interval; double scalar = exp(lambda * simulationTime); correctPosition = scalar * positionInit; Vec3 axis; float angle; orientationInit.getAxisAngle(axis, angle); correctOrientation = Quaternion(scalar * angle, axis); correctAngularVelocity = scalar * angularVelocityInit; referenceBody->setPosition(correctPosition); referenceBody->setVelocity(correctVelocity); referenceBody->setOrientation(correctOrientation); referenceBody->setAngularVelocity(correctAngularVelocity); referenceBody->getOrientation().getAxisAngle(axis, angle); correctRotationAxis = axis; correctRotationAngle = angle; cout << "Correct Values:" << endl << " Position: " << correctPosition << endl << " Velocity: " << correctVelocity << endl << " Orientation: " << correctOrientation << endl << " AngularVelocity: " << correctAngularVelocity << endl << " RotationAngle: " << correctRotationAngle << endl << " RotationAxis: " << correctRotationAxis << endl << endl; }
TEFUNC void computeCorrectValuesForThree() { simulationTime += interval; double scalar = exp(lambda * simulationTime); Vec3 correctRotation(orientationInit.getEulerRotation() + lambda * simulationTime * scalar * angularVelocityInit); correctPosition = positionInit + lambda * simulationTime * scalar * velocityInit; correctOrientation = Quaternion(correctRotation[0], correctRotation[1], correctRotation[2]); Vec3 axis; float angle; referenceBody->getOrientation().getAxisAngle(axis, angle); correctRotationAxis = axis; correctRotationAngle = angle; referenceBody->setPosition(correctPosition); referenceBody->setVelocity(correctVelocity); referenceBody->setOrientation(correctOrientation); referenceBody->setAngularVelocity(correctAngularVelocity); cout << "Correct Values:" << endl << " Position: " << correctPosition << endl << " Orientation: " << correctOrientation << endl << " RotationAngle: " << correctRotationAngle << endl << " RotationAxis: " << correctRotationAxis << endl << endl; }
//! Do update for the RB by useing the second test case TEFUNC void updateRigidBodyForTwo(RigidBodyPtr body) { body->setVelocity(lambda * body->getPosition()); body->setAngularVelocity(lambda * body->getOrientation().getEulerRotation()); body->setAngularAcceleration(Vec3(0,0,0)); }
//! Do update for the RB by useing the first test case TEFUNC void updateRigidBodyForOne(RigidBodyPtr body) { body->setVelocity(lambda * body->getPosition()); body->setAcceleration(lambda * body->getVelocity()); Vec3 axis; float angle; body->getOrientation().getAxisAngle(axis, angle); Quaternion tmp(lambda * angle, axis); body->setAngularVelocity(tmp.getEulerRotation()); body->setAngularAcceleration(lambda * body->getAngularVelocity()); }
/** * \brief Start-Funktion der Testumgebung * * Diese Funktion wird einmal beim Starten der Testumgebung * aufgerufen. */ TEFUNC void initialize(int /*argc*/, char** /*argv*/) { // --------- Ein wenig Testkram, ist unbedeutetnd ------------- orientationInit.normalize(); Quaternion test(0,M_PI/2,M_PI/2); cout << test << endl << M_PI/2 << endl << test.getEulerRotation() << endl; // exit (0); //----------------- uhr initialisieren -------------------- timer.init(); // --- Anlegen der Zeiger und Objekte mit denen gearbeitet werden soll ---- RigidBodyPtr body; GeometryPtr boxGeo; // Erste id ist null. Wird dann hochgezählt. Id id(Id::typeBox,0); // -------------- Einfache Rotation ----------- //Euler id.setNumber(0); body = rigidBodySystemEuler.create(id); body->setPosition(positionInit); body->setMass(massInit); body->setOrientation(orientationInit); body->setVelocity(velocityInit); body->setAngularVelocity(angularVelocityInit); boxGeo = geometrySystem.createBox(body, boxScaleInit); boxGeo->setBounciness(0.6); boxGeo->setColor(Graphics::red); //Runge-Kutta id.setNumber(1); body = rigidBodySystemRunge.create(id); body->setPosition(Vec3(-300.0, 0.0, 0.0)); body->setPosition(positionInit); body->setMass(massInit); body->setOrientation(orientationInit); body->setVelocity(velocityInit); body->setAngularVelocity(angularVelocityInit); boxGeo = geometrySystem.createBox(body, boxScaleInit); boxGeo->setBounciness(0.6); boxGeo->setColor(Graphics::blue); // Verlet-Baltman id.setNumber(2); body = rigidBodySystemVerlet.create(id); body->setPosition(positionInit); body->setMass(massInit); body->setOrientation(orientationInit); body->setVelocity(velocityInit); body->setAngularVelocity(angularVelocityInit); boxGeo = geometrySystem.createBox(body, boxScaleInit); boxGeo->setBounciness(0.6); boxGeo->setColor(Graphics::green); referenceBody->setPosition(positionInit); referenceBody->setMass(massInit); referenceBody->setOrientation(orientationInit); referenceBody->setVelocity(velocityInit); referenceBody->setAngularVelocity(angularVelocityInit); boxGeo = geometrySystem.createBox(referenceBody, boxScaleInit); boxGeo->setBounciness(0.6); boxGeo->setColor(Graphics::yellow); // ------------- Keine Visosity ------------- rigidBodySystemEuler.disableViscosity(); rigidBodySystemRunge.disableViscosity(); rigidBodySystemVerlet.disableViscosity(); }