NW4F Sys
Loading...
Searching...
No Matches
math_Vector3.h
Go to the documentation of this file.
1#ifndef NW_MATH_VECTOR3_H_
2#define NW_MATH_VECTOR3_H_
3
4#include <cstring>
5#include <nw/math/math_Config.h>
6#include <nw/math/math_Constant.h>
7
8namespace nw { namespace math {
9
10struct VEC3;
11struct MTX34;
12struct MTX44;
13
14namespace internal { namespace standard {
15
16 VEC3* VEC3Maximize(VEC3* pOut, const VEC3* p1, const VEC3* p2);
17 VEC3* VEC3Minimize(VEC3* pOut, const VEC3* p1, const VEC3* p2);
18 f32 VEC3SquareDist(const VEC3* p1, const VEC3* p2);
19
20} } // namespace internal::standard
21
22#if defined(NW_MATH_ENABLE_INTRINSICS)
23
24namespace internal { namespace intrinsics {
25
26 VEC3* VEC3Maximize(VEC3* pOut, const VEC3* p1, const VEC3* p2);
27 VEC3* VEC3Minimize(VEC3* pOut, const VEC3* p1, const VEC3* p2);
28 f32 VEC3SquareDist(const VEC3* p1, const VEC3* p2);
29
30} } // namespace internal::intrinsics
31
32#endif // NW_MATH_ENABLE_INTRINSICS
33
35NW_MATH_INLINE VEC3* VEC3Maximize(VEC3* pOut, const VEC3* p1, const VEC3* p2);
36NW_MATH_INLINE VEC3* VEC3Minimize(VEC3* pOut, const VEC3* p1, const VEC3* p2);
37NW_MATH_INLINE VEC3* VEC3Cross(VEC3* pOut, const VEC3* p1, const VEC3* p2);
39/* NW_MATH_INLINE */ extern VEC3* VEC3FastNormalize(VEC3* pOut, const VEC3* p);
40NW_MATH_INLINE VEC3* VEC3SafeNormalize(VEC3* pOut, const VEC3* p, const VEC3& alt);
41/* NW_MATH_INLINE */ extern VEC3* VEC3FastSafeNormalize(VEC3* pOut, const VEC3* p, const VEC3& alt);
43
44inline VEC3* VEC3Add(VEC3* pOut, const VEC3* p1, const VEC3* p2);
45inline VEC3* VEC3Sub(VEC3* pOut, const VEC3* p1, const VEC3* p2);
46inline VEC3* VEC3Mult(VEC3* pOut, const VEC3* p1, const VEC3* p2);
47inline VEC3* VEC3Scale(VEC3* pOut, const VEC3* p, f32 scale);
48inline VEC3* VEC3Lerp(VEC3* pOut, const VEC3* p1, const VEC3* p2, f32 t);
49inline f32 VEC3Dot(const VEC3* p1, const VEC3* p2);
50inline f32 VEC3Len(const VEC3* p);
51inline f32 VEC3SquareLen(const VEC3* p);
52inline f32 VEC3Dist(const VEC3* p1, const VEC3* p2);
53
54struct VEC3_
55{
59};
60
61struct VEC3 : public VEC3_
62{
63public:
64 static const int DIMENSION = 3;
65
66 static const VEC3& Zero()
67 {
68 static const VEC3 zero(0.0f, 0.0f, 0.0f);
69
70 return zero;
71 }
72
73 typedef VEC3 self_type;
74 typedef f32 value_type;
75public:
76 VEC3() {}
77 explicit VEC3(const f32* p) { x = p[0]; y = p[1]; z = p[2]; }
78 explicit VEC3(const VEC3_& v) { x = v.x; y = v.y; z = v.z; }
79 VEC3(f32 fx, f32 fy, f32 fz) { x = fx; y = fy; z = fz; }
80
81 operator f32*() { return &x; }
82 operator const f32*() const { return &x; }
83
84 f32* ToF32() { return &x; }
85 const f32* ToF32() const { return &x; }
86
87 template <typename ToPtr>
89 {
90 return reinterpret_cast<ToPtr>( this );
91 }
92
93 template <typename ToPtr>
94 ToPtr Cast() const
95 {
96 return reinterpret_cast<ToPtr>( this );
97 }
98
99 self_type& operator += (const self_type& rhs) { (void)VEC3Add(this, this, &rhs); return *this; }
100 self_type& operator -= (const self_type& rhs) { (void)VEC3Sub(this, this, &rhs); return *this; }
101 self_type& operator *= (const self_type& rhs) { (void)VEC3Mult(this, this, &rhs); return *this; }
102 self_type& operator *= (f32 f) { (void)VEC3Scale(this, this, f); return *this; }
103 self_type& operator /= (f32 f) { return operator*=(1.f / f); }
104
105 self_type operator + () const { return *this; }
106 self_type operator - () const { return self_type(-x, -y, -z); }
107
108 self_type operator + (const self_type& rhs) const { VEC3 tmp; (void)VEC3Add(&tmp, this, &rhs); return tmp; }
109 self_type operator - (const self_type& rhs) const { VEC3 tmp; (void)VEC3Sub(&tmp, this, &rhs); return tmp; }
110 self_type operator * (f32 f) const { VEC3 tmp; (void)VEC3Scale(&tmp, this, f); return tmp; }
111 self_type operator / (f32 f) const { f32 r = 1.f / f; return operator*(r); }
112
113 self_type& Lerp(const VEC3& lhs, const VEC3& rhs, f32 t)
114 {
115 return *VEC3Lerp(this, &lhs, &rhs, t);
116 }
117
118 f32 Dot(const VEC3& vec) const
119 {
120 return VEC3Dot(this, &vec);
121 }
122
123 f32 LengthSquare() const { return VEC3SquareLen(this); }
124 f32 Length() const { return VEC3Len(this); }
125
127 {
128 return *VEC3Normalize(this, this);
129 }
130
132 {
133 return *VEC3Normalize(this, &src);
134 }
135
137 {
138 return *VEC3SafeNormalize(this, this, alt);
139 }
140
142 {
143 return *VEC3SafeNormalize(this, &src, alt);
144 }
145
147 {
148 return VEC3SquareDist(this, &vec);
149 }
150
152 {
153 return VEC3Dist(this, &vec);
154 }
155
157 {
158 return *VEC3Maximize(this, &lhs, &rhs);
159 }
160
162 {
163 return *VEC3Minimize(this, &lhs, &rhs);
164 }
165
167 {
168 return *VEC3Cross(this, this, &rhs);
169 }
170
172 {
173 return *VEC3Cross(this, &lhs, &rhs);
174 }
175
177 self_type& Transform(const MTX34& pM) { return this->SetTransform(pM, *this); }
178
179 NW_MATH_INLINE self_type& SetTransform(const MTX44& pM, const VEC3& src);
180 self_type& Transform(const MTX44& pM) { return this->SetTransform(pM, *this); }
181
182 NW_MATH_INLINE self_type& SetTransformNormal(const MTX34& pM, const VEC3& src);
183 self_type& TransformNormal(const MTX34& pM) { return this->SetTransform(pM, *this); } // <--- Mistake?
184
185 void Set(f32 fx, f32 fy, f32 fz) { x = fx; y = fy; z = fz; }
186 void Set(const self_type& value) { x = value.x; y = value.y; z = value.z; }
187
188#pragma clang diagnostic push
189#pragma clang diagnostic ignored "-Wfloat-equal"
190
191 bool operator == (const self_type& rhs) const { return x == rhs.x && y == rhs.y && z == rhs.z; }
192 bool operator != (const self_type& rhs) const { return x != rhs.x || y != rhs.y || z != rhs.z; }
193
194#pragma clang diagnostic pop
195
196 bool IsZero() const { return VEC3IsZero(this); }
197};
198
199typedef struct VEC3 Vector3;
200
201namespace internal { namespace standard {
202
204VEC3Add(VEC3* pOut, const VEC3* p1, const VEC3* p2)
205{
206 pOut->x = p1->x + p2->x;
207 pOut->y = p1->y + p2->y;
208 pOut->z = p1->z + p2->z;
209 return pOut;
210}
211
213VEC3Sub(VEC3* pOut, const VEC3* p1, const VEC3* p2)
214{
215 pOut->x = p1->x - p2->x;
216 pOut->y = p1->y - p2->y;
217 pOut->z = p1->z - p2->z;
218 return pOut;
219}
220
222VEC3Mult(VEC3* pOut, const VEC3* p1, const VEC3* p2)
223{
224 pOut->x = p1->x * p2->x;
225 pOut->y = p1->y * p2->y;
226 pOut->z = p1->z * p2->z;
227 return pOut;
228}
229
231VEC3Scale(VEC3* pOut, const VEC3* p, f32 scale)
232{
233 pOut->x = scale * p->x;
234 pOut->y = scale * p->y;
235 pOut->z = scale * p->z;
236 return pOut;
237}
238
240VEC3Lerp(VEC3* pOut, const VEC3* p1, const VEC3* p2, f32 t)
241{
242 pOut->x = p1->x + t * (p2->x - p1->x);
243 pOut->y = p1->y + t * (p2->y - p1->y);
244 pOut->z = p1->z + t * (p2->z - p1->z);
245 return pOut;
246}
247
249VEC3Dot(const VEC3* p1, const VEC3* p2)
250{
251 return p1->x * p2->x + p1->y * p2->y + p1->z * p2->z;
252}
253
254} } // namespace internal::standard
255
256#if defined(NW_MATH_ENABLE_INTRINSICS)
257
258namespace internal { namespace intrinsics {
259
261VEC3Add(VEC3* pOut, const VEC3* p1, const VEC3* p2)
262{
264
265 pOut->z = p1->z + p2->z;
266
267 return pOut;
268}
269
271VEC3Sub(VEC3* pOut, const VEC3* p1, const VEC3* p2)
272{
274
275 pOut->z = p1->z - p2->z;
276
277 return pOut;
278}
279
281VEC3Mult(VEC3* pOut, const VEC3* p1, const VEC3* p2)
282{
284
285 pOut->z = p1->z * p2->z;
286
287 return pOut;
288}
289
291VEC3Scale(VEC3* pOut, const VEC3* p, f32 scale)
292{
294
295 pOut->z = scale * p->z;
296
297 return pOut;
298}
299
301VEC3Lerp(VEC3* pOut, const VEC3* p1, const VEC3* p2, f32 t)
302{
303 f32x2 tt = __PS_FDUP(t);
304 f32x2 f0 = tof32x2(p1->x);
305 f0 = __PS_NMSUB(f0, tt, f0);
307
308 pOut->z = p1->z + t * (p2->z - p1->z);
309
310 return pOut;
311}
312
314VEC3Dot(const VEC3* p1, const VEC3* p2)
315{
316 f32x2 f0;
317 f0 = __PS_MUL(tof32x2(p1->x), tof32x2(p2->x));
318 f0 = __PS_SUM0(f0, f0, f0);
319
320 return f0[0] + p1->z * p2->z;
321}
322
323} } // namespace internal::intrinsics
324
325#endif // NW_MATH_ENABLE_INTRINSICS
326
327inline VEC3*
328VEC3Add(VEC3* pOut, const VEC3* p1, const VEC3* p2)
329{
330 return NW_MATH_IMPL_NS::VEC3Add(pOut, p1, p2);
331}
332
333inline VEC3*
334VEC3Sub(VEC3* pOut, const VEC3* p1, const VEC3* p2)
335{
336 return NW_MATH_IMPL_NS::VEC3Sub(pOut, p1, p2);
337}
338
339inline VEC3*
340VEC3Mult(VEC3* pOut, const VEC3* p1, const VEC3* p2)
341{
342 return NW_MATH_IMPL_NS::VEC3Mult(pOut, p1, p2);
343}
344
345inline VEC3*
346VEC3Scale(VEC3* pOut, const VEC3* p, f32 scale)
347{
348 return NW_MATH_IMPL_NS::VEC3Scale(pOut, p, scale);
349}
350
351inline VEC3*
352VEC3Lerp(VEC3* pOut, const VEC3* p1, const VEC3* p2, f32 t)
353{
354 return NW_MATH_IMPL_NS::VEC3Lerp(pOut, p1, p2, t);
355}
356
357inline f32
358VEC3Dot(const VEC3* p1, const VEC3* p2)
359{
360 return internal::standard::VEC3Dot(p1, p2);
361}
362
363inline f32
365{
366 return p->x * p->x + p->y * p->y + p->z * p->z;
367}
368
369inline f32
370VEC3Len(const VEC3* p)
371{
372 return ::std::sqrt( VEC3SquareLen( p ) );
373}
374
375inline f32
376VEC3Dist( const VEC3* p1, const VEC3* p2 )
377{
378 return ::std::sqrt( VEC3SquareDist( p1, p2 ) );
379}
380
381inline VEC3
382operator * (f32 f, const VEC3& rhs) { VEC3 tmp; (void)VEC3Scale(&tmp, &rhs, f); return tmp; }
383
384} } // namespace nw::math
385
386#if defined(NW_MATH_AS_INLINE)
387
388#include <cmath>
389
390namespace nw { namespace math {
391
392namespace internal { namespace standard {
393
395VEC3Maximize(VEC3* pOut, const VEC3* p1, const VEC3* p2)
396{
397 pOut->x = (p1->x > p2->x) ? p1->x : p2->x;
398 pOut->y = (p1->y > p2->y) ? p1->y : p2->y;
399 pOut->z = (p1->z > p2->z) ? p1->z : p2->z;
400
401 return pOut;
402}
403
405VEC3Minimize(VEC3* pOut, const VEC3* p1, const VEC3* p2)
406{
407 pOut->x = (p1->x < p2->x) ? p1->x : p2->x;
408 pOut->y = (p1->y < p2->y) ? p1->y : p2->y;
409 pOut->z = (p1->z < p2->z) ? p1->z : p2->z;
410
411 return pOut;
412}
413
415VEC3SquareDist(const VEC3* p1, const VEC3* p2)
416{
417 VEC3 diff;
418
419 diff.x = p1->x - p2->x;
420 diff.y = p1->y - p2->y;
421 diff.z = p1->z - p2->z;
422
423 return (diff.x * diff.x) + (diff.y * diff.y) + (diff.z * diff.z);
424}
425
426} } // namespace internal::standard
427
428#if defined(NW_MATH_ENABLE_INTRINSICS)
429
430namespace internal { namespace intrinsics {
431
433VEC3Maximize(VEC3* pOut, const VEC3* p1, const VEC3* p2)
434{
435 f32x2 f0, f1, f2;
436
437 f0 = tof32x2(p1->x);
438 f1 = tof32x2(p2->x);
439 f2 = __PS_SUB(f0, f1);
440 f2 = __PS_SEL(f2, f0, f1);
441
442 tof32x2(pOut->x) = f2;
443
444 pOut->z = (p1->z > p2->z) ? p1->z : p2->z;
445
446 return pOut;
447}
448
450VEC3Minimize(VEC3* pOut, const VEC3* p1, const VEC3* p2)
451{
452 f32x2 f0, f1, f2;
453
454 f0 = tof32x2(p1->x);
455 f1 = tof32x2(p2->x);
456 f2 = __PS_SUB(f1, f0);
457 f2 = __PS_SEL(f2, f0, f1);
458
459 tof32x2(pOut->x) = f2;
460
461 f32 z1 = p1->z;
462 f32 z2 = p2->z;
463
464 pOut->z = (z1 < z2) ? z1 : z2;
465
466 return pOut;
467}
468
470VEC3SquareDist(const VEC3* p1, const VEC3* p2)
471{
472 f32x2 f0;
473 f0 = __PS_SUB(tof32x2(p1->x), tof32x2(p2->x));
474 f0 = __PS_MUL(f0, f0);
475 f0 = __PS_SUM0(f0, f0, f0);
476
477 f32 f1 = p1->z - p2->z;
478
479 return f0[0] + f1 * f1;
480}
481
482} } // namespace internal::intrinsics
483
484#endif // NW_MATH_ENABLE_INTRINSICS
485
487VEC3IsZero(const VEC3* p)
488{
489 return p->x == 0.f && p->y == 0.f && p->z == 0.f;
490}
491
493VEC3Maximize(VEC3* pOut, const VEC3* p1, const VEC3* p2)
494{
495 return NW_MATH_IMPL_NS::VEC3Maximize(pOut, p1, p2);
496}
497
499VEC3Minimize(VEC3* pOut, const VEC3* p1, const VEC3* p2)
500{
501 return NW_MATH_IMPL_NS::VEC3Minimize(pOut, p1, p2);
502}
503
505VEC3Cross(VEC3* pOut, const VEC3* p1, const VEC3* p2)
506{
507 VEC3 tmpVec;
508
509 tmpVec.x = ( p1->y * p2->z ) - ( p1->z * p2->y );
510 tmpVec.y = ( p1->z * p2->x ) - ( p1->x * p2->z );
511 tmpVec.z = ( p1->x * p2->y ) - ( p1->y * p2->x );
512
513 pOut->x = tmpVec.x;
514 pOut->y = tmpVec.y;
515 pOut->z = tmpVec.z;
516
517 return pOut;
518}
519
521VEC3Normalize(VEC3* pOut, const VEC3* p)
522{
523 f32 mag = (p->x * p->x) + (p->y * p->y) + (p->z * p->z);
524
525 mag = 1.0f / ::std::sqrt(mag);
526
527 pOut->x = p->x * mag;
528 pOut->y = p->y * mag;
529 pOut->z = p->z * mag;
530
531 return pOut;
532}
533
534// NW_MATH_INLINE VEC3*
535// VEC3FastNormalize(VEC3* pOut, const VEC3* p)
536// {
537// f32 mag = (p->x * p->x) + (p->y * p->y) + (p->z * p->z);
538//
539// mag = FrFastSqrt(mag);
540//
541// pOut->x = p->x * mag;
542// pOut->y = p->y * mag;
543// pOut->z = p->z * mag;
544//
545// return pOut;
546// }
547
549VEC3SafeNormalize(VEC3* pOut, const VEC3* p, const VEC3& alt)
550{
551 f32 mag = (p->x * p->x) + (p->y * p->y) + (p->z * p->z);
552
553#pragma clang diagnostic push
554#pragma clang diagnostic ignored "-Wfloat-equal"
555
556 if (mag == 0 /* || mag == F_INF || isnan(mag) */)
557 {
558 *pOut = alt;
559
560 return pOut;
561 }
562
563#pragma clang diagnostic pop
564
565 mag = 1.0f / ::std::sqrt(mag);
566
567 pOut->x = p->x * mag;
568 pOut->y = p->y * mag;
569 pOut->z = p->z * mag;
570
571 return pOut;
572}
573
574// NW_MATH_INLINE VEC3*
575// VEC3FastSafeNormalize(VEC3* pOut, const VEC3* p, const VEC3& alt)
576// {
577// f32 mag = (p->x * p->x) + (p->y * p->y) + (p->z * p->z);
578//
579// if (mag == 0 /* || mag == F_INF || isnan(mag) */)
580// {
581// *pOut = alt;
582//
583// return pOut;
584// }
585//
586// mag = FrFastSqrt(mag);
587//
588// pOut->x = p->x * mag;
589// pOut->y = p->y * mag;
590// pOut->z = p->z * mag;
591//
592// return pOut;
593// }
594
596VEC3SquareDist(const VEC3* p1, const VEC3* p2)
597{
598 return NW_MATH_IMPL_NS::VEC3SquareDist(p1, p2);
599}
600
601} } // namespace nw::math
602
603#endif
604
605namespace nw { namespace math {
606
607inline bool VEC3IsZero(const VEC3& v){ return VEC3IsZero( &v ); }
608inline VEC3* VEC3Maximize(VEC3* pOut, const VEC3& v1, const VEC3& v2) { return VEC3Maximize( pOut, &v1, &v2 ); }
609inline VEC3* VEC3Minimize(VEC3* pOut, const VEC3& v1, const VEC3& v2) { return VEC3Minimize( pOut, &v1, &v2 ); }
610inline VEC3* VEC3Cross(VEC3* pOut, const VEC3& v1, const VEC3& v2) { return VEC3Cross( pOut, &v1, &v2 ); }
611inline VEC3* VEC3Normalize(VEC3* pOut, const VEC3& v) { return VEC3Normalize( pOut, &v ); }
612inline VEC3* VEC3FastNormalize(VEC3* pOut, const VEC3& v) { return VEC3FastNormalize( pOut, &v ); }
613inline VEC3* VEC3SafeNormalize(VEC3* pOut, const VEC3& v, const VEC3& alt) { return VEC3SafeNormalize( pOut, &v, alt ); }
614inline VEC3* VEC3FastSafeNormalize(VEC3* pOut, const VEC3& v, const VEC3& alt) { return VEC3FastSafeNormalize( pOut, &v, alt ); }
615inline f32 VEC3SquareDist(const VEC3& v1, const VEC3& v2) { return VEC3SquareDist( &v1, &v2 ); }
616
617inline VEC3* VEC3Add(VEC3* pOut, const VEC3& v1, const VEC3& v2) { return VEC3Add( pOut, &v1, &v2 ); }
618inline VEC3* VEC3Sub(VEC3* pOut, const VEC3& v1, const VEC3& v2) { return VEC3Sub( pOut, &v1, &v2 ); }
619inline VEC3* VEC3Scale(VEC3* pOut, const VEC3& v, f32 scale) { return VEC3Scale( pOut, &v, scale ); }
620inline VEC3* VEC3Lerp(VEC3* pOut, const VEC3& v1, const VEC3& v2, f32 t) { return VEC3Lerp( pOut, &v1, &v2, t ); }
621inline f32 VEC3Dot(const VEC3& v1, const VEC3& v2) { return VEC3Dot( &v1, &v2 ); }
622inline f32 VEC3Len(const VEC3& v) { return VEC3Len( &v ); }
623inline f32 VEC3SquareLen(const VEC3& v) { return VEC3SquareLen( &v ); }
624inline f32 VEC3Dist(const VEC3& v1, const VEC3& v2) { return VEC3Dist( &v1, &v2 ); }
625
626} } // namespace nw::math
627
628#endif
#define NW_MATH_AS_INLINE
Definition math_Config.h:6
#define NW_MATH_INLINE
Definition math_Config.h:7
#define NW_MATH_IMPL_NS
Definition math_Config.h:14
Definition math_Matrix34.h:11
NW_INLINE VEC3 * VEC3Scale(VEC3 *pOut, const VEC3 *p, f32 scale)
Definition math_Vector3.h:231
VEC3 * VEC3Maximize(VEC3 *pOut, const VEC3 *p1, const VEC3 *p2)
NW_INLINE VEC3 * VEC3Mult(VEC3 *pOut, const VEC3 *p1, const VEC3 *p2)
Definition math_Vector3.h:222
NW_INLINE VEC3 * VEC3Lerp(VEC3 *pOut, const VEC3 *p1, const VEC3 *p2, f32 t)
Definition math_Vector3.h:240
NW_INLINE VEC3 * VEC3Sub(VEC3 *pOut, const VEC3 *p1, const VEC3 *p2)
Definition math_Vector3.h:213
f32 VEC3SquareDist(const VEC3 *p1, const VEC3 *p2)
VEC3 * VEC3Minimize(VEC3 *pOut, const VEC3 *p1, const VEC3 *p2)
NW_INLINE VEC3 * VEC3Add(VEC3 *pOut, const VEC3 *p1, const VEC3 *p2)
Definition math_Vector3.h:204
NW_INLINE f32 VEC3Dot(const VEC3 *p1, const VEC3 *p2)
Definition math_Vector3.h:249
Definition math_Triangular.cpp:3
Definition math_Constant.cpp:5
VEC3 * VEC3Normalize(VEC3 *pOut, const VEC3 &v)
Definition math_Vector3.h:611
VEC3 * VEC3FastNormalize(VEC3 *pOut, const VEC3 *p)
VEC3 * VEC3Sub(VEC3 *pOut, const VEC3 *p1, const VEC3 *p2)
Definition math_Vector3.h:334
NW_MATH_INLINE VEC3 * VEC3Maximize(VEC3 *pOut, const VEC3 *p1, const VEC3 *p2)
VEC3 * VEC3Lerp(VEC3 *pOut, const VEC3 &v1, const VEC3 &v2, f32 t)
Definition math_Vector3.h:620
NW_MATH_INLINE VEC3 * VEC3SafeNormalize(VEC3 *pOut, const VEC3 *p, const VEC3 &alt)
f32 VEC3Dot(const VEC3 &v1, const VEC3 &v2)
Definition math_Vector3.h:621
VEC3 * VEC3FastSafeNormalize(VEC3 *pOut, const VEC3 *p, const VEC3 &alt)
f32 VEC3SquareLen(const VEC3 &v)
Definition math_Vector3.h:623
VEC3 * VEC3Add(VEC3 *pOut, const VEC3 &v1, const VEC3 &v2)
Definition math_Vector3.h:617
VEC3 * VEC3Maximize(VEC3 *pOut, const VEC3 &v1, const VEC3 &v2)
Definition math_Vector3.h:608
VEC3 * VEC3Scale(VEC3 *pOut, const VEC3 &v, f32 scale)
Definition math_Vector3.h:619
VEC3 * VEC3Minimize(VEC3 *pOut, const VEC3 &v1, const VEC3 &v2)
Definition math_Vector3.h:609
f32 VEC3SquareLen(const VEC3 *p)
Definition math_Vector3.h:364
f32 VEC3Dist(const VEC3 &v1, const VEC3 &v2)
Definition math_Vector3.h:624
f32 VEC3Len(const VEC3 &v)
Definition math_Vector3.h:622
VEC3 * VEC3Add(VEC3 *pOut, const VEC3 *p1, const VEC3 *p2)
Definition math_Vector3.h:328
f32 VEC3Dot(const VEC3 *p1, const VEC3 *p2)
Definition math_Vector3.h:358
NW_MATH_INLINE VEC3 * VEC3Cross(VEC3 *pOut, const VEC3 *p1, const VEC3 *p2)
NW_MATH_INLINE VEC3 * VEC3Normalize(VEC3 *pOut, const VEC3 *p)
f32 VEC3SquareDist(const VEC3 &v1, const VEC3 &v2)
Definition math_Vector3.h:615
VEC3 * VEC3FastNormalize(VEC3 *pOut, const VEC3 &v)
Definition math_Vector3.h:612
VEC3 * VEC3FastSafeNormalize(VEC3 *pOut, const VEC3 &v, const VEC3 &alt)
Definition math_Vector3.h:614
VEC3 * VEC3Scale(VEC3 *pOut, const VEC3 *p, f32 scale)
Definition math_Vector3.h:346
f32 VEC3Len(const VEC3 *p)
Definition math_Vector3.h:370
f32 VEC3Dist(const VEC3 *p1, const VEC3 *p2)
Definition math_Vector3.h:376
NW_MATH_INLINE bool VEC3IsZero(const VEC3 *p)
VEC3 * VEC3Mult(VEC3 *pOut, const VEC3 *p1, const VEC3 *p2)
Definition math_Vector3.h:340
NW_MATH_INLINE f32 VEC3SquareDist(const VEC3 *p1, const VEC3 *p2)
struct VEC3 Vector3
Definition math_Vector3.h:199
VEC3 * VEC3Sub(VEC3 *pOut, const VEC3 &v1, const VEC3 &v2)
Definition math_Vector3.h:618
bool VEC3IsZero(const VEC3 &v)
Definition math_Vector3.h:607
NW_MATH_INLINE VEC3 * VEC3Minimize(VEC3 *pOut, const VEC3 *p1, const VEC3 *p2)
VEC3 * VEC3SafeNormalize(VEC3 *pOut, const VEC3 &v, const VEC3 &alt)
Definition math_Vector3.h:613
VEC3 * VEC3Lerp(VEC3 *pOut, const VEC3 *p1, const VEC3 *p2, f32 t)
Definition math_Vector3.h:352
VEC3 operator*(f32 f, const VEC3 &rhs)
Definition math_Vector3.h:382
VEC3 * VEC3Cross(VEC3 *pOut, const VEC3 &v1, const VEC3 &v2)
Definition math_Vector3.h:610
Definition math_Constant.cpp:5
Definition math_Matrix34.h:136
Definition math_Matrix44.h:189
Definition math_Vector3.h:55
f32 z
Definition math_Vector3.h:58
f32 y
Definition math_Vector3.h:57
f32 x
Definition math_Vector3.h:56
Definition math_Vector3.h:62
static const VEC3 & Zero()
Definition math_Vector3.h:66
self_type & Transform(const MTX44 &pM)
Definition math_Vector3.h:180
VEC3()
Definition math_Vector3.h:76
f32 value_type
Definition math_Vector3.h:74
static const int DIMENSION
Definition math_Vector3.h:64
void Set(f32 fx, f32 fy, f32 fz)
Definition math_Vector3.h:185
NW_MATH_INLINE self_type & SetTransformNormal(const MTX34 &pM, const VEC3 &src)
Definition math_Transform.h:137
self_type & Transform(const MTX34 &pM)
Definition math_Vector3.h:177
VEC3(const VEC3_ &v)
Definition math_Vector3.h:78
bool IsZero() const
Definition math_Vector3.h:196
bool operator!=(const self_type &rhs) const
Definition math_Vector3.h:192
VEC3(const f32 *p)
Definition math_Vector3.h:77
void Set(const self_type &value)
Definition math_Vector3.h:186
bool operator==(const self_type &rhs) const
Definition math_Vector3.h:191
VEC3(f32 fx, f32 fy, f32 fz)
Definition math_Vector3.h:79
self_type & TransformNormal(const MTX34 &pM)
Definition math_Vector3.h:183
NW_MATH_INLINE self_type & SetTransform(const MTX44 &pM, const VEC3 &src)
Definition math_Transform.h:131
VEC3 self_type
Definition math_Vector3.h:73
#define NW_INLINE
Definition types.h:14