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 
134  public: friend std::ostream &operator<<(std::ostream &_out,
136  {
137  _out << "Min[" << _b.Min() << "] Max[" << _b.Max() << "]";
138  return _out;
139  }
140 
143  public: const Vector3d &Min() const;
144 
147  public: const Vector3d &Max() const;
148 
151  public: Vector3d &Min();
152 
155  public: Vector3d &Max();
156 
163  public: bool Intersects(const AxisAlignedBox &_box) const;
164 
168  public: bool Contains(const Vector3d &_p) const;
169 
176  public: bool IntersectCheck(const Vector3d &_origin, const Vector3d &_dir,
177  const double _min, const double _max) const;
178 
194  public: std::tuple<bool, double> IntersectDist(
195  const Vector3d &_origin, const Vector3d &_dir,
196  const double _min, const double _max) const;
197 
215  public: std::tuple<bool, double, Vector3d> Intersect(
216  const Vector3d &_origin, const Vector3d &_dir,
217  const double _min, const double _max) const;
218 
227  public: std::tuple<bool, double, Vector3d> Intersect(
228  const Line3d &_line) const;
229 
232  public: double Volume() const;
233 
242  public: double DensityFromMass(const double _mass) const;
243 
256  public: bool SetDensityFromMass(const double _mass);
257 
260  public: const ignition::math::Material &Material() const;
261 
264  public: void SetMaterial(const ignition::math::Material &_mat);
265 
273  public: bool MassMatrix(MassMatrix3d &_massMat) const;
274 
281  private: bool ClipLine(const int _d, const Line3d &_line,
282  double &_low, double &_high) const;
283 
285  private: AxisAlignedBoxPrivate *dataPtr;
286  };
287  }
288  }
289 }
290 #endif
friend std::ostream & operator<<(std::ostream &_out, const AxisAlignedBox &_b)
Output operator.
Definition: AxisAlignedBox.hh:134
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