numerix 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +18 -0
  3. data/.travis.yml +5 -0
  4. data/.yardopts +5 -0
  5. data/CODE_OF_CONDUCT.md +74 -0
  6. data/Gemfile +6 -0
  7. data/LICENSE.txt +21 -0
  8. data/README.md +66 -0
  9. data/Rakefile +18 -0
  10. data/TODO.txt +25 -0
  11. data/bin/console +14 -0
  12. data/bin/setup +8 -0
  13. data/ext/numerix/common.h +107 -0
  14. data/ext/numerix/extconf.rb +3 -0
  15. data/ext/numerix/matrix3x2.c +638 -0
  16. data/ext/numerix/matrix3x2.h +52 -0
  17. data/ext/numerix/matrix4x4.c +1807 -0
  18. data/ext/numerix/matrix4x4.h +90 -0
  19. data/ext/numerix/matrix_base.c +307 -0
  20. data/ext/numerix/matrix_base.h +70 -0
  21. data/ext/numerix/numerix.c +33 -0
  22. data/ext/numerix/numerix.h +19 -0
  23. data/ext/numerix/plane.c +311 -0
  24. data/ext/numerix/plane.h +34 -0
  25. data/ext/numerix/quaternion.c +712 -0
  26. data/ext/numerix/quaternion.h +53 -0
  27. data/ext/numerix/structure.c +154 -0
  28. data/ext/numerix/structure.h +24 -0
  29. data/ext/numerix/vector.c +326 -0
  30. data/ext/numerix/vector.h +57 -0
  31. data/ext/numerix/vector2.c +641 -0
  32. data/ext/numerix/vector2.h +64 -0
  33. data/ext/numerix/vector3.c +805 -0
  34. data/ext/numerix/vector3.h +68 -0
  35. data/ext/numerix/vector4.c +727 -0
  36. data/ext/numerix/vector4.h +63 -0
  37. data/ext/numerix/vector_base.c +94 -0
  38. data/ext/numerix/vector_base.h +30 -0
  39. data/extra/numerix128.png +0 -0
  40. data/extra/numerix24.png +0 -0
  41. data/extra/numerix32.png +0 -0
  42. data/extra/numerix320.png +0 -0
  43. data/extra/numerix48.png +0 -0
  44. data/extra/numerix96.png +0 -0
  45. data/lib/numerix/error.rb +36 -0
  46. data/lib/numerix/matrix3x2.rb +420 -0
  47. data/lib/numerix/matrix4x4.rb +676 -0
  48. data/lib/numerix/matrix_base.rb +14 -0
  49. data/lib/numerix/plane.rb +154 -0
  50. data/lib/numerix/quaternion.rb +355 -0
  51. data/lib/numerix/structure.rb +124 -0
  52. data/lib/numerix/vector.rb +13 -0
  53. data/lib/numerix/vector2.rb +534 -0
  54. data/lib/numerix/vector3.rb +572 -0
  55. data/lib/numerix/vector4.rb +551 -0
  56. data/lib/numerix/vector_base.rb +14 -0
  57. data/lib/numerix/version.rb +6 -0
  58. data/lib/numerix.rb +10 -0
  59. data/numerix.gemspec +30 -0
  60. metadata +167 -0
