Gazebo Math

API Reference

7.6.0
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 <optional>
21 #include "gz/math/MassMatrix3.hh"
22 #include "gz/math/Material.hh"
23 #include "gz/math/Quaternion.hh"
24 #include "gz/math/Plane.hh"
25 
26 namespace gz::math
27 {
28  // Foward declarations
29  class SpherePrivate;
30 
31  // Inline bracket to help doxygen filtering.
32  inline namespace GZ_MATH_VERSION_NAMESPACE {
33  //
44  template<typename Precision>
45  class Sphere
46  {
48  public: Sphere() = default;
49 
52  public: explicit Sphere(const Precision _radius);
53 
57  public: Sphere(const Precision _radius, const Material &_mat);
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 
88  public: std::optional< MassMatrix3<Precision> > MassMatrix() const;
89 
92  public: bool operator==(const Sphere &_sphere) const;
93 
96  public: bool operator!=(const Sphere &_sphere) 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 
123  public: Vector3<Precision> Centroid() const;
124 
133  public: Precision DensityFromMass(const Precision _mass) const;
134 
147  public: bool SetDensityFromMass(const Precision _mass);
148 
150  private: Precision radius = 0.0;
151 
153  private: gz::math::Material material;
154  };
155 
159 
163 
167  } // namespace GZ_MATH_VERSION_NAMESPACE
168 } // namespace gz::math
169 #include "gz/math/detail/Sphere.hh"
170 #endif // GZ_MATH_SPHERE_HH_