File: 3dmath.h

package info (click to toggle)
lsp-plugins 1.2.5-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 91,856 kB
  • sloc: cpp: 427,831; xml: 57,779; makefile: 9,961; php: 1,005; sh: 18
file content (1214 lines) | stat: -rw-r--r-- 45,080 bytes parent folder | download | duplicates (2)
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
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
/*
 * Copyright (C) 2020 Linux Studio Plugins Project <https://lsp-plug.in/>
 *           (C) 2020 Vladimir Sadovnikov <sadko4u@gmail.com>
 *
 * This file is part of lsp-dsp-lib
 * Created on: 31 мар. 2020 г.
 *
 * lsp-dsp-lib is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * any later version.
 *
 * lsp-dsp-lib is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with lsp-dsp-lib. If not, see <https://www.gnu.org/licenses/>.
 */

#ifndef LSP_PLUG_IN_DSP_COMMON_3DMATH_H_
#define LSP_PLUG_IN_DSP_COMMON_3DMATH_H_

#include <lsp-plug.in/dsp/common/types.h>
#include <lsp-plug.in/dsp/common/3dmath/types.h>

/** Init point using coordinates
 *
 * @param p point to initialize
 * @param x X coordinate
 * @param y Y coordinate
 * @param z Z coordinate
 */
LSP_DSP_LIB_SYMBOL(void, init_point_xyz, LSP_DSP_LIB_TYPE(point3d_t) *p, float x, float y, float z);

/** Init point using another point
 *
 * @param p point to initialize
 * @param s source point
 */
LSP_DSP_LIB_SYMBOL(void, init_point, LSP_DSP_LIB_TYPE(point3d_t) *p, const LSP_DSP_LIB_TYPE(point3d_t) *s);

/** Normalize point coordinates
 *
 * @param p point to normalize
 */
LSP_DSP_LIB_SYMBOL(void, normalize_point, LSP_DSP_LIB_TYPE(point3d_t) *p);

/** Normalize point coordinates to specified radius-vector length
 *
 * @param p point to scale
 * @param r radius-vector length
 */
LSP_DSP_LIB_SYMBOL(void, scale_point1, LSP_DSP_LIB_TYPE(point3d_t) *p, float r);

/** Scale point coordinates to match specified radius-vector length
 *
 * @param p point to store result
 * @param s point to scale
 * @param r radius-vector length
 */
LSP_DSP_LIB_SYMBOL(void, scale_point2, LSP_DSP_LIB_TYPE(point3d_t) *p, const LSP_DSP_LIB_TYPE(point3d_t) *s, float r);

/** Initialize vector
 *
 * @param v vector to initialize
 * @param dx delta coordinate X
 * @param dy delta coordinate Y
 * @param dz delta coordinate Y
 */
LSP_DSP_LIB_SYMBOL(void, init_vector_dxyz, LSP_DSP_LIB_TYPE(vector3d_t) *v, float dx, float dy, float dz);

/** Initialize vector
 *
 * @param v destination vector
 * @param s source vector
 */
LSP_DSP_LIB_SYMBOL(void, init_vector, LSP_DSP_LIB_TYPE(vector3d_t) *v, const LSP_DSP_LIB_TYPE(vector3d_t) *s);

/** Initialize vector
 *
 * @param v destination vector
 * @param p1 start point of vector
 * @param p2 end point of vector
 */
LSP_DSP_LIB_SYMBOL(void, init_vector_p2, LSP_DSP_LIB_TYPE(vector3d_t) *v, const LSP_DSP_LIB_TYPE(point3d_t) *p1, const LSP_DSP_LIB_TYPE(point3d_t) *p2);

/** Initialize vector
 *
 * @param v destination vector
 * @param pv array of two points
 */
LSP_DSP_LIB_SYMBOL(void, init_vector_pv, LSP_DSP_LIB_TYPE(vector3d_t) *v, const LSP_DSP_LIB_TYPE(point3d_t) *pv);

/** Initialize normal vector
 *
 * @param v vector to initialize
 * @param x1 point 1 x
 * @param y1 point 1 y
 * @param z1 point 1 z
 * @param x2 point 2 x
 * @param y2 point 2 y
 * @param z2 point 2 z
 */
LSP_DSP_LIB_SYMBOL(void, init_normal3d_xyz, LSP_DSP_LIB_TYPE(vector3d_t) *v, float x1, float y1, float z1, float x2, float y2, float z2);

/** Initialize normal vector
 *
 * @param v vector to initialize
 * @param dx delta coordinate X
 * @param dy delta coordinate Y
 * @param dz delta coordinate Y
 */
LSP_DSP_LIB_SYMBOL(void, init_normal3d_dxyz, LSP_DSP_LIB_TYPE(vector3d_t) *v, float dx, float dy, float dz);

/** Initialize normal vector
 *
 * @param p source vector
 * @param s destination vector
 */
LSP_DSP_LIB_SYMBOL(void, init_normal3d, LSP_DSP_LIB_TYPE(vector3d_t) *p, const LSP_DSP_LIB_TYPE(vector3d_t) *s);

/** Normalize vector
 *
 * @param v vector to normalize
 */
LSP_DSP_LIB_SYMBOL(void, normalize_vector, LSP_DSP_LIB_TYPE(vector3d_t) *m);

/** Normalize vector
 *
 * @param v vector to store normalized value
 * @param src source vector to normalize
 */
LSP_DSP_LIB_SYMBOL(void, normalize_vector2, LSP_DSP_LIB_TYPE(vector3d_t) *v, const LSP_DSP_LIB_TYPE(vector3d_t) *src);

/**
 * Flip vector coordinates
 * @param v vector to flip
 */
LSP_DSP_LIB_SYMBOL(void, flip_vector_v1, LSP_DSP_LIB_TYPE(vector3d_t) *v);

/**
 * Flip vector coordinates
 * @param v vector to store result
 * @param sv source vector
 */
LSP_DSP_LIB_SYMBOL(void, flip_vector_v2, LSP_DSP_LIB_TYPE(vector3d_t) *v, const LSP_DSP_LIB_TYPE(vector3d_t) *sv);

/** Scale vector coordinates to match specified radius-vector length
 *
 * @param v vector to scale
 * @param r radius-vector length
 */
LSP_DSP_LIB_SYMBOL(void, scale_vector1, LSP_DSP_LIB_TYPE(vector3d_t) *v, float r);

/** Scale vector coordinates to match specified radius-vector length
 *
 * @param v vector to store result
 * @param s vector to scale
 * @param r radius-vector length
 */
LSP_DSP_LIB_SYMBOL(void, scale_vector2, LSP_DSP_LIB_TYPE(vector3d_t) *v, const LSP_DSP_LIB_TYPE(vector3d_t) *s, float r);

/** Calculate vector multiplications
 *
 * @param r vector to store result
 * @param v1 vector 1
 * @param v2 vector 2
 */
LSP_DSP_LIB_SYMBOL(void, vector_mul_v2, LSP_DSP_LIB_TYPE(vector3d_t) *r, const LSP_DSP_LIB_TYPE(vector3d_t) *v1, const LSP_DSP_LIB_TYPE(vector3d_t) *v2);

/** Calculate vector multiplications
 *
 * @param r vector to store result
 * @param vv array of two vectors to multiply
 */
