SegmentSegmentCcdStaticContact.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_SEGMENTSEGMENTCCDSTATICCONTACT_H
#define SURGSIM_COLLISION_SEGMENTSEGMENTCCDSTATICCONTACT_H
#include <array>
#include "SurgSim/Math/Vector.h"
namespace SurgSim
{
namespace Collision
{
class SegmentSegmentCcdStaticContact
{
public:
enum SegmentCcdEdgeType
{
SegmentCcdEdgeTypeR0, // Closest approach occurs at parametric value r = 0
SegmentCcdEdgeTypeR1, // Closest approach occurs at parametric value r = 1
SegmentCcdEdgeTypeS0, // Closest approach occurs at parametric value s = 0
SegmentCcdEdgeTypeS1, // Closest approach occurs at parametric value s = 1
SegmentCcdEdgeTypeEdgeSkip, // Closest approach is not at segment boundary (0.0 <= r,s, <= 1.0)
SegmentCcdEdgeTypeEdgeInvalid // Invalid value
};
SegmentSegmentCcdStaticContact();
bool collideStaticSegmentSegment(
const std::array<SurgSim::Math::Vector3d, 2>& p,
const std::array<SurgSim::Math::Vector3d, 2>& q,
double distanceEpsilon,
double* r, double* s);
bool collideStaticSegmentSegment(
const std::array<SurgSim::Math::Vector3d, 2>& p,
const std::array<SurgSim::Math::Vector3d, 2>& q,
double radiusP, double radiusQ,
double* r, double* s);
protected:
bool collideStaticPointSegment(
const Math::Vector3d& point,
const std::array<SurgSim::Math::Vector3d, 2>& p,
double thicknessPoint, double thicknessSegment,
double* r
);
SegmentCcdEdgeType computeCollisionEdge(double a, double b, double d,
double r, double s, double ratio) const;
void computeCollisionParametrics(SegmentCcdEdgeType edge, double a, double b, double c, double d, double e,
double ratio, double* r, double* s) const;
void computeParallelSegmentParametrics(double a, double b, double d, double* r, double* s) const;
private:
const double m_degenerateEpsilon;
};
}; // namespace Collision
}; // namespace SurgSim
#endif // SURGSIM_COLLISION_SEGMENTSEGMENTCCDSTATICCONTACT_H
SurgSim::Collision::SegmentSegmentCcdStaticContact::m_degenerateEpsilon
const double m_degenerateEpsilon
During collision, points closer than this value are considered a single point.
Definition: SegmentSegmentCcdStaticContact.h:160
SurgSim
Definition: CompoundShapeToGraphics.cpp:29
SurgSim::Collision::SegmentSegmentCcdStaticContact::SegmentCcdEdgeTypeEdgeSkip
Definition: SegmentSegmentCcdStaticContact.h:44
SurgSim::Collision::SegmentSegmentCcdStaticContact::SegmentCcdEdgeTypeEdgeInvalid
Definition: SegmentSegmentCcdStaticContact.h:45
SurgSim::Collision::SegmentSegmentCcdStaticContact::computeParallelSegmentParametrics
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
SurgSim::Collision::SegmentSegmentCcdStaticContact::SegmentCcdEdgeTypeR1
Definition: SegmentSegmentCcdStaticContact.h:41
SurgSim::Collision::SegmentSegmentCcdStaticContact::computeCollisionEdge
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
SurgSim::Collision::SegmentSegmentCcdStaticContact::SegmentSegmentCcdStaticContact
SegmentSegmentCcdStaticContact()
Constructor.
Definition: SegmentSegmentCcdStaticContact.cpp:26
SurgSim::Collision::SegmentSegmentCcdStaticContact::SegmentCcdEdgeTypeS1
Definition: SegmentSegmentCcdStaticContact.h:43
Vector.h
Definitions of small fixed-size vector types.
SurgSim::Collision::SegmentSegmentCcdStaticContact::computeCollisionParametrics
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
SurgSim::Collision::SegmentSegmentCcdStaticContact
SegmentSegmentCcdStaticContact computes if there is contact between two segments at a specific point ...
Definition: SegmentSegmentCcdStaticContact.h:35
SurgSim::Collision::SegmentSegmentCcdStaticContact::SegmentCcdEdgeType
SegmentCcdEdgeType
Definition: SegmentSegmentCcdStaticContact.h:38
SurgSim::Collision::SegmentSegmentCcdStaticContact::collideStaticPointSegment
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
SurgSim::Collision::SegmentSegmentCcdStaticContact::SegmentCcdEdgeTypeS0
Definition: SegmentSegmentCcdStaticContact.h:42
SurgSim::Collision::SegmentSegmentCcdStaticContact::collideStaticSegmentSegment
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
SurgSim::Math::Vector3d
Eigen::Matrix< double, 3, 1 > Vector3d
A 3D vector of doubles.
Definition: Vector.h:57
SurgSim::Collision::SegmentSegmentCcdStaticContact::SegmentCcdEdgeTypeR0
Definition: SegmentSegmentCcdStaticContact.h:40