Gazebo Math

API Reference

6.15.1
gz/math/Ellipsoid.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2020 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_ELLIPSOID_HH_
18 #define GZ_MATH_ELLIPSOID_HH_
19 
20 #include <optional>
21 #include "gz/math/MassMatrix3.hh"
22 #include "gz/math/Material.hh"
23 #include "gz/math/Plane.hh"
24 
25 namespace ignition
26 {
27  namespace math
28  {
29  // Inline bracket to help doxygen filtering.
30  inline namespace IGNITION_MATH_VERSION_NAMESPACE {
31  //
39  template<typename Precision>
40  class Ellipsoid
41  {
44  public: Ellipsoid() = default;
45 
48  public: explicit Ellipsoid(const Vector3<Precision> &_radii);
49 
53  public: Ellipsoid(const Vector3<Precision> &_radii,
54  const Material &_mat);
55 
58  public: Vector3<Precision> Radii() const;
59 
62  public: void SetRadii(const Vector3<Precision> &_radii);
63 
66  public: const Material &Mat() const;
67 
70  public: void SetMat(const Material &_mat);
71 
78  public: std::optional< MassMatrix3<Precision> > MassMatrix() const;
79 
82  public: bool operator==(const Ellipsoid &_ellipsoid) const;
83 
86  public: Precision Volume() const;
87 
93  public: Precision VolumeBelow(const Plane<Precision> &_plane) const;
94 
102  public: std::optional<Vector3<Precision>>
103  CenterOfVolumeBelow(const Plane<Precision> &_plane) const;
104 
113  public: Precision DensityFromMass(const Precision _mass) const;
114 
127  public: bool SetDensityFromMass(const Precision _mass);
128 
131 
133  private: Material material;
134  };
135 
139 
143 
147  }
148  }
149 }
150 #include "gz/math/detail/Ellipsoid.hh"
151 
152 #endif
std::optional< MassMatrix3< Precision > > MassMatrix() const
Get the mass matrix for this ellipsoid. This function is only meaningful if the ellipsoid's radii and...
Definition: gz/math/AdditivelySeparableScalarField3.hh:27
A plane and related functions.
Definition: gz/math/Plane.hh:38
Contains information about a single material.
Definition: gz/math/Material.hh:65
bool operator==(const Ellipsoid &_ellipsoid) const
Check if this ellipsoid is equal to the provided ellipsoid. Radius, length, and material properties w...
const Material & Mat() const
Get the material associated with this ellipsoid.
Vector3< Precision > Radii() const
Get the radius in meters.
Precision Volume() const
Get the volume of the ellipsoid in m^3.
bool SetDensityFromMass(const Precision _mass)
Set the density of this ellipsoid based on a mass value. Density is computed using Precision DensityF...
Ellipsoid< double > Ellipsoidd
Ellipsoid with double precision.
Definition: gz/math/Ellipsoid.hh:142
Precision VolumeBelow(const Plane< Precision > &_plane) const
Get the volume of ellipsoid below a given plane in m^3. It is assumed that the center of the ellipsoi...
void SetMat(const Material &_mat)
Set the material associated with this ellipsoid.
A representation of a general ellipsoid.
Definition: gz/math/Ellipsoid.hh:40
Ellipsoid< int > Ellipsoidi
Ellipsoid with integer precision.
Definition: gz/math/Ellipsoid.hh:138
Ellipsoid()=default
Default constructor. The default radius and length are both zero.
Precision DensityFromMass(const Precision _mass) const
Compute the ellipsoid's density given a mass value. The ellipsoid is assumed to be solid with uniform...
void SetRadii(const Vector3< Precision > &_radii)
Set the radius in meters.
Ellipsoid< float > Ellipsoidf
Ellipsoid with float precision.
Definition: gz/math/Ellipsoid.hh:146
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...