-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathla.h
2878 lines (2549 loc) · 48.1 KB
/
la.h
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
#ifndef LA_H_
#define LA_H_
#include <math.h>
#ifndef LADEF
#define LADEF static inline
#endif // LADEF
LADEF float lerpf(float a, float b, float t);
LADEF double lerp(double a, double b, double t);
LADEF int mini(int a, int b);
LADEF int maxi(int a, int b);
LADEF unsigned int minu(unsigned int a, unsigned int b);
LADEF unsigned int maxu(unsigned int a, unsigned int b);
LADEF float clampf(float x, float a, float b);
LADEF double clampd(double x, double a, double b);
LADEF int clampi(int x, int a, int b);
LADEF unsigned int clampu(unsigned int x, unsigned int a, unsigned int b);
typedef struct { float x, y; } V2f;
typedef struct { double x, y; } V2d;
typedef struct { int x, y; } V2i;
typedef struct { unsigned int x, y; } V2u;
typedef struct { float x, y, z; } V3f;
typedef struct { double x, y, z; } V3d;
typedef struct { int x, y, z; } V3i;
typedef struct { unsigned int x, y, z; } V3u;
typedef struct { float x, y, z, w; } V4f;
typedef struct { double x, y, z, w; } V4d;
typedef struct { int x, y, z, w; } V4i;
typedef struct { unsigned int x, y, z, w; } V4u;
#define V2f_Fmt "v2f(%f, %f)"
#define V2f_Arg(v) (v).x, (v).y
LADEF V2f v2f(float x, float y);
LADEF V2f v2ff(float x);
LADEF V2f v2f2d(V2d a);
LADEF V2f v2f2i(V2i a);
LADEF V2f v2f2u(V2u a);
LADEF V2f v2f3f(V3f a);
LADEF V2f v2f3d(V3d a);
LADEF V2f v2f3i(V3i a);
LADEF V2f v2f3u(V3u a);
LADEF V2f v2f4f(V4f a);
LADEF V2f v2f4d(V4d a);
LADEF V2f v2f4i(V4i a);
LADEF V2f v2f4u(V4u a);
LADEF V2f v2f_sum(V2f a, V2f b);
LADEF V2f v2f_sub(V2f a, V2f b);
LADEF V2f v2f_mul(V2f a, V2f b);
LADEF V2f v2f_div(V2f a, V2f b);
LADEF V2f v2f_sqrt(V2f a);
LADEF V2f v2f_pow(V2f base, V2f exp);
LADEF V2f v2f_sin(V2f a);
LADEF V2f v2f_cos(V2f a);
LADEF V2f v2f_min(V2f a, V2f b);
LADEF V2f v2f_max(V2f a, V2f b);
LADEF V2f v2f_lerp(V2f a, V2f b, V2f t);
LADEF V2f v2f_floor(V2f a);
LADEF V2f v2f_ceil(V2f a);
LADEF V2f v2f_clamp(V2f x, V2f a, V2f b);
LADEF float v2f_sqrlen(V2f a);
LADEF float v2f_len(V2f a);
#define V2d_Fmt "v2d(%lf, %lf)"
#define V2d_Arg(v) (v).x, (v).y
LADEF V2d v2d(double x, double y);
LADEF V2d v2dd(double x);
LADEF V2d v2d2f(V2f a);
LADEF V2d v2d2i(V2i a);
LADEF V2d v2d2u(V2u a);
LADEF V2d v2d3f(V3f a);
LADEF V2d v2d3d(V3d a);
LADEF V2d v2d3i(V3i a);
LADEF V2d v2d3u(V3u a);
LADEF V2d v2d4f(V4f a);
LADEF V2d v2d4d(V4d a);
LADEF V2d v2d4i(V4i a);
LADEF V2d v2d4u(V4u a);
LADEF V2d v2d_sum(V2d a, V2d b);
LADEF V2d v2d_sub(V2d a, V2d b);
LADEF V2d v2d_mul(V2d a, V2d b);
LADEF V2d v2d_div(V2d a, V2d b);
LADEF V2d v2d_sqrt(V2d a);
LADEF V2d v2d_pow(V2d base, V2d exp);
LADEF V2d v2d_sin(V2d a);
LADEF V2d v2d_cos(V2d a);
LADEF V2d v2d_min(V2d a, V2d b);
LADEF V2d v2d_max(V2d a, V2d b);
LADEF V2d v2d_lerp(V2d a, V2d b, V2d t);
LADEF V2d v2d_floor(V2d a);
LADEF V2d v2d_ceil(V2d a);
LADEF V2d v2d_clamp(V2d x, V2d a, V2d b);
LADEF double v2d_sqrlen(V2d a);
LADEF double v2d_len(V2d a);
#define V2i_Fmt "v2i(%d, %d)"
#define V2i_Arg(v) (v).x, (v).y
LADEF V2i v2i(int x, int y);
LADEF V2i v2ii(int x);
LADEF V2i v2i2f(V2f a);
LADEF V2i v2i2d(V2d a);
LADEF V2i v2i2u(V2u a);
LADEF V2i v2i3f(V3f a);
LADEF V2i v2i3d(V3d a);
LADEF V2i v2i3i(V3i a);
LADEF V2i v2i3u(V3u a);
LADEF V2i v2i4f(V4f a);
LADEF V2i v2i4d(V4d a);
LADEF V2i v2i4i(V4i a);
LADEF V2i v2i4u(V4u a);
LADEF V2i v2i_sum(V2i a, V2i b);
LADEF V2i v2i_sub(V2i a, V2i b);
LADEF V2i v2i_mul(V2i a, V2i b);
LADEF V2i v2i_div(V2i a, V2i b);
LADEF V2i v2i_min(V2i a, V2i b);
LADEF V2i v2i_max(V2i a, V2i b);
LADEF V2i v2i_clamp(V2i x, V2i a, V2i b);
LADEF int v2i_sqrlen(V2i a);
#define V2u_Fmt "v2u(%u, %u)"
#define V2u_Arg(v) (v).x, (v).y
LADEF V2u v2u(unsigned int x, unsigned int y);
LADEF V2u v2uu(unsigned int x);
LADEF V2u v2u2f(V2f a);
LADEF V2u v2u2d(V2d a);
LADEF V2u v2u2i(V2i a);
LADEF V2u v2u3f(V3f a);
LADEF V2u v2u3d(V3d a);
LADEF V2u v2u3i(V3i a);
LADEF V2u v2u3u(V3u a);
LADEF V2u v2u4f(V4f a);
LADEF V2u v2u4d(V4d a);
LADEF V2u v2u4i(V4i a);
LADEF V2u v2u4u(V4u a);
LADEF V2u v2u_sum(V2u a, V2u b);
LADEF V2u v2u_sub(V2u a, V2u b);
LADEF V2u v2u_mul(V2u a, V2u b);
LADEF V2u v2u_div(V2u a, V2u b);
LADEF V2u v2u_min(V2u a, V2u b);
LADEF V2u v2u_max(V2u a, V2u b);
LADEF V2u v2u_clamp(V2u x, V2u a, V2u b);
LADEF unsigned int v2u_sqrlen(V2u a);
#define V3f_Fmt "v3f(%f, %f, %f)"
#define V3f_Arg(v) (v).x, (v).y, (v).z
LADEF V3f v3f(float x, float y, float z);
LADEF V3f v3ff(float x);
LADEF V3f v3f2f(V2f a);
LADEF V3f v3f2d(V2d a);
LADEF V3f v3f2i(V2i a);
LADEF V3f v3f2u(V2u a);
LADEF V3f v3f3d(V3d a);
LADEF V3f v3f3i(V3i a);
LADEF V3f v3f3u(V3u a);
LADEF V3f v3f4f(V4f a);
LADEF V3f v3f4d(V4d a);
LADEF V3f v3f4i(V4i a);
LADEF V3f v3f4u(V4u a);
LADEF V3f v3f_sum(V3f a, V3f b);
LADEF V3f v3f_sub(V3f a, V3f b);
LADEF V3f v3f_mul(V3f a, V3f b);
LADEF V3f v3f_div(V3f a, V3f b);
LADEF V3f v3f_sqrt(V3f a);
LADEF V3f v3f_pow(V3f base, V3f exp);
LADEF V3f v3f_sin(V3f a);
LADEF V3f v3f_cos(V3f a);
LADEF V3f v3f_min(V3f a, V3f b);
LADEF V3f v3f_max(V3f a, V3f b);
LADEF V3f v3f_lerp(V3f a, V3f b, V3f t);
LADEF V3f v3f_floor(V3f a);
LADEF V3f v3f_ceil(V3f a);
LADEF V3f v3f_clamp(V3f x, V3f a, V3f b);
LADEF float v3f_sqrlen(V3f a);
LADEF float v3f_len(V3f a);
#define V3d_Fmt "v3d(%lf, %lf, %lf)"
#define V3d_Arg(v) (v).x, (v).y, (v).z
LADEF V3d v3d(double x, double y, double z);
LADEF V3d v3dd(double x);
LADEF V3d v3d2f(V2f a);
LADEF V3d v3d2d(V2d a);
LADEF V3d v3d2i(V2i a);
LADEF V3d v3d2u(V2u a);
LADEF V3d v3d3f(V3f a);
LADEF V3d v3d3i(V3i a);
LADEF V3d v3d3u(V3u a);
LADEF V3d v3d4f(V4f a);
LADEF V3d v3d4d(V4d a);
LADEF V3d v3d4i(V4i a);
LADEF V3d v3d4u(V4u a);
LADEF V3d v3d_sum(V3d a, V3d b);
LADEF V3d v3d_sub(V3d a, V3d b);
LADEF V3d v3d_mul(V3d a, V3d b);
LADEF V3d v3d_div(V3d a, V3d b);
LADEF V3d v3d_sqrt(V3d a);
LADEF V3d v3d_pow(V3d base, V3d exp);
LADEF V3d v3d_sin(V3d a);
LADEF V3d v3d_cos(V3d a);
LADEF V3d v3d_min(V3d a, V3d b);
LADEF V3d v3d_max(V3d a, V3d b);
LADEF V3d v3d_lerp(V3d a, V3d b, V3d t);
LADEF V3d v3d_floor(V3d a);
LADEF V3d v3d_ceil(V3d a);
LADEF V3d v3d_clamp(V3d x, V3d a, V3d b);
LADEF double v3d_sqrlen(V3d a);
LADEF double v3d_len(V3d a);
#define V3i_Fmt "v3i(%d, %d, %d)"
#define V3i_Arg(v) (v).x, (v).y, (v).z
LADEF V3i v3i(int x, int y, int z);
LADEF V3i v3ii(int x);
LADEF V3i v3i2f(V2f a);
LADEF V3i v3i2d(V2d a);
LADEF V3i v3i2i(V2i a);
LADEF V3i v3i2u(V2u a);
LADEF V3i v3i3f(V3f a);
LADEF V3i v3i3d(V3d a);
LADEF V3i v3i3u(V3u a);
LADEF V3i v3i4f(V4f a);
LADEF V3i v3i4d(V4d a);
LADEF V3i v3i4i(V4i a);
LADEF V3i v3i4u(V4u a);
LADEF V3i v3i_sum(V3i a, V3i b);
LADEF V3i v3i_sub(V3i a, V3i b);
LADEF V3i v3i_mul(V3i a, V3i b);
LADEF V3i v3i_div(V3i a, V3i b);
LADEF V3i v3i_min(V3i a, V3i b);
LADEF V3i v3i_max(V3i a, V3i b);
LADEF V3i v3i_clamp(V3i x, V3i a, V3i b);
LADEF int v3i_sqrlen(V3i a);
#define V3u_Fmt "v3u(%u, %u, %u)"
#define V3u_Arg(v) (v).x, (v).y, (v).z
LADEF V3u v3u(unsigned int x, unsigned int y, unsigned int z);
LADEF V3u v3uu(unsigned int x);
LADEF V3u v3u2f(V2f a);
LADEF V3u v3u2d(V2d a);
LADEF V3u v3u2i(V2i a);
LADEF V3u v3u2u(V2u a);
LADEF V3u v3u3f(V3f a);
LADEF V3u v3u3d(V3d a);
LADEF V3u v3u3i(V3i a);
LADEF V3u v3u4f(V4f a);
LADEF V3u v3u4d(V4d a);
LADEF V3u v3u4i(V4i a);
LADEF V3u v3u4u(V4u a);
LADEF V3u v3u_sum(V3u a, V3u b);
LADEF V3u v3u_sub(V3u a, V3u b);
LADEF V3u v3u_mul(V3u a, V3u b);
LADEF V3u v3u_div(V3u a, V3u b);
LADEF V3u v3u_min(V3u a, V3u b);
LADEF V3u v3u_max(V3u a, V3u b);
LADEF V3u v3u_clamp(V3u x, V3u a, V3u b);
LADEF unsigned int v3u_sqrlen(V3u a);
#define V4f_Fmt "v4f(%f, %f, %f, %f)"
#define V4f_Arg(v) (v).x, (v).y, (v).z, (v).w
LADEF V4f v4f(float x, float y, float z, float w);
LADEF V4f v4ff(float x);
LADEF V4f v4f2f(V2f a);
LADEF V4f v4f2d(V2d a);
LADEF V4f v4f2i(V2i a);
LADEF V4f v4f2u(V2u a);
LADEF V4f v4f3f(V3f a);
LADEF V4f v4f3d(V3d a);
LADEF V4f v4f3i(V3i a);
LADEF V4f v4f3u(V3u a);
LADEF V4f v4f4d(V4d a);
LADEF V4f v4f4i(V4i a);
LADEF V4f v4f4u(V4u a);
LADEF V4f v4f_sum(V4f a, V4f b);
LADEF V4f v4f_sub(V4f a, V4f b);
LADEF V4f v4f_mul(V4f a, V4f b);
LADEF V4f v4f_div(V4f a, V4f b);
LADEF V4f v4f_sqrt(V4f a);
LADEF V4f v4f_pow(V4f base, V4f exp);
LADEF V4f v4f_sin(V4f a);
LADEF V4f v4f_cos(V4f a);
LADEF V4f v4f_min(V4f a, V4f b);
LADEF V4f v4f_max(V4f a, V4f b);
LADEF V4f v4f_lerp(V4f a, V4f b, V4f t);
LADEF V4f v4f_floor(V4f a);
LADEF V4f v4f_ceil(V4f a);
LADEF V4f v4f_clamp(V4f x, V4f a, V4f b);
LADEF float v4f_sqrlen(V4f a);
LADEF float v4f_len(V4f a);
#define V4d_Fmt "v4d(%lf, %lf, %lf, %lf)"
#define V4d_Arg(v) (v).x, (v).y, (v).z, (v).w
LADEF V4d v4d(double x, double y, double z, double w);
LADEF V4d v4dd(double x);
LADEF V4d v4d2f(V2f a);
LADEF V4d v4d2d(V2d a);
LADEF V4d v4d2i(V2i a);
LADEF V4d v4d2u(V2u a);
LADEF V4d v4d3f(V3f a);
LADEF V4d v4d3d(V3d a);
LADEF V4d v4d3i(V3i a);
LADEF V4d v4d3u(V3u a);
LADEF V4d v4d4f(V4f a);
LADEF V4d v4d4i(V4i a);
LADEF V4d v4d4u(V4u a);
LADEF V4d v4d_sum(V4d a, V4d b);
LADEF V4d v4d_sub(V4d a, V4d b);
LADEF V4d v4d_mul(V4d a, V4d b);
LADEF V4d v4d_div(V4d a, V4d b);
LADEF V4d v4d_sqrt(V4d a);
LADEF V4d v4d_pow(V4d base, V4d exp);
LADEF V4d v4d_sin(V4d a);
LADEF V4d v4d_cos(V4d a);
LADEF V4d v4d_min(V4d a, V4d b);
LADEF V4d v4d_max(V4d a, V4d b);
LADEF V4d v4d_lerp(V4d a, V4d b, V4d t);
LADEF V4d v4d_floor(V4d a);
LADEF V4d v4d_ceil(V4d a);
LADEF V4d v4d_clamp(V4d x, V4d a, V4d b);
LADEF double v4d_sqrlen(V4d a);
LADEF double v4d_len(V4d a);
#define V4i_Fmt "v4i(%d, %d, %d, %d)"
#define V4i_Arg(v) (v).x, (v).y, (v).z, (v).w
LADEF V4i v4i(int x, int y, int z, int w);
LADEF V4i v4ii(int x);
LADEF V4i v4i2f(V2f a);
LADEF V4i v4i2d(V2d a);
LADEF V4i v4i2i(V2i a);
LADEF V4i v4i2u(V2u a);
LADEF V4i v4i3f(V3f a);
LADEF V4i v4i3d(V3d a);
LADEF V4i v4i3i(V3i a);
LADEF V4i v4i3u(V3u a);
LADEF V4i v4i4f(V4f a);
LADEF V4i v4i4d(V4d a);
LADEF V4i v4i4u(V4u a);
LADEF V4i v4i_sum(V4i a, V4i b);
LADEF V4i v4i_sub(V4i a, V4i b);
LADEF V4i v4i_mul(V4i a, V4i b);
LADEF V4i v4i_div(V4i a, V4i b);
LADEF V4i v4i_min(V4i a, V4i b);
LADEF V4i v4i_max(V4i a, V4i b);
LADEF V4i v4i_clamp(V4i x, V4i a, V4i b);
LADEF int v4i_sqrlen(V4i a);
#define V4u_Fmt "v4u(%u, %u, %u, %u)"
#define V4u_Arg(v) (v).x, (v).y, (v).z, (v).w
LADEF V4u v4u(unsigned int x, unsigned int y, unsigned int z, unsigned int w);
LADEF V4u v4uu(unsigned int x);
LADEF V4u v4u2f(V2f a);
LADEF V4u v4u2d(V2d a);
LADEF V4u v4u2i(V2i a);
LADEF V4u v4u2u(V2u a);
LADEF V4u v4u3f(V3f a);
LADEF V4u v4u3d(V3d a);
LADEF V4u v4u3i(V3i a);
LADEF V4u v4u3u(V3u a);
LADEF V4u v4u4f(V4f a);
LADEF V4u v4u4d(V4d a);
LADEF V4u v4u4i(V4i a);
LADEF V4u v4u_sum(V4u a, V4u b);
LADEF V4u v4u_sub(V4u a, V4u b);
LADEF V4u v4u_mul(V4u a, V4u b);
LADEF V4u v4u_div(V4u a, V4u b);
LADEF V4u v4u_min(V4u a, V4u b);
LADEF V4u v4u_max(V4u a, V4u b);
LADEF V4u v4u_clamp(V4u x, V4u a, V4u b);
LADEF unsigned int v4u_sqrlen(V4u a);
#endif // LA_H_
#ifdef LA_IMPLEMENTATION
LADEF float lerpf(float a, float b, float t)
{
return a + (b - a) * t;
}
LADEF double lerp(double a, double b, double t)
{
return a + (b - a) * t;
}
LADEF int mini(int a, int b)
{
return a < b ? a : b;
}
LADEF int maxi(int a, int b)
{
return a < b ? b : a;
}
LADEF unsigned int minu(unsigned int a, unsigned int b)
{
return a < b ? a : b;
}
LADEF unsigned int maxu(unsigned int a, unsigned int b)
{
return a < b ? b : a;
}
LADEF float clampf(float x, float a, float b)
{
return fminf(fmaxf(a, x), b);
}
LADEF double clampd(double x, double a, double b)
{
return fmin(fmax(a, x), b);
}
LADEF int clampi(int x, int a, int b)
{
return mini(maxi(a, x), b);
}
LADEF unsigned int clampu(unsigned int x, unsigned int a, unsigned int b)
{
return minu(maxu(a, x), b);
}
LADEF V2f v2f(float x, float y)
{
V2f v;
v.x = x;
v.y = y;
return v;
}
LADEF V2f v2ff(float x)
{
return v2f(x, x);
}
LADEF V2f v2f2d(V2d a)
{
V2f result;
result.x = (float) a.x;
result.y = (float) a.y;
return result;
}
LADEF V2f v2f2i(V2i a)
{
V2f result;
result.x = (float) a.x;
result.y = (float) a.y;
return result;
}
LADEF V2f v2f2u(V2u a)
{
V2f result;
result.x = (float) a.x;
result.y = (float) a.y;
return result;
}
LADEF V2f v2f3f(V3f a)
{
V2f result;
result.x = (float) a.x;
result.y = (float) a.y;
return result;
}
LADEF V2f v2f3d(V3d a)
{
V2f result;
result.x = (float) a.x;
result.y = (float) a.y;
return result;
}
LADEF V2f v2f3i(V3i a)
{
V2f result;
result.x = (float) a.x;
result.y = (float) a.y;
return result;
}
LADEF V2f v2f3u(V3u a)
{
V2f result;
result.x = (float) a.x;
result.y = (float) a.y;
return result;
}
LADEF V2f v2f4f(V4f a)
{
V2f result;
result.x = (float) a.x;
result.y = (float) a.y;
return result;
}
LADEF V2f v2f4d(V4d a)
{
V2f result;
result.x = (float) a.x;
result.y = (float) a.y;
return result;
}
LADEF V2f v2f4i(V4i a)
{
V2f result;
result.x = (float) a.x;
result.y = (float) a.y;
return result;
}
LADEF V2f v2f4u(V4u a)
{
V2f result;
result.x = (float) a.x;
result.y = (float) a.y;
return result;
}
LADEF V2f v2f_sum(V2f a, V2f b)
{
a.x += b.x;
a.y += b.y;
return a;
}
LADEF V2f v2f_sub(V2f a, V2f b)
{
a.x -= b.x;
a.y -= b.y;
return a;
}
LADEF V2f v2f_mul(V2f a, V2f b)
{
a.x *= b.x;
a.y *= b.y;
return a;
}
LADEF V2f v2f_div(V2f a, V2f b)
{
a.x /= b.x;
a.y /= b.y;
return a;
}
LADEF V2f v2f_sqrt(V2f a)
{
a.x = sqrtf(a.x);
a.y = sqrtf(a.y);
return a;
}
LADEF V2f v2f_pow(V2f base, V2f exp)
{
base.x = powf(base.x, exp.x);
base.y = powf(base.y, exp.y);
return base;
}
LADEF V2f v2f_sin(V2f a)
{
a.x = sinf(a.x);
a.y = sinf(a.y);
return a;
}
LADEF V2f v2f_cos(V2f a)
{
a.x = cosf(a.x);
a.y = cosf(a.y);
return a;
}
LADEF V2f v2f_min(V2f a, V2f b)
{
a.x = fminf(a.x, b.x);
a.y = fminf(a.y, b.y);
return a;
}
LADEF V2f v2f_max(V2f a, V2f b)
{
a.x = fmaxf(a.x, b.x);
a.y = fmaxf(a.y, b.y);
return a;
}
LADEF V2f v2f_lerp(V2f a, V2f b, V2f t)
{
a.x = lerpf(a.x, b.x, t.x);
a.y = lerpf(a.y, b.y, t.y);
return a;
}
LADEF V2f v2f_floor(V2f a)
{
a.x = floorf(a.x);
a.y = floorf(a.y);
return a;
}
LADEF V2f v2f_ceil(V2f a)
{
a.x = ceilf(a.x);
a.y = ceilf(a.y);
return a;
}
LADEF V2f v2f_clamp(V2f x, V2f a, V2f b)
{
x.x = clampf(x.x, a.x, b.x);
x.y = clampf(x.y, a.y, b.y);
return x;
}
LADEF float v2f_sqrlen(V2f a)
{
return a.x*a.x + a.y*a.y;
}
LADEF float v2f_len(V2f a)
{
return sqrtf(v2f_sqrlen(a));
}
LADEF V2d v2d(double x, double y)
{
V2d v;
v.x = x;
v.y = y;
return v;
}
LADEF V2d v2dd(double x)
{
return v2d(x, x);
}
LADEF V2d v2d2f(V2f a)
{
V2d result;
result.x = (double) a.x;
result.y = (double) a.y;
return result;
}
LADEF V2d v2d2i(V2i a)
{
V2d result;
result.x = (double) a.x;
result.y = (double) a.y;
return result;
}
LADEF V2d v2d2u(V2u a)
{
V2d result;
result.x = (double) a.x;
result.y = (double) a.y;
return result;
}
LADEF V2d v2d3f(V3f a)
{
V2d result;
result.x = (double) a.x;
result.y = (double) a.y;
return result;
}
LADEF V2d v2d3d(V3d a)
{
V2d result;
result.x = (double) a.x;
result.y = (double) a.y;
return result;
}
LADEF V2d v2d3i(V3i a)
{
V2d result;
result.x = (double) a.x;
result.y = (double) a.y;
return result;
}
LADEF V2d v2d3u(V3u a)
{
V2d result;
result.x = (double) a.x;
result.y = (double) a.y;
return result;
}
LADEF V2d v2d4f(V4f a)
{
V2d result;
result.x = (double) a.x;
result.y = (double) a.y;
return result;
}
LADEF V2d v2d4d(V4d a)
{
V2d result;
result.x = (double) a.x;
result.y = (double) a.y;
return result;
}
LADEF V2d v2d4i(V4i a)
{
V2d result;
result.x = (double) a.x;
result.y = (double) a.y;
return result;
}
LADEF V2d v2d4u(V4u a)
{
V2d result;
result.x = (double) a.x;
result.y = (double) a.y;
return result;
}
LADEF V2d v2d_sum(V2d a, V2d b)
{
a.x += b.x;
a.y += b.y;
return a;
}
LADEF V2d v2d_sub(V2d a, V2d b)
{
a.x -= b.x;
a.y -= b.y;
return a;
}
LADEF V2d v2d_mul(V2d a, V2d b)
{
a.x *= b.x;
a.y *= b.y;
return a;
}
LADEF V2d v2d_div(V2d a, V2d b)
{
a.x /= b.x;
a.y /= b.y;
return a;
}
LADEF V2d v2d_sqrt(V2d a)
{
a.x = sqrt(a.x);
a.y = sqrt(a.y);
return a;
}
LADEF V2d v2d_pow(V2d base, V2d exp)
{
base.x = pow(base.x, exp.x);
base.y = pow(base.y, exp.y);
return base;
}
LADEF V2d v2d_sin(V2d a)
{
a.x = sin(a.x);
a.y = sin(a.y);
return a;
}
LADEF V2d v2d_cos(V2d a)
{
a.x = cos(a.x);
a.y = cos(a.y);
return a;
}
LADEF V2d v2d_min(V2d a, V2d b)
{
a.x = fmin(a.x, b.x);
a.y = fmin(a.y, b.y);
return a;
}
LADEF V2d v2d_max(V2d a, V2d b)
{
a.x = fmax(a.x, b.x);
a.y = fmax(a.y, b.y);
return a;
}
LADEF V2d v2d_lerp(V2d a, V2d b, V2d t)
{
a.x = lerp(a.x, b.x, t.x);
a.y = lerp(a.y, b.y, t.y);
return a;
}
LADEF V2d v2d_floor(V2d a)
{
a.x = floor(a.x);
a.y = floor(a.y);
return a;
}
LADEF V2d v2d_ceil(V2d a)
{
a.x = ceil(a.x);
a.y = ceil(a.y);
return a;
}
LADEF V2d v2d_clamp(V2d x, V2d a, V2d b)
{
x.x = clampd(x.x, a.x, b.x);
x.y = clampd(x.y, a.y, b.y);
return x;
}
LADEF double v2d_sqrlen(V2d a)
{
return a.x*a.x + a.y*a.y;
}
LADEF double v2d_len(V2d a)
{
return sqrt(v2d_sqrlen(a));
}
LADEF V2i v2i(int x, int y)
{
V2i v;
v.x = x;
v.y = y;
return v;
}
LADEF V2i v2ii(int x)
{
return v2i(x, x);
}
LADEF V2i v2i2f(V2f a)
{
V2i result;
result.x = (int) a.x;
result.y = (int) a.y;
return result;
}
LADEF V2i v2i2d(V2d a)
{
V2i result;
result.x = (int) a.x;
result.y = (int) a.y;
return result;
}
LADEF V2i v2i2u(V2u a)
{
V2i result;
result.x = (int) a.x;
result.y = (int) a.y;
return result;
}
LADEF V2i v2i3f(V3f a)
{
V2i result;
result.x = (int) a.x;
result.y = (int) a.y;
return result;
}
LADEF V2i v2i3d(V3d a)
{
V2i result;
result.x = (int) a.x;
result.y = (int) a.y;
return result;
}
LADEF V2i v2i3i(V3i a)
{
V2i result;
result.x = (int) a.x;
result.y = (int) a.y;
return result;
}
LADEF V2i v2i3u(V3u a)
{
V2i result;
result.x = (int) a.x;
result.y = (int) a.y;
return result;
}
LADEF V2i v2i4f(V4f a)
{
V2i result;
result.x = (int) a.x;
result.y = (int) a.y;
return result;
}
LADEF V2i v2i4d(V4d a)
{
V2i result;
result.x = (int) a.x;
result.y = (int) a.y;
return result;
}
LADEF V2i v2i4i(V4i a)
{
V2i result;
result.x = (int) a.x;
result.y = (int) a.y;
return result;
}
LADEF V2i v2i4u(V4u a)
{
V2i result;
result.x = (int) a.x;
result.y = (int) a.y;
return result;
}
LADEF V2i v2i_sum(V2i a, V2i b)
{
a.x += b.x;
a.y += b.y;
return a;
}
LADEF V2i v2i_sub(V2i a, V2i b)
{
a.x -= b.x;
a.y -= b.y;
return a;
}
LADEF V2i v2i_mul(V2i a, V2i b)
{
a.x *= b.x;
a.y *= b.y;
return a;
}
LADEF V2i v2i_div(V2i a, V2i b)
{
a.x /= b.x;
a.y /= b.y;
return a;
}
LADEF V2i v2i_min(V2i a, V2i b)
{
a.x = mini(a.x, b.x);
a.y = mini(a.y, b.y);
return a;
}
LADEF V2i v2i_max(V2i a, V2i b)
{
a.x = maxi(a.x, b.x);
a.y = maxi(a.y, b.y);
return a;
}
LADEF V2i v2i_clamp(V2i x, V2i a, V2i b)
{
x.x = clampi(x.x, a.x, b.x);
x.y = clampi(x.y, a.y, b.y);
return x;
}
LADEF int v2i_sqrlen(V2i a)
{
return a.x*a.x + a.y*a.y;
}
LADEF V2u v2u(unsigned int x, unsigned int y)
{
V2u v;
v.x = x;