00001
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 #ifndef _GAN_4VECTOR_H
00030 #define _GAN_4VECTOR_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/3vector.h>
00169 #include <gandalf/linalg/vec_gen.h>
00170
00171 #ifdef __cplusplus
00172 extern "C" {
00173 #endif
00174
00190
00191 typedef struct Gan_Vector4
00192 {
00193 double x, y, z, w;
00194 } Gan_Vector4, Gan_Vector4_d;
00195
00197 typedef struct Gan_Vector4_uc
00198 {
00199 unsigned char x, y, z, w;
00200 } Gan_Vector4_uc;
00201
00203 typedef struct Gan_Vector4_i
00204 {
00205 int x, y, z, w;
00206 } Gan_Vector4_i;
00207
00209 typedef struct Gan_Vector4_ui
00210 {
00211 unsigned int x, y, z, w;
00212 } Gan_Vector4_ui;
00213
00214
00228
00229
00230
00231
00232
00233
00234
00235
00236
00237
00238
00239
00240
00241
00242
00258 Gan_Vector4 *gan_vec4_fill_q ( Gan_Vector4 *p,
00259 double X, double Y, double Z, double W );
00260
00275 Gan_Vector3 *gan_vec4_get_v3t_q ( Gan_Vector4 *p, Gan_Vector3 *q );
00276
00298 Gan_Vector4 *gan_vec4_set_parts_q ( Gan_Vector4 *p, Gan_Vector3 *q, double s );
00299
00311 Gan_Vector4 *gan_vec4_set_blocks_q ( Gan_Vector4 *p,
00312 Gan_Vector2 *q, Gan_Vector2 *r );
00313
00319 #define GAN_VECTYPE Gan_Vector4
00320 #define GAN_VECTOR_TYPE Gan_Vector
00321 #define GAN_VEC_ELEMENT_TYPE GAN_DOUBLE
00322 #define GAN_REALTYPE double
00323 #define GAN_VEC_FPRINT gan_vec4_fprint
00324 #define GAN_VEC_PRINT gan_vec4_print
00325 #define GAN_VEC_FSCANF gan_vec4_fscanf
00326 #define GAN_VEC_FWRITE gan_vec4_fwrite
00327 #define GAN_VEC_FREAD gan_vec4_fread
00328 #define GAN_VEC_ZERO_Q gan_vec4_zero_q
00329 #define GAN_VEC_ZERO_S gan_vec4_zero_s
00330 #define GAN_VEC_COPY_Q gan_vec4_copy_q
00331 #define GAN_VEC_COPY_S gan_vec4_copy_s
00332 #define GAN_VEC_SCALE_Q gan_vec4_scale_q
00333 #define GAN_VEC_SCALE_S gan_vec4_scale_s
00334 #define GAN_VEC_SCALE_I gan_vec4_scale_i
00335 #define GAN_VEC_DIVIDE_Q gan_vec4_divide_q
00336 #define GAN_VEC_DIVIDE_S gan_vec4_divide_s
00337 #define GAN_VEC_DIVIDE_I gan_vec4_divide_i
00338 #define GAN_VEC_NEGATE_Q gan_vec4_negate_q
00339 #define GAN_VEC_NEGATE_S gan_vec4_negate_s
00340 #define GAN_VEC_NEGATE_I gan_vec4_negate_i
00341 #define GAN_VEC_UNIT_Q gan_vec4_unit_q
00342 #define GAN_VEC_UNIT_S gan_vec4_unit_s
00343 #define GAN_VEC_UNIT_I gan_vec4_unit_i
00344 #define GAN_VEC_ADD_Q gan_vec4_add_q
00345 #define GAN_VEC_ADD_I1 gan_vec4_add_i1
00346 #define GAN_VEC_ADD_I2 gan_vec4_add_i2
00347 #define GAN_VEC_INCREMENT gan_vec4_increment
00348 #define GAN_VEC_ADD_S gan_vec4_add_s
00349 #define GAN_VEC_SUB_Q gan_vec4_sub_q
00350 #define GAN_VEC_SUB_I1 gan_vec4_sub_i1
00351 #define GAN_VEC_SUB_I2 gan_vec4_sub_i2
00352 #define GAN_VEC_DECREMENT gan_vec4_decrement
00353 #define GAN_VEC_SUB_S gan_vec4_sub_s
00354 #define GAN_VEC_DOT_Q gan_vec4_dot_q
00355 #define GAN_VEC_DOT_S gan_vec4_dot_s
00356 #define GAN_VEC_SQRLEN_Q gan_vec4_sqrlen_q
00357 #define GAN_VEC_SQRLEN_S gan_vec4_sqrlen_s
00358 #define GAN_VEC_FROM_VEC_Q gan_vec4_from_vec_q
00359 #define GAN_VEC_FROM_VEC_S gan_vec4_from_vec_s
00360
00374
00375
00376
00377
00378
00379
00380
00381
00382
00383
00384
00385
00386
00387
00388
00389
00390
00391
00392
00393
00404 Gan_Vector4 *gan_vec4_zero_q ( Gan_Vector4 *p );
00405
00420 Gan_Vector4 *gan_vec4_copy_q ( Gan_Vector4 *p, Gan_Vector4 *q );
00421
00437 Gan_Vector4 *gan_vec4_scale_q ( Gan_Vector4 *p, double a,
00438 Gan_Vector4 *q );
00439
00445 Gan_Vector4 *gan_vec4_scale_i ( Gan_Vector4 *p, double a );
00446
00453 Gan_Vector4 *gan_vec4_divide_q ( Gan_Vector4 *p, double a,
00454 Gan_Vector4 *q );
00455
00461 Gan_Vector4 *gan_vec4_divide_i ( Gan_Vector4 *p, double a );
00462
00470 Gan_Vector4 *gan_vec4_negate_q ( Gan_Vector4 *p, Gan_Vector4 *q );
00471
00479 Gan_Vector4 *gan_vec4_negate_i ( Gan_Vector4 *p );
00480
00486 Gan_Vector4 *gan_vec4_unit_i ( Gan_Vector4 *p );
00487
00505 Gan_Vector4 *gan_vec4_add_q ( Gan_Vector4 *p, Gan_Vector4 *q, Gan_Vector4 *r );
00506
00515 Gan_Vector4 *gan_vec4_add_i1 ( Gan_Vector4 *p, Gan_Vector4 *q );
00516
00525 Gan_Vector4 *gan_vec4_add_i2 ( Gan_Vector4 *p, Gan_Vector4 *q );
00526
00535 Gan_Vector4 *gan_vec4_increment ( Gan_Vector4 *p, Gan_Vector4 *q );
00536
00554 Gan_Vector4 *gan_vec4_sub_q ( Gan_Vector4 *p, Gan_Vector4 *q, Gan_Vector4 *r );
00555
00564 Gan_Vector4 *gan_vec4_sub_i1 ( Gan_Vector4 *p, Gan_Vector4 *q );
00565
00574 Gan_Vector4 *gan_vec4_sub_i2 ( Gan_Vector4 *p, Gan_Vector4 *q );
00575
00584 Gan_Vector4 *gan_vec4_decrement ( Gan_Vector4 *p, Gan_Vector4 *q );
00585
00601 double gan_vec4_dot_q ( Gan_Vector4 *p, Gan_Vector4 *q );
00602
00620 double gan_vec4_sqrlen_q ( Gan_Vector4 *p );
00621
00639 Gan_Vector4 gan_vec4_from_vec_s ( Gan_Vector *x );
00640
00658
00659
00660
00661
00662
00663
00664
00665
00666
00667
00668
00669
00670
00671
00672
00673 #undef GAN_VECTYPE
00674 #undef GAN_VECTOR_TYPE
00675 #undef GAN_VEC_ELEMENT_TYPE
00676 #undef GAN_REALTYPE
00677 #undef GAN_VEC_FPRINT
00678 #undef GAN_VEC_PRINT
00679 #undef GAN_VEC_FSCANF
00680 #undef GAN_VEC_FWRITE
00681 #undef GAN_VEC_FREAD
00682 #undef GAN_VEC_ZERO_Q
00683 #undef GAN_VEC_ZERO_S
00684 #undef GAN_VEC_COPY_Q
00685 #undef GAN_VEC_COPY_S
00686 #undef GAN_VEC_SCALE_Q
00687 #undef GAN_VEC_SCALE_S
00688 #undef GAN_VEC_SCALE_I
00689 #undef GAN_VEC_DIVIDE_Q
00690 #undef GAN_VEC_DIVIDE_S
00691 #undef GAN_VEC_DIVIDE_I
00692 #undef GAN_VEC_NEGATE_Q
00693 #undef GAN_VEC_NEGATE_S
00694 #undef GAN_VEC_NEGATE_I
00695 #undef GAN_VEC_UNIT_Q
00696 #undef GAN_VEC_UNIT_S
00697 #undef GAN_VEC_UNIT_I
00698 #undef GAN_VEC_ADD_Q
00699 #undef GAN_VEC_ADD_I1
00700 #undef GAN_VEC_ADD_I2
00701 #undef GAN_VEC_INCREMENT
00702 #undef GAN_VEC_ADD_S
00703 #undef GAN_VEC_SUB_Q
00704 #undef GAN_VEC_SUB_I1
00705 #undef GAN_VEC_SUB_I2
00706 #undef GAN_VEC_DECREMENT
00707 #undef GAN_VEC_SUB_S
00708 #undef GAN_VEC_DOT_Q
00709 #undef GAN_VEC_DOT_S
00710 #undef GAN_VEC_SQRLEN_Q
00711 #undef GAN_VEC_SQRLEN_S
00712 #undef GAN_VEC_FROM_VEC_Q
00713 #undef GAN_VEC_FROM_VEC_S
00714
00727 #ifdef __cplusplus
00728 }
00729 #endif
00730
00731 #endif