VR-Link API Documentation for HLA Evolved
Home
Namespaces
Classes
Files
Examples
Libraries
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
include
matrix
vlVector.h
Go to the documentation of this file.
1
/*********************************************************************
2
** Copyright (c) 2015 VT MAK
3
** All rights reserved.
4
*********************************************************************/
5
6
#pragma once
7
11
12
#include <
vlutil/vlMachineTypes.h
>
13
#include <
vlutil/vlNetTypes.h
>
14
#include <
vlutil/vlString.h
>
15
#include <
matrix/vlMath.h
>
16
#include <iomanip>
17
#include <ios>
18
#include <iosfwd>
19
#include <sstream>
20
21
#ifdef DtUSE_UTILITIES_NAMESPACE
22
namespace
DtUSE_UTILITIES_NAMESPACE
23
{
24
#endif
25
26
29
enum
DtVectorOffset
30
{
31
DtX
,
32
DtY
,
33
DtZ
34
};
35
36
class
DtDcm
;
37
48
template
<
typename
T>
49
class
DtVectorT
50
{
51
public
:
52
inline
DtVectorT<T>
();
53
55
inline
DtVectorT<T>
(
const
T& x,
const
T& y,
const
T& z);
56
58
inline
~
DtVectorT<T>
();
59
61
inline
DtVectorT<T>
(
const
DtVectorT<T>
& vec);
62
64
inline
DtVectorT<T>
& operator=(
const
DtVectorT<T>
& vec);
65
67
inline
void
setToZero();
68
70
71
inline
const
T& x()
const
;
72
inline
void
setX(
const
T& x);
74
76
77
inline
const
T& y()
const
;
78
inline
void
setY(
const
T& y);
80
82
83
inline
const
T& z()
const
;
84
inline
void
setZ(
const
T& z);
86
88
inline
T& operator[](
int
ind);
89
91
inline
T operator[](
int
ind)
const
;
92
94
inline
T& operator[](
DtVectorOffset
ind);
95
97
inline
T operator[](
DtVectorOffset
ind)
const
;
98
101
inline
int
operator==
(
const
DtVectorT<T>
& vec)
const
;
102
105
inline
int
operator!=
(
const
DtVectorT<T>
& vec)
const
;
106
108
inline
DtString
string()
const
;
109
112
inline
double
magnitudeSquared()
const
;
113
115
inline
void
normalize();
116
118
inline
bool
isNormalized()
const
;
119
120
122
inline
bool
magnitudeIsZero()
const
;
123
127
inline
bool
magnitudeIsZero(
double
tolerance)
const
;
128
130
inline
std::ostream &printDataToStream(std::ostream &str)
const
;
131
132
public
:
133
136
137
inline
operator
T* ();
138
inline
operator
const
T* ()
const
;
140
141
protected
:
142
143
T myRep[3];
144
};
145
146
class
DtVector64
;
//Forward declaration for conversions
147
148
// Specifically instantiate 32 bit vector.
149
// in C++11 we could just typedef and export, but
150
// this is not compatible with older versions.
151
class
DT_DLL_MATRIX
DtVector32
:
public
DtVectorT
< float >
152
{
153
public
:
154
inline
DtVector32
();
155
157
inline
DtVector32
(
const
float
& x,
const
float
& y,
const
float
& z);
158
160
inline
~
DtVector32
();
161
163
inline
DtVector32
(
const
DtVector32
& vec);
164
inline
DtVector32
(
const
DtVectorT < float >
& vec);
165
167
inline
DtVector32
& operator=(
const
DtVector32
& vec);
168
inline
DtVector32
& operator=(
const
DtVectorT < float >
& vec);
169
171
inline
DtVector32
crossProduct(
const
DtVector32
& v)
const
;
172
173
#ifdef DtEXPLICIT_VECTOR_CONVERSION
174
175
176
inline
DtVector32
& operator= (
const
DtVector64
& vec);
177
inline
DtVector32
(
const
DtVector64
& vec);
178
#endif
179
181
DtVector32
&operator+=(
const
DtVector32
&other);
182
184
DtVector32
&operator-=(
const
DtVector32
&other);
185
187
float
dotProduct(
const
DtVector32
& v)
const
;
188
190
bool
approxEq(
const
DtVector32
& v,
const
double
& tolerance)
const
;
191
192
public
:
193
195
static
const
DtVector32
& zero();
196
198
static
const
DtVector32
& i();
199
201
static
const
DtVector32
& j();
202
204
static
const
DtVector32
& k();
205
207
static
const
DtVector32
& ones();
208
};
209
210
// Specifically instantiate 64 bit vector.
211
// in C++11 we could just typedef and export, but
212
// this is not compatible with older versions.
213
class
DT_DLL_MATRIX
DtVector64
:
public
DtVectorT
< double >
214
{
215
public
:
216
inline
DtVector64
();
217
219
inline
DtVector64
(
const
double
& x,
const
double
& y,
const
double
& z);
220
222
inline
~
DtVector64
();
223
225
inline
DtVector64
(
const
DtVector64
& vec);
226
inline
DtVector64
(
const
DtVectorT < double >
& vec);
227
229
inline
DtVector64
& operator=(
const
DtVector64
& vec);
230
inline
DtVector64
& operator=(
const
DtVectorT < double >
& vec);
231
233
inline
DtVector64
crossProduct(
const
DtVector64
& v)
const
;
234
235
#ifdef DtIMPLICIT_VECTOR_CONVERSION
236
237
238
inline
DtVector64
& operator= (
const
DtVector32
& vec);
239
inline
DtVector64
(
const
DtVector32
& vec);
240
#endif
241
243
DtVector64
&operator+=(
const
DtVector64
&other);
244
246
DtVector64
&operator-=(
const
DtVector64
&other);
247
249
double
dotProduct(
const
DtVector64
& v)
const
;
250
252
bool
approxEq(
const
DtVector64
& v,
const
double
& tolerance)
const
;
253
254
255
public
:
256
258
static
const
DtVector64
& zero();
259
261
static
const
DtVector64
& i();
262
264
static
const
DtVector64
& j();
265
267
static
const
DtVector64
& k();
268
270
static
const
DtVector64
& ones();
271
};
272
273
//Helper typedefs
274
typedef
DtVector64
DtVector
;
275
typedef
const
DtVector
&
DtConstVector
;
276
typedef
const
DtVector32
&
DtConstVector32
;
277
typedef
DtVector
&
DtVectorRef
;
278
typedef
DtVector32
&
DtVectorRef32
;
279
280
typedef
double
DtThreeIndex
[3][3][3];
281
typedef
double
(*
DtThreeIndexPtr
)[3][3];
282
283
//
284
// Vector routines.
285
//
286
287
#define DtSetVec(v, x, y, z) v[DtX]=x;v[DtY]=y;v[DtZ]=z;
288
290
extern
DT_DLL_MATRIX
DtThreeIndex
DtLevi_Civita
;
291
294
DT_DLL_MATRIX
DtVector
operator+
(
const
DtVector
& v1,
const
DtVector
&v2);
295
DT_DLL_MATRIX
DtVector32
operator+
(
const
DtVector32
& v1,
const
DtVector32
&v2);
296
DT_DLL_MATRIX
DtVector
operator+
(
const
DtVector32
& v1,
const
DtVector
&v2);
297
DT_DLL_MATRIX
DtVector
operator+
(
const
DtVector
& v1,
const
DtVector32
&v2);
298
301
DT_DLL_MATRIX
DtVector
operator-
(
const
DtVector
& v1,
const
DtVector
&v2);
302
DT_DLL_MATRIX
DtVector32
operator-
(
const
DtVector32
& v1,
const
DtVector32
&v2);
303
DT_DLL_MATRIX
DtVector
operator-
(
const
DtVector32
& v1,
const
DtVector
&v2);
304
DT_DLL_MATRIX
DtVector
operator-
(
const
DtVector
& v1,
const
DtVector32
&v2);
305
307
DT_DLL_MATRIX
void
DtVecScale
(
const
DtVector
& v,
double
scale_factor,
DtVector
& result);
308
DT_DLL_MATRIX
void
DtVecScale
(
const
DtVector32
& v,
double
scale_factor,
DtVector32
& result);
309
DT_DLL_MATRIX
void
DtVecScale
(
const
DtVector32
& v,
double
scale_factor,
DtVector
& result);
310
312
DT_DLL_MATRIX
void
DtVecNeg
(
const
DtVector
& v1,
DtVector
& result);
313
DT_DLL_MATRIX
void
DtVecNeg
(
const
DtVector32
& v1,
DtVector32
& result);
314
317
DT_DLL_MATRIX
double
DtVecCosProd
(
const
DtVector
& v1,
const
DtVector
& v2);
318
DT_DLL_MATRIX
double
DtVecCosProd
(
const
DtVector32
& v1,
const
DtVector32
& v2);
319
322
DT_DLL_MATRIX
double
DtVecBoxProd
(
const
DtVector
& v1,
const
DtVector
& v2,
const
DtVector
& v3);
323
DT_DLL_MATRIX
double
DtVecBoxProd
(
const
DtVector32
& v1,
const
DtVector32
& v2,
const
DtVector32
& v3);
324
327
DT_DLL_MATRIX
void
DtVecDcmMul
(
const
DtVector
& v,
const
DtDcm
& m,
DtVector
& result);
328
DT_DLL_MATRIX
void
DtVecDcmMul
(
const
DtVector32
& v,
const
DtDcm
& m,
DtVector32
& result);
329
331
DT_DLL_MATRIX
void
DtVV_Product
(
const
DtVector
& a,
const
DtVector
& b,
DtDcm
& ans);
332
DT_DLL_MATRIX
void
DtVV_Product
(
const
DtVector32
& a,
const
DtVector32
& b,
DtDcm
& ans);
333
335
DT_DLL_MATRIX
double
DtVecInfNorm
(
const
DtVector
& v1);
336
DT_DLL_MATRIX
double
DtVecInfNorm
(
const
DtVector32
& v1);
337
339
DT_DLL_MATRIX
void
DtVecInit
(
DtVector
& v);
340
DT_DLL_MATRIX
void
DtVecInit
(
DtVector32
& v);
341
344
DT_DLL_MATRIX
DtVector
DtLerpVector
(
DtVector
va,
DtVector
vb,
double
t);
345
DT_DLL_MATRIX
DtVector32
DtLerpVector
(
DtVector32
va,
DtVector32
vb,
double
t);
346
349
DT_DLL_MATRIX
void
DtVecCopy
(
const
DtVector
& from,
DtVector
& to);
350
DT_DLL_MATRIX
void
DtVecCopy
(
const
DtVector32
& from,
DtVector32
& to);
351
354
DT_DLL_MATRIX
int
DtVecCheck
(
const
DtVector
& v);
355
DT_DLL_MATRIX
int
DtVecCheck
(
const
DtVector32
& v);
356
359
DT_DLL_MATRIX
void
DtVecNormalize
(
const
DtVector
& v,
DtVector
& result);
360
DT_DLL_MATRIX
void
DtVecNormalize
(
const
DtVector32
& v,
DtVector32
& result);
361
364
DT_DLL_MATRIX
void
DtVecCrossProd
(
const
DtVector
& v1,
const
DtVector
& v2,
DtVector
& result);
365
DT_DLL_MATRIX
void
DtVecCrossProd
(
const
DtVector
& v1,
const
DtVector
& v2,
DtVector32
& result);
366
DT_DLL_MATRIX
void
DtVecCrossProd
(
const
DtVector32
& v1,
const
DtVector32
& v2,
DtVector32
& result);
367
370
DT_DLL_MATRIX
double
DtVecDotProd
(
const
DtVector
& v1,
const
DtVector
& v2);
371
DT_DLL_MATRIX
double
DtVecDotProd
(
const
DtVector32
& v1,
const
DtVector32
& v2);
372
375
DT_DLL_MATRIX
void
DtVecDump
(
const
char
*str,
const
DtVector
& v);
376
DT_DLL_MATRIX
void
DtVecDump
(
const
char
*str,
const
DtVector32
& v);
377
380
DT_DLL_MATRIX
void
DtVecSub
(
const
DtVector
& v1,
const
DtVector
& v2,
DtVector
& result);
381
DT_DLL_MATRIX
void
DtVecSub
(
const
DtVector32
& v1,
const
DtVector32
& v2,
DtVector32
& result);
382
385
DT_DLL_MATRIX
void
DtVecAdd
(
const
DtVector
& v1,
const
DtVector
& v2,
DtVector
& result);
386
DT_DLL_MATRIX
void
DtVecAdd
(
const
DtVector32
& v1,
const
DtVector32
& v2,
DtVector32
& result);
387
391
DT_DLL_MATRIX
DtVector
DtVelocityFromAToB
(
const
DtVector
& a,
392
const
DtVector
& b,
double
time);
393
DT_DLL_MATRIX
DtVector32
DtVelocityFromAToB
(
const
DtVector32
& a,
394
const
DtVector32
& b,
double
time);
395
399
DT_DLL_MATRIX
double
DtHeadingFromAToB
(
const
DtVector
& a,
const
DtVector
& b);
400
DT_DLL_MATRIX
double
DtHeadingFromAToB
(
const
DtVector32
& a,
const
DtVector32
& b);
401
402
/* ||p1-p2||_{2} */
404
DT_DLL_MATRIX
double
DtDistance
(
const
DtVector
& p1,
const
DtVector
& p2);
405
DT_DLL_MATRIX
double
DtDistance
(
const
DtVector32
& p1,
const
DtVector32
& p2);
406
408
DT_DLL_MATRIX
double
DtDistSqr
(
const
DtVector
& p1,
const
DtVector
& p2);
409
DT_DLL_MATRIX
double
DtDistSqr
(
const
DtVector32
& p1,
const
DtVector32
& p2);
410
413
DT_DLL_MATRIX
DtVector64
DtVector32To64
(
const
DtVector32
& v32);
414
DT_DLL_MATRIX
DtVector32
DtVector64To32
(
const
DtVector64
& v32);
415
416
419
class
DT_DLL_MATRIX
DtNetVector32
420
{
421
public
:
422
DtNetVector32
();
423
DtNetVector32
(
const
DtVector32
&vec);
424
DtVector32
operator=(
const
DtVector32
&vec);
425
operator
DtVector32
()
const
;
426
DtNetFloat32
&operator[](
int
i);
427
DtNetFloat32
operator[](
int
i)
const
;
428
private
:
429
DtNetFloat32
rep[3];
430
};
431
434
class
DT_DLL_MATRIX
DtNetVector64
435
{
436
public
:
437
DtNetVector64
();
438
DtNetVector64
(
const
DtVector
&vec);
439
DtVector
operator=(
const
DtVector
&vec);
440
operator
DtVector
()
const
;
441
DtNetFloat64
&operator[](
int
i);
442
DtNetFloat64
operator[](
int
i)
const
;
443
private
:
444
DtNetFloat64
rep[3];
445
};
446
447
template
<
typename
T> std::ostream & operator << (std::ostream &str, const DtVectorT<T> &vec)
448
{
449
vec.printDataToStream(str);
450
return
str;
451
};
452
453
455
#define vlVector_inl
456
#include "vlVector.inl"
457
#undef vlVector_inl
458
459
#ifdef DtUSE_UTILITIES_NAMESPACE
460
}
461
#endif
462
463
Document ID: Generated on Mon Feb 6 18:36:34 EST 2017 from SVN revision 173107
Copyright © 2005-2016 VT MÄK. All Rights Reserved (
www.mak.com
)