SphereShape.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_SPHERESHAPE_H
17 #define SURGSIM_MATH_SPHERESHAPE_H
18 
20 #include "SurgSim/Math/Shape.h"
21 
22 namespace SurgSim
23 {
24 
25 namespace Math
26 {
27 SURGSIM_STATIC_REGISTRATION(SphereShape);
28 
30 class SphereShape: public Shape
31 {
32 public:
35  explicit SphereShape(double radius = 0.0);
36 
38 
40  int getType() const override;
41 
44  double getRadius() const;
45 
48  double getVolume() const override;
49 
52  Vector3d getCenter() const override;
53 
57  Matrix33d getSecondMomentOfVolume() const override;
58 
60  bool isValid() const override;
61 
62 protected:
63  // Setters in 'protected' sections are for serialization purpose only.
64 
67  void setRadius(double radius);
68 
69  void updateAabb();
70 private:
72  double m_radius;
73 
74 };
75 
76 }; // Math
77 }; // SurgSim
78 
79 #endif // SURGSIM_MATH_SPHERESHAPE_H
Shape.h
SurgSim::Math::SphereShape::getRadius
double getRadius() const
Get the sphere radius.
Definition: SphereShape.cpp:35
SurgSim::Math::SphereShape::setRadius
void setRadius(double radius)
Set the sphere radius.
Definition: SphereShape.cpp:40
SurgSim::Math::Shape::Matrix33d
::SurgSim::Math::Matrix33d Matrix33d
Definition: Shape.h:69
SurgSim::Math::SphereShape::m_radius
double m_radius
Sphere radius.
Definition: SphereShape.h:72
ObjectFactory.h
SurgSim
Definition: CompoundShapeToGraphics.cpp:29
SurgSim::Math::SphereShape::updateAabb
void updateAabb()
Definition: SphereShape.cpp:46
SurgSim::Math::SphereShape::getCenter
Vector3d getCenter() const override
Get the volumetric center of the shape.
Definition: SphereShape.cpp:58
SurgSim::Math::SphereShape::SphereShape
SphereShape(double radius=0.0)
Constructor.
Definition: SphereShape.cpp:24
SurgSim::Math::SphereShape::getVolume
double getVolume() const override
Get the volume of the shape.
Definition: SphereShape.cpp:53
SurgSim::Math::SphereShape
Sphere shape: sphere centered on (0 0 0), defined with radius.
Definition: SphereShape.h:30
SurgSim::Math::SphereShape::getSecondMomentOfVolume
Matrix33d getSecondMomentOfVolume() const override
Get the second central moment of the volume, commonly used to calculate the moment of inertia matrix.
Definition: SphereShape.cpp:63
SurgSim::Math::SphereShape::SURGSIM_CLASSNAME
SURGSIM_CLASSNAME(SurgSim::Math::SphereShape)
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::SphereShape::isValid
bool isValid() const override
Definition: SphereShape.cpp:76
SurgSim::Math::SphereShape::getType
int getType() const override
Definition: SphereShape.cpp:30