Gazebo Math

API Reference

6.15.1
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 
24 namespace ignition
25 {
26  namespace math
27  {
28  // Foward declarations
29  class CapsulePrivate;
30 
31  // Inline bracket to help doxygen filtering.
32  inline namespace IGNITION_MATH_VERSION_NAMESPACE {
33  //
42  template<typename Precision>
43  class Capsule
44  {
47  public: Capsule() = default;
48 
52  public: Capsule(const Precision _length, const Precision _radius);
53 
58  public: Capsule(const Precision _length, const Precision _radius,
59  const Material &_mat);
60 
63  public: Precision Radius() const;
64 
67  public: void SetRadius(const Precision _radius);
68 
71  public: Precision Length() const;
72 
75  public: void SetLength(const Precision _length);
76 
79  public: const Material &Mat() const;
80 
83  public: void SetMat(const Material &_mat);
84 
91  public: std::optional< MassMatrix3<Precision> > MassMatrix() const;
92 
95  public: bool operator==(const Capsule &_capsule) const;
96 
99  public: Precision Volume() const;
100 
109  public: Precision DensityFromMass(const Precision _mass) const;
110 
123  public: bool SetDensityFromMass(const Precision _mass);
124 
126  private: Precision radius = 0.0;
127 
129  private: Precision length = 0.0;
130 
132  private: Material material;
133  };
134 
138 
142 
146  }
147  }
148 }
149 #include "gz/math/detail/Capsule.hh"
150 
151 #endif
void SetRadius(const Precision _radius)
Set the radius in meters.
Capsule< int > Capsulei
Capsule with integer precision.
Definition: gz/math/Capsule.hh:137
Definition: gz/math/AdditivelySeparableScalarField3.hh:27
Capsule< double > Capsuled
Capsule with double precision.
Definition: gz/math/Capsule.hh:141
Contains information about a single material.
Definition: gz/math/Material.hh:65
Capsule()=default
Default constructor. The default radius and length are both zero.
Precision DensityFromMass(const Precision _mass) const
Compute the capsule's density given a mass value. The capsule is assumed to be solid with uniform den...
const Material & Mat() const
Get the material associated with this capsule.
bool operator==(const Capsule &_capsule) const
Check if this capsule is equal to the provided capsule. Radius, length, and material properties will ...
Precision Length() const
Get the length in meters.
bool SetDensityFromMass(const Precision _mass)
Set the density of this capsule based on a mass value. Density is computed using Precision DensityFro...
void SetMat(const Material &_mat)
Set the material associated with this capsule.
std::optional< MassMatrix3< Precision > > MassMatrix() const
Get the mass matrix for this capsule. This function is only meaningful if the capsule's radius,...
void SetLength(const Precision _length)
Set the length in meters.
Precision Volume() const
Get the volume of the capsule in m^3.
Precision Radius() const
Get the radius in meters.
A representation of a capsule or sphere-capped cylinder.
Definition: gz/math/Capsule.hh:43
Capsule< float > Capsulef
Capsule with float precision.
Definition: gz/math/Capsule.hh:145