Berkeley SfM
point_3d.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2015, The Regents of the University of California (Regents).
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are
7  * met:
8  *
9  * 1. Redistributions of source code must retain the above copyright
10  * notice, this list of conditions and the following disclaimer.
11  *
12  * 2. Redistributions in binary form must reproduce the above
13  * copyright notice, this list of conditions and the following
14  * disclaimer in the documentation and/or other materials provided
15  * with the distribution.
16  *
17  * 3. Neither the name of the copyright holder nor the names of its
18  * contributors may be used to endorse or promote products derived
19  * from this software without specific prior written permission.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS AS IS
22  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
25  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31  * POSSIBILITY OF SUCH DAMAGE.
32  *
33  * Please contact the author(s) of this library if you have any questions.
34  * Authors: Erik Nelson ( eanelson@eecs.berkeley.edu )
35  * David Fridovich-Keil ( dfk@eecs.berkeley.edu )
36  */
37 
38 ///////////////////////////////////////////////////////////////////////////////
39 //
40 // The Point3D class is a light-weight wrapper around an Eigen::Vector3d.
41 //
42 ///////////////////////////////////////////////////////////////////////////////
43 
44 #ifndef BSFM_GEOMETRY_POINT_3D_H
45 #define BSFM_GEOMETRY_POINT_3D_H
46 
47 #include <Eigen/Core>
48 #include <memory>
49 #include <string>
50 #include <vector>
51 
52 namespace bsfm {
53 
54 using Eigen::Vector3d;
55 
56 class Point3D {
57  public:
58  typedef std::shared_ptr<Point3D> Ptr;
59  typedef std::shared_ptr<const Point3D> ConstPtr;
60 
61  // Constructors.
62  Point3D();
63  Point3D(double x, double y, double z);
64  Point3D(const Point3D& in);
65  Point3D(const Vector3d& in);
66 
67  // Destructor.
68  ~Point3D();
69 
70  // Setters.
71  void SetX(double x);
72  void SetY(double x);
73  void SetZ(double x);
74  void Set(double x, double y, double z);
75  void Set(const Point3D& in);
76  void Set(const Vector3d& in);
77 
78  // Getters.
79  double& operator()(int index);
80  const double& operator()(int index) const;
81  double X() const;
82  double Y() const;
83  double Z() const;
84  Vector3d& Get();
85  const Vector3d& Get() const;
86 
87  // Utility.
88  void Print(const std::string& prefix = std::string()) const;
89 
90  // Math operations.
91  void Normalize();
92  Point3D Normalized() const;
93  double Dot(const Point3D& other) const;
94 
95  private:
96  Vector3d data_;
97 }; //\class Point3D
98 
99 // Define a list of Point3D objects.
100 typedef std::vector<Point3D> Point3DList;
101 
102 } //\namespace bsfm
103 
104 #endif
std::vector< Point3D > Point3DList
Definition: point_3d.h:100
double & operator()(int index)
Definition: point_3d.cpp:82
void Normalize()
Definition: point_3d.cpp:116
Point3D Normalized() const
Definition: point_3d.cpp:120
void SetY(double x)
Definition: point_3d.cpp:63
void SetZ(double x)
Definition: point_3d.cpp:65
double Y() const
Definition: point_3d.cpp:94
double X() const
Definition: point_3d.cpp:92
void Print(const std::string &prefix=std::string()) const
Definition: point_3d.cpp:107
void SetX(double x)
Definition: point_3d.cpp:61
Definition: camera.cpp:50
Vector3d & Get()
Definition: point_3d.cpp:98
double Z() const
Definition: point_3d.cpp:96
std::shared_ptr< Point3D > Ptr
Definition: point_3d.h:58
Vector3d data_
Definition: point_3d.h:96
std::shared_ptr< const Point3D > ConstPtr
Definition: point_3d.h:59
void Set(double x, double y, double z)
Definition: point_3d.cpp:67
double Dot(const Point3D &other) const
Definition: point_3d.cpp:126