Gazebo Math

API Reference

7.4.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>
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
31namespace gz
32{
33 namespace math
34 {
35 // Inline bracket to help doxygen filtering.
36 inline namespace GZ_MATH_VERSION_NAMESPACE {
39 template<typename T>
40 using IntersectionPoints = std::set<Vector3<T>, WellOrderedVectors<T>>;
41
51 template<typename Precision>
52 class Box
53 {
55 public: Box() = default;
56
61 public: Box(const Precision _length,
62 const Precision _width,
63 const Precision _height);
64
70 public: Box(const Precision _length, const Precision _width,
71 const Precision _height,
72 const gz::math::Material &_mat);
73
81 public: explicit Box(const Vector3<Precision> &_size);
82
92 public: Box(const Vector3<Precision> &_size,
93 const gz::math::Material &_mat);
94
98
106 public: void SetSize(const math::Vector3<Precision> &_size);
107
112 public: void SetSize(const Precision _length,
113 const Precision _width,
114 const Precision _height);
115
119 public: bool operator==(const Box<Precision> &_b) const;
120
124 public: bool operator!=(const Box<Precision> &_b) const;
125
128 public: const gz::math::Material &Material() const;
129
132 public: void SetMaterial(const gz::math::Material &_mat);
133
136 public: Precision Volume() const;
137
142 public: Precision VolumeBelow(const Plane<Precision> &_plane) const;
143
149 public: std::optional<Vector3<Precision>>
151
158 VerticesBelow(const Plane<Precision> &_plane) const;
159
168 public: Precision DensityFromMass(const Precision _mass) const;
169
182 public: bool SetDensityFromMass(const Precision _mass);
183
191 public: bool MassMatrix(MassMatrix3<Precision> &_massMat) const;
192
199 public: std::optional< MassMatrix3<Precision> > MassMatrix() const;
200
207 const Plane<Precision> &_plane) const;
208
211
213 private: gz::math::Material material;
214 };
215
218 typedef Box<int> Boxi;
219
223
227 }
228 }
229}
230#include "gz/math/detail/Box.hh"
231#endif