SegmentSegmentCcdMovingContact.h
Go to the documentation of this file.
// This file is a part of the OpenSurgSim project.
// Copyright 2013, SimQuest Solutions Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef SURGSIM_COLLISION_SEGMENTSEGMENTCCDMOVINGCONTACT_H
#define SURGSIM_COLLISION_SEGMENTSEGMENTCCDMOVINGCONTACT_H
#include <array>
#include "SurgSim/Collision/SegmentSegmentCcdIntervalCheck.h"
#include "SurgSim/Collision/SegmentSegmentCcdStaticContact.h"
#include "SurgSim/Framework/Logger.h"
namespace SurgSim
{
namespace Math
{
class SegmentMeshShape;
};
namespace Collision
{
class CollisionPair;
class SegmentSegmentCcdMovingContact
{
public:
static const int SUB_POINTS_PARALLEL_CASE = 5;
static const int SUB_POINTS_COPLANAR_CASE = 10;
SegmentSegmentCcdMovingContact();
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);
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 thicknessP,
double thicknessQ,
double timePrecisionEpsilon,
double* t, double* r, double* s, Math::Vector3d* pToQDir);
protected:
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);
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);
bool collideSegmentSegmentCoplanarCase(
const std::array<Math::Vector3d, 2>& pT0, /* Segment 1 at t=0 */
const std::array<Math::Vector3d, 2>& pT1, /* Segment 1 at t=1 */
const std::array<Math::Vector3d, 2>& qT0, /* Segment 2 at t=0 */
const std::array<Math::Vector3d, 2>& qT1, /* Segment 2 at t=1 */
double a, double b, /* Interval boundaries */
double timePrecisionEpsilon,
double thicknessP, double thicknessQ,
double* t, double* r, double* s,
int depth = 0);
bool collideSegmentSegmentGeneralCase(
const SegmentSegmentCcdIntervalCheck& state,
double a, double b, // Interval boundaries
double* t, double* r, double* s,
int depth = 0);
void normalizeSegmentsConsistently(Math::Vector3d* t0, Math::Vector3d* t1, double epsilon) const;
private:
bool checkForCoplanarContactWithinInterval(double rCurrent, double rNext, double sCurrent, double sNext,
const Math::Vector3d& nCurrent, const Math::Vector3d& nNext) const;
const double m_distanceEpsilon;
Collision::SegmentSegmentCcdStaticContact m_staticTest;
std::shared_ptr<SurgSim::Framework::Logger> m_logger;
};
}; // namespace Collision
}; // namespace SurgSim
#endif // SURGSIM_COLLISION_SEGMENTSEGMENTCCDMOVINGCONTACT_H
SurgSim
Definition: CompoundShapeToGraphics.cpp:29
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::SegmentSegmentCcdMovingContact::m_distanceEpsilon
const double m_distanceEpsilon
Minimum distance precision epsilon used in continuous collision detection.
Definition: SegmentSegmentCcdMovingContact.h:227
SurgSim::Collision::SegmentSegmentCcdMovingContact::m_staticTest
Collision::SegmentSegmentCcdStaticContact m_staticTest
Utility class for testing interval boundary collisions.
Definition: SegmentSegmentCcdMovingContact.h:230
SegmentSegmentCcdStaticContact.h
Logger.h
SurgSim::Collision::SegmentSegmentCcdStaticContact
SegmentSegmentCcdStaticContact computes if there is contact between two segments at a specific point ...
Definition: SegmentSegmentCcdStaticContact.h:35
SegmentSegmentCcdIntervalCheck.h
SurgSim::Math::Vector3d
Eigen::Matrix< double, 3, 1 > Vector3d
A 3D vector of doubles.
Definition: Vector.h:57
SurgSim::Collision::SegmentSegmentCcdIntervalCheck
SegmentSegmentCcdIntervalCheck uses the Interval classes including the LinearMotion and Polynomial fa...
Definition: SegmentSegmentCcdIntervalCheck.h:37