BLI_math_geom_test.cc 539 B

12345678910111213141516171819202122
  1. /* Apache License, Version 2.0 */
  2. #include "testing/testing.h"
  3. #include "BLI_math.h"
  4. #include "stubs/bf_intern_eigen_stubs.h"
  5. TEST(math_geom, DistToLine2DSimple)
  6. {
  7. float p[2] = {5.0f, 1.0f}, a[2] = {0.0f, 0.0f}, b[2] = {2.0f, 0.0f};
  8. float distance = dist_to_line_v2(p, a, b);
  9. EXPECT_NEAR(1.0f, distance, 1e-6);
  10. }
  11. TEST(math_geom, DistToLineSegment2DSimple)
  12. {
  13. float p[2] = {3.0f, 1.0f}, a[2] = {0.0f, 0.0f}, b[2] = {2.0f, 0.0f};
  14. float distance = dist_to_line_segment_v2(p, a, b);
  15. EXPECT_NEAR(sqrtf(2.0f), distance, 1e-6);
  16. }