Main Page   Modules   Compound List   File List   Compound Members   File Members  

2vector.h

Go to the documentation of this file.
00001 
00014 /* This library is free software; you can redistribute it and/or
00015    modify it under the terms of the GNU Lesser General Public
00016    License as published by the Free Software Foundation; either
00017    version 2.1 of the License, or (at your option) any later version.
00018 
00019    This library is distributed in the hope that it will be useful,
00020    but WITHOUT ANY WARRANTY; without even the implied warranty of
00021    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00022    Lesser General Public License for more details.
00023 
00024    You should have received a copy of the GNU Lesser General Public
00025    License along with this library; if not, write to the Free Software
00026    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00027 */
00028 
00029 #ifndef _GAN_2VECTOR_H
00030 #define _GAN_2VECTOR_H
00031 
00032 #include <stdlib.h>
00033 #include <stdio.h>
00034 #include <gandalf/common/misc_defs.h>
00048 /* This library is free software; you can redistribute it and/or
00049    modify it under the terms of the GNU Lesser General Public
00050    License as published by the Free Software Foundation; either
00051    version 2.1 of the License, or (at your option) any later version.
00052 
00053    This library is distributed in the hope that it will be useful,
00054    but WITHOUT ANY WARRANTY; without even the implied warranty of
00055    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00056    Lesser General Public License for more details.
00057 
00058    You should have received a copy of the GNU Lesser General Public
00059    License along with this library; if not, write to the Free Software
00060    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00061 */
00062 
00063 #ifndef _GAN_REPEAT2_H
00064 #define _GAN_REPEAT2_H
00065 
00066 #ifdef __cplusplus
00067 extern "C" {
00068 #endif
00069 
00070 /* macros for constructing two-fold repetitions */
00071 #define GAN_REP2_AS(a,b,p1,p2) (a p1 b, a p2 b)
00072 #define GAN_REP2_A(a,p1,p2) (a p1, a p2)
00073 #define GAN_REP2_AS_C(a,b) GAN_REP2_AS(a,b,x,y)
00074 #define GAN_REP2_A_C(a) GAN_REP2_A(a,x,y)
00075 
00076 #define GAN_FREP2_A(a,b,p1,p2,q1,q2) (a p1 b q1, a p2 b q2)
00077 #define GAN_FREP2_A_C(a,b,p1,p2) GAN_FREP2_A(a,b,x,y,p1,p2)
00078 
00079 #define GAN_REP2_AB(a,b,p1,p2,q1,q2) (a p1 b q1, a p2 b q2)
00080 #define GAN_REP2_AA(a,b,p1,p2) GAN_REP2_AB(a,b,p1,p2,p1,p2)
00081 #define GAN_REP2_AA_C(a,b) GAN_REP2_AA(a,b,x,y)
00082 
00083 #define GAN_REP2_ABS(a,b,c,p1,p2,q1,q2) (a p1 b q1 c, a p2 b q2 c)
00084 #define GAN_REP2_AAS(a,b,c,p1,p2) GAN_REP2_ABS(a,b,c,p1,p2,p1,p2)
00085 #define GAN_REP2_AAS_C(a,b,c) GAN_REP2_AAS(a,b,c,x,y)
00086 
00087 #define GAN_REP2_AB(a,b,p1,p2,q1,q2) (a p1 b q1, a p2 b q2)
00088 #define GAN_REP2_AA(a,b,p1,p2) GAN_REP2_AB(a,b,p1,p2,p1,p2)
00089 #define GAN_REP2_AA_C(a,b) GAN_REP2_AA(a,b,x,y)
00090 
00091 #define GAN_REP2_ABCS(a,b,c,d,p1,p2,q1,q2,r1,r2)\
00092            (a p1 b q1 c r1 d, a p2 b q2 c r2 d)
00093 #define GAN_REP2_ABC(a,b,c,p1,p2,q1,q2,r1,r2)\
00094            (a p1 b q1 c r1, a p2 b q2 c r2)
00095 #define GAN_REP2_AAA(a,b,c,p1,p2) GAN_REP2_ABC(a,b,c,p1,p2,p1,p2,p1,p2)
00096 #define GAN_REP2_AAA_C(a,b,c) GAN_REP2_AAA(a,b,c,x,y)
00097 
00098 #define GAN_REP2_OP_AB(a,b,p1,p2,q1,q2,op)\
00099            (a p1 b q1 op a p2 b q2)
00100 #define GAN_REP2_OP_AA(a,b,p1,p2,op) GAN_REP2_OP_AB(a,b,p1,p2,p1,p2,op)
00101 #define GAN_REP2_OP_AA_C(a,b,op) GAN_REP2_OP_AA(a,b,x,y,op)
00102 
00103 #ifdef __cplusplus
00104 }
00105 #endif
00106 
00107 #endif /* #ifndef _GAN_REPEAT2_H */
00108 
00121 /* This library is free software; you can redistribute it and/or
00122    modify it under the terms of the GNU Lesser General Public
00123    License as published by the Free Software Foundation; either
00124    version 2.1 of the License, or (at your option) any later version.
00125 
00126    This library is distributed in the hope that it will be useful,
00127    but WITHOUT ANY WARRANTY; without even the implied warranty of
00128    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00129    Lesser General Public License for more details.
00130 
00131    You should have received a copy of the GNU Lesser General Public
00132    License along with this library; if not, write to the Free Software
00133    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00134 */
00135 
00136 #ifndef _GAN_MATVECF_MACROS_H
00137 #define _GAN_MATVECF_MACROS_H
00138 
00139 #ifdef __cplusplus
00140 extern "C" {
00141 #endif
00142 
00143 /* macros for testing the types of pointer arguments and then applying an
00144  * operation to them */
00145 #define GAN_TEST_OP1(A,typeA) assert(sizeof(*(A))==sizeof(typeA))
00146 #define GAN_TEST_OP2(A,B,typeA,typeB)\
00147   (assert(sizeof(*(A))==sizeof(typeA)&&sizeof(*(B))==sizeof(typeB)))
00148 #define GAN_TEST_OP3(A,B,C,typeA,typeB,typeC)\
00149   (assert(sizeof(*(A))==sizeof(typeA)&&sizeof(*(B))==sizeof(typeB)&&\
00150           sizeof(*(C))==sizeof(typeC)))
00151 #define GAN_TEST_OP4(A,B,C,D,typeA,typeB,typeC,typeD)\
00152   (assert(sizeof(*(A))==sizeof(typeA)&&sizeof(*(B))==sizeof(typeB)&&\
00153           sizeof(*(C))==sizeof(typeC)&&sizeof(*(D))==sizeof(typeD)))
00154 #define GAN_TEST_OP5(A,B,C,D,E,typeA,typeB,typeC,typeD,typeE)\
00155   (assert(sizeof(*(A))==sizeof(typeA)&&sizeof(*(B))==sizeof(typeB)&&\
00156           sizeof(*(C))==sizeof(typeC)&&sizeof(*(D))==sizeof(typeD)&&\
00157           sizeof(*(E))==sizeof(typeE)))
00158 
00159 #ifdef __cplusplus
00160 }
00161 #endif
00162 
00163 #endif /* #ifndef _GAN_MATVECF_MACROS_H */
00164 #include <gandalf/linalg/vec_gen.h>
00165 
00166 #ifdef __cplusplus
00167 extern "C" {
00168 #endif
00169 
00185 
00186 typedef struct Gan_Vector2
00187 {
00188    double x, y;
00189 } Gan_Vector2, Gan_Vector2_d;
00190 
00192 typedef struct Gan_Vector2_uc
00193 {
00194    unsigned char x, y;
00195 } Gan_Vector2_uc;
00196 
00198 typedef struct Gan_Vector2_s
00199 {
00200    short x, y;
00201 } Gan_Vector2_s;
00202 
00204 typedef struct Gan_Vector2_us
00205 {
00206    unsigned short x, y;
00207 } Gan_Vector2_us;
00208 
00210 typedef struct Gan_Vector2_i
00211 {
00212    int x, y;
00213 } Gan_Vector2_i;
00214 
00216 typedef struct Gan_Vector2_ui
00217 {
00218    unsigned int x, y;
00219 } Gan_Vector2_ui;
00220 
00221 /* declare functions specific to 2-vectors */
00235 /* This library is free software; you can redistribute it and/or
00236    modify it under the terms of the GNU Lesser General Public
00237    License as published by the Free Software Foundation; either
00238    version 2.1 of the License, or (at your option) any later version.
00239 
00240    This library is distributed in the hope that it will be useful,
00241    but WITHOUT ANY WARRANTY; without even the implied warranty of
00242    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00243    Lesser General Public License for more details.
00244 
00245    You should have received a copy of the GNU Lesser General Public
00246    License along with this library; if not, write to the Free Software
00247    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00248 */
00249 
00264 Gan_Vector2 *gan_vec2_fill_q ( Gan_Vector2 *p, double X, double Y );
00265 
00271 #define GAN_VECTYPE Gan_Vector2
00272 #define GAN_VECTOR_TYPE Gan_Vector
00273 #define GAN_VEC_ELEMENT_TYPE GAN_DOUBLE
00274 #define GAN_REALTYPE double
00275 #define GAN_VEC_FPRINT     gan_vec2_fprint
00276 #define GAN_VEC_PRINT      gan_vec2_print
00277 #define GAN_VEC_FSCANF     gan_vec2_fscanf
00278 #define GAN_VEC_FWRITE     gan_vec2_fwrite
00279 #define GAN_VEC_FREAD      gan_vec2_fread
00280 #define GAN_VEC_ZERO_Q     gan_vec2_zero_q
00281 #define GAN_VEC_ZERO_S     gan_vec2_zero_s
00282 #define GAN_VEC_COPY_Q     gan_vec2_copy_q
00283 #define GAN_VEC_COPY_S     gan_vec2_copy_s
00284 #define GAN_VEC_SCALE_Q    gan_vec2_scale_q
00285 #define GAN_VEC_SCALE_S    gan_vec2_scale_s
00286 #define GAN_VEC_SCALE_I    gan_vec2_scale_i
00287 #define GAN_VEC_DIVIDE_Q   gan_vec2_divide_q
00288 #define GAN_VEC_DIVIDE_S   gan_vec2_divide_s
00289 #define GAN_VEC_DIVIDE_I   gan_vec2_divide_i
00290 #define GAN_VEC_NEGATE_Q   gan_vec2_negate_q
00291 #define GAN_VEC_NEGATE_S   gan_vec2_negate_s
00292 #define GAN_VEC_NEGATE_I   gan_vec2_negate_i
00293 #define GAN_VEC_UNIT_Q     gan_vec2_unit_q
00294 #define GAN_VEC_UNIT_S     gan_vec2_unit_s
00295 #define GAN_VEC_UNIT_I     gan_vec2_unit_i
00296 #define GAN_VEC_ADD_Q      gan_vec2_add_q
00297 #define GAN_VEC_ADD_I1     gan_vec2_add_i1
00298 #define GAN_VEC_ADD_I2     gan_vec2_add_i2
00299 #define GAN_VEC_INCREMENT  gan_vec2_increment
00300 #define GAN_VEC_ADD_S      gan_vec2_add_s
00301 #define GAN_VEC_SUB_Q      gan_vec2_sub_q
00302 #define GAN_VEC_SUB_I1     gan_vec2_sub_i1
00303 #define GAN_VEC_SUB_I2     gan_vec2_sub_i2
00304 #define GAN_VEC_DECREMENT  gan_vec2_decrement
00305 #define GAN_VEC_SUB_S      gan_vec2_sub_s
00306 #define GAN_VEC_DOT_Q      gan_vec2_dot_q
00307 #define GAN_VEC_DOT_S      gan_vec2_dot_s
00308 #define GAN_VEC_SQRLEN_Q   gan_vec2_sqrlen_q
00309 #define GAN_VEC_SQRLEN_S   gan_vec2_sqrlen_s
00310 #define GAN_VEC_FROM_VEC_Q gan_vec2_from_vec_q
00311 #define GAN_VEC_FROM_VEC_S gan_vec2_from_vec_s
00312 
00326 /* This library is free software; you can redistribute it and/or
00327    modify it under the terms of the GNU Lesser General Public
00328    License as published by the Free Software Foundation; either
00329    version 2.1 of the License, or (at your option) any later version.
00330 
00331    This library is distributed in the hope that it will be useful,
00332    but WITHOUT ANY WARRANTY; without even the implied warranty of
00333    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00334    Lesser General Public License for more details.
00335 
00336    You should have received a copy of the GNU Lesser General Public
00337    License along with this library; if not, write to the Free Software
00338    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00339 */
00340 
00341 /* function declarations for functions common to all small vector types */
00342 
00343 
00344 /* documentation for macros defined in individual header files */
00345 
00356 Gan_Vector2 *gan_vec2_zero_q ( Gan_Vector2 *p );
00357 
00372 Gan_Vector2 *gan_vec2_copy_q ( Gan_Vector2 *p, Gan_Vector2 *q );
00373 
00389 Gan_Vector2 *gan_vec2_scale_q ( Gan_Vector2 *p, double a,
00390                                Gan_Vector2 *q );
00391 
00397 Gan_Vector2 *gan_vec2_scale_i ( Gan_Vector2 *p, double a );
00398 
00405 Gan_Vector2 *gan_vec2_divide_q ( Gan_Vector2 *p, double a,
00406                                 Gan_Vector2 *q );
00407 
00413 Gan_Vector2 *gan_vec2_divide_i ( Gan_Vector2 *p, double a );
00414 
00422 Gan_Vector2 *gan_vec2_negate_q ( Gan_Vector2 *p, Gan_Vector2 *q );
00423 
00431 Gan_Vector2 *gan_vec2_negate_i ( Gan_Vector2 *p );
00432 
00438 Gan_Vector2 *gan_vec2_unit_i ( Gan_Vector2 *p );
00439 
00457 Gan_Vector2 *gan_vec2_add_q ( Gan_Vector2 *p, Gan_Vector2 *q, Gan_Vector2 *r );
00458 
00467 Gan_Vector2 *gan_vec2_add_i1 ( Gan_Vector2 *p, Gan_Vector2 *q );
00468 
00477 Gan_Vector2 *gan_vec2_add_i2 ( Gan_Vector2 *p, Gan_Vector2 *q );
00478 
00487 Gan_Vector2 *gan_vec2_increment ( Gan_Vector2 *p, Gan_Vector2 *q );
00488 
00506 Gan_Vector2 *gan_vec2_sub_q ( Gan_Vector2 *p, Gan_Vector2 *q, Gan_Vector2 *r );
00507 
00516 Gan_Vector2 *gan_vec2_sub_i1 ( Gan_Vector2 *p, Gan_Vector2 *q );
00517 
00526 Gan_Vector2 *gan_vec2_sub_i2 ( Gan_Vector2 *p, Gan_Vector2 *q );
00527 
00536 Gan_Vector2 *gan_vec2_decrement ( Gan_Vector2 *p, Gan_Vector2 *q );
00537 
00553 double gan_vec2_dot_q ( Gan_Vector2 *p, Gan_Vector2 *q );
00554 
00572 double gan_vec2_sqrlen_q ( Gan_Vector2 *p );
00573 
00591 Gan_Vector2 gan_vec2_from_vec_s ( Gan_Vector *x );
00592 
00610 /* This library is free software; you can redistribute it and/or
00611    modify it under the terms of the GNU Lesser General Public
00612    License as published by the Free Software Foundation; either
00613    version 2.1 of the License, or (at your option) any later version.
00614 
00615    This library is distributed in the hope that it will be useful,
00616    but WITHOUT ANY WARRANTY; without even the implied warranty of
00617    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00618    Lesser General Public License for more details.
00619 
00620    You should have received a copy of the GNU Lesser General Public
00621    License along with this library; if not, write to the Free Software
00622    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00623 */
00624 
00625 #undef GAN_VECTYPE
00626 #undef GAN_VECTOR_TYPE
00627 #undef GAN_VEC_ELEMENT_TYPE
00628 #undef GAN_REALTYPE
00629 #undef GAN_VEC_FPRINT
00630 #undef GAN_VEC_PRINT
00631 #undef GAN_VEC_FSCANF
00632 #undef GAN_VEC_FWRITE
00633 #undef GAN_VEC_FREAD
00634 #undef GAN_VEC_ZERO_Q
00635 #undef GAN_VEC_ZERO_S
00636 #undef GAN_VEC_COPY_Q
00637 #undef GAN_VEC_COPY_S
00638 #undef GAN_VEC_SCALE_Q
00639 #undef GAN_VEC_SCALE_S
00640 #undef GAN_VEC_SCALE_I
00641 #undef GAN_VEC_DIVIDE_Q
00642 #undef GAN_VEC_DIVIDE_S
00643 #undef GAN_VEC_DIVIDE_I
00644 #undef GAN_VEC_NEGATE_Q
00645 #undef GAN_VEC_NEGATE_S
00646 #undef GAN_VEC_NEGATE_I
00647 #undef GAN_VEC_UNIT_Q
00648 #undef GAN_VEC_UNIT_S
00649 #undef GAN_VEC_UNIT_I
00650 #undef GAN_VEC_ADD_Q
00651 #undef GAN_VEC_ADD_I1
00652 #undef GAN_VEC_ADD_I2
00653 #undef GAN_VEC_INCREMENT
00654 #undef GAN_VEC_ADD_S
00655 #undef GAN_VEC_SUB_Q
00656 #undef GAN_VEC_SUB_I1
00657 #undef GAN_VEC_SUB_I2
00658 #undef GAN_VEC_DECREMENT
00659 #undef GAN_VEC_SUB_S
00660 #undef GAN_VEC_DOT_Q
00661 #undef GAN_VEC_DOT_S
00662 #undef GAN_VEC_SQRLEN_Q
00663 #undef GAN_VEC_SQRLEN_S
00664 #undef GAN_VEC_FROM_VEC_Q
00665 #undef GAN_VEC_FROM_VEC_S
00666 
00679 #ifdef __cplusplus
00680 }
00681 #endif
00682 
00683 #endif /* #ifndef _GAN_2VECTOR_H */

Generated on Mon Oct 13 16:14:30 2003 by doxygen1.3-rc1