LSP_DSP_LIB_SYMBOL(void, vector_mul_vv, LSP_DSP_LIB_TYPE(vector3d_t) *r, const LSP_DSP_LIB_TYPE(vector3d_t) *vv);

/** Init segment using coordinates of 2 points
 *
 * @param s segment to initialize
 * @param x0 point 1 X coordinate
 * @param y0 point 1 Y coordinate
 * @param z0 point 1 Z coordinate
 * @param x1 point 2 X coordinate
 * @param y1 point 2 Y coordinate
 * @param z1 point 2 Z coordinate
 */
LSP_DSP_LIB_SYMBOL(void, init_segment_xyz, LSP_DSP_LIB_TYPE(segment3d_t) *s,
    float x0, float y0, float z0,
    float x1, float y1, float z1
);

/** Init segment using two points
 *
 * @param s segment to initialize
 * @param p1 point 1
 * @param p2 point 2
 */
LSP_DSP_LIB_SYMBOL(void, init_segment_p2, LSP_DSP_LIB_TYPE(segment3d_t) *s, const LSP_DSP_LIB_TYPE(point3d_t) *p1, const LSP_DSP_LIB_TYPE(point3d_t) *p2);

/** Init segment using array of two points
 *
 * @param s segment to initialize
 * @param p array of points
 */
LSP_DSP_LIB_SYMBOL(void, init_segment_pv, LSP_DSP_LIB_TYPE(segment3d_t) *s, const LSP_DSP_LIB_TYPE(point3d_t) *p);

/** Initialize matrix (make copy)
 *
 * @param dst destination matrix
 * @param src source matrix
 */
LSP_DSP_LIB_SYMBOL(void, init_matrix3d, LSP_DSP_LIB_TYPE(matrix3d_t) *dst, const LSP_DSP_LIB_TYPE(matrix3d_t) *src);

/** Zero matrix
 *
 * @param m target matrix
 */
LSP_DSP_LIB_SYMBOL(void, init_matrix3d_zero, LSP_DSP_LIB_TYPE(matrix3d_t) *m);

/** Fill matrix with ones
 *
 * @param m target matrix
 */
LSP_DSP_LIB_SYMBOL(void, init_matrix3d_one, LSP_DSP_LIB_TYPE(matrix3d_t) *m);

/** Fill matrix with identity values
 *
 * @param m matrix
 */
LSP_DSP_LIB_SYMBOL(void, init_matrix3d_identity, LSP_DSP_LIB_TYPE(matrix3d_t) *m);

/** Init matrix translation
 *
 * @param m matrix
 * @param dx translation X
 * @param dy translation Y
 * @param dz translation Z
 */
LSP_DSP_LIB_SYMBOL(void, init_matrix3d_translate, LSP_DSP_LIB_TYPE(matrix3d_t) *m, float dx, float dy, float dz);

/** Init matrix translation
 *
 * @param m matrix
 * @param p point that defines translation
 */
LSP_DSP_LIB_SYMBOL(void, init_matrix3d_translate_p1, LSP_DSP_LIB_TYPE(matrix3d_t) *m, const LSP_DSP_LIB_TYPE(point3d_t) *p);

/**
 * Init matrix translation
 * @param m matrix
 * @param v vector that defines translation
 */
LSP_DSP_LIB_SYMBOL(void, init_matrix3d_translate_v1, LSP_DSP_LIB_TYPE(matrix3d_t) *m, const LSP_DSP_LIB_TYPE(vector3d_t) *v);

/** Init matrix scale
 *
 * @param m matrix
 * @param sx size X
 * @param sy size Y
 * @param sz size Z
 */
LSP_DSP_LIB_SYMBOL(void, init_matrix3d_scale, LSP_DSP_LIB_TYPE(matrix3d_t) *m, float sx, float sy, float sz);

/** Initialize rotation matrix around X axis
 *
 * @param m matrix
 * @param angle angle
 */
LSP_DSP_LIB_SYMBOL(void, init_matrix3d_rotate_x, LSP_DSP_LIB_TYPE(matrix3d_t) *m, float angle);

/** Initialize rotation matrix around Y axis
 *
 * @param m matrix
 * @param angle angle
 */
LSP_DSP_LIB_SYMBOL(void, init_matrix3d_rotate_y, LSP_DSP_LIB_TYPE(matrix3d_t) *m, float angle);

/** Initialize rotation matrix around Z axis
 *
 * @param m matrix
 * @param angle angle
 */
LSP_DSP_LIB_SYMBOL(void, init_matrix3d_rotate_z, LSP_DSP_LIB_TYPE(matrix3d_t) *m, float angle);

/** Initialize rotation matrix around vector
 *
 * @param m matrix
 * @param x vector X
 * @param y vector Y
 * @param z vector Z
 * @param angle angle
 */
LSP_DSP_LIB_SYMBOL(void, init_matrix3d_rotate_xyz, LSP_DSP_LIB_TYPE(matrix3d_t) *m, float x, float y, float z, float angle);

/**
 * Initialize projection matrix according to the glFrustum() specification
 * @param m target matrix to store values
 * @param left coordinates for the left vertical clipping plane
 * @param right coordinates for the right vertical clipping plane
 * @param bottom coordinates for the bottom clipping plane
 * @param top coordinates for the top clipping plane
 * @param near distance to the near clipping plane
 * @param far distance to the far clipping plane
 */
LSP_DSP_LIB_SYMBOL(void, init_matrix3d_frustum, LSP_DSP_LIB_TYPE(matrix3d_t) *m, float left, float right, float bottom, float top, float near, float far);

/**
 * Initialize matrix similar to gluPerspective()
 * @param m target matrix to store values
 * @param pov point-of view coordinates
 * @param fwd direction of view (vector)
 * @param up the up vector
 */
LSP_DSP_LIB_SYMBOL(void, init_matrix3d_lookat_p1v2, LSP_DSP_LIB_TYPE(matrix3d_t) *m, const LSP_DSP_LIB_TYPE(point3d_t) *pov, const LSP_DSP_LIB_TYPE(vector3d_t) *fwd, const LSP_DSP_LIB_TYPE(vector3d_t) *up);

/**
 * Initialize matrix similar to gluPerspective()
 * @param m target matrix to store values
 * @param pov point-of view coordinates
 * @param pod point-of-destination coordinates
 * @param up the up vector
 */
LSP_DSP_LIB_SYMBOL(void, init_matrix3d_lookat_p2v1, LSP_DSP_LIB_TYPE(matrix3d_t) *m, const LSP_DSP_LIB_TYPE(point3d_t) *pov, const LSP_DSP_LIB_TYPE(point3d_t) *pod, const LSP_DSP_LIB_TYPE(vector3d_t) *up);

/**
 * Initialize matrix that changes ortogonal orientation
 * @param m matrix to initialize
 * @param orientation axis orientation
 */
LSP_DSP_LIB_SYMBOL(void, init_matrix3d_orientation, LSP_DSP_LIB_TYPE(matrix3d_t) *m, LSP_DSP_LIB_TYPE(axis_orientation_t) orientation);

