Gazebo Math

API Reference

7.5.1
gz/math/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 GZ_MATH_BOX_HH_
18 #define GZ_MATH_BOX_HH_
19 
20 #include <optional>
21 #include <gz/math/config.hh>
22 #include <gz/math/MassMatrix3.hh>
23 #include <gz/math/Material.hh>
24 #include <gz/math/Plane.hh>
25 #include <gz/math/Vector3.hh>
26 
27 #include "gz/math/detail/WellOrderedVector.hh"
28 
29 #include <set>
30 
31 namespace gz::math
32 {
33  // Inline bracket to help doxygen filtering.
34  inline namespace GZ_MATH_VERSION_NAMESPACE {
37  template<typename T>
38  using IntersectionPoints = std::set<Vector3<T>, WellOrderedVectors<T>>;
39 
49  template<typename Precision>
50  class Box
51  {
53  public: Box() = default;
54 
59  public: Box(const Precision _length,
60  const Precision _width,
61  const Precision _height);
62 
68  public: Box(const Precision _length, const Precision _width,
69  const Precision _height,
70  const gz::math::Material &_mat);
71 
79  public: explicit Box(const Vector3<Precision> &_size);
80 
90  public: Box(const Vector3<Precision> &_size,
91  const gz::math::Material &_mat);
92 
95  public: math::Vector3<Precision> Size() const;
96 
104  public: void SetSize(const math::Vector3<Precision> &_size);
105 
110  public: void SetSize(const Precision _length,
111  const Precision _width,
112  const Precision _height);
113 
117  public: bool operator==(const Box<Precision> &_b) const;
118 
122  public: bool operator!=(const Box<Precision> &_b) const;
123 
126  public: const gz::math::Material &Material() const;
127 
130  public: void SetMaterial(const gz::math::Material &_mat);
131 
134  public: Precision Volume() const;
135 
140  public: Precision VolumeBelow(const Plane<Precision> &_plane) const;
141 
147  public: std::optional<Vector3<Precision>>
148  CenterOfVolumeBelow(const Plane<Precision> &_plane) const;
149 
156  VerticesBelow(const Plane<Precision> &_plane) const;
157 
166  public: Precision DensityFromMass(const Precision _mass) const;
167 
180  public: bool SetDensityFromMass(const Precision _mass);
181 
189  public: bool MassMatrix(MassMatrix3<Precision> &_massMat) const;
190 
197  public: std::optional< MassMatrix3<Precision> > MassMatrix() const;
198 
205  const Plane<Precision> &_plane) const;
206 
209 
211  private: gz::math::Material material;
212  };
213 
216  typedef Box<int> Boxi;
217 
220  typedef Box<double> Boxd;
221 
224  typedef Box<float> Boxf;
225  } // namespace GZ_MATH_VERSION_NAMESPACE
226 } // namespace gz::math
227 #include "gz/math/detail/Box.hh"
228 #endif // GZ_MATH_BOX_HH_