ContactConstraintData.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_PHYSICS_CONTACTCONSTRAINTDATA_H
17 #define SURGSIM_PHYSICS_CONTACTCONSTRAINTDATA_H
18 
21 #include "SurgSim/Math/Vector.h"
22 
23 namespace SurgSim
24 {
25 
26 namespace Physics
27 {
28 
31 {
32 public:
36  m_distance(0.0)
37  {
38  m_normal.setZero();
39  }
40 
43  {
44  }
45 
50  void setPlaneEquation(const SurgSim::Math::Vector3d& n, double d)
51  {
52  m_normal = n;
53  m_distance = d;
54  }
55 
59  {
60  return m_normal;
61  }
62 
65  double getDistance() const
66  {
67  return m_distance;
68  }
69 
72  double getContactTime() const
73  {
74  return m_contact->time;
75  }
76 
78  std::shared_ptr<Collision::Contact> getContact()
79  {
80  return m_contact;
81  }
82 
84  void setContact(const std::shared_ptr<Collision::Contact>& contacts)
85  {
86  m_contact = contacts;
87  }
88 
89 private:
92 
94  double m_distance;
95 
97  std::shared_ptr<Collision::Contact> m_contact;
98 };
99 
100 }; // namespace Physics
101 
102 }; // namespace SurgSim
103 
104 #endif // SURGSIM_PHYSICS_CONTACTCONSTRAINTDATA_H
std::shared_ptr< Collision::Contact > getContact()
Definition: ContactConstraintData.h:78
Definition: CompoundShapeToGraphics.cpp:29
void setContact(const std::shared_ptr< Collision::Contact > &contacts)
Definition: ContactConstraintData.h:84
double getContactTime() const
Gets the time of contact for the collision.
Definition: ContactConstraintData.h:72
Base class for all CosntraintData Derived classes should be specific to a given constraint.
Definition: ConstraintData.h:27
double getDistance() const
Gets the plane distance to the origin.
Definition: ContactConstraintData.h:65
void setPlaneEquation(const SurgSim::Math::Vector3d &n, double d)
Sets the plane equation of the frictionless contact.
Definition: ContactConstraintData.h:50
std::shared_ptr< Collision::Contact > m_contact
The contact that uses this constraint data.
Definition: ContactConstraintData.h:97
const SurgSim::Math::Vector3d & getNormal() const
Gets the plane normal vector.
Definition: ContactConstraintData.h:58
Definitions of small fixed-size vector types.
double m_distance
Plane equation distance to origin.
Definition: ContactConstraintData.h:94
Class for Frictionless contact (only needs a plane equation)
Definition: ContactConstraintData.h:30
SurgSim::Math::Vector3d m_normal
Plane equation normal vector (normalized vector)
Definition: ContactConstraintData.h:91
ContactConstraintData()
Default constructor.
Definition: ContactConstraintData.h:34
Eigen::Matrix< double, 3, 1 > Vector3d
A 3D vector of doubles.
Definition: Vector.h:57
virtual ~ContactConstraintData()
Destructor.
Definition: ContactConstraintData.h:42