/**
 * Compute tranfromation matrix from point and vector data which provides:
 *   - position of the object (point)
 *   - direction of the object (vector)
 *   - scale of the object (length of vector)
 * After applying this matrix, the point with coordinates (0, 0, 1)
 * will have coordinates (p.x + v.dx, p.y + v.dy, p.z + v.dz)
 *
 * @param m target matrix
 * @param p point that indicates position of the object
 * @param v vector that indicates rotation and size of the object
 */
LSP_DSP_LIB_SYMBOL(void, calc_matrix3d_transform_p1v1, LSP_DSP_LIB_TYPE(matrix3d_t) *m, const LSP_DSP_LIB_TYPE(point3d_t) *p, const LSP_DSP_LIB_TYPE(vector3d_t) *v);

/**
 * Compute tranfromation matrix from ray data which provides:
 *   - position of the object (point)
 *   - direction of the object (vector)
 *   - scale of the object (length of vector)
 * After applying this matrix, the point with coordinates (0, 0, 1)
 * will have coordinates (r.z.x + r.v.dx, r.z.y + r.v.dy, r.z.z + r.v.dz)
 * @param m target matrix
 * @param r ray that indicates position, rotation and size of the object
 */
LSP_DSP_LIB_SYMBOL(void, calc_matrix3d_transform_r1, LSP_DSP_LIB_TYPE(matrix3d_t) *m, const LSP_DSP_LIB_TYPE(ray3d_t) *r);

/** Apply matrix to vector
 *
 * @param r target vector
 * @param v source vector
 * @param m matrix
 */
LSP_DSP_LIB_SYMBOL(void, apply_matrix3d_mv2, LSP_DSP_LIB_TYPE(vector3d_t) *r, const LSP_DSP_LIB_TYPE(vector3d_t) *v, const LSP_DSP_LIB_TYPE(matrix3d_t) *m);

/** Apply matrix to vector
 *
 * @param r target vector
 * @param m matrix
 */
LSP_DSP_LIB_SYMBOL(void, apply_matrix3d_mv1, LSP_DSP_LIB_TYPE(vector3d_t) *r, const LSP_DSP_LIB_TYPE(matrix3d_t) *m);

/** Apply matrix to point
 *
 * @param r target point
 * @param v source point
 * @param m matrix
 */
LSP_DSP_LIB_SYMBOL(void, apply_matrix3d_mp2, LSP_DSP_LIB_TYPE(point3d_t) *r, const LSP_DSP_LIB_TYPE(point3d_t) *p, const LSP_DSP_LIB_TYPE(matrix3d_t) *m);

/** Apply matrix to point
 *
 * @param r target point
 * @param m matrix
 */
LSP_DSP_LIB_SYMBOL(void, apply_matrix3d_mp1, LSP_DSP_LIB_TYPE(point3d_t) *r, const LSP_DSP_LIB_TYPE(matrix3d_t) *m);

/** Apply matrix to matrix (calculate matrix multiplication)
 *
 * @param r target matrix
 * @param s source matrix
 * @param m matrix
 */
LSP_DSP_LIB_SYMBOL(void, apply_matrix3d_mm2, LSP_DSP_LIB_TYPE(matrix3d_t) *r, const LSP_DSP_LIB_TYPE(matrix3d_t) *s, const LSP_DSP_LIB_TYPE(matrix3d_t) *m);

/** Apply matrix to matrix (calculate matrix multiplication)
 *
 * @param r target matrix
 * @param m matrix
 */
LSP_DSP_LIB_SYMBOL(void, apply_matrix3d_mm1, LSP_DSP_LIB_TYPE(matrix3d_t) *r, const LSP_DSP_LIB_TYPE(matrix3d_t) *m);

/** Transpose matrix
 *
 * @param r target matrix
 */
LSP_DSP_LIB_SYMBOL(void, transpose_matrix3d1, LSP_DSP_LIB_TYPE(matrix3d_t) *r);

/** Transpose matrix
 *
 * @param r target matrix
 * @param m source matrix
 */
LSP_DSP_LIB_SYMBOL(void, transpose_matrix3d2, LSP_DSP_LIB_TYPE(matrix3d_t) *r, const LSP_DSP_LIB_TYPE(matrix3d_t) *m);

/** Initialize ray using coordinates of 2 points
 *
 * @param l ray to initialize
 * @param x0 source point X coordinate
 * @param y0 source point Y coordinate
 * @param z0 source point Z coordinate
 * @param x1 destination point X coordinate
 * @param y1 destination point X coordinate
 * @param z1 destination point X coordinate
 */
LSP_DSP_LIB_SYMBOL(void, init_ray_xyz, LSP_DSP_LIB_TYPE(ray3d_t) *l, float x0, float y0, float z0, float x1, float y1, float z1);

/** Initialize ray using coordinate of start point and direction vector
 *
 * @param l ray to initialize
 * @param x0 source point X coordinate
 * @param y0 source point Y coordinate
 * @param z0 source point Z coordinate
 * @param dx direction vector X projection
 * @param dy direction vector Y projection
 * @param dz direction vector Z projection
 */
LSP_DSP_LIB_SYMBOL(void, init_ray_dxyz, LSP_DSP_LIB_TYPE(ray3d_t) *l, float x0, float y0, float z0, float dx, float dy, float dz);

/** Initialize ray using point and vector object
 *
 * @param l ray to initialize
 * @param p source point
 * @param v direction vector
 */
LSP_DSP_LIB_SYMBOL(void, init_ray_pdv, LSP_DSP_LIB_TYPE(ray3d_t) *l, const LSP_DSP_LIB_TYPE(point3d_t) *p, const LSP_DSP_LIB_TYPE(vector3d_t) *m);

/** Initialize ray using two points
 *
 * @param l ray to initialize
 * @param p1 source point
 * @param p2 destination point
 */
LSP_DSP_LIB_SYMBOL(void, init_ray_p2, LSP_DSP_LIB_TYPE(ray3d_t) *l, const LSP_DSP_LIB_TYPE(point3d_t) *p1, const LSP_DSP_LIB_TYPE(point3d_t) *p2);

/** Initialize ray using array of two points
 *
 * @param l ray to initialize
 * @param p array of two points to initialize
 */
LSP_DSP_LIB_SYMBOL(void, init_ray_pv, LSP_DSP_LIB_TYPE(ray3d_t) *l, const LSP_DSP_LIB_TYPE(point3d_t) *p);

/** Initialize ray using another ray
 *
 * @param l ray to initialize
 * @param r source ray
 */
LSP_DSP_LIB_SYMBOL(void, init_ray, LSP_DSP_LIB_TYPE(ray3d_t) *l, const LSP_DSP_LIB_TYPE(ray3d_t) *r);

/** Calculate ray using coordinates of 2 points
 *
 * @param l ray to initialize
 * @param x0 source point X coordinate
 * @param y0 source point Y coordinate
 * @param z0 source point Z coordinate
 * @param x1 destination point X coordinate
 * @param y1 destination point X coordinate
 * @param z1 destination point X coordinate
 */
LSP_DSP_LIB_SYMBOL(void, calc_ray_xyz, LSP_DSP_LIB_TYPE(ray3d_t) *l, float x0, float y0, float z0, float x1, float y1, float z1);

/** Calculate ray using coordinate of start point and direction vector
 *
 * @param l ray to initialize
 * @param x0 source point X coordinate
 * @param y0 source point Y coordinate
 * @param z0 source point Z coordinate
 * @param dx direction vector X projection
 * @param dy direction vector Y projection
 * @param dz direction vector Z projection
 */
