Files Classes Functions Hierarchy
#include <graphmisc.h>
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 |
Definition at line 819 of file graphmisc.h.
| 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 }
| 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 }
| double gobjMyArrow::delta |
The width or height of the arrow head.
Definition at line 830 of file graphmisc.h.
Referenced by draw().
| point3<double> gobjMyArrow::p0 |
| point3<double> gobjMyArrow::p1 |
1.5.8