Gazebo Math

API Reference

6.15.1
gz/math/Cylinder.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2018 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_CYLINDER_HH_
18 #define GZ_MATH_CYLINDER_HH_
19 
20 #include <optional>
21 #include "gz/math/MassMatrix3.hh"
22 #include "gz/math/Material.hh"
23 #include "gz/math/Plane.hh"
24 #include "gz/math/Quaternion.hh"
25 
26 namespace ignition
27 {
28  namespace math
29  {
30  // Foward declarations
31  class CylinderPrivate;
32 
33  // Inline bracket to help doxygen filtering.
34  inline namespace IGNITION_MATH_VERSION_NAMESPACE {
35  //
44  template<typename Precision>
45  class Cylinder
46  {
50  public: Cylinder() = default;
51 
57  public: Cylinder(const Precision _length, const Precision _radius,
58  const Quaternion<Precision> &_rotOffset =
60 
67  public: Cylinder(const Precision _length, const Precision _radius,
68  const Material &_mat,
69  const Quaternion<Precision> &_rotOffset =
71 
73  public: ~Cylinder() = default;
74 
77  public: Precision Radius() const;
78 
81  public: void SetRadius(const Precision _radius);
82 
85  public: Precision Length() const;
86 
89  public: void SetLength(const Precision _length);
90 
96  public: Quaternion<Precision> RotationalOffset() const;
97 
102  public: void SetRotationalOffset(
103  const Quaternion<Precision> &_rotOffset);
104 
107  public: const Material &Mat() const;
108 
111  public: void SetMat(const Material &_mat);
112 
121  public: bool MassMatrix(MassMatrix3d &_massMat) const;
122 
125  public: bool operator==(const Cylinder &_cylinder) const;
126 
129  public: Precision Volume() const;
130 
136  public: Precision VolumeBelow(const Plane<Precision> &_plane) const;
137 
145  public: std::optional<Vector3<Precision>>
146  CenterOfVolumeBelow(const Plane<Precision> &_plane) const;
147 
156  public: Precision DensityFromMass(const Precision _mass) const;
157 
170  public: bool SetDensityFromMass(const Precision _mass);
171 
173  private: Precision radius = 0.0;
174 
176  private: Precision length = 0.0;
177 
179  private: Material material;
180 
182  private: Quaternion<Precision> rotOffset =
184  };
185 
189 
193 
197  }
198  }
199 }
200 #include "gz/math/detail/Cylinder.hh"
201 
202 #endif
Cylinder< float > Cylinderf
Cylinder with float precision.
Definition: gz/math/Cylinder.hh:196
Definition: gz/math/AdditivelySeparableScalarField3.hh:27
Precision Volume() const
Get the volume of the cylinder in m^3.
A plane and related functions.
Definition: gz/math/Plane.hh:38
~Cylinder()=default
Destructor.
Contains information about a single material.
Definition: gz/math/Material.hh:65
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...
Cylinder< double > Cylinderd
Cylinder with double precision.
Definition: gz/math/Cylinder.hh:192
Precision Radius() const
Get the radius in meters.
const Material & Mat() const
Get the material associated with this cylinder.
Precision DensityFromMass(const Precision _mass) const
Compute the cylinder's density given a mass value. The cylinder is assumed to be solid with uniform d...
Cylinder< int > Cylinderi
Cylinder with integer precision.
Definition: gz/math/Cylinder.hh:188
Cylinder()=default
Default constructor. The default radius and length are both zero. The default rotational offset is Qu...
Precision Length() const
Get the length in meters.
void SetRadius(const Precision _radius)
Set the radius in meters.
bool operator==(const Cylinder &_cylinder) const
Check if this cylinder is equal to the provided cylinder. Radius, length, and material properties wil...
void SetLength(const Precision _length)
Set the length in meters.
Quaternion< Precision > RotationalOffset() const
Get the rotational offset. By default, a cylinder's length is aligned with the Z axis....
Precision VolumeBelow(const Plane< Precision > &_plane) const
Get the volume of the cylinder below a given plane in m^3. It is assumed that the center of the cylin...
void SetMat(const Material &_mat)
Set the material associated with this cylinder.
bool MassMatrix(MassMatrix3d &_massMat) const
Get the mass matrix for this cylinder. This function is only meaningful if the cylinder's radius,...
A representation of a cylinder.
Definition: gz/math/Cylinder.hh:45
A class for inertial information about a rigid body consisting of the scalar mass and a 3x3 symmetric...
Definition: gz/math/MassMatrix3.hh:45
bool SetDensityFromMass(const Precision _mass)
Set the density of this cylinder based on a mass value. Density is computed using Precision DensityFr...
void SetRotationalOffset(const Quaternion< Precision > &_rotOffset)
Set the rotation offset. See Quaternion<Precision> RotationalOffset() for details on the rotational o...