proj home

Files   Classes   Functions   Hierarchy  

gobjMyCircleDraw Class Reference

Draw a circle or ellipse in xy plane. More...

#include <graphmisc.h>

Inheritance diagram for gobjMyCircleDraw:
Collaboration diagram for gobjMyCircleDraw:

List of all members.

Public Member Functions

void radiusset (doublec radius)
template<typename T >
 gobjMyCircleDraw (point3< T > const &center_, gobjMyCircle const &cir_)
 Pass in a center point and a sampled circle.
template<typename T >
 gobjMyCircleDraw (point2< T > const &center_, gobjMyCircle const &cir_)
 Pass in a center point and a sampled circle.
template<typename T >
 gobjMyCircleDraw (doublec radius, point3< T > const &center_, gobjMyCircle const &cir_)
 Pass in a center point and a sampled circle.
template<typename T >
 gobjMyCircleDraw (doublec radius, point3< T > const &center_, point3< T > const &axis_, gobjMyCircle const &cir_)
 Pass in a center point, an axis which the circle is draw about and a sampled circle.
void draw ()
 Draw a 2D circle in 3D space.

Public Attributes

double scalex
 Multiplier of the x component of the circle cir.
double scaley
 Multiplier of the y component of the circle cir.
point3< double > center
 Translate to center before drawing.
point3< double > axis
 The circles normal, by default is the z-axis.
gobjMyCircle const & cir
 Many drawings can share a common circle as a reference.


Detailed Description

Draw a circle or ellipse in xy plane.

Definition at line 693 of file graphmisc.h.


Constructor & Destructor Documentation

template<typename T >
gobjMyCircleDraw::gobjMyCircleDraw ( point3< T > const &  center_,
gobjMyCircle const &  cir_ 
) [inline]

Pass in a center point and a sampled circle.

Definition at line 718 of file graphmisc.h.

00722     : scalex(1.0), scaley(1.0), center(center_.x,center_.y,center_.z), 
00723       axis(zaxis), cir(cir_) {}

template<typename T >
gobjMyCircleDraw::gobjMyCircleDraw ( point2< T > const &  center_,
gobjMyCircle const &  cir_ 
) [inline]

Pass in a center point and a sampled circle.

Definition at line 728 of file graphmisc.h.

00732     : scalex(1.0), scaley(1.0), center(center_.x,center_.y,0.0), 
00733       axis(zaxis), cir(cir_) {}

template<typename T >
gobjMyCircleDraw::gobjMyCircleDraw ( doublec  radius,
point3< T > const &  center_,
gobjMyCircle const &  cir_ 
) [inline]

Pass in a center point and a sampled circle.

Definition at line 739 of file graphmisc.h.

00744     : scalex(radius), scaley(radius), center(center_.x,center_.y,center_.z), 
00745       axis(zaxis), cir(cir_) {}

template<typename T >
gobjMyCircleDraw::gobjMyCircleDraw ( doublec  radius,
point3< T > const &  center_,
point3< T > const &  axis_,
gobjMyCircle const &  cir_ 
) [inline]

Pass in a center point, an axis which the circle is draw about and a sampled circle.

Definition at line 751 of file graphmisc.h.

00757     : scalex(radius), scaley(radius), center(center_), 
00758       axis(axis_), cir(cir_) {}


Member Function Documentation

void gobjMyCircleDraw::draw (  )  [virtual]

Draw a 2D circle in 3D space.

Implements gobj.

Definition at line 365 of file graphmisc.cpp.

References axis, center, cir, point3< T >::distance(), point3< T >::dot(), crossproduct::evalxyz(), GOBJDEBUGCODE, gobjMyCircle::N, gobjMyCircle::ptx, gobjMyCircle::pty, scalex, scaley, point3< T >::x, point3< T >::y, and point3< T >::z.

Referenced by display(), and graphicsImmediateDeferredTest::display01().

00366 {
00367   GOBJDEBUGCODE
00368   uintc const N(cir.N);
00369   float * const ptx(cir.ptx);
00370   float * const pty(cir.pty);
00371 
00372   glPushMatrix();
00373 
00374   glTranslatef(center.x,center.y,center.z);
00375 
00376   if (axis!=zaxis)
00377   {
00378     assert(axis!=point3<double>(0,0,0));
00379 
00380     point3<double> N;
00381     crossproduct::evalxyz(N,zaxis,axis);
00382 
00383     double angle = acos( axis.dot(zaxis) / axis.distance() );
00384     angle *= 180.0/PI;
00385     glRotated(angle,N.x,N.y,N.z);
00386   }
00387 
00388   //glBegin(GL_LINE_LOOP);
00389   glBegin(GL_LINE);
00390 
00391   if ( (scalex==1.0)&&(scaley==1.0))
00392   {
00393     for (uint i=0; i<N-1; ++i)
00394     {
00395       glVertex2f(ptx[i],pty[i]);
00396       glVertex2f(ptx[i+1],pty[i+1]);
00397     }
00398   }
00399   else
00400   {
00401     for (uint i=0; i<N-1; ++i)
00402     {
00403       glVertex2f(ptx[i]*scalex,pty[i]*scaley);
00404       glVertex2f(ptx[i+1]*scalex,pty[i+1]*scaley);
00405     }
00406   }
00407     //glVertex2f(ptx[i]*radius,pty[i]*radius);
00408 
00409   glEnd();
00410 
00411   glPopMatrix();
00412 }

void gobjMyCircleDraw::radiusset ( doublec  radius  )  [inline]

Definition at line 712 of file graphmisc.h.

References scalex, and scaley.

Referenced by diskinttest::update02(), and diskinttest::update03lineline().

00713     { scalex=radius; scaley=radius; }


Member Data Documentation

The circles normal, by default is the z-axis.

Definition at line 707 of file graphmisc.h.

Referenced by draw(), diskinttest::update01(), diskinttest::update02(), and diskinttest::update03lineline().

Translate to center before drawing.

Definition at line 704 of file graphmisc.h.

Referenced by draw(), diskinttest::update01(), diskinttest::update02(), and diskinttest::update03lineline().

Many drawings can share a common circle as a reference.

Definition at line 710 of file graphmisc.h.

Referenced by draw().

Multiplier of the x component of the circle cir.

Definition at line 699 of file graphmisc.h.

Referenced by draw(), and radiusset().

Multiplier of the y component of the circle cir.

Definition at line 701 of file graphmisc.h.

Referenced by draw(), and radiusset().


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

Generated on Fri Mar 4 00:50:01 2011 for Chelton Evans Source by  doxygen 1.5.8