Gazebo Math

API Reference

6.15.1
gz/math/Sphere.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_SPHERE_HH_
18 #define GZ_MATH_SPHERE_HH_
19 
20 #include "gz/math/MassMatrix3.hh"
21 #include "gz/math/Material.hh"
22 #include "gz/math/Quaternion.hh"
23 #include "gz/math/Plane.hh"
24 
25 namespace ignition
26 {
27  namespace math
28  {
29  // Foward declarations
30  class SpherePrivate;
31 
32  // Inline bracket to help doxygen filtering.
33  inline namespace IGNITION_MATH_VERSION_NAMESPACE {
34  //
41  template<typename Precision>
42  class Sphere
43  {
45  public: Sphere() = default;
46 
49  public: explicit Sphere(const Precision _radius);
50 
54  public: Sphere(const Precision _radius, const Material &_mat);
55 
57  public: ~Sphere() = default;
58 
61  public: Precision Radius() const;
62 
65  public: void SetRadius(const Precision _radius);
66 
69  public: const gz::math::Material &Material() const;
70 
73  public: void SetMaterial(const gz::math::Material &_mat);
74 
81  public: bool MassMatrix(MassMatrix3d &_massMat) const;
82 
85  public: bool operator==(const Sphere &_sphere) const;
86 
89  public: bool operator!=(const Sphere &_sphere) const;
90 
93  public: Precision Volume() const;
94 
100  public: Precision VolumeBelow(const Plane<Precision> &_plane) const;
101 
109  public: std::optional<Vector3<Precision>>
110  CenterOfVolumeBelow(const Plane<Precision> &_plane) const;
111 
120  public: Precision DensityFromMass(const Precision _mass) const;
121 
134  public: bool SetDensityFromMass(const Precision _mass);
135 
137  private: Precision radius = 0.0;
138 
140  private: gz::math::Material material;
141  };
142 
146 
150 
154  }
155  }
156 }
157 #include "gz/math/detail/Sphere.hh"
158 
159 #endif
Precision DensityFromMass(const Precision _mass) const
Compute the sphere's density given a mass value. The sphere is assumed to be solid with uniform densi...
Definition: gz/math/AdditivelySeparableScalarField3.hh:27
A representation of a sphere.
Definition: gz/math/Sphere.hh:42
void SetMaterial(const Material &_mat)
Set the material associated with this sphere.
const Material & Material() const
Get the material associated with this sphere.
A plane and related functions.
Definition: gz/math/Plane.hh:38
Contains information about a single material.
Definition: gz/math/Material.hh:65
bool MassMatrix(MassMatrix3d &_massMat) const
Get the mass matrix for this sphere. This function is only meaningful if the sphere's radius and mate...
~Sphere()=default
Destructor.
Precision VolumeBelow(const Plane< Precision > &_plane) const
Get the volume of sphere below a given plane in m^3. It is assumed that the center of the sphere is o...
void SetRadius(const Precision _radius)
Set the radius in meters.
Precision Radius() const
Get the radius in meters.
Sphere()=default
Default constructor. The default radius is zero.
bool SetDensityFromMass(const Precision _mass)
Set the density of this sphere based on a mass value. Density is computed using Precision DensityFrom...
Sphere< float > Spheref
Sphere with float precision.
Definition: gz/math/Sphere.hh:153
bool operator!=(const Sphere &_sphere) const
Check if this sphere is not equal to the provided sphere. Radius and material properties will be chec...
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...
Precision Volume() const
Get the volume of the sphere in m^3.
Sphere< double > Sphered
Sphere with double precision.
Definition: gz/math/Sphere.hh:149
A class for inertial information about a rigid body consisting of the scalar mass and a 3x3 symmetric...
Definition: gz/math/MassMatrix3.hh:45
Sphere< int > Spherei
Sphere with integer precision.
Definition: gz/math/Sphere.hh:145
bool operator==(const Sphere &_sphere) const
Check if this sphere is equal to the provided sphere. Radius and material properties will be checked.