Gazebo Math
API Reference
7.4.0
insert_drive_file
Tutorials
library_books
Classes
toc
Namespaces
insert_drive_file
Files
launch
Gazebo Website
Index
List
Hierarchy
Members: All
Members: Functions
Members: Variables
Members: Typedefs
Members: Enumerations
Members: Enumerator
List
Members
Functions
Typedefs
Variables
Enumerations
Enumerator
include
gz
math
gz/math/Region3.hh
Go to the documentation of this file.
1
/*
2
* Copyright (C) 2022 Open Source Robotics Foundation
3
*
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
* you may not use this file except in compliance with the License.
6
* You may obtain a copy of the License at
7
*
8
* http://www.apache.org/licenses/LICENSE-2.0
9
*
10
* Unless required by applicable law or agreed to in writing, software
11
* distributed under the License is distributed on an "AS IS" BASIS,
12
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
* See the License for the specific language governing permissions and
14
* limitations under the License.
15
*
16
*/
17
#ifndef GZ_MATH_REGION3_HH_
18
#define GZ_MATH_REGION3_HH_
19
20
#include <cmath>
21
#include <limits>
22
#include <ostream>
23
#include <utility>
24
25
#include <
gz/math/Interval.hh
>
26
#include <
gz/math/Vector3.hh
>
27
#include <gz/math/config.hh>
28
29
namespace
gz
30
{
31
namespace
math
32
{
33
// Inline bracket to help doxygen filtering.
34
inline
namespace
GZ_MATH_VERSION_NAMESPACE {
35
//
50
template
<
typename
T>
51
class
Region3
52
{
54
public
:
static
const
Region3<T>
&
Unbounded
;
55
57
public
:
Region3
() =
default
;
58
63
public
:
constexpr
Region3
(
64
Interval<T>
_ix,
Interval<T>
_iy,
Interval<T>
_iz)
65
: ix(
std
::move(_ix)), iy(
std
::move(_iy)), iz(
std
::move(_iz))
66
{
67
}
68
78
public
:
static
constexpr
Region3<T>
Open
(
79
T _xLeft, T _yLeft, T _zLeft,
80
T _xRight, T _yRight, T _zRight)
81
{
82
return
Region3<T>
(
Interval<T>::Open
(_xLeft, _xRight),
83
Interval<T>::Open
(_yLeft, _yRight),
84
Interval<T>::Open
(_zLeft, _zRight));
85
}
86
96
public
:
static
constexpr
Region3<T>
Closed
(
97
T _xLeft, T _yLeft, T _zLeft,
98
T _xRight, T _yRight, T _zRight)
99
{
100
return
Region3<T>
(
Interval<T>::Closed
(_xLeft, _xRight),
101
Interval<T>::Closed
(_yLeft, _yRight),
102
Interval<T>::Closed
(_zLeft, _zRight));
103
}
104
107
public
:
const
Interval<T>
&
Ix
()
const
{
return
this->ix; }
108
111
public
:
const
Interval<T>
&
Iy
()
const
{
return
this->iy; }
112
115
public
:
const
Interval<T>
&
Iz
()
const
{
return
this->iz; }
116
121
public
:
bool
Empty
()
const
122
{
123
return
this->ix.Empty() || this->iy.Empty() || this->iz.Empty();
124
}
125
129
public
:
bool
Contains
(
const
Vector3<T>
&_point)
const
130
{
131
return
(this->ix.Contains(_point.
X
()) &&
132
this->iy.Contains(_point.
Y
()) &&
133
this->iz.Contains(_point.
Z
()));
134
}
135
139
public
:
bool
Contains
(
const
Region3<T>
&_other)
const
140
{
141
return
(this->ix.Contains(_other.ix) &&
142
this->iy.Contains(_other.iy) &&
143
this->iz.Contains(_other.iz));
144
}
145
149
public
:
bool
Intersects
(
const
Region3<T>
& _other)
const
150
{
151
return
(this->ix.Intersects(_other.ix) &&
152
this->iy.Intersects(_other.iy) &&
153
this->iz.Intersects(_other.iz));
154
}
155
159
public
:
bool
operator==
(
const
Region3<T>
&_other)
const
160
{
161
return
this->Contains(_other) && _other.
Contains
(*
this
);
162
}
163
167
public
:
bool
operator!=
(
const
Region3<T>
&_other)
const
168
{
169
return
!this->Contains(_other) || !_other.
Contains
(*
this
);
170
}
171
176
public
:
friend
std::ostream
&
operator<<
(
177
std::ostream
&_out,
const
gz::math::Region3<T>
&_r)
178
{
179
return
_out <<_r.ix <<
" x "
<< _r.iy <<
" x "
<< _r.iz;
180
}
181
183
private
:
Interval<T>
ix;
185
private
:
Interval<T>
iy;
187
private
:
Interval<T>
iz;
188
};
189
190
namespace
detail {
191
template
<
typename
T>
192
constexpr
Region3<T> gUnboundedRegion3(
193
Interval<T>::Open(-
std::numeric_limits<T>::infinity
(),
194
std::numeric_limits<T>::infinity
()),
195
Interval<T>::Open(-
std::numeric_limits<T>::infinity
(),
196
std::numeric_limits<T>::infinity
()),
197
Interval<T>::Open(-
std::numeric_limits<T>::infinity
(),
198
std::numeric_limits<T>::infinity
()));
199
}
200
template
<
typename
T>
201
const
Region3<T> &Region3<T>::Unbounded = detail::gUnboundedRegion3<T>;
202
203
using
Region3f
=
Region3<float>
;
204
using
Region3d
=
Region3<double>
;
205
}
206
}
207
}
208
209
#endif