Gazebo Math

API Reference

6.17.0
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  //
45  template<typename Precision>
46  class Ellipsoid
47  {
50  public: Ellipsoid() = default;
51 
54  public: explicit Ellipsoid(const Vector3<Precision> &_radii);
55 
59  public: Ellipsoid(const Vector3<Precision> &_radii,
60  const Material &_mat);
61 
64  public: Vector3<Precision> Radii() const;
65 
68  public: void SetRadii(const Vector3<Precision> &_radii);
69 
72  public: const Material &Mat() const;
73 
76  public: void SetMat(const Material &_mat);
77 
84  public: std::optional< MassMatrix3<Precision> > MassMatrix() const;
85 
88  public: bool operator==(const Ellipsoid &_ellipsoid) const;
89 
92  public: Precision Volume() const;
93 
99  public: Precision VolumeBelow(const Plane<Precision> &_plane) const;
100 
108  public: std::optional<Vector3<Precision>>
109  CenterOfVolumeBelow(const Plane<Precision> &_plane) const;
110 
115  public: Vector3<Precision> Centroid() const;
116 
125  public: Precision DensityFromMass(const Precision _mass) const;
126 
139  public: bool SetDensityFromMass(const Precision _mass);
140 
143 
145  private: Material material;
146  };
147 
151 
155 
159  }
160  }
161 }
162 #include "gz/math/detail/Ellipsoid.hh"
163 
164 #endif
A representation of a general ellipsoid.
Definition: gz/math/Ellipsoid.hh:47
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.
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...
void SetRadii(const Vector3< Precision > &_radii)
Set the radius in meters.
bool SetDensityFromMass(const Precision _mass)
Set the density of this ellipsoid based on a mass value. Density is computed using Precision DensityF...
Precision DensityFromMass(const Precision _mass) const
Compute the ellipsoid's density given a mass value. The ellipsoid is assumed to be solid with uniform...
Ellipsoid(const Vector3< Precision > &_radii)
Construct a ellipsoid with a Vector3 of three radii.
Ellipsoid()=default
Default constructor. The default radius and length are both zero.
Ellipsoid(const Vector3< Precision > &_radii, const Material &_mat)
Construct a ellipsoid with three radii and a material.
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...
Precision Volume() const
Get the volume of the ellipsoid in m^3.
void SetMat(const Material &_mat)
Set the material associated with this ellipsoid.
std::optional< MassMatrix3< Precision > > MassMatrix() const
Get the mass matrix for this ellipsoid. This function is only meaningful if the ellipsoid's radii and...
Vector3< Precision > Centroid() const
Get the centroid of the ellipsoid. It coincides with the origin of the reference frame defined in the...
Contains information about a single material.
Definition: gz/math/Material.hh:66
A plane and related functions.
Definition: gz/math/Plane.hh:39
Ellipsoid< float > Ellipsoidf
Ellipsoid with float precision.
Definition: gz/math/Ellipsoid.hh:158
Ellipsoid< double > Ellipsoidd
Ellipsoid with double precision.
Definition: gz/math/Ellipsoid.hh:154
Ellipsoid< int > Ellipsoidi
Ellipsoid with integer precision.
Definition: gz/math/Ellipsoid.hh:150
Definition: gz/math/AdditivelySeparableScalarField3.hh:28