Blender  V2.93
BLI_math_geom_test.cc
Go to the documentation of this file.
1 /* Apache License, Version 2.0 */
2 
3 #include "testing/testing.h"
4 
5 #include "BLI_math.h"
6 
7 TEST(math_geom, DistToLine2DSimple)
8 {
9  float p[2] = {5.0f, 1.0f}, a[2] = {0.0f, 0.0f}, b[2] = {2.0f, 0.0f};
10  float distance = dist_to_line_v2(p, a, b);
11  EXPECT_NEAR(1.0f, distance, 1e-6);
12 }
13 
14 TEST(math_geom, DistToLineSegment2DSimple)
15 {
16  float p[2] = {3.0f, 1.0f}, a[2] = {0.0f, 0.0f}, b[2] = {2.0f, 0.0f};
17  float distance = dist_to_line_segment_v2(p, a, b);
18  EXPECT_NEAR(sqrtf(2.0f), distance, 1e-6);
19 }
float dist_to_line_segment_v2(const float p[2], const float l1[2], const float l2[2])
Definition: math_geom.c:347
float dist_to_line_v2(const float p[2], const float l1[2], const float l2[2])
Definition: math_geom.c:332
TEST(math_geom, DistToLine2DSimple)
ATTR_WARN_UNUSED_RESULT const BMVert const BMEdge * e
#define sqrtf(x)
static unsigned a[3]
Definition: RandGen.cpp:92
ccl_device_inline float distance(const float2 &a, const float2 &b)