@@ -0,0 +1,676 @@
1
+ module Numerix
2
+
3
+ ##
4
+ # A structure encapsulating a 4x4 matrix.
5
+ class Matrix4x4 < MatrixBase
6
+
7
+ ##
8
+ # @return [Float] Value at row 1, column 1 of the matrix.
9
+ attr_accessor :m11
10
+
11
+ ##
12
+ # @return [Float] Value at row 1, column 2 of the matrix.
13
+ attr_accessor :m12
14
+
15
+ ##
16
+ # @return [Float] Value at row 1, column 3 of the matrix.
17
+ attr_accessor :m13
18
+
19
+ ##
20
+ # @return [Float] Value at row 1, column 4 of the matrix.
21
+ attr_accessor :m14
22
+
23
+ ##
24
+ # @return [Float] Value at row 2, column 1 of the matrix.
25
+ attr_accessor :m21
26
+
27
+ ##
28
+ # @return [Float] Value at row 2, column 2 of the matrix.
29
+ attr_accessor :m22
30
+
31
+ ##
32
+ # @return [Float] Value at row 2, column 3 of the matrix.
33
+ attr_accessor :m23
34
+
35
+ ##
36
+ # @return [Float] Value at row 2, column 4 of the matrix.
37
+ attr_accessor :m24
38
+
39
+ ##
40
+ # @return [Float] Value at row 3, column 1 of the matrix.
41
+ attr_accessor :m31
42
+
43
+ ##
44
+ # @return [Float] Value at row 3, column 2 of the matrix.
45
+ attr_accessor :m32
46
+
47
+ ##
48
+ # @return [Float] Value at row 3, column 3 of the matrix.
49
+ attr_accessor :m33
50
+
51
+ ##
52
+ # @return [Float] Value at row 3, column 4 of the matrix.
53
+ attr_accessor :m34
54
+
55
+ ##
56
+ # @return [Float] Value at row 4, column 1 of the matrix.
57
+ attr_accessor :m41
58
+
59
+ ##
60
+ # @return [Float] Value at row 4, column 2 of the matrix.
61
+ attr_accessor :m42
62
+
63
+ ##
64
+ # @return [Float] Value at row 4, column 3 of the matrix.
65
+ attr_accessor :m43
66
+
67
+ ##
68
+ # @return [Float] Value at row 4, column 4 of the matrix.
69
+ attr_accessor :m44
70
+
71
+ ##
72
+ # @return [Vector3] the translation component of this matrix.
73
+ attr_accessor :translation
74
+
75
+ ##
76
+ # @overload initialize
77
+ # Constructs a default matrix with all values set to `0.0`.
78
+ #
79
+ # @overload initialize(matrix)
80
+ # Constructs a Matrix4x4 from the given {Matrix3x2}.
81
+ #
82
+ # @param matrix [Matrix3x3] The source matrix.
83
+ #
84
+ # @overload initialize(value)
85
+ # Constructs a matrix from a single component value.
86
+ #
87
+ # @param value [Float] Value to applied to all components.
88
+ #
89
+ # @overload initialize(m11, m12, m13, m14, m21, m22, m23, m24, m31, m32, m33, m34, m41, m42, m43, m44)
90
+ # Constructs a matrix from the given components.
91
+ #
92
+ # @param m11 [Float] Value at row 1, column 1 of the matrix.
93
+ # @param m12 [Float] Value at row 1, column 2 of the matrix.
94
+ # @param m13 [Float] Value at row 1, column 3 of the matrix.
95
+ # @param m14 [Float] Value at row 1, column 4 of the matrix.
96
+ # @param m21 [Float] Value at row 2, column 1 of the matrix.
97
+ # @param m22 [Float] Value at row 2, column 2 of the matrix.
98
+ # @param m23 [Float] Value at row 2, column 3 of the matrix.
99
+ # @param m24 [Float] Value at row 2, column 4 of the matrix.
100
+ # @param m31 [Float] Value at row 3, column 1 of the matrix.
101
+ # @param m32 [Float] Value at row 3, column 2 of the matrix.
102
+ # @param m33 [Float] Value at row 3, column 3 of the matrix.
103
+ # @param m34 [Float] Value at row 3, column 4 of the matrix.
104
+ # @param m41 [Float] Value at row 4, column 1 of the matrix.
105
+ # @param m42 [Float] Value at row 4, column 2 of the matrix.
106
+ # @param m43 [Float] Value at row 4, column 3 of the matrix.
107
+ # @param m44 [Float] Value at row 4, column 4 of the matrix.
108
+ #
109
+ def initialize(*args)
110
+ end
111
+
112
+ ##
113
+ # The equivalent of `Enumerable#map`, but returns a matrix object instead of
114
+ # an Array.
115
+ #
116
+ # Invokes the given block once for each element of `self`.
117
+ #
118
+ # Creates a new matrix containing the values returned by the block.
119
+ #
120
+ # @yield [component] Yields a component of the matrix to the block.
121
+ # @yieldparam component [Float] The yielded component.
122
+ #
123
+ # @return [Matrix4x4]
124
+ #
125
+ # @see map!
126
+ def map
127
+ end
128
+
129
+ ##
130
+ # Invokes the given block once for each element of self, replacing the
131
+ # element with the value returned by the block.
132
+ #
133
+ # The values of the matrix are altered without creating a ne object.
134
+ #
135
+ # @yield [component] Yields a component of the matrix to the block.
136
+ # @yieldparam component [Float] The yielded component.
137
+ #
138
+ # @return [self]
139
+ #
140
+ # @see map
141
+ def map!
142
+ end
143
+
144
+ alias_method :collect, :map
145
+ alias_method :collect!, :map!
146
+
147
+ ##
148
+ # Raises the matrix to the given power.
149
+ #
150
+ # @param exponent [Float] The power to raise the matrix to.
151
+ #
152
+ # @return [Matrix4x4] New matrix that is result of the operation.
153
+ def **(exponent)
154
+ end
155
+
156
+ ##
157
+ # @return [Boolean] `true` if the matrix is the identity matrix, otherwise
158
+ # `false`.
159
+ def identity?
160
+ end
161
+
162
+ ##
163
+ # Calculates the determinant for this matrix.
164
+ #
165
+ # The determinant is calculated by expanding the matrix with a third column
166
+ # whose values are (0,0,1).
167
+ #
168
+ # @return [Float] the determinant.
169
+ def determinant
170
+ end
171
+
172
+ ##
173
+ # Returns the specified matrix row as an array.
174
+ #
175
+ # @param index [Integer] The row index to retrieve.
176
+ #
177
+ # @return [Array<Float>, nil] the requested row, or `nil` if index is out of
178
+ # range.
179
+ #
180
+ # @see column
181
+ def row(index)
182
+ end
183
+
184
+ ##
185
+ # Returns the specified matrix column as an array.
186
+ #
187
+ # @param index [Integer] The column index to retrieve.
188
+ #
189
+ # @return [Array<Float>, nil] the requested column, or `nil` if index is out
190
+ # of range.
191
+ #
192
+ # @see row
193
+ def column(index)
194
+ end
195
+
196
+ ##
197
+ # Enumerates the rows of the matrix.
198
+ #
199
+ # @yield [row] Yields a row to the block.
200
+ # @yieldparam row [Array<Float>] The current row as an array.
201
+ #
202
+ # @return [self]
203
+ #
204
+ # see each_column
205
+ def each_row
206
+ end
207
+
208
+ ##
209
+ # Enumerates the columns of the matrix.
210
+ #
211
+ # @yield [column] Yields a column to the block.
212
+ # @yieldparam column [Array<Float>] The current column as an array.
213
+ #
214
+ # @return [self]
215
+ #
216
+ # @see each_row
217
+ def each_column
218
+ end
219
+
220
+ ##
221
+ # Linearly interpolates from this matrix to another, based on the amount.
222
+ #
223
+ # @param matrix [Matrix4x4] The source matrix to interpolate between.
224
+ # @param amount [Float] The relative weighting of the given matrix, clamped
225
+ # between `0.0` and `1.0`.
226
+ #
227
+ # @return [Matrix4x4] a newly created interpolated matrix.
228
+ #
229
+ # @see lerp!
230
+ def lerp(matrix, amount)
231
+ end
232
+
233
+ ##
234
+ # @note This method is the same as {#lerp}, but alters the values of this
235
+ # matrix instead of creating a new instance.
236
+ #
237
+ # Linearly interpolates from this matrix to another, based on the amount.
238
+ #
239
+ # @param matrix [Matrix4x4] The source matrix to interpolate between.
240
+ # @param amount [Float] The relative weighting of the given matrix, clamped
241
+ # between `0.0` and `1.0`.
242
+ #
243
+ # @return [self]
244
+ #
245
+ # @see lerp
246
+ def lerp!(matrix, amount)
247
+ end
248
+
249
+ ##
250
+ # @return [String] a String representation of this instance.
251
+ def to_s
252
+ end
253
+
254
+ ##
255
+ # @return [Array<Array<Float>>] an Array representation of this instance.
256
+ def to_a
257
+ end
258
+
259
+ alias_method :elements, :to_a
260
+
261
+ ##
262
+ # @return [Hash{Symbol => Float}] a Hash representation of this instance.
263
+ def to_h
264
+ end
265
+
266
+ ##
267
+ # Negates the given matrix by multiplying all values by `-1.0`.
268
+ #
269
+ # @return [Matrix4x4] the negated matrix.
270
+ def -@
271
+ end
272
+
273
+ ##
274
+ # Adds each matrix element in value1 with its corresponding element in the
275
+ # specified matrix.
276
+ #
277
+ # @param other [Matrix4x4] The matrix to add.
278
+ #
279
+ # @return [Matrix4x4] A matrix containing the summed values.
280
+ def +(other)
281
+ end
282
+
283
+ ##
284
+ # Subtracts each matrix element in the specified matrix from its
285
+ # corresponding element in this matrix to form a new matrix of the
286
+ # difference.
287
+ #
288
+ # @param other [Matrix4x4] The matrix to subtract.
289
+ #
290
+ # @return [Matrix4x4] The matrix containing the resulting values.
291
+ def -(other)
292
+ end
293
+
294
+ ##
295
+ # Multiplies this matrix by the specified value.
296
+ #
297
+ # @overload *(scalar)
298
+ # Scales all elements in a matrix by the given scalar factor.
299
+ #
300
+ # @param scalar [Float] The scaling value to use.
301
+ #
302
+ # @overload *(other)
303
+ # Multiplies two matrices together and returns the resulting matrix.
304
+ #
305
+ # @param other [Matrix4x4] The source matrix to multiply.
306
+ #
307
+ # @return [Matrix4x4] the product matrix.
308
+ def *(other)
309
+ end
310
+
311
+ ##
312
+ # Returns flag if this matrix instance is equal to the given object.
313
+ #
314
+ # @param other [Object] The object to compare.
315
+ #
316
+ # @return [Boolean] `true` if objects are equal, otherwise `false`.
317
+ def ==(other)
318
+ end
319
+
320
+ ##
321
+ # Accesses the matrix component using the zero-based row/column indices.
322
+ #
323
+ # @param row [Integer] The zero-based row index.
324
+ # @param column [Integer] The zero-based column index.
325
+ #
326
+ # @return [Float, nil] the value at the specified location, or `nil` if an
327
+ # index is out of range.
328
+ def [](row, column)
329
+ end
330
+
331
+ ##
332
+ # Sets the matrix component using the zero-based row/column indices.
333
+ #
334
+ # @param row [Integer] The zero-based row index.
335
+ # @param column [Integer] The zero-based column index.
336
+ # @param value [Float] The value to set.
337
+ #
338
+ # @return [Float] the value.
339
+ def []=(row, column, value)
340
+ end
341
+
342
+ ##
343
+ # Attempts to invert the given matrix.
344
+ #
345
+ # @note Some matrices cannot be inverted, in which case the returned matrix
346
+ # will have all values set to `NaN`.
347
+ #
348
+ # @return [Matrix4x4] A new matrix that is this matrix inverted.
349
+ def invert
350
+ end
351
+
352
+ ##
353
+ # Creates a matrix by transforming this instance by applying the given
354
+ # quaternion rotation.
355
+ #
356
+ # @param rotation [Quaternion] The rotation to apply.
357
+ #
358
+ # @return [Matrix4x4] a transformed matrix.
359
+ def transform(rotation)
360
+ end
361
+
362
+ ##
363
+ # Transforms this matrix by applying the given quaternion rotation.
364
+ #
365
+ # @param rotation [Quaternion] The rotation to apply.
366
+ #
367
+ # @return [self]
368
+ def transform!(rotation)
369
+ end
370
+
371
+ ##
372
+ # Transposes the rows and columns of a matrix.
373
+ #
374
+ # @return [Matrix4x4] a transposed matrix.
375
+ def transpose
376
+ end
377
+
378
+ class << self
379
+
380
+ ##
381
+ # @return [Matrix4x4] the multiplicative identity matrix.
382
+ def identity
383
+ end
384
+
385
+ ##
386
+ # Creates a spherical billboard that rotates around a specified object
387
+ # position.
388
+ #
389
+ # @param position [Vector3] Position of the object the billboard will
390
+ # rotate around.
391
+ # @param camera [Vector3] Position of the camera.
392
+ # @param up [Vector3] The up vector of the camera.
393
+ # @param forward [Vector3] The forward vector of the camera.
394
+ #
395
+ # @return [Matrix4x4] the created billboard matrix.
396
+ def create_billboard(position, camera, up, forward)
397
+ end
398
+
399
+ ##
400
+ # Creates a cylindrical billboard that rotates around a specified axis.
401
+ #
402
+ # @param position [Vector3] Position of the object the billboard will
403
+ # rotate around.
404
+ # @param camera [Vector3] Position of the camera.
405
+ # @param axis [Vector3] Axis to rotate the billboard around.
406
+ # @param cam_forward [Vector3] Forward vector of the camera.
407
+ # @param obj_forward [Vector3] Forward vector of the object.
408
+ #
409
+ # @return [Matrix4x4] the created billboard matrix.
410
+ def create_constrained_billboard(position, camera, axis, cam_forward, obj_forward)
411
+ end
412
+
413
+ ##
414
+ # Creates a translation matrix.
415
+ #
416
+ # @overload create_translation(position)
417
+ # @param position [Vector3] The amount to translate in each axis.
418
+ #
419
+ # @overload create_translation(x, y, z)
420
+ # @param x [Float] The amount to translate on the X-axis.
421
+ # @param y [Float] The amount to translate on the Y-axis.
422
+ # @param z [Float] The amount to translate on the Z-axis.
423
+ #
424
+ # @return [Matrix4x4] the translation matrix.
425
+ def create_translation
426
+ end
427
+
428
+ ##
429
+ # Creates a scaling matrix.
430
+ #
431
+ # @overload create_scale(x, y, z)
432
+ # @param x [Float] Value to scale by on the X-axis.
433
+ # @param y [Float] Value to scale by on the Y-axis.
434
+ # @param z [Float] Value to scale by on the Z-axis.
435
+ #
436
+ # @overload create_scale(x, y, z, center)
437
+ # @param x [Float] Value to scale by on the X-axis.
438
+ # @param y [Float] Value to scale by on the Y-axis.
439
+ # @param z [Float] Value to scale by on the Z-axis.
440
+ # @param center [Vector3] The center point.
441
+ #
442
+ # @overload create_scale(scales)
443
+ # @param scales [Vector3] The vector containing the amount to scale by
444
+ # on each axis.
445
+ #
446
+ # @overload create_scale(scales, center)
447
+ # @param scales [Vector3] The vector containing the amount to scale by
448
+ # on each axis.
449
+ # @param center [Vector3] The center point.
450
+ #
451
+ # @overload create_scale(scale)
452
+ # @param scale [Float] The uniform scaling factor.
453
+ #
454
+ # @overload create_scale(scale, center)
455
+ # @param scale [Float] The uniform scaling factor.
456
+ # @param center [Vector3] The center point.
457
+ #
458
+ # @return [Matrix4x4] the scaling matrix.
459
+ def create_scale
460
+ end
461
+
462
+ ##
463
+ # Creates a matrix for rotating points around the X-axis.
464
+ #
465
+ # @overload create_rotation_x(radians)
466
+ # @param radians [Float] The amount, in radians, by which to rotate
467
+ # around the X-axis.
468
+ #
469
+ # @overload create_rotation_x(radians, center)
470
+ # @param radians [Float] The amount, in radians, by which to rotate
471
+ # around the X-axis.
472
+ # @param center [Vector3] The center point.
473
+ #
474
+ # @return [Matrix4x4] the rotation matrix.
475
+ def create_rotation_x
476
+ end
477
+
478
+ ##
479
+ # Creates a matrix for rotating points around the Y-axis.
480
+ #
481
+ # @overload create_rotation_y(radians)
482
+ # @param radians [Float] The amount, in radians, by which to rotate
483
+ # around the Y-axis.
484
+ #
485
+ # @overload create_rotation_y(radians, center)
486
+ # @param radians [Float] The amount, in radians, by which to rotate
487
+ # around the Y-axis.
488
+ # @param center [Vector3] The center point.
489
+ #
490
+ # @return [Matrix4x4] the rotation matrix.
491
+ def create_rotation_y
492
+ end
493
+
494
+ ##
495
+ # Creates a matrix for rotating points around the Z-axis.
496
+ #
497
+ # @overload create_rotation_z(radians)
498
+ # @param radians [Float] The amount, in radians, by which to rotate
499
+ # around the Z-axis.
500
+ #
501
+ # @overload create_rotation_z(radians, center)
502
+ # @param radians [Float] The amount, in radians, by which to rotate
503
+ # around the Z-axis.
504
+ # @param center [Vector3] The center point.
505
+ #
506
+ # @return [Matrix4x4] the rotation matrix.
507
+ def create_rotation_z
508
+ end
509
+
510
+ ##
511
+ # Creates a perspective projection matrix based on a field of view, aspect
512
+ # ratio, and near and far view plane distances.
513
+ #
514
+ # @param fov [Float] Field of view in the y direction, in radians.
515
+ # @param ratio [Float] Aspect ratio, defined as view space width divided
516
+ # by height.
517
+ # @param near [Float] Distance to the near view plane.
518
+ # @param far [Float] Distance to the far view plane.
519
+ #
520
+ # @return [Vector3] the perspective projection matrix.
521
+ def create_perspective_fov(fov, ratio, near, far)
522
+ end
523
+
524
+ ##
525
+ # Creates a perspective projection matrix from the given view volume
526
+ # dimensions.
527
+ #
528
+ # @param width [Float] Width of the view volume at the near view plane.
529
+ # @param height [Float] Height of the view volume at the near view plane.
530
+ # @param near [Float] Distance to the near view plane.
531
+ # @param far [Float] Distance to the far view plane.
532
+ #
533
+ # @return [Vector3] the perspective projection matrix.
534
+ def create_perspective(width, height, near, far)
535
+ end
536
+
537
+ ##
538
+ # Creates a customized, perspective projection matrix.
539
+ #
540
+ # @param left [Float] Minimum x-value of the view volume at the near view
541
+ # plane.
542
+ # @param right [Float] Maximum x-value of the view volume at the near view
543
+ # plane.
544
+ # @param bottom [Float] Minimum y-value of the view volume at the near
545
+ # view plane.
546
+ # @param top [Float] Maximum y-value of the view volume at the near view
547
+ # plane.
548
+ # @param near [Float] Distance to the near view plane.
549
+ # @param far [Float] Distance to the far view plane.
550
+ #
551
+ # @return [Vector3] the perspective projection matrix.
552
+ def create_perspective_off_center(left, right, bottom, top, near, far)
553
+ end
554
+
555
+ ##
556
+ # Creates an orthographic perspective matrix from the given view volume
557
+ # dimensions.
558
+ #
559
+ # @param width [Float] Width of the view volume.
560
+ # @param height [Float] Height of the view volume.
561
+ # @param near [Float] Minimum Z-value of the view volume.
562
+ # @param far [Float] Maximum Z-value of the view volume.
563
+ #
564
+ # @return [Matrix4x4] the orthographic projection matrix.
565
+ def create_orthographic(width, height, near, far)
566
+ end
567
+
568
+ ##
569
+ # Builds a customized, orthographic projection matrix.
570
+ #
571
+ # @param left [Float] Minimum X-value of the view volume.
572
+ # @param right [Float] Maximum X-value of the view volume.
573
+ # @param bottom [Float] Minimum Y-value of the view volume.
574
+ # @param top [Float] Maximum Y-value of the view volume.
575
+ # @param near [Float] Minimum Z-value of the view volume.
576
+ # @param far [Float] Maximum Z-value of the view volume.
577
+ #
578
+ # @return [Matrix4x4] the orthographic projection matrix.
579
+ def create_orthographic_off_center(left, right, bottom, top, near, far)
580
+ end
581
+
582
+ ##
583
+ # Creates a view matrix.
584
+ #
585
+ # @param camera [Vector3] The position of the camera.
586
+ # @param target [Vector3] The target towards which the camera is pointing.
587
+ # @param up [Vector3] The direction that is "up" from the camera's point
588
+ # of view.
589
+ #
590
+ # @return [Matrix4x4] The view matrix.
591
+ def create_look_at(camera, target, up)
592
+ end
593
+
594
+ ##
595
+ # Creates a world matrix with the specified parameters.
596
+ #
597
+ # @param position [Vector3] The position of the object; used in
598
+ # translation operations.
599
+ # @param forward [Vector3] Forward direction of the object.
600
+ # @param up [Vector3] Upward direction of the object; usually
601
+ # `<0.0, 1.0, 0.0>`.
602
+ #
603
+ # @return [Matrix4x4] the world matrix.
604
+ def create_world(position, forward, up)
605
+ end
606
+
607
+ ##
608
+ # Creates a Matrix that flattens geometry into a specified Plane as if
609
+ # casting a shadow from a specified light source.
610
+ #
611
+ # @param direction [Vector3] The direction from which the light that will
612
+ # cast the shadow is coming.
613
+ # @param plane [Plane] he Plane onto which the new matrix should flatten
614
+ # geometry so as to cast a shadow.
615
+ #
616
+ # @return [Matrix4x4] A new Matrix that can be used to flatten geometry
617
+ # onto the specified plane from the specified direction.
618
+ def create_shadow(direction, plane)
619
+ end
620
+
621
+ ##
622
+ # Creates a Matrix that reflects the coordinate system about a specified
623
+ # plane.
624
+ #
625
+ # @param plane [Plane] The plane about which to create a reflection.
626
+ #
627
+ # @return [Matrix4x4] a new matrix expressing the reflection.
628
+ def create_reflection(plane)
629
+ end
630
+
631
+ ##
632
+ # Creates a matrix that rotates around an arbitrary vector.
633
+ #
634
+ # @param axis [Vector3] The axis to rotate around.
635
+ # @param angle [Float] The angle to rotate around the given axis, in
636
+ # radians.
637
+ #
638
+ # @return [Matrix4x4] the rotation matrix.
639
+ def from_axis_angle(axis, angle)
640
+ end
641
+
642
+ ##
643
+ # Creates a rotation matrix from the given quaternion rotation value.
644
+ #
645
+ # @param quaternion [Quaternion] The source quaternion.
646
+ #
647
+ # @return [Matrix4x4] the rotation matrix.
648
+ def from_quaternion(quaternion)
649
+ end
650
+
651
+ ##
652
+ # Creates a rotation matrix from the specified yaw, pitch, and roll.
653
+ #
654
+ # @param yaw [Float] Angle of rotation, in radians, around the Y-axis.
655
+ # @param pitch [Float] Angle of rotation, in radians, around the X-axis.
656
+ # @param roll [Float] Angle of rotation, in radians, around the Z-axis.
657
+ #
658
+ # @return [Matrix4x4] the rotation matrix.
659
+ def from_yaw_pitch_roll(yaw, pitch, roll)
660
+ end
661
+
662
+ ##
663
+ # Linearly interpolates from _matrix1_ to _matrix2_, based on the third
664
+ # parameter.
665
+ #
666
+ # @param matrix1 [Matrix4x4] The first source matrix.
667
+ # @param matrix2 [Matrix4x4] The second source matrix.
668
+ # @param amount [Float] The relative weighting of _matrix2_, clamped
669
+ # between `0.0` and `1.0`.
670
+ #
671
+ # @return [Matrix4x4] the interpolated matrix.
672
+ def lerp(matrix1, matrix2, amount)
673
+ end
674
+ end
675
+ end
676
+ end
@@ -0,0 +1,14 @@
1
+ module Numerix
2
+
3
+ ##
4
+ # @abstract Abstract base class for matrix classes.
5
+ #
6
+ # This class cannot be instantiated, it of only for providing a common base
7
+ # class for matrix types.
8
+ class MatrixBase < Structure
9
+
10
+ private_class_method :new
11
+
12
+ include Enumerable
13
+ end
14
+ end