Blender  V3.3
BLI_math_geom_test.cc
Go to the documentation of this file.
1 /* SPDX-License-Identifier: Apache-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:292
float dist_to_line_v2(const float p[2], const float l1[2], const float l2[2])
Definition: math_geom.c:278
TEST(math_geom, DistToLine2DSimple)
ATTR_WARN_UNUSED_RESULT const BMVert const BMEdge * e
#define sqrtf(x)
Definition: metal/compat.h:243
static unsigned a[3]
Definition: RandGen.cpp:78
T distance(const T &a, const T &b)
static const pxr::TfToken b("b", pxr::TfToken::Immortal)