LSP_DSP_LIB_SYMBOL(void, calc_ray_dxyz, LSP_DSP_LIB_TYPE(ray3d_t) *l, float x0, float y0, float z0, float dx, float dy, float dz);

/** Calculate ray using another ray
 *
 * @param l ray to initialize
 * @param r source ray
 */
LSP_DSP_LIB_SYMBOL(void, calc_ray_pdv, LSP_DSP_LIB_TYPE(ray3d_t) *l, const LSP_DSP_LIB_TYPE(point3d_t) *p, const LSP_DSP_LIB_TYPE(vector3d_t) *m);

/** Calculate ray using two points
 *
 * @param l ray to initialize
 * @param p1 source point
 * @param p2 destination point
 */
LSP_DSP_LIB_SYMBOL(void, calc_ray_p2, LSP_DSP_LIB_TYPE(ray3d_t) *l, const LSP_DSP_LIB_TYPE(point3d_t) *p1, const LSP_DSP_LIB_TYPE(point3d_t) *p2);

/** Calculate ray using array of two points
 *
 * @param l ray to initialize
 * @param p array of two points to initialize
 */
LSP_DSP_LIB_SYMBOL(void, calc_ray_pv, LSP_DSP_LIB_TYPE(ray3d_t) *l, const LSP_DSP_LIB_TYPE(point3d_t) *p);

/** Calculate ray using another ray
 *
 * @param l ray to initialize
 * @param r source ray
 */
LSP_DSP_LIB_SYMBOL(void, calc_ray, LSP_DSP_LIB_TYPE(ray3d_t) *l, const LSP_DSP_LIB_TYPE(ray3d_t) *r);

/** Calculate triangle normal and edge lengths
 *
 * @param t triangle
 */
LSP_DSP_LIB_SYMBOL(void, calc_triangle3d_params, LSP_DSP_LIB_TYPE(triangle3d_t) *t);

/** Initialize triangle using coordinates of 3 points,
 *  fill normal vector with zeros
 *
 * @param t triangle to initialize
 * @param x0 point 1 X coordinate
 * @param y0 point 1 Y coordinate
 * @param z0 point 1 Z coordinate
 * @param x1 point 2 X coordinate
 * @param y1 point 2 Y coordinate
 * @param z1 point 2 Z coordinate
 * @param x2 point 3 X coordinate
 * @param y2 point 3 Y coordinate
 * @param z2 point 3 Z coordinate
 */
LSP_DSP_LIB_SYMBOL(void, init_triangle3d_xyz, LSP_DSP_LIB_TYPE(triangle3d_t) *t,
        float x0, float y0, float z0,
        float x1, float y1, float z1,
        float x2, float y2, float z2
    );

/** Initialize triangle using 3 points,
 *  fill normal vector with zeros
 *
 * @param t triangle to initialize
 * @param p1 point 1
 * @param p2 point 2
 * @param p3 point 3
 */
LSP_DSP_LIB_SYMBOL(void, init_triangle3d_p3,
        LSP_DSP_LIB_TYPE(triangle3d_t) *t,
        const LSP_DSP_LIB_TYPE(point3d_t) *p1,
        const LSP_DSP_LIB_TYPE(point3d_t) *p2,
        const LSP_DSP_LIB_TYPE(point3d_t) *p3
    );

/** Initialize triangle using array of 3 points,
 *  fill normal vector with zeros
 *
 * @param t triangle to initialize
 * @param p array of 3 points
 */
LSP_DSP_LIB_SYMBOL(void, init_triangle3d_pv,
        LSP_DSP_LIB_TYPE(triangle3d_t) *t,
        const LSP_DSP_LIB_TYPE(point3d_t) *p
    );

/** Initialize triangle from another triangle
 *
 * @param dst destination triangle
 * @param src source triangle
 */
LSP_DSP_LIB_SYMBOL(void, init_triangle3d, LSP_DSP_LIB_TYPE(triangle3d_t) *dst, const LSP_DSP_LIB_TYPE(triangle3d_t) *src);

/** Initialize triangle using coordinates of 3 points,
 *  calculate normal vector
 *
 * @param t triangle to initialize
 * @param x0 point 1 X coordinate
 * @param y0 point 1 Y coordinate
 * @param z0 point 1 Z coordinate
 * @param x1 point 2 X coordinate
 * @param y1 point 2 Y coordinate
 * @param z1 point 2 Z coordinate
 * @param x2 point 3 X coordinate
 * @param y2 point 3 Y coordinate
 * @param z2 point 3 Z coordinate
 */
LSP_DSP_LIB_SYMBOL(void, calc_triangle3d_xyz, LSP_DSP_LIB_TYPE(triangle3d_t) *t,
        float x0, float y0, float z0,
        float x1, float y1, float z1,
        float x2, float y2, float z2
    );

/** Initialize triangle using 3 points,
 *  calculate normal vector
 *
 * @param t triangle to initialize
 * @param p1 point 1
 * @param p2 point 2
 * @param p3 point 3
 */
LSP_DSP_LIB_SYMBOL(void, calc_triangle3d_p3,
        LSP_DSP_LIB_TYPE(triangle3d_t) *t,
        const LSP_DSP_LIB_TYPE(point3d_t) *p1,
        const LSP_DSP_LIB_TYPE(point3d_t) *p2,
        const LSP_DSP_LIB_TYPE(point3d_t) *p3
    );

/** Initialize triangle using array of 3 points,
 *  calculate normal vector
 *
 * @param t triangle to initialize
 * @param p array of 3 points
 */
LSP_DSP_LIB_SYMBOL(void, calc_triangle3d_pv,
        LSP_DSP_LIB_TYPE(triangle3d_t) *t,
        const LSP_DSP_LIB_TYPE(point3d_t) *p
    );

/** Init triangle from another triangle,
 *  calculate normal vector
 *
 * @param dst destination triangle
 * @param src source triangle
 */
LSP_DSP_LIB_SYMBOL(void, calc_triangle3d, LSP_DSP_LIB_TYPE(triangle3d_t) *dst, const LSP_DSP_LIB_TYPE(triangle3d_t) *src);

/** Analyze that two vectors and the normal vector organize the left triplet
 *
 * @param p1 start point of the first vector
 * @param p2 end point of the first vector, start point of the second vector
 * @param p3 end point of the second vector
 * @param n normal vector
 * @return value greater than zero if left triplet, less than zero if right triplet, zero if not triplet
 */
LSP_DSP_LIB_SYMBOL(float, check_triplet3d_p3n, const LSP_DSP_LIB_TYPE(point3d_t) *p1, const LSP_DSP_LIB_TYPE(point3d_t) *p2, const LSP_DSP_LIB_TYPE(point3d_t) *p3, const LSP_DSP_LIB_TYPE(vector3d_t) *n);

/** Analyze that two vectors and the normal vector organize the left triplet
 *
 * @param pv array of three points, each previous point is start of vector, each next point is end of vector
 * @param n normal vector
 * @return value greater than zero if left triplet, less than zero if right triplet, zero if not triplet
 */
