00001
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
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
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063 #ifndef _GAN_REPEAT4_H
00064 #define _GAN_REPEAT4_H
00065
00066 #ifdef __cplusplus
00067 extern "C" {
00068 #endif
00069
00070
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
00112
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
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
00148
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
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
00215
00216
00217
00218
00219
00220
00221
00222
00223
00224
00225
00226
00227
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
00365
00366
00367
00368
00369
00370
00371
00372
00373
00374
00375
00376
00377
00378
00379
00380
00381
00382
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
00641
00642
00643
00644
00645
00646
00647
00648
00649
00650
00651
00652
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