FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
DirectXTK/Inc/SimpleMath.h at main · microsoft/DirectXTK · GitHub
microsoft
/
DirectXTK
Public
Notifications
You must be signed in to change notification settings
Fork
537
Star
2.9k
Code
Issues
34
Pull requests
0
Actions
Projects
Wiki
Security and quality
2
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
DirectXTK
/
Inc
/
SimpleMath.h
Copy path
More file actions
More file actions
Latest commit
History
History
History
1626 lines (1376 loc) · 67.4 KB
Breadcrumbs
DirectXTK
/
Inc
/
SimpleMath.h
Copy path
File metadata and controls
1626 lines (1376 loc) · 67.4 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
//
-------------------------------------------------------------------------------------
//
SimpleMath.h -- Simplified C++ Math wrapper for DirectXMath
//
//
Copyright (c) Microsoft Corporation.
//
Licensed under the MIT License.
//
//
https://go.microsoft.com/fwlink/?LinkId=248929
//
https://go.microsoft.com/fwlink/?LinkID=615561
//
-------------------------------------------------------------------------------------
#
pragma
once
#
if
(defined(_WIN32) || defined(WINAPI_FAMILY)) && !(defined(_XBOX_ONE) && defined(_TITLE)) && !defined(_GAMING_XBOX)
#
include
<
dxgi1_2.h
>
#
endif
#
include
<
cassert
>
#
include
<
cmath
>
#
include
<
cstddef
>
#
include
<
cstring
>
#
include
<
functional
>
#
if
(__cplusplus >= 202002L)
#
include
<
compare
>
#
endif
#
include
<
DirectXMath.h
>
#
include
<
DirectXPackedVector.h
>
#
include
<
DirectXCollision.h
>
#
ifndef
DIRECTX_TOOLKIT_API
#
ifdef
DIRECTX_TOOLKIT_EXPORT
#
ifdef
__GNUC__
#
define
DIRECTX_TOOLKIT_API
__attribute__
((dllexport))
#
else
#
define
DIRECTX_TOOLKIT_API
__declspec
(dllexport)
#endif
#
elif
defined(DIRECTX_TOOLKIT_IMPORT)
#
ifdef
__GNUC__
#
define
DIRECTX_TOOLKIT_API
__attribute__
((dllimport))
#
else
#
define
DIRECTX_TOOLKIT_API
__declspec
(dllimport)
#endif
#
else
#
define
DIRECTX_TOOLKIT_API
#
endif
#
endif
#
if
defined(DIRECTX_TOOLKIT_IMPORT) && defined(_MSC_VER)
#
pragma
warning(push)
#
pragma
warning(disable : 4251 4275)
#
endif
#
ifdef
__clang__
#
pragma
clang diagnostic push
#
pragma
clang diagnostic ignored "-Wfloat-equal"
#
pragma
clang diagnostic ignored "-Wunknown-warning-option"
#
pragma
clang diagnostic ignored "-Wunsafe-buffer-usage"
#
endif
namespace
DirectX
{
namespace
SimpleMath
{
struct
Vector2
;
struct
Vector4
;
struct
Matrix
;
struct
Quaternion
;
struct
Plane
;
//
------------------------------------------------------------------------------
//
2D rectangle
struct
DIRECTX_TOOLKIT_API
Rectangle
{
long
x;
long
y;
long
width;
long
height;
//
Creators
Rectangle
()
noexcept
: x(
0
),
y
(
0
),
width(
0
),
height(
0
)
{}
constexpr
Rectangle
(
long
ix,
long
iy,
long
iw,
long
ih)
noexcept
: x(ix),
y(iy),
width(iw),
height(ih)
{}
explicit
Rectangle
(
const
RECT
& rct)
noexcept
: x(rct.left),
y(rct.top),
width(rct.right - rct.left),
height(rct.bottom - rct.top)
{}
Rectangle
(
const
Rectangle&) = default;
Rectangle&
operator
=(
const
Rectangle&) =
default
;
Rectangle
(Rectangle&&) = default;
Rectangle&
operator
=(Rectangle&&) =
default
;
operator
RECT
()
noexcept
{
RECT
rct;
rct.
left
= x;
rct.
top
= y;
rct.
right
= (x + width);
rct.
bottom
= (y + height);
return
rct;
}
#
ifdef
__cplusplus_winrt
operator
Windows::Foundation::Rect
()
noexcept
{
return
Windows::Foundation::Rect
(
float
(x),
float
(y),
float
(width),
float
(height));
}
#
endif
//
Comparison operators
#
if
(__cplusplus >= 202002L)
bool
operator
==(
const
Rectangle&)
const
=
default
;
auto
operator
<= > (
const
Rectangle&)
const
=
default
;
#
else
bool
operator
==(
const
Rectangle& r)
const
noexcept
{
return
(x == r.
x
) && (y == r.
y
) && (width == r.
width
) && (height == r.
height
);
}
bool
operator
!=(
const
Rectangle& r)
const
noexcept
{
return
(x != r.
x
) || (y != r.
y
) || (width != r.
width
) || (height != r.
height
);
}
#
endif
bool
operator
==(
const
RECT
& rct)
const
noexcept
{
return
(x == rct.
left
) && (y == rct.
top
) && (width == (rct.
right
- rct.
left
)) && (height == (rct.
bottom
- rct.
top
));
}
bool
operator
!=(
const
RECT
& rct)
const
noexcept
{
return
(x != rct.
left
) || (y != rct.
top
) || (width != (rct.
right
- rct.
left
)) || (height != (rct.
bottom
- rct.
top
));
}
//
Assignment operators
Rectangle&
operator
=(_In_
const
RECT
& rct)
noexcept
{
x = rct.
left
;
y = rct.
top
;
width = (rct.
right
- rct.
left
);
height = (rct.
bottom
- rct.
top
);
return
*
this
;
}
//
Rectangle operations
Vector2
Location
()
const
noexcept
;
Vector2
Center
()
const
noexcept
;
bool
IsEmpty
()
const
noexcept
{
return
(width ==
0
&& height ==
0
&& x ==
0
&& y ==
0
); }
bool
Contains
(
long
ix,
long
iy)
const
noexcept
{
return
(x <= ix) && (ix < (x + width)) && (y <= iy) && (iy < (y + height)); }
bool
Contains
(
const
Vector2& point)
const
noexcept
;
bool
Contains
(
const
Rectangle& r)
const
noexcept
{
return
(x <= r.
x
) && ((r.
x
+ r.
width
) <= (x + width)) && (y <= r.
y
) && ((r.
y
+ r.
height
) <= (y + height));
}
bool
Contains
(
const
RECT
& rct)
const
noexcept
{
return
(x <= rct.
left
) && (rct.
right
<= (x + width)) && (y <= rct.
top
) && (rct.
bottom
<= (y + height));
}
void
Inflate
(
long
horizAmount,
long
vertAmount)
noexcept
;
bool
Intersects
(
const
Rectangle& r)
const
noexcept
{
return
(r.
x
< (x + width)) && (x < (r.
x
+ r.
width
)) && (r.
y
< (y + height)) && (y < (r.
y
+ r.
height
));
}
bool
Intersects
(
const
RECT
& rct)
const
noexcept
{
return
(rct.
left
< (x + width)) && (x < rct.
right
) && (rct.
top
< (y + height)) && (y < rct.
bottom
);
}
void
Offset
(
long
ox,
long
oy)
noexcept
{
x += ox;
y += oy;
}
//
Static functions
static
Rectangle
Intersect
(
const
Rectangle& ra,
const
Rectangle& rb)
noexcept
;
static
RECT
Intersect
(
const
RECT
& rcta,
const
RECT
& rctb)
noexcept
;
static
Rectangle
Union
(
const
Rectangle& ra,
const
Rectangle& rb)
noexcept
;
static
RECT
Union
(
const
RECT
& rcta,
const
RECT
& rctb)
noexcept
;
};
//
------------------------------------------------------------------------------
//
2D vector
struct
DIRECTX_TOOLKIT_API
Vector2 : public
XMFLOAT2
{
Vector2
()
noexcept
:
XMFLOAT2
(
0
.f,
0
.f)
{}
constexpr
explicit
Vector2
(
float
ix)
noexcept
: XMFLOAT2(ix, ix)
{}
constexpr
Vector2
(
float
ix,
float
iy)
noexcept
: XMFLOAT2(ix, iy)
{}
explicit
Vector2
(_In_reads_(
2
)
const
float* pArray)
noexcept
: XMFLOAT2(pArray)
{}
Vector2
(
FXMVECTOR
V)
noexcept
{
XMStoreFloat2
(
this
, V); }
Vector2
(
const
XMFLOAT2
& V)
noexcept
{
this
->
x
= V.
x
;
this
->
y
= V.
y
;
}
explicit
Vector2
(
const
XMVECTORF32
& F)
noexcept
{
this
->
x
= F.
f
[
0
];
this
->
y
= F.
f
[
1
];
}
Vector2
(
const
Vector2&) =
default
;
Vector2&
operator
=(
const
Vector2&) =
default
;
Vector2
(Vector2&&) =
default
;
Vector2&
operator
=(Vector2&&) =
default
;
operator
XMVECTOR
()
const
noexcept
{
return
XMLoadFloat2
(
this
); }
//
Comparison operators
bool
operator
==(
const
Vector2& V)
const
noexcept
{
return
((x == V.
x
) && (y == V.
y
)); }
bool
operator
!=(
const
Vector2& V)
const
noexcept
{
return
((x != V.
x
) || (y != V.
y
)); }
//
Assignment operators
Vector2&
operator
=(
const
XMVECTORF32
& F)
noexcept
{
x = F.
f
[
0
];
y = F.
f
[
1
];
return
*
this
;
}
Vector2&
operator
+=(
const
Vector2& V)
noexcept
{
x += V.
x
;
y += V.
y
;
return
*
this
;
}
Vector2&
operator
-=(
const
Vector2& V)
noexcept
{
x -= V.
x
;
y -= V.
y
;
return
*
this
;
}
Vector2&
operator
*=(
const
Vector2& V)
noexcept
{
x *= V.
x
;
y *= V.
y
;
return
*
this
;
}
Vector2&
operator
*=(
float
S)
noexcept
{
x *= S;
y *= S;
return
*
this
;
}
Vector2&
operator
/=(
float
S)
noexcept
{
x /= S;
y /= S;
return
*
this
;
}
//
Unary operators
Vector2
operator
+()
const
noexcept
{
return
*
this
; }
Vector2
operator
-()
const
noexcept
{
return
Vector2
(-x, -y); }
//
Vector operations
bool
InBounds
(
const
Vector2& Bounds)
const
noexcept
;
float
Length
()
const
noexcept
{
return
std::sqrt
((x * x) + (y * y)); }
float
LengthSquared
()
const
noexcept
{
return
(x * x) + (y * y); }
float
Dot
(
const
Vector2& V)
const
noexcept
{
return
(x * V.
x
) + (y * V.
y
); }
void
Cross
(
const
Vector2& V, Vector2& result)
const
noexcept
{ result.
x
= result.
y
= (x * V.
y
) - (y * V.
x
); }
Vector2
Cross
(
const
Vector2& V)
const
noexcept
{
float
c = (x * V.
y
) - (y * V.
x
);
return
Vector2
(c, c);
}
void
Normalize
()
noexcept
;
void
Normalize
(Vector2& result)
const
noexcept
;
void
Clamp
(
const
Vector2& vmin,
const
Vector2& vmax)
noexcept
;
void
Clamp
(
const
Vector2& vmin,
const
Vector2& vmax, Vector2& result)
const
noexcept
;
//
Static functions
static
float
Distance
(
const
Vector2& v1,
const
Vector2& v2)
noexcept
;
static
float
DistanceSquared
(
const
Vector2& v1,
const
Vector2& v2)
noexcept
;
static
void
Min
(
const
Vector2& v1,
const
Vector2& v2, Vector2& result)
noexcept
;
static
Vector2
Min
(
const
Vector2& v1,
const
Vector2& v2)
noexcept
;
static
void
Max
(
const
Vector2& v1,
const
Vector2& v2, Vector2& result)
noexcept
;
static
Vector2
Max
(
const
Vector2& v1,
const
Vector2& v2)
noexcept
;
static
void
Lerp
(
const
Vector2& v1,
const
Vector2& v2,
float
t, Vector2& result)
noexcept
;
static
Vector2
Lerp
(
const
Vector2& v1,
const
Vector2& v2,
float
t)
noexcept
;
static
void
SmoothStep
(
const
Vector2& v1,
const
Vector2& v2,
float
t, Vector2& result)
noexcept
;
static
Vector2
SmoothStep
(
const
Vector2& v1,
const
Vector2& v2,
float
t)
noexcept
;
static
void
Barycentric
(
const
Vector2& v1,
const
Vector2& v2,
const
Vector2& v3,
float
f,
float
g, Vector2& result)
noexcept
;
static
Vector2
Barycentric
(
const
Vector2& v1,
const
Vector2& v2,
const
Vector2& v3,
float
f,
float
g)
noexcept
;
static
void
CatmullRom
(
const
Vector2& v1,
const
Vector2& v2,
const
Vector2& v3,
const
Vector2& v4,
float
t, Vector2& result)
noexcept
;
static
Vector2
CatmullRom
(
const
Vector2& v1,
const
Vector2& v2,
const
Vector2& v3,
const
Vector2& v4,
float
t)
noexcept
;
static
void
Hermite
(
const
Vector2& v1,
const
Vector2& t1,
const
Vector2& v2,
const
Vector2& t2,
float
t, Vector2& result)
noexcept
;
static
Vector2
Hermite
(
const
Vector2& v1,
const
Vector2& t1,
const
Vector2& v2,
const
Vector2& t2,
float
t)
noexcept
;
static
void
Reflect
(
const
Vector2& ivec,
const
Vector2& nvec, Vector2& result)
noexcept
;
static
Vector2
Reflect
(
const
Vector2& ivec,
const
Vector2& nvec)
noexcept
;
static
void
Refract
(
const
Vector2& ivec,
const
Vector2& nvec,
float
refractionIndex, Vector2& result)
noexcept
;
static
Vector2
Refract
(
const
Vector2& ivec,
const
Vector2& nvec,
float
refractionIndex)
noexcept
;
static
void
Transform
(
const
Vector2& v,
const
Quaternion& quat, Vector2& result)
noexcept
;
static
Vector2
Transform
(
const
Vector2& v,
const
Quaternion& quat)
noexcept
;
static
void
Transform
(
const
Vector2& v,
const
Matrix& m, Vector2& result)
noexcept
;
static
Vector2
Transform
(
const
Vector2& v,
const
Matrix& m)
noexcept
;
static
void
Transform
(_In_reads_(count)
const
Vector2* varray,
size_t count,
const
Matrix& m,
_Out_writes_(count) Vector2* resultArray)
noexcept
;
static
void
Transform
(
const
Vector2& v,
const
Matrix& m, Vector4& result)
noexcept
;
static
void
Transform
(_In_reads_(count)
const
Vector2* varray,
size_t count,
const
Matrix& m,
_Out_writes_(count) Vector4* resultArray)
noexcept
;
static
void
TransformNormal
(
const
Vector2& v,
const
Matrix& m, Vector2& result)
noexcept
;
static
Vector2
TransformNormal
(
const
Vector2& v,
const
Matrix& m)
noexcept
;
static
void
TransformNormal
(_In_reads_(count)
const
Vector2* varray,
size_t count,
const
Matrix& m,
_Out_writes_(count) Vector2* resultArray)
noexcept
;
//
Constants
static
const
Vector2 Zero;
static
const
Vector2 One;
static
const
Vector2 UnitX;
static
const
Vector2 UnitY;
};
//
Binary operators
DIRECTX_TOOLKIT_API
inline
Vector2
operator
+(
const
Vector2&
V1
,
const
Vector2&
V2
)
noexcept
{
return
Vector2
(
V1
.
x
+
V2
.
x
,
V1
.
y
+
V2
.
y
);
}
DIRECTX_TOOLKIT_API
inline
Vector2
operator
-(
const
Vector2&
V1
,
const
Vector2&
V2
)
noexcept
{
return
Vector2
(
V1
.
x
-
V2
.
x
,
V1
.
y
-
V2
.
y
);
}
DIRECTX_TOOLKIT_API
inline
Vector2
operator
*(
const
Vector2&
V1
,
const
Vector2&
V2
)
noexcept
{
return
Vector2
(
V1
.
x
*
V2
.
x
,
V1
.
y
*
V2
.
y
);
}
DIRECTX_TOOLKIT_API
inline
Vector2
operator
*(
const
Vector2& V,
float
S)
noexcept
{
return
Vector2
(V.
x
* S, V.
y
* S);
}
DIRECTX_TOOLKIT_API
inline
Vector2
operator
*(
float
S,
const
Vector2& V)
noexcept
{
return
Vector2
(S * V.
x
, S * V.
y
);
}
DIRECTX_TOOLKIT_API
inline
Vector2
operator
/(
const
Vector2&
V1
,
const
Vector2&
V2
)
noexcept
{
return
Vector2
(
V1
.
x
/
V2
.
x
,
V1
.
y
/
V2
.
y
);
}
DIRECTX_TOOLKIT_API
inline
Vector2
operator
/(
const
Vector2& V,
float
S)
noexcept
{
return
Vector2
(V.
x
/ S, V.
y
/ S);
}
DIRECTX_TOOLKIT_API
inline
Vector2
operator
/(
float
S,
const
Vector2& V)
noexcept
{
return
Vector2
(S / V.
x
, S / V.
y
);
};
//
------------------------------------------------------------------------------
//
3D vector
struct
DIRECTX_TOOLKIT_API
Vector3 : public
XMFLOAT3
{
Vector3
()
noexcept
:
XMFLOAT3
(
0
.f,
0
.f,
0
.f)
{}
constexpr
explicit
Vector3
(
float
ix)
noexcept
: XMFLOAT3(ix, ix, ix)
{}
constexpr
Vector3
(
float
ix,
float
iy,
float
iz)
noexcept
: XMFLOAT3(ix, iy, iz)
{}
explicit
Vector3
(_In_reads_(
3
)
const
float* pArray)
noexcept
: XMFLOAT3(pArray)
{}
Vector3
(
FXMVECTOR
V)
noexcept
{
XMStoreFloat3
(
this
, V); }
Vector3
(
const
XMFLOAT3
& V)
noexcept
{
this
->
x
= V.
x
;
this
->
y
= V.
y
;
this
->
z
= V.
z
;
}
explicit
Vector3
(
const
XMVECTORF32
& F)
noexcept
{
this
->
x
= F.
f
[
0
];
this
->
y
= F.
f
[
1
];
this
->
z
= F.
f
[
2
];
}
Vector3
(
const
Vector3&) =
default
;
Vector3&
operator
=(
const
Vector3&) =
default
;
Vector3
(Vector3&&) =
default
;
Vector3&
operator
=(Vector3&&) =
default
;
operator
XMVECTOR
()
const
noexcept
{
return
XMLoadFloat3
(
this
); }
//
Comparison operators
bool
operator
==(
const
Vector3& V)
const
noexcept
{
return
((x == V.
x
) && (y == V.
y
) && (z == V.
z
)); }
bool
operator
!=(
const
Vector3& V)
const
noexcept
{
return
((x != V.
x
) || (y != V.
y
) || (z != V.
z
)); }
//
Assignment operators
Vector3&
operator
=(
const
XMVECTORF32
& F)
noexcept
{
x = F.
f
[
0
];
y = F.
f
[
1
];
z = F.
f
[
2
];
return
*
this
;
}
Vector3&
operator
+=(
const
Vector3& V)
noexcept
{
x += V.
x
;
y += V.
y
;
z += V.
z
;
return
*
this
;
}
Vector3&
operator
-=(
const
Vector3& V)
noexcept
{
x -= V.
x
;
y -= V.
y
;
z -= V.
z
;
return
*
this
;
}
Vector3&
operator
*=(
const
Vector3& V)
noexcept
{
x *= V.
x
;
y *= V.
y
;
z *= V.
z
;
return
*
this
;
}
Vector3&
operator
*=(
float
S)
noexcept
{
x *= S;
y *= S;
z *= S;
return
*
this
;
}
Vector3&
operator
/=(
float
S)
noexcept
{
x /= S;
y /= S;
z /= S;
return
*
this
;
}
//
Unary operators
Vector3
operator
+()
const
noexcept
{
return
*
this
; }
Vector3
operator
-()
const
noexcept
{
return
Vector3
(-x, -y, -z); }
//
Vector operations
bool
InBounds
(
const
Vector3& Bounds)
const
noexcept
;
float
Length
()
const
noexcept
{
return
std::sqrt
((x * x) + (y * y) + (z * z)); }
float
LengthSquared
()
const
noexcept
{
return
(x * x) + (y * y) + (z * z); }
float
Dot
(
const
Vector3& V)
const
noexcept
{
return
(x * V.
x
) + (y * V.
y
) + (z * V.
z
); }
void
Cross
(
const
Vector3& V, Vector3& result)
const
noexcept
{
result.
x
= y * V.
z
- z * V.
y
;
result.
y
= z * V.
x
- x * V.
z
;
result.
z
= x * V.
y
- y * V.
x
;
}
Vector3
Cross
(
const
Vector3& V)
const
noexcept
{
return
Vector3
(y * V.
z
- z * V.
y
, z * V.
x
- x * V.
z
, x * V.
y
- y * V.
x
); }
void
Normalize
()
noexcept
;
void
Normalize
(Vector3& result)
const
noexcept
;
void
Clamp
(
const
Vector3& vmin,
const
Vector3& vmax)
noexcept
;
void
Clamp
(
const
Vector3& vmin,
const
Vector3& vmax, Vector3& result)
const
noexcept
;
//
Static functions
static
float
Distance
(
const
Vector3& v1,
const
Vector3& v2)
noexcept
;
static
float
DistanceSquared
(
const
Vector3& v1,
const
Vector3& v2)
noexcept
;
static
void
Min
(
const
Vector3& v1,
const
Vector3& v2, Vector3& result)
noexcept
;
static
Vector3
Min
(
const
Vector3& v1,
const
Vector3& v2)
noexcept
;
static
void
Max
(
const
Vector3& v1,
const
Vector3& v2, Vector3& result)
noexcept
;
static
Vector3
Max
(
const
Vector3& v1,
const
Vector3& v2)
noexcept
;
static
void
Lerp
(
const
Vector3& v1,
const
Vector3& v2,
float
t, Vector3& result)
noexcept
;
static
Vector3
Lerp
(
const
Vector3& v1,
const
Vector3& v2,
float
t)
noexcept
;
static
void
SmoothStep
(
const
Vector3& v1,
const
Vector3& v2,
float
t, Vector3& result)
noexcept
;
static
Vector3
SmoothStep
(
const
Vector3& v1,
const
Vector3& v2,
float
t)
noexcept
;
static
void
Barycentric
(
const
Vector3& v1,
const
Vector3& v2,
const
Vector3& v3,
float
f,
float
g, Vector3& result)
noexcept
;
static
Vector3
Barycentric
(
const
Vector3& v1,
const
Vector3& v2,
const
Vector3& v3,
float
f,
float
g)
noexcept
;
static
void
CatmullRom
(
const
Vector3& v1,
const
Vector3& v2,
const
Vector3& v3,
const
Vector3& v4,
float
t, Vector3& result)
noexcept
;
static
Vector3
CatmullRom
(
const
Vector3& v1,
const
Vector3& v2,
const
Vector3& v3,
const
Vector3& v4,
float
t)
noexcept
;
static
void
Hermite
(
const
Vector3& v1,
const
Vector3& t1,
const
Vector3& v2,
const
Vector3& t2,
float
t, Vector3& result)
noexcept
;
static
Vector3
Hermite
(
const
Vector3& v1,
const
Vector3& t1,
const
Vector3& v2,
const
Vector3& t2,
float
t)
noexcept
;
static
void
Reflect
(
const
Vector3& ivec,
const
Vector3& nvec, Vector3& result)
noexcept
;
static
Vector3
Reflect
(
const
Vector3& ivec,
const
Vector3& nvec)
noexcept
;
static
void
Refract
(
const
Vector3& ivec,
const
Vector3& nvec,
float
refractionIndex, Vector3& result)
noexcept
;
static
Vector3
Refract
(
const
Vector3& ivec,
const
Vector3& nvec,
float
refractionIndex)
noexcept
;
static
void
Transform
(
const
Vector3& v,
const
Quaternion& quat, Vector3& result)
noexcept
;
static
Vector3
Transform
(
const
Vector3& v,
const
Quaternion& quat)
noexcept
;
static
void
Transform
(
const
Vector3& v,
const
Matrix& m, Vector3& result)
noexcept
;
static
Vector3
Transform
(
const
Vector3& v,
const
Matrix& m)
noexcept
;
static
void
Transform
(_In_reads_(count)
const
Vector3* varray,
size_t count,
const
Matrix& m,
_Out_writes_(count) Vector3* resultArray)
noexcept
;
static
void
Transform
(
const
Vector3& v,
const
Matrix& m, Vector4& result)
noexcept
;
static
void
Transform
(_In_reads_(count)
const
Vector3* varray,
size_t count,
const
Matrix& m,
_Out_writes_(count) Vector4* resultArray)
noexcept
;
static
void
TransformNormal
(
const
Vector3& v,
const
Matrix& m, Vector3& result)
noexcept
;
static
Vector3
TransformNormal
(
const
Vector3& v,
const
Matrix& m)
noexcept
;
static
void
TransformNormal
(_In_reads_(count)
const
Vector3* varray,
size_t count,
const
Matrix& m,
_Out_writes_(count) Vector3* resultArray)
noexcept
;
//
Constants
static
const
Vector3 Zero;
static
const
Vector3 One;
static
const
Vector3 UnitX;
static
const
Vector3 UnitY;
static
const
Vector3 UnitZ;
static
const
Vector3 Up;
static
const
Vector3 Down;
static
const
Vector3 Right;
static
const
Vector3 Left;
static
const
Vector3 Forward;
static
const
Vector3 Backward;
};
//
Binary operators
DIRECTX_TOOLKIT_API
inline
Vector3
operator
+(
const
Vector3&
V1
,
const
Vector3&
V2
)
noexcept
{
return
Vector3
(
V1
.
x
+
V2
.
x
,
V1
.
y
+
V2
.
y
,
V1
.
z
+
V2
.
z
);
}
DIRECTX_TOOLKIT_API
inline
Vector3
operator
-(
const
Vector3&
V1
,
const
Vector3&
V2
)
noexcept
{
return
Vector3
(
V1
.
x
-
V2
.
x
,
V1
.
y
-
V2
.
y
,
V1
.
z
-
V2
.
z
);
}
DIRECTX_TOOLKIT_API
inline
Vector3
operator
*(
const
Vector3&
V1
,
const
Vector3&
V2
)
noexcept
{
return
Vector3
(
V1
.
x
*
V2
.
x
,
V1
.
y
*
V2
.
y
,
V1
.
z
*
V2
.
z
);
}
DIRECTX_TOOLKIT_API
inline
Vector3
operator
*(
const
Vector3& V,
float
S)
noexcept
{
return
Vector3
(V.
x
* S, V.
y
* S, V.
z
* S);
}
DIRECTX_TOOLKIT_API
inline
Vector3
operator
*(
float
S,
const
Vector3& V)
noexcept
{
return
Vector3
(S * V.
x
, S * V.
y
, S * V.
z
);
}
DIRECTX_TOOLKIT_API
inline
Vector3
operator
/(
const
Vector3&
V1
,
const
Vector3&
V2
)
noexcept
{
return
Vector3
(
V1
.
x
/
V2
.
x
,
V1
.
y
/
V2
.
y
,
V1
.
z
/
V2
.
z
);
}
DIRECTX_TOOLKIT_API
inline
Vector3
operator
/(
const
Vector3& V,
float
S)
noexcept
{
return
Vector3
(V.
x
/ S, V.
y
/ S, V.
z
/ S);
}
DIRECTX_TOOLKIT_API
inline
Vector3
operator
/(
float
S,
const
Vector3& V)
noexcept
{
return
Vector3
(S / V.
x
, S / V.
y
, S / V.
z
);
}
//
------------------------------------------------------------------------------
//
4D vector
struct
DIRECTX_TOOLKIT_API
Vector4 : public
XMFLOAT4
{
Vector4
()
noexcept
:
XMFLOAT4
(
0
.f,
0
.f,
0
.f,
0
.f)
{}
constexpr
explicit
Vector4
(
float
ix)
noexcept
: XMFLOAT4(ix, ix, ix, ix)
{}
constexpr
Vector4
(
float
ix,
float
iy,
float
iz,
float
iw)
noexcept
: XMFLOAT4(ix, iy, iz, iw)
{}
explicit
Vector4
(_In_reads_(
4
)
const
float* pArray)
noexcept
: XMFLOAT4(pArray)
{}
Vector4
(
FXMVECTOR
V)
noexcept
{
XMStoreFloat4
(
this
, V); }
Vector4
(
const
XMFLOAT4
& V)
noexcept
{
this
->
x
= V.
x
;
this
->
y
= V.
y
;
this
->
z
= V.
z
;
this
->
w
= V.
w
;
}
explicit
Vector4
(
const
XMVECTORF32
& F)
noexcept
{
this
->
x
= F.
f
[
0
];
this
->
y
= F.
f
[
1
];
this
->
z
= F.
f
[
2
];
this
->
w
= F.
f
[
3
];
}
Vector4
(
const
Vector4&) =
default
;
Vector4&
operator
=(
const
Vector4&) =
default
;
Vector4
(Vector4&&) =
default
;
Vector4&
operator
=(Vector4&&) =
default
;
operator
XMVECTOR
()
const
noexcept
{
return
XMLoadFloat4
(
this
); }
//
Comparison operators
bool
operator
==(
const
Vector4& V)
const
noexcept
;
bool
operator
!=(
const
Vector4& V)
const
noexcept
;
//
Assignment operators
Vector4&
operator
=(
const
XMVECTORF32
& F)
noexcept
{
x = F.
f
[
0
];
y = F.
f
[
1
];
z = F.
f
[
2
];
w = F.
f
[
3
];
return
*
this
;
}
Vector4&
operator
+=(
const
Vector4& V)
noexcept
;
Vector4&
operator
-=(
const
Vector4& V)
noexcept
;
Vector4&
operator
*=(
const
Vector4& V)
noexcept
;
Vector4&
operator
*=(
float
S)
noexcept
;
Vector4&
operator
/=(
float
S)
noexcept
;
//
Unary operators
Vector4
operator
+()
const
noexcept
{
return
*
this
; }
Vector4
operator
-()
const
noexcept
{
return
Vector4
(-x, -y, -z, -w); }
//
Vector operations
bool
InBounds
(
const
Vector4& Bounds)
const
noexcept
;
float
Length
()
const
noexcept
;
float
LengthSquared
()
const
noexcept
;
float
Dot
(
const
Vector4& V)
const
noexcept
;
void
Cross
(
const
Vector4& v1,
const
Vector4& v2, Vector4& result)
const
noexcept
;
Vector4
Cross
(
const
Vector4& v1,
const
Vector4& v2)
const
noexcept
;
void
Normalize
()
noexcept
;
void
Normalize
(Vector4& result)
const
noexcept
;
void
Clamp
(
const
Vector4& vmin,
const
Vector4& vmax)
noexcept
;
void
Clamp
(
const
Vector4& vmin,
const
Vector4& vmax, Vector4& result)
const
noexcept
;
//
Static functions
static
float
Distance
(
const
Vector4& v1,
const
Vector4& v2)
noexcept
;
static
float
DistanceSquared
(
const
Vector4& v1,
const
Vector4& v2)
noexcept
;
static
void
Min
(
const
Vector4& v1,
const
Vector4& v2, Vector4& result)
noexcept
;
static
Vector4
Min
(
const
Vector4& v1,
const
Vector4& v2)
noexcept
;
static
void
Max
(
const
Vector4& v1,
const
Vector4& v2, Vector4& result)
noexcept
;
static
Vector4
Max
(
const
Vector4& v1,
const
Vector4& v2)
noexcept
;
static
void
Lerp
(
const
Vector4& v1,
const
Vector4& v2,
float
t, Vector4& result)
noexcept
;
static
Vector4
Lerp
(
const
Vector4& v1,
const
Vector4& v2,
float
t)
noexcept
;
static
void
SmoothStep
(
const
Vector4& v1,
const
Vector4& v2,
float
t, Vector4& result)
noexcept
;
static
Vector4
SmoothStep
(
const
Vector4& v1,
const
Vector4& v2,
float
t)
noexcept
;
static
void
Barycentric
(
const
Vector4& v1,
const
Vector4& v2,
const
Vector4& v3,
float
f,
float
g, Vector4& result)
noexcept
;
static
Vector4
Barycentric
(
const
Vector4& v1,
const
Vector4& v2,
const
Vector4& v3,
float
f,
float
g)
noexcept
;
static
void
CatmullRom
(
const
Vector4& v1,
const
Vector4& v2,
const
Vector4& v3,
const
Vector4& v4,
float
t, Vector4& result)
noexcept
;
static
Vector4
CatmullRom
(
const
Vector4& v1,
const
Vector4& v2,
const
Vector4& v3,
const
Vector4& v4,
float
t)
noexcept
;
static
void
Hermite
(
const
Vector4& v1,
const
Vector4& t1,
const
Vector4& v2,
const
Vector4& t2,
float
t, Vector4& result)
noexcept
;
static
Vector4
Hermite
(
const
Vector4& v1,
const
Vector4& t1,
const
Vector4& v2,
const
Vector4& t2,
float
t)
noexcept
;
static
void
Reflect
(
const
Vector4& ivec,
const
Vector4& nvec, Vector4& result)
noexcept
;
static
Vector4
Reflect
(
const
Vector4& ivec,
const
Vector4& nvec)
noexcept
;
static
void
Refract
(
const
Vector4& ivec,
const
Vector4& nvec,
float
refractionIndex, Vector4& result)
noexcept
;
static
Vector4
Refract
(
const
Vector4& ivec,
const
Vector4& nvec,
float
refractionIndex)
noexcept
;
static
void
Transform
(
const
Vector2& v,
const
Quaternion& quat, Vector4& result)
noexcept
;
static
Vector4
Transform
(
const
Vector2& v,
const
Quaternion& quat)
noexcept
;
static
void
Transform
(
const
Vector3& v,
const
Quaternion& quat, Vector4& result)
noexcept
;
static
Vector4
Transform
(
const
Vector3& v,
const
Quaternion& quat)
noexcept
;
static
void
Transform
(
const
Vector4& v,
const
Quaternion& quat, Vector4& result)
noexcept
;
static
Vector4
Transform
(
const
Vector4& v,
const
Quaternion& quat)
noexcept
;
static
void
Transform
(
const
Vector4& v,
const
Matrix& m, Vector4& result)
noexcept
;
static
Vector4
Transform
(
const
Vector4& v,
const
Matrix& m)
noexcept
;
static
void
Transform
(_In_reads_(count)
const
Vector4* varray,
size_t count,
const
Matrix& m,
_Out_writes_(count) Vector4* resultArray)
noexcept
;
//
Constants
static
const
Vector4 Zero;
static
const
Vector4 One;
static
const
Vector4 UnitX;
static
const
Vector4 UnitY;
static
const
Vector4 UnitZ;
static
const
Vector4 UnitW;
};
//
Binary operators
DIRECTX_TOOLKIT_API
Vector4
operator
+(
const
Vector4&
V1
,
const
Vector4&
V2
)
noexcept
;
DIRECTX_TOOLKIT_API
Vector4
operator
-(
const
Vector4&
V1
,
const
Vector4&
V2
)
noexcept
;
DIRECTX_TOOLKIT_API
Vector4
operator
*(
const
Vector4&
V1
,
const
Vector4&
V2
)
noexcept
;
DIRECTX_TOOLKIT_API
Vector4
operator
*(
const
Vector4& V,
float
S)
noexcept
;
DIRECTX_TOOLKIT_API
Vector4
operator
*(
float
S,
const
Vector4& V)
noexcept
;
DIRECTX_TOOLKIT_API
Vector4
operator
/(
const
Vector4&
V1
,
const
Vector4&
V2
)
noexcept
;
DIRECTX_TOOLKIT_API
Vector4
operator
/(
const
Vector4& V,
float
S)
noexcept
;
DIRECTX_TOOLKIT_API
Vector4
operator
/(
float
S,
const
Vector4& V)
noexcept
;
//
------------------------------------------------------------------------------
//
4x4 Matrix (assumes right-handed cooordinates)
struct
DIRECTX_TOOLKIT_API
Matrix : public
XMFLOAT4X4
{
Matrix
()
noexcept
:
XMFLOAT4X4
(
1
.f,
0
,
0
,
0
,
0
,
1
.f,
0
,
0
,
0
,
0
,
1
.f,
0
,
0
,
0
,
0
,
1
.f)
{}
constexpr
Matrix
(
float
m00,
float
m01,
float
m02,
float
m03,
float
m10,
float
m11,
float
m12,
float
m13,
float
m20,
float
m21,
float
m22,
float
m23,
float
m30,
float
m31,
float
m32,
float
m33)
noexcept
: XMFLOAT4X4(m00, m01, m02, m03, m10, m11, m12, m13, m20, m21, m22, m23, m30, m31, m32, m33)
{}
explicit
Matrix
(
const
Vector3& r0,
const
Vector3& r1,
const
Vector3& r2)
noexcept
: XMFLOAT4X4(r0.x, r0.y, r0.z,
0
, r1.x, r1.y, r1.z,
0
, r2.x, r2.y, r2.z,
0
,
0
,
0
,
0
,
1
.f)
{}
explicit
Matrix
(
const
Vector4& r0,
const
Vector4& r1,
const
Vector4& r2,
const
Vector4& r3)
noexcept
: XMFLOAT4X4(r0.x, r0.y, r0.z, r0.w, r1.x, r1.y, r1.z, r1.w, r2.x, r2.y, r2.z, r2.w, r3.x, r3.y, r3.z, r3.w)
{}
Matrix
(
const
XMFLOAT4X4
& M)
noexcept
{
memcpy
(
this
, &M,
sizeof
(
XMFLOAT4X4
)); }
Matrix
(
const
XMFLOAT3X3
& M)
noexcept
;
Matrix
(
const
XMFLOAT4X3
& M)
noexcept
;
explicit
Matrix
(_In_reads_(
16
)
const
float* pArray)
noexcept
: XMFLOAT4X4(pArray)
{}
Matrix
(
CXMMATRIX
M)
noexcept
{
XMStoreFloat4x4
(
this
, M); }
Matrix
(
const
Matrix&) =
default
;
Matrix&
operator
=(
const
Matrix&) =
default
;
Matrix
(Matrix&&) =
default
;
Matrix&
operator
=(Matrix&&) =
default
;
operator
XMMATRIX
()
const
noexcept
{
return
XMLoadFloat4x4
(
this
); }
//
Comparison operators
bool
operator
==(
const
Matrix& M)
const
noexcept
;
bool
operator
!=(
const
Matrix& M)
const
noexcept
;
//
Assignment operators
Matrix&
operator
=(
const
XMFLOAT3X3
& M)
noexcept
;
Matrix&
operator
=(
const
XMFLOAT4X3
& M)
noexcept
;
Matrix&
operator
+=(
const
Matrix& M)
noexcept
;
Matrix&
operator
-=(
const
Matrix& M)
noexcept
;
Matrix&
operator
*=(
const
Matrix& M)
noexcept
;
Matrix&
operator
*=(
float
S)
noexcept
;
Matrix&
operator
/=(
float
S)
noexcept
;
Matrix&
operator
/=(
const
Matrix& M)
noexcept
;
//
Element-wise divide
//
Unary operators
Matrix
operator
+()
const
noexcept
{
return
*
this
; }
Matrix
operator
-()
const
noexcept
;
//
Properties
Vector3
Up
()
const
noexcept
{
return
Vector3
(_21, _22, _23); }
void
Up
(
const
Vector3& v)
noexcept
{
_21 = v.
x
;
_22 = v.
y
;
_23 = v.
z
;
}
Vector3
Down
()
const
noexcept
{
return
Vector3
(-_21, -_22, -_23); }
void
Down
(
const
Vector3& v)
noexcept
{
_21 = -v.
x
;
_22 = -v.
y
;
_23 = -v.
z
;
}
Vector3
Right
()
const
noexcept
{
return
Vector3
(_11, _12, _13); }
void
Right
(
const
Vector3& v)
noexcept
{
_11 = v.
x
;
_12 = v.
y
;
_13 = v.
z
;
}
Vector3
Left
()
const
noexcept
{
return
Vector3
(-_11, -_12, -_13); }
void
Left
(
const
Vector3& v)
noexcept
{
_11 = -v.
x
;
_12 = -v.
y
;
_13 = -v.
z
;
}
Vector3
Forward
()
const
noexcept
{
return
Vector3
(-_31, -_32, -_33); }
void
Forward
(
const
Vector3& v)
noexcept
{
_31 = -v.
x
;
_32 = -v.
y
;
_33 = -v.
z
;
}
Vector3
Backward
()
const
noexcept
{
return
Vector3
(_31, _32, _33); }
void
Backward
(
const
Vector3& v)
noexcept
{
_31 = v.
x
;
_32 = v.
y
;
_33 = v.
z
;
}
Vector3
Translation
()
const
noexcept
{
return
Vector3
(_41, _42, _43); }
void
Translation
(
const
Vector3& v)
noexcept
{
_41 = v.
x
;
_42 = v.
y
;
_43 = v.
z
;
}
//
Matrix operations
bool
Decompose
(Vector3& scale, Quaternion& rotation, Vector3& translation)
noexcept
;
Matrix
Transpose
()
const
noexcept
;
void
Transpose
(Matrix& result)
const
noexcept
;
Matrix
Invert
()
const
noexcept
;
void
Invert
(Matrix& result)
const
noexcept
;
float
Determinant
()
const
noexcept
;
//
Computes rotation about y-axis (y), then x-axis (x), then z-axis (z)
Vector3
ToEuler
()
const
noexcept
;
//
Static functions
static
Matrix
CreateBillboard
(
const
Vector3& object,
const
Vector3& cameraPosition,
const
Vector3& cameraUp,
_In_opt_
const
Vector3* cameraForward =
nullptr
)
noexcept
;
static
Matrix
CreateConstrainedBillboard
(
const
Vector3& object,
const
Vector3& cameraPosition,
const
Vector3& rotateAxis,
_In_opt_
const
Vector3* cameraForward =
nullptr
,
_In_opt_
const
Vector3* objectForward =
nullptr
)
noexcept
;
static
Matrix
CreateTranslation
(
const
Vector3& position)
noexcept
;
static
Matrix
CreateTranslation
(
float
x,
float
y,
float
z)
noexcept
;
static
Matrix
CreateScale
(
const
Vector3& scales)
noexcept
;
static
Matrix
CreateScale
(
float
xs,
float
ys,
float
zs)
noexcept
;
static
Matrix
CreateScale
(
float
scale)
noexcept
;
static
Matrix
CreateRotationX
(
float
radians)
noexcept
;
static
Matrix
CreateRotationY
(
float
radians)
noexcept
;
static
Matrix
CreateRotationZ
(
float
radians)
noexcept
;
static
Matrix
CreateFromAxisAngle
(
const
Vector3& axis,
float
angle)
noexcept
;
static
Matrix
CreatePerspectiveFieldOfView
(
float
fov,
float
aspectRatio,
float
nearPlane,
float
farPlane)
noexcept
;
static
Matrix
CreatePerspective
(
float
width,
float
height,
float
nearPlane,
float
farPlane)
noexcept
;
static
Matrix
CreatePerspectiveOffCenter
(
float
left,
float
right,
float
bottom,
float
top,
float
nearPlane,
float
farPlane)
noexcept
;
static
Matrix
CreateOrthographic
(
float
width,
float
height,
float
zNearPlane,
float
zFarPlane)
noexcept
;
static
Matrix
CreateOrthographicOffCenter
(
float
left,
float
right,
float
bottom,
float
top,
float
zNearPlane,
float
zFarPlane)
noexcept
;
static
Matrix
CreateLookAt
(
const
Vector3& position,
const
Vector3& target,
const
Vector3& up)
noexcept
;
static
Matrix
CreateWorld
(
const
Vector3& position,
const
Vector3& forward,
const
Vector3& up)
noexcept
;
static
Matrix
CreateFromQuaternion
(
const
Quaternion& quat)
noexcept
;
//
Rotates about y-axis (yaw), then x-axis (pitch), then z-axis (roll)
static
Matrix
CreateFromYawPitchRoll
(
float
yaw,
float
pitch,
float
roll)
noexcept
;
//
Rotates about y-axis (angles.y), then x-axis (angles.x), then z-axis (angles.z)
static
Matrix
CreateFromYawPitchRoll
(
const
Vector3& angles)
noexcept
;
static
Matrix
CreateShadow
(
const
Vector3& lightDir,
const
Plane& plane)
noexcept
;
static
Matrix
CreateReflection
(
const
Plane& plane)
noexcept
;
static
void
Lerp
(
const
Matrix&
M1
,
const
Matrix&
M2
,
float
t, Matrix& result)
noexcept
;
static
Matrix
Lerp
(
const
Matrix&
M1
,
const
Matrix&
M2
,
float
t)
noexcept
;
static
void
Transform
(
const
Matrix& M,
const
Quaternion& rotation, Matrix& result)
noexcept
;
static
Matrix
Transform
(
const
Matrix& M,
const
Quaternion& rotation)
noexcept
;
//
Constants
static
const
Matrix Identity;
};
//
Binary operators
DIRECTX_TOOLKIT_API
Matrix
operator
+(
const
Matrix&
M1
,
const
Matrix&
M2
)
noexcept
;
DIRECTX_TOOLKIT_API
Matrix
operator
-(
const
Matrix&
M1
,
const
Matrix&
M2
)
noexcept
;
DIRECTX_TOOLKIT_API
Matrix
operator
*(
const
Matrix&
M1
,
const
Matrix&
M2
)
noexcept
;
DIRECTX_TOOLKIT_API
Matrix
operator
*(
const
Matrix& M,
float
S)
noexcept
;
DIRECTX_TOOLKIT_API
Matrix
operator
*(
float
S,
const
Matrix& M)
noexcept
;
DIRECTX_TOOLKIT_API
Matrix
operator
/(
const
Matrix& M,
float
S)
noexcept
;
DIRECTX_TOOLKIT_API
Matrix
operator
/(
const
Matrix&
M1
,
const
Matrix&
M2
)
noexcept
;
//
Element-wise divide
DIRECTX_TOOLKIT_API
Matrix
operator
/(
float
S,
const
Matrix& M)
noexcept
;
//
-----------------------------------------------------------------------------
//
Plane
struct
DIRECTX_TOOLKIT_API
Plane : public
XMFLOAT4
{
Plane
()
noexcept
:
XMFLOAT4
(
0
.f,
1
.f,
0
.f,
0
.f)
{}
constexpr
Plane
(
float
ix,
float
iy,
float
iz,
float
iw)
noexcept
: XMFLOAT4(ix, iy, iz, iw)
{}
Plane
(
const
Vector3& normal,
float
d)
noexcept
:
XMFLOAT4
(normal.x, normal.y, normal.z, d)
{}
Plane
(
const
Vector3& point1,
const
Vector3& point2,
const
Vector3& point3)
noexcept
;
Plane
(
const
Vector3& point,
const
Vector3& normal)
noexcept
;
explicit
Plane
(
const
Vector4& v)
noexcept
: XMFLOAT4(v.x, v.y, v.z, v.w)
{}
explicit
Plane
(_In_reads_(
4
)
const
float* pArray)
noexcept
: XMFLOAT4(pArray)
{}
Plane
(
FXMVECTOR
V)
noexcept
{
XMStoreFloat4
(
this
, V); }
Plane
(
const
XMFLOAT4
& p)
noexcept
{
this
->
x
= p.
x
;
this
->
y
= p.
y
;
this
->
z
= p.
z
;
this
->
w
= p.
w
;
}
explicit
Plane
(
const
XMVECTORF32
& F)
noexcept
{
this
->
x
= F.
f
[
0
];
this
->
y
= F.
f
[
1
];
this
->
z
= F.
f
[
2
];
this
->
w
= F.
f
[
3
];
View remainder of file in raw view
Back
|
FazBrowse Home
|
New Git URL