proj home

Files   Classes   Functions   Hierarchy  

circleD2< PT, PD > Class Template Reference

Circle and OBB intersection. More...

#include <circleD2.h>

Inheritance diagram for circleD2< PT, PD >:
Collaboration diagram for circleD2< PT, PD >:

List of all members.

Public Member Functions

 circleD2 (PT const &center_, PD const radius_)
 Construct a circle.
boolc intersects (boxOBBhalfspaceD2< PT, PD > &B)
 Do the circle and box intersect?

Public Attributes

PT center
 The circles center.
PD radius
 Circles radius.


Detailed Description

template<typename PT, typename PD>
class circleD2< PT, PD >

Circle and OBB intersection.

Definition at line 12 of file circleD2.h.


Constructor & Destructor Documentation

template<typename PT, typename PD>
circleD2< PT, PD >::circleD2 ( PT const &  center_,
PD const   radius_ 
) [inline]

Construct a circle.

Definition at line 23 of file circleD2.h.

00027     : center(center_), radius(radius_) {}


Member Function Documentation

template<typename PT, typename PD>
boolc circleD2< PT, PD >::intersects ( boxOBBhalfspaceD2< PT, PD > &  B  )  [inline]

Do the circle and box intersect?

Definition at line 37 of file circleD2.h.

References circleD2< PT, PD >::center, boxOBBhalfspaceD2< PT, PD >::cornerpoints(), line< PT, PD >::nearestpointcapped(), line< PT, PD >::nml, line< PT, PD >::pos, and circleD2< PT, PD >::radius.

Referenced by circleD2test::update01().

00038 {
00039   PT pi[4];
00040   B.cornerpoints(pi[0],pi[1],pi[2],pi[3]);
00041 
00042   PD t;
00043 
00044   bool inside=true;
00045   for (uint i=0; i<4; ++i)
00046   {
00047     line<PT,PD> L(pi[(i+1)%4],pi[i],true);
00048     PT normal(-L.nml.y,L.nml.x);
00049     if (normal.dot(center-L.pos)>=0.0)
00050     {
00051       inside=false;
00052 
00053       L.nearestpointcapped(t,center);
00054       if ((L(t)-center).dot()<=radius*radius)
00055         return true;
00056     }
00057   }
00058 
00059   return inside;
00060 }


Member Data Documentation

template<typename PT, typename PD>
PT circleD2< PT, PD >::center

The circles center.

Definition at line 17 of file circleD2.h.

Referenced by circleD2< PT, PD >::intersects(), circleD2test::keyboard01(), and circleD2test::update01().

template<typename PT, typename PD>
PD circleD2< PT, PD >::radius

Circles radius.

Definition at line 19 of file circleD2.h.

Referenced by circleD2< PT, PD >::intersects(), and circleD2test::update01().


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

Generated on Fri Mar 4 00:49:52 2011 for Chelton Evans Source by  doxygen 1.5.8