1 // Some tests for vgl_line_segment_3d
2 // Kevin de Souza, Aug 2005.
3
4 #include <iostream>
5 #include <limits>
6 // not used? #include <vcl_compiler.h>
7 #include "testlib/testlib_test.h"
8 #include "vgl/vgl_line_segment_3d.h"
9
10
11 static void
test_direction_vector()12 test_direction_vector()
13 {
14 vgl_point_3d<double> p1(0, 0, 0);
15 vgl_point_3d<double> p2(1, 2, 3);
16 vgl_line_segment_3d<double> l1(p1, p2);
17 vgl_vector_3d<double> u = p2 - p1;
18 TEST("Direction vector 1", u, l1.direction());
19 }
20
21
22 static void
test_parametric_point()23 test_parametric_point()
24 {
25 vgl_point_3d<double> p1(0, 0, 0);
26 vgl_point_3d<double> p2(1, 2, 4);
27 vgl_point_3d<double> p3(0.5, 1.0, 2.0);
28 vgl_line_segment_3d<double> l1(p1, p2);
29 TEST("Parametric point: t=0.0", l1.point_t(0.0), p1);
30 TEST("Parametric point: t=1.0", l1.point_t(1.0), p2);
31 TEST("Parametric point: t=0.5", l1.point_t(0.5), p3);
32 TEST("Parametric point: t=-1.0", l1.point_t(-1.0), vgl_point_3d<double>(-1, -2, -4));
33 TEST("Parametric point: t=2.0", l1.point_t(2.0), vgl_point_3d<double>(2, 4, 8));
34 }
35
36
37 void
test_line_segment_3d()38 test_line_segment_3d()
39 {
40 std::cout << "*****************************\n"
41 << " Testing vgl_line_segment_3d\n"
42 << "*****************************\n\n";
43
44 test_direction_vector();
45
46 test_parametric_point();
47 }
48
49
50 TESTMAIN(test_line_segment_3d);
51