Documentation


boundingBox3D_test.cpp

#include <animal/boundingBox.h>
#include <animal/quaternion.h>

// --------------------------------------------
//  
//  
//  Test of the BoundingBox3D class.
//  
//  
//  Author: Francois Faure
//  
// --------------------------------------------

typedef animal::BoundingBox3D<> Bbox;
typedef animal::Vec3 Point;
typedef animal::Vec3 Translation;
typedef animal::Quaternion<> Rotation;

int main()
{
  using std::cout;
  using std::cin;
  using std::endl;
  cout << endl;
  cout << "---------------------------------------------" << endl;
  cout << " T E S T   O F   T H E   BoundingBox3D  C L A S S " << endl;
  cout << "---------------------------------------------" << endl;
  cout << "# Size of BoundingBox3D: " << sizeof(Bbox) << " bytes" << endl;
  
  //  Default constructors
  Bbox A;
  cout << endl << "# Create  A un-initialized: " << endl;
  cout << A << endl;
  
  Bbox B;
  cout << "# Create  B un-initialized: " << endl;
  cout << B << endl;
  
    if( animal::intersect( A, B ) ) cout<< " A and B do intersect " <<endl;
    else cout<< " A and B do not intersect " <<endl;


    // Other constructors
    Point pmin, pmax;
    cout << endl <<"# Test constructors using points.\n  enter pmin pmax > ";
    cin >> pmin >> pmax;
    cout << endl;

    
    Bbox C(pmin);
    cout<<"C(pmin) = "<< C <<endl;
    Bbox D(pmin, pmax);
    cout<<"D(pmin, pmax) = "<< D <<endl;
    cout<<"D.min() = "<< D.min() <<endl;
    cout<<"D.max() = "<< D.max() << endl;

    if( animal::intersect( C, D ) ) cout<< " C and D do intersect " <<endl;
    else cout<< " C and D do not intersect " <<endl;
    
    
    // Insertion
    Point p1, p2;
    cout << endl <<"# Test point insertion.\n  enter p1 p2 > ";
    cin >> p1 >> p2;
    cout << endl;
    
    Bbox E(p1); 
    E.insert( p2 );
    cout<<"E includes p1 and p2: "<< E <<endl;
    
    if( animal::intersect( E, D ) ) cout<< " E and D do intersect " <<endl;
    else cout<< " E and D do not intersect " <<endl;
    
    E.insert( D );
    cout<<"E now includes D: "<< E << endl;
    
    
    // Displacement
    Translation t;
    Rotation r;
    double m[3][3];
    cout << endl <<"# test displacement. " << endl;
    cout << " enter a translation: "; cin >> t; cout << endl;
    cout << " enter a rotation: "; cin >> r; cout << endl;
    animal::writeRotMatrix( r, m );
    cout<<"E translated and rotated: "<< E.move( t, m ) << endl;
    
    return 0;
    
    
}

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