numerix 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +18 -0
- data/.travis.yml +5 -0
- data/.yardopts +5 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +6 -0
- data/LICENSE.txt +21 -0
- data/README.md +66 -0
- data/Rakefile +18 -0
- data/TODO.txt +25 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/ext/numerix/common.h +107 -0
- data/ext/numerix/extconf.rb +3 -0
- data/ext/numerix/matrix3x2.c +638 -0
- data/ext/numerix/matrix3x2.h +52 -0
- data/ext/numerix/matrix4x4.c +1807 -0
- data/ext/numerix/matrix4x4.h +90 -0
- data/ext/numerix/matrix_base.c +307 -0
- data/ext/numerix/matrix_base.h +70 -0
- data/ext/numerix/numerix.c +33 -0
- data/ext/numerix/numerix.h +19 -0
- data/ext/numerix/plane.c +311 -0
- data/ext/numerix/plane.h +34 -0
- data/ext/numerix/quaternion.c +712 -0
- data/ext/numerix/quaternion.h +53 -0
- data/ext/numerix/structure.c +154 -0
- data/ext/numerix/structure.h +24 -0
- data/ext/numerix/vector.c +326 -0
- data/ext/numerix/vector.h +57 -0
- data/ext/numerix/vector2.c +641 -0
- data/ext/numerix/vector2.h +64 -0
- data/ext/numerix/vector3.c +805 -0
- data/ext/numerix/vector3.h +68 -0
- data/ext/numerix/vector4.c +727 -0
- data/ext/numerix/vector4.h +63 -0
- data/ext/numerix/vector_base.c +94 -0
- data/ext/numerix/vector_base.h +30 -0
- data/extra/numerix128.png +0 -0
- data/extra/numerix24.png +0 -0
- data/extra/numerix32.png +0 -0
- data/extra/numerix320.png +0 -0
- data/extra/numerix48.png +0 -0
- data/extra/numerix96.png +0 -0
- data/lib/numerix/error.rb +36 -0
- data/lib/numerix/matrix3x2.rb +420 -0
- data/lib/numerix/matrix4x4.rb +676 -0
- data/lib/numerix/matrix_base.rb +14 -0
- data/lib/numerix/plane.rb +154 -0
- data/lib/numerix/quaternion.rb +355 -0
- data/lib/numerix/structure.rb +124 -0
- data/lib/numerix/vector.rb +13 -0
- data/lib/numerix/vector2.rb +534 -0
- data/lib/numerix/vector3.rb +572 -0
- data/lib/numerix/vector4.rb +551 -0
- data/lib/numerix/vector_base.rb +14 -0
- data/lib/numerix/version.rb +6 -0
- data/lib/numerix.rb +10 -0
- data/numerix.gemspec +30 -0
- metadata +167 -0
@@ -0,0 +1,90 @@
|
|
1
|
+
#ifndef NUMERIX_MATRIX4X4_H
|
2
|
+
#define NUMERIX_MATRIX4X4_H 1
|
3
|
+
|
4
|
+
#include "common.h"
|
5
|
+
#include "matrix_base.h"
|
6
|
+
#include "plane.h"
|
7
|
+
#include "quaternion.h"
|
8
|
+
|
9
|
+
#define MATRIX4X4() \
|
10
|
+
Matrix4x4 *m; \
|
11
|
+
Data_Get_Struct(self, Matrix4x4, m)
|
12
|
+
|
13
|
+
typedef struct CanonicalBasis {
|
14
|
+
Vector3 row0;
|
15
|
+
Vector3 row1;
|
16
|
+
Vector3 row2;
|
17
|
+
} CanonicalBasis;
|
18
|
+
|
19
|
+
typedef struct VectorBasis {
|
20
|
+
Vector3 *element0;
|
21
|
+
Vector3 *element1;
|
22
|
+
Vector3 *element2;
|
23
|
+
} VectorBasis;
|
24
|
+
|
25
|
+
void Init_matrix4x4(VALUE outer);
|
26
|
+
static VALUE rb_matrix4x4_allocate(VALUE klass);
|
27
|
+
VALUE rb_matrix4x4_initialize(int argc, VALUE *argv, VALUE self);
|
28
|
+
|
29
|
+
// Instance
|
30
|
+
VALUE rb_matrix4x4_identity_p(VALUE self);
|
31
|
+
VALUE rb_matrix4x4_translation(VALUE self);
|
32
|
+
VALUE rb_matrix4x4_translation_set(VALUE self, VALUE value);
|
33
|
+
VALUE rb_matrix4x4_determinant(VALUE self);
|
34
|
+
VALUE rb_matrix4x4_add(VALUE self, VALUE other);
|
35
|
+
VALUE rb_matrix4x4_subtract(VALUE self, VALUE other);
|
36
|
+
VALUE rb_matrix4x4_multiply(VALUE self, VALUE other);
|
37
|
+
VALUE rb_matrix4x4_negate(VALUE self);
|
38
|
+
VALUE rb_matrix4x4_equal(VALUE self, VALUE other);
|
39
|
+
VALUE rb_matrix4x4_pow(VALUE self, VALUE exponent);
|
40
|
+
VALUE rb_matrix4x4_row(VALUE self, VALUE row);
|
41
|
+
VALUE rb_matrix4x4_column(VALUE self, VALUE column);
|
42
|
+
VALUE rb_matrix4x4_each_row(VALUE self);
|
43
|
+
VALUE rb_matrix4x4_each_column(VALUE self);
|
44
|
+
VALUE rb_matrix4x4_aref(int argc, VALUE *argv, VALUE self);
|
45
|
+
VALUE rb_matrix4x4_aset(int argc, VALUE *argv, VALUE self);
|
46
|
+
VALUE rb_matrix4x4_invert(VALUE self);
|
47
|
+
VALUE rb_matrix4x4_transform(VALUE self, VALUE quaternion);
|
48
|
+
VALUE rb_matrix4x4_transform_bang(VALUE self, VALUE quaternion);
|
49
|
+
VALUE rb_matrix4x4_transpose(VALUE self);
|
50
|
+
VALUE rb_matrix4x4_lerp(VALUE self, VALUE other, VALUE amount);
|
51
|
+
VALUE rb_matrix4x4_lerp_bang(VALUE self, VALUE other, VALUE amount);
|
52
|
+
VALUE rb_matrix4x4_map(VALUE self);
|
53
|
+
VALUE rb_matrix4x4_map_bang(VALUE self);
|
54
|
+
|
55
|
+
// Conversion
|
56
|
+
VALUE rb_matrix4x4_to_s(VALUE self);
|
57
|
+
VALUE rb_matrix4x4_to_a(VALUE self);
|
58
|
+
VALUE rb_matrix4x4_to_h(VALUE self);
|
59
|
+
// TODO to_mat3x2
|
60
|
+
|
61
|
+
// // Class
|
62
|
+
VALUE rb_matrix4x4_identity(VALUE klass);
|
63
|
+
VALUE rb_matrix4x4_create_billboard(VALUE klass, VALUE position, VALUE camera, VALUE up, VALUE forward);
|
64
|
+
VALUE rb_matrix4x4_create_constrained_billboard(VALUE klass, VALUE position, VALUE rotate, VALUE camera, VALUE up, VALUE forward);
|
65
|
+
VALUE rb_matrix4x4_create_translation(int argc, VALUE *argv, VALUE klass);
|
66
|
+
VALUE rb_matrix4x4_create_scale(int argc, VALUE *argv, VALUE klass);
|
67
|
+
VALUE rb_matrix4x4_create_rotation_x(int argc, VALUE *argv, VALUE klass);
|
68
|
+
VALUE rb_matrix4x4_create_rotation_y(int argc, VALUE *argv, VALUE klass);
|
69
|
+
VALUE rb_matrix4x4_create_rotation_z(int argc, VALUE *argv, VALUE klass);
|
70
|
+
VALUE rb_matrix4x4_from_axis_angle(VALUE klass, VALUE axis, VALUE angle);
|
71
|
+
VALUE rb_matrix4x4_create_perspective_fov(VALUE klass, VALUE fieldOfView, VALUE aspectRatio, VALUE nearDist, VALUE farDist);
|
72
|
+
VALUE rb_matrix4x4_create_perspective(VALUE klass, VALUE width, VALUE height, VALUE nearDist, VALUE farDist);
|
73
|
+
VALUE rb_matrix4x4_create_perspective_off_center(VALUE klass, VALUE left, VALUE right, VALUE bottom, VALUE top, VALUE nearDist, VALUE farDist);
|
74
|
+
VALUE rb_matrix4x4_create_orthographic(VALUE klass, VALUE width, VALUE height, VALUE zNearPlane, VALUE zFarPlane);
|
75
|
+
VALUE rb_matrix4x4_create_orthographic_off_center(VALUE klass, VALUE left, VALUE right, VALUE bottom, VALUE top, VALUE zNearPlane, VALUE zFarPlane);
|
76
|
+
VALUE rb_matrix4x4_create_look_at(VALUE klass, VALUE camPos, VALUE camTarget, VALUE camUp);
|
77
|
+
VALUE rb_matrix4x4_create_world(VALUE klass, VALUE position, VALUE forward, VALUE up);
|
78
|
+
VALUE rb_matrix4x4_from_quaternion(VALUE klass, VALUE quaternion);
|
79
|
+
VALUE rb_matrix4x4_from_yaw_pitch_roll(VALUE klass, VALUE yaw, VALUE pitch, VALUE roll);
|
80
|
+
VALUE rb_matrix4x4_create_shadow(VALUE klass, VALUE light, VALUE plane);
|
81
|
+
VALUE rb_matrix4x4_create_reflection(VALUE klass, VALUE plane);
|
82
|
+
VALUE rb_matrix4x4_lerp_s(VALUE klass, VALUE matrix1, VALUE matrix2, VALUE amount);
|
83
|
+
|
84
|
+
// Internal
|
85
|
+
static inline void numerix_vec3_normalize(Vector3 *v);
|
86
|
+
static inline void numerix_vec3_cross(Vector3 *v1, Vector3 *v2, Vector3 *result);
|
87
|
+
static inline float numerix_vec3_dot(Vector3 *v1, Vector3 *v2);
|
88
|
+
static inline void numerix_cross_norm(Vector3 *v1, Vector3 *v2, Vector3 *result);
|
89
|
+
|
90
|
+
#endif /* NUMERIX_MATRIX4X4_H */
|
@@ -0,0 +1,307 @@
|
|
1
|
+
|
2
|
+
#include "matrix_base.h"
|
3
|
+
|
4
|
+
VALUE rb_cMatrixBase;
|
5
|
+
VALUE rb_cMatrix3x2;
|
6
|
+
VALUE rb_cMatrix4x4;
|
7
|
+
|
8
|
+
void Init_matrix_base(VALUE outer) {
|
9
|
+
rb_cMatrixBase = rb_define_class_under(outer, "MatrixBase", rb_cNumerixStruct);
|
10
|
+
rb_cMatrix3x2 = rb_define_class_under(outer, "Matrix3x2", rb_cMatrixBase);
|
11
|
+
rb_cMatrix4x4 = rb_define_class_under(outer, "Matrix4x4", rb_cMatrixBase);
|
12
|
+
|
13
|
+
rb_define_method(rb_cMatrixBase, "initialize", rb_numerix_abstract_initialize, 0);
|
14
|
+
|
15
|
+
rb_define_method(rb_cMatrix3x2, "m11", rb_matrix3x2_m11, 0);
|
16
|
+
rb_define_method(rb_cMatrix3x2, "m12", rb_matrix3x2_m12, 0);
|
17
|
+
rb_define_method(rb_cMatrix3x2, "m21", rb_matrix3x2_m21, 0);
|
18
|
+
rb_define_method(rb_cMatrix3x2, "m22", rb_matrix3x2_m22, 0);
|
19
|
+
rb_define_method(rb_cMatrix3x2, "m31", rb_matrix3x2_m31, 0);
|
20
|
+
rb_define_method(rb_cMatrix3x2, "m32", rb_matrix3x2_m32, 0);
|
21
|
+
|
22
|
+
rb_define_method(rb_cMatrix3x2, "m11=", rb_matrix3x2_m11_set, 1);
|
23
|
+
rb_define_method(rb_cMatrix3x2, "m12=", rb_matrix3x2_m12_set, 1);
|
24
|
+
rb_define_method(rb_cMatrix3x2, "m21=", rb_matrix3x2_m21_set, 1);
|
25
|
+
rb_define_method(rb_cMatrix3x2, "m22=", rb_matrix3x2_m22_set, 1);
|
26
|
+
rb_define_method(rb_cMatrix3x2, "m31=", rb_matrix3x2_m31_set, 1);
|
27
|
+
rb_define_method(rb_cMatrix3x2, "m32=", rb_matrix3x2_m32_set, 1);
|
28
|
+
|
29
|
+
rb_define_method(rb_cMatrix4x4, "m11", rb_matrix4x4_m11, 0);
|
30
|
+
rb_define_method(rb_cMatrix4x4, "m12", rb_matrix4x4_m12, 0);
|
31
|
+
rb_define_method(rb_cMatrix4x4, "m13", rb_matrix4x4_m13, 0);
|
32
|
+
rb_define_method(rb_cMatrix4x4, "m14", rb_matrix4x4_m14, 0);
|
33
|
+
rb_define_method(rb_cMatrix4x4, "m21", rb_matrix4x4_m21, 0);
|
34
|
+
rb_define_method(rb_cMatrix4x4, "m22", rb_matrix4x4_m22, 0);
|
35
|
+
rb_define_method(rb_cMatrix4x4, "m23", rb_matrix4x4_m23, 0);
|
36
|
+
rb_define_method(rb_cMatrix4x4, "m24", rb_matrix4x4_m24, 0);
|
37
|
+
rb_define_method(rb_cMatrix4x4, "m31", rb_matrix4x4_m31, 0);
|
38
|
+
rb_define_method(rb_cMatrix4x4, "m32", rb_matrix4x4_m32, 0);
|
39
|
+
rb_define_method(rb_cMatrix4x4, "m33", rb_matrix4x4_m33, 0);
|
40
|
+
rb_define_method(rb_cMatrix4x4, "m34", rb_matrix4x4_m34, 0);
|
41
|
+
rb_define_method(rb_cMatrix4x4, "m41", rb_matrix4x4_m41, 0);
|
42
|
+
rb_define_method(rb_cMatrix4x4, "m42", rb_matrix4x4_m42, 0);
|
43
|
+
rb_define_method(rb_cMatrix4x4, "m43", rb_matrix4x4_m43, 0);
|
44
|
+
rb_define_method(rb_cMatrix4x4, "m44", rb_matrix4x4_m44, 0);
|
45
|
+
|
46
|
+
rb_define_method(rb_cMatrix4x4, "m11=", rb_matrix4x4_m11_set, 1);
|
47
|
+
rb_define_method(rb_cMatrix4x4, "m12=", rb_matrix4x4_m12_set, 1);
|
48
|
+
rb_define_method(rb_cMatrix4x4, "m13=", rb_matrix4x4_m13_set, 1);
|
49
|
+
rb_define_method(rb_cMatrix4x4, "m14=", rb_matrix4x4_m14_set, 1);
|
50
|
+
rb_define_method(rb_cMatrix4x4, "m21=", rb_matrix4x4_m21_set, 1);
|
51
|
+
rb_define_method(rb_cMatrix4x4, "m22=", rb_matrix4x4_m22_set, 1);
|
52
|
+
rb_define_method(rb_cMatrix4x4, "m23=", rb_matrix4x4_m23_set, 1);
|
53
|
+
rb_define_method(rb_cMatrix4x4, "m24=", rb_matrix4x4_m24_set, 1);
|
54
|
+
rb_define_method(rb_cMatrix4x4, "m31=", rb_matrix4x4_m31_set, 1);
|
55
|
+
rb_define_method(rb_cMatrix4x4, "m32=", rb_matrix4x4_m32_set, 1);
|
56
|
+
rb_define_method(rb_cMatrix4x4, "m33=", rb_matrix4x4_m33_set, 1);
|
57
|
+
rb_define_method(rb_cMatrix4x4, "m34=", rb_matrix4x4_m34_set, 1);
|
58
|
+
rb_define_method(rb_cMatrix4x4, "m41=", rb_matrix4x4_m41_set, 1);
|
59
|
+
rb_define_method(rb_cMatrix4x4, "m42=", rb_matrix4x4_m42_set, 1);
|
60
|
+
rb_define_method(rb_cMatrix4x4, "m43=", rb_matrix4x4_m43_set, 1);
|
61
|
+
rb_define_method(rb_cMatrix4x4, "m44=", rb_matrix4x4_m44_set, 1);
|
62
|
+
|
63
|
+
PRIVATE_CLASS_METHOD(rb_cMatrixBase, "new");
|
64
|
+
rb_include_module(rb_cMatrixBase, rb_mEnumerable);
|
65
|
+
}
|
66
|
+
|
67
|
+
VALUE rb_matrix3x2_m11(VALUE self) {
|
68
|
+
MATRIX3X2();
|
69
|
+
return DBL2NUM(m->m11);
|
70
|
+
}
|
71
|
+
|
72
|
+
VALUE rb_matrix3x2_m12(VALUE self) {
|
73
|
+
MATRIX3X2();
|
74
|
+
return DBL2NUM(m->m12);
|
75
|
+
}
|
76
|
+
|
77
|
+
VALUE rb_matrix3x2_m21(VALUE self) {
|
78
|
+
MATRIX3X2();
|
79
|
+
return DBL2NUM(m->m21);
|
80
|
+
}
|
81
|
+
|
82
|
+
VALUE rb_matrix3x2_m22(VALUE self) {
|
83
|
+
MATRIX3X2();
|
84
|
+
return DBL2NUM(m->m22);
|
85
|
+
}
|
86
|
+
|
87
|
+
VALUE rb_matrix3x2_m31(VALUE self) {
|
88
|
+
MATRIX3X2();
|
89
|
+
return DBL2NUM(m->m31);
|
90
|
+
}
|
91
|
+
|
92
|
+
VALUE rb_matrix3x2_m32(VALUE self) {
|
93
|
+
MATRIX3X2();
|
94
|
+
return DBL2NUM(m->m32);
|
95
|
+
}
|
96
|
+
|
97
|
+
VALUE rb_matrix4x4_m11(VALUE self) {
|
98
|
+
MATRIX4X4();
|
99
|
+
return DBL2NUM(m->m11);
|
100
|
+
}
|
101
|
+
|
102
|
+
VALUE rb_matrix4x4_m12(VALUE self) {
|
103
|
+
MATRIX4X4();
|
104
|
+
return DBL2NUM(m->m12);
|
105
|
+
}
|
106
|
+
|
107
|
+
VALUE rb_matrix4x4_m13(VALUE self) {
|
108
|
+
MATRIX4X4();
|
109
|
+
return DBL2NUM(m->m13);
|
110
|
+
}
|
111
|
+
|
112
|
+
VALUE rb_matrix4x4_m14(VALUE self) {
|
113
|
+
MATRIX4X4();
|
114
|
+
return DBL2NUM(m->m14);
|
115
|
+
}
|
116
|
+
|
117
|
+
VALUE rb_matrix4x4_m21(VALUE self) {
|
118
|
+
MATRIX4X4();
|
119
|
+
return DBL2NUM(m->m21);
|
120
|
+
}
|
121
|
+
|
122
|
+
VALUE rb_matrix4x4_m22(VALUE self) {
|
123
|
+
MATRIX4X4();
|
124
|
+
return DBL2NUM(m->m22);
|
125
|
+
}
|
126
|
+
|
127
|
+
VALUE rb_matrix4x4_m23(VALUE self) {
|
128
|
+
MATRIX4X4();
|
129
|
+
return DBL2NUM(m->m23);
|
130
|
+
}
|
131
|
+
|
132
|
+
VALUE rb_matrix4x4_m24(VALUE self) {
|
133
|
+
MATRIX4X4();
|
134
|
+
return DBL2NUM(m->m24);
|
135
|
+
}
|
136
|
+
|
137
|
+
VALUE rb_matrix4x4_m31(VALUE self) {
|
138
|
+
MATRIX4X4();
|
139
|
+
return DBL2NUM(m->m31);
|
140
|
+
}
|
141
|
+
|
142
|
+
VALUE rb_matrix4x4_m32(VALUE self) {
|
143
|
+
MATRIX4X4();
|
144
|
+
return DBL2NUM(m->m32);
|
145
|
+
}
|
146
|
+
|
147
|
+
VALUE rb_matrix4x4_m33(VALUE self) {
|
148
|
+
MATRIX4X4();
|
149
|
+
return DBL2NUM(m->m33);
|
150
|
+
}
|
151
|
+
|
152
|
+
VALUE rb_matrix4x4_m34(VALUE self) {
|
153
|
+
MATRIX4X4();
|
154
|
+
return DBL2NUM(m->m34);
|
155
|
+
}
|
156
|
+
|
157
|
+
VALUE rb_matrix4x4_m41(VALUE self) {
|
158
|
+
MATRIX4X4();
|
159
|
+
return DBL2NUM(m->m41);
|
160
|
+
}
|
161
|
+
|
162
|
+
VALUE rb_matrix4x4_m42(VALUE self) {
|
163
|
+
MATRIX4X4();
|
164
|
+
return DBL2NUM(m->m42);
|
165
|
+
}
|
166
|
+
|
167
|
+
VALUE rb_matrix4x4_m43(VALUE self) {
|
168
|
+
MATRIX4X4();
|
169
|
+
return DBL2NUM(m->m43);
|
170
|
+
}
|
171
|
+
|
172
|
+
VALUE rb_matrix4x4_m44(VALUE self) {
|
173
|
+
MATRIX4X4();
|
174
|
+
return DBL2NUM(m->m44);
|
175
|
+
}
|
176
|
+
|
177
|
+
VALUE rb_matrix3x2_m11_set(VALUE self, VALUE value) {
|
178
|
+
MATRIX3X2();
|
179
|
+
m->m11 = NUM2FLT(value);
|
180
|
+
return value;
|
181
|
+
}
|
182
|
+
|
183
|
+
VALUE rb_matrix3x2_m12_set(VALUE self, VALUE value) {
|
184
|
+
MATRIX3X2();
|
185
|
+
m->m12 = NUM2FLT(value);
|
186
|
+
return value;
|
187
|
+
}
|
188
|
+
|
189
|
+
VALUE rb_matrix3x2_m21_set(VALUE self, VALUE value) {
|
190
|
+
MATRIX3X2();
|
191
|
+
m->m21 = NUM2FLT(value);
|
192
|
+
return value;
|
193
|
+
}
|
194
|
+
|
195
|
+
VALUE rb_matrix3x2_m22_set(VALUE self, VALUE value) {
|
196
|
+
MATRIX3X2();
|
197
|
+
m->m22 = NUM2FLT(value);
|
198
|
+
return value;
|
199
|
+
}
|
200
|
+
|
201
|
+
VALUE rb_matrix3x2_m31_set(VALUE self, VALUE value) {
|
202
|
+
MATRIX3X2();
|
203
|
+
m->m31 = NUM2FLT(value);
|
204
|
+
return value;
|
205
|
+
}
|
206
|
+
|
207
|
+
VALUE rb_matrix3x2_m32_set(VALUE self, VALUE value) {
|
208
|
+
MATRIX3X2();
|
209
|
+
m->m32 = NUM2FLT(value);
|
210
|
+
return value;
|
211
|
+
}
|
212
|
+
|
213
|
+
VALUE rb_matrix4x4_m11_set(VALUE self, VALUE value) {
|
214
|
+
MATRIX4X4();
|
215
|
+
m->m11 = NUM2FLT(value);
|
216
|
+
return value;
|
217
|
+
}
|
218
|
+
|
219
|
+
VALUE rb_matrix4x4_m12_set(VALUE self, VALUE value) {
|
220
|
+
MATRIX4X4();
|
221
|
+
m->m12 = NUM2FLT(value);
|
222
|
+
return value;
|
223
|
+
}
|
224
|
+
|
225
|
+
VALUE rb_matrix4x4_m13_set(VALUE self, VALUE value) {
|
226
|
+
MATRIX4X4();
|
227
|
+
m->m13 = NUM2FLT(value);
|
228
|
+
return value;
|
229
|
+
}
|
230
|
+
|
231
|
+
VALUE rb_matrix4x4_m14_set(VALUE self, VALUE value) {
|
232
|
+
MATRIX4X4();
|
233
|
+
m->m14 = NUM2FLT(value);
|
234
|
+
return value;
|
235
|
+
}
|
236
|
+
|
237
|
+
VALUE rb_matrix4x4_m21_set(VALUE self, VALUE value) {
|
238
|
+
MATRIX4X4();
|
239
|
+
m->m21 = NUM2FLT(value);
|
240
|
+
return value;
|
241
|
+
}
|
242
|
+
|
243
|
+
VALUE rb_matrix4x4_m22_set(VALUE self, VALUE value) {
|
244
|
+
MATRIX4X4();
|
245
|
+
m->m22 = NUM2FLT(value);
|
246
|
+
return value;
|
247
|
+
}
|
248
|
+
|
249
|
+
VALUE rb_matrix4x4_m23_set(VALUE self, VALUE value) {
|
250
|
+
MATRIX4X4();
|
251
|
+
m->m23 = NUM2FLT(value);
|
252
|
+
return value;
|
253
|
+
}
|
254
|
+
|
255
|
+
VALUE rb_matrix4x4_m24_set(VALUE self, VALUE value) {
|
256
|
+
MATRIX4X4();
|
257
|
+
m->m24 = NUM2FLT(value);
|
258
|
+
return value;
|
259
|
+
}
|
260
|
+
|
261
|
+
VALUE rb_matrix4x4_m31_set(VALUE self, VALUE value) {
|
262
|
+
MATRIX4X4();
|
263
|
+
m->m31 = NUM2FLT(value);
|
264
|
+
return value;
|
265
|
+
}
|
266
|
+
|
267
|
+
VALUE rb_matrix4x4_m32_set(VALUE self, VALUE value) {
|
268
|
+
MATRIX4X4();
|
269
|
+
m->m32 = NUM2FLT(value);
|
270
|
+
return value;
|
271
|
+
}
|
272
|
+
|
273
|
+
VALUE rb_matrix4x4_m33_set(VALUE self, VALUE value) {
|
274
|
+
MATRIX4X4();
|
275
|
+
m->m33 = NUM2FLT(value);
|
276
|
+
return value;
|
277
|
+
}
|
278
|
+
|
279
|
+
VALUE rb_matrix4x4_m34_set(VALUE self, VALUE value) {
|
280
|
+
MATRIX4X4();
|
281
|
+
m->m34 = NUM2FLT(value);
|
282
|
+
return value;
|
283
|
+
}
|
284
|
+
|
285
|
+
VALUE rb_matrix4x4_m41_set(VALUE self, VALUE value) {
|
286
|
+
MATRIX4X4();
|
287
|
+
m->m41 = NUM2FLT(value);
|
288
|
+
return value;
|
289
|
+
}
|
290
|
+
|
291
|
+
VALUE rb_matrix4x4_m42_set(VALUE self, VALUE value) {
|
292
|
+
MATRIX4X4();
|
293
|
+
m->m42 = NUM2FLT(value);
|
294
|
+
return value;
|
295
|
+
}
|
296
|
+
|
297
|
+
VALUE rb_matrix4x4_m43_set(VALUE self, VALUE value) {
|
298
|
+
MATRIX4X4();
|
299
|
+
m->m43 = NUM2FLT(value);
|
300
|
+
return value;
|
301
|
+
}
|
302
|
+
|
303
|
+
VALUE rb_matrix4x4_m44_set(VALUE self, VALUE value) {
|
304
|
+
MATRIX4X4();
|
305
|
+
m->m44 = NUM2FLT(value);
|
306
|
+
return value;
|
307
|
+
}
|
@@ -0,0 +1,70 @@
|
|
1
|
+
#ifndef NUMERIX_MATRIX_BASE_H
|
2
|
+
#define NUMERIX_MATRIX_BASE_H 1
|
3
|
+
|
4
|
+
#include "common.h"
|
5
|
+
|
6
|
+
#define MATRIX3X2() \
|
7
|
+
Matrix3x2 *m; \
|
8
|
+
Data_Get_Struct(self, Matrix3x2, m)
|
9
|
+
|
10
|
+
#define MATRIX4X4() \
|
11
|
+
Matrix4x4 *m; \
|
12
|
+
Data_Get_Struct(self, Matrix4x4, m)
|
13
|
+
|
14
|
+
void Init_matrix_base(VALUE outer);
|
15
|
+
|
16
|
+
VALUE rb_matrix3x2_m11(VALUE self);
|
17
|
+
VALUE rb_matrix3x2_m12(VALUE self);
|
18
|
+
VALUE rb_matrix3x2_m21(VALUE self);
|
19
|
+
VALUE rb_matrix3x2_m22(VALUE self);
|
20
|
+
VALUE rb_matrix3x2_m31(VALUE self);
|
21
|
+
VALUE rb_matrix3x2_m32(VALUE self);
|
22
|
+
|
23
|
+
VALUE rb_matrix4x4_m11(VALUE self);
|
24
|
+
VALUE rb_matrix4x4_m12(VALUE self);
|
25
|
+
VALUE rb_matrix4x4_m13(VALUE self);
|
26
|
+
VALUE rb_matrix4x4_m14(VALUE self);
|
27
|
+
|
28
|
+
VALUE rb_matrix4x4_m21(VALUE self);
|
29
|
+
VALUE rb_matrix4x4_m22(VALUE self);
|
30
|
+
VALUE rb_matrix4x4_m23(VALUE self);
|
31
|
+
VALUE rb_matrix4x4_m24(VALUE self);
|
32
|
+
|
33
|
+
VALUE rb_matrix4x4_m31(VALUE self);
|
34
|
+
VALUE rb_matrix4x4_m32(VALUE self);
|
35
|
+
VALUE rb_matrix4x4_m33(VALUE self);
|
36
|
+
VALUE rb_matrix4x4_m34(VALUE self);
|
37
|
+
|
38
|
+
VALUE rb_matrix4x4_m41(VALUE self);
|
39
|
+
VALUE rb_matrix4x4_m42(VALUE self);
|
40
|
+
VALUE rb_matrix4x4_m43(VALUE self);
|
41
|
+
VALUE rb_matrix4x4_m44(VALUE self);
|
42
|
+
|
43
|
+
VALUE rb_matrix3x2_m11_set(VALUE self, VALUE value);
|
44
|
+
VALUE rb_matrix3x2_m12_set(VALUE self, VALUE value);
|
45
|
+
VALUE rb_matrix3x2_m21_set(VALUE self, VALUE value);
|
46
|
+
VALUE rb_matrix3x2_m22_set(VALUE self, VALUE value);
|
47
|
+
VALUE rb_matrix3x2_m31_set(VALUE self, VALUE value);
|
48
|
+
VALUE rb_matrix3x2_m32_set(VALUE self, VALUE value);
|
49
|
+
|
50
|
+
VALUE rb_matrix4x4_m11_set(VALUE self, VALUE value);
|
51
|
+
VALUE rb_matrix4x4_m12_set(VALUE self, VALUE value);
|
52
|
+
VALUE rb_matrix4x4_m13_set(VALUE self, VALUE value);
|
53
|
+
VALUE rb_matrix4x4_m14_set(VALUE self, VALUE value);
|
54
|
+
|
55
|
+
VALUE rb_matrix4x4_m21_set(VALUE self, VALUE value);
|
56
|
+
VALUE rb_matrix4x4_m22_set(VALUE self, VALUE value);
|
57
|
+
VALUE rb_matrix4x4_m23_set(VALUE self, VALUE value);
|
58
|
+
VALUE rb_matrix4x4_m24_set(VALUE self, VALUE value);
|
59
|
+
|
60
|
+
VALUE rb_matrix4x4_m31_set(VALUE self, VALUE value);
|
61
|
+
VALUE rb_matrix4x4_m32_set(VALUE self, VALUE value);
|
62
|
+
VALUE rb_matrix4x4_m33_set(VALUE self, VALUE value);
|
63
|
+
VALUE rb_matrix4x4_m34_set(VALUE self, VALUE value);
|
64
|
+
|
65
|
+
VALUE rb_matrix4x4_m41_set(VALUE self, VALUE value);
|
66
|
+
VALUE rb_matrix4x4_m42_set(VALUE self, VALUE value);
|
67
|
+
VALUE rb_matrix4x4_m43_set(VALUE self, VALUE value);
|
68
|
+
VALUE rb_matrix4x4_m44_set(VALUE self, VALUE value);
|
69
|
+
|
70
|
+
#endif /* NUMERIX_MATRIX_BASE_H */
|
@@ -0,0 +1,33 @@
|
|
1
|
+
#include "numerix.h"
|
2
|
+
|
3
|
+
VALUE rb_mNumerix;
|
4
|
+
VALUE rb_eNumerixError;
|
5
|
+
|
6
|
+
void Init_numerix(void) {
|
7
|
+
rb_mNumerix = rb_define_module("Numerix");
|
8
|
+
rb_eNumerixError = rb_define_class_under(rb_mNumerix, "NumerixError", rb_eStandardError);
|
9
|
+
|
10
|
+
Init_basic_vector(rb_mNumerix);
|
11
|
+
Init_numerix_structure(rb_mNumerix);
|
12
|
+
Init_vector_base(rb_mNumerix);
|
13
|
+
Init_matrix_base(rb_mNumerix);
|
14
|
+
Init_vector2(rb_mNumerix);
|
15
|
+
Init_vector3(rb_mNumerix);
|
16
|
+
Init_vector4(rb_mNumerix);
|
17
|
+
Init_matrix3x2(rb_mNumerix);
|
18
|
+
Init_matrix4x4(rb_mNumerix);
|
19
|
+
Init_quaternion(rb_mNumerix);
|
20
|
+
Init_plane(rb_mNumerix);
|
21
|
+
|
22
|
+
rb_define_const(rb_mNumerix, "SIZEOF_VECTOR2", INT2NUM(sizeof(Vector2)));
|
23
|
+
rb_define_const(rb_mNumerix, "SIZEOF_VECTOR3", INT2NUM(sizeof(Vector3)));
|
24
|
+
rb_define_const(rb_mNumerix, "SIZEOF_VECTOR4", INT2NUM(sizeof(Vector4)));
|
25
|
+
rb_define_const(rb_mNumerix, "SIZEOF_MATRIX3X2", INT2NUM(sizeof(Matrix3x2)));
|
26
|
+
rb_define_const(rb_mNumerix, "SIZEOF_MATRiX4X4", INT2NUM(sizeof(Matrix4x4)));
|
27
|
+
rb_define_const(rb_mNumerix, "SIZEOF_QUATERNION", INT2NUM(sizeof(Quaternion)));
|
28
|
+
rb_define_const(rb_mNumerix, "SIZEOF_PLANE", INT2NUM(sizeof(Plane)));
|
29
|
+
}
|
30
|
+
|
31
|
+
VALUE rb_numerix_abstract_initialize(VALUE self) {
|
32
|
+
rb_raise(rb_eNumerixError, "cannot create instance of abstract class %s", rb_class2name(CLASS_OF(self)));
|
33
|
+
}
|
@@ -0,0 +1,19 @@
|
|
1
|
+
#ifndef NUMERIX_H
|
2
|
+
#define NUMERIX_H 1
|
3
|
+
|
4
|
+
#include "common.h"
|
5
|
+
#include "matrix3x2.h"
|
6
|
+
#include "matrix4x4.h"
|
7
|
+
#include "matrix_base.h"
|
8
|
+
#include "plane.h"
|
9
|
+
#include "quaternion.h"
|
10
|
+
#include "structure.h"
|
11
|
+
#include "vector.h"
|
12
|
+
#include "vector2.h"
|
13
|
+
#include "vector3.h"
|
14
|
+
#include "vector4.h"
|
15
|
+
#include "vector_base.h"
|
16
|
+
|
17
|
+
VALUE rb_numerix_abstract_initialize(VALUE self);
|
18
|
+
|
19
|
+
#endif /* NUMERIX_H */
|