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 #include "gz/math/Plane.hh"
24 
25 namespace ignition
26 {
27  namespace math
28  {
29  // Foward declarations
30  class CapsulePrivate;
31 
32  // Inline bracket to help doxygen filtering.
33  inline namespace IGNITION_MATH_VERSION_NAMESPACE {
34  //
43  template<typename Precision>
44  class Capsule
45  {
48  public: Capsule() = default;
49 
53  public: Capsule(const Precision _length, const Precision _radius);
54 
59  public: Capsule(const Precision _length, const Precision _radius,
60  const Material &_mat);
61 
64  public: Precision Radius() const;
65 
68  public: void SetRadius(const Precision _radius);
69 
72  public: Precision Length() const;
73 
76  public: void SetLength(const Precision _length);
77 
80  public: const Material &Mat() const;
81 
84  public: void SetMat(const Material &_mat);
85 
92  public: std::optional< MassMatrix3<Precision> > MassMatrix() const;
93 
96  public: bool operator==(const Capsule &_capsule) const;
97 
100  public: Precision Volume() const;
101 
107  public: Precision VolumeBelow(const Plane<Precision> &_plane) const;
108 
116  public: std::optional<Vector3<Precision>>
117  CenterOfVolumeBelow(const Plane<Precision> &_plane) const;
118 
127  public: Precision DensityFromMass(const Precision _mass) const;
128 
141  public: bool SetDensityFromMass(const Precision _mass);
142 
144  private: Precision radius = 0.0;
145 
147  private: Precision length = 0.0;
148 
150  private: Material material;
151  };
152 
156 
160 
164  }
165  }
166 }
167 #include "gz/math/detail/Capsule.hh"
168 
169 #endif
void SetRadius(const Precision _radius)
Set the radius in meters.
Capsule< int > Capsulei
Capsule with integer precision.
Definition: gz/math/Capsule.hh:155
Definition: gz/math/AdditivelySeparableScalarField3.hh:27
A plane and related functions.
Definition: gz/math/Plane.hh:38
Capsule< double > Capsuled
Capsule with double precision.
Definition: gz/math/Capsule.hh:159
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.
std::optional< Vector3< Precision > > CenterOfVolumeBelow(const Plane< Precision > &_plane) const
Center of volume below the plane. This is useful for example when calculating where buoyancy should b...
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 VolumeBelow(const Plane< Precision > &_plane) const
Get the volume of the capsule below a given plane in m^3. It is assumed that the center of the capsul...
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:44
Capsule< float > Capsulef
Capsule with float precision.
Definition: gz/math/Capsule.hh:163