Gazebo Math

API Reference

6.17.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 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  //
49  template<typename Precision>
50  class Capsule
51  {
54  public: Capsule() = default;
55 
59  public: Capsule(const Precision _length, const Precision _radius);
60 
65  public: Capsule(const Precision _length, const Precision _radius,
66  const Material &_mat);
67 
70  public: Precision Radius() const;
71 
74  public: void SetRadius(const Precision _radius);
75 
78  public: Precision Length() const;
79 
82  public: void SetLength(const Precision _length);
83 
86  public: const Material &Mat() const;
87 
90  public: void SetMat(const Material &_mat);
91 
98  public: std::optional< MassMatrix3<Precision> > MassMatrix() const;
99 
102  public: bool operator==(const Capsule &_capsule) const;
103 
106  public: Precision Volume() const;
107 
113  public: Precision VolumeBelow(const Plane<Precision> &_plane) const;
114 
122  public: std::optional<Vector3<Precision>>
123  CenterOfVolumeBelow(const Plane<Precision> &_plane) const;
124 
129  public: Vector3<Precision> Centroid() const;
130 
139  public: Precision DensityFromMass(const Precision _mass) const;
140 
153  public: bool SetDensityFromMass(const Precision _mass);
154 
156  private: Precision radius = 0.0;
157 
159  private: Precision length = 0.0;
160 
162  private: Material material;
163  };
164 
168 
172 
176  }
177  }
178 }
179 #include "gz/math/detail/Capsule.hh"
180 
181 #endif
A representation of a capsule or sphere-capped cylinder.
Definition: gz/math/Capsule.hh:51
void SetLength(const Precision _length)
Set the length in meters.
const Material & Mat() const
Get the material associated with this capsule.
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...
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...
Precision Radius() const
Get the radius in meters.
void SetRadius(const Precision _radius)
Set the radius in meters.
Capsule(const Precision _length, const Precision _radius)
Construct a capsule with a length and radius.
Precision Length() const
Get the length in meters.
bool operator==(const Capsule &_capsule) const
Check if this capsule is equal to the provided capsule. Radius, length, and material properties will ...
Capsule(const Precision _length, const Precision _radius, const Material &_mat)
Construct a capsule with a length, radius, and material.
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.
Capsule()=default
Default constructor. The default radius and length are both zero.
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,...
Vector3< Precision > Centroid() const
Get the centroid of the capsule. It coincides with the origin of the reference frame defined in the c...
Contains information about a single material.
Definition: gz/math/Material.hh:66
A plane and related functions.
Definition: gz/math/Plane.hh:39
Capsule< float > Capsulef
Capsule with float precision.
Definition: gz/math/Capsule.hh:175
Capsule< int > Capsulei
Capsule with integer precision.
Definition: gz/math/Capsule.hh:167
Capsule< double > Capsuled
Capsule with double precision.
Definition: gz/math/Capsule.hh:171
Definition: gz/math/AdditivelySeparableScalarField3.hh:28