proj home

Files   Classes   Functions   Hierarchy  

d3tesstransform Class Reference

Apply 2D transforms to the meshes points. More...

#include <d3tesstransform.h>

Collaboration diagram for d3tesstransform:

List of all members.

Public Member Functions

void transEval ()
 Apply trans to all the points in the mesh.
 d3tesstransform (d3tess &_tess)
 Constructor.
void rotate (double const theta)
 Rotate every point about the origin.
void multiply (pt2c &row1, pt2c &row2)
 Multiply every point by the transform.
void translate (pt2c &x)
 Shift every point in the mesh by x.

Public Attributes

d3tesstess
 The tessellation.
d2homogeneous trans
 The current transform.


Detailed Description

Apply 2D transforms to the meshes points.

There are two ways of using this class. Either use the direct methods to change the mesh or configure trans and call transEval().

The direct methods are simple and as they do not use a 3 by 3 matrix they are more efficient that the homogeneous transform.

But efficiency is relative. The homogeneous trans can have multiple transforms applied to it by multiplying with other d2homogeneous transforms.

It is also easy to pre compute the transform and forever use again by configuring trans and afterwards calling transEval() as opposed for example to using rotate(theta) which re calculates the tranform every time it is called.

Definition at line 31 of file d3tesstransform.h.


Constructor & Destructor Documentation

d3tesstransform::d3tesstransform ( d3tess _tess  ) 

Constructor.

Definition at line 7 of file d3tesstransform.cpp.

00008   : tess(_tess)
00009 {
00010 }


Member Function Documentation

void d3tesstransform::multiply ( pt2c row1,
pt2c row2 
)

Multiply every point by the transform.

Definition at line 13 of file d3tesstransform.cpp.

References point2< T >::dot(), d3tess::pt, and tess.

Referenced by rotate().

00014 {
00015   vector<pt3> & pt(tess.pt);
00016   uintc sz = pt.size();
00017   for ( uint i=1; i<sz; ++i )
00018   {
00019     pt2c w(pt[i]);
00020     pt[i].x = row1.dot(w);
00021     pt[i].y = row2.dot(w);
00022   }
00023 }

void d3tesstransform::rotate ( double const   theta  ) 

Rotate every point about the origin.

Definition at line 36 of file d3tesstransform.cpp.

References multiply().

Referenced by d3meshpartitiondraw::rotate().

00037 {
00038   double const cos_t = cos(theta);
00039   double const sin_t = sin(theta);
00040   pt2c r1(cos_t,-sin_t);
00041   pt2c r2(sin_t,cos_t);
00042 
00043   multiply(r1,r2);
00044 }

void d3tesstransform::transEval (  ) 

Apply trans to all the points in the mesh.

Definition at line 47 of file d3tesstransform.cpp.

References d2homogeneous::matrixMultiply(), d3tess::pt, tess, trans, point3< T >::x, point3< T >::y, and point3< T >::z.

00048 {
00049   vector<pt3> & pt(tess.pt);
00050   uintc sz = pt.size();
00051   point3<double> t;
00052   point3<double> *p;
00053   double c;
00054   for ( uint i=1; i<sz; ++i )
00055   {
00056     p = & pt[i]; 
00057     // Preserve the c value of the point
00058     c = p->z;
00059     t.x = p->x;
00060     t.y = p->y;
00061     // Homogeneous points have 1 as their z value
00062     t.z = 1.0;
00063     
00064     trans.matrixMultiply(*p,t);
00065    
00066     // Restore the c value of the point
00067     p->z = c;
00068   }
00069 }

void d3tesstransform::translate ( pt2c x  ) 

Shift every point in the mesh by x.

Definition at line 25 of file d3tesstransform.cpp.

References d3tess::pt, tess, point2< T >::x, and point2< T >::y.

Referenced by d3meshpartitiondraw::translate().

00026 {
00027   vector<pt3> & pt(tess.pt);
00028   uintc sz = pt.size();
00029   for ( uint i=1; i<sz; ++i )
00030   {
00031     pt[i].x += x.x;
00032     pt[i].y += x.y;
00033   }
00034 }


Member Data Documentation

The tessellation.

Definition at line 36 of file d3tesstransform.h.

Referenced by multiply(), transEval(), and translate().

The current transform.

Definition at line 39 of file d3tesstransform.h.

Referenced by transEval().


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

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