projected_point_ax.cpp 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. // Boost.Geometry (aka GGL, Generic Geometry Library)
  2. // Unit Test
  3. // Copyright (c) 2007-2014 Barend Gehrels, Amsterdam, the Netherlands.
  4. // Copyright (c) 2008-2014 Bruno Lalande, Paris, France.
  5. // Copyright (c) 2009-2014 Mateusz Loskot, London, UK.
  6. // This file was modified by Oracle on 2014.
  7. // Modifications copyright (c) 2014, Oracle and/or its affiliates.
  8. // Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
  9. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
  10. // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
  11. // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
  12. // Use, modification and distribution is subject to the Boost Software License,
  13. // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
  14. // http://www.boost.org/LICENSE_1_0.txt)
  15. #include <strategies/test_projected_point.hpp>
  16. template <typename P1, typename P2>
  17. void test_all_2d_ax()
  18. {
  19. typedef bg::strategy::distance::detail::projected_point_ax<> strategy_type;
  20. typedef bg::strategy::distance::detail::projected_point_ax
  21. <
  22. void,
  23. bg::strategy::distance::comparable::pythagoras<>
  24. > comparable_strategy_type;
  25. typedef typename strategy_type::result_type<P1, P2>::type result_type;
  26. strategy_type strategy;
  27. comparable_strategy_type comparable_strategy;
  28. boost::ignore_unused(strategy, comparable_strategy);
  29. test_2d<P1, P2>("POINT(1 1)", "POINT(0 0)", "POINT(2 3)",
  30. result_type(0, 0.27735203958327),
  31. result_type(0, 0.27735203958327 * 0.27735203958327),
  32. strategy, comparable_strategy);
  33. test_2d<P1, P2>("POINT(2 2)", "POINT(1 4)", "POINT(4 1)",
  34. result_type(0, 0.5 * sqrt(2.0)),
  35. result_type(0, 0.5),
  36. strategy, comparable_strategy);
  37. test_2d<P1, P2>("POINT(6 1)", "POINT(1 4)", "POINT(4 1)",
  38. result_type(sqrt(2.0), sqrt(2.0)),
  39. result_type(2.0, 2.0),
  40. strategy, comparable_strategy);
  41. test_2d<P1, P2>("POINT(1 6)", "POINT(1 4)", "POINT(4 1)",
  42. result_type(sqrt(2.0), sqrt(2.0)),
  43. result_type(2.0, 2.0),
  44. strategy, comparable_strategy);
  45. }
  46. template <typename P>
  47. void test_all_2d_ax()
  48. {
  49. test_all_2d_ax<P, bg::model::point<int, 2, bg::cs::cartesian> >();
  50. test_all_2d_ax<P, bg::model::point<float, 2, bg::cs::cartesian> >();
  51. test_all_2d_ax<P, bg::model::point<double, 2, bg::cs::cartesian> >();
  52. test_all_2d_ax<P, bg::model::point<long double, 2, bg::cs::cartesian> >();
  53. }
  54. int test_main(int, char* [])
  55. {
  56. test_all_2d_ax<bg::model::point<int, 2, bg::cs::cartesian> >();
  57. test_all_2d_ax<bg::model::point<float, 2, bg::cs::cartesian> >();
  58. test_all_2d_ax<bg::model::point<double, 2, bg::cs::cartesian> >();
  59. #if defined(HAVE_TTMATH)
  60. test_all_2d_ax
  61. <
  62. bg::model::point<ttmath_big, 2, bg::cs::cartesian>,
  63. bg::model::point<ttmath_big, 2, bg::cs::cartesian>
  64. >();
  65. #endif
  66. return 0;
  67. }