Open3D (C++ API)
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
Geometry3D.h
Go to the documentation of this file.
1 // ----------------------------------------------------------------------------
2 // - Open3D: www.open3d.org -
3 // ----------------------------------------------------------------------------
4 // The MIT License (MIT)
5 //
6 // Copyright (c) 2018 www.open3d.org
7 //
8 // Permission is hereby granted, free of charge, to any person obtaining a copy
9 // of this software and associated documentation files (the "Software"), to deal
10 // in the Software without restriction, including without limitation the rights
11 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 // copies of the Software, and to permit persons to whom the Software is
13 // furnished to do so, subject to the following conditions:
14 //
15 // The above copyright notice and this permission notice shall be included in
16 // all copies or substantial portions of the Software.
17 //
18 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
24 // IN THE SOFTWARE.
25 // ----------------------------------------------------------------------------
26 
27 #pragma once
28 
29 #include <Eigen/Core>
30 #include <Eigen/Geometry>
31 
33 #include "Open3D/Utility/Eigen.h"
34 
35 namespace open3d {
36 namespace geometry {
37 
38 class AxisAlignedBoundingBox;
39 class OrientedBoundingBox;
40 
41 class Geometry3D : public Geometry {
42 public:
43  enum class RotationType { XYZ, YZX, ZXY, XZY, ZYX, YXZ, AxisAngle };
44 
45  ~Geometry3D() override {}
46 
47 protected:
49 
50 public:
51  Geometry3D& Clear() override = 0;
52  bool IsEmpty() const override = 0;
53  virtual Eigen::Vector3d GetMinBound() const = 0;
54  virtual Eigen::Vector3d GetMaxBound() const = 0;
55  virtual Eigen::Vector3d GetCenter() const = 0;
57  virtual OrientedBoundingBox GetOrientedBoundingBox() const = 0;
58  virtual Geometry3D& Transform(const Eigen::Matrix4d& transformation) = 0;
59  virtual Geometry3D& Translate(const Eigen::Vector3d& translation,
60  bool relative = true) = 0;
61  virtual Geometry3D& Scale(const double scale, bool center = true) = 0;
62  virtual Geometry3D& Rotate(const Eigen::Vector3d& rotation,
63  bool center = true,
65 
66 protected:
67  Eigen::Vector3d ComputeMinBound(
68  const std::vector<Eigen::Vector3d>& points) const;
69  Eigen::Vector3d ComputeMaxBound(
70  const std::vector<Eigen::Vector3d>& points) const;
71  Eigen::Vector3d ComputeCenter(
72  const std::vector<Eigen::Vector3d>& points) const;
73 
74  void ResizeAndPaintUniformColor(std::vector<Eigen::Vector3d>& colors,
75  const size_t size,
76  const Eigen::Vector3d& color) const;
77 
78  void TransformPoints(const Eigen::Matrix4d& transformation,
79  std::vector<Eigen::Vector3d>& points) const;
80  void TransformNormals(const Eigen::Matrix4d& transformation,
81  std::vector<Eigen::Vector3d>& normals) const;
82  void TranslatePoints(const Eigen::Vector3d& translation,
83  std::vector<Eigen::Vector3d>& points,
84  bool relative) const;
85  void ScalePoints(const double scale,
86  std::vector<Eigen::Vector3d>& points,
87  bool center) const;
88  void RotatePoints(const Eigen::Vector3d& rotation,
89  std::vector<Eigen::Vector3d>& points,
90  bool center,
91  RotationType type) const;
92  void RotateNormals(const Eigen::Vector3d& rotation,
93  std::vector<Eigen::Vector3d>& normals,
94  bool center,
95  RotationType type) const;
96 
97  Eigen::Matrix3d GetRotationMatrix(
98  const Eigen::Vector3d& rotation,
99  RotationType type = RotationType::XYZ) const;
100 };
101 
102 } // namespace geometry
103 } // namespace open3d
Eigen::Vector3d ComputeCenter(const std::vector< Eigen::Vector3d > &points) const
Definition: Geometry3D.cpp:60
virtual Geometry3D & Scale(const double scale, bool center=true)=0
Definition: Geometry.h:32
bool IsEmpty() const override=0
virtual Eigen::Vector3d GetMinBound() const =0
void ScalePoints(const double scale, std::vector< Eigen::Vector3d > &points, bool center) const
Definition: Geometry3D.cpp:124
void RotatePoints(const Eigen::Vector3d &rotation, std::vector< Eigen::Vector3d > &points, bool center, RotationType type) const
Definition: Geometry3D.cpp:136
Definition: BoundingVolume.h:90
virtual OrientedBoundingBox GetOrientedBoundingBox() const =0
Geometry3D(GeometryType type)
Definition: Geometry3D.h:48
virtual Eigen::Vector3d GetCenter() const =0
virtual Geometry3D & Transform(const Eigen::Matrix4d &transformation)=0
virtual AxisAlignedBoundingBox GetAxisAlignedBoundingBox() const =0
void RotateNormals(const Eigen::Vector3d &rotation, std::vector< Eigen::Vector3d > &normals, bool center, RotationType type) const
Definition: Geometry3D.cpp:150
Eigen::Matrix3d GetRotationMatrix(const Eigen::Vector3d &rotation, RotationType type=RotationType::XYZ) const
Definition: Geometry3D.cpp:160
virtual Eigen::Vector3d GetMaxBound() const =0
void TransformNormals(const Eigen::Matrix4d &transformation, std::vector< Eigen::Vector3d > &normals) const
Definition: Geometry3D.cpp:102
Definition: BoundingVolume.h:38
Geometry3D & Clear() override=0
RotationType
Definition: Geometry3D.h:43
virtual Geometry3D & Rotate(const Eigen::Vector3d &rotation, bool center=true, RotationType type=RotationType::XYZ)=0
int size
Definition: FilePCD.cpp:55
Definition: Geometry3D.h:41
void TranslatePoints(const Eigen::Vector3d &translation, std::vector< Eigen::Vector3d > &points, bool relative) const
Definition: Geometry3D.cpp:112
char type
Definition: FilePCD.cpp:56
~Geometry3D() override
Definition: Geometry3D.h:45
int points
Definition: FilePCD.cpp:69
void TransformPoints(const Eigen::Matrix4d &transformation, std::vector< Eigen::Vector3d > &points) const
Definition: Geometry3D.cpp:92
Definition: PinholeCameraIntrinsic.cpp:34
GeometryType
Definition: Geometry.h:34
virtual Geometry3D & Translate(const Eigen::Vector3d &translation, bool relative=true)=0
void ResizeAndPaintUniformColor(std::vector< Eigen::Vector3d > &colors, const size_t size, const Eigen::Vector3d &color) const
Definition: Geometry3D.cpp:71
Eigen::Vector3d ComputeMinBound(const std::vector< Eigen::Vector3d > &points) const
Definition: Geometry3D.cpp:37
Eigen::Vector3d ComputeMaxBound(const std::vector< Eigen::Vector3d > &points) const
Definition: Geometry3D.cpp:49