LSP_DSP_LIB_SYMBOL(float, check_triplet3d_pvn, const LSP_DSP_LIB_TYPE(point3d_t) *pv, const LSP_DSP_LIB_TYPE(vector3d_t) *n);

/** Analyze that two vectors and the normal vector organize the left triplet
 *
 * @param v1 first vector
 * @param v2 second vector
 * @param n normal vector
 * @return value greater than zero if left triplet, less than zero if right triplet, zero if not triplet
 */
LSP_DSP_LIB_SYMBOL(float, check_triplet3d_v2n, const LSP_DSP_LIB_TYPE(vector3d_t) *v1, const LSP_DSP_LIB_TYPE(vector3d_t) *v2, const LSP_DSP_LIB_TYPE(vector3d_t) *n);

/** Analyze that two vectors and the normal vector organize the left triplet
 *
 * @param v array of two vectors
 * @param n normal vector
 * @return value greater than zero if left triplet, less than zero if right triplet, zero if not triplet
 */
LSP_DSP_LIB_SYMBOL(float, check_triplet3d_vvn, const LSP_DSP_LIB_TYPE(vector3d_t) *v, const LSP_DSP_LIB_TYPE(vector3d_t) *n);

/** Analyze that three vectors organize the left triplet
 *
 * @param v array of three vectors
 * @param n normal vector
 * @return value greater than zero if left triplet, less than zero if right triplet, zero if not triplet
 */
LSP_DSP_LIB_SYMBOL(float, check_triplet3d_vv, const LSP_DSP_LIB_TYPE(vector3d_t) *v);

/** Analyze that triangle vectors and normal vector of triangle organize the left triplet
 *
 * @param t triganle
 * @return value greater than zero if left triplet, less than zero if right triplet, zero if not triplet
 */
LSP_DSP_LIB_SYMBOL(float, check_triplet3d_t, const LSP_DSP_LIB_TYPE(triangle3d_t) *t);

/** Analyze that triangle vectors and normal vector organize the left triplet
 *
 * @param t triganle
 * @param n normal vector
 * @return value greater than zero if left triplet, less than zero if right triplet, zero if not triplet
 */
LSP_DSP_LIB_SYMBOL(float, check_triplet3d_tn, const LSP_DSP_LIB_TYPE(triangle3d_t) *t, const LSP_DSP_LIB_TYPE(vector3d_t) *n);

/** Analyze point location relative to the triangle
 *
 * @param t triangle
 * @param p point
 * @return value > 0 if point is candidate to be inside the triangle,
 *         value < 0 if point is candidate to be outside the triangle,
 *         value = 0 if point is on the edge of triangle
 */
LSP_DSP_LIB_SYMBOL(float, check_point3d_on_triangle_tp, const LSP_DSP_LIB_TYPE(triangle3d_t) *t, const LSP_DSP_LIB_TYPE(point3d_t) *p);

/** Analyze point location relative to the triangle of three points
 *
 * @param t array of three triangle points
 * @param p point
 * @return value > 0 if point is candidate to be inside the triangle,
 *         value < 0 if point is candidate to be outside the triangle,
 *         value = 0 if point is on the edge of triangle
 */
LSP_DSP_LIB_SYMBOL(float, check_point3d_on_triangle_pvp, const LSP_DSP_LIB_TYPE(point3d_t) *t, const LSP_DSP_LIB_TYPE(point3d_t) *p);

/** Analyze point location relative to the triangle of three points
 *
 * @param p1 triangle point 1
 * @param p2 triangle point 2
 * @param p3 triangle point 3
 * @param p point
 * @return value > 0 if point is candidate to be inside the triangle,
 *         value < 0 if point is candidate to be outside the triangle,
 *         value = 0 if point is on the edge of triangle
 */
LSP_DSP_LIB_SYMBOL(float, check_point3d_on_triangle_p3p, const LSP_DSP_LIB_TYPE(point3d_t) *p1, const LSP_DSP_LIB_TYPE(point3d_t) *p2, const LSP_DSP_LIB_TYPE(point3d_t) *p3, const LSP_DSP_LIB_TYPE(point3d_t) *p);


/** Return the index of longest edge between three points
 *
 * @param p1 point 1
 * @param p2 point 2
 * @param p3 point 3
 * @return 0 if edge between points 1 and 2 is longest, 1 if between points 2 and 3, 2 if between ponts 3 and 1
 */
LSP_DSP_LIB_SYMBOL(size_t, longest_edge3d_p3, const LSP_DSP_LIB_TYPE(point3d_t) *p1, const LSP_DSP_LIB_TYPE(point3d_t) *p2, const LSP_DSP_LIB_TYPE(point3d_t) *p3);

/** Return the index of longest edge between three points
 *
 * @param p array of points
 * @return 0 if edge between points 0 and 1 is longest, 1 if between points 1 and 2, 2 if between ponts 2 and 0
 */
LSP_DSP_LIB_SYMBOL(size_t, longest_edge3d_pv, const LSP_DSP_LIB_TYPE(point3d_t) *p);

/** Find intersection of ray and triangle
 *
 * @param ip intersection point to store result
 * @param l ray to test intersection
 * @param t pre-calculated triangle to check (with plane equation)
 * @return actual distance between ray start point and intersection point.
 *         If value is less than zero, then there is no intersection
 */
LSP_DSP_LIB_SYMBOL(float, find_intersection3d_rt, LSP_DSP_LIB_TYPE(point3d_t) *ip, const LSP_DSP_LIB_TYPE(ray3d_t) *l, const LSP_DSP_LIB_TYPE(triangle3d_t) *t);

/** Calculate angle between two vectors
 *
 * @param v1 vector 1
 * @param v2 vector 2
 * @return cosine of angle between two vectors [-1..1]
 */
LSP_DSP_LIB_SYMBOL(float, calc_angle3d_v2, const LSP_DSP_LIB_TYPE(vector3d_t) *v1, const LSP_DSP_LIB_TYPE(vector3d_t) *v2);

/** Calculate angle between two vectors
 *
 * @param v array of two vectors
 * @return cosine of angle between two vectors [-1..1]
 */
LSP_DSP_LIB_SYMBOL(float, calc_angle3d_vv, const LSP_DSP_LIB_TYPE(vector3d_t) *v);

/** Calculate normal for triangle described by three points
 *
 * @param n normal
 * @param p1 point 1
 * @param p2 point 2
 * @param p3 point 3
 */
LSP_DSP_LIB_SYMBOL(void, calc_normal3d_p3, LSP_DSP_LIB_TYPE(vector3d_t) *n, const LSP_DSP_LIB_TYPE(point3d_t) *p1, const LSP_DSP_LIB_TYPE(point3d_t) *p2, const LSP_DSP_LIB_TYPE(point3d_t) *p3);

/** Calculate normal for triangle described by array of three points
 *
 * @param n normal
 * @param pv array of three points
 */
LSP_DSP_LIB_SYMBOL(void, calc_normal3d_pv, LSP_DSP_LIB_TYPE(vector3d_t) *n, const LSP_DSP_LIB_TYPE(point3d_t) *pv);

/** Calculate normal for triangle described by two vectors
 *
 * @param n normal
 * @param v1 vector 1
 * @param v2 vector 2
 */
