Skip to content

Commit

Permalink
neq and tests
Browse files Browse the repository at this point in the history
  • Loading branch information
MarshallVielmetti committed Jan 24, 2025
1 parent de52f8b commit 2abfc17
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 0 deletions.
14 changes: 14 additions & 0 deletions include/manif/impl/lie_group_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,20 @@ struct LieGroupBase
template <typename _DerivedOther>
bool operator ==(const LieGroupBase<_DerivedOther>& m) const;


/**
* @brief Inequality operator.
* @param[in] An element of the same Lie group.
* @return false if the Lie group element m is 'close' to this,
* true otherwise.
* @see operator==.
*/
template <typename _DerivedOther>
bool operator!=(
const LieGroupBase<_DerivedOther> &m) const {
return !(*this == m);
}

/**
* @brief Right oplus operator.
* @see rplus.
Expand Down
8 changes: 8 additions & 0 deletions test/se2/gtest_se2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -550,6 +550,14 @@ TEST(TEST_SE2, TEST_SE2_NORMALIZE)
);
}

TEST(TEST_SE2, TEST_SE2_NEQ)
{
SE2d one(SE2d::DataType(0,0,1,0));
SE2d two(4, 2, 1, 0);

EXPECT_NE(one, two);
}

#endif

MANIF_TEST(SE2d);
Expand Down
11 changes: 11 additions & 0 deletions test/se3/gtest_se3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,17 @@ TEST(TEST_SE3, TEST_SE3_NORMALIZE)
);
}

TEST(TEST_SE3, TEST_SE3_NEQ)
{
SE3d one(SE3d::Translation(1,2,3),
Eigen::Quaterniond::Identity());

SE3d::DataType values; values << 0,0,0, 0,0,0,1;
SE3d two(values);

EXPECT_NE(one, two);
}

#endif

MANIF_TEST(SE3d);
Expand Down
8 changes: 8 additions & 0 deletions test/so2/gtest_so2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -576,6 +576,14 @@ TEST(TEST_SO2, TEST_SO2_NORMALIZE)
);
}

TEST(TEST_SO2, TEST_SO2_NEQ)
{
SO2d one(0, 1);
SO2d two = SO2d::Identity();

EXPECT_NE(one, two);
}

#endif

MANIF_TEST(SO2d);
Expand Down
8 changes: 8 additions & 0 deletions test/so3/gtest_so3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -617,6 +617,14 @@ TEST(TEST_SO3, TEST_SO3_NORMALIZE)
);
}

TEST(TEST_SO3, TEST_SO3_NOTEQ)
{
SO3d one(0,0,0,1);
SO3d two(1,0,0,0);

EXPECT_NE(one, two);
}

#endif

MANIF_TEST(SO3d);
Expand Down

0 comments on commit 2abfc17

Please sign in to comment.