calcul.h
00001 /***************************************************/ 00002 /* Last Revised: 00003 $Id: calcul.h 8465 2009-12-16 00:44:13Z gbiggs $ 00004 */ 00005 /***************************************************/ 00006 /* 00007 * This program is free software; you can redistribute it and/or modify 00008 * it under the terms of the GNU General Public License as published by 00009 * the Free Software Foundation; either version 2 of the License, or 00010 * (at your option) any later version. 00011 * 00012 * This program is distributed in the hope that it will be useful, 00013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 * GNU General Public License for more details. 00016 * 00017 * You should have received a copy of the GNU General Public License 00018 * along with this program; if not, write to the Free Software 00019 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00020 * 00021 */ 00022 #ifndef Calcul 00023 #define Calcul 00024 00025 #include <stdio.h> 00026 #include <math.h> 00027 #include "TData.h" 00028 00029 #ifdef __cplusplus 00030 extern "C" { 00031 #endif 00032 00033 /* 00034 Este fichero tiene operaciones de transformacion de sistemas de referencia, 00035 transformaciones de puntos entre sistemas, de paso de coordenadadas polares, 00036 a cartesianas y de corte de segmentos 00037 00038 */ 00039 00040 /* --------------------------------------------------------------------------------------- */ 00041 /* TRANSFORMACIONES DE PUNTO DE UN SISTEMA DE REFERENCIA A OTRO */ 00042 /* --------------------------------------------------------------------------------------- */ 00043 00044 /* --------------------------------------------------------------------------------------- */ 00045 /* transfor_directa_p */ 00046 /* .... Hace la transformacion directa de un punto a un sistema a otro */ 00047 /* .... In: (x,y) las coordenadas del punto, sistema es el sistema de referencia */ 00048 /* .... Out: en sol se devuelve las coordenadas del punto en el nuevo sistema */ 00049 00050 void transfor_directa_p ( float x, float y, Tsc *sistema, Tpf *sol ); 00051 00052 /* --------------------------------------------------------------------------------------- */ 00053 /* transfor_directa_p */ 00054 /* .... Hace la transformacion directa de un punto a un sistema a otro */ 00055 /* .... La diferencia es que aqui el punto de entrada es el (0,0) (optimiza la anterior) */ 00056 /* .... In: (x,y) las coordenadas del punto, sistema es el sistema de referencia */ 00057 /* .... Out: en sol se devuelve las coordenadas del punto en el nuevo sistema */ 00058 00059 void transfor_directa_pt0(float x, float y, 00060 Tsc *sistema, Tpf *sol); 00061 00062 /* --------------------------------------------------------------------------------------- */ 00063 /* transfor_inversa_p */ 00064 /* .... Hace la transformacion inversa de un punto a un sistema a otro */ 00065 /* .... In: (x,y) las coordenadas del punto, sistema es el sistema de referencia */ 00066 /* .... Out: en sol se devuelve las coordenadas del punto en el nuevo sistema */ 00067 00068 void transfor_inversa_p ( float x, float y, Tsc *sistema, Tpf *sol ); 00069 00070 /* --------------------------------------------------------------------------------------- */ 00071 /* TRANSFORMACIONES DE COMPOSICION E INVERSION DE SISTEMAS DE REFERENCIA */ 00072 /* --------------------------------------------------------------------------------------- */ 00073 00074 /* --------------------------------------------------------------------------------------- */ 00075 /* composicion_sis */ 00076 /* .... Realiza la composicion de sistemas de referencia en otro sistema */ 00077 /* .... In: compone sis1 y sis2 */ 00078 /* .... Out: la salida sisOut es el resultado de la composicion de los sistemas */ 00079 /* .... Nota: resulta muy importante el orden de las entradas en la composicion */ 00080 00081 void composicion_sis(Tsc *sis1,Tsc *sis2,Tsc *sisOut); 00082 00083 /* --------------------------------------------------------------------------------------- */ 00084 /* inversion_sis */ 00085 /* .... Realiza la inversion de un sistema de referencia */ 00086 /* .... In: sisIn es el sistema a invertir */ 00087 /* .... Out: sisOut es el sistema invertido */ 00088 00089 void inversion_sis(Tsc *sisIn, Tsc *sisOut); 00090 00091 /* --------------------------------------------------------------------------------------- */ 00092 /* TRANSFORMACIONES DE PUNTO DE UN SISTEMA DE REFERENCIA A OTRO */ 00093 /* --------------------------------------------------------------------------------------- */ 00094 00095 /* --------------------------------------------------------------------------------------- */ 00096 /* car2pol */ 00097 /* .... Transforma un punto de coordenadas cartesianas a polares */ 00098 /* .... In: el punto en coordenadas cartesianas a transformar */ 00099 /* .... Out: el punto salida en coordenadas polares */ 00100 00101 void car2pol(Tpf *in, Tpfp *out); 00102 00103 /* --------------------------------------------------------------------------------------- */ 00104 /* pol2car */ 00105 /* .... Transforma un punto de coordenadas polares a cartesianas */ 00106 /* .... In: el punto entrada en coordenadas polares a transformar */ 00107 /* .... Out: el punto en coordenadas cartesianas transformado */ 00108 00109 void pol2car(Tpfp *in, Tpf *out); 00110 00111 /* --------------------------------------------------------------------------------------- */ 00112 /* TRANSFORMACIONES DE PUNTO DE UN SISTEMA DE REFERENCIA A OTRO */ 00113 /* --------------------------------------------------------------------------------------- */ 00114 00115 /* --------------------------------------------------------------------------------------- */ 00116 /* corte_segmentos */ 00117 /* .... Calcula el punto de corte entre dos segmentos */ 00118 /* .... In: las coordenadas de los puntos extremos (x1,y1)-(x2,y2) y (x3,y3)-(x4,y4) */ 00119 /* .... Out: sol son las coordenadas del punto de corte. return --> 1 si hay corte. -->0 no */ 00120 00121 int corte_segmentos ( float x1, float y1, float x2, float y2, 00122 float x3, float y3, float x4, float y4, 00123 Tpf *sol ); 00124 00125 00126 /* Normaliza el angulo entre [-PI, PI] */ 00127 float NormalizarPI(float ang); 00128 00129 #ifdef __cplusplus 00130 } 00131 #endif 00132 00133 #endif