Open3D (C++ API)  0.16.1
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-2021 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#include <vector>
32
35
36namespace open3d {
37namespace geometry {
38
39class AxisAlignedBoundingBox;
40class OrientedBoundingBox;
41
47class Geometry3D : public Geometry {
48public:
49 ~Geometry3D() override {}
50
51protected:
56
57public:
58 Geometry3D& Clear() override = 0;
59 bool IsEmpty() const override = 0;
61 virtual Eigen::Vector3d GetMinBound() const = 0;
63 virtual Eigen::Vector3d GetMaxBound() const = 0;
65 virtual Eigen::Vector3d GetCenter() const = 0;
68
76 bool robust = false) const = 0;
78 virtual Geometry3D& Transform(const Eigen::Matrix4d& transformation) = 0;
79
85 virtual Geometry3D& Translate(const Eigen::Vector3d& translation,
86 bool relative = true) = 0;
94 virtual Geometry3D& Scale(const double scale,
95 const Eigen::Vector3d& center) = 0;
96
103 virtual Geometry3D& Rotate(const Eigen::Matrix3d& R,
104 const Eigen::Vector3d& center) = 0;
105
106 virtual Geometry3D& Rotate(const Eigen::Matrix3d& R);
107
109 static Eigen::Matrix3d GetRotationMatrixFromXYZ(
110 const Eigen::Vector3d& rotation);
112 static Eigen::Matrix3d GetRotationMatrixFromYZX(
113 const Eigen::Vector3d& rotation);
115 static Eigen::Matrix3d GetRotationMatrixFromZXY(
116 const Eigen::Vector3d& rotation);
118 static Eigen::Matrix3d GetRotationMatrixFromXZY(
119 const Eigen::Vector3d& rotation);
121 static Eigen::Matrix3d GetRotationMatrixFromZYX(
122 const Eigen::Vector3d& rotation);
124 static Eigen::Matrix3d GetRotationMatrixFromYXZ(
125 const Eigen::Vector3d& rotation);
127 static Eigen::Matrix3d GetRotationMatrixFromAxisAngle(
128 const Eigen::Vector3d& rotation);
130 static Eigen::Matrix3d GetRotationMatrixFromQuaternion(
131 const Eigen::Vector4d& rotation);
132
133protected:
135 Eigen::Vector3d ComputeMinBound(
136 const std::vector<Eigen::Vector3d>& points) const;
138 Eigen::Vector3d ComputeMaxBound(
139 const std::vector<Eigen::Vector3d>& points) const;
141 Eigen::Vector3d ComputeCenter(
142 const std::vector<Eigen::Vector3d>& points) const;
143
149 void ResizeAndPaintUniformColor(std::vector<Eigen::Vector3d>& colors,
150 const size_t size,
151 const Eigen::Vector3d& color) const;
152
157 void TransformPoints(const Eigen::Matrix4d& transformation,
158 std::vector<Eigen::Vector3d>& points) const;
159
164 void TransformNormals(const Eigen::Matrix4d& transformation,
165 std::vector<Eigen::Vector3d>& normals) const;
166
171 void TransformCovariances(const Eigen::Matrix4d& transformation,
172 std::vector<Eigen::Matrix3d>& covariances) const;
173
181 void TranslatePoints(const Eigen::Vector3d& translation,
182 std::vector<Eigen::Vector3d>& points,
183 bool relative) const;
184
191 void ScalePoints(const double scale,
192 std::vector<Eigen::Vector3d>& points,
193 const Eigen::Vector3d& center) const;
194
201 void RotatePoints(const Eigen::Matrix3d& R,
202 std::vector<Eigen::Vector3d>& points,
203 const Eigen::Vector3d& center) const;
204
209 void RotateNormals(const Eigen::Matrix3d& R,
210 std::vector<Eigen::Vector3d>& normals) const;
211
216 void RotateCovariances(const Eigen::Matrix3d& R,
217 std::vector<Eigen::Matrix3d>& covariances) const;
218};
219
220} // namespace geometry
221} // namespace open3d
math::float4 color
Definition: LineSetBuffers.cpp:64
A bounding box that is aligned along the coordinate axes.
Definition: BoundingVolume.h:155
The base geometry class for 3D geometries.
Definition: Geometry3D.h:47
void TransformPoints(const Eigen::Matrix4d &transformation, std::vector< Eigen::Vector3d > &points) const
Transforms all points with the transformation matrix.
Definition: Geometry3D.cpp:96
virtual Geometry3D & Scale(const double scale, const Eigen::Vector3d &center)=0
Apply scaling to the geometry coordinates. Given a scaling factor , and center , a given point is tr...
static Eigen::Matrix3d GetRotationMatrixFromYXZ(const Eigen::Vector3d &rotation)
Get Rotation Matrix from YXZ RotationType.
Definition: Geometry3D.cpp:203
void ResizeAndPaintUniformColor(std::vector< Eigen::Vector3d > &colors, const size_t size, const Eigen::Vector3d &color) const
Resizes the colors vector and paints a uniform color.
Definition: Geometry3D.cpp:75
void ScalePoints(const double scale, std::vector< Eigen::Vector3d > &points, const Eigen::Vector3d &center) const
Scale the coordinates of all points by the scaling factor scale.
Definition: Geometry3D.cpp:134
virtual Eigen::Vector3d GetCenter() const =0
Returns the center of the geometry coordinates.
~Geometry3D() override
Definition: Geometry3D.h:49
void TranslatePoints(const Eigen::Vector3d &translation, std::vector< Eigen::Vector3d > &points, bool relative) const
Apply translation to the geometry coordinates.
Definition: Geometry3D.cpp:122
Eigen::Vector3d ComputeMaxBound(const std::vector< Eigen::Vector3d > &points) const
Compute max bound of a list points.
Definition: Geometry3D.cpp:53
virtual Eigen::Vector3d GetMaxBound() const =0
Returns max bounds for geometry coordinates.
virtual Eigen::Vector3d GetMinBound() const =0
Returns min bounds for geometry coordinates.
bool IsEmpty() const override=0
Returns true iff the geometry is empty.
void TransformCovariances(const Eigen::Matrix4d &transformation, std::vector< Eigen::Matrix3d > &covariances) const
Transforms all covariance matrices with the transformation.
Definition: Geometry3D.cpp:116
virtual AxisAlignedBoundingBox GetAxisAlignedBoundingBox() const =0
Returns an axis-aligned bounding box of the geometry.
static Eigen::Matrix3d GetRotationMatrixFromXZY(const Eigen::Vector3d &rotation)
Get Rotation Matrix from XZY RotationType.
Definition: Geometry3D.cpp:189
void RotatePoints(const Eigen::Matrix3d &R, std::vector< Eigen::Vector3d > &points, const Eigen::Vector3d &center) const
Rotate all points with the rotation matrix R.
Definition: Geometry3D.cpp:142
Geometry3D & Clear() override=0
Clear all elements in the geometry.
void RotateCovariances(const Eigen::Matrix3d &R, std::vector< Eigen::Matrix3d > &covariances) const
Rotate all covariance matrices with the rotation matrix R.
Definition: Geometry3D.cpp:160
Eigen::Vector3d ComputeMinBound(const std::vector< Eigen::Vector3d > &points) const
Compute min bound of a list points.
Definition: Geometry3D.cpp:41
void RotateNormals(const Eigen::Matrix3d &R, std::vector< Eigen::Vector3d > &normals) const
Rotate all normals with the rotation matrix R.
Definition: Geometry3D.cpp:150
virtual OrientedBoundingBox GetOrientedBoundingBox(bool robust=false) const =0
static Eigen::Matrix3d GetRotationMatrixFromAxisAngle(const Eigen::Vector3d &rotation)
Get Rotation Matrix from AxisAngle RotationType.
Definition: Geometry3D.cpp:210
virtual Geometry3D & Rotate(const Eigen::Matrix3d &R, const Eigen::Vector3d &center)=0
Apply rotation to the geometry coordinates and normals. Given a rotation matrix , and center ,...
static Eigen::Matrix3d GetRotationMatrixFromXYZ(const Eigen::Vector3d &rotation)
Get Rotation Matrix from XYZ RotationType.
Definition: Geometry3D.cpp:168
Geometry3D(GeometryType type)
Parameterized Constructor.
Definition: Geometry3D.h:55
void TransformNormals(const Eigen::Matrix4d &transformation, std::vector< Eigen::Vector3d > &normals) const
Transforms the normals with the transformation matrix.
Definition: Geometry3D.cpp:106
Eigen::Vector3d ComputeCenter(const std::vector< Eigen::Vector3d > &points) const
Computer center of a list of points.
Definition: Geometry3D.cpp:64
static Eigen::Matrix3d GetRotationMatrixFromZYX(const Eigen::Vector3d &rotation)
Get Rotation Matrix from ZYX RotationType.
Definition: Geometry3D.cpp:196
static Eigen::Matrix3d GetRotationMatrixFromQuaternion(const Eigen::Vector4d &rotation)
Get Rotation Matrix from Quaternion.
Definition: Geometry3D.cpp:219
virtual Geometry3D & Translate(const Eigen::Vector3d &translation, bool relative=true)=0
Apply translation to the geometry coordinates.
static Eigen::Matrix3d GetRotationMatrixFromYZX(const Eigen::Vector3d &rotation)
Get Rotation Matrix from YZX RotationType.
Definition: Geometry3D.cpp:175
virtual Geometry3D & Transform(const Eigen::Matrix4d &transformation)=0
Apply transformation (4x4 matrix) to the geometry coordinates.
static Eigen::Matrix3d GetRotationMatrixFromZXY(const Eigen::Vector3d &rotation)
Get Rotation Matrix from ZXY RotationType.
Definition: Geometry3D.cpp:182
The base geometry class.
Definition: Geometry.h:37
GeometryType
Specifies possible geometry types.
Definition: Geometry.h:42
A bounding box oriented along an arbitrary frame of reference.
Definition: BoundingVolume.h:44
int size
Definition: FilePCD.cpp:59
int points
Definition: FilePCD.cpp:73
char type
Definition: FilePCD.cpp:60
Definition: PinholeCameraIntrinsic.cpp:35