Gazebo Math

API Reference

6.17.0
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  //
50  template<typename Precision>
51  class Cylinder
52  {
56  public: Cylinder() = default;
57 
63  public: Cylinder(const Precision _length, const Precision _radius,
64  const Quaternion<Precision> &_rotOffset =
66 
73  public: Cylinder(const Precision _length, const Precision _radius,
74  const Material &_mat,
75  const Quaternion<Precision> &_rotOffset =
77 
79  public: ~Cylinder() = default;
80 
83  public: Precision Radius() const;
84 
87  public: void SetRadius(const Precision _radius);
88 
91  public: Precision Length() const;
92 
95  public: void SetLength(const Precision _length);
96 
103 
108  public: void SetRotationalOffset(
109  const Quaternion<Precision> &_rotOffset);
110 
113  public: const Material &Mat() const;
114 
117  public: void SetMat(const Material &_mat);
118 
127  public: bool MassMatrix(MassMatrix3d &_massMat) const;
128 
131  public: bool operator==(const Cylinder &_cylinder) const;
132 
135  public: Precision Volume() const;
136 
142  public: Precision VolumeBelow(const Plane<Precision> &_plane) const;
143 
151  public: std::optional<Vector3<Precision>>
152  CenterOfVolumeBelow(const Plane<Precision> &_plane) const;
153 
158  public: Vector3<Precision> Centroid() const;
159 
168  public: Precision DensityFromMass(const Precision _mass) const;
169 
182  public: bool SetDensityFromMass(const Precision _mass);
183 
185  private: Precision radius = 0.0;
186 
188  private: Precision length = 0.0;
189 
191  private: Material material;
192 
194  private: Quaternion<Precision> rotOffset =
196  };
197 
201 
205 
209  }
210  }
211 }
212 #include "gz/math/detail/Cylinder.hh"
213 
214 #endif
A representation of a cylinder.
Definition: gz/math/Cylinder.hh:52
void SetRotationalOffset(const Quaternion< Precision > &_rotOffset)
Set the rotation offset. See Quaternion<Precision> RotationalOffset() for details on the rotational o...
void SetLength(const Precision _length)
Set the length in meters.
const Material & Mat() const
Get the material associated with this cylinder.
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 operator==(const Cylinder &_cylinder) const
Check if this cylinder is equal to the provided cylinder. Radius, length, and material properties wil...
bool SetDensityFromMass(const Precision _mass)
Set the density of this cylinder based on a mass value. Density is computed using Precision DensityFr...
Cylinder()=default
Default constructor. The default radius and length are both zero. The default rotational offset is Qu...
bool MassMatrix(MassMatrix3d &_massMat) const
Get the mass matrix for this cylinder. This function is only meaningful if the cylinder's radius,...
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...
Precision Radius() const
Get the radius in meters.
~Cylinder()=default
Destructor.
void SetRadius(const Precision _radius)
Set the radius in meters.
Cylinder(const Precision _length, const Precision _radius, const Quaternion< Precision > &_rotOffset=Quaternion< Precision >::Identity)
Construct a cylinder with a length, radius, and optionally a rotational offset.
Cylinder(const Precision _length, const Precision _radius, const Material &_mat, const Quaternion< Precision > &_rotOffset=Quaternion< Precision >::Identity)
Construct a cylinder with a length, radius, material and optionally a rotational offset.
Precision Length() const
Get 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...
Precision Volume() const
Get the volume of the cylinder in m^3.
void SetMat(const Material &_mat)
Set the material associated with this cylinder.
Vector3< Precision > Centroid() const
Get the centroid of the cylinder. It coincides with the origin of the reference frame defined in the ...
A class for inertial information about a rigid body consisting of the scalar mass and a 3x3 symmetric...
Definition: gz/math/MassMatrix3.hh:46
Contains information about a single material.
Definition: gz/math/Material.hh:66
A plane and related functions.
Definition: gz/math/Plane.hh:39
Cylinder< int > Cylinderi
Cylinder with integer precision.
Definition: gz/math/Cylinder.hh:200
Cylinder< double > Cylinderd
Cylinder with double precision.
Definition: gz/math/Cylinder.hh:204
Cylinder< float > Cylinderf
Cylinder with float precision.
Definition: gz/math/Cylinder.hh:208
Definition: gz/math/AdditivelySeparableScalarField3.hh:28