LSP_DSP_LIB_SYMBOL(void, calc_normal3d_v2, LSP_DSP_LIB_TYPE(vector3d_t) *n, const LSP_DSP_LIB_TYPE(vector3d_t) *v1, const LSP_DSP_LIB_TYPE(vector3d_t) *v2);

/** Calculate normal for triangle described by array two vectors
 *
 * @param n normal
 * @param vv array of two vectors
 */
LSP_DSP_LIB_SYMBOL(void, calc_normal3d_vv, LSP_DSP_LIB_TYPE(vector3d_t) *n, const LSP_DSP_LIB_TYPE(vector3d_t) *vv);

/** Move point between two other points: p = p1 + (p2 - p1) * k
 *
 * @param p target to store result
 * @param p1 point 1
 * @param p2 point 2
 * @param k movement
 */
LSP_DSP_LIB_SYMBOL(void, move_point3d_p2, LSP_DSP_LIB_TYPE(point3d_t) *p, const LSP_DSP_LIB_TYPE(point3d_t) *p1, const LSP_DSP_LIB_TYPE(point3d_t) *p2, float k);

/** Move point between two other points: p = p1 + (p2 - p1) * k
 *
 * @param p point to move
 * @param pv array of two points
 * @param k movement
 */
LSP_DSP_LIB_SYMBOL(void, move_point3d_pv, LSP_DSP_LIB_TYPE(point3d_t) *p, const LSP_DSP_LIB_TYPE(point3d_t) *pv, float k);

/**
 * Add vector to point
 * @param p point
 * @param dv vector to add
 */
LSP_DSP_LIB_SYMBOL(void, add_vector_pv1, LSP_DSP_LIB_TYPE(point3d_t) *p, const LSP_DSP_LIB_TYPE(vector3d_t) *dv);

/**
 * Add vector to point
 * @param p point
 * @param dv vector to add
 */
LSP_DSP_LIB_SYMBOL(void, add_vector_pv2, LSP_DSP_LIB_TYPE(point3d_t) *p, const LSP_DSP_LIB_TYPE(point3d_t) *sp, const LSP_DSP_LIB_TYPE(vector3d_t) *dv);

/**
 * Add scaled vector to point: p = p + dv * k
 * @param p target point
 * @param dv vector to add
 * @param k scale factor
 */
LSP_DSP_LIB_SYMBOL(void, add_vector_pvk1, LSP_DSP_LIB_TYPE(point3d_t) *p, const LSP_DSP_LIB_TYPE(vector3d_t) *dv, float k);

/**
 * Add scaled vector to point: p = sp + dv * k
 * @param p point
 * @param sp source point
 * @param dv vector to add
 * @param k scale factor
 */
LSP_DSP_LIB_SYMBOL(void, add_vector_pvk2, LSP_DSP_LIB_TYPE(point3d_t) *p, const LSP_DSP_LIB_TYPE(point3d_t) *sp, const LSP_DSP_LIB_TYPE(vector3d_t) *dv, float k);

/**
 * Compute bounding box around object
 * @param b bounding box object
 * @param p array of object vertexes
 * @param n number of vertexes in object
 */
LSP_DSP_LIB_SYMBOL(void, calc_bound_box, LSP_DSP_LIB_TYPE(bound_box3d_t) *b, const LSP_DSP_LIB_TYPE(point3d_t) *p, size_t n);

/**
 * Compute plane equation using three points
 * @param v pointer to store plane equation
 * @param p0 point 0
 * @param p1 point 1
 * @param p2 point 2
 * @return the length of the original normal vector
 */
LSP_DSP_LIB_SYMBOL(float, calc_plane_p3, LSP_DSP_LIB_TYPE(vector3d_t) *v, const LSP_DSP_LIB_TYPE(point3d_t) *p0, const LSP_DSP_LIB_TYPE(point3d_t) *p1, const LSP_DSP_LIB_TYPE(point3d_t) *p2);

/**
 * Compute plane equation using three points
 * @param v pointer to store plane equation
 * @param pv array of three points that lay on the plane
 * @return the length of the original normal vector
 */
LSP_DSP_LIB_SYMBOL(float, calc_plane_pv, LSP_DSP_LIB_TYPE(vector3d_t) *v, const LSP_DSP_LIB_TYPE(point3d_t) *pv);

/**
 * Compute plane equation using vector and two points
 * @param v vector to store plane equation
 * @param v0 vector
 * @param p0 point 0
 * @param p1 point 1
 * @return the length of the original normal vector
 */
LSP_DSP_LIB_SYMBOL(float, calc_plane_v1p2, LSP_DSP_LIB_TYPE(vector3d_t) *v, const LSP_DSP_LIB_TYPE(vector3d_t) *v0, const LSP_DSP_LIB_TYPE(point3d_t) *p0, const LSP_DSP_LIB_TYPE(point3d_t) *p1);

/**
 * Orient plane to have source point below the plane
 * @param v target plane equation vector
 * @param sp source point
 * @param pl source plane equation vector
 * @return distance from point to the plane
 */
LSP_DSP_LIB_SYMBOL(float, orient_plane_v1p1, LSP_DSP_LIB_TYPE(vector3d_t) *v, const LSP_DSP_LIB_TYPE(point3d_t) *sp, const LSP_DSP_LIB_TYPE(vector3d_t) *pl);

/**
 * Compute plane equation using three points and set the proper direction so the orienting point is always 'below'
 * the plane
 * @param v pointer to store plane equation
 * @param sp orienting point
 * @param p0 point 0
 * @param p1 point 1
 * @param p2 point 2
 * @return the length of the original normal vector
 */
LSP_DSP_LIB_SYMBOL(float, calc_oriented_plane_p3, LSP_DSP_LIB_TYPE(vector3d_t) *v, const LSP_DSP_LIB_TYPE(point3d_t) *sp, const LSP_DSP_LIB_TYPE(point3d_t) *p0, const LSP_DSP_LIB_TYPE(point3d_t) *p1, const LSP_DSP_LIB_TYPE(point3d_t) *p2);

/**
 * Compute plane equation using three points and set the proper direction so the orienting point is always 'below'
 * the plane
 * @param v pointer to store plane equation
 * @param sp orienting point
 * @param pv array of three points that lay on the plane
 * @return the length of the original normal vector
 */
LSP_DSP_LIB_SYMBOL(float, calc_oriented_plane_pv, LSP_DSP_LIB_TYPE(vector3d_t) *v, const LSP_DSP_LIB_TYPE(point3d_t) *sp, const LSP_DSP_LIB_TYPE(point3d_t) *pv);

/**
 * Compute plane equation using three points and set the proper direction so the orienting point is always 'above'
 * the plane
 * @param v pointer to store plane equation
 * @param sp orienting point
 * @param p0 point 0
 * @param p1 point 1
 * @param p2 point 2
 * @return the length of the original normal vector
 */
LSP_DSP_LIB_SYMBOL(float, calc_rev_oriented_plane_p3, LSP_DSP_LIB_TYPE(vector3d_t) *v, const LSP_DSP_LIB_TYPE(point3d_t) *sp, const LSP_DSP_LIB_TYPE(point3d_t) *p0, const LSP_DSP_LIB_TYPE(point3d_t) *p1, const LSP_DSP_LIB_TYPE(point3d_t) *p2);

