gtsam 4.2.0
gtsam
Point3.h
Go to the documentation of this file.
1/* ----------------------------------------------------------------------------
2
3 * GTSAM Copyright 2010, Georgia Tech Research Corporation,
4 * Atlanta, Georgia 30332-0415
5 * All Rights Reserved
6 * Authors: Frank Dellaert, et al. (see THANKS for the full author list)
7
8 * See LICENSE for the license information
9
10 * -------------------------------------------------------------------------- */
11
20// \callgraph
21
22#pragma once
23
24#include <gtsam/config.h>
25#include <gtsam/base/VectorSpace.h>
26#include <gtsam/base/Vector.h>
27#include <gtsam/dllexport.h>
29#include <boost/serialization/nvp.hpp>
30#include <numeric>
31
32namespace gtsam {
33
36typedef Vector3 Point3;
37typedef std::vector<Point3, Eigen::aligned_allocator<Point3> > Point3Vector;
38
39// Convenience typedef
40using Point3Pair = std::pair<Point3, Point3>;
41GTSAM_EXPORT std::ostream &operator<<(std::ostream &os, const gtsam::Point3Pair &p);
42
43using Point3Pairs = std::vector<Point3Pair>;
44
46GTSAM_EXPORT double distance3(const Point3& p1, const Point3& q,
47 OptionalJacobian<1, 3> H1 = boost::none,
48 OptionalJacobian<1, 3> H2 = boost::none);
49
51GTSAM_EXPORT double norm3(const Point3& p, OptionalJacobian<1, 3> H = boost::none);
52
54GTSAM_EXPORT Point3 normalize(const Point3& p, OptionalJacobian<3, 3> H = boost::none);
55
57GTSAM_EXPORT Point3 cross(const Point3& p, const Point3& q,
58 OptionalJacobian<3, 3> H_p = boost::none,
59 OptionalJacobian<3, 3> H_q = boost::none);
60
62GTSAM_EXPORT double dot(const Point3& p, const Point3& q,
63 OptionalJacobian<1, 3> H_p = boost::none,
64 OptionalJacobian<1, 3> H_q = boost::none);
65
67template <class CONTAINER>
68Point3 mean(const CONTAINER& points) {
69 if (points.size() == 0) throw std::invalid_argument("Point3::mean input container is empty");
70 Point3 sum(0, 0, 0);
71 sum = std::accumulate(points.begin(), points.end(), sum);
72 return sum / points.size();
73}
74
76GTSAM_EXPORT Point3Pair means(const std::vector<Point3Pair> &abPointPairs);
77
78template <typename A1, typename A2>
79struct Range;
80
81template <>
83 typedef double result_type;
84 double operator()(const Point3& p, const Point3& q,
85 OptionalJacobian<1, 3> H1 = boost::none,
86 OptionalJacobian<1, 3> H2 = boost::none) {
87 return distance3(p, q, H1, H2);
88 }
89};
90
91} // namespace gtsam
92
typedef and functions to augment Eigen's VectorXd
serialization for Vectors
Global functions in a separate testing namespace.
Definition: chartTesting.h:28
Point3 mean(const CONTAINER &points)
mean
Definition: Point3.h:68
Point3 cross(const Point3 &p, const Point3 &q, OptionalJacobian< 3, 3 > H1, OptionalJacobian< 3, 3 > H2)
cross product
Definition: Point3.cpp:64
Point2Pair means(const std::vector< Point2Pair > &abPointPairs)
Calculate the two means of a set of Point2 pairs.
Definition: Point2.cpp:116
double distance3(const Point3 &p1, const Point3 &q, OptionalJacobian< 1, 3 > H1, OptionalJacobian< 1, 3 > H2)
distance between two points
Definition: Point3.cpp:27
Vector3 Point3
As of GTSAM 4, in order to make GTSAM more lean, it is now possible to just typedef Point3 to Vector3...
Definition: Point3.h:36
Point3 normalize(const Point3 &p, OptionalJacobian< 3, 3 > H)
normalize, with optional Jacobian
Definition: Point3.cpp:52
double norm3(const Point3 &p, OptionalJacobian< 1, 3 > H)
Distance of the point from the origin, with Jacobian.
Definition: Point3.cpp:41
double dot(const V1 &a, const V2 &b)
Dot product.
Definition: Vector.h:195
OptionalJacobian is an Eigen::Ref like class that can take be constructed using either a fixed size o...
Definition: OptionalJacobian.h:41
Definition: BearingRange.h:40