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
|
=encoding UTF-8
=head1 NAME
BH_Mat4f - real 4x4 matrix
=head1 SYNTAX
#include <BH/Math/Mat4f.h>
cc prog.c -o prog -lbh
=head1 DESCRIPTION
The BH_Mat4f module provides a set of functions for working with real 4x4
matrices. These functions allow you to perform various operations on matrices,
such as addition, subtraction, multiplication, transposition, determinant
calculation, and others.
=head1 API CALLS
=head2 BH_Mat4fIdentity
void BH_Mat4fIdentity(float out[16]);
Writes an identity matrix to I<out>.
=head2 BH_Mat4fAdd
void BH_Mat4fAdd(const float a[16],
const float b[16],
float out[16]);
Calculates the sum of two matrices I<a> and I<b>.
The I<out> parameter describes the resulting matrix.
=head2 BH_Mat4fSub
void BH_Mat4fSub(const float a[16],
const float b[16],
float out[16]);
Calculates the difference between two matrices I<a> and I<b>.
The I<out> parameter describes the resulting matrix.
=head2 BH_Mat4fMul
void BH_Mat4fMul(const float a[16],
const float b[16],
float out[16]);
Calculates the result of multiplying two matrices I<a> and I<b>.
The I<out> parameter describes the resulting matrix.
=head2 BH_Mat4fScale
void BH_Mat4fScale(const float a[16],
float b,
float out[16]);
Calculates the result of multiplying matrix I<a> by value I<b>.
The I<out> parameter describes the resulting matrix.
=head2 BH_Mat4fTranspose
void BH_Mat4fTranspose(const float in[16],
float out[16]);
Transposes matrix I<in>.
The I<out> parameter describes the resulting matrix.
=head2 BH_Mat4fTrace
float BH_Mat4fTrace(const float in[16]);
Calculates the sum of the elements of the main diagonal of matrix I<in>.
=head2 BH_Mat4fDet
float BH_Mat4fDet(const float in[16]);
Calculates the determinant of matrix I<in>.
=head2 BH_Mat4fInverse
int BH_Mat4fInverse(const float in[16],
float out[16]);
Calculates the inverse matrix for I<in>.
The I<out> parameter describes the resulting matrix.
If successful, the function returns 0, otherwise it returns an error code.
=head2 BH_Mat4fFromScale
void BH_Mat4fFromScale(float x,
float y,
float z,
float out[16]);
Calculates a scaling matrix with scales I<x>, I<y>, and I<z>.
The I<out> parameter describes the resulting matrix.
=head2 BH_Mat4fFromTranslation
void BH_Mat4fFromTranslation(float x,
float y,
float z,
float out[16]);
Calculates a translation matrix with values I<x>, I<y>, and I<z>.
The I<out> parameter describes the resulting matrix.
=head2 BH_Mat4fFromRotationX
void BH_Mat4fFromRotationX(float angle,
float out[16]);
Calculates a rotation matrix around the X axis with a given I<angle>.
The I<out> parameter describes the resulting matrix.
=head2 BH_Mat4fFromRotationY
void BH_Mat4fFromRotationY(float angle,
float out[16]);
Calculates a rotation matrix around the Y axis with a given I<angle>.
The I<out> parameter describes the resulting matrix.
=head2 BH_Mat4fFromRotationZ
void BH_Mat4fFromRotationZ(float angle,
float out[16]);
Calculates a rotation matrix around the Z axis with a given I<angle>.
The I<out> parameter describes the resulting matrix.
=head2 BH_Mat4fFromAxis
void BH_Mat4fFromAxis(const float axis[3],
float angle,
float out[16]);
Calculates a rotation matrix around the axis I<axis> with a given I<angle>.
The I<out> parameter describes the resulting matrix.
=head2 BH_Mat4fFromEuler
void BH_Mat4fFromEuler(float roll,
float pitch,
float yaw,
float out[16]);
Calculates a rotation matrix from the angles of the associated coordinate system
I<roll>, I<pitch>, and I<yaw>.
The order of rotation application is ZYX (yaw, pitch, roll).
The I<out> parameter describes the resulting matrix.
=head2 BH_Mat4fFromQuat4f
void BH_Mat4fFromQuat4f(const float in[4],
float out[16]);
Calculates a rotation matrix from quaternion I<in>.
The I<out> parameter describes the resulting matrix.
=head2 BH_Mat4fFromOrtho
void BH_Mat4fFromOrtho(float xMin,
float xMax,
float yMin,
float yMax,
float zMin,
float zMax,
float out[16]);
Calculates an orthographic projection matrix.
The I<xMin> and I<xMax> parameters define the valid range of X coordinates.
The I<yMin> and I<yMax> parameters define the valid range of Y coordinates.
The I<zMin> and I<zMax> parameters define the valid range of Z coordinates.
The I<out> parameter describes the resulting matrix.
=head2 BH_Mat4fFromFrustum
void BH_Mat4fFromFrustum(float fov,
float aspect,
float zMin,
float zMax,
float out[16]);
Calculates a perspective projection matrix.
The I<fov> parameter defines the field of view.
The I<aspect> parameter defines the aspect ratio.
The I<zMin> and I<zMax> parameters define the valid range of Z coordinates.
The I<out> parameter describes the resulting matrix.
=head2 BH_Mat4fFromLookAt
void BH_Mat4fFromLookAt(const float position[3],
const float at[3],
const float up[3],
float out[16]);
Calculates the camera view matrix.
The I<position> parameter defines the position of the camera in space.
The I<at> parameter defines the point where the camera is aimed.
The I<up> parameter defines the "up" direction of the camera.
The I<out> parameter describes the resulting matrix.
=head2 BH_Mat4fApplyVec4f
void BH_Mat4fApplyVec4f(const float a[16],
const float b[4],
float out[4]);
Calculates the result of multiplying matrix I<a> by vector I<b>.
The I<out> parameter describes the resulting vector.
=head2 BH_Mat4fApplyVec3f
void BH_Mat4fApplyVec3f(const float a[16],
const float b[3],
float out[3]);
Calculates the result of multiplying matrix I<a> by vector I<b>.
The I<out> parameter describes the resulting vector.
=head1 SEE ALSO
L<BH>
|