/**
 * Compute plane equation using three points and set the proper direction so the orienting point is always 'above'
 * the plane
 * @param v pointer to store plane equation
 * @param sp orienting point
 * @param pv array of three points that lay on the plane
 * @return the length of the original normal vector
 */
LSP_DSP_LIB_SYMBOL(float, calc_rev_oriented_plane_pv, LSP_DSP_LIB_TYPE(vector3d_t) *v, const LSP_DSP_LIB_TYPE(point3d_t) *sp, const LSP_DSP_LIB_TYPE(point3d_t) *pv);

/**
 * Compute plane equation for parallel plane that contains sp and pp points and is parallel to the line formed from p0 and p1 points
 * @param v pointer to store plane equation
 * @param sp source (projection) point
 * @param pp point that lays on the plane
 * @param p0 line point 0
 * @param p1 line point 1
 * @return the length of the original normal vector
 */
LSP_DSP_LIB_SYMBOL(float, calc_parallel_plane_p2p2, LSP_DSP_LIB_TYPE(vector3d_t) *v, const LSP_DSP_LIB_TYPE(point3d_t) *sp, const LSP_DSP_LIB_TYPE(point3d_t) *pp, const LSP_DSP_LIB_TYPE(point3d_t) *p0, const LSP_DSP_LIB_TYPE(point3d_t) *p1);

/**
 * Estimate the area of parallelogram formed by three points
 * @param p0 point 0
 * @param p1 point 1
 * @param p2 point 2
 * @return area of parallelogram
 */
LSP_DSP_LIB_SYMBOL(float, calc_area_p3, const LSP_DSP_LIB_TYPE(point3d_t) *p0, const LSP_DSP_LIB_TYPE(point3d_t) *p1, const LSP_DSP_LIB_TYPE(point3d_t) *p2);

/**
 * Estimate the area of parallelogram formed by three points
 * @param pv array of three points that form prarallelogram
 * @return area of parallelogram
 */
LSP_DSP_LIB_SYMBOL(float, calc_area_pv, const LSP_DSP_LIB_TYPE(point3d_t) *pv);

/**
 * Return length of the projection of the point on the line
 * @param p0 projection line point 0
 * @param p1 projection line point 1
 * @param pp projected point
 * @return length of the projection of the point on the line
 */
LSP_DSP_LIB_SYMBOL(float, projection_length_p2, const LSP_DSP_LIB_TYPE(point3d_t) *p0, const LSP_DSP_LIB_TYPE(point3d_t) *p1, const LSP_DSP_LIB_TYPE(point3d_t) *pp);

/**
 * Return length of the projection of the vector on another vector
 * @param v projection vector
 * @param pv projected vector
 * @return length of the projection of the vector on another vector
 */
LSP_DSP_LIB_SYMBOL(float, projection_length_v2, const LSP_DSP_LIB_TYPE(vector3d_t) *v, const LSP_DSP_LIB_TYPE(vector3d_t) *pv);

/**
 * Estimate the shortest distance to triangle
 * @param sp projection point
 * @param p0 point 0 of triangle
 * @param p1 point 1 of triangle
 * @param p2 point 2 of triangle
 * @return shortest distance
 */
LSP_DSP_LIB_SYMBOL(float, calc_min_distance_p3, const LSP_DSP_LIB_TYPE(point3d_t) *sp, const LSP_DSP_LIB_TYPE(point3d_t) *p0, const LSP_DSP_LIB_TYPE(point3d_t) *p1, const LSP_DSP_LIB_TYPE(point3d_t) *p2);

/**
 * Estimate the shortest distance to triangle
 * @param sp projection point
 * @param p0 point 0 of triangle
 * @param p1 point 1 of triangle
 * @param p2 point 2 of triangle
 * @return shortest distance
 */
LSP_DSP_LIB_SYMBOL(float, calc_min_distance_pv, const LSP_DSP_LIB_TYPE(point3d_t) *sp, const LSP_DSP_LIB_TYPE(point3d_t) *pv);

/**
 * Estimate the average distance to triangle
 * @param sp projection point
 * @param p0 point 0 of triangle
 * @param p1 point 1 of triangle
 * @param p2 point 2 of triangle
 * @return average distance
 */
LSP_DSP_LIB_SYMBOL(float, calc_avg_distance_p3, const LSP_DSP_LIB_TYPE(point3d_t) *sp, const LSP_DSP_LIB_TYPE(point3d_t) *p0, const LSP_DSP_LIB_TYPE(point3d_t) *p1, const LSP_DSP_LIB_TYPE(point3d_t) *p2);

/**
 * Compute distance between two pointes
 * @param p1 point 1
 * @param p2 point 2
 * @return distance
 */
LSP_DSP_LIB_SYMBOL(float, calc_distance_p2, const LSP_DSP_LIB_TYPE(point3d_t) *p1, const LSP_DSP_LIB_TYPE(point3d_t) *p2);

/**
 * Compute square of distance between two points
 * @param p1 point 1
 * @param p2 point 2
 * @return square value of distance
 */
LSP_DSP_LIB_SYMBOL(float, calc_sqr_distance_p2, const LSP_DSP_LIB_TYPE(point3d_t) *p1, const LSP_DSP_LIB_TYPE(point3d_t) *p2);

/**
 * Compute distance between two points
 * @param pv array of two points
 * @return distance between two points
 */
LSP_DSP_LIB_SYMBOL(float, calc_distance_pv, const LSP_DSP_LIB_TYPE(point3d_t) *pv);

/**
 * Compute the distance (actually, the length of the vector)
 * @param v vector
 * @return distance (vector length)
 */
LSP_DSP_LIB_SYMBOL(float, calc_distance_v1, const LSP_DSP_LIB_TYPE(vector3d_t) *v);

/**
 * Compute square of distance between two points
 * @param pv array of two points
 * @return square of distance between two points
 */
LSP_DSP_LIB_SYMBOL(float, calc_sqr_distance_pv, const LSP_DSP_LIB_TYPE(point3d_t) *pv);

/**
 * Compute intersection point of line and plane,
 * the method is safe from providing the same pointer of ip to l0 and/or l1
 * @param ip target point to store coordinates
 * @param l0 line point 0
 * @param l1 line point 1
 * @param pl vector containing plane equation
 */
LSP_DSP_LIB_SYMBOL(void, calc_split_point_p2v1, LSP_DSP_LIB_TYPE(point3d_t) *ip, const LSP_DSP_LIB_TYPE(point3d_t) *l0, const LSP_DSP_LIB_TYPE(point3d_t) *l1, const LSP_DSP_LIB_TYPE(vector3d_t) *pl);

/**
 * Compute intersection point of line and plane,
 * the method is safe from providing the same pointer of ip to l0 and/or l1
 * @param ip target point to store coordinates
 * @param lv line points (2 elements)
 * @param pl vector containing plane equation
 */
LSP_DSP_LIB_SYMBOL(void, calc_split_point_pvv1, LSP_DSP_LIB_TYPE(point3d_t) *ip, const LSP_DSP_LIB_TYPE(point3d_t) *lv, const LSP_DSP_LIB_TYPE(vector3d_t) *pl);

