Ignition Math

API Reference

6.10.0
Box.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2018 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_BOX_HH_
18 #define IGNITION_MATH_BOX_HH_
19 
20 #include <ignition/math/config.hh>
23 #include <ignition/math/Plane.hh>
24 #include <ignition/math/Vector3.hh>
25 
26 #include "ignition/math/detail/WellOrderedVector.hh"
27 
28 #include <set>
29 
30 namespace ignition
31 {
32  namespace math
33  {
34  // Inline bracket to help doxygen filtering.
35  inline namespace IGNITION_MATH_VERSION_NAMESPACE {
38  template<typename T>
39  using IntersectionPoints = std::set<Vector3<T>, WellOrderedVectors<T>>;
40 
50  template<typename Precision>
51  class Box
52  {
54  public: Box() = default;
55 
60  public: Box(const Precision _length,
61  const Precision _width,
62  const Precision _height);
63 
69  public: Box(const Precision _length, const Precision _width,
70  const Precision _height,
71  const ignition::math::Material &_mat);
72 
80  public: explicit Box(const Vector3<Precision> &_size);
81 
91  public: Box(const Vector3<Precision> &_size,
92  const ignition::math::Material &_mat);
93 
95  public: virtual ~Box() = default;
96 
99  public: math::Vector3<Precision> Size() const;
100 
108  public: void SetSize(const math::Vector3<Precision> &_size);
109 
114  public: void SetSize(const Precision _length,
115  const Precision _width,
116  const Precision _height);
117 
121  public: bool operator==(const Box<Precision> &_b) const;
122 
126  public: bool operator!=(const Box<Precision> &_b) const;
127 
130  public: const ignition::math::Material &Material() const;
131 
134  public: void SetMaterial(const ignition::math::Material &_mat);
135 
138  public: Precision Volume() const;
139 
144  public: Precision VolumeBelow(const Plane<Precision> &_plane) const;
145 
151  public: std::optional<Vector3<Precision>>
152  CenterOfVolumeBelow(const Plane<Precision> &_plane) const;
153 
160  VerticesBelow(const Plane<Precision> &_plane) const;
161 
170  public: Precision DensityFromMass(const Precision _mass) const;
171 
184  public: bool SetDensityFromMass(const Precision _mass);
185 
193  public: bool MassMatrix(MassMatrix3<Precision> &_massMat) const;
194 
200  public: IntersectionPoints<Precision> Intersections(
201  const Plane<Precision> &_plane) const;
202 
205 
207  private: ignition::math::Material material;
208  };
209 
212  typedef Box<int> Boxi;
213 
216  typedef Box<double> Boxd;
217 
220  typedef Box<float> Boxf;
221  }
222  }
223 }
224 #include "ignition/math/detail/Box.hh"
225 #endif
A class for inertial information about a rigid body consisting of the scalar mass and a 3x3 symmetric...
Definition: MassMatrix3.hh:45
A plane and related functions.
Definition: Plane.hh:38
Contains information about a single material.
Definition: Material.hh:65
Box< double > Boxd
Box with double precision.
Definition: Box.hh:216
Box< float > Boxf
Box with float precision.
Definition: Box.hh:220
A representation of a box. All units are in meters.
Definition: Box.hh:51
STL class.
Box< int > Boxi
Box with integer precision.
Definition: Box.hh:212
Definition: Angle.hh:42