// Boost.Geometry // Unit Test // Copyright (c) 2019 Barend Gehrels, Amsterdam, the Netherlands. // This file was modified by Oracle on 2019. // Modifications copyright (c) 2019, Oracle and/or its affiliates. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle // Use, modification and distribution is subject to the Boost Software License, // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) #include #include #include #include #include namespace { // Boost.Test does not support BOOST_CHECK_CLOSE for integral types template bool is_small(T const& value) { static long double const epsilon = 1.0e-5; return bg::math::abs(value) < epsilon; } } template void verify_point_on_line(bg::model::infinite_line const& line, C const& x, C const& y) { BOOST_CHECK_MESSAGE(is_small(line.a * x + line.b * y + line.c), "Point is not located on the line"); } template void test_make() { typedef bg::model::infinite_line line_type; // Horizontal through origin line_type line = bg::detail::make::make_infinite_line(0, 0, 10, 0); verify_point_on_line(line, 0, 0); verify_point_on_line(line, 10, 0); // Horizontal line above origin line = bg::detail::make::make_infinite_line(0, 5, 10, 5); verify_point_on_line(line, 0, 5); verify_point_on_line(line, 10, 5); // Vertical through origin line = bg::detail::make::make_infinite_line(0, 0, 0, 10); verify_point_on_line(line, 0, 0); verify_point_on_line(line, 0, 10); // Vertical line left from origin line = bg::detail::make::make_infinite_line(5, 0, 5, 10); verify_point_on_line(line, 5, 0); verify_point_on_line(line, 5, 10); // Diagonal through origin line = bg::detail::make::make_infinite_line(0, 0, 8, 10); verify_point_on_line(line, 0, 0); verify_point_on_line(line, 8, 10); // Diagonal not through origin line = bg::detail::make::make_infinite_line(5, 2, -8, 10); verify_point_on_line(line, 5, 2); verify_point_on_line(line, -8, 10); } template void test_all() { test_make(); } int test_main(int, char* []) { test_all(); test_all(); test_all(); test_all(); return 0; }