46 std::cout << errors <<
" errors found." << std::endl;
48 std::cout <<
"All tests passed." << std::endl;
58 int coordsa[4] = { 1, 2, 3, 1 };
59 int coordsb[4] = { 4, 3, 2, 1 };
67 coords2.
set( coordsb );
70 for(
int i = 0; i < 4; i++ )
72 if( coords2.
hom_coord()[i] != coordsb[i] )
74 std::cout <<
"Get test failed." << std::endl;
80 if( coords2.
i() != coordsb[0] || coords2.
j() != coordsb[1] || coords2.
k() != coordsb[2] ||
81 coords2.
h() != coordsb[3] )
83 std::cout <<
"ijkh test failed." << std::endl;
88 coords2.
set( 3, 3, 3 );
94 std::cout <<
"Set (int) test failed." << std::endl;
111 bool optest = ( coords2 >= coords4 && coords2 >= coords3 && coords3 >= coords2 );
114 std::cout <<
"Test failed for operator >=." << std::endl;
118 optest = ( coords4 <= coords2 && coords2 <= coords3 && coords3 <= coords2 );
121 std::cout <<
"Test failed for operator <=." << std::endl;
126 optest = ( coords2 > coords4 && !( coords2 > coords3 ) && !( coords3 > coords2 ) );
129 std::cout <<
"Test failed for operator >." << std::endl;
133 optest = ( coords4 < coords2 && !( coords2 < coords3 ) && !( coords3 < coords2 ) );
136 std::cout <<
"Test failed for operator <." << std::endl;
141 for(
int i = 0; i < 3; i++ )
143 if( coords1[i] != coords2[3 - i] )
145 std::cout <<
"Test failed for operator[]." << std::endl;
151 HomCoord coords5( 2 * coords1[0], 2 * coords1[1], 2 * coords1[2] );
152 HomCoord coords6 = coords1 + coords1;
153 if( coords5 != coords6 )
155 std::cout <<
"Test failed for operator+." << std::endl;
160 if( coords5 - coords1 != coords1 )
162 std::cout <<
"Test failed for operator-." << std::endl;
174 int test_int[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 };
176 for(
int i = 0; i < 16; i++ )
180 std::cout <<
"HomXform integer array constructor failed." << std::endl;
185 HomXform xform3( test_int[0], test_int[1], test_int[2], test_int[3], test_int[4], test_int[5], test_int[6],
186 test_int[7], test_int[8], test_int[9], test_int[10], test_int[11], test_int[12], test_int[13],
187 test_int[14], test_int[15] );
188 for(
int i = 0; i < 16; i++ )
192 std::cout <<
"HomXform integer constructor failed." << std::endl;
198 int rotate[] = { 0, 1, 0, -1, 0, 0, 0, 0, 1 };
199 int translate[] = { 4, 5, 6 };
200 int scale[] = { 1, 1, 1 };
203 HomXform xform2( rotate, scale, translate );
215 std::cout <<
"HomXform rotate, scale, translate constructor failed." << std::endl;
227 int rotate[] = { 0, 1, 0, -1, 0, 0, 0, 0, 1 };
228 int translate[] = { 4, 5, 6 };
229 int scale[] = { 1, 1, 1 };
232 HomXform xform1( rotate, scale, translate );
233 HomXform xform1a( rotate, scale, translate );
236 if( !( xform1 == xform1a ) )
238 std::cout <<
"HomXform operator== failed." << std::endl;
244 if( !( xform1 != xform1a ) )
246 std::cout <<
"HomXform operator!= failed." << std::endl;
252 if( !( xform1c == xform1 ) )
254 std::cout <<
"HomXform operator= failed." << std::endl;
259 if( xform3 != xform1 )
261 std::cout <<
"HomXform operator * failed." << std::endl;
267 if( xform3 != xform1 )
269 std::cout <<
"HomXform operator *= failed." << std::endl;
285 std::cout <<
"HomCoord length() or length_squared() failed." << std::endl;
295 std::cout <<
"HomCoord normalize failed." << std::endl;
300 int inv_int[] = { 0, 1, 0, 0, -1, 0, 0, 0, 0, 0, 1, 0, 7, 5, 0, 1 };
307 HomXform xform2 = xform1 * xform1_inv;
310 std::cout <<
"HomXform inverse failed." << std::endl;
325 if( test_pt2 != test_pt )
327 std::cout <<
"Coord-xform operator* failed." << std::endl;
332 int rotate[] = { 0, 1, 0, -1, 0, 0, 0, 0, 1 };
333 int translate[] = { 4, 5, 6 };
334 int scale[] = { 1, 1, 1 };
335 HomXform xform2( rotate, scale, translate );
340 if( test_pt3 != ident )
342 std::cout <<
"Coord-xform operator* failed." << std::endl;
347 test_pt2 = ( test_pt * xform2 ) / xform2;
348 if( test_pt2 != test_pt )
350 std::cout <<
"Coord-xform operator/ failed." << std::endl;
358 xform.
three_pt_xform(
HomCoord( 0, 0, 0, 1 ),
HomCoord( 7, 5, 0, 1 ),
HomCoord( 0, 3, 0, 1 ),
359 HomCoord( 4, 5, 0, 1 ),
HomCoord( 0, 0, 3, 1 ),
HomCoord( 7, 5, 3, 1 ) );
361 HomXform solution( 0, 1, 0, 0, -1, 0, 0, 0, 0, 0, 1, 0, 7, 5, 0, 1 );
362 if( xform != solution )
364 std::cout <<
"Three-pt transform (general) test failed." << std::endl;
369 xform.
three_pt_xform(
HomCoord( 0, 0, 0, 1 ),
HomCoord( 7, 5, 0, 1 ),
HomCoord( 6, 0, 0, 1 ),
370 HomCoord( 7, 11, 0, 1 ),
HomCoord( 0, 0, 0, 1 ),
HomCoord( 7, 5, 0, 1 ) );
372 solution =
HomXform( 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, -1, 0, 7, 5, 0, 1 );
373 if( xform != solution )
375 std::cout <<
"Three-pt transform (1d) test failed." << std::endl;