Gazebo Math

API Reference

6.15.1
gz/math/AxisAlignedBox.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2012 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_AXISALIGNEDBOX_HH_
18 #define GZ_MATH_AXISALIGNEDBOX_HH_
19 
20 #include <iostream>
21 #include <tuple>
22 #include <gz/math/config.hh>
23 #include <gz/math/Helpers.hh>
24 #include <gz/math/Line3.hh>
25 #include <gz/math/MassMatrix3.hh>
26 #include <gz/math/Material.hh>
27 #include <gz/math/Vector3.hh>
28 
29 namespace ignition
30 {
31  namespace math
32  {
33  // Inline bracket to help doxygen filtering.
34  inline namespace IGNITION_MATH_VERSION_NAMESPACE {
35  //
36  // Forward declaration of private data
37  class AxisAlignedBoxPrivate;
38 
42  class IGNITION_MATH_VISIBLE AxisAlignedBox
43  {
50  public: AxisAlignedBox();
51 
56  public: AxisAlignedBox(const Vector3d &_vec1, const Vector3d &_vec2);
57 
66  public: AxisAlignedBox(double _vec1X, double _vec1Y, double _vec1Z,
67  double _vec2X, double _vec2Y, double _vec2Z);
68 
71  public: AxisAlignedBox(const AxisAlignedBox &_b);
72 
74  public: virtual ~AxisAlignedBox();
75 
78  public: double XLength() const;
79 
82  public: double YLength() const;
83 
86  public: double ZLength() const;
87 
90  public: math::Vector3d Size() const;
91 
94  public: math::Vector3d Center() const;
95 
98  public: void Merge(const AxisAlignedBox &_box);
99 
103  public: AxisAlignedBox &operator=(const AxisAlignedBox &_b);
104 
108  public: AxisAlignedBox operator+(const AxisAlignedBox &_b) const;
109 
113  public: const AxisAlignedBox &operator+=(const AxisAlignedBox &_b);
114 
118  public: bool operator==(const AxisAlignedBox &_b) const;
119 
123  public: bool operator!=(const AxisAlignedBox &_b) const;
124 
128  public: AxisAlignedBox operator-(const Vector3d &_v);
129 
133  public: AxisAlignedBox operator+(const Vector3d &_v);
134 
138  public: AxisAlignedBox operator-(const Vector3d &_v) const;
139 
143  public: AxisAlignedBox operator+(const Vector3d &_v) const;
144 
149  public: friend std::ostream &operator<<(std::ostream &_out,
150  const gz::math::AxisAlignedBox &_b)
151  {
152  _out << "Min[" << _b.Min() << "] Max[" << _b.Max() << "]";
153  return _out;
154  }
155 
158  public: const Vector3d &Min() const;
159 
162  public: const Vector3d &Max() const;
163 
166  public: Vector3d &Min();
167 
170  public: Vector3d &Max();
171 
178  public: bool Intersects(const AxisAlignedBox &_box) const;
179 
183  public: bool Contains(const Vector3d &_p) const;
184 
191  public: bool IntersectCheck(const Vector3d &_origin, const Vector3d &_dir,
192  const double _min, const double _max) const;
193 
209  public: std::tuple<bool, double> IntersectDist(
210  const Vector3d &_origin, const Vector3d &_dir,
211  const double _min, const double _max) const;
212 
230  public: std::tuple<bool, double, Vector3d> Intersect(
231  const Vector3d &_origin, const Vector3d &_dir,
232  const double _min, const double _max) const;
233 
242  public: std::tuple<bool, double, Vector3d> Intersect(
243  const Line3d &_line) const;
244 
247  public: double Volume() const;
248 
258  public: double IGN_DEPRECATED(6.0) DensityFromMass(
259  const double _mass) const;
260 
274  public: bool IGN_DEPRECATED(6.0) SetDensityFromMass(
275  const double _mass);
276 
280  public: const gz::math::Material IGN_DEPRECATED(6.0)
281  &Material() const;
282 
286  public: void IGN_DEPRECATED(6.0) SetMaterial(
287  const gz::math::Material &_mat);
288 
297  public: bool IGN_DEPRECATED(6.0) MassMatrix(
298  MassMatrix3d &_massMat) const;
299 
306  private: bool ClipLine(const int _d, const Line3d &_line,
307  double &_low, double &_high) const;
308 
310  private: AxisAlignedBoxPrivate *dataPtr;
311  };
312  }
313  }
314 }
315 #endif
virtual ~AxisAlignedBox()
Destructor.
AxisAlignedBox & operator=(const AxisAlignedBox &_b)
Assignment operator. Set this box to the parameter.
Definition: gz/math/AdditivelySeparableScalarField3.hh:27
bool IntersectCheck(const Vector3d &_origin, const Vector3d &_dir, const double _min, const double _max) const
Check if a ray (origin, direction) intersects the box.
std::tuple< bool, double > IntersectDist(const Vector3d &_origin, const Vector3d &_dir, const double _min, const double _max) const
Check if a ray (origin, direction) intersects the box.
bool SetDensityFromMass(const double _mass)
Set the density of this box based on a mass value. Density is computed using double DensityFromMass(c...
bool Intersects(const AxisAlignedBox &_box) const
Test box intersection. This test will only work if both box's minimum corner is less than or equal to...
math::Vector3d Size() const
Get the size of the box.
std::tuple< bool, double, Vector3d > Intersect(const Vector3d &_origin, const Vector3d &_dir, const double _min, const double _max) const
Check if a ray (origin, direction) intersects the box.
double XLength() const
Get the length along the x dimension.
double DensityFromMass(const double _mass) const
Compute the cylinder's density given a mass value. The cylinder is assumed to be solid with uniform d...
Contains information about a single material.
Definition: gz/math/Material.hh:65
const Vector3d & Max() const
Get the maximum corner.
AxisAlignedBox operator-(const Vector3d &_v)
Subtract a vector from the min and max values.
const Material & Material() const
Get the material associated with this box.
bool Contains(const Vector3d &_p) const
Check if a point lies inside the box.
math::Vector3d Center() const
Get the box center.
friend std::ostream & operator<<(std::ostream &_out, const AxisAlignedBox &_b)
Output operator.
Definition: gz/math/AxisAlignedBox.hh:149
double YLength() const
Get the length along the y dimension.
const AxisAlignedBox & operator+=(const AxisAlignedBox &_b)
Addition set operator. this = this + _b.
STL class.
bool MassMatrix(MassMatrix3d &_massMat) const
Get the mass matrix for this box. This function is only meaningful if the box's size and material hav...
The Vector3 class represents the generic vector containing 3 elements. Since it's commonly used to ke...
Definition: gz/math/Vector3.hh:41
bool operator!=(const AxisAlignedBox &_b) const
Inequality test operator.
const Vector3d & Min() const
Get the minimum corner.
double ZLength() const
Get the length along the z dimension.
A three dimensional line segment. The line is defined by a start and end point.
Definition: gz/math/Line3.hh:35
AxisAlignedBox operator+(const AxisAlignedBox &_b) const
Addition operator. result = this + _b.
void SetMaterial(const Material &_mat)
Set the material associated with this box.
AxisAlignedBox()
Default constructor. This constructor will set the box's minimum and maximum corners to the highest (...
Mathematical representation of a box that is aligned along an X,Y,Z axis.
Definition: gz/math/AxisAlignedBox.hh:42
double Volume() const
Get the volume of the box in m^3.
bool operator==(const AxisAlignedBox &_b) const
Equality test operator.
void Merge(const AxisAlignedBox &_box)
Merge a box with this box.
A class for inertial information about a rigid body consisting of the scalar mass and a 3x3 symmetric...
Definition: gz/math/MassMatrix3.hh:45