This repository has been archived on 2023-10-09. You can view files and clone it, but cannot push or open issues or pull requests.
Files
blender-archive/source/blender/blenlib/tests/BLI_math_geom_test.cc

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

20 lines
505 B
C++
Raw Normal View History

/* SPDX-License-Identifier: Apache-2.0 */
#include "testing/testing.h"
#include "BLI_math.h"
2014-07-19 20:02:14 +10:00
TEST(math_geom, DistToLine2DSimple)
{
float p[2] = {5.0f, 1.0f}, a[2] = {0.0f, 0.0f}, b[2] = {2.0f, 0.0f};
float distance = dist_to_line_v2(p, a, b);
EXPECT_NEAR(1.0f, distance, 1e-6);
}
2014-07-19 20:02:14 +10:00
TEST(math_geom, DistToLineSegment2DSimple)
{
float p[2] = {3.0f, 1.0f}, a[2] = {0.0f, 0.0f}, b[2] = {2.0f, 0.0f};
float distance = dist_to_line_segment_v2(p, a, b);
EXPECT_NEAR(sqrtf(2.0f), distance, 1e-6);
}