Gazebo Math

API Reference

7.5.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 <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  //
40  template<typename Precision>
41  class Sphere
42  {
44  public: Sphere() = default;
45 
48  public: explicit Sphere(const Precision _radius);
49 
53  public: Sphere(const Precision _radius, const Material &_mat);
54 
57  public: Precision Radius() const;
58 
61  public: void SetRadius(const Precision _radius);
62 
65  public: const gz::math::Material &Material() const;
66 
69  public: void SetMaterial(const gz::math::Material &_mat);
70 
77  public: bool MassMatrix(MassMatrix3d &_massMat) const;
78 
84  public: std::optional< MassMatrix3<Precision> > MassMatrix() const;
85 
88  public: bool operator==(const Sphere &_sphere) const;
89 
92  public: bool operator!=(const Sphere &_sphere) const;
93 
96  public: Precision Volume() const;
97 
103  public: Precision VolumeBelow(const Plane<Precision> &_plane) const;
104 
112  public: std::optional<Vector3<Precision>>
113  CenterOfVolumeBelow(const Plane<Precision> &_plane) const;
114 
123  public: Precision DensityFromMass(const Precision _mass) const;
124 
137  public: bool SetDensityFromMass(const Precision _mass);
138 
140  private: Precision radius = 0.0;
141 
143  private: gz::math::Material material;
144  };
145 
149 
153 
157  } // namespace GZ_MATH_VERSION_NAMESPACE
158 } // namespace gz::math
159 #include "gz/math/detail/Sphere.hh"
160 #endif // GZ_MATH_SPHERE_HH_