NLPACS::CEdgeCollide Class Reference

Collisions against edge in 2D. More...

#include <edge_collide.h>

Inherited by NLPACS::CEdgeCollideNode.

List of all members.

Public Types

enum  TPointMoveProblem {
  ParallelEdges = 0, StartOnEdge, StopOnEdge, TraverseEndPoint,
  EdgeNull, PointMoveProblemCount
}

Public Member Functions

void make (const CVector2f &p0, const CVector2f &p1)
CRational64 testPointMove (const CVector2f &start, const CVector2f &end, TPointMoveProblem &moveBug)
 return 1 either if no collision occurs.
float testCircleMove (const CVector2f &start, const CVector2f &delta, float radius, CVector2f &normal)
 return 1 either if the circle moves away from the line, or no collision occurs.
float testBBoxMove (const CVector2f &start, const CVector2f &delta, const CVector2f bbox[4], CVector2f &normal)
 return 1 either if the bbox moves away from the line, or no collision occurs.
bool testBBoxCollide (const CVector2f bbox[4])
 return true if this oriented bbox collide this edge.

Public Attributes

CVector2f P0
CVector2f P1
CVector2f Dir
CVector2f Norm
float A0
float A1
float C

Private Member Functions

bool testEdgeMove (const CVector2f &q0, const CVector2f &q1, const CVector2f &delta, float &tMin, float &tMax, bool &normalOnBox)
 test if edge collide against me.

Detailed Description

Collisions against edge in 2D.

Author:
Lionel Berenguier
Nevrax France
Date:
2001

Definition at line 178 of file edge_collide.h.


Member Enumeration Documentation

Enumerator:
ParallelEdges 
StartOnEdge 
StopOnEdge 
TraverseEndPoint 
EdgeNull 
PointMoveProblemCount 

Definition at line 181 of file edge_collide.h.


Member Function Documentation

void NLPACS::CEdgeCollide::make ( const CVector2f p0,
const CVector2f p1 
)
bool NLPACS::CEdgeCollide::testBBoxCollide ( const CVector2f  bbox[4]  ) 

return true if this oriented bbox collide this edge.

Parameters:
bbox 4 points of the bbox, in CCW.
Returns:
true if collision occurs.

Definition at line 654 of file edge_collide.cpp.

References P0, P1, and NLMISC::CVector2f::x.

Referenced by NLPACS::CGlobalRetriever::testRotCollisionWithCollisionChains().

float NLPACS::CEdgeCollide::testBBoxMove ( const CVector2f start,
const CVector2f delta,
const CVector2f  bbox[4],
CVector2f normal 
)

return 1 either if the bbox moves away from the line, or no collision occurs.

Else return a [0,1[ interval. If collision occurs (ie return<1), return in "normal" the normal of the collision. It may be normal of edge (+-), or normal against a point of the edge.

Parameters:
bbox 4 points of the bbox at start. start must be the barycentre of those points.

Definition at line 556 of file edge_collide.cpp.

References C, min, Norm, testEdgeMove(), NLMISC::CVector2f::x, and NLMISC::CVector2f::y.

Referenced by NLPACS::CGlobalRetriever::testCollisionWithCollisionChains().

float NLPACS::CEdgeCollide::testCircleMove ( const CVector2f start,
const CVector2f delta,
float  radius,
CVector2f normal 
)

return 1 either if the circle moves away from the line, or no collision occurs.

Else return a [0,1[ interval. If collision occurs (ie return<1), return in "normal" the normal of the collision. It may be normal of edge (+-), or normal against a point of the edge.

Definition at line 264 of file edge_collide.cpp.

References A0, A1, C, Dir, NLMISC::CVector2f::isNull(), min, Norm, NLMISC::CVector2f::normalize(), P0, P1, and NLPACS::testCirclePoint().

Referenced by NLPACS::CGlobalRetriever::testCollisionWithCollisionChains().

bool NLPACS::CEdgeCollide::testEdgeMove ( const CVector2f q0,
const CVector2f q1,
const CVector2f delta,
float tMin,
float tMax,
bool normalOnBox 
) [private]

test if edge collide against me.

if true, return time intervals of collisions (]-oo, +oo[). NB: for simplicity, if lines are //, return false.

Definition at line 391 of file edge_collide.cpp.

References NLPACS::EdgeCollideEpsilon, min, NLMISC::CVector2f::norm(), P0, P1, NLMISC::CVector2d::sqrnorm(), NLMISC::CVector2d::x, and NLMISC::CVector2d::y.

Referenced by testBBoxMove().

CRational64 NLPACS::CEdgeCollide::testPointMove ( const CVector2f start,
const CVector2f end,
TPointMoveProblem moveBug 
)

return 1 either if no collision occurs.

Else return a [0,1[ interval. return -1 if precision problem (see below). This method is used by CGlobalRetriever::doMove(). UnManageables cases arise when:

  • the movement start/stop on a edge (dist==0). In this case, don't know on what surface we arrive (before or after).
  • the movement is // to the edge and collide with it. same problem than stop on an edge.
  • the movement traverse the edge on an endpoint. In this case, there is 2+ edges sharing the point, and result is undefined. On thoses cases, moveBug is filled, and -1 is returned.

Definition at line 58 of file edge_collide.cpp.

References EdgeNull, NLMISC::fsgn(), nlassert, P0, P1, ParallelEdges, StartOnEdge, StopOnEdge, TraverseEndPoint, NLMISC::CVector2f::x, and NLMISC::CVector2f::y.

Referenced by NLPACS::CGlobalRetriever::testMovementWithCollisionChains().


Member Data Documentation

Definition at line 188 of file edge_collide.h.

Referenced by make(), and testCircleMove().

Definition at line 188 of file edge_collide.h.

Referenced by make(), and testCircleMove().

Definition at line 189 of file edge_collide.h.

Referenced by make(), testBBoxMove(), and testCircleMove().

Definition at line 187 of file edge_collide.h.

Referenced by make(), and testCircleMove().

Definition at line 185 of file edge_collide.h.

Referenced by make(), testBBoxCollide(), testCircleMove(), testEdgeMove(), and testPointMove().

Definition at line 186 of file edge_collide.h.

Referenced by make(), testBBoxCollide(), testCircleMove(), testEdgeMove(), and testPointMove().


The documentation for this class was generated from the following files:

Generated on Thu Jan 7 08:30:21 2010 for NeL by  doxygen 1.6.1