00001 //=========================================================================== 00002 //= resorte.h Mayo de 1999 = 00003 //=-------------------------------------------------------------------------= 00004 //= Definiciones de la clase RESORTE = 00005 //=-------------------------------------------------------------------------= 00006 //= ADVERTENCIA: ESTE SOFTWARE NO ESTA CONCEBIDO NI DISENNADO PARA EL USO = 00007 //= EN EQUIPO DE CONTROL EN LINEA EN ENTORNOS PELIGROSOS QUE REQUIERAN UN = 00008 //= DESEMPENNO LIBRE DE FALLAS, COMO LA OPERACION DE PLANTAS NUCLEARES, = 00009 //= SISTEMAS DE NAVEGACION O COMUNICACION EN AVIONES, TRAFICO AEREO, = 00010 //= EQUIPO MEDICO DEL CUAL DEPENDAN VIDAS HUMANAS O SISTEMAS DE ARMAMENTO, = 00011 //= EN LOS CUALES UNA FALLA EN EL SOFTWARE PUEDA IMPLICAR DIRECTAMENTE LA = 00012 //= MUERTE, DANNOS PERSONALES O DANNOS FISICOS Y/O AMBIENTALES GRAVES = 00013 //= ("ACTIVIDADES DE ALGO RIESGO"). = 00014 //=-------------------------------------------------------------------------= 00015 //= Autor original: Oscar J. Chavarro G. A.K.A. JEDILINK. Copyright (c), = 00016 //= 1997 - 2003, oscarchavarro@hotmail.com = 00017 //= AQUYNZA es software libre, y se rige bajo los terminos de la licencia = 00018 //= LGPL de GNU (http://www.gnu.org). Para mayor informacion respecto a la = 00019 //= licencia de uso, consulte el archivo ./doc/LICENCIA en la distribucion. = 00020 //=========================================================================== 00021 00022 #ifndef __RESORTE__ 00023 #define __RESORTE__ 00024 00025 #include "jed_defs.h" // Incluir antes que nada, en ese modulo se definen 00026 // aspectos importantes para la portabilidad del sistema 00027 00028 #include "core/cosas/cosa.h" 00029 00030 #ifdef VEL_ROSITA 00031 #include "core/uniones/union.h" 00032 #endif 00033 00034 class TELA; 00035 00036 class RESORTE : public UNION { 00037 private: 00038 //- Variables fisicas del resorte --------------------------------------- 00039 double l; // Longitud de reposo del resorte 00040 double ks; // Constante del resorte segun la ley de Hooke 00041 double kd; // Constante de amortiguamiento 00042 00043 //- Anclas del resorte: indican sus extremos ---------------------------- 00044 COSA *Extremo1; 00045 VECTOR posicion1; 00046 COSA *Extremo2; 00047 VECTOR posicion2; 00048 00049 //- Servicios privados -------------------------------------------------- 00050 int num_extremos; 00051 00052 BOOLEAN 00053 insertar_extremo(char *nombre, LISTA<COSA*> *Lista_cosas, VECTOR pos); 00054 public: 00055 RESORTE(); 00056 virtual ~RESORTE(); 00057 00058 //- Operaciones de simulacion ------------------------------------------- 00059 inline void actualizar(void); 00060 00061 //- Operaciones de consulta (visualizacion) ----------------------------- 00062 #ifdef GL_ENABLED 00063 void pintar_gl(CALIDAD_VISUAL *Calidad); 00064 #endif 00065 void pintar_povray(FILE *fd); 00066 00067 //- Operaciones de persistencia ----------------------------------------- 00068 BOOLEAN leer(TOKENIZADOR *Sabiondo, LISTA<COSA *> *Lista_cosas); 00069 00070 friend class TELA; // Acceso irrestringido por razones de eficiencia! 00071 }; 00072 00073 //=========================================================================== 00074 //= Operacione inline de la clase RESORTE = 00075 //=========================================================================== 00076 00077 inline void 00078 RESORTE::actualizar(void) 00093 { 00094 VECTOR f1, f2; 00095 VECTOR delta_x, delta_v; 00096 double absdx; 00097 00098 delta_x = Extremo1->posicion_absoluta(posicion1) - 00099 Extremo2->posicion_absoluta(posicion2); 00100 delta_v = Extremo1->velocidad_absoluta() - Extremo2->velocidad_absoluta(); 00101 00102 absdx = fabs(delta_x.norma()); 00103 00104 f1 = ( 00105 ( delta_x * (1/absdx) ) * 00106 ( ks*(absdx-l) + 00107 kd*delta_v.producto_punto(delta_x)/absdx 00108 ) 00109 ) * (-1); 00110 00111 f2 = f1 * (-1); 00112 00113 // OJO: Estaran bien las posiciones? (parece que no) 00114 Extremo1->anexar_fuerza(f1, Extremo1->posicion_absoluta(posicion1)); 00115 Extremo2->anexar_fuerza(f2, Extremo2->posicion_absoluta(posicion2)); 00116 } 00117 00118 #endif // __RESORTE__ 00119 00120 //=========================================================================== 00121 //= EOF = 00122 //=========================================================================== 00123