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

4vectorf.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_4VECTORF_H
00030 #define _GAN_4VECTORF_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_REPEAT4_H
00064 #define _GAN_REPEAT4_H
00065 
00066 #ifdef __cplusplus
00067 extern "C" {
00068 #endif
00069 
00070 /* macros for constructing four-fold repetitions */
00071 #define GAN_REP4_AS(a,b,p1,p2,p3,p4) (a p1 b, a p2 b, a p3 b, a p4 b)
00072 #define GAN_REP4_AS_C(a,b) GAN_REP4_AS(a,b,x,y,z,w)
00073 #define GAN_REP4_A(a,p1,p2,p3,p4) (a p1, a p2, a p3, a p4)
00074 #define GAN_REP4_A_C(a) GAN_REP4_A(a,x,y,z,w)
00075 
00076 #define GAN_FREP4_A(a,b,p1,p2,p3,p4,q1,q2,q3,q4)\
00077     (a p1 b q1, a p2 b q2,\
00078      a p3 b q3, a p4 b q4)
00079 #define GAN_FREP4_A_C(a,b,p1,p2,p3,p4) GAN_FREP4_A(a,b,x,y,z,w,p1,p2,p3,p4)
00080 
00081 #define GAN_REP4_ABS(a,b,c,p1,p2,p3,p4,q1,q2,q3,q4)\
00082            (a p1 b q1 c, a p2 b q2 c, a p3 b q3 c, a p4 b q4 c)
00083 #define GAN_REP4_AAS(a,b,c,p1,p2,p3,p4)\
00084            GAN_REP4_ABS(a,b,c,p1,p2,p3,p4,p1,p2,p3,p4)
00085 #define GAN_REP4_AAS_C(a,b,c) GAN_REP4_AAS(a,b,c,x,y,z,w)
00086 
00087 #define GAN_REP4_AB(a,b,p1,p2,p3,p4,q1,q2,q3,q4)\
00088            (a p1 b q1, a p2 b q2, a p3 b q3, a p4 b q4)
00089 #define GAN_REP4_AA(a,b,p1,p2,p3,p4)\
00090            GAN_REP4_AB(a,b,p1,p2,p3,p4,p1,p2,p3,p4)
00091 #define GAN_REP4_AA_C(a,b) GAN_REP4_AA(a,b,x,y,z,w)
00092 
00093 #define GAN_REP4_ABCS(a,b,c,d,p1,p2,p3,p4,q1,q2,q3,q4,r1,r2,r3,r4)\
00094      (a p1 b q1 c r1 d, a p2 b q2 c r2 d, a p3 b q3 c r3 d, a p4 b q4 c r4 d)
00095 #define GAN_REP4_ABC(a,b,c,p1,p2,p3,p4,q1,q2,q3,q4,r1,r2,r3,r4)\
00096      (a p1 b q1 c r1, a p2 b q2 c r2, a p3 b q3 c r3, a p4 b q4 c r4)
00097 #define GAN_REP4_AAA(a,b,c,p1,p2,p3,p4)\
00098            GAN_REP4_ABC(a,b,c,p1,p2,p3,p4,p1,p2,p3,p4,p1,p2,p3,p4)
00099 #define GAN_REP4_AAA_C(a,b,c) GAN_REP4_AAA(a,b,c,x,y,z,w)
00100 
00101 #define GAN_REP4_OP_AB(a,b,p1,p2,p3,p4,q1,q2,q3,q4,op)\
00102         (a p1 b q1 op a p2 b q2 op a p3 b q3 op a p4 b q4)
00103 #define GAN_REP4_OP_AA(a,b,p1,p2,p3,p4,op)\
00104            GAN_REP4_OP_AB(a,b,p1,p2,p3,p4,p1,p2,p3,p4,op)
00105 #define GAN_REP4_OP_AA_C(a,b,op) GAN_REP4_OP_AA(a,b,x,y,z,w,op)
00106 
00107 #ifdef __cplusplus
00108 }
00109 #endif
00110 
00111 #endif /* #ifndef _GAN_REPEAT4_H */
00112 
00125 /* This library is free software; you can redistribute it and/or
00126    modify it under the terms of the GNU Lesser General Public
00127    License as published by the Free Software Foundation; either
00128    version 2.1 of the License, or (at your option) any later version.
00129 
00130    This library is distributed in the hope that it will be useful,
00131    but WITHOUT ANY WARRANTY; without even the implied warranty of
00132    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00133    Lesser General Public License for more details.
00134 
00135    You should have received a copy of the GNU Lesser General Public
00136    License along with this library; if not, write to the Free Software
00137    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00138 */
00139 
00140 #ifndef _GAN_MATVECF_MACROS_H
00141 #define _GAN_MATVECF_MACROS_H
00142 
00143 #ifdef __cplusplus
00144 extern "C" {
00145 #endif
00146 
00147 /* macros for testing the types of pointer arguments and then applying an
00148  * operation to them */
00149 #define GAN_TEST_OP1(A,typeA) assert(sizeof(*(A))==sizeof(typeA))
00150 #define GAN_TEST_OP2(A,B,typeA,typeB)\
00151   (assert(sizeof(*(A))==sizeof(typeA)&&sizeof(*(B))==sizeof(typeB)))
00152 #define GAN_TEST_OP3(A,B,C,typeA,typeB,typeC)\
00153   (assert(sizeof(*(A))==sizeof(typeA)&&sizeof(*(B))==sizeof(typeB)&&\
00154           sizeof(*(C))==sizeof(typeC)))
00155 #define GAN_TEST_OP4(A,B,C,D,typeA,typeB,typeC,typeD)\
00156   (assert(sizeof(*(A))==sizeof(typeA)&&sizeof(*(B))==sizeof(typeB)&&\
00157           sizeof(*(C))==sizeof(typeC)&&sizeof(*(D))==sizeof(typeD)))
00158 #define GAN_TEST_OP5(A,B,C,D,E,typeA,typeB,typeC,typeD,typeE)\
00159   (assert(sizeof(*(A))==sizeof(typeA)&&sizeof(*(B))==sizeof(typeB)&&\
00160           sizeof(*(C))==sizeof(typeC)&&sizeof(*(D))==sizeof(typeD)&&\
00161           sizeof(*(E))==sizeof(typeE)))
00162 
00163 #ifdef __cplusplus
00164 }
00165 #endif
00166 
00167 #endif /* #ifndef _GAN_MATVECF_MACROS_H */
00168 #include <gandalf/linalg/3vectorf.h>
00169 #include <gandalf/linalg/vecf_gen.h>
00170 
00171 #ifdef __cplusplus
00172 extern "C" {
00173 #endif
00174 
00190 
00191 typedef struct Gan_Vector4_f
00192 {
00193    float x, y, z, w;
00194 } Gan_Vector4_f;
00195 
00197 #if (SIZEOF_FLOAT == 4)
00198 typedef struct Gan_Vector4_f Gan_Vector4_f32;
00199 #endif
00200 
00201 /* declare functions specific to 4-vectors */
00215 /* This library is free software; you can redistribute it and/or
00216    modify it under the terms of the GNU Lesser General Public
00217    License as published by the Free Software Foundation; either
00218    version 2.1 of the License, or (at your option) any later version.
00219 
00220    This library is distributed in the hope that it will be useful,
00221    but WITHOUT ANY WARRANTY; without even the implied warranty of
00222    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00223    Lesser General Public License for more details.
00224 
00225    You should have received a copy of the GNU Lesser General Public
00226    License along with this library; if not, write to the Free Software
00227    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00228 */
00229 
00245  Gan_Vector4_f *gan_vec4f_fill_q ( Gan_Vector4_f *p,
00246                                   float X, float Y, float Z, float W );
00247 
00262  Gan_Vector3_f *gan_vec4f_get_v3t_q ( const Gan_Vector4_f *p, Gan_Vector3_f *q );
00263 
00285  Gan_Vector4_f *gan_vec4f_set_parts_q ( Gan_Vector4_f *p,
00286                                        const Gan_Vector3_f *q, float s );
00287 
00299  Gan_Vector4_f *gan_vec4f_set_blocks_q ( Gan_Vector4_f *p,
00300                                         const Gan_Vector2_f *q, const Gan_Vector2_f *r );
00301 
00307 #define GAN_VECTYPE Gan_Vector4_f
00308 #define GAN_VECTOR_TYPE Gan_Vector_f
00309 #define GAN_VEC_ELEMENT_TYPE GAN_FLOAT
00310 #define GAN_REALTYPE float
00311 #define GAN_FWRITE_LENDIAN gan_fwrite_lendian_f32
00312 #define GAN_FREAD_LENDIAN  gan_fread_lendian_f32
00313 #define GAN_VEC_FPRINT      gan_vec4f_fprint
00314 #define GAN_VEC_PRINT       gan_vec4f_print
00315 #define GAN_VEC_FSCANF      gan_vec4f_fscanf
00316 #define GAN_VEC_FWRITE      gan_vec4f_fwrite
00317 #define GAN_VEC_FREAD       gan_vec4f_fread
00318 #define GAN_VEC_ZERO_Q      gan_vec4f_zero_q
00319 #define GAN_VEC_ZERO_S      gan_vec4f_zero_s
00320 #define GAN_VEC_COPY_Q      gan_vec4f_copy_q
00321 #define GAN_VEC_COPY_S      gan_vec4f_copy_s
00322 #define GAN_VEC_SCALE_Q     gan_vec4f_scale_q
00323 #define GAN_VEC_SCALE_S     gan_vec4f_scale_s
00324 #define GAN_VEC_SCALE_I     gan_vec4f_scale_i
00325 #define GAN_VEC_DIVIDE_Q    gan_vec4f_divide_q
00326 #define GAN_VEC_DIVIDE_S    gan_vec4f_divide_s
00327 #define GAN_VEC_DIVIDE_I    gan_vec4f_divide_i
00328 #define GAN_VEC_NEGATE_Q    gan_vec4f_negate_q
00329 #define GAN_VEC_NEGATE_S    gan_vec4f_negate_s
00330 #define GAN_VEC_NEGATE_I    gan_vec4f_negate_i
00331 #define GAN_VEC_UNIT_Q      gan_vec4f_unit_q
00332 #define GAN_VEC_UNIT_S      gan_vec4f_unit_s
00333 #define GAN_VEC_UNIT_I      gan_vec4f_unit_i
00334 #define GAN_VEC_ADD_Q       gan_vec4f_add_q
00335 #define GAN_VEC_ADD_I1      gan_vec4f_add_i1
00336 #define GAN_VEC_ADD_I2      gan_vec4f_add_i2
00337 #define GAN_VEC_INCREMENT   gan_vec4f_increment
00338 #define GAN_VEC_ADD_S       gan_vec4f_add_s
00339 #define GAN_VEC_SUB_Q       gan_vec4f_sub_q
00340 #define GAN_VEC_SUB_I1      gan_vec4f_sub_i1
00341 #define GAN_VEC_SUB_I2      gan_vec4f_sub_i2
00342 #define GAN_VEC_DECREMENT   gan_vec4f_decrement
00343 #define GAN_VEC_SUB_S       gan_vec4f_sub_s
00344 #define GAN_VEC_DOT_Q       gan_vec4f_dot_q
00345 #define GAN_VEC_DOT_S       gan_vec4f_dot_s
00346 #define GAN_VEC_SQRLEN_Q    gan_vec4f_sqrlen_q
00347 #define GAN_VEC_SQRLEN_S    gan_vec4f_sqrlen_s
00348 #define GAN_VEC_FROM_VEC_Q  gan_vec4f_from_vecf_q
00349 #define GAN_VEC_FROM_VEC_S  gan_vec4f_from_vecf_s
00350 
00364 /* This library is free software; you can redistribute it and/or
00365    modify it under the terms of the GNU Lesser General Public
00366    License as published by the Free Software Foundation; either
00367    version 2.1 of the License, or (at your option) any later version.
00368 
00369    This library is distributed in the hope that it will be useful,
00370    but WITHOUT ANY WARRANTY; without even the implied warranty of
00371    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00372    Lesser General Public License for more details.
00373 
00374    You should have received a copy of the GNU Lesser General Public
00375    License along with this library; if not, write to the Free Software
00376    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00377 */
00378 
00379 /* function declarations for functions common to all small vector types */
00380 
00381 
00382 /* documentation for macros defined in individual header files */
00383 
00394  Gan_Vector4_f *gan_vec4f_zero_q ( Gan_Vector4_f *p );
00395 
00410  Gan_Vector4_f *gan_vec4f_copy_q ( Gan_Vector4_f *p, Gan_Vector4_f *q );
00411 
00427  Gan_Vector4_f *gan_vec4f_scale_q ( Gan_Vector4_f *p, float a,
00428                                Gan_Vector4_f *q );
00429 
00435  Gan_Vector4_f *gan_vec4f_scale_i ( Gan_Vector4_f *p, float a );
00436 
00443  Gan_Vector4_f *gan_vec4f_divide_q ( Gan_Vector4_f *p, float a,
00444                                 Gan_Vector4_f *q );
00445 
00451  Gan_Vector4_f *gan_vec4f_divide_i ( Gan_Vector4_f *p, float a );
00452 
00460  Gan_Vector4_f *gan_vec4f_negate_q ( Gan_Vector4_f *p, Gan_Vector4_f *q );
00461 
00469  Gan_Vector4_f *gan_vec4f_negate_i ( Gan_Vector4_f *p );
00470 
00476  Gan_Vector4_f *gan_vec4f_unit_i ( Gan_Vector4_f *p );
00477 
00495  Gan_Vector4_f *gan_vec4f_add_q ( Gan_Vector4_f *p, Gan_Vector4_f *q, Gan_Vector4_f *r );
00496 
00505  Gan_Vector4_f *gan_vec4f_add_i1 ( Gan_Vector4_f *p, Gan_Vector4_f *q );
00506 
00515  Gan_Vector4_f *gan_vec4f_add_i2 ( Gan_Vector4_f *p, Gan_Vector4_f *q );
00516 
00525  Gan_Vector4_f *gan_vec4f_increment ( Gan_Vector4_f *p, Gan_Vector4_f *q );
00526 
00544  Gan_Vector4_f *gan_vec4f_sub_q ( Gan_Vector4_f *p, Gan_Vector4_f *q, Gan_Vector4_f *r );
00545 
00554  Gan_Vector4_f *gan_vec4f_sub_i1 ( Gan_Vector4_f *p, Gan_Vector4_f *q );
00555 
00564  Gan_Vector4_f *gan_vec4f_sub_i2 ( Gan_Vector4_f *p, Gan_Vector4_f *q );
00565 
00574  Gan_Vector4_f *gan_vec4f_decrement ( Gan_Vector4_f *p, Gan_Vector4_f *q );
00575 
00591  float gan_vec4f_dot_q ( const Gan_Vector4_f *p, const Gan_Vector4_f *q );
00592 
00610  float gan_vec4f_sqrlen_q ( const Gan_Vector4_f *p );
00611 
00621  Gan_Vector4_f gan_vec4f_from_vecf_s ( const Gan_Vector_f *x );
00622 
00640 /* This library is free software; you can redistribute it and/or
00641    modify it under the terms of the GNU Lesser General Public
00642    License as published by the Free Software Foundation; either
00643    version 2.1 of the License, or (at your option) any later version.
00644 
00645    This library is distributed in the hope that it will be useful,
00646    but WITHOUT ANY WARRANTY; without even the implied warranty of
00647    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00648    Lesser General Public License for more details.
00649 
00650    You should have received a copy of the GNU Lesser General Public
00651    License along with this library; if not, write to the Free Software
00652    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00653 */
00654 
00655 #undef GAN_VECTYPE
00656 #undef GAN_VECTOR_TYPE
00657 #undef GAN_VEC_ELEMENT_TYPE
00658 #undef GAN_REALTYPE
00659 #undef GAN_FWRITE_LENDIAN
00660 #undef GAN_FREAD_LENDIAN
00661 #undef GAN_VEC_FPRINT
00662 #undef GAN_VEC_PRINT
00663 #undef GAN_VEC_FSCANF
00664 #undef GAN_VEC_FWRITE
00665 #undef GAN_VEC_FREAD
00666 #undef GAN_VEC_ZERO_Q
00667 #undef GAN_VEC_ZERO_S
00668 #undef GAN_VEC_COPY_Q
00669 #undef GAN_VEC_COPY_S
00670 #undef GAN_VEC_SCALE_Q
00671 #undef GAN_VEC_SCALE_S
00672 #undef GAN_VEC_SCALE_I
00673 #undef GAN_VEC_DIVIDE_Q
00674 #undef GAN_VEC_DIVIDE_S
00675 #undef GAN_VEC_DIVIDE_I
00676 #undef GAN_VEC_NEGATE_Q
00677 #undef GAN_VEC_NEGATE_S
00678 #undef GAN_VEC_NEGATE_I
00679 #undef GAN_VEC_UNIT_Q
00680 #undef GAN_VEC_UNIT_S
00681 #undef GAN_VEC_UNIT_I
00682 #undef GAN_VEC_ADD_Q
00683 #undef GAN_VEC_ADD_I1
00684 #undef GAN_VEC_ADD_I2
00685 #undef GAN_VEC_INCREMENT
00686 #undef GAN_VEC_ADD_S
00687 #undef GAN_VEC_SUB_Q
00688 #undef GAN_VEC_SUB_I1
00689 #undef GAN_VEC_SUB_I2
00690 #undef GAN_VEC_DECREMENT
00691 #undef GAN_VEC_SUB_S
00692 #undef GAN_VEC_DOT_Q
00693 #undef GAN_VEC_DOT_S
00694 #undef GAN_VEC_SQRLEN_Q
00695 #undef GAN_VEC_SQRLEN_S
00696 #undef GAN_VEC_FROM_VEC_Q
00697 #undef GAN_VEC_FROM_VEC_S
00698 
00711 #ifdef __cplusplus
00712 }
00713 #endif
00714 
00715 #endif /* #ifndef _GAN_4VECTORF_H */

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