Welcome to mirror list, hosted at ThFree Co, Russian Federation.

BLI_math_geom_test.cc « blenlib « gtests « tests - git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 2f85e6b4d7d496fd305af62e5c2cd251186b1849 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
/* Apache License, Version 2.0 */

#include "testing/testing.h"

#include "BLI_math.h"

TEST(mathutils, 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);
}

TEST(mathutils, 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);
}