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

Add getters to Line3 #668

Merged
merged 2 commits into from
Jan 14, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions gtsam/geometry/Line3.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,27 @@ class Line3 {
*/
Point3 point(double distance = 0) const;

/**
* Return the rotation of the line.
*/
inline Rot3 R() const {
return R_;
}

/**
* Return the x-coordinate of the intersection of the line with the xy plane.
*/
inline double a() const {
return a_;
}

/**
* Return the y-coordinate of the intersection of the line with the xy plane.
*/
inline double b() const {
return b_;
}

/**
* Transform a line from world to camera frame
* @param wTc - Pose3 of camera in world frame
Expand Down
10 changes: 10 additions & 0 deletions gtsam/geometry/tests/testLine3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,16 @@ GTSAM_CONCEPT_MANIFOLD_INST(Line3)

static const Line3 l(Rot3(), 1, 1);

// Testing getters
TEST(Line3, getMethods) {
const double a = 5, b = 10;
const Rot3 R = Rot3::Expmap(Vector3(0.1, 0.2, 0.3));
const Line3 line(R, a, b);
EXPECT_DOUBLES_EQUAL(a, line.a(), 1e-8);
EXPECT_DOUBLES_EQUAL(b, line.b(), 1e-8);
EXPECT(assert_equal(R, line.R(), 1e-8));
}

// Testing equals function of Line3
TEST(Line3, equals) {
Line3 l_same = l;
Expand Down