Página principal | Jerarquía de la clase | Lista alfabética | Lista de componentes | Lista de archivos | Miembros de las clases | Archivos de los miembros | Páginas relacionadas

paralele.h

Ir a la documentación de este archivo.
00001 //===========================================================================
00002 //= paralele.h                                                Marzo de 1999 =
00003 //=-------------------------------------------------------------------------=
00004 //= Definiciones de la clase PARALELEPIPEDO                                 =
00005 //= NOTA: No incluya este encabezado en los modulos.  Incluya a             =
00006 //=       geometria.h.                                                      =
00007 //=-------------------------------------------------------------------------=
00008 //= ADVERTENCIA: ESTE SOFTWARE NO ESTA CONCEBIDO NI DISENNADO PARA EL USO   =
00009 //= EN EQUIPO DE CONTROL EN LINEA EN ENTORNOS PELIGROSOS QUE REQUIERAN UN   =
00010 //= DESEMPENNO LIBRE DE FALLAS, COMO LA OPERACION DE PLANTAS NUCLEARES,     = 
00011 //= SISTEMAS DE NAVEGACION O COMUNICACION EN AVIONES, TRAFICO AEREO,        =
00012 //= EQUIPO MEDICO DEL CUAL DEPENDAN VIDAS HUMANAS O SISTEMAS DE ARMAMENTO,  =
00013 //= EN LOS CUALES UNA FALLA EN EL SOFTWARE PUEDA IMPLICAR DIRECTAMENTE LA   =
00014 //= MUERTE, DANNOS PERSONALES O DANNOS FISICOS Y/O AMBIENTALES GRAVES       =
00015 //= ("ACTIVIDADES DE ALGO RIESGO").                                         =
00016 //=-------------------------------------------------------------------------=
00017 //= Autor original: Oscar J. Chavarro G.  A.K.A. JEDILINK. Copyright (c),   =
00018 //= 1997 - 2003, oscarchavarro@hotmail.com                                  =
00019 //= AQUYNZA es software libre, y se rige bajo los terminos de la licencia   =
00020 //= LGPL de GNU (http://www.gnu.org). Para mayor informacion respecto a la  =
00021 //= licencia de uso, consulte el archivo ./doc/LICENCIA en la distribucion. =
00022 //===========================================================================
00023 
00024 #ifndef __PARALELEPIPEDO__
00025 #define __PARALELEPIPEDO__
00026 
00027 #include "jed_defs.h"
00028 
00029 #ifndef __GEOMETRIA__
00030     #error "No incluya a paralele.h, incluya a geometria.h!"
00031 #endif
00032 
00033 #ifdef VEL_ROSITA
00034     #include "toolkits/geom/geometria.h"
00035 #endif
00036 
00037 class PARALELEPIPEDO : public PRIMITIVA_GEOMETRICA 
00038 {
00039   private:
00040     VECTOR _lados;
00041     IMAGEN *imagen;
00042   public:
00043     PARALELEPIPEDO(VECTOR l);
00044     PARALELEPIPEDO(double lx, double ly, double lz);
00045     virtual ~PARALELEPIPEDO();
00046     VECTOR lados(void);
00047     void set_lados(VECTOR l);
00048     void minmax(VECTOR *min, VECTOR *max);
00049 
00050 #ifdef GL_ENABLED
00051     void
00052     pintar_gl(CALIDAD_VISUAL *Calidad, MATERIAL* Material, CAMARA *Camara);
00053 #endif
00054     void pintar_povray(FILE *fd);
00055     void pintar_aqz(FILE *fd);
00056     void pintar_vrml(FILE *fd);
00057     void anexar_textura(IMAGEN *img);
00058     int clasificar_punto(VECTOR p);
00059     virtual GEOMETRIA *crear_copia(void);
00060     double interseccion(RAYO *Rayo, VECTOR &punto, VECTOR &normal);
00061 };
00062 
00063 //===========================================================================
00064 //= Metodos inline de la clase CUBO                                         =
00065 //===========================================================================
00066 
00067 inline double
00068 PARALELEPIPEDO::interseccion(RAYO *Rayo, VECTOR &punto, VECTOR &normal)
00079 {
00080     double t, min_t = INFINITO;
00081     double l2x = _lados.x/2; 
00082     double l2y = _lados.y/2; 
00083     double l2z = _lados.z/2; 
00084     VECTOR p;
00085 
00086     // Plano superior: Z = _lado/2
00087     if ( fabs(Rayo->direccion.z) > EPSILON ) {
00088         // El rayo no es paralelo al plano Z=_lado/2
00089         t = (l2z-Rayo->origen.z)/Rayo->direccion.z;
00090         if ( t > -EPSILON ) {
00091             p = Rayo->origen + Rayo->direccion * t;
00092             if ( p.x >= -l2x && p.x <= l2x && 
00093                  p.y >= -l2y && p.y <= l2y ) {
00094                 normal.x = normal.y = 0;
00095                 normal.z = 1;
00096                 punto = p;
00097                 min_t = t;
00098             }
00099         }
00100     }
00101 
00102     // Plano inferior: Z = -_lado/2
00103     if ( fabs(Rayo->direccion.z) > EPSILON ) {
00104         // El rayo no es paralelo al plano Z=-_lado/2
00105         t = (-l2z-Rayo->origen.z)/Rayo->direccion.z;
00106         if ( t > -EPSILON && t < min_t ) {
00107             p = Rayo->origen + Rayo->direccion * t;
00108             if ( p.x >= -l2x && p.x <= l2x && 
00109                  p.y >= -l2y && p.y <= l2y ) {
00110                 normal.x = normal.y = 0;
00111                 normal.z = -1;
00112                 punto = p;
00113                 min_t = t;
00114             }
00115         }
00116     }
00117 
00118     // Plano frontal: Y = _lado/2
00119     if ( fabs(Rayo->direccion.y) > EPSILON ) {
00120         // El rayo no es paralelo al plano Y=_lado/2
00121         t = (l2y-Rayo->origen.y)/Rayo->direccion.y;
00122         if ( t > -EPSILON && t < min_t ) {
00123             p = Rayo->origen + Rayo->direccion * t;
00124             if ( p.x >= -l2x && p.x <= l2x && 
00125                  p.z >= -l2z && p.z <= l2z ) {
00126                 normal.x = normal.z = 0;
00127                 normal.y = 1;
00128                 punto = p;
00129                 min_t = t;
00130             }
00131         }
00132     }
00133 
00134     // Plano posterior: Y = -_lado/2
00135     if ( fabs(Rayo->direccion.y) > EPSILON ) {
00136         // El rayo no es paralelo al plano Y=-_lado/2
00137         t = (-l2y-Rayo->origen.y)/Rayo->direccion.y;
00138         if ( t > -EPSILON && t < min_t ) {
00139             p = Rayo->origen + Rayo->direccion * t;
00140             if ( p.x >= -l2x && p.x <= l2x && 
00141                  p.z >= -l2z && p.z <= l2z ) {
00142                 normal.x = normal.z = 0;
00143                 normal.y = -1;
00144                 punto = p;
00145                 min_t = t;
00146             }
00147         }
00148     }
00149 
00150     // Plano X = _lado/2
00151     if ( fabs(Rayo->direccion.x) > EPSILON ) {
00152         // El rayo no es paralelo al plano X=_lado/2
00153         t = (l2x-Rayo->origen.x)/Rayo->direccion.x;
00154         if ( t > -EPSILON && t < min_t ) {
00155             p = Rayo->origen + Rayo->direccion * t;
00156             if ( p.y >= -l2y && p.y <= l2y && 
00157                  p.z >= -l2z && p.z <= l2z ) {
00158                 normal.y = normal.z = 0;
00159                 normal.x = 1;
00160                 punto = p;
00161                 min_t = t;
00162             }
00163         }
00164     }
00165 
00166     // Plano X = -_lado/2
00167     if ( fabs(Rayo->direccion.x) > EPSILON ) {
00168         // El rayo no es paralelo al plano X=-_lado/2
00169         t = (-l2x-Rayo->origen.x)/Rayo->direccion.x;
00170         if ( t > -EPSILON && t < min_t ) {
00171             p = Rayo->origen + Rayo->direccion * t;
00172             if ( p.y >= -l2y && p.y <= l2y && 
00173                  p.z >= -l2z && p.z <= l2z ) {
00174                 normal.y = normal.z = 0;
00175                 normal.x = -1;
00176                 punto = p;
00177                 min_t = t;
00178             }
00179         }
00180     }
00181 
00182     if ( min_t < INFINITO ) return min_t;
00183     return 0;
00184 }
00185 
00186 #endif
00187 
00188 //===========================================================================
00189 //= EOF                                                                     =
00190 //===========================================================================
00191 

Este archivo HTML ha sido generado automáticamente a partir del código fuente AQUYNZA. NO LO EDITE. Para mayor información contacte al autor.