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
H
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
Definition: gnuplot_common_settings.hh:74
Eigen::internal::print
EIGEN_STRONG_INLINE Packet4f print(const Packet4f &a)
Definition: NEON/PacketMath.h:3115
s
RealScalar s
Definition: level1_cplx_impl.h:126
gtsam::Vector3
Eigen::Vector3d Vector3
Definition: Vector.h:43
gtsam::Rot3::unrotate
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
gtsam::OrientedPlane3
Represents an infinite plane in 3D, which is composed of a planar normal and its perpendicular distan...
Definition: OrientedPlane3.h:36
OrientedPlane3.h
gtsam::Pose3
Definition: Pose3.h:37
gtsam::Pose3::translation
const Point3 & translation(OptionalJacobian< 3, 6 > Hself={}) const
get translation
Definition: Pose3.cpp:308
Vector2
Definition: test_operator_overloading.cpp:18
transform
EIGEN_DONT_INLINE void transform(const Transformation &t, Data &data)
Definition: geometry.cpp:25
y
Scalar * y
Definition: level1_cplx_impl.h:124
gtsam::Pose3::rotation
const Rot3 & rotation(OptionalJacobian< 3, 6 > Hself={}) const
get rotation
Definition: Pose3.cpp:315
gtsam
traits
Definition: chartTesting.h:28
gtsam::OptionalJacobian
Definition: OptionalJacobian.h:38
std
Definition: BFloat16.h:88
gtsam::Z_2x1
static const Eigen::MatrixBase< Vector2 >::ConstantReturnType Z_2x1
Definition: Vector.h:45
v
Array< int, Dynamic, 1 > v
Definition: Array_initializer_list_vector_cxx11.cpp:1
gtsam::Unit3
Represents a 3D point on a unit sphere.
Definition: Unit3.h:42
gtsam::Unit3::unitVector
Vector3 unitVector(OptionalJacobian< 3, 2 > H={}) const
Return unit-norm Vector.
Definition: Unit3.cpp:151
pybind_wrapper_test_script.other
other
Definition: pybind_wrapper_test_script.py:42


gtsam
Author(s):
autogenerated on Thu Jun 13 2024 03:03:52