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
00215 #if (SIZEOF_DOUBLE == 8)
00216 typedef struct Gan_Vector4 Gan_Vector4_f64;
00217 #endif
00218
00219 #if (SIZEOF_CHAR == 1)
00220 typedef struct Gan_Vector4_uc Gan_Vector4_ui8;
00221 #endif
00222
00223 #if (SIZEOF_SHORT == 2)
00224 typedef struct Gan_Vector4_s Gan_Vector4_i16;
00225 typedef struct Gan_Vector4_us Gan_Vector4_ui16;
00226 #endif
00227
00228 #if (SIZEOF_INT == 4)
00229 typedef struct Gan_Vector4_i Gan_Vector4_i32;
00230 typedef struct Gan_Vector4_ui Gan_Vector4_ui32;
00231 #endif
00232
00233
00247
00248
00249
00250
00251
00252
00253
00254
00255
00256
00257
00258
00259
00260
00261
00277 Gan_Vector4 *gan_vec4_fill_q ( Gan_Vector4 *p,
00278 double X, double Y, double Z, double W );
00279
00294 Gan_Vector3 *gan_vec4_get_v3t_q ( const Gan_Vector4 *p, Gan_Vector3 *q );
00295
00317 Gan_Vector4 *gan_vec4_set_parts_q ( Gan_Vector4 *p, const Gan_Vector3 *q, double s );
00318
00330 Gan_Vector4 *gan_vec4_set_blocks_q ( Gan_Vector4 *p,
00331 const Gan_Vector2 *q, const Gan_Vector2 *r );
00332
00338 #define GAN_VECTYPE Gan_Vector4
00339 #define GAN_VECTOR_TYPE Gan_Vector
00340 #define GAN_VEC_ELEMENT_TYPE GAN_DOUBLE
00341 #define GAN_REALTYPE double
00342 #define GAN_FWRITE_LENDIAN gan_fwrite_lendian_f64
00343 #define GAN_FREAD_LENDIAN gan_fread_lendian_f64
00344 #define GAN_VEC_FPRINT gan_vec4_fprint
00345 #define GAN_VEC_PRINT gan_vec4_print
00346 #define GAN_VEC_FSCANF gan_vec4_fscanf
00347 #define GAN_VEC_FWRITE gan_vec4_fwrite
00348 #define GAN_VEC_FREAD gan_vec4_fread
00349 #define GAN_VEC_ZERO_Q gan_vec4_zero_q
00350 #define GAN_VEC_ZERO_S gan_vec4_zero_s
00351 #define GAN_VEC_COPY_Q gan_vec4_copy_q
00352 #define GAN_VEC_COPY_S gan_vec4_copy_s
00353 #define GAN_VEC_SCALE_Q gan_vec4_scale_q
00354 #define GAN_VEC_SCALE_S gan_vec4_scale_s
00355 #define GAN_VEC_SCALE_I gan_vec4_scale_i
00356 #define GAN_VEC_DIVIDE_Q gan_vec4_divide_q
00357 #define GAN_VEC_DIVIDE_S gan_vec4_divide_s
00358 #define GAN_VEC_DIVIDE_I gan_vec4_divide_i
00359 #define GAN_VEC_NEGATE_Q gan_vec4_negate_q
00360 #define GAN_VEC_NEGATE_S gan_vec4_negate_s
00361 #define GAN_VEC_NEGATE_I gan_vec4_negate_i
00362 #define GAN_VEC_UNIT_Q gan_vec4_unit_q
00363 #define GAN_VEC_UNIT_S gan_vec4_unit_s
00364 #define GAN_VEC_UNIT_I gan_vec4_unit_i
00365 #define GAN_VEC_ADD_Q gan_vec4_add_q
00366 #define GAN_VEC_ADD_I1 gan_vec4_add_i1
00367 #define GAN_VEC_ADD_I2 gan_vec4_add_i2
00368 #define GAN_VEC_INCREMENT gan_vec4_increment
00369 #define GAN_VEC_ADD_S gan_vec4_add_s
00370 #define GAN_VEC_SUB_Q gan_vec4_sub_q
00371 #define GAN_VEC_SUB_I1 gan_vec4_sub_i1
00372 #define GAN_VEC_SUB_I2 gan_vec4_sub_i2
00373 #define GAN_VEC_DECREMENT gan_vec4_decrement
00374 #define GAN_VEC_SUB_S gan_vec4_sub_s
00375 #define GAN_VEC_DOT_Q gan_vec4_dot_q
00376 #define GAN_VEC_DOT_S gan_vec4_dot_s
00377 #define GAN_VEC_SQRLEN_Q gan_vec4_sqrlen_q
00378 #define GAN_VEC_SQRLEN_S gan_vec4_sqrlen_s
00379 #define GAN_VEC_FROM_VEC_Q gan_vec4_from_vec_q
00380 #define GAN_VEC_FROM_VEC_S gan_vec4_from_vec_s
00381
00395
00396
00397
00398
00399
00400
00401
00402
00403
00404
00405
00406
00407
00408
00409
00410
00411
00412
00413
00414
00425 Gan_Vector4 *gan_vec4_zero_q ( Gan_Vector4 *p );
00426
00441 Gan_Vector4 *gan_vec4_copy_q ( Gan_Vector4 *p, Gan_Vector4 *q );
00442
00458 Gan_Vector4 *gan_vec4_scale_q ( Gan_Vector4 *p, double a,
00459 Gan_Vector4 *q );
00460
00466 Gan_Vector4 *gan_vec4_scale_i ( Gan_Vector4 *p, double a );
00467
00474 Gan_Vector4 *gan_vec4_divide_q ( Gan_Vector4 *p, double a,
00475 Gan_Vector4 *q );
00476
00482 Gan_Vector4 *gan_vec4_divide_i ( Gan_Vector4 *p, double a );
00483
00491 Gan_Vector4 *gan_vec4_negate_q ( Gan_Vector4 *p, Gan_Vector4 *q );
00492
00500 Gan_Vector4 *gan_vec4_negate_i ( Gan_Vector4 *p );
00501
00507 Gan_Vector4 *gan_vec4_unit_i ( Gan_Vector4 *p );
00508
00526 Gan_Vector4 *gan_vec4_add_q ( Gan_Vector4 *p, Gan_Vector4 *q, Gan_Vector4 *r );
00527
00536 Gan_Vector4 *gan_vec4_add_i1 ( Gan_Vector4 *p, Gan_Vector4 *q );
00537
00546 Gan_Vector4 *gan_vec4_add_i2 ( Gan_Vector4 *p, Gan_Vector4 *q );
00547
00556 Gan_Vector4 *gan_vec4_increment ( Gan_Vector4 *p, Gan_Vector4 *q );
00557
00575 Gan_Vector4 *gan_vec4_sub_q ( Gan_Vector4 *p, Gan_Vector4 *q, Gan_Vector4 *r );
00576
00585 Gan_Vector4 *gan_vec4_sub_i1 ( Gan_Vector4 *p, Gan_Vector4 *q );
00586
00595 Gan_Vector4 *gan_vec4_sub_i2 ( Gan_Vector4 *p, Gan_Vector4 *q );
00596
00605 Gan_Vector4 *gan_vec4_decrement ( Gan_Vector4 *p, Gan_Vector4 *q );
00606
00622 double gan_vec4_dot_q ( const Gan_Vector4 *p, const Gan_Vector4 *q );
00623
00641 double gan_vec4_sqrlen_q ( const Gan_Vector4 *p );
00642
00652 Gan_Vector4 gan_vec4_from_vec_s ( const Gan_Vector *x );
00653
00671
00672
00673
00674
00675
00676
00677
00678
00679
00680
00681
00682
00683
00684
00685
00686 #undef GAN_VECTYPE
00687 #undef GAN_VECTOR_TYPE
00688 #undef GAN_VEC_ELEMENT_TYPE
00689 #undef GAN_REALTYPE
00690 #undef GAN_FWRITE_LENDIAN
00691 #undef GAN_FREAD_LENDIAN
00692 #undef GAN_VEC_FPRINT
00693 #undef GAN_VEC_PRINT
00694 #undef GAN_VEC_FSCANF
00695 #undef GAN_VEC_FWRITE
00696 #undef GAN_VEC_FREAD
00697 #undef GAN_VEC_ZERO_Q
00698 #undef GAN_VEC_ZERO_S
00699 #undef GAN_VEC_COPY_Q
00700 #undef GAN_VEC_COPY_S
00701 #undef GAN_VEC_SCALE_Q
00702 #undef GAN_VEC_SCALE_S
00703 #undef GAN_VEC_SCALE_I
00704 #undef GAN_VEC_DIVIDE_Q
00705 #undef GAN_VEC_DIVIDE_S
00706 #undef GAN_VEC_DIVIDE_I
00707 #undef GAN_VEC_NEGATE_Q
00708 #undef GAN_VEC_NEGATE_S
00709 #undef GAN_VEC_NEGATE_I
00710 #undef GAN_VEC_UNIT_Q
00711 #undef GAN_VEC_UNIT_S
00712 #undef GAN_VEC_UNIT_I
00713 #undef GAN_VEC_ADD_Q
00714 #undef GAN_VEC_ADD_I1
00715 #undef GAN_VEC_ADD_I2
00716 #undef GAN_VEC_INCREMENT
00717 #undef GAN_VEC_ADD_S
00718 #undef GAN_VEC_SUB_Q
00719 #undef GAN_VEC_SUB_I1
00720 #undef GAN_VEC_SUB_I2
00721 #undef GAN_VEC_DECREMENT
00722 #undef GAN_VEC_SUB_S
00723 #undef GAN_VEC_DOT_Q
00724 #undef GAN_VEC_DOT_S
00725 #undef GAN_VEC_SQRLEN_Q
00726 #undef GAN_VEC_SQRLEN_S
00727 #undef GAN_VEC_FROM_VEC_Q
00728 #undef GAN_VEC_FROM_VEC_S
00729
00742 #ifdef __cplusplus
00743 }
00744 #endif
00745
00746 #endif