Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   File Members   Search  

/home/mrm/Simex/simulations/hr_bike/pv_drawings.cxx File Reference

#include "pv_drawings.h"
#include <cmath>
#include <GL/gl.h>
#include <GL/glu.h>
#include "pv_geometry.h"
#include "pv_gl.h"

Include dependency graph for pv_drawings.cxx:

Include dependency graph

Functions

void pv_triangle_and_normal (Pv_Point A, Pv_Point B, Pv_Point C)
void pv_gluCylinder (double radius, Pv_Point A, Pv_Point B)

Function Documentation

void pv_triangle_and_normal Pv_Point    A,
Pv_Point    B,
Pv_Point    C
 

00012                                                         {
00013   /*the points must be counter clock wise to get the front face*/
00014   glBegin(GL_TRIANGLES);
00015   Pv_Point D=normalize((A-C)^(B-C));
00016   glNormal3f(D.x,D.y,D.z);
00017   glVertex3f(A.x,A.y,A.z);
00018   glVertex3f(B.x,B.y,B.z);
00019   glVertex3f(C.x,C.y,C.z);
00020   glEnd();
00021 }

void pv_gluCylinder double    radius,
Pv_Point    A,
Pv_Point    B
 

00026                           {
00027   Pv_Point C=B-A;
00028 
00029   /*segment lengths*/
00030   double a1=C.z;
00031   double h1=sqrt(pow(C.x,2)+pow(C.z,2));
00032   double a2=h1;
00033   double h2=sqrt(pow(C.x,2)+pow(C.y,2)+pow(C.z,2));
00034 
00035   /*angles*/
00036   double angle_y;
00037   double angle_x;
00038 
00039   if(h1==0){
00040     angle_y=0;
00041   }
00042   else{
00043     angle_y=acos(fabs(a1/h1));
00044   }
00045   if(h2==0){
00046     angle_x=0;
00047   }
00048   else{
00049     angle_x=acos(fabs(a2/h2));
00050   }
00051 
00052   /*modifications*/
00053   if(C.z>=0 && C.x>=0){
00054   }
00055   else if(C.z<=0 && C.x>=0){
00056     angle_y=M_PI-angle_y;
00057   }  
00058   else if(C.z<=0 && C.x<=0){
00059     angle_y=angle_y+M_PI;
00060   }
00061   else if(C.z>=0 && C.x<=0){
00062     angle_y=2*M_PI-angle_y;
00063   }
00064 
00065   if(C.y>=0){
00066     angle_x=2*M_PI-angle_x;
00067   }
00068   else if(C.y<=0){
00069   }
00070 
00071   /*drawing*/
00072   glPushMatrix();
00073   glTranslated(A.x,A.y,A.z);
00074   glRotated(rad_to_deg(angle_y),0.,1.,0.);
00075   glRotated(rad_to_deg(angle_x),1.,0.,0.);
00076   gluCylinder(Pv_Gl::default_quadric,
00077               radius,radius,
00078               length(C),
00079               Pv_Gl::get_tube_slices(),
00080               Pv_Gl::get_tube_stacks());
00081   glPushMatrix();
00082   glFrontFace(GL_CW);
00083   gluDisk(Pv_Gl::default_quadric,
00084           0.,radius,
00085           Pv_Gl::get_tube_slices(),
00086           Pv_Gl::get_tube_stacks());
00087   glFrontFace(GL_CCW);
00088   glTranslated(-C.x,-C.y,-C.z);
00089   gluDisk(Pv_Gl::default_quadric,
00090           0.,radius,
00091           Pv_Gl::get_tube_slices(),
00092           Pv_Gl::get_tube_stacks());
00093   glPopMatrix();
00094   glPopMatrix();
00095 }


Generated on Sat Jul 19 04:02:14 2003 for SIMEX by doxygen1.2.18