Main Page | Modules | Class List | File List | Class Members | File Members

3vector.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_3VECTOR_H
00030 #define _GAN_3VECTOR_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_REPEAT3_H
00064 #define _GAN_REPEAT3_H
00065 
00066 #ifdef __cplusplus
00067 extern "C" {
00068 #endif
00069 
00070 /* macros for constructing three-fold repetitions */
00071 #define GAN_REP3_AS(a,b,p1,p2,p3) (a p1 b, a p2 b, a p3 b)
00072 #define GAN_REP3_AS_C(a,b) GAN_REP3_AS(a,b,x,y,z)
00073 #define GAN_REP3_A(a,p1,p2,p3) (a p1, a p2, a p3)
00074 #define GAN_REP3_A_C(a) GAN_REP3_A(a,x,y,z)
00075 
00076 #define GAN_FREP3_A(a,b,p1,p2,p3,q1,q2,q3) (a p1 b q1, a p2 b q2, a p3 b q3)
00077 #define GAN_FREP3_A_C(a,b,p1,p2,p3) GAN_FREP3_A(a,b,x,y,z,p1,p2,p3)
00078 
00079 
00080 #define GAN_REP3_ABS(a,b,c,p1,p2,p3,q1,q2,q3)\
00081            (a p1 b q1 c, a p2 b q2 c, a p3 b q3 c)
00082 #define GAN_REP3_AAS(a,b,c,p1,p2,p3) GAN_REP3_ABS(a,b,c,p1,p2,p3,p1,p2,p3)
00083 #define GAN_REP3_AAS_C(a,b,c) GAN_REP3_AAS(a,b,c,x,y,z)
00084 
00085 #define GAN_REP3_AB(a,b,p1,p2,p3,q1,q2,q3)\
00086            (a p1 b q1, a p2 b q2, a p3 b q3)
00087 #define GAN_REP3_AA(a,b,p1,p2,p3) GAN_REP3_AB(a,b,p1,p2,p3,p1,p2,p3)
00088 #define GAN_REP3_AA_C(a,b) GAN_REP3_AA(a,b,x,y,z)
00089 
00090 #define GAN_REP3_ABCS(a,b,c,d,p1,p2,p3,q1,q2,q3,r1,r2,r3)\
00091            (a p1 b q1 c r1 d, a p2 b q2 c r2 d, a p3 b q3 c r3 d)
00092 #define GAN_REP3_ABC(a,b,c,p1,p2,p3,q1,q2,q3,r1,r2,r3)\
00093            (a p1 b q1 c r1, a p2 b q2 c r2, a p3 b q3 c r3)
00094 #define GAN_REP3_AAA(a,b,c,p1,p2,p3)\
00095         GAN_REP3_ABC(a,b,c,p1,p2,p3,p1,p2,p3,p1,p2,p3)
00096 #define GAN_REP3_AAA_C(a,b,c) GAN_REP3_AAA(a,b,c,x,y,z)
00097 
00098 #define GAN_REP3_OP_AB(a,b,p1,p2,p3,q1,q2,q3,op)\
00099            (a p1 b q1 op a p2 b q2 op a p3 b q3)
00100 #define GAN_REP3_OP_AA(a,b,p1,p2,p3,op)\
00101            GAN_REP3_OP_AB(a,b,p1,p2,p3,p1,p2,p3,op)
00102 #define GAN_REP3_OP_AA_C(a,b,op) GAN_REP3_OP_AA(a,b,x,y,z,op)
00103 
00104 #ifdef __cplusplus
00105 }
00106 #endif
00107 
00108 #endif /* #ifndef _GAN_REPEAT3_H */
00109 
00122 /* This library is free software; you can redistribute it and/or
00123    modify it under the terms of the GNU Lesser General Public
00124    License as published by the Free Software Foundation; either
00125    version 2.1 of the License, or (at your option) any later version.
00126 
00127    This library is distributed in the hope that it will be useful,
00128    but WITHOUT ANY WARRANTY; without even the implied warranty of
00129    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00130    Lesser General Public License for more details.
00131 
00132    You should have received a copy of the GNU Lesser General Public
00133    License along with this library; if not, write to the Free Software
00134    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00135 */
00136 
00137 #ifndef _GAN_MATVECF_MACROS_H
00138 #define _GAN_MATVECF_MACROS_H
00139 
00140 #ifdef __cplusplus
00141 extern "C" {
00142 #endif
00143 
00144 /* macros for testing the types of pointer arguments and then applying an
00145  * operation to them */
00146 #define GAN_TEST_OP1(A,typeA) assert(sizeof(*(A))==sizeof(typeA))
00147 #define GAN_TEST_OP2(A,B,typeA,typeB)\
00148   (assert(sizeof(*(A))==sizeof(typeA)&&sizeof(*(B))==sizeof(typeB)))
00149 #define GAN_TEST_OP3(A,B,C,typeA,typeB,typeC)\
00150   (assert(sizeof(*(A))==sizeof(typeA)&&sizeof(*(B))==sizeof(typeB)&&\
00151           sizeof(*(C))==sizeof(typeC)))
00152 #define GAN_TEST_OP4(A,B,C,D,typeA,typeB,typeC,typeD)\
00153   (assert(sizeof(*(A))==sizeof(typeA)&&sizeof(*(B))==sizeof(typeB)&&\
00154           sizeof(*(C))==sizeof(typeC)&&sizeof(*(D))==sizeof(typeD)))
00155 #define GAN_TEST_OP5(A,B,C,D,E,typeA,typeB,typeC,typeD,typeE)\
00156   (assert(sizeof(*(A))==sizeof(typeA)&&sizeof(*(B))==sizeof(typeB)&&\
00157           sizeof(*(C))==sizeof(typeC)&&sizeof(*(D))==sizeof(typeD)&&\
00158           sizeof(*(E))==sizeof(typeE)))
00159 
00160 #ifdef __cplusplus
00161 }
00162 #endif
00163 
00164 #endif /* #ifndef _GAN_MATVECF_MACROS_H */
00165 #include <gandalf/linalg/2vector.h>
00166 #include <gandalf/linalg/vec_gen.h>
00167 
00168 #ifdef __cplusplus
00169 extern "C" {
00170 #endif
00171 
00187 
00188 typedef struct Gan_Vector3
00189 {
00190    double x, y, z;
00191 } Gan_Vector3, Gan_Vector3_d;
00192 
00194 typedef struct Gan_Vector3_uc
00195 {
00196    unsigned char x, y, z;
00197 } Gan_Vector3_uc;
00198 
00200 typedef struct Gan_Vector3_s
00201 {
00202    short x, y, z;
00203 } Gan_Vector3_s;
00204 
00206 typedef struct Gan_Vector3_us
00207 {
00208    unsigned short x, y, z;
00209 } Gan_Vector3_us;
00210 
00212 typedef struct Gan_Vector3_i
00213 {
00214    int x, y, z;
00215 } Gan_Vector3_i;
00216 
00218 typedef struct Gan_Vector3_ui
00219 {
00220    unsigned int x, y, z;
00221 } Gan_Vector3_ui;
00222 
00224 #if (SIZEOF_DOUBLE == 8)
00225 typedef struct Gan_Vector3 Gan_Vector3_f64;
00226 #endif
00227 
00228 #if (SIZEOF_CHAR == 1)
00229 typedef struct Gan_Vector3_uc Gan_Vector3_ui8;
00230 #endif
00231 
00232 #if (SIZEOF_SHORT == 2)
00233 typedef struct Gan_Vector3_s  Gan_Vector3_i16;
00234 typedef struct Gan_Vector3_us Gan_Vector3_ui16;
00235 #endif
00236 
00237 #if (SIZEOF_INT == 4)
00238 typedef struct Gan_Vector3_i  Gan_Vector3_i32;
00239 typedef struct Gan_Vector3_ui Gan_Vector3_ui32;
00240 #endif
00241 
00242 /* declare functions specific to 3-vectors */
00256 /* This library is free software; you can redistribute it and/or
00257    modify it under the terms of the GNU Lesser General Public
00258    License as published by the Free Software Foundation; either
00259    version 2.1 of the License, or (at your option) any later version.
00260 
00261    This library is distributed in the hope that it will be useful,
00262    but WITHOUT ANY WARRANTY; without even the implied warranty of
00263    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00264    Lesser General Public License for more details.
00265 
00266    You should have received a copy of the GNU Lesser General Public
00267    License along with this library; if not, write to the Free Software
00268    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00269 */
00270 
00286  Gan_Vector3 *gan_vec3_fill_q ( Gan_Vector3 *p, double X, double Y, double Z );
00287 
00305  Gan_Vector3 *gan_vec3_cross_q ( const Gan_Vector3 *p, const Gan_Vector3 *q,
00306                                 Gan_Vector3 *r );
00307 
00322  Gan_Vector2 *gan_vec3_get_v2t_q ( const Gan_Vector3 *p, Gan_Vector2 *q );
00323 
00345  Gan_Vector3 *gan_vec3_set_parts_q ( Gan_Vector3 *p, const Gan_Vector2 *q, double s );
00346 
00352 #define GAN_VECTYPE Gan_Vector3
00353 #define GAN_VECTOR_TYPE Gan_Vector
00354 #define GAN_VEC_ELEMENT_TYPE GAN_DOUBLE
00355 #define GAN_REALTYPE double
00356 #define GAN_FWRITE_LENDIAN gan_fwrite_lendian_f64
00357 #define GAN_FREAD_LENDIAN  gan_fread_lendian_f64
00358 #define GAN_VEC_FPRINT        gan_vec3_fprint
00359 #define GAN_VEC_PRINT         gan_vec3_print
00360 #define GAN_VEC_FSCANF        gan_vec3_fscanf
00361 #define GAN_VEC_FWRITE        gan_vec3_fwrite
00362 #define GAN_VEC_FREAD         gan_vec3_fread
00363 #define GAN_VEC_ZERO_Q        gan_vec3_zero_q
00364 #define GAN_VEC_ZERO_S        gan_vec3_zero_s
00365 #define GAN_VEC_COPY_Q        gan_vec3_copy_q
00366 #define GAN_VEC_COPY_S        gan_vec3_copy_s
00367 #define GAN_VEC_SCALE_Q       gan_vec3_scale_q
00368 #define GAN_VEC_SCALE_S       gan_vec3_scale_s
00369 #define GAN_VEC_SCALE_I       gan_vec3_scale_i
00370 #define GAN_VEC_DIVIDE_Q      gan_vec3_divide_q
00371 #define GAN_VEC_DIVIDE_S      gan_vec3_divide_s
00372 #define GAN_VEC_DIVIDE_I      gan_vec3_divide_i
00373 #define GAN_VEC_NEGATE_Q      gan_vec3_negate_q
00374 #define GAN_VEC_NEGATE_S      gan_vec3_negate_s
00375 #define GAN_VEC_NEGATE_I      gan_vec3_negate_i
00376 #define GAN_VEC_UNIT_Q        gan_vec3_unit_q
00377 #define GAN_VEC_UNIT_S        gan_vec3_unit_s
00378 #define GAN_VEC_UNIT_I        gan_vec3_unit_i
00379 #define GAN_VEC_ADD_Q         gan_vec3_add_q
00380 #define GAN_VEC_ADD_I1        gan_vec3_add_i1
00381 #define GAN_VEC_ADD_I2        gan_vec3_add_i2
00382 #define GAN_VEC_INCREMENT     gan_vec3_increment
00383 #define GAN_VEC_ADD_S         gan_vec3_add_s
00384 #define GAN_VEC_SUB_Q         gan_vec3_sub_q
00385 #define GAN_VEC_SUB_I1        gan_vec3_sub_i1
00386 #define GAN_VEC_SUB_I2        gan_vec3_sub_i2
00387 #define GAN_VEC_DECREMENT     gan_vec3_decrement
00388 #define GAN_VEC_SUB_S         gan_vec3_sub_s
00389 #define GAN_VEC_DOT_Q         gan_vec3_dot_q
00390 #define GAN_VEC_DOT_S         gan_vec3_dot_s
00391 #define GAN_VEC_SQRLEN_Q      gan_vec3_sqrlen_q
00392 #define GAN_VEC_SQRLEN_S      gan_vec3_sqrlen_s
00393 #define GAN_VEC_FROM_VEC_Q    gan_vec3_from_vec_q
00394 #define GAN_VEC_FROM_VEC_S    gan_vec3_from_vec_s
00395 
00409 /* This library is free software; you can redistribute it and/or
00410    modify it under the terms of the GNU Lesser General Public
00411    License as published by the Free Software Foundation; either
00412    version 2.1 of the License, or (at your option) any later version.
00413 
00414    This library is distributed in the hope that it will be useful,
00415    but WITHOUT ANY WARRANTY; without even the implied warranty of
00416    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00417    Lesser General Public License for more details.
00418 
00419    You should have received a copy of the GNU Lesser General Public
00420    License along with this library; if not, write to the Free Software
00421    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00422 */
00423 
00424 /* function declarations for functions common to all small vector types */
00425 
00426 
00427 /* documentation for macros defined in individual header files */
00428 
00439  Gan_Vector3 *gan_vec3_zero_q ( Gan_Vector3 *p );
00440 
00455  Gan_Vector3 *gan_vec3_copy_q ( Gan_Vector3 *p, Gan_Vector3 *q );
00456 
00472  Gan_Vector3 *gan_vec3_scale_q ( Gan_Vector3 *p, double a,
00473                                Gan_Vector3 *q );
00474 
00480  Gan_Vector3 *gan_vec3_scale_i ( Gan_Vector3 *p, double a );
00481 
00488  Gan_Vector3 *gan_vec3_divide_q ( Gan_Vector3 *p, double a,
00489                                 Gan_Vector3 *q );
00490 
00496  Gan_Vector3 *gan_vec3_divide_i ( Gan_Vector3 *p, double a );
00497 
00505  Gan_Vector3 *gan_vec3_negate_q ( Gan_Vector3 *p, Gan_Vector3 *q );
00506 
00514  Gan_Vector3 *gan_vec3_negate_i ( Gan_Vector3 *p );
00515 
00521  Gan_Vector3 *gan_vec3_unit_i ( Gan_Vector3 *p );
00522 
00540  Gan_Vector3 *gan_vec3_add_q ( Gan_Vector3 *p, Gan_Vector3 *q, Gan_Vector3 *r );
00541 
00550  Gan_Vector3 *gan_vec3_add_i1 ( Gan_Vector3 *p, Gan_Vector3 *q );
00551 
00560  Gan_Vector3 *gan_vec3_add_i2 ( Gan_Vector3 *p, Gan_Vector3 *q );
00561 
00570  Gan_Vector3 *gan_vec3_increment ( Gan_Vector3 *p, Gan_Vector3 *q );
00571 
00589  Gan_Vector3 *gan_vec3_sub_q ( Gan_Vector3 *p, Gan_Vector3 *q, Gan_Vector3 *r );
00590 
00599  Gan_Vector3 *gan_vec3_sub_i1 ( Gan_Vector3 *p, Gan_Vector3 *q );
00600 
00609  Gan_Vector3 *gan_vec3_sub_i2 ( Gan_Vector3 *p, Gan_Vector3 *q );
00610 
00619  Gan_Vector3 *gan_vec3_decrement ( Gan_Vector3 *p, Gan_Vector3 *q );
00620 
00636  double gan_vec3_dot_q ( const Gan_Vector3 *p, const Gan_Vector3 *q );
00637 
00655  double gan_vec3_sqrlen_q ( const Gan_Vector3 *p );
00656 
00666  Gan_Vector3 gan_vec3_from_vec_s ( const Gan_Vector *x );
00667 
00685 /* This library is free software; you can redistribute it and/or
00686    modify it under the terms of the GNU Lesser General Public
00687    License as published by the Free Software Foundation; either
00688    version 2.1 of the License, or (at your option) any later version.
00689 
00690    This library is distributed in the hope that it will be useful,
00691    but WITHOUT ANY WARRANTY; without even the implied warranty of
00692    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00693    Lesser General Public License for more details.
00694 
00695    You should have received a copy of the GNU Lesser General Public
00696    License along with this library; if not, write to the Free Software
00697    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00698 */
00699 
00700 #undef GAN_VECTYPE
00701 #undef GAN_VECTOR_TYPE
00702 #undef GAN_VEC_ELEMENT_TYPE
00703 #undef GAN_REALTYPE
00704 #undef GAN_FWRITE_LENDIAN
00705 #undef GAN_FREAD_LENDIAN
00706 #undef GAN_VEC_FPRINT
00707 #undef GAN_VEC_PRINT
00708 #undef GAN_VEC_FSCANF
00709 #undef GAN_VEC_FWRITE
00710 #undef GAN_VEC_FREAD
00711 #undef GAN_VEC_ZERO_Q
00712 #undef GAN_VEC_ZERO_S
00713 #undef GAN_VEC_COPY_Q
00714 #undef GAN_VEC_COPY_S
00715 #undef GAN_VEC_SCALE_Q
00716 #undef GAN_VEC_SCALE_S
00717 #undef GAN_VEC_SCALE_I
00718 #undef GAN_VEC_DIVIDE_Q
00719 #undef GAN_VEC_DIVIDE_S
00720 #undef GAN_VEC_DIVIDE_I
00721 #undef GAN_VEC_NEGATE_Q
00722 #undef GAN_VEC_NEGATE_S
00723 #undef GAN_VEC_NEGATE_I
00724 #undef GAN_VEC_UNIT_Q
00725 #undef GAN_VEC_UNIT_S
00726 #undef GAN_VEC_UNIT_I
00727 #undef GAN_VEC_ADD_Q
00728 #undef GAN_VEC_ADD_I1
00729 #undef GAN_VEC_ADD_I2
00730 #undef GAN_VEC_INCREMENT
00731 #undef GAN_VEC_ADD_S
00732 #undef GAN_VEC_SUB_Q
00733 #undef GAN_VEC_SUB_I1
00734 #undef GAN_VEC_SUB_I2
00735 #undef GAN_VEC_DECREMENT
00736 #undef GAN_VEC_SUB_S
00737 #undef GAN_VEC_DOT_Q
00738 #undef GAN_VEC_DOT_S
00739 #undef GAN_VEC_SQRLEN_Q
00740 #undef GAN_VEC_SQRLEN_S
00741 #undef GAN_VEC_FROM_VEC_Q
00742 #undef GAN_VEC_FROM_VEC_S
00743 
00756 #ifdef __cplusplus
00757 }
00758 #endif
00759 
00760 #endif /* #ifndef _GAN_3VECTOR_H */

Generated on Fri Mar 17 12:44:46 2006 by  doxygen 1.3.9.1