DART  6.10.1
EllipsoidShape.hpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2011-2021, The DART development contributors
3  * All rights reserved.
4  *
5  * The list of contributors can be found at:
6  * https://github.com/dartsim/dart/blob/master/LICENSE
7  *
8  * This file is provided under the following "BSD-style" License:
9  * Redistribution and use in source and binary forms, with or
10  * without modification, are permitted provided that the following
11  * conditions are met:
12  * * Redistributions of source code must retain the above copyright
13  * notice, this list of conditions and the following disclaimer.
14  * * Redistributions in binary form must reproduce the above
15  * copyright notice, this list of conditions and the following
16  * disclaimer in the documentation and/or other materials provided
17  * with the distribution.
18  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
19  * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
20  * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
21  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
23  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
26  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
27  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
29  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30  * POSSIBILITY OF SUCH DAMAGE.
31  */
32 
33 #ifndef DART_DYNAMICS_ELLIPSOIDSHAPE_HPP_
34 #define DART_DYNAMICS_ELLIPSOIDSHAPE_HPP_
35 
36 #include "dart/dynamics/Shape.hpp"
37 
38 namespace dart {
39 namespace dynamics {
40 
41 class EllipsoidShape : public Shape
42 {
43 public:
45  explicit EllipsoidShape(const Eigen::Vector3d& diameters);
46  // TODO(JS): In order to follow the commonly used convention, change the
47  // constructor to take radii instead of diameters in DART 7.
48 
50  virtual ~EllipsoidShape();
51 
52  // Documentation inherited.
53  const std::string& getType() const override;
54 
56  static const std::string& getStaticType();
57 
60  DART_DEPRECATED(6.2)
61  void setSize(const Eigen::Vector3d& diameters);
62 
65  DART_DEPRECATED(6.2)
66  const Eigen::Vector3d& getSize() const;
67 
69  void setDiameters(const Eigen::Vector3d& diameters);
70 
72  const Eigen::Vector3d& getDiameters() const;
73 
75  void setRadii(const Eigen::Vector3d& radii);
76 
78  const Eigen::Vector3d getRadii() const;
79 
81  static double computeVolume(const Eigen::Vector3d& diameters);
82  // TODO(JS): In order to follow the commonly used convention, change to take
83  // radii instead of diameters in DART 7.
84 
86  static Eigen::Matrix3d computeInertia(
87  const Eigen::Vector3d& diameters, double mass);
88  // TODO(JS): In order to follow the commonly used convention, change to take
89  // radii instead of diameters in DART 7.
90 
91  // Documentation inherited.
92  Eigen::Matrix3d computeInertia(double mass) const override;
93 
95  bool isSphere(void) const;
96 
97 protected:
98  // Documentation inherited.
99  void updateBoundingBox() const override;
100 
101  // Documentation inherited.
102  void updateVolume() const override;
103 
104 private:
106  Eigen::Vector3d mDiameters;
107 };
108 
109 } // namespace dynamics
110 } // namespace dart
111 
112 #endif // DART_DYNAMICS_ELLIPSOIDSHAPE_HPP_
#define DART_DEPRECATED(version)
Definition: Deprecated.hpp:51
Definition: EllipsoidShape.hpp:42
Eigen::Vector3d mDiameters
Diameters of this ellipsoid.
Definition: EllipsoidShape.hpp:106
static double computeVolume(const Eigen::Vector3d &diameters)
Compute volume from given properties.
Definition: EllipsoidShape.cpp:117
bool isSphere(void) const
True if all the radii are exactly eqaul.
Definition: EllipsoidShape.cpp:149
void updateBoundingBox() const override
Updates bounding box.
Definition: EllipsoidShape.cpp:158
static Eigen::Matrix3d computeInertia(const Eigen::Vector3d &diameters, double mass)
Compute moments of inertia of a ellipsoid.
Definition: EllipsoidShape.cpp:125
const Eigen::Vector3d getRadii() const
Get radii of this ellipsoid.
Definition: EllipsoidShape.cpp:111
const std::string & getType() const override
Returns a string representing the shape type.
Definition: EllipsoidShape.cpp:54
void setSize(const Eigen::Vector3d &diameters)
Set diameters of this ellipsoid.
Definition: EllipsoidShape.cpp:67
void updateVolume() const override
Updates volume.
Definition: EllipsoidShape.cpp:166
virtual ~EllipsoidShape()
Destructor.
Definition: EllipsoidShape.cpp:48
const Eigen::Vector3d & getSize() const
Get diameters of this ellipsoid.
Definition: EllipsoidShape.cpp:73
EllipsoidShape(const Eigen::Vector3d &diameters)
Constructor.
Definition: EllipsoidShape.cpp:41
void setRadii(const Eigen::Vector3d &radii)
Set radii of this ellipsoid.
Definition: EllipsoidShape.cpp:100
static const std::string & getStaticType()
Returns shape type for this class.
Definition: EllipsoidShape.cpp:60
const Eigen::Vector3d & getDiameters() const
Get diameters of this ellipsoid.
Definition: EllipsoidShape.cpp:94
void setDiameters(const Eigen::Vector3d &diameters)
Set diameters of this ellipsoid.
Definition: EllipsoidShape.cpp:79
Definition: Shape.hpp:54
Definition: BulletCollisionDetector.cpp:65