Skip to content

Commit c9e01a1

Browse files
committed
Fix issues
1 parent 91abbf0 commit c9e01a1

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

modules/yup_graphics/primitives/yup_Point.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ class YUP_API Point
260260
*/
261261
[[nodiscard]] constexpr ValueType horizontalDistanceTo (const Point& other) const noexcept
262262
{
263-
return yup_abs (other.x - x);
263+
return other.x - x;
264264
}
265265

266266
/** Calculates the vertical distance between this point and another point.
@@ -274,7 +274,7 @@ class YUP_API Point
274274
*/
275275
[[nodiscard]] constexpr ValueType verticalDistanceTo (const Point& other) const noexcept
276276
{
277-
return yup_abs (other.y - y);
277+
return other.y - y;
278278
}
279279

280280
/** Calculates the Manhattan distance between this point and another point.

tests/yup_graphics/yup_Point.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,9 @@ TEST (PointTests, Distance_Calculations)
106106
EXPECT_FLOAT_EQ (p1.distanceTo (p2), 5.0f);
107107
EXPECT_FLOAT_EQ (p1.distanceToSquared (p2), 25.0f);
108108
EXPECT_FLOAT_EQ (p1.horizontalDistanceTo (p2), 3.0f);
109+
EXPECT_FLOAT_EQ (p2.horizontalDistanceTo (p1), -3.0f);
109110
EXPECT_FLOAT_EQ (p1.verticalDistanceTo (p2), 4.0f);
111+
EXPECT_FLOAT_EQ (p2.verticalDistanceTo (p1), -4.0f);
110112
EXPECT_FLOAT_EQ (p1.manhattanDistanceTo (p2), 7.0f);
111113
}
112114

@@ -693,8 +695,10 @@ TEST (PointTests, DistanceCalculations_EdgeCases)
693695
// Test with negative coordinates
694696
Point<float> negative (-3.0f, -4.0f);
695697
EXPECT_FLOAT_EQ (origin.distanceTo (negative), 5.0f);
696-
EXPECT_FLOAT_EQ (origin.horizontalDistanceTo (negative), 3.0f);
697-
EXPECT_FLOAT_EQ (origin.verticalDistanceTo (negative), 4.0f);
698+
EXPECT_FLOAT_EQ (origin.horizontalDistanceTo (negative), -3.0f);
699+
EXPECT_FLOAT_EQ (negative.horizontalDistanceTo (origin), 3.0f);
700+
EXPECT_FLOAT_EQ (origin.verticalDistanceTo (negative), -4.0f);
701+
EXPECT_FLOAT_EQ (negative.verticalDistanceTo (origin), 4.0f);
698702

699703
// Test with infinity
700704
Point<float> inf (std::numeric_limits<float>::infinity(), 0.0f);

0 commit comments

Comments
 (0)