Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vector comparison operator isn't strict #244

Open
chapulina opened this issue Sep 21, 2021 · 1 comment
Open

Vector comparison operator isn't strict #244

chapulina opened this issue Sep 21, 2021 · 1 comment
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@chapulina
Copy link
Contributor

chapulina commented Sep 21, 2021

Environment

  • OS Version: all
  • Source or binary build? all

Description

  • Expected behavior: Operators can be used to strictly order vectors.
  • Actual behavior: Operator is not asymmetric, so a < b and b < a can both be true at the same time, as demonstrated on the example below:
diff --git a/src/Vector3_TEST.cc b/src/Vector3_TEST.cc
index 81d8753..d038e15 100644
--- a/src/Vector3_TEST.cc
+++ b/src/Vector3_TEST.cc
@@ -546,3 +546,13 @@ TEST(Vector3dTest, DistToLine)
     EXPECT_DOUBLE_EQ(point.DistToLine(pointA, pointB), 0);
   }
 }
+
+/////////////////////////////////////////////////
+TEST(Vector3dTest, LessThanOperator)
+{
+  math::Vector3d vec1(1, 0, 0);
+  math::Vector3d vec2(0, 1, 0);
+
+  EXPECT_TRUE(vec2 < vec1);
+  EXPECT_TRUE(vec1 < vec2);
+}

Steps to reproduce

See the example test above, which passes

Additional context

On #219 , the WellOrderedVector was added to provide a strict comparison function so the current behaviour wouldn't be changed. We should consider changing the behaviour on a new major version.

@chapulina chapulina added the bug Something isn't working label Sep 21, 2021
@chapulina chapulina changed the title Vector comparison operator isn' Vector comparison operator isn't strict Sep 21, 2021
@chapulina chapulina added the help wanted Extra attention is needed label Sep 21, 2021
@chapulina chapulina mentioned this issue Sep 21, 2021
8 tasks
@Avisheet
Copy link

Hey @chapulina . I have done some changes in the Vector3_TEST.cc to resolve the issue of operator not beign assymetric and have given the pull request . Can you just check and verify it .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants