Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00077 #ifndef VECTOR3D_H
00078 #define VECTOR3D_H
00079
00080
00081 #include <math.h>
00082 #include <immintrin.h>
00083
00084
00085 #ifdef __GNUC__
00086
00087 #define align16 __attribute__((aligned (16)))
00088
00089 #ifndef __forceinline
00090 #define __forceinline __attribute__((always_inline))
00091 #endif
00092
00093 #elif defined (__MSVC__)
00094
00095 #define align16 __declspec(align (16))
00096
00097 #ifndef __forceinline
00098 #define __forceinline inline
00099 #endif
00100
00101 #endif
00102
00103
00104 #define VECTOR3D_DOTP_MASK 0x71 // dot product selection mask // NEEDS TO BE FIXED!
00105 #define VECTOR3D_ROT1_MASK 0xC9 // first rotation mask
00106 #define VECTOR3D_ROT2_MASK 0xD2 // second rotation mask
00107
00108
00109 #ifdef __SSE__ // SSE enabled
00110 typedef align16 __m128 Vector3D__;
00111 #else // SSE disabled
00112 typedef align16 float Vector3D__[4];
00113 #endif
00114
00115
00116
00117
00118 typedef align16 struct {
00119 float x;
00120 float y;
00121 float z;
00122 float _;
00123 } Vector3D_v;
00124
00125
00126
00127
00128 typedef align16 struct {
00129 float r;
00130 float phi;
00131 float z;
00132 float _;
00133 } Vector3D_c;
00134
00135
00136
00137
00138 typedef align16 struct {
00139 float r;
00140 float phi;
00141 float theta;
00142 float _;
00143 } Vector3D_s;
00144
00145
00146
00147
00148 typedef align16 union {
00149 align16 Vector3D__ _;
00150 align16 Vector3D_v v;
00151 align16 Vector3D_c c;
00152 align16 Vector3D_s s;
00153 } Vector3D_t;
00154
00155
00156
00161 __forceinline
00162 Vector3D_t Vector3D ();
00163
00164
00165
00171 __forceinline
00172 Vector3D_t Vector3D (register float S0);
00173
00174
00175
00183 __forceinline
00184 Vector3D_t Vector3D (register float x, register float y, register float z);
00185
00186
00187
00196 __forceinline
00197 Vector3D_t Vector3DC (register float r, register float phi, register float z);
00198
00199
00200
00209 __forceinline
00210 Vector3D_t Vector3DS (register float r, register float phi, register float theta);
00211
00212
00213
00220 __forceinline
00221 Vector3D_t add (register Vector3D_t L0, register Vector3D_t R0);
00222
00223
00224
00230 __forceinline
00231 void add_ (register Vector3D_t &L0, register Vector3D_t R0);
00232
00233
00234
00241 __forceinline
00242 Vector3D_t sub (register Vector3D_t L0, register Vector3D_t R0);
00243
00244
00245
00251 __forceinline
00252 void sub_ (register Vector3D_t &L0, register Vector3D_t R0);
00253
00254
00255
00262 __forceinline
00263 Vector3D_t mul (register Vector3D_t L0, register float R0);
00264
00265
00266
00272 __forceinline
00273 void mul_ (register Vector3D_t &L0, register float R0);
00274
00275
00276
00283 __forceinline
00284 Vector3D_t div (register Vector3D_t L0, register float R0);
00285
00286
00287
00293 __forceinline
00294 void div_ (register Vector3D_t &L0, register float R0);
00295
00296
00297
00304 __forceinline
00305 float dot (register Vector3D_t L0, register Vector3D_t R0);
00306
00307
00308
00315 __forceinline
00316 Vector3D_t cross (register Vector3D_t L0, register Vector3D_t R0);
00317
00318
00319
00325 __forceinline
00326 void cross_ (register Vector3D_t &L0, register Vector3D_t R0);
00327
00328
00329
00337 __forceinline
00338 float triple (register Vector3D_t L0, register Vector3D_t M0, register Vector3D_t R0);
00339
00340
00341
00347 __forceinline
00348 float abs (register Vector3D_t V0);
00349
00350
00351
00358 __forceinline
00359 float absC (register Vector3D_t V0);
00360
00361
00362
00369 __forceinline
00370 float absS (register Vector3D_t V0);
00371
00372
00373
00379 __forceinline
00380 Vector3D_t unit (register Vector3D_t V0);
00381
00382
00383
00388 __forceinline
00389 void unit_ (register Vector3D_t &V0);
00390
00391
00392
00399 __forceinline
00400 Vector3D_t unitC (register Vector3D_t V0);
00401
00402
00403
00409 __forceinline
00410 void unitC_ (register Vector3D_t &V0);
00411
00412
00413
00420 __forceinline
00421 Vector3D_t unitS (register Vector3D_t V0);
00422
00423
00424
00430 __forceinline
00431 void unitS_ (register Vector3D_t &V0);
00432
00433
00434
00441 __forceinline
00442 Vector3D_t v2c (register Vector3D_t V0);
00443
00444
00445
00451 __forceinline
00452 void v2c_ (register Vector3D_t &V0);
00453
00454
00455
00462 __forceinline
00463 Vector3D_t v2s (register Vector3D_t V0);
00464
00465
00466
00472 __forceinline
00473 void v2s_ (register Vector3D_t &V0);
00474
00475
00476
00483 __forceinline
00484 Vector3D_t c2v (register Vector3D_t V0);
00485
00486
00487
00493 __forceinline
00494 void c2v_ (register Vector3D_t &V0);
00495
00496
00497
00504 __forceinline
00505 Vector3D_t c2s (register Vector3D_t V0);
00506
00507
00508
00514 __forceinline
00515 void c2s_ (register Vector3D_t &V0);
00516
00517
00518
00525 __forceinline
00526 Vector3D_t s2v (register Vector3D_t V0);
00527
00528
00529
00535 __forceinline
00536 void s2v_ (register Vector3D_t &V0);
00537
00538
00539
00546 __forceinline
00547 Vector3D_t s2c (register Vector3D_t V0);
00548
00549
00550
00556 __forceinline
00557 void s2c_ (register Vector3D_t &V0);
00558
00559
00560
00561 #include "Vector3D.hpp"
00562 #endif