proj home

Files   Classes   Functions   Hierarchy  

d2simplex Class Reference

A triangle in 2D. More...

#include <d2simplex.h>

Inheritance diagram for d2simplex:
Collaboration diagram for d2simplex:

List of all members.

Public Member Functions

bool const intersects (d2simplex const &s2) const
 Do the two simplexes intersect?
bool const sees (d2simplex const &s2) const
 If one simplex sees the other there is no intersection.
void rotate (doublec theta)
 Anticlockwise rotation of the simplex about its center.
void translate (pt2c &x)
 Shift the simplex.

Public Attributes

point2< double > v [3]
 Ordered in anticlockwise direction.


Detailed Description

A triangle in 2D.

Definition at line 14 of file d2simplex.h.


Member Function Documentation

bool const d2simplex::intersects ( d2simplex const &  s2  )  const

Do the two simplexes intersect?

Reimplemented in d2simplexSeparateAxis.

void d2simplex::rotate ( doublec  theta  ) 

Anticlockwise rotation of the simplex about its center.

Definition at line 16 of file d2simplex.cpp.

References d2homogeneous::matrixMultiply(), d2homogeneous::setRotateAboutPoint(), and v.

Referenced by d2simplextestmenu01::readImmediate().

00017 {
00018   point2<double> c(v[0]);
00019   c += v[1];
00020   c += v[2];
00021   c *= (1.0/3.0);
00022 
00023   d2homogeneous R;
00024 
00025   R.setRotateAboutPoint(theta,c);
00026 
00027   for (uint i=0; i<3; ++i)
00028     R.matrixMultiply(v[i]);
00029 
00030 /*
00031   double const cos_t = cos(theta);
00032   double const sin_t = sin(theta);
00033 
00034   pt2c r1(cos_t,-sin_t);
00035   pt2c r2(sin_t,cos_t);
00036 
00037   pt2 z;
00038   for (uint i=0; i<3; ++i)
00039   {
00040     z.x = r1.dot(v[i]);
00041     z.y = r2.dot(v[i]);
00042     v[i] = z;
00043   }
00044 */
00045 
00046 
00047 }

bool const d2simplex::sees ( d2simplex const &  s2  )  const

If one simplex sees the other there is no intersection.

Reimplemented in d2simplexSeparateAxis.

void d2simplex::translate ( pt2c x  ) 

Shift the simplex.

Definition at line 9 of file d2simplex.cpp.

References v.

Referenced by d2simplextestmenu01::readImmediate(), and d2simplextest::test01().

00010 {
00011   for (uint i=0; i<3; ++i)
00012     v[i] += x; 
00013 }


Member Data Documentation

point2<double> d2simplex::v[3]


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

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