Ignition Math

API Reference

6.4.0
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 IGNITION_MATH_AXISALIGNEDBOX_HH_
18 #define IGNITION_MATH_AXISALIGNEDBOX_HH_
19 
20 #include <iostream>
21 #include <tuple>
22 #include <ignition/math/config.hh>
23 #include <ignition/math/Helpers.hh>
24 #include <ignition/math/Line3.hh>
27 #include <ignition/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 
139  public: friend std::ostream &operator<<(std::ostream &_out,
141  {
142  _out << "Min[" << _b.Min() << "] Max[" << _b.Max() << "]";
143  return _out;
144  }
145 
148  public: const Vector3d &Min() const;
149 
152  public: const Vector3d &Max() const;
153 
156  public: Vector3d &Min();
157 
160  public: Vector3d &Max();
161 
168  public: bool Intersects(const AxisAlignedBox &_box) const;
169 
173  public: bool Contains(const Vector3d &_p) const;
174 
181  public: bool IntersectCheck(const Vector3d &_origin, const Vector3d &_dir,
182  const double _min, const double _max) const;
183 
199  public: std::tuple<bool, double> IntersectDist(
200  const Vector3d &_origin, const Vector3d &_dir,
201  const double _min, const double _max) const;
202 
220  public: std::tuple<bool, double, Vector3d> Intersect(
221  const Vector3d &_origin, const Vector3d &_dir,
222  const double _min, const double _max) const;
223 
232  public: std::tuple<bool, double, Vector3d> Intersect(
233  const Line3d &_line) const;
234 
237  public: double Volume() const;
238 
247  public: double DensityFromMass(const double _mass) const;
248 
261  public: bool SetDensityFromMass(const double _mass);
262 
265  public: const ignition::math::Material &Material() const;
266 
269  public: void SetMaterial(const ignition::math::Material &_mat);
270 
278  public: bool MassMatrix(MassMatrix3d &_massMat) const;
279 
286  private: bool ClipLine(const int _d, const Line3d &_line,
287  double &_low, double &_high) const;
288 
290  private: AxisAlignedBoxPrivate *dataPtr;
291  };
292  }
293  }
294 }
295 #endif
friend std::ostream & operator<<(std::ostream &_out, const AxisAlignedBox &_b)
Output operator.
Definition: AxisAlignedBox.hh:139
const Vector3d & Max() const
Get the maximum corner.
A class for inertial information about a rigid body consisting of the scalar mass and a 3x3 symmetric...
Definition: MassMatrix3.hh:45
Contains information about a single material.
Definition: Material.hh:65
The Vector3 class represents the generic vector containing 3 elements. Since it&#39;s commonly used to ke...
Definition: Vector3.hh:40
A three dimensional line segment. The line is defined by a start and end point.
Definition: Line3.hh:35
Definition: Angle.hh:42
const Vector3d & Min() const
Get the minimum corner.
STL class.
Mathematical representation of a box that is aligned along an X,Y,Z axis.
Definition: AxisAlignedBox.hh:42