Gazebo Math

API Reference

7.6.0
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 
55  template<typename Precision>
56  class Box
57  {
59  public: Box() = default;
60 
65  public: Box(const Precision _length,
66  const Precision _width,
67  const Precision _height);
68 
74  public: Box(const Precision _length, const Precision _width,
75  const Precision _height,
76  const gz::math::Material &_mat);
77 
85  public: explicit Box(const Vector3<Precision> &_size);
86 
96  public: Box(const Vector3<Precision> &_size,
97  const gz::math::Material &_mat);
98 
102 
110  public: void SetSize(const math::Vector3<Precision> &_size);
111 
116  public: void SetSize(const Precision _length,
117  const Precision _width,
118  const Precision _height);
119 
123  public: bool operator==(const Box<Precision> &_b) const;
124 
128  public: bool operator!=(const Box<Precision> &_b) const;
129 
132  public: const gz::math::Material &Material() const;
133 
136  public: void SetMaterial(const gz::math::Material &_mat);
137 
140  public: Precision Volume() const;
141 
146  public: Precision VolumeBelow(const Plane<Precision> &_plane) const;
147 
153  public: std::optional<Vector3<Precision>>
154  CenterOfVolumeBelow(const Plane<Precision> &_plane) const;
155 
162  VerticesBelow(const Plane<Precision> &_plane) const;
163 
168  public: Vector3<Precision> Centroid() const;
169 
178  public: Precision DensityFromMass(const Precision _mass) const;
179 
192  public: bool SetDensityFromMass(const Precision _mass);
193 
201  public: bool MassMatrix(MassMatrix3<Precision> &_massMat) const;
202 
209  public: std::optional< MassMatrix3<Precision> > MassMatrix() const;
210 
217  const Plane<Precision> &_plane) const;
218 
221 
223  private: gz::math::Material material;
224  };
225 
228  typedef Box<int> Boxi;
229 
232  typedef Box<double> Boxd;
233 
236  typedef Box<float> Boxf;
237  } // namespace GZ_MATH_VERSION_NAMESPACE
238 } // namespace gz::math
239 #include "gz/math/detail/Box.hh"
240 #endif // GZ_MATH_BOX_HH_