/**
 * Split raw triangle with plane, generates output set of triangles into out (triangles above split plane)
 * and in (triangles below split plane). For every triangle, points 1 and 2 are the points that
 * lay on the split plane, the first triangle ALWAYS has 2 common points with plane (1 and 2)
 *
 * @param out array of vertexes above plane
 * @param n_out counter of triangles above plane, should be initialized
 * @param in array of vertexes below plane
 * @param n_in counter of triangles below plane, should be initialized
 * @param pl plane equation
 * @param pv triangle to perform the split
 */
LSP_DSP_LIB_SYMBOL(void, split_triangle_raw,
        LSP_DSP_LIB_TYPE(raw_triangle_t) *out,
        size_t *n_out,
        LSP_DSP_LIB_TYPE(raw_triangle_t) *in,
        size_t *n_in,
        const LSP_DSP_LIB_TYPE(vector3d_t) *pl,
        const LSP_DSP_LIB_TYPE(raw_triangle_t) *pv
    );

/**
 * Cull raw triangle with plane, generates set of triangles below the split plane.
 * For every triangle, points 1 and 2 are the points that lay on the split plane,
 * the first triangle ALWAYS has 2 common points with split plane (1 and 2)
 *
 * @param in array of vertexes below plane
 * @param n_in counter of triangles below plane, should be initialized
 * @param pl plane equation
 * @param pv triangle to perform the split
 */
LSP_DSP_LIB_SYMBOL(void, cull_triangle_raw,
        LSP_DSP_LIB_TYPE(raw_triangle_t) *in,
        size_t *n_in,
        const LSP_DSP_LIB_TYPE(vector3d_t) *pl,
        const LSP_DSP_LIB_TYPE(raw_triangle_t) *pv
    );

/**
 * Check colocation of two points and a plane
 * @param v vector that contains plane equation
 * @param p1 point 1
 * @param p3 point 3
 * @return bit mask: 2 groups of 2 bits, describing state of each point, proper values are:
 *   00 - if point is above the plane
 *   01 - if point is on the plane
 *   10 - if point is below the plane
 *   11 - non-permitted value, won't be produced
 *   The example state:
 *   1001 - point 0 lays above the plane, point 1 lays on the plane
 */
LSP_DSP_LIB_SYMBOL(size_t, colocation_x2_v1p2, const LSP_DSP_LIB_TYPE(vector3d_t) *v, const LSP_DSP_LIB_TYPE(point3d_t) *p0, const LSP_DSP_LIB_TYPE(point3d_t) *p1);

/**
 * Check colocation of three points and a plane
 * @param v vector that contains plane equation
 * @param pv array of two points
 * @return bit mask: 2 groups of 2 bits, describing state of each point, proper values are:
 *   00 - if point is above the plane
 *   01 - if point is on the plane
 *   10 - if point is below the plane
 *   11 - non-permitted value, won't be produced
 *   The example state:
 *   1001 - point 0 lays above the plane, point 1 lays on the plane
 */
LSP_DSP_LIB_SYMBOL(size_t, colocation_x2_v1pv, const LSP_DSP_LIB_TYPE(vector3d_t) *v, const LSP_DSP_LIB_TYPE(point3d_t) *pv);

/**
 * Check colocation of three points and a plane
 * @param v vector that contains plane equation
 * @param p0 point 0
 * @param p1 point 1
 * @param p2 point 2
 * @return bit mask: 3 groups of 2 bits, describing state of each point, proper values are:
 *   00 - if point is above the plane
 *   01 - if point is on the plane
 *   10 - if point is below the plane
 *   11 - non-permitted value, won't be produced
 *   The example state:
 *   100100 - point 0 lays above the plane, point 1 lays on the plane, point 2 lays below the plane
 */
LSP_DSP_LIB_SYMBOL(size_t, colocation_x3_v1p3, const LSP_DSP_LIB_TYPE(vector3d_t) *v, const LSP_DSP_LIB_TYPE(point3d_t) *p0, const LSP_DSP_LIB_TYPE(point3d_t) *p1, const LSP_DSP_LIB_TYPE(point3d_t) *p2);

/**
 * Check colocation of three points and a plane
 * @param v vector that contains plane equation
 * @param pv array of three points
 * @return bit mask: 3 groups of 2 bits, describing state of each point, proper values are:
 *   00 - if point is above the plane
 *   01 - if point is on the plane
 *   10 - if point is below the plane
 *   11 - non-permitted value, won't be produced
 *   The example state:
 *   100100 - point 0 lays above the plane, point 1 lays on the plane, point 2 lays below the plane
 */
LSP_DSP_LIB_SYMBOL(size_t, colocation_x3_v1pv, const LSP_DSP_LIB_TYPE(vector3d_t) *v, const LSP_DSP_LIB_TYPE(point3d_t) *pv);

/**
 * Check colocation of three planes and a point
 * @param v0 plane 0
 * @param v1 plane 1
 * @param v2 plane 2
 * @param p point
 * @return bit mask: 3 groups of 2 bits, describing state of point relative to each plane, proper values are:
 *   00 - if point is above the plane
 *   01 - if point is on the plane
 *   10 - if point is below the plane
 *   11 - non-permitted value, won't be produced
 *   The example state:
 *   100100 - point lays above the plane 0, on the plane 1 and below the plane 2
 */
LSP_DSP_LIB_SYMBOL(size_t, colocation_x3_v3p1, const LSP_DSP_LIB_TYPE(vector3d_t) *v0, const LSP_DSP_LIB_TYPE(vector3d_t) *v1, const LSP_DSP_LIB_TYPE(vector3d_t) *v2, const LSP_DSP_LIB_TYPE(point3d_t) *p);

/**
 * Check colocation of three planes and a point
 * @param vv array of three vectors
 * @param p point
 * @return bit mask: 3 groups of 2 bits, describing state of point relative to each plane, proper values are:
 *   00 - if point is above the plane
 *   01 - if point is on the plane
 *   10 - if point is below the plane
 *   11 - non-permitted value, won't be produced
 *   The example state:
 *   100100 - point lays above the plane 0, on the plane 1 and below the plane 2
 */
LSP_DSP_LIB_SYMBOL(size_t, colocation_x3_vvp1, const LSP_DSP_LIB_TYPE(vector3d_t) *vv, const LSP_DSP_LIB_TYPE(point3d_t) *p);

/**
 * Compute unit vector from source point to center of triangle
 * @param v target to store vector
 * @param sp source point
 * @param p0 point 0
 * @param p1 point 1
 * @param p2 point 2
 */
LSP_DSP_LIB_SYMBOL(void, unit_vector_p1p3, LSP_DSP_LIB_TYPE(vector3d_t) *v, const LSP_DSP_LIB_TYPE(point3d_t) *sp, const LSP_DSP_LIB_TYPE(point3d_t) *p0, const LSP_DSP_LIB_TYPE(point3d_t) *p1, const LSP_DSP_LIB_TYPE(point3d_t) *p2);

/**
 * Compute unit vector from source point to center of triangle
 * @param v target to store vector
 * @param sp source point
 * @param pv array of three points
 */
LSP_DSP_LIB_SYMBOL(void, unit_vector_p1pv, LSP_DSP_LIB_TYPE(vector3d_t) *v, const LSP_DSP_LIB_TYPE(point3d_t) *sp, const LSP_DSP_LIB_TYPE(point3d_t) *pv);

#endif /* LSP_PLUG_IN_DSP_COMMON_3DMATH_H_ */