MCPcopy Create free account
hub / github.com/davisking/dlib / test_line

Function test_line

dlib/test/geometry.cpp:888–918  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

886// ----------------------------------------------------------------------------------------
887
888 void test_line()
889 {
890 print_spinner();
891 line l1(point(0,1),point(1,0));
892 line l2(point(0,0),point(1,1));
893
894 DLIB_TEST(length(intersect(l1,l2) - dpoint(0.5,0.5)) < 1e-12);
895
896 DLIB_TEST(std::abs(distance_to_line(l1, l1.p1())) < 1e-12);
897
898 DLIB_TEST(std::abs(distance_to_line(l1, dpoint(0,0)) - sqrt(0.5)) < 1e-12);
899 DLIB_TEST(std::abs(distance_to_line(l1, dpoint(1,1)) - sqrt(0.5)) < 1e-12);
900
901 DLIB_TEST(std::abs(signed_distance_to_line(l1, dpoint(0,0)) + sqrt(0.5)) < 1e-12);
902 DLIB_TEST(std::abs(signed_distance_to_line(l1, dpoint(1,1)) - sqrt(0.5)) < 1e-12);
903 DLIB_TEST(std::abs(signed_distance_to_line(reverse(l1), dpoint(1,1)) + sqrt(0.5)) < 1e-12);
904
905
906 dpoint reference_point(0.7,0.5);
907 std::vector<dpoint> pts = {dpoint(0.01,0), dpoint(1,0.5), dpoint(0.9, 0.3), dpoint(0.4, 2), dpoint(1.3, 0.9)};
908
909
910 DLIB_TEST(count_points_between_lines(l1,l2,reference_point,pts) == 3);
911 DLIB_TEST(count_points_on_side_of_line(l1,reference_point,pts) == 4);
912
913 reference_point = dpoint(0,0.5);
914 DLIB_TEST(count_points_between_lines(l1,l2,reference_point,pts) == 0);
915 DLIB_TEST(count_points_on_side_of_line(l1,reference_point,pts) == 1);
916
917
918 }
919
920// ----------------------------------------------------------------------------------------
921

Callers 1

perform_testMethod · 0.85

Calls 11

print_spinnerFunction · 0.85
absFunction · 0.85
distance_to_lineFunction · 0.85
signed_distance_to_lineFunction · 0.85
reverseFunction · 0.85
pointClass · 0.50
lengthFunction · 0.50
intersectFunction · 0.50
sqrtFunction · 0.50

Tested by

no test coverage detected