All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
BoxShape.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_BOXSHAPE_H
17 #define SURGSIM_MATH_BOXSHAPE_H
18 
19 #include <array>
20 
22 #include "SurgSim/Math/Shape.h"
23 
24 namespace SurgSim
25 {
26 
27 namespace Math
28 {
30 
33 class BoxShape: public Shape
34 {
35 public:
38  BoxShape(double sizeX = 0.0, double sizeY = 0.0, double sizeZ = 0.0);
39 
41 
43  virtual int getType() override;
44 
47  Vector3d getSize() const;
48 
51  double getSizeX() const;
52 
55  double getSizeY() const;
56 
59  double getSizeZ() const;
60 
63  virtual double getVolume() const override;
64 
67  virtual Vector3d getCenter() const override;
68 
72  virtual Matrix33d getSecondMomentOfVolume() const override;
73 
77  Vector3d getVertex(const int i) const;
78 
81  const std::array<Vector3d, 8>& getVertices() const;
82 
84  virtual bool isValid() const override;
85 
86 protected:
87  // Setters in 'protected' sections are for serialization purpose only.
88 
91  void setSizeX(double sizeX);
92 
95  void setSizeY(double sizeY);
96 
99  void setSizeZ(double sizeZ);
100 
101 private:
103  void calculateVertices();
104 
107 
109  std::array<Vector3d,8> m_vertices;
110 };
111 
112 }; // Math
113 
114 }; // SurgSim
115 
116 #endif // SURGSIM_MATH_BOXSHAPE_H
void calculateVertices()
Function that calculates the box vertices.
Definition: BoxShape.cpp:107
double getSizeY() const
Get size in Y direction.
Definition: BoxShape.cpp:49
SURGSIM_STATIC_REGISTRATION(BoxShape)
Box shape: box centered on (0 0 0), aligned with the axis with different sizes along X...
Definition: BoxShape.h:33
void setSizeZ(double sizeZ)
Set size in Z direction.
Definition: BoxShape.cpp:69
Vector3d getVertex(const int i) const
Function that returns the local vertex location, given an index.
Definition: BoxShape.cpp:97
double getSizeZ() const
Get size in Z direction.
Definition: BoxShape.cpp:54
void setSizeY(double sizeY)
Set size in Y direction.
Definition: BoxShape.cpp:64
virtual bool isValid() const override
Definition: BoxShape.cpp:123
void setSizeX(double sizeX)
Set size in X direction.
Definition: BoxShape.cpp:59
BoxShape(double sizeX=0.0, double sizeY=0.0, double sizeZ=0.0)
Constructor.
Definition: BoxShape.cpp:24
virtual double getVolume() const override
Get the volume of the shape.
Definition: BoxShape.cpp:74
virtual Vector3d getCenter() const override
Get the volumetric center of the shape.
Definition: BoxShape.cpp:79
virtual Matrix33d getSecondMomentOfVolume() const override
Get the second central moment of the volume, commonly used to calculate the moment of inertia matrix...
Definition: BoxShape.cpp:84
virtual int getType() override
Definition: BoxShape.cpp:34
const std::array< Vector3d, 8 > & getVertices() const
Function that returns the local vertices' location.
Definition: BoxShape.cpp:102
std::array< Vector3d, 8 > m_vertices
The box vertices.
Definition: BoxShape.h:109
::SurgSim::Math::Matrix33d Matrix33d
Definition: Shape.h:63
Vector3d m_size
The box sizes along the 3 axis respectively {X,Y,Z}.
Definition: BoxShape.h:106
Vector3d getSize() const
Get size of the box.
Definition: BoxShape.cpp:39
Eigen::Matrix< double, 3, 1 > Vector3d
A 3D vector of doubles.
Definition: Vector.h:56
double getSizeX() const
Get size in X direction.
Definition: BoxShape.cpp:44
SURGSIM_CLASSNAME(SurgSim::Math::BoxShape)
Generic rigid shape class defining a shape.
Definition: Shape.h:59