Subversion Repositories gelsvn

Rev

Blame | Last modification | View Log | RSS feed

#include <iostream>

#include "CGLA/Vec2f.h"
#include "CGLA/Vec2i.h"
#include "CGLA/Vec3i.h"
#include "CGLA/Vec3f.h"
#include "CGLA/Vec3d.h"
#include "CGLA/Vec3Hf.h"

using namespace std;
using namespace CGLA;


/* This is a non-exhaustive test program for CGLA */
main()
{
        // Test that the right cross products get called;

        {
                Vec2f a2(1,0),b2(0,1),c2;
                Vec3f af(1,0,0),bf(0,1,0),cf;
                Vec3d ad(1,0,0),bd(0,1,0),cd;
                Vec3i ai(1,0,0),bi(0,1,0),ci;

                float x = cross(a2, b2);
                cross(a2-b2, a2-b2);
                cf = cross(af, bf);
                ci = cross(ai, bi);

                assert(x == 1.0f);
                assert(cf == Vec3f(0,0,1));
                assert(ci == Vec3i(0,0,1));
                cout << " x (should be 1) " << x << endl;
                cout << " cf (should be 0,0,1) " << cf << endl;
                cout << " ci (should be 0,0,1) " << ci << endl;
        }

        {
                Vec3f af(1,0,0);
                Vec3f df,ef;
                orthogonal(af, df, ef);
                assert(df == Vec3f(0,1,0));
                assert(ef == Vec3f(0,0,1));
                cout << " df ef (should be 010 and 001) " << df << ef << endl;

                Vec3d ad(1,0,0);
                Vec3d dd,ed;
                orthogonal(ad, dd, ed);
                assert(dd == Vec3d(0,1,0));
                assert(ed == Vec3d(0,0,1));
                cout << " dd ed (should be 010 and 001) " << dd << ed << endl;
        }
}