Gazebo Math

API Reference

7.6.0
gz/math/Capsule.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2020 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_CAPSULE_HH_
18 #define GZ_MATH_CAPSULE_HH_
19 
20 #include <optional>
21 #include "gz/math/MassMatrix3.hh"
22 #include "gz/math/Material.hh"
23 #include "gz/math/Plane.hh"
24 
25 namespace gz::math
26 {
27  // Foward declarations
28  class CapsulePrivate;
29 
30  // Inline bracket to help doxygen filtering.
31  inline namespace GZ_MATH_VERSION_NAMESPACE {
32  //
47  template<typename Precision>
48  class Capsule
49  {
52  public: Capsule() = default;
53 
57  public: Capsule(const Precision _length, const Precision _radius);
58 
63  public: Capsule(const Precision _length, const Precision _radius,
64  const Material &_mat);
65 
68  public: Precision Radius() const;
69 
72  public: void SetRadius(const Precision _radius);
73 
76  public: Precision Length() const;
77 
80  public: void SetLength(const Precision _length);
81 
84  public: const Material &Mat() const;
85 
88  public: void SetMat(const Material &_mat);
89 
96  public: std::optional< MassMatrix3<Precision> > MassMatrix() const;
97 
100  public: bool operator==(const Capsule &_capsule) const;
101 
104  public: Precision Volume() const;
105 
111  public: Precision VolumeBelow(const Plane<Precision> &_plane) const;
112 
120  public: std::optional<Vector3<Precision>>
121  CenterOfVolumeBelow(const Plane<Precision> &_plane) const;
122 
127  public: Vector3<Precision> Centroid() const;
128 
137  public: Precision DensityFromMass(const Precision _mass) const;
138 
151  public: bool SetDensityFromMass(const Precision _mass);
152 
154  private: Precision radius = 0.0;
155 
157  private: Precision length = 0.0;
158 
160  private: Material material;
161  };
162 
166 
170 
174  } // namespace GZ_MATH_VERSION_NAMESPACE
175 } // namespace gz::math
176 #include "gz/math/detail/Capsule.hh"
177 #endif // GZ_MATH_CAPSULE_HH_