DI-Guy SDK Documentation  13.2
diguy_vector_classes.h
Go to the documentation of this file.
1 
2 /*********************************************************************
3  ** Copyright (c) 1992-2019 VT MAK
4  ** All rights reserved.
5  *********************************************************************/
6 
7 /*********************************************************************
8  **
9  *t DI-Guy Vector Classes
10  **
11  *b Link against: libdiguy
12  */
13 
14 #ifndef __diguy_vector_classes_H
15 #define __diguy_vector_classes_H
16 
17 #ifdef SWIG
18 %module diguyVec3f
19 #else
20 #define CPLUSPLUS_ONLY
21 #endif
22 
23 #ifdef CPLUSPLUS_ONLY
24 #include <declspec_diguy.h>
25 #endif
26 class diguyVec4f;
27 class bdiVec3f;
28 
29 
30 /****************************************************************************/
31 /*
32  * diguyVec2f
33  */
34 /****************************************************************************/
35 
36 class BDI_DECLSPEC_diguy diguyVec2f
37 {
38 
39 public:
40 
41  inline diguyVec2f() {x = y = 0.0f;}
42  inline diguyVec2f(float new_x) {x = y = new_x;}
43  inline diguyVec2f(float new_x, float new_y) {x = new_x; y = new_y;}
44 
45  inline float _x() {return x;}
46  inline float _y() {return y;}
47 
48  inline float _azimuth() {return azimuth;}
49  inline float _elevation() {return elevation;}
50 
51  /*
52  * Data members. See the comment in diguyVec3f regarding the use of
53  * unions.
54  */
55 #ifdef CPLUSPLUS_ONLY
56 
57  union {
58  float x;
59  float azimuth;
60  };
61 
62  union {
63  float y;
64  float elevation;
65  };
66 
67 #endif
68 };
69 
70 
71 
72 /****************************************************************************/
73 /*
74  * diguyVec3f
75  */
76 /****************************************************************************/
77 
78 class BDI_DECLSPEC_diguy diguyVec3f
79 {
80 
81 public:
82 
83  inline diguyVec3f() {x = y = z = 0.0f;}
84  inline diguyVec3f(float new_x) {x = y = z = new_x;}
85  inline diguyVec3f(float new_x, float new_y, float new_z) {x = new_x; y = new_y; z = new_z;}
86  diguyVec3f(const bdiVec3f& bdiVec);
87 
88  diguyVec3f diguy_to_y_forward_z_up_coords();
89  diguyVec3f y_forward_z_up_to_diguy_coords();
90 
91  diguyVec3f diguy_to_z_forward_y_up_coords(); // diguy coords to unity coords
92  diguyVec3f z_forward_y_up_to_diguy_coords(); // unity coords to diguy coords
93 
94  diguyVec4f diguy_euler_angles_to_quaternion() const;
95 
96  inline float _x() {return x;}
97  inline float _y() {return y;}
98  inline float _z() {return z;}
99 
100  inline float _rz() {return rz;}
101  inline float _rx() {return rx;}
102  inline float _ry() {return ry;}
103 
104  inline float _r() {return r;}
105  inline float _g() {return g;}
106  inline float _b() {return b;}
107 
108  inline float _azimuth() {return azimuth;}
109  inline float _elevation() {return elevation;}
110  inline float _radius() {return radius;}
111 
112 #ifdef CPLUSPLUS_ONLY
113 
114  /*
115  * Data members.
116  *
117  * Each data member is a union of different floats, so that variable
118  * names appropriate to the variable's context can be used. For
119  * example, for a position vector p, the following would be appropriate:
120  *
121  * p.x = 10.0f; p.y = 0.0f; p.z = 1.0f;
122  *
123  * For a color green:
124  *
125  * c.r = 0.0f; c.g = 1.0f; c.b = 0.0f;
126  */
128  union {
129  float x;
130  float rz;
131  float r;
132  float azimuth;
133  };
135  union {
136  float y;
137  float rx;
138  float g;
139  float elevation;
140  };
142  union {
143  float z;
144  float ry;
145  float b;
146  float radius;
147  };
148 
149 #endif
150 };
151 
152 
153 
154 /****************************************************************************/
155 /*
156  * diguyVec4f
157  */
158 /****************************************************************************/
160 class BDI_DECLSPEC_diguy diguyVec4f
161 {
162 
163 public:
165  inline diguyVec4f() {x = y = z = w = 0.0f;}
166  inline diguyVec4f(float new_x) {x = y = z = w = new_x;}
167  inline diguyVec4f(float new_x, float new_y, float new_z, float new_w) {x = new_x; y = new_y; z = new_z; w = new_w;}
169  inline float _x() {return x;}
170  inline float _y() {return y;}
171  inline float _z() {return z;}
172  inline float _w() {return w;}
174  inline float _rz() {return rz;}
175  inline float _rx() {return rx;}
176  inline float _ry() {return ry;}
177  inline float _rw() {return rw;}
179  inline float _r() {return r;}
180  inline float _g() {return g;}
181  inline float _b() {return b;}
182  inline float _a() {return a;}
183 
184  inline float _qx() {return qx;}
185  inline float _qy() {return qy;}
186  inline float _qz() {return qz;}
187  inline float _qw() {return qw;}
188 
189 #ifdef CPLUSPLUS_ONLY
190 
191  /*
192  * Data members. See the comment in diguyVec3f regarding the use of
193  * unions.
194  */
195 
196  union {
197  float x;
198  float rz;
199  float r;
200  float qx;
201  };
202 
203  union {
204  float y;
205  float rx;
206  float g;
207  float qy;
208  };
209 
210  union {
211  float z;
212  float ry;
213  float b;
214  float qz;
215  };
216 
217  union {
218  float w;
219  float rw;
220  float a;
221  float qw;
222  };
223 
224 #endif
225 };
226 
228 
229 
230 /****************************************************************************/
231 /*
232  * diguyVec3d
233  */
234 /****************************************************************************/
235 
236 class BDI_DECLSPEC_diguy diguyVec3d
237 {
239 public:
241  inline diguyVec3d() {x = y = z = 0.0;}
242  inline diguyVec3d(double new_x) {x = y = z = new_x;}
243  inline diguyVec3d(double new_x, double new_y, double new_z) {x = new_x; y = new_y; z = new_z;}
245  inline double _x() {return x;}
246  inline double _y() {return y;}
247  inline double _z() {return z;}
249  inline double _rz() {return rz;}
250  inline double _rx() {return rx;}
251  inline double _ry() {return ry;}
252 
253  inline double _r() {return r;}
254  inline double _g() {return g;}
255  inline double _b() {return b;}
256 
257  inline double _azimuth() {return azimuth;}
258  inline double _elevation() {return elevation;}
259  inline double _radius() {return radius;}
261 #ifdef CPLUSPLUS_ONLY
263  /*
264  * Data members. See the comment in diguyVec3f regarding the use of
265  * unions.
266  */
268  union {
269  double x;
270  double rz;
271  double r;
272  double azimuth;
273  };
275  union {
276  double y;
277  double rx;
278  double g;
279  double elevation;
280  };
281 
282  union {
283  double z;
284  double ry;
285  double b;
286  double radius;
287  };
288 
289 #endif
290 };
291 
292 
293 
295 /****************************************************************************/
296 /*
297  * diguyVec4d
298  */
299 /****************************************************************************/
301 class BDI_DECLSPEC_diguy diguyVec4d
302 {
304 public:
306  inline diguyVec4d() {x = y = z = w = 0.0;}
307  inline diguyVec4d(double new_x) {x = y = z = w = new_x;}
308  inline diguyVec4d(double new_x, double new_y, double new_z, double new_w) {x = new_x; y = new_y; z = new_z; w = new_w;}
310  inline double _x() {return x;}
311  inline double _y() {return y;}
312  inline double _z() {return z;}
313  inline double _w() {return w;}
315  inline double _rz() {return rz;}
316  inline double _rx() {return rx;}
317  inline double _ry() {return ry;}
318  inline double _rw() {return rw;}
319 
320  inline double _r() {return r;}
321  inline double _g() {return g;}
322  inline double _b() {return b;}
323  inline double _a() {return a;}
324 
325  inline double _qx() {return qx;}
326  inline double _qy() {return qy;}
327  inline double _qz() {return qz;}
328  inline double _qw() {return qw;}
330 #ifdef CPLUSPLUS_ONLY
331 
332  /*
333  * Data members. See the comment in diguyVec3f regarding the use of
334  * unions.
335  */
337  union {
338  double x;
339  double rz;
340  double r;
341  double qx;
342  };
344  union {
345  double y;
346  double rx;
347  double g;
348  double qy;
349  };
351  union {
352  double z;
353  double ry;
354  double b;
355  double qz;
356  };
357 
358  union {
359  double w;
360  double rw;
361  double a;
362  double qw;
363  };
364 
365 #endif
366 };
370 
371 /****************************************************************************/
372 /*
373  * diguyVec3i
374  */
375 /****************************************************************************/
377 class BDI_DECLSPEC_diguy diguyVec3i
378 {
379 
380 public:
381 
382  inline diguyVec3i() {x = y = z = 0;}
383  inline diguyVec3i(int new_x) {x = y = z = new_x;}
384  inline diguyVec3i(int new_x, int new_y, int new_z) {x = new_x; y = new_y; z = new_z;}
385 
386  inline int _x() {return x;}
387  inline int _y() {return y;}
388  inline int _z() {return z;}
389 
390  inline int _r() {return r;}
391  inline int _g() {return g;}
392  inline int _b() {return b;}
394 #ifdef CPLUSPLUS_ONLY
395 
396  /*
397  * Data members. See the comment in diguyVec3f regarding the use of
398  * unions.
399  */
400 
401  union {
402  int x;
403  int r;
404  };
405 
406  union {
407  int y;
408  int g;
409  };
411  union {
412  int z;
413  int b;
414  };
416 #endif
417 };
418 
423 /****************************************************************************/
424 /*
425  * diguyVec4i
426  */
427 /****************************************************************************/
428 
429 class BDI_DECLSPEC_diguy diguyVec4i
430 {
431 
432 public:
433 
434  inline diguyVec4i() {x = y = z = w = 0;}
435  inline diguyVec4i(int new_x) {x = y = z = w = new_x;}
436  inline diguyVec4i(int new_x, int new_y, int new_z, int new_w) {x = new_x; y = new_y; z = new_z; w = new_w;}
438  inline int _x() {return x;}
439  inline int _y() {return y;}
440  inline int _z() {return z;}
441  inline int _w() {return w;}
443  inline int _r() {return r;}
444  inline int _g() {return g;}
445  inline int _b() {return b;}
446  inline int _a() {return a;}
448 #ifdef CPLUSPLUS_ONLY
449 
450  /*
451  * Data members. See the comment in diguyVec3f regarding the use of
452  * unions.
453  */
454 
455  union {
456  int x;
457  int r;
458  };
459 
460  union {
461  int y;
462  int g;
463  };
464 
465  union {
466  int z;
467  int b;
468  };
469 
470  union {
471  int w;
472  int a;
473  };
474 
475 #endif
476 };
477 
478 
479 #endif // __diguy_vector_classes_H
480 
Definition: diguy_vector_classes.h:227
Definition: diguy_vector_classes.h:34
diguyVec2f(float new_x, float new_y)
Definition: diguy_vector_classes.h:41
Definition: diguy_vector_classes.h:154
Definition: diguy_vector_classes.h:362
Definition: diguy_vector_classes.h:289
Definition: diguy_vector_classes.h:74
Definition: diguy_vector_classes.h:410