You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/API/Math/Mat4.md
+361Lines changed: 361 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -84,3 +84,364 @@ returns
84
84
85
85
---
86
86
87
+
### `multiplyQuat`
88
+
89
+
Mat4 * Quat
90
+
91
+
```php
92
+
static function multiplyQuat(\GL\Math\Mat4 $left, \GL\Math\Quat $right) : \GL\Math\Mat4
93
+
```
94
+
95
+
Multiplies the left matrix by the right quaternion
96
+
97
+
Note: **This method only exists because there is a bug with the order of operation in PHP.**
98
+
99
+
---
100
+
101
+
### `copy`
102
+
103
+
Copys the current matrix
104
+
105
+
```php
106
+
function copy() : \GL\Math\Mat4
107
+
```
108
+
109
+
Returns a new instance of the current matrix with the same values. This means that any modifications made to the returned matrix will not affect the current matrix.
110
+
111
+
```php
112
+
$copy = $matrix->copy();
113
+
```
114
+
115
+
returns
116
+
117
+
: `\Mat4` The copy of the current matrix.
118
+
119
+
---
120
+
121
+
### `row`
122
+
123
+
Returns the row at the given index.
124
+
125
+
```php
126
+
function row(int $index) : \GL\Math\Vec4
127
+
```
128
+
129
+
Example usage:
130
+
131
+
```php
132
+
$matrix = new Mat4([
133
+
[1.0, 2.0, 3.0, 4.0],
134
+
[5.0, 6.0, 7.0, 8.0],
135
+
[9.0, 10.0, 11.0, 12.0],
136
+
[13.0, 14.0, 15.0, 16.0]
137
+
]);
138
+
139
+
// Get the first row
140
+
$row = $matrix->row(0);
141
+
// Expected result: Vec4(1.0, 2.0, 3.0, 4.0)
142
+
```
143
+
144
+
arguments
145
+
146
+
: 1. `int``$index` The index of the row to return.
147
+
148
+
returns
149
+
150
+
: `\Vec4` The row at the given index.
151
+
152
+
---
153
+
154
+
### `setRow`
155
+
156
+
Sets the row at the given index to the given row
157
+
158
+
```php
159
+
function setRow(int $index, \GL\Math\Vec4 $row) : void
160
+
```
161
+
162
+
Example usage:
163
+
```php
164
+
$matrix = new Mat4();
165
+
$row = new Vec4(1, 2, 3, 4);
166
+
$matrix->setRow(0, $row);
167
+
```
168
+
169
+
arguments
170
+
171
+
: 1. `int``$index` The index of the row to set.
172
+
2. `\Vec4``$row` The row to set.
173
+
174
+
returns
175
+
176
+
: `void`
177
+
178
+
---
179
+
180
+
### `col`
181
+
182
+
Returns the column at the given index.
183
+
184
+
```php
185
+
function col(int $index) : \GL\Math\Vec4
186
+
```
187
+
188
+
This method retrieves a column from the matrix at the specified index and returns it as a Vec4 object.
189
+
190
+
Example:
191
+
```php
192
+
$matrix = new Mat4([
193
+
[1.0, 2.0, 3.0, 4.0],
194
+
[5.0, 6.0, 7.0, 8.0],
195
+
[9.0, 10.0, 11.0, 12.0],
196
+
[13.0, 14.0, 15.0, 16.0]
197
+
]);
198
+
199
+
$col = $matrix->col(0);
200
+
201
+
// Returns Vec4(1.0, 5.0, 9.0, 13.0)
202
+
```
203
+
204
+
arguments
205
+
206
+
: 1. `int``$index` The index of the column to return.
207
+
208
+
returns
209
+
210
+
: `\Vec4` The column at the given index.
211
+
212
+
---
213
+
214
+
### `setCol`
215
+
216
+
Sets the column at the given index to the given column
217
+
218
+
```php
219
+
function setCol(int $index, \GL\Math\Vec4 $col) : void
220
+
```
221
+
222
+
```php
223
+
// Create a new matrix and set the second column
224
+
$matrix = new Mat4();
225
+
$col = new Vec4(1, 2, 3, 4);
226
+
$matrix->setCol(1, $col);
227
+
```
228
+
229
+
arguments
230
+
231
+
: 1. `int``$index` The index of the column to set.
232
+
2. `\Vec4``$col` The column to set.
233
+
234
+
returns
235
+
236
+
: `void`
237
+
238
+
---
239
+
240
+
### `lookAt`
241
+
242
+
Sets the matrix to a lookAt matrix
243
+
244
+
```php
245
+
function lookAt(\GL\Math\Vec3 $eye, \GL\Math\Vec3 $center, \GL\Math\Vec3 $up) : void
246
+
```
247
+
248
+
The `lookAt()` method sets the matrix to a lookAt matrix based on the camera's position and orientation.
249
+
It takes three parameters: `$eye`, `$center`, and `$up`, which are all instances of the `Vec3` class.
250
+
251
+
The `$eye` parameter indicates the position of the camera, while `$center` indicates the point
252
+
in space to look at. The `$up` parameter specifies the up vector, which determines the orientation of the camera.
253
+
254
+
Example usage:
255
+
256
+
```php
257
+
// Create a new matrix
258
+
$matrix = new Mat4();
259
+
260
+
// Set the matrix to a lookAt matrix
261
+
$matrix->lookAt(
262
+
new Vec3(0, 0, 5), // eye
263
+
new Vec3(0, 0, 0), // center
264
+
new Vec3(0, 1, 0) // up
265
+
);
266
+
```
267
+
268
+
This will create a new matrix and set it to a lookAt matrix with the camera positioned at `(0, 0, 5)`,
269
+
looking at the origin `(0, 0, 0)`, with the up vector pointing in the positive y direction.
0 commit comments