Documentation


rotation2d_test.cpp

#include <animal/rotation2d.h>
#include <animal/vec2.h>



// --------------------------------------------
//  
//  
//  Test of the Rotation2d class.
//  
//  
//  Author: François Faure
//  
// --------------------------------------------
using std::cout;
using std::cin;
using std::endl;

typedef animal::Rotation2d<> Rot;
typedef animal::Vec2 Vec;

int main()
{
  cout << endl;
  cout << "---------------------------------------------" << endl;
  cout << " T E S T   O F   T H E   R O T A T I O N 2 D   C L A S S " << endl;
  cout << "---------------------------------------------" << endl;
  cout << "# Size of Rotation2d: " << sizeof(Rot) << " bytes" << endl;
  
  //  Constructors
  Rot A;
  cout << "Create  A un-initialized" << endl;
  cout << A << endl;
    cout << "Set A to identity(): " << (A = Rot::identity()) <<endl;
  
    cout << endl << ">>>> enter a rotation angle for matrix A > ";
    double angle;
    cin >> angle;
    A.setAngle( angle );
    cout << "Rotation A: " << A << endl;
    cout << "Inverse: " << A.inverse() << endl;
    cout << "Test constructor: A/Rotation(angle) should be equal to (" << Rot::identity() << ") : "<< A / Rot(angle) << endl;
    
    cout << endl << ">>>> enter a vector to project: ";
    Vec v;
    cin >> v;
    cout << endl << " v*A = " << v*A <<endl;
    cout << " v/A = " << v/A <<endl;
    
    cout << endl;
    Vec copy_v = v;
    cout << "(v *= A) = " << (v *= A) << endl;
    cout << "(v /= A) = " << (v /= A) << endl;
    cout << "Difference (correct value is 0 0): " << v - copy_v <<endl;

    Rot B;
    cout << endl;
    cout << ">>>> enter a rotation > ";
    cin >> B; cout << endl;
    cout << " A*B = " << A*B << endl;
    cout << " A/B = " << A/B << endl;
    cout << " A*B/B/A = (correct value is " << Rot::identity() << " ): " << A*B/B/A << endl;
    
    Rot copy_A = A;
    cout << endl;
    cout << " (A *= B) = " << (A *= B) <<endl;
    cout << " (A /= B) = " << (A /= B) <<endl;
    cout << " compare to previous value (correct result is " << Rot::identity() << " ): " << A/copy_A << endl;
  
  return 0;
}

Generated on Thu Dec 23 13:52:23 2004 by doxygen 1.3.6