CapsuleShape.h
Go to the documentation of this file.
1 // This file is a part of the OpenSurgSim project.
2 // Copyright 2013, SimQuest Solutions Inc.
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 #ifndef SURGSIM_MATH_CAPSULESHAPE_H
17 #define SURGSIM_MATH_CAPSULESHAPE_H
18 
20 #include "SurgSim/Math/Shape.h"
21 
22 namespace SurgSim
23 {
24 
25 namespace Math
26 {
27 SURGSIM_STATIC_REGISTRATION(CapsuleShape);
28 
31 class CapsuleShape: public Shape
32 {
33 public:
37  explicit CapsuleShape(double length = 0.0, double radius = 0.0);
38 
40 
42  int getType() const override;
43 
46  double getLength() const;
47 
50  double getRadius() const;
51 
54  double getVolume() const override;
55 
58  Vector3d getCenter() const override;
59 
62  Vector3d topCenter() const;
63 
66  Vector3d bottomCenter() const;
67 
71  Matrix33d getSecondMomentOfVolume() const override;
72 
74  bool isValid() const override;
75 
76 protected:
77  // Setters in 'protected' sections are for serialization purpose only.
78 
81  void setLength(double length);
82 
85  void setRadius(double radius);
86  void updateAabb();
87 private:
89  double m_length;
90 
92  double m_radius;
93 };
94 
95 }; // Math
96 }; // SurgSim
97 
98 #endif // SURGSIM_MATH_CAPSULESHAPE_H
Shape.h
SurgSim::Math::CapsuleShape
Capsule shape: centered on (0, 0, 0), aligned along Y, with length and radius.
Definition: CapsuleShape.h:31
SurgSim::Math::CapsuleShape::setRadius
void setRadius(double radius)
Set the capsule radius (i.e.
Definition: CapsuleShape.cpp:52
SurgSim::Math::CapsuleShape::CapsuleShape
CapsuleShape(double length=0.0, double radius=0.0)
Constructor.
Definition: CapsuleShape.cpp:24
SurgSim::Math::CapsuleShape::bottomCenter
Vector3d bottomCenter() const
Return the center of the bottom sphere of the internal cylinder.
Definition: CapsuleShape.cpp:77
SurgSim::Math::CapsuleShape::getVolume
double getVolume() const override
Get the volume of the shape.
Definition: CapsuleShape.cpp:58
SurgSim::Math::Shape::Matrix33d
::SurgSim::Math::Matrix33d Matrix33d
Definition: Shape.h:69
SurgSim::Math::CapsuleShape::getLength
double getLength() const
Get the capsule length (i.e.
Definition: CapsuleShape.cpp:36
SurgSim::Math::CapsuleShape::getType
int getType() const override
Definition: CapsuleShape.cpp:31
SurgSim::Math::CapsuleShape::getRadius
double getRadius() const
Get the capsule radius (i.e.
Definition: CapsuleShape.cpp:41
SurgSim::Math::CapsuleShape::topCenter
Vector3d topCenter() const
Return the center of the top sphere of the internal cylinder.
Definition: CapsuleShape.cpp:72
ObjectFactory.h
SurgSim
Definition: CompoundShapeToGraphics.cpp:29
SurgSim::Math::CapsuleShape::setLength
void setLength(double length)
Set the capsule length (i.e.
Definition: CapsuleShape.cpp:46
SurgSim::Math::CapsuleShape::getSecondMomentOfVolume
Matrix33d getSecondMomentOfVolume() const override
Get the second central moment of the volume, commonly used to calculate the moment of inertia matrix.
Definition: CapsuleShape.cpp:82
SurgSim::Math::CapsuleShape::m_length
double m_length
Capsule length.
Definition: CapsuleShape.h:89
SurgSim::Math::CapsuleShape::m_radius
double m_radius
Capsule radius.
Definition: CapsuleShape.h:92
SurgSim::Math::CapsuleShape::isValid
bool isValid() const override
Definition: CapsuleShape.cpp:122
SurgSim::Math::CapsuleShape::updateAabb
void updateAabb()
Definition: CapsuleShape.cpp:127
SurgSim::Math::Shape
Generic rigid shape class defining a shape.
Definition: Shape.h:65
SurgSim::Math::Shape::Vector3d
::SurgSim::Math::Vector3d Vector3d
Definition: Shape.h:68
SurgSim::Math::CapsuleShape::getCenter
Vector3d getCenter() const override
Get the volumetric center of the shape.
Definition: CapsuleShape.cpp:67
SurgSim::Math::CapsuleShape::SURGSIM_CLASSNAME
SURGSIM_CLASSNAME(SurgSim::Math::CapsuleShape)