00001
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 #ifndef _GAN_3VECTOR_H
00030 #define _GAN_3VECTOR_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_REPEAT3_H
00064 #define _GAN_REPEAT3_H
00065
00066 #ifdef __cplusplus
00067 extern "C" {
00068 #endif
00069
00070
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
00109
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
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
00145
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
00165 #include <gandalf/linalg/2vector.h>
00166 #include <gandalf/linalg/vec_gen.h>
00167
00168 #ifdef __cplusplus
00169 extern "C" {
00170 #endif
00171
00187
00188 typedef struct Gan_Vector3
00189 {
00190 double x, y, z;
00191 } Gan_Vector3, Gan_Vector3_d;
00192
00194 typedef struct Gan_Vector3_uc
00195 {
00196 unsigned char x, y, z;
00197 } Gan_Vector3_uc;
00198
00200 typedef struct Gan_Vector3_s
00201 {
00202 short x, y, z;
00203 } Gan_Vector3_s;
00204
00206 typedef struct Gan_Vector3_us
00207 {
00208 unsigned short x, y, z;
00209 } Gan_Vector3_us;
00210
00212 typedef struct Gan_Vector3_i
00213 {
00214 int x, y, z;
00215 } Gan_Vector3_i;
00216
00218 typedef struct Gan_Vector3_ui
00219 {
00220 unsigned int x, y, z;
00221 } Gan_Vector3_ui;
00222
00223
00237
00238
00239
00240
00241
00242
00243
00244
00245
00246
00247
00248
00249
00250
00251
00267 Gan_Vector3 *gan_vec3_fill_q ( Gan_Vector3 *p, double X, double Y, double Z );
00268
00286 Gan_Vector3 *gan_vec3_cross_q ( Gan_Vector3 *p, Gan_Vector3 *q,
00287 Gan_Vector3 *r );
00288
00303 Gan_Vector2 *gan_vec3_get_v2t_q ( Gan_Vector3 *p, Gan_Vector2 *q );
00304
00326 Gan_Vector3 *gan_vec3_set_parts_q ( Gan_Vector3 *p, Gan_Vector2 *q, double s );
00327
00333 #define GAN_VECTYPE Gan_Vector3
00334 #define GAN_VECTOR_TYPE Gan_Vector
00335 #define GAN_VEC_ELEMENT_TYPE GAN_DOUBLE
00336 #define GAN_REALTYPE double
00337 #define GAN_VEC_FPRINT gan_vec3_fprint
00338 #define GAN_VEC_PRINT gan_vec3_print
00339 #define GAN_VEC_FSCANF gan_vec3_fscanf
00340 #define GAN_VEC_FWRITE gan_vec3_fwrite
00341 #define GAN_VEC_FREAD gan_vec3_fread
00342 #define GAN_VEC_ZERO_Q gan_vec3_zero_q
00343 #define GAN_VEC_ZERO_S gan_vec3_zero_s
00344 #define GAN_VEC_COPY_Q gan_vec3_copy_q
00345 #define GAN_VEC_COPY_S gan_vec3_copy_s
00346 #define GAN_VEC_SCALE_Q gan_vec3_scale_q
00347 #define GAN_VEC_SCALE_S gan_vec3_scale_s
00348 #define GAN_VEC_SCALE_I gan_vec3_scale_i
00349 #define GAN_VEC_DIVIDE_Q gan_vec3_divide_q
00350 #define GAN_VEC_DIVIDE_S gan_vec3_divide_s
00351 #define GAN_VEC_DIVIDE_I gan_vec3_divide_i
00352 #define GAN_VEC_NEGATE_Q gan_vec3_negate_q
00353 #define GAN_VEC_NEGATE_S gan_vec3_negate_s
00354 #define GAN_VEC_NEGATE_I gan_vec3_negate_i
00355 #define GAN_VEC_UNIT_Q gan_vec3_unit_q
00356 #define GAN_VEC_UNIT_S gan_vec3_unit_s
00357 #define GAN_VEC_UNIT_I gan_vec3_unit_i
00358 #define GAN_VEC_ADD_Q gan_vec3_add_q
00359 #define GAN_VEC_ADD_I1 gan_vec3_add_i1
00360 #define GAN_VEC_ADD_I2 gan_vec3_add_i2
00361 #define GAN_VEC_INCREMENT gan_vec3_increment
00362 #define GAN_VEC_ADD_S gan_vec3_add_s
00363 #define GAN_VEC_SUB_Q gan_vec3_sub_q
00364 #define GAN_VEC_SUB_I1 gan_vec3_sub_i1
00365 #define GAN_VEC_SUB_I2 gan_vec3_sub_i2
00366 #define GAN_VEC_DECREMENT gan_vec3_decrement
00367 #define GAN_VEC_SUB_S gan_vec3_sub_s
00368 #define GAN_VEC_DOT_Q gan_vec3_dot_q
00369 #define GAN_VEC_DOT_S gan_vec3_dot_s
00370 #define GAN_VEC_SQRLEN_Q gan_vec3_sqrlen_q
00371 #define GAN_VEC_SQRLEN_S gan_vec3_sqrlen_s
00372 #define GAN_VEC_FROM_VEC_Q gan_vec3_from_vec_q
00373 #define GAN_VEC_FROM_VEC_S gan_vec3_from_vec_s
00374
00388
00389
00390
00391
00392
00393
00394
00395
00396
00397
00398
00399
00400
00401
00402
00403
00404
00405
00406
00407
00418 Gan_Vector3 *gan_vec3_zero_q ( Gan_Vector3 *p );
00419
00434 Gan_Vector3 *gan_vec3_copy_q ( Gan_Vector3 *p, Gan_Vector3 *q );
00435
00451 Gan_Vector3 *gan_vec3_scale_q ( Gan_Vector3 *p, double a,
00452 Gan_Vector3 *q );
00453
00459 Gan_Vector3 *gan_vec3_scale_i ( Gan_Vector3 *p, double a );
00460
00467 Gan_Vector3 *gan_vec3_divide_q ( Gan_Vector3 *p, double a,
00468 Gan_Vector3 *q );
00469
00475 Gan_Vector3 *gan_vec3_divide_i ( Gan_Vector3 *p, double a );
00476
00484 Gan_Vector3 *gan_vec3_negate_q ( Gan_Vector3 *p, Gan_Vector3 *q );
00485
00493 Gan_Vector3 *gan_vec3_negate_i ( Gan_Vector3 *p );
00494
00500 Gan_Vector3 *gan_vec3_unit_i ( Gan_Vector3 *p );
00501
00519 Gan_Vector3 *gan_vec3_add_q ( Gan_Vector3 *p, Gan_Vector3 *q, Gan_Vector3 *r );
00520
00529 Gan_Vector3 *gan_vec3_add_i1 ( Gan_Vector3 *p, Gan_Vector3 *q );
00530
00539 Gan_Vector3 *gan_vec3_add_i2 ( Gan_Vector3 *p, Gan_Vector3 *q );
00540
00549 Gan_Vector3 *gan_vec3_increment ( Gan_Vector3 *p, Gan_Vector3 *q );
00550
00568 Gan_Vector3 *gan_vec3_sub_q ( Gan_Vector3 *p, Gan_Vector3 *q, Gan_Vector3 *r );
00569
00578 Gan_Vector3 *gan_vec3_sub_i1 ( Gan_Vector3 *p, Gan_Vector3 *q );
00579
00588 Gan_Vector3 *gan_vec3_sub_i2 ( Gan_Vector3 *p, Gan_Vector3 *q );
00589
00598 Gan_Vector3 *gan_vec3_decrement ( Gan_Vector3 *p, Gan_Vector3 *q );
00599
00615 double gan_vec3_dot_q ( Gan_Vector3 *p, Gan_Vector3 *q );
00616
00634 double gan_vec3_sqrlen_q ( Gan_Vector3 *p );
00635
00653 Gan_Vector3 gan_vec3_from_vec_s ( Gan_Vector *x );
00654
00672
00673
00674
00675
00676
00677
00678
00679
00680
00681
00682
00683
00684
00685
00686
00687 #undef GAN_VECTYPE
00688 #undef GAN_VECTOR_TYPE
00689 #undef GAN_VEC_ELEMENT_TYPE
00690 #undef GAN_REALTYPE
00691 #undef GAN_VEC_FPRINT
00692 #undef GAN_VEC_PRINT
00693 #undef GAN_VEC_FSCANF
00694 #undef GAN_VEC_FWRITE
00695 #undef GAN_VEC_FREAD
00696 #undef GAN_VEC_ZERO_Q
00697 #undef GAN_VEC_ZERO_S
00698 #undef GAN_VEC_COPY_Q
00699 #undef GAN_VEC_COPY_S
00700 #undef GAN_VEC_SCALE_Q
00701 #undef GAN_VEC_SCALE_S
00702 #undef GAN_VEC_SCALE_I
00703 #undef GAN_VEC_DIVIDE_Q
00704 #undef GAN_VEC_DIVIDE_S
00705 #undef GAN_VEC_DIVIDE_I
00706 #undef GAN_VEC_NEGATE_Q
00707 #undef GAN_VEC_NEGATE_S
00708 #undef GAN_VEC_NEGATE_I
00709 #undef GAN_VEC_UNIT_Q
00710 #undef GAN_VEC_UNIT_S
00711 #undef GAN_VEC_UNIT_I
00712 #undef GAN_VEC_ADD_Q
00713 #undef GAN_VEC_ADD_I1
00714 #undef GAN_VEC_ADD_I2
00715 #undef GAN_VEC_INCREMENT
00716 #undef GAN_VEC_ADD_S
00717 #undef GAN_VEC_SUB_Q
00718 #undef GAN_VEC_SUB_I1
00719 #undef GAN_VEC_SUB_I2
00720 #undef GAN_VEC_DECREMENT
00721 #undef GAN_VEC_SUB_S
00722 #undef GAN_VEC_DOT_Q
00723 #undef GAN_VEC_DOT_S
00724 #undef GAN_VEC_SQRLEN_Q
00725 #undef GAN_VEC_SQRLEN_S
00726 #undef GAN_VEC_FROM_VEC_Q
00727 #undef GAN_VEC_FROM_VEC_S
00728
00741 #ifdef __cplusplus
00742 }
00743 #endif
00744
00745 #endif