proj home

Files   Classes   Functions   Hierarchy  

gobjMyArrow Class Reference

Draw a primitive flat arrow in 3D space. More...

#include <graphmisc.h>

Inheritance diagram for gobjMyArrow:
Collaboration diagram for gobjMyArrow:

List of all members.

Public Member Functions

 gobjMyArrow (point3< double > const &p0_, point3< double > const &p1_, doublec headlength_, doublec headwidth_, doublec delta_)
void draw ()
 Draw the object.

Public Attributes

point3< double > p0
 The start of the arrow.
point3< double > p1
 The end of the arrow.
doublec headlength
 The length of the head.
doublec headwidth
 The width or height of the arrow head.
double delta


Detailed Description

Draw a primitive flat arrow in 3D space.

Definition at line 819 of file graphmisc.h.


Constructor & Destructor Documentation

gobjMyArrow::gobjMyArrow ( point3< double > const &  p0_,
point3< double > const &  p1_,
doublec  headlength_,
doublec  headwidth_,
doublec  delta_ 
)

Definition at line 212 of file graphmisc.cpp.

References delta.

00219   : p0(_p0), p1(_p1), headlength(_headlength),
00220     headwidth(_headwidth), delta(_delta)
00221 {
00222   assert(delta>=0.0);
00223   assert(delta*2.0<1.0);
00224   // The arrow head length must be <= the arrow length.
00225   double len = (p1-p0).distance();
00226   assert(headlength <= len*(1.0-2.0*delta));
00227 }


Member Function Documentation

void gobjMyArrow::draw (  )  [virtual]

Draw the object.

Implements gobj.

Definition at line 229 of file graphmisc.cpp.

References delta, point3< T >::distance(), GOBJDEBUGCODE, headlength, headwidth, p0, p1, point3< T >::x, point3< T >::y, and point3< T >::z.

00230 {
00231   GOBJDEBUGCODE
00232   point3<double> p01 = p1 - p0;
00233   double len = p01.distance();
00234 
00235   if (len==0.0)
00236     return;
00237 
00238   p01 *= 1.0/len;
00239 
00240   // p2 is the start of the arrow.
00241   point3<double> p2 = p0 + p01*delta;
00242   // p3 is the end of the arrow.
00243   point3<double> p3 = p0 + p01*(1.0-delta);
00244 
00245   point3<double> q(-p01.y,p01.x,p01.z);
00246   //q.normalize();
00247   point3<double> p4 = p3 - p01*headlength;
00248   point3<double> p5 = p4 + q*headwidth;
00249   point3<double> p6 = p4 - q*headwidth;
00250 
00251   glBegin(GL_LINES);
00252   glVertex3f(p2.x,p2.y,p2.z);
00253   glVertex3f(p3.x,p3.y,p3.z);
00254   glEnd();
00255 
00256   glBegin(GL_TRIANGLES);
00257   glVertex3f(p3.x,p3.y,p3.z);
00258   glVertex3f(p5.x,p5.y,p5.z);
00259   glVertex3f(p6.x,p6.y,p6.z);
00260   glVertex3f(p6.x,p6.y,p6.z);
00261   glVertex3f(p5.x,p5.y,p5.z);
00262   glVertex3f(p3.x,p3.y,p3.z);
00263   glEnd();
00264 }


Member Data Documentation

Definition at line 831 of file graphmisc.h.

Referenced by draw().

The length of the head.

Definition at line 828 of file graphmisc.h.

Referenced by draw().

The width or height of the arrow head.

Definition at line 830 of file graphmisc.h.

Referenced by draw().

The start of the arrow.

Definition at line 824 of file graphmisc.h.

Referenced by draw().

The end of the arrow.

Definition at line 826 of file graphmisc.h.

Referenced by draw().


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