Main Page   Modules   Compound List   File List   Compound Members   File Members  

3vectorf.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_3VECTORF_H
00030 #define _GAN_3VECTORF_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/2vectorf.h>
00166 #include <gandalf/linalg/vecf_gen.h>
00167 
00168 #ifdef __cplusplus
00169 extern "C" {
00170 #endif
00171 
00187 
00188 typedef struct Gan_Vector3_f
00189 {
00190    float x, y, z;
00191 } Gan_Vector3_f;
00192 
00193 /* declare functions specific to 3-vectors */
00208 /* This library is free software; you can redistribute it and/or
00209    modify it under the terms of the GNU Lesser General Public
00210    License as published by the Free Software Foundation; either
00211    version 2.1 of the License, or (at your option) any later version.
00212 
00213    This library is distributed in the hope that it will be useful,
00214    but WITHOUT ANY WARRANTY; without even the implied warranty of
00215    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00216    Lesser General Public License for more details.
00217 
00218    You should have received a copy of the GNU Lesser General Public
00219    License along with this library; if not, write to the Free Software
00220    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00221 */
00222 
00238 Gan_Vector3_f *gan_vec3f_fill_q ( Gan_Vector3_f *p,
00239                                   float X, float Y, float Z );
00240 
00258 Gan_Vector3_f *gan_vec3f_cross_q ( Gan_Vector3_f *p, Gan_Vector3_f *q,
00259                                    Gan_Vector3_f *r );
00260 
00275 Gan_Vector2_f *gan_vec3f_get_v2t_q ( Gan_Vector3_f *p, Gan_Vector2_f *q );
00276 
00298 Gan_Vector3_f *gan_vec3f_set_parts_q ( Gan_Vector3_f *p,
00299                                        Gan_Vector2_f *q, float s );
00300 
00306 #define GAN_VECTYPE Gan_Vector3_f
00307 #define GAN_VECTOR_TYPE Gan_Vector_f
00308 #define GAN_VEC_ELEMENT_TYPE GAN_FLOAT
00309 #define GAN_REALTYPE float
00310 #define GAN_VEC_FPRINT        gan_vec3f_fprint
00311 #define GAN_VEC_PRINT         gan_vec3f_print
00312 #define GAN_VEC_FSCANF        gan_vec3f_fscanf
00313 #define GAN_VEC_FWRITE        gan_vec3f_fwrite
00314 #define GAN_VEC_FREAD         gan_vec3f_fread
00315 #define GAN_VEC_ZERO_Q        gan_vec3f_zero_q
00316 #define GAN_VEC_ZERO_S        gan_vec3f_zero_s
00317 #define GAN_VEC_COPY_Q        gan_vec3f_copy_q
00318 #define GAN_VEC_COPY_S        gan_vec3f_copy_s
00319 #define GAN_VEC_SCALE_Q       gan_vec3f_scale_q
00320 #define GAN_VEC_SCALE_S       gan_vec3f_scale_s
00321 #define GAN_VEC_SCALE_I       gan_vec3f_scale_i
00322 #define GAN_VEC_DIVIDE_Q      gan_vec3f_divide_q
00323 #define GAN_VEC_DIVIDE_S      gan_vec3f_divide_s
00324 #define GAN_VEC_DIVIDE_I      gan_vec3f_divide_i
00325 #define GAN_VEC_NEGATE_Q      gan_vec3f_negate_q
00326 #define GAN_VEC_NEGATE_S      gan_vec3f_negate_s
00327 #define GAN_VEC_NEGATE_I      gan_vec3f_negate_i
00328 #define GAN_VEC_UNIT_Q        gan_vec3f_unit_q
00329 #define GAN_VEC_UNIT_S        gan_vec3f_unit_s
00330 #define GAN_VEC_UNIT_I        gan_vec3f_unit_i
00331 #define GAN_VEC_ADD_Q         gan_vec3f_add_q
00332 #define GAN_VEC_ADD_I1        gan_vec3f_add_i1
00333 #define GAN_VEC_ADD_I2        gan_vec3f_add_i2
00334 #define GAN_VEC_INCREMENT     gan_vec3f_increment
00335 #define GAN_VEC_ADD_S         gan_vec3f_add_s
00336 #define GAN_VEC_SUB_Q         gan_vec3f_sub_q
00337 #define GAN_VEC_SUB_I1        gan_vec3f_sub_i1
00338 #define GAN_VEC_SUB_I2        gan_vec3f_sub_i2
00339 #define GAN_VEC_DECREMENT     gan_vec3f_decrement
00340 #define GAN_VEC_SUB_S         gan_vec3f_sub_s
00341 #define GAN_VEC_DOT_Q         gan_vec3f_dot_q
00342 #define GAN_VEC_DOT_S         gan_vec3f_dot_s
00343 #define GAN_VEC_SQRLEN_Q      gan_vec3f_sqrlen_q
00344 #define GAN_VEC_SQRLEN_S      gan_vec3f_sqrlen_s
00345 #define GAN_VEC_FROM_VEC_Q    gan_vec3f_from_vecf_q
00346 #define GAN_VEC_FROM_VEC_S    gan_vec3f_from_vecf_s
00347 
00361 /* This library is free software; you can redistribute it and/or
00362    modify it under the terms of the GNU Lesser General Public
00363    License as published by the Free Software Foundation; either
00364    version 2.1 of the License, or (at your option) any later version.
00365 
00366    This library is distributed in the hope that it will be useful,
00367    but WITHOUT ANY WARRANTY; without even the implied warranty of
00368    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00369    Lesser General Public License for more details.
00370 
00371    You should have received a copy of the GNU Lesser General Public
00372    License along with this library; if not, write to the Free Software
00373    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00374 */
00375 
00376 /* function declarations for functions common to all small vector types */
00377 
00378 
00379 /* documentation for macros defined in individual header files */
00380 
00391 Gan_Vector3_f *gan_vec3f_zero_q ( Gan_Vector3_f *p );
00392 
00407 Gan_Vector3_f *gan_vec3f_copy_q ( Gan_Vector3_f *p, Gan_Vector3_f *q );
00408 
00424 Gan_Vector3_f *gan_vec3f_scale_q ( Gan_Vector3_f *p, float a,
00425                                Gan_Vector3_f *q );
00426 
00432 Gan_Vector3_f *gan_vec3f_scale_i ( Gan_Vector3_f *p, float a );
00433 
00440 Gan_Vector3_f *gan_vec3f_divide_q ( Gan_Vector3_f *p, float a,
00441                                 Gan_Vector3_f *q );
00442 
00448 Gan_Vector3_f *gan_vec3f_divide_i ( Gan_Vector3_f *p, float a );
00449 
00457 Gan_Vector3_f *gan_vec3f_negate_q ( Gan_Vector3_f *p, Gan_Vector3_f *q );
00458 
00466 Gan_Vector3_f *gan_vec3f_negate_i ( Gan_Vector3_f *p );
00467 
00473 Gan_Vector3_f *gan_vec3f_unit_i ( Gan_Vector3_f *p );
00474 
00492 Gan_Vector3_f *gan_vec3f_add_q ( Gan_Vector3_f *p, Gan_Vector3_f *q, Gan_Vector3_f *r );
00493 
00502 Gan_Vector3_f *gan_vec3f_add_i1 ( Gan_Vector3_f *p, Gan_Vector3_f *q );
00503 
00512 Gan_Vector3_f *gan_vec3f_add_i2 ( Gan_Vector3_f *p, Gan_Vector3_f *q );
00513 
00522 Gan_Vector3_f *gan_vec3f_increment ( Gan_Vector3_f *p, Gan_Vector3_f *q );
00523 
00541 Gan_Vector3_f *gan_vec3f_sub_q ( Gan_Vector3_f *p, Gan_Vector3_f *q, Gan_Vector3_f *r );
00542 
00551 Gan_Vector3_f *gan_vec3f_sub_i1 ( Gan_Vector3_f *p, Gan_Vector3_f *q );
00552 
00561 Gan_Vector3_f *gan_vec3f_sub_i2 ( Gan_Vector3_f *p, Gan_Vector3_f *q );
00562 
00571 Gan_Vector3_f *gan_vec3f_decrement ( Gan_Vector3_f *p, Gan_Vector3_f *q );
00572 
00588 float gan_vec3f_dot_q ( Gan_Vector3_f *p, Gan_Vector3_f *q );
00589 
00607 float gan_vec3f_sqrlen_q ( Gan_Vector3_f *p );
00608 
00626 Gan_Vector3_f gan_vec3f_from_vecf_s ( Gan_Vector_f *x );
00627 
00645 /* This library is free software; you can redistribute it and/or
00646    modify it under the terms of the GNU Lesser General Public
00647    License as published by the Free Software Foundation; either
00648    version 2.1 of the License, or (at your option) any later version.
00649 
00650    This library is distributed in the hope that it will be useful,
00651    but WITHOUT ANY WARRANTY; without even the implied warranty of
00652    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00653    Lesser General Public License for more details.
00654 
00655    You should have received a copy of the GNU Lesser General Public
00656    License along with this library; if not, write to the Free Software
00657    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00658 */
00659 
00660 #undef GAN_VECTYPE
00661 #undef GAN_VECTOR_TYPE
00662 #undef GAN_VEC_ELEMENT_TYPE
00663 #undef GAN_REALTYPE
00664 #undef GAN_VEC_FPRINT
00665 #undef GAN_VEC_PRINT
00666 #undef GAN_VEC_FSCANF
00667 #undef GAN_VEC_FWRITE
00668 #undef GAN_VEC_FREAD
00669 #undef GAN_VEC_ZERO_Q
00670 #undef GAN_VEC_ZERO_S
00671 #undef GAN_VEC_COPY_Q
00672 #undef GAN_VEC_COPY_S
00673 #undef GAN_VEC_SCALE_Q
00674 #undef GAN_VEC_SCALE_S
00675 #undef GAN_VEC_SCALE_I
00676 #undef GAN_VEC_DIVIDE_Q
00677 #undef GAN_VEC_DIVIDE_S
00678 #undef GAN_VEC_DIVIDE_I
00679 #undef GAN_VEC_NEGATE_Q
00680 #undef GAN_VEC_NEGATE_S
00681 #undef GAN_VEC_NEGATE_I
00682 #undef GAN_VEC_UNIT_Q
00683 #undef GAN_VEC_UNIT_S
00684 #undef GAN_VEC_UNIT_I
00685 #undef GAN_VEC_ADD_Q
00686 #undef GAN_VEC_ADD_I1
00687 #undef GAN_VEC_ADD_I2
00688 #undef GAN_VEC_INCREMENT
00689 #undef GAN_VEC_ADD_S
00690 #undef GAN_VEC_SUB_Q
00691 #undef GAN_VEC_SUB_I1
00692 #undef GAN_VEC_SUB_I2
00693 #undef GAN_VEC_DECREMENT
00694 #undef GAN_VEC_SUB_S
00695 #undef GAN_VEC_DOT_Q
00696 #undef GAN_VEC_DOT_S
00697 #undef GAN_VEC_SQRLEN_Q
00698 #undef GAN_VEC_SQRLEN_S
00699 #undef GAN_VEC_FROM_VEC_Q
00700 #undef GAN_VEC_FROM_VEC_S
00701 
00714 #ifdef __cplusplus
00715 }
00716 #endif
00717 
00718 #endif /* #ifndef _GAN_3VECTORF_H */

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