All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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  CapsuleShape(double length = 0.0, double radius = 0.0);
38 
40 
42  virtual int getType() override;
43 
46  double getLength() const;
47 
50  double getRadius() const;
51 
54  virtual double getVolume() const override;
55 
58  virtual Vector3d getCenter() const override;
59 
62  Vector3d topCenter() const;
63 
66  Vector3d bottomCenter() const;
67 
71  virtual Matrix33d getSecondMomentOfVolume() const override;
72 
74  virtual 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 
87 private:
89  double m_length;
90 
92  double m_radius;
93 };
94 
95 }; // Math
96 }; // SurgSim
97 
98 #endif // SURGSIM_MATH_CAPSULESHAPE_H
double getLength() const
Get the capsule length (i.e.
Definition: CapsuleShape.cpp:35
Capsule shape: centered on (0, 0, 0), aligned along Y, with length and radius.
Definition: CapsuleShape.h:31
SURGSIM_STATIC_REGISTRATION(BoxShape)
::SurgSim::Math::Vector3d Vector3d
Definition: Shape.h:62
virtual Vector3d getCenter() const override
Get the volumetric center of the shape.
Definition: CapsuleShape.cpp:64
double m_length
Capsule length.
Definition: CapsuleShape.h:89
void setLength(double length)
Set the capsule length (i.e.
Definition: CapsuleShape.cpp:45
SURGSIM_CLASSNAME(SurgSim::Math::CapsuleShape)
virtual Matrix33d getSecondMomentOfVolume() const override
Get the second central moment of the volume, commonly used to calculate the moment of inertia matrix...
Definition: CapsuleShape.cpp:79
Vector3d bottomCenter() const
Return the center of the bottom sphere of the internal cylinder.
Definition: CapsuleShape.cpp:74
void setRadius(double radius)
Set the capsule radius (i.e.
Definition: CapsuleShape.cpp:50
virtual double getVolume() const override
Get the volume of the shape.
Definition: CapsuleShape.cpp:55
virtual int getType() override
Definition: CapsuleShape.cpp:30
double getRadius() const
Get the capsule radius (i.e.
Definition: CapsuleShape.cpp:40
::SurgSim::Math::Matrix33d Matrix33d
Definition: Shape.h:63
Vector3d topCenter() const
Return the center of the top sphere of the internal cylinder.
Definition: CapsuleShape.cpp:69
virtual bool isValid() const override
Definition: CapsuleShape.cpp:119
CapsuleShape(double length=0.0, double radius=0.0)
Constructor.
Definition: CapsuleShape.cpp:24
double m_radius
Capsule radius.
Definition: CapsuleShape.h:92
Generic rigid shape class defining a shape.
Definition: Shape.h:59