SegmentSegmentCcdMovingContact.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_COLLISION_SEGMENTSEGMENTCCDMOVINGCONTACT_H
17 #define SURGSIM_COLLISION_SEGMENTSEGMENTCCDMOVINGCONTACT_H
18 
19 #include <array>
20 
24 
25 namespace SurgSim
26 {
27 namespace Math
28 {
29 class SegmentMeshShape;
30 };
31 
32 namespace Collision
33 {
34 
35 class CollisionPair;
36 
53 {
54 public:
55  static const int SUB_POINTS_PARALLEL_CASE = 5;
56  static const int SUB_POINTS_COPLANAR_CASE = 10;
57 
60 
75  const std::array<Math::Vector3d, 2>& pt0Positions,
76  const std::array<Math::Vector3d, 2>& pt1Positions,
77  const std::array<Math::Vector3d, 2>& qt0Positions,
78  const std::array<Math::Vector3d, 2>& qt1Positions,
79  double thicknessEpsilon,
80  double timePrecisionEpsilon,
81  double* t, double* r, double* s, Math::Vector3d* pToQDir);
82 
98  const std::array<Math::Vector3d, 2>& pt0Positions,
99  const std::array<Math::Vector3d, 2>& pt1Positions,
100  const std::array<Math::Vector3d, 2>& qt0Positions,
101  const std::array<Math::Vector3d, 2>& qt1Positions,
102  double thicknessP,
103  double thicknessQ,
104  double timePrecisionEpsilon,
105  double* t, double* r, double* s, Math::Vector3d* pToQDir);
106 
107 protected:
122  const std::array<Math::Vector3d, 2>& pT0,
123  const std::array<Math::Vector3d, 2>& pT1,
124  const std::array<Math::Vector3d, 2>& qT0,
125  const std::array<Math::Vector3d, 2>& qT1,
126  double thicknessP,
127  double thicknessQ,
128  double timePrecisionEpsilon,
129  double* t, double* r, double* s);
130 
148  const std::array<Math::Vector3d, 2>& pT0,
149  const std::array<Math::Vector3d, 2>& pT1,
150  const std::array<Math::Vector3d, 2>& qT0,
151  const std::array<Math::Vector3d, 2>& qT1,
152  double a, double b,
153  double thicknessP, double thicknessQ,
154  double timePrecisionEpsilon,
155  double* t, double* r, double* s, int depth = 0);
156 
174  const std::array<Math::Vector3d, 2>& pT0, /* Segment 1 at t=0 */
175  const std::array<Math::Vector3d, 2>& pT1, /* Segment 1 at t=1 */
176  const std::array<Math::Vector3d, 2>& qT0, /* Segment 2 at t=0 */
177  const std::array<Math::Vector3d, 2>& qT1, /* Segment 2 at t=1 */
178  double a, double b, /* Interval boundaries */
179  double timePrecisionEpsilon,
180  double thicknessP, double thicknessQ,
181  double* t, double* r, double* s,
182  int depth = 0);
183 
195  const SegmentSegmentCcdIntervalCheck& state,
196  double a, double b, // Interval boundaries
197  double* t, double* r, double* s,
198  int depth = 0);
199 
207  void normalizeSegmentsConsistently(Math::Vector3d* t0, Math::Vector3d* t1, double epsilon) const;
208 
209 private:
223  bool checkForCoplanarContactWithinInterval(double rCurrent, double rNext, double sCurrent, double sNext,
224  const Math::Vector3d& nCurrent, const Math::Vector3d& nNext) const;
225 
227  const double m_distanceEpsilon;
228 
231 
233  std::shared_ptr<SurgSim::Framework::Logger> m_logger;
234 };
235 
236 }; // namespace Collision
237 }; // namespace SurgSim
238 
239 #endif // SURGSIM_COLLISION_SEGMENTSEGMENTCCDMOVINGCONTACT_H
SurgSim::Collision::SegmentSegmentCcdMovingContact::checkForCoplanarContactWithinInterval
bool checkForCoplanarContactWithinInterval(double rCurrent, double rNext, double sCurrent, double sNext, const Math::Vector3d &nCurrent, const Math::Vector3d &nNext) const
Utility routine to perform a series of checks to determine if a collision is likely within an interva...
Definition: SegmentSegmentCcdMovingContact.cpp:519
SurgSim::Collision::SegmentSegmentCcdMovingContact::collideSegmentSegmentCoplanarCase
bool collideSegmentSegmentCoplanarCase(const std::array< Math::Vector3d, 2 > &pT0, const std::array< Math::Vector3d, 2 > &pT1, const std::array< Math::Vector3d, 2 > &qT0, const std::array< Math::Vector3d, 2 > &qT1, double a, double b, double timePrecisionEpsilon, double thicknessP, double thicknessQ, double *t, double *r, double *s, int depth=0)
Manage the specific case of detecting collisions between segments p and q which are coplanar througho...
Definition: SegmentSegmentCcdMovingContact.cpp:309
SegmentSegmentCcdStaticContact.h
SurgSim::Collision::SegmentSegmentCcdMovingContact::collideSegmentSegmentGeneralCase
bool collideSegmentSegmentGeneralCase(const SegmentSegmentCcdIntervalCheck &state, double a, double b, double *t, double *r, double *s, int depth=0)
Manage the general case of detecting collisions between segments p and q over the parametric time int...
Definition: SegmentSegmentCcdMovingContact.cpp:424
SurgSim::Math::Vector3d
Eigen::Matrix< double, 3, 1 > Vector3d
A 3D vector of doubles.
Definition: Vector.h:57
SurgSim
Definition: CompoundShapeToGraphics.cpp:29
SurgSim::Collision::SegmentSegmentCcdMovingContact::collideMovingSegmentSegment
bool collideMovingSegmentSegment(const std::array< Math::Vector3d, 2 > &pt0Positions, const std::array< Math::Vector3d, 2 > &pt1Positions, const std::array< Math::Vector3d, 2 > &qt0Positions, const std::array< Math::Vector3d, 2 > &qt1Positions, double thicknessEpsilon, double timePrecisionEpsilon, double *t, double *r, double *s, Math::Vector3d *pToQDir)
Calculate if, where, and when the segments p and q collide in the interval from t = 0 to t = 1 for "z...
Definition: SegmentSegmentCcdMovingContact.cpp:38
SurgSim::Collision::SegmentSegmentCcdMovingContact::SUB_POINTS_PARALLEL_CASE
static const int SUB_POINTS_PARALLEL_CASE
Definition: SegmentSegmentCcdMovingContact.h:55
SurgSim::Collision::SegmentSegmentCcdMovingContact::m_staticTest
Collision::SegmentSegmentCcdStaticContact m_staticTest
Utility class for testing interval boundary collisions.
Definition: SegmentSegmentCcdMovingContact.h:230
SegmentSegmentCcdIntervalCheck.h
Logger.h
SurgSim::Collision::SegmentSegmentCcdMovingContact::SegmentSegmentCcdMovingContact
SegmentSegmentCcdMovingContact()
Constructor.
Definition: SegmentSegmentCcdMovingContact.cpp:33
SurgSim::Collision::SegmentSegmentCcdMovingContact::collideSegmentSegmentBaseCase
bool collideSegmentSegmentBaseCase(const std::array< Math::Vector3d, 2 > &pT0, const std::array< Math::Vector3d, 2 > &pT1, const std::array< Math::Vector3d, 2 > &qT0, const std::array< Math::Vector3d, 2 > &qT1, double thicknessP, double thicknessQ, double timePrecisionEpsilon, double *t, double *r, double *s)
Manage the collision of moving segments as a series of cases based on the segment relationships over ...
Definition: SegmentSegmentCcdMovingContact.cpp:82
SurgSim::Collision::SegmentSegmentCcdStaticContact
SegmentSegmentCcdStaticContact computes if there is contact between two segments at a specific point ...
Definition: SegmentSegmentCcdStaticContact.h:35
SurgSim::Collision::SegmentSegmentCcdMovingContact::SUB_POINTS_COPLANAR_CASE
static const int SUB_POINTS_COPLANAR_CASE
Definition: SegmentSegmentCcdMovingContact.h:56
SurgSim::Collision::SegmentSegmentCcdMovingContact::m_logger
std::shared_ptr< SurgSim::Framework::Logger > m_logger
Logger.
Definition: SegmentSegmentCcdMovingContact.h:233
SurgSim::Collision::SegmentSegmentCcdMovingContact
SegmentSegmentCcdMovingContact computes the self collisions among a SegmentMesh under motion at two t...
Definition: SegmentSegmentCcdMovingContact.h:52
SurgSim::Collision::SegmentSegmentCcdIntervalCheck
SegmentSegmentCcdIntervalCheck uses the Interval classes including the LinearMotion and Polynomial fa...
Definition: SegmentSegmentCcdIntervalCheck.h:37
SurgSim::Collision::SegmentSegmentCcdMovingContact::collideSegmentSegmentParallelCase
bool collideSegmentSegmentParallelCase(const std::array< Math::Vector3d, 2 > &pT0, const std::array< Math::Vector3d, 2 > &pT1, const std::array< Math::Vector3d, 2 > &qT0, const std::array< Math::Vector3d, 2 > &qT1, double a, double b, double thicknessP, double thicknessQ, double timePrecisionEpsilon, double *t, double *r, double *s, int depth=0)
Manage the specific case of detecting collisions between segments p and q which are parallel througho...
Definition: SegmentSegmentCcdMovingContact.cpp:197
SurgSim::Collision::SegmentSegmentCcdMovingContact::normalizeSegmentsConsistently
void normalizeSegmentsConsistently(Math::Vector3d *t0, Math::Vector3d *t1, double epsilon) const
Safely normalize segments t0 and t1 consistently with each other.
Definition: SegmentSegmentCcdMovingContact.cpp:476
SurgSim::Collision::SegmentSegmentCcdMovingContact::m_distanceEpsilon
const double m_distanceEpsilon
Minimum distance precision epsilon used in continuous collision detection.
Definition: SegmentSegmentCcdMovingContact.h:227