OrientedPlane3.cpp
Go to the documentation of this file.
1 /* ----------------------------------------------------------------------------
2 
3  * Atlanta, Georgia 30332-0415
4  * All Rights Reserved
5  * GTSAM Copyright 2010, Georgia Tech Research Corporation,
6  * Authors: Frank Dellaert, et al. (see THANKS for the full author list)
7 
8  * See LICENSE for the license information
9 
10  * -------------------------------------------------------------------------- */
11 
12 /*
13  * @file OrientedPlane3.cpp
14  * @date Dec 19, 2013
15  * @author Alex Trevor
16  * @author Zhaoyang Lv
17  * @brief A plane, represented by a normal direction and perpendicular distance
18  */
19 
21 
22 #include <iostream>
23 
24 using namespace std;
25 
26 namespace gtsam {
27 
28 /* ************************************************************************* */
29 void OrientedPlane3::print(const string& s) const {
30  Vector4 coeffs = planeCoefficients();
31  cout << s << " : " << coeffs.transpose() << endl;
32 }
33 
34 /* ************************************************************************* */
37  OptionalJacobian<3, 6> Hr) const {
38  Matrix23 D_rotated_plane;
39  Matrix22 D_rotated_pose;
40  Unit3 n_rotated = xr.rotation().unrotate(n_, D_rotated_plane, D_rotated_pose);
41 
42  Vector3 unit_vec = n_rotated.unitVector();
43  double pred_d = n_.unitVector().dot(xr.translation()) + d_;
44 
45  if (Hr) {
46  Hr->setZero();
47  Hr->block<2, 3>(0, 0) = D_rotated_plane;
48  Hr->block<1, 3>(2, 3) = unit_vec;
49  }
50  if (Hp) {
51  Hp->setZero();
52  Hp->block<2, 2>(0, 0) = D_rotated_pose;
53  Hp->block<1, 2>(2, 0) = n_.basis().transpose() * xr.translation();
54  (*Hp)(2, 2) = 1;
55  }
56 
57  return OrientedPlane3(unit_vec(0), unit_vec(1), unit_vec(2), pred_d);
58 }
59 
60 /* ************************************************************************* */
61 Vector3 OrientedPlane3::errorVector(const OrientedPlane3& other,
63  OptionalJacobian<3, 3> H2) const {
64  Matrix22 H_n_error_this, H_n_error_other;
65  Vector2 n_error = n_.errorVector(other.n_, H1 ? &H_n_error_this : 0,
66  H2 ? &H_n_error_other : 0);
67 
68  double d_error = d_ - other.d_;
69 
70  if (H1) {
71  *H1 << H_n_error_this, Z_2x1, 0, 0, 1;
72  }
73  if (H2) {
74  *H2 << H_n_error_other, Z_2x1, 0, 0, -1;
75  }
76 
77  return Vector3(n_error(0), n_error(1), d_error);
78 }
79 
80 /* ************************************************************************* */
81 OrientedPlane3 OrientedPlane3::retract(const Vector3& v,
82  OptionalJacobian<3, 3> H) const {
83  Matrix22 H_n;
84  Unit3 n_retract(n_.retract(Vector2(v(0), v(1)), H? &H_n : nullptr));
85  if (H) {
86  *H << H_n, Z_2x1, 0, 0, 1;
87  }
88  return OrientedPlane3(n_retract, d_ + v(2));
89 }
90 
91 /* ************************************************************************* */
92 Vector3 OrientedPlane3::localCoordinates(const OrientedPlane3& y) const {
93  Vector2 n_local = n_.localCoordinates(y.n_);
94  double d_local = d_ - y.d_;
95  return Vector3(n_local(0), n_local(1), -d_local);
96 }
97 
98 } // namespace gtsam
const Point3 & translation(OptionalJacobian< 3, 6 > Hself={}) const
get translation
Definition: Pose3.cpp:308
Scalar * y
Eigen::Vector3d Vector3
Definition: Vector.h:43
Vector3 unitVector(OptionalJacobian< 3, 2 > H={}) const
Return unit-norm Vector.
Definition: Unit3.cpp:151
Definition: BFloat16.h:88
EIGEN_STRONG_INLINE Packet4f print(const Packet4f &a)
set noclip points set clip one set noclip two set bar set border lt lw set xdata set ydata set zdata set x2data set y2data set boxwidth set dummy y set format x g set format y g set format x2 g set format y2 g set format z g set angles radians set nogrid set key title set key left top Right noreverse box linetype linewidth samplen spacing width set nolabel set noarrow set nologscale set logscale x set set pointsize set encoding default set nopolar set noparametric set set set set surface set nocontour set clabel set mapping cartesian set nohidden3d set cntrparam order set cntrparam linear set cntrparam levels auto set cntrparam points set size set set xzeroaxis lt lw set x2zeroaxis lt lw set yzeroaxis lt lw set y2zeroaxis lt lw set tics in set ticslevel set tics set mxtics default set mytics default set mx2tics default set my2tics default set xtics border mirror norotate autofreq set ytics border mirror norotate autofreq set ztics border nomirror norotate autofreq set nox2tics set noy2tics set timestamp bottom norotate set rrange [*:*] noreverse nowriteback set trange [*:*] noreverse nowriteback set urange [*:*] noreverse nowriteback set vrange [*:*] noreverse nowriteback set xlabel matrix size set x2label set timefmt d m y n H
Represents an infinite plane in 3D, which is composed of a planar normal and its perpendicular distan...
Represents a 3D point on a unit sphere.
Definition: Unit3.h:42
double d_
The perpendicular distance to this plane.
Point3 unrotate(const Point3 &p, OptionalJacobian< 3, 3 > H1={}, OptionalJacobian< 3, 3 > H2={}) const
rotate point from world to rotated frame
Definition: Rot3.cpp:135
Array< int, Dynamic, 1 > v
RealScalar s
EIGEN_DONT_INLINE void transform(const Transformation &t, Data &data)
Definition: geometry.cpp:25
traits
Definition: chartTesting.h:28
const Rot3 & rotation(OptionalJacobian< 3, 6 > Hself={}) const
get rotation
Definition: Pose3.cpp:315
Unit3 n_
The direction of the planar normal.
static const Eigen::MatrixBase< Vector2 >::ConstantReturnType Z_2x1
Definition: Vector.h:45


gtsam
Author(s):
autogenerated on Tue Jul 4 2023 02:34:59