Gazebo Math

API Reference

7.5.2
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  //
41  template<typename Precision>
42  class Capsule
43  {
46  public: Capsule() = default;
47 
51  public: Capsule(const Precision _length, const Precision _radius);
52 
57  public: Capsule(const Precision _length, const Precision _radius,
58  const Material &_mat);
59 
62  public: Precision Radius() const;
63 
66  public: void SetRadius(const Precision _radius);
67 
70  public: Precision Length() const;
71 
74  public: void SetLength(const Precision _length);
75 
78  public: const Material &Mat() const;
79 
82  public: void SetMat(const Material &_mat);
83 
90  public: std::optional< MassMatrix3<Precision> > MassMatrix() const;
91 
94  public: bool operator==(const Capsule &_capsule) const;
95 
98  public: Precision Volume() const;
99 
105  public: Precision VolumeBelow(const Plane<Precision> &_plane) const;
106 
114  public: std::optional<Vector3<Precision>>
115  CenterOfVolumeBelow(const Plane<Precision> &_plane) const;
116 
125  public: Precision DensityFromMass(const Precision _mass) const;
126 
139  public: bool SetDensityFromMass(const Precision _mass);
140 
142  private: Precision radius = 0.0;
143 
145  private: Precision length = 0.0;
146 
148  private: Material material;
149  };
150 
154 
158 
162  } // namespace GZ_MATH_VERSION_NAMESPACE
163 } // namespace gz::math
164 #include "gz/math/detail/Capsule.hh"
165 #endif // GZ_MATH_CAPSULE_HH_