00001 #include <ivfmath/IvfVec3d.h>
00002 #include <ivfmath/IvfVec4d.h>
00003 #include <ivfmath/IvfMat3d.h>
00004 #include <ivfmath/IvfMat4d.h>
00005
00006 int main(int argc, char* argv[])
00007 {
00008 using namespace std;
00009
00010 CIvfVec3d a(1.0, 0.0, 0.0);
00011 CIvfVec3d b(0.0, 1.0, 0.0);
00012
00013 CIvfVec3d c;
00014 c = a + b;
00015
00016 CIvfVec3d d;
00017 d = a * b;
00018
00019 CIvfVec3d e;
00020 e = d;
00021
00022 cout << "Vectors c, d, e." << endl << endl;
00023
00024 c.print(cout);
00025 d.print(cout);
00026 e.print(cout);
00027
00028 CIvfVec3d axis(0.0, 1.0, 0.0);
00029 CIvfVec3d rotated(1.0, 0.0, 0.0);
00030
00031 rotated.rotate(axis, 45.0);
00032
00033 cout << endl << "Rotated matrix rotated." << endl << endl;
00034 rotated.print(cout);
00035
00036 CIvfMat3d A;
00037 A = 0.0;
00038
00039 cout << endl << "Matrix A." << endl << endl;
00040
00041 A.print(cout);
00042
00043 CIvfMat3d B;
00044
00045 B = A;
00046 B = 0.0;
00047
00048 CIvfMat3d C;
00049
00050 C = 0.0;
00051 C.setRow(1, 1.0, 1.0, 1.0);
00052
00053 cout << endl << "Matrix C." << endl << endl;
00054 C.print(cout);
00055
00056 CIvfMat3d D = C.t();
00057
00058 cout << endl << "Matrix D." << endl << endl;
00059 D.print(cout);
00060
00061 CIvfMat3d E;
00062
00063 E.setRow(1, 1.0, 3.0, 2.0);
00064 E.setRow(2, 5.0, 7.4, 1.5);
00065 E.setRow(3, -1.0, 2.5, 3.6);
00066
00067 cout << endl << "Matrix E." << endl << endl;
00068 E.print(cout);
00069
00070 CIvfMat3d F;
00071
00072 F.setRow(1, 3.0, 1.0, 7.0);
00073 F.setRow(2, 6.0, 2.4, 2.5);
00074 F.setRow(3, 2.0, 9.5, 1.6);
00075
00076 cout << endl << "Matrix F." << endl << endl;
00077 F.print(cout);
00078
00079 CIvfMat3d G = E*F;
00080
00081 cout << endl << "Matrix G=E*F." << endl << endl;
00082 G.print(cout);
00083
00084 CIvfVec3d f(1.0, 1.0, 1.0);
00085 CIvfVec3d g;
00086
00087 g = E*f;
00088
00089 cout << endl << "Vector g=E*f." << endl << endl;
00090 g.print(cout);
00091
00092 CIvfMat3d H = F*F.inv();
00093
00094 cout << endl << "Matrix g=F*F.inv()." << endl << endl;
00095 H.print(cout);
00096
00097 CIvfMat4d X;
00098 X.setRow(1, 3.0, 4.5, 6.7, 1.2);
00099 X.setRow(2, 2.0, 7.5, 1.7, 4.2);
00100 X.setRow(3, 3.0, 5.5, 8.7, 5.2);
00101 X.setRow(4, 5.0, 4.5, 4.7, 3.2);
00102
00103 CIvfMat4d Y;
00104
00105 Y = X*X.inv();
00106
00107 cout << endl << "Matrix Y=X*X.inv()." << endl << endl;
00108 Y.print(cout);
00109
00110 cout << endl << "Rotation matrices Rx, Ry, Rz." << endl << endl;
00111
00112 CIvfMat4d Rx;
00113 CIvfMat4d Ry;
00114 CIvfMat4d Rz;
00115
00116 Rx.rotateX(45.0*M_PI/360.0); Rx.print(cout); cout << endl;
00117 Ry.rotateY(45.0*M_PI/360.0); Ry.print(cout); cout << endl;
00118 Rz.rotateZ(45.0*M_PI/360.0); Rz.print(cout); cout << endl;
00119
00120 CIvfMat4d R;
00121
00122 cout << endl << "Rotation matrix R." << endl << endl;
00123
00124 R.rotate(1.0, 0.0, 0.0, 45.0*M_PI/360.0);
00125 R.print(cout);
00126
00127 CIvfMat4d T;
00128 CIvfVec4d p1;
00129 CIvfVec4d p2;
00130
00131 cout << endl << "Translation T." << endl << endl;
00132
00133 p1.setComponents(0.0, 0.0, 0.0, 1.0);
00134 p1.print(cout); cout << endl;
00135 T.translate(1.0, 1.0, 1.0);
00136 T.print(cout); cout << endl;
00137 p2 = T * p1;
00138 p2.print(cout);
00139
00140
00141
00142
00143
00144 return 0;
00145 }