SegmentSegmentCcdStaticContact.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_SEGMENTSEGMENTCCDSTATICCONTACT_H
17 #define SURGSIM_COLLISION_SEGMENTSEGMENTCCDSTATICCONTACT_H
18 
19 #include <array>
20 
21 #include "SurgSim/Math/Vector.h"
22 
23 namespace SurgSim
24 {
25 namespace Collision
26 {
27 
36 {
37 public:
39  {
40  SegmentCcdEdgeTypeR0, // Closest approach occurs at parametric value r = 0
41  SegmentCcdEdgeTypeR1, // Closest approach occurs at parametric value r = 1
42  SegmentCcdEdgeTypeS0, // Closest approach occurs at parametric value s = 0
43  SegmentCcdEdgeTypeS1, // Closest approach occurs at parametric value s = 1
44  SegmentCcdEdgeTypeEdgeSkip, // Closest approach is not at segment boundary (0.0 <= r,s, <= 1.0)
46  };
47 
50 
60  const std::array<SurgSim::Math::Vector3d, 2>& p,
61  const std::array<SurgSim::Math::Vector3d, 2>& q,
62  double distanceEpsilon,
63  double* r, double* s);
64 
75  const std::array<SurgSim::Math::Vector3d, 2>& p,
76  const std::array<SurgSim::Math::Vector3d, 2>& q,
77  double radiusP, double radiusQ,
78  double* r, double* s);
79 
80 protected:
89  const Math::Vector3d& point,
90  const std::array<SurgSim::Math::Vector3d, 2>& p,
91  double thicknessPoint, double thicknessSegment,
92  double* r
93  );
94 
118  SegmentCcdEdgeType computeCollisionEdge(double a, double b, double d,
119  double r, double s, double ratio) const;
120 
140  void computeCollisionParametrics(SegmentCcdEdgeType edge, double a, double b, double c, double d, double e,
141  double ratio, double* r, double* s) const;
142 
156  void computeParallelSegmentParametrics(double a, double b, double d, double* r, double* s) const;
157 
158 private:
160  const double m_degenerateEpsilon;
161 };
162 
163 }; // namespace Collision
164 }; // namespace SurgSim
165 
166 #endif // SURGSIM_COLLISION_SEGMENTSEGMENTCCDSTATICCONTACT_H
const double m_degenerateEpsilon
During collision, points closer than this value are considered a single point.
Definition: SegmentSegmentCcdStaticContact.h:160
Definition: CompoundShapeToGraphics.cpp:29
void computeParallelSegmentParametrics(double a, double b, double d, double *r, double *s) const
Calculate the parametric values that give the minimum distance for two parallel segments value for th...
Definition: SegmentSegmentCcdStaticContact.cpp:371
SegmentCcdEdgeType computeCollisionEdge(double a, double b, double d, double r, double s, double ratio) const
Find the edge to be clamped for the closest point solution using the outline of: https://www.assembla.com/spaces/OpenSurgSim/documents/cRWomWC2er5ykpacwqjQYw/download/cRWomWC2er5ykpacwqjQYw.
Definition: SegmentSegmentCcdStaticContact.cpp:161
SegmentSegmentCcdStaticContact()
Constructor.
Definition: SegmentSegmentCcdStaticContact.cpp:26
Definitions of small fixed-size vector types.
void computeCollisionParametrics(SegmentCcdEdgeType edge, double a, double b, double c, double d, double e, double ratio, double *r, double *s) const
Given an edge indicator, clamp the indicated parametric edge and calculate the minimum parametric val...
Definition: SegmentSegmentCcdStaticContact.cpp:279
SegmentSegmentCcdStaticContact computes if there is contact between two segments at a specific point ...
Definition: SegmentSegmentCcdStaticContact.h:35
SegmentCcdEdgeType
Definition: SegmentSegmentCcdStaticContact.h:38
bool collideStaticPointSegment(const Math::Vector3d &point, const std::array< SurgSim::Math::Vector3d, 2 > &p, double thicknessPoint, double thicknessSegment, double *r)
Determine whether a single point and a segment collide.
Definition: SegmentSegmentCcdStaticContact.cpp:114
bool collideStaticSegmentSegment(const std::array< SurgSim::Math::Vector3d, 2 > &p, const std::array< SurgSim::Math::Vector3d, 2 > &q, double distanceEpsilon, double *r, double *s)
Determine whether two "zero radius" segments collide.
Definition: SegmentSegmentCcdStaticContact.cpp:30
Eigen::Matrix< double, 3, 1 > Vector3d
A 3D vector of doubles.
Definition: Vector.h:57