rmath3d 1.1.0 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ChangeLog +5 -0
- data/README.md +4 -1
- data/ext/rmath3d/rmath3d.c +628 -551
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 49898e4a80e600f039ecd7ec04511872b3ae42d2
|
4
|
+
data.tar.gz: fcc1b6d2a979747fc86519d30560e824dbf1b88c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5ddcc540d1be103a66966c51d839ad3c2af5775b5d0ad2dbe9f1c729964ec60a5cd411fd692fb76e6731a482f778f09e9f77dc9a6913ce7f20e4663c32422067
|
7
|
+
data.tar.gz: ad561643d3081d05ae0821ecafb762be751d07b5675330f7df913a37bac12c827964217dff897b4524be833a68c2545852ba138dd34414d4b4523d8d0f802835
|
data/ChangeLog
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
+
2015-05-02 vaiorabbit <http://twitter.com/vaiorabbit>
|
2
|
+
|
3
|
+
* Ruby 1.9.3 and prior versions are no longer supported. Ref.: https://www.ruby-lang.org/en/news/2015/02/23/support-for-ruby-1-9-3-has-ended/
|
4
|
+
* rmath3d.c: Data_Get_Struct -> TypedData_Get_Struct, etc.
|
5
|
+
|
1
6
|
2015-04-12 vaiorabbit <http://twitter.com/vaiorabbit>
|
2
7
|
|
3
8
|
* RVec2.c|h, RMtx2.c|h: Added.
|
data/README.md
CHANGED
@@ -4,7 +4,7 @@
|
|
4
4
|
|
5
5
|
rmath3d is a math module for 3D game programming and computer graphics.
|
6
6
|
|
7
|
-
* Last Update:
|
7
|
+
* Last Update: Mar 02, 2015
|
8
8
|
* Since: Jul 20, 2008
|
9
9
|
|
10
10
|
## Features ##
|
@@ -35,6 +35,9 @@ Notice: This library provides native extension. You must setup develop environme
|
|
35
35
|
* I used: DevKit-mingw64-32-4.7.2-20130224-1151-sfx.exe
|
36
36
|
* Unpack the archive -> "> ruby dk.rb init" -> edit config.yml (just add your ruby foldier) -> "> ruby dk.rb install"
|
37
37
|
* Ref.: http://blog.mattwynne.net/2010/10/12/installing-ruby-gems-with-native-extensions-on-windows/
|
38
|
+
* ruby 2.2.2p95 (2015-04-13 revision 50295) [x86_64-darwin14]
|
39
|
+
* Ruby 1.9.3 and prior versions are no longer supported.
|
40
|
+
* Ref.: https://www.ruby-lang.org/en/news/2015/02/23/support-for-ruby-1-9-3-has-ended/
|
38
41
|
|
39
42
|
## Building rmath3d.{so|bundle} ##
|
40
43
|
|
data/ext/rmath3d/rmath3d.c
CHANGED
@@ -33,15 +33,6 @@ VALUE rb_cRMtx4;
|
|
33
33
|
#endif
|
34
34
|
#endif /* RMATH_EXPORT */
|
35
35
|
|
36
|
-
/* for Ruby 1.8 (C API has no RFLOAT_VALUE macro.) */
|
37
|
-
#ifndef RFLOAT_VALUE
|
38
|
-
#define RFLOAT_VALUE(v) (RFLOAT(v)->value)
|
39
|
-
#endif
|
40
|
-
/* for Ruby 1.8 (C API has no DOUBLE2NUM macro) */
|
41
|
-
#ifndef DOUBLE2NUM
|
42
|
-
#define DOUBLE2NUM(dbl) rb_float_new(dbl)
|
43
|
-
#endif
|
44
|
-
|
45
36
|
#define IsRVec2(v) rb_obj_is_kind_of( (v), rb_cRVec2 )
|
46
37
|
#define IsRVec3(v) rb_obj_is_kind_of( (v), rb_cRVec3 )
|
47
38
|
#define IsRVec4(v) rb_obj_is_kind_of( (v), rb_cRVec4 )
|
@@ -50,6 +41,77 @@ VALUE rb_cRMtx4;
|
|
50
41
|
#define IsRMtx3(v) rb_obj_is_kind_of( (v), rb_cRMtx3 )
|
51
42
|
#define IsRMtx4(v) rb_obj_is_kind_of( (v), rb_cRMtx4 )
|
52
43
|
|
44
|
+
static void RVec2_free( void* ptr );
|
45
|
+
static size_t RVec2_memsize( const void* ptr );
|
46
|
+
|
47
|
+
static void RVec3_free( void* ptr );
|
48
|
+
static size_t RVec3_memsize( const void* ptr );
|
49
|
+
|
50
|
+
static void RVec4_free( void* ptr );
|
51
|
+
static size_t RVec4_memsize( const void* ptr );
|
52
|
+
|
53
|
+
static void RQuat_free( void* ptr );
|
54
|
+
static size_t RQuat_memsize( const void* ptr );
|
55
|
+
|
56
|
+
static void RMtx2_free( void* ptr );
|
57
|
+
static size_t RMtx2_memsize( const void* ptr );
|
58
|
+
|
59
|
+
static void RMtx3_free( void* ptr );
|
60
|
+
static size_t RMtx3_memsize( const void* ptr );
|
61
|
+
|
62
|
+
static void RMtx4_free( void* ptr );
|
63
|
+
static size_t RMtx4_memsize( const void* ptr );
|
64
|
+
|
65
|
+
static const rb_data_type_t RVec2_type = {
|
66
|
+
"RVec2",
|
67
|
+
{0, RVec2_free, RVec2_memsize,},
|
68
|
+
0, 0,
|
69
|
+
RUBY_TYPED_FREE_IMMEDIATELY,
|
70
|
+
};
|
71
|
+
|
72
|
+
static const rb_data_type_t RVec3_type = {
|
73
|
+
"RVec3",
|
74
|
+
{0, RVec3_free, RVec3_memsize,},
|
75
|
+
0, 0,
|
76
|
+
RUBY_TYPED_FREE_IMMEDIATELY,
|
77
|
+
};
|
78
|
+
|
79
|
+
static const rb_data_type_t RVec4_type = {
|
80
|
+
"RVec4",
|
81
|
+
{0, RVec4_free, RVec4_memsize,},
|
82
|
+
0, 0,
|
83
|
+
RUBY_TYPED_FREE_IMMEDIATELY,
|
84
|
+
};
|
85
|
+
|
86
|
+
static const rb_data_type_t RQuat_type = {
|
87
|
+
"RQuat",
|
88
|
+
{0, RQuat_free, RQuat_memsize,},
|
89
|
+
0, 0,
|
90
|
+
RUBY_TYPED_FREE_IMMEDIATELY,
|
91
|
+
};
|
92
|
+
|
93
|
+
static const rb_data_type_t RMtx2_type = {
|
94
|
+
"RMtx2",
|
95
|
+
{0, RMtx2_free, RMtx2_memsize,},
|
96
|
+
0, 0,
|
97
|
+
RUBY_TYPED_FREE_IMMEDIATELY,
|
98
|
+
};
|
99
|
+
|
100
|
+
static const rb_data_type_t RMtx3_type = {
|
101
|
+
"RMtx3",
|
102
|
+
{0, RMtx3_free, RMtx3_memsize,},
|
103
|
+
0, 0,
|
104
|
+
RUBY_TYPED_FREE_IMMEDIATELY,
|
105
|
+
};
|
106
|
+
|
107
|
+
static const rb_data_type_t RMtx4_type = {
|
108
|
+
"RMtx4",
|
109
|
+
{0, RMtx4_free, RMtx4_memsize,},
|
110
|
+
0, 0,
|
111
|
+
RUBY_TYPED_FREE_IMMEDIATELY,
|
112
|
+
};
|
113
|
+
|
114
|
+
|
53
115
|
#ifdef RMATH_SINGLE_PRECISION
|
54
116
|
# define RMATH_FVAL_FMT "%#.6g"
|
55
117
|
#else
|
@@ -72,7 +134,7 @@ static VALUE RVec4_from_source( RVec4* src );
|
|
72
134
|
********************************************************************************/
|
73
135
|
|
74
136
|
/*
|
75
|
-
* Document-class:
|
137
|
+
* Document-class: RMath3D::RMtx2
|
76
138
|
* provies 2x2 matrix arithmetic.
|
77
139
|
*
|
78
140
|
* <b>Notice</b>
|
@@ -82,28 +144,30 @@ static VALUE RVec4_from_source( RVec4* src );
|
|
82
144
|
static void
|
83
145
|
RMtx2_free( void* ptr )
|
84
146
|
{
|
85
|
-
|
147
|
+
xfree( ptr );
|
148
|
+
}
|
149
|
+
|
150
|
+
static size_t
|
151
|
+
RMtx2_memsize( const void* ptr )
|
152
|
+
{
|
153
|
+
const struct RMtx2* data = ptr;
|
154
|
+
return data ? sizeof(*data) : 0;
|
86
155
|
}
|
87
156
|
|
88
157
|
static VALUE
|
89
158
|
RMtx2_from_source( RMtx2* src )
|
90
159
|
{
|
91
|
-
RMtx2* v =
|
92
|
-
|
160
|
+
RMtx2* v = ZALLOC( struct RMtx2 );
|
93
161
|
RMtx2Copy( v, src );
|
94
|
-
|
95
|
-
return Data_Wrap_Struct( rb_cRMtx2, NULL, RMtx2_free, v );
|
162
|
+
return TypedData_Wrap_Struct( rb_cRMtx2, &RMtx2_type, v );
|
96
163
|
}
|
97
164
|
|
98
165
|
|
99
166
|
static VALUE
|
100
167
|
RMtx2_allocate( VALUE klass )
|
101
168
|
{
|
102
|
-
RMtx2* v =
|
103
|
-
|
104
|
-
memset( v, 0, sizeof(RMtx2) );
|
105
|
-
|
106
|
-
return Data_Wrap_Struct( klass, NULL, RMtx2_free, v );
|
169
|
+
RMtx2* v = ZALLOC( RMtx2 );
|
170
|
+
return TypedData_Wrap_Struct( klass, &RMtx2_type, v );
|
107
171
|
}
|
108
172
|
|
109
173
|
|
@@ -120,7 +184,8 @@ static VALUE
|
|
120
184
|
RMtx2_initialize( int argc, VALUE* argv, VALUE self )
|
121
185
|
{
|
122
186
|
RMtx2* v = NULL;
|
123
|
-
|
187
|
+
|
188
|
+
TypedData_Get_Struct( self, RMtx2, &RMtx2_type, v );
|
124
189
|
|
125
190
|
switch( argc )
|
126
191
|
{
|
@@ -155,7 +220,7 @@ RMtx2_initialize( int argc, VALUE* argv, VALUE self )
|
|
155
220
|
{
|
156
221
|
/* Copy Constructor */
|
157
222
|
RMtx2* other;
|
158
|
-
|
223
|
+
TypedData_Get_Struct( arg, RMtx2, &RMtx2_type, other );
|
159
224
|
RMtx2Copy( v, other );
|
160
225
|
return self;
|
161
226
|
}
|
@@ -236,7 +301,7 @@ RMtx2_to_s( VALUE self )
|
|
236
301
|
int row, col, n;
|
237
302
|
rmReal val;
|
238
303
|
|
239
|
-
|
304
|
+
TypedData_Get_Struct( self, RMtx2, &RMtx2_type, v );
|
240
305
|
|
241
306
|
p = dest;
|
242
307
|
for ( row = 0; row < 2; ++row )
|
@@ -280,7 +345,7 @@ RMtx2_to_a( VALUE self )
|
|
280
345
|
int row, col;
|
281
346
|
RMtx2* v = NULL;
|
282
347
|
VALUE dbl[4];
|
283
|
-
|
348
|
+
TypedData_Get_Struct( self, RMtx2, &RMtx2_type, v );
|
284
349
|
|
285
350
|
/* column-major */
|
286
351
|
for ( col = 0; col < 2; ++col )
|
@@ -288,7 +353,7 @@ RMtx2_to_a( VALUE self )
|
|
288
353
|
for ( row = 0; row < 2; ++row )
|
289
354
|
{
|
290
355
|
int i = 2*col + row;
|
291
|
-
dbl[i] =
|
356
|
+
dbl[i] = DBL2NUM(RMtx2GetElement(v,row,col));
|
292
357
|
}
|
293
358
|
}
|
294
359
|
|
@@ -304,7 +369,7 @@ static VALUE
|
|
304
369
|
RMtx2_coerce( VALUE self, VALUE other )
|
305
370
|
{
|
306
371
|
RMtx2* v = NULL;
|
307
|
-
|
372
|
+
TypedData_Get_Struct( self, RMtx2, &RMtx2_type, v );
|
308
373
|
|
309
374
|
switch( TYPE(other) )
|
310
375
|
{
|
@@ -351,7 +416,7 @@ RMtx2_setElements( int argc, VALUE* argv, VALUE self )
|
|
351
416
|
}
|
352
417
|
#endif
|
353
418
|
|
354
|
-
|
419
|
+
TypedData_Get_Struct( self, RMtx2, &RMtx2_type, m );
|
355
420
|
for ( row = 0; row < 2; ++row )
|
356
421
|
{
|
357
422
|
for ( col = 0; col < 2; ++col )
|
@@ -376,7 +441,7 @@ RMtx2_setElement( VALUE self, VALUE r, VALUE c, VALUE f )
|
|
376
441
|
int row, col;
|
377
442
|
rmReal flt;
|
378
443
|
|
379
|
-
|
444
|
+
TypedData_Get_Struct( self, RMtx2, &RMtx2_type, m );
|
380
445
|
row = FIX2INT(r);
|
381
446
|
col = FIX2INT(c);
|
382
447
|
flt = NUM2DBL(f);
|
@@ -398,12 +463,12 @@ RMtx2_getElement( VALUE self, VALUE r, VALUE c )
|
|
398
463
|
int row, col;
|
399
464
|
rmReal flt;
|
400
465
|
|
401
|
-
|
466
|
+
TypedData_Get_Struct( self, RMtx2, &RMtx2_type, m );
|
402
467
|
row = FIX2INT(r);
|
403
468
|
col = FIX2INT(c);
|
404
469
|
flt = RMtx2GetElement( m, row, col );
|
405
470
|
|
406
|
-
return
|
471
|
+
return DBL2NUM( flt );
|
407
472
|
}
|
408
473
|
|
409
474
|
/* Returns the element at row 0 and column 0.
|
@@ -413,9 +478,9 @@ RMtx2_get_e00( VALUE self )
|
|
413
478
|
{
|
414
479
|
RMtx2* m;
|
415
480
|
|
416
|
-
|
481
|
+
TypedData_Get_Struct( self, RMtx2, &RMtx2_type, m );
|
417
482
|
|
418
|
-
return
|
483
|
+
return DBL2NUM( RMtx2GetElement( m, 0, 0 ) );
|
419
484
|
}
|
420
485
|
|
421
486
|
/* Returns the element at row 0 and column 1.
|
@@ -425,9 +490,9 @@ RMtx2_get_e01( VALUE self )
|
|
425
490
|
{
|
426
491
|
RMtx2* m;
|
427
492
|
|
428
|
-
|
493
|
+
TypedData_Get_Struct( self, RMtx2, &RMtx2_type, m );
|
429
494
|
|
430
|
-
return
|
495
|
+
return DBL2NUM( RMtx2GetElement( m, 0, 1 ) );
|
431
496
|
}
|
432
497
|
|
433
498
|
/* Returns the element at row 1 and column 0.
|
@@ -437,9 +502,9 @@ RMtx2_get_e10( VALUE self )
|
|
437
502
|
{
|
438
503
|
RMtx2* m;
|
439
504
|
|
440
|
-
|
505
|
+
TypedData_Get_Struct( self, RMtx2, &RMtx2_type, m );
|
441
506
|
|
442
|
-
return
|
507
|
+
return DBL2NUM( RMtx2GetElement( m, 1, 0 ) );
|
443
508
|
}
|
444
509
|
|
445
510
|
/* Returns the element at row 1 and column 1.
|
@@ -449,9 +514,9 @@ RMtx2_get_e11( VALUE self )
|
|
449
514
|
{
|
450
515
|
RMtx2* m;
|
451
516
|
|
452
|
-
|
517
|
+
TypedData_Get_Struct( self, RMtx2, &RMtx2_type, m );
|
453
518
|
|
454
|
-
return
|
519
|
+
return DBL2NUM( RMtx2GetElement( m, 1, 1 ) );
|
455
520
|
}
|
456
521
|
|
457
522
|
/* Replaces the element at row 0 and column 0 by +value+.
|
@@ -461,7 +526,7 @@ RMtx2_set_e00( VALUE self, VALUE f )
|
|
461
526
|
{
|
462
527
|
RMtx2* m;
|
463
528
|
|
464
|
-
|
529
|
+
TypedData_Get_Struct( self, RMtx2, &RMtx2_type, m );
|
465
530
|
|
466
531
|
RMtx2SetElement( m, 0, 0, NUM2DBL(f) );
|
467
532
|
|
@@ -475,7 +540,7 @@ RMtx2_set_e01( VALUE self, VALUE f )
|
|
475
540
|
{
|
476
541
|
RMtx2* m;
|
477
542
|
|
478
|
-
|
543
|
+
TypedData_Get_Struct( self, RMtx2, &RMtx2_type, m );
|
479
544
|
|
480
545
|
RMtx2SetElement( m, 0, 1, NUM2DBL(f) );
|
481
546
|
|
@@ -489,7 +554,7 @@ RMtx2_set_e10( VALUE self, VALUE f )
|
|
489
554
|
{
|
490
555
|
RMtx2* m;
|
491
556
|
|
492
|
-
|
557
|
+
TypedData_Get_Struct( self, RMtx2, &RMtx2_type, m );
|
493
558
|
|
494
559
|
RMtx2SetElement( m, 1, 0, NUM2DBL(f) );
|
495
560
|
|
@@ -503,7 +568,7 @@ RMtx2_set_e11( VALUE self, VALUE f )
|
|
503
568
|
{
|
504
569
|
RMtx2* m;
|
505
570
|
|
506
|
-
|
571
|
+
TypedData_Get_Struct( self, RMtx2, &RMtx2_type, m );
|
507
572
|
|
508
573
|
RMtx2SetElement( m, 1, 1, NUM2DBL(f) );
|
509
574
|
|
@@ -523,7 +588,7 @@ RMtx2_getRow( VALUE self, VALUE row )
|
|
523
588
|
int at;
|
524
589
|
RVec2 out;
|
525
590
|
|
526
|
-
|
591
|
+
TypedData_Get_Struct( self, RMtx2, &RMtx2_type, m );
|
527
592
|
at = FIX2INT(row);
|
528
593
|
RMtx2GetRow( &out, m, at );
|
529
594
|
|
@@ -542,7 +607,7 @@ RMtx2_getColumn( VALUE self, VALUE column )
|
|
542
607
|
int at;
|
543
608
|
RVec2 out;
|
544
609
|
|
545
|
-
|
610
|
+
TypedData_Get_Struct( self, RMtx2, &RMtx2_type, m );
|
546
611
|
at = FIX2INT(column);
|
547
612
|
RMtx2GetColumn( &out, m, at );
|
548
613
|
|
@@ -562,8 +627,8 @@ RMtx2_setRow( VALUE self, VALUE v, VALUE row )
|
|
562
627
|
RVec2* in;
|
563
628
|
int at;
|
564
629
|
|
565
|
-
|
566
|
-
|
630
|
+
TypedData_Get_Struct( self, RMtx2, &RMtx2_type, m );
|
631
|
+
TypedData_Get_Struct( v, RVec2, &RVec2_type, in );
|
567
632
|
at = FIX2INT(row);
|
568
633
|
RMtx2SetRow( m, in, at );
|
569
634
|
|
@@ -583,8 +648,8 @@ RMtx2_setColumn( VALUE self, VALUE v, VALUE column )
|
|
583
648
|
RVec2* in;
|
584
649
|
int at;
|
585
650
|
|
586
|
-
|
587
|
-
|
651
|
+
TypedData_Get_Struct( self, RMtx2, &RMtx2_type, m );
|
652
|
+
TypedData_Get_Struct( v, RVec2, &RVec2_type, in );
|
588
653
|
at = FIX2INT(column);
|
589
654
|
RMtx2SetColumn( m, in, at );
|
590
655
|
|
@@ -603,7 +668,7 @@ RMtx2_setZero( VALUE self )
|
|
603
668
|
{
|
604
669
|
RMtx2* m = NULL;
|
605
670
|
|
606
|
-
|
671
|
+
TypedData_Get_Struct( self, RMtx2, &RMtx2_type, m );
|
607
672
|
RMtx2Zero( m );
|
608
673
|
|
609
674
|
return self;
|
@@ -619,7 +684,7 @@ RMtx2_setIdentity( VALUE self )
|
|
619
684
|
{
|
620
685
|
RMtx2* m = NULL;
|
621
686
|
|
622
|
-
|
687
|
+
TypedData_Get_Struct( self, RMtx2, &RMtx2_type, m );
|
623
688
|
RMtx2Identity( m );
|
624
689
|
|
625
690
|
return self;
|
@@ -636,10 +701,10 @@ RMtx2_getDeterminant( VALUE self )
|
|
636
701
|
RMtx2* m = NULL;
|
637
702
|
rmReal f;
|
638
703
|
|
639
|
-
|
704
|
+
TypedData_Get_Struct( self, RMtx2, &RMtx2_type, m );
|
640
705
|
f = RMtx2Determinant( m );
|
641
706
|
|
642
|
-
return
|
707
|
+
return DBL2NUM( f );
|
643
708
|
}
|
644
709
|
|
645
710
|
/*
|
@@ -653,7 +718,7 @@ RMtx2_transpose( VALUE self )
|
|
653
718
|
RMtx2* m = NULL;
|
654
719
|
RMtx2 out;
|
655
720
|
|
656
|
-
|
721
|
+
TypedData_Get_Struct( self, RMtx2, &RMtx2_type, m );
|
657
722
|
RMtx2Transpose( &out, m );
|
658
723
|
|
659
724
|
return RMtx2_from_source( &out );
|
@@ -669,7 +734,7 @@ RMtx2_transpose_intrusive( VALUE self )
|
|
669
734
|
{
|
670
735
|
RMtx2* m = NULL;
|
671
736
|
|
672
|
-
|
737
|
+
TypedData_Get_Struct( self, RMtx2, &RMtx2_type, m );
|
673
738
|
RMtx2Transpose( m, m );
|
674
739
|
|
675
740
|
return self;
|
@@ -686,7 +751,7 @@ RMtx2_inverse( VALUE self )
|
|
686
751
|
RMtx2* m = NULL;
|
687
752
|
RMtx2 out;
|
688
753
|
|
689
|
-
|
754
|
+
TypedData_Get_Struct( self, RMtx2, &RMtx2_type, m );
|
690
755
|
RMtx2Inverse( &out, m );
|
691
756
|
|
692
757
|
return RMtx2_from_source( &out );
|
@@ -702,7 +767,7 @@ RMtx2_invert( VALUE self )
|
|
702
767
|
{
|
703
768
|
RMtx2* m = NULL;
|
704
769
|
|
705
|
-
|
770
|
+
TypedData_Get_Struct( self, RMtx2, &RMtx2_type, m );
|
706
771
|
RMtx2Inverse( m, m );
|
707
772
|
|
708
773
|
return self;
|
@@ -719,7 +784,7 @@ RMtx2_rotation( VALUE self, VALUE radian )
|
|
719
784
|
RMtx2* m = NULL;
|
720
785
|
rmReal angle_radian;
|
721
786
|
|
722
|
-
|
787
|
+
TypedData_Get_Struct( self, RMtx2, &RMtx2_type, m );
|
723
788
|
angle_radian = NUM2DBL(radian);
|
724
789
|
RMtx2Rotation( m, angle_radian );
|
725
790
|
|
@@ -737,7 +802,7 @@ RMtx2_scaling( VALUE self, VALUE x, VALUE y )
|
|
737
802
|
RMtx2* m = NULL;
|
738
803
|
rmReal sx, sy;
|
739
804
|
|
740
|
-
|
805
|
+
TypedData_Get_Struct( self, RMtx2, &RMtx2_type, m );
|
741
806
|
sx = NUM2DBL(x);
|
742
807
|
sy = NUM2DBL(y);
|
743
808
|
RMtx2Scaling( m, sx, sy );
|
@@ -767,7 +832,7 @@ RMtx2_op_unary_minus( VALUE self )
|
|
767
832
|
RMtx2* m = NULL;
|
768
833
|
RMtx2 out;
|
769
834
|
|
770
|
-
|
835
|
+
TypedData_Get_Struct( self, RMtx2, &RMtx2_type, m );
|
771
836
|
RMtx2Scale( &out, m, (rmReal)(-1) );
|
772
837
|
|
773
838
|
return RMtx2_from_source( &out );
|
@@ -796,8 +861,8 @@ RMtx2_op_binary_plus( VALUE self, VALUE other )
|
|
796
861
|
}
|
797
862
|
#endif
|
798
863
|
|
799
|
-
|
800
|
-
|
864
|
+
TypedData_Get_Struct( self, RMtx2, &RMtx2_type, m1 );
|
865
|
+
TypedData_Get_Struct( other, RMtx2, &RMtx2_type, m2 );
|
801
866
|
RMtx2Add( &result, m1, m2 );
|
802
867
|
|
803
868
|
return RMtx2_from_source( &result );
|
@@ -826,8 +891,8 @@ RMtx2_op_binary_minus( VALUE self, VALUE other )
|
|
826
891
|
}
|
827
892
|
#endif
|
828
893
|
|
829
|
-
|
830
|
-
|
894
|
+
TypedData_Get_Struct( self, RMtx2, &RMtx2_type, m1 );
|
895
|
+
TypedData_Get_Struct( other, RMtx2, &RMtx2_type, m2 );
|
831
896
|
RMtx2Sub( &result, m1, m2 );
|
832
897
|
|
833
898
|
return RMtx2_from_source( &result );
|
@@ -846,11 +911,11 @@ RMtx2_op_binary_mult( VALUE self, VALUE other )
|
|
846
911
|
rmReal f;
|
847
912
|
RMtx2 result;
|
848
913
|
|
849
|
-
|
914
|
+
TypedData_Get_Struct( self, RMtx2, &RMtx2_type, m1 );
|
850
915
|
|
851
916
|
if ( IsRMtx2(other) )
|
852
917
|
{
|
853
|
-
|
918
|
+
TypedData_Get_Struct( other, RMtx2, &RMtx2_type, m2 );
|
854
919
|
RMtx2Mul( &result, m1, m2 );
|
855
920
|
}
|
856
921
|
else
|
@@ -884,8 +949,8 @@ RMtx2_op_binary_eq( VALUE self, VALUE other )
|
|
884
949
|
}
|
885
950
|
#endif
|
886
951
|
|
887
|
-
|
888
|
-
|
952
|
+
TypedData_Get_Struct( self, RMtx2, &RMtx2_type, m1 );
|
953
|
+
TypedData_Get_Struct( other, RMtx2, &RMtx2_type, m2 );
|
889
954
|
|
890
955
|
if ( !RMtx2Equal(m1,m2) )
|
891
956
|
return Qfalse;
|
@@ -915,8 +980,8 @@ RMtx2_op_assign_plus( VALUE self, VALUE other )
|
|
915
980
|
}
|
916
981
|
#endif
|
917
982
|
|
918
|
-
|
919
|
-
|
983
|
+
TypedData_Get_Struct( self, RMtx2, &RMtx2_type, m1 );
|
984
|
+
TypedData_Get_Struct( other, RMtx2, &RMtx2_type, m2 );
|
920
985
|
RMtx2Add( m1, m1, m2 );
|
921
986
|
|
922
987
|
return self;
|
@@ -944,8 +1009,8 @@ RMtx2_op_assign_minus( VALUE self, VALUE other )
|
|
944
1009
|
}
|
945
1010
|
#endif
|
946
1011
|
|
947
|
-
|
948
|
-
|
1012
|
+
TypedData_Get_Struct( self, RMtx2, &RMtx2_type, m1 );
|
1013
|
+
TypedData_Get_Struct( other, RMtx2, &RMtx2_type, m2 );
|
949
1014
|
RMtx2Sub( m1, m1, m2 );
|
950
1015
|
|
951
1016
|
return self;
|
@@ -963,11 +1028,11 @@ RMtx2_op_assign_mult( VALUE self, VALUE other )
|
|
963
1028
|
RMtx2* m2 = NULL;
|
964
1029
|
rmReal f;
|
965
1030
|
|
966
|
-
|
1031
|
+
TypedData_Get_Struct( self, RMtx2, &RMtx2_type, m1 );
|
967
1032
|
|
968
1033
|
if ( IsRMtx2(other) )
|
969
1034
|
{
|
970
|
-
|
1035
|
+
TypedData_Get_Struct( other, RMtx2, &RMtx2_type, m2 );
|
971
1036
|
RMtx2Mul( m1, m1, m2 );
|
972
1037
|
}
|
973
1038
|
else
|
@@ -987,7 +1052,7 @@ RMtx2_op_assign_mult( VALUE self, VALUE other )
|
|
987
1052
|
********************************************************************************/
|
988
1053
|
|
989
1054
|
/*
|
990
|
-
* Document-class:
|
1055
|
+
* Document-class: RMath3D::RMtx3
|
991
1056
|
* provies 3x3 matrix arithmetic.
|
992
1057
|
*
|
993
1058
|
* <b>Notice</b>
|
@@ -1000,25 +1065,27 @@ RMtx3_free( void* ptr )
|
|
1000
1065
|
xfree( ptr );
|
1001
1066
|
}
|
1002
1067
|
|
1068
|
+
static size_t
|
1069
|
+
RMtx3_memsize( const void* ptr )
|
1070
|
+
{
|
1071
|
+
const struct RMtx3* data = ptr;
|
1072
|
+
return data ? sizeof(*data) : 0;
|
1073
|
+
}
|
1074
|
+
|
1003
1075
|
static VALUE
|
1004
1076
|
RMtx3_from_source( RMtx3* src )
|
1005
1077
|
{
|
1006
|
-
RMtx3* v =
|
1007
|
-
|
1078
|
+
RMtx3* v = ZALLOC( struct RMtx3 );
|
1008
1079
|
RMtx3Copy( v, src );
|
1009
|
-
|
1010
|
-
return Data_Wrap_Struct( rb_cRMtx3, NULL, RMtx3_free, v );
|
1080
|
+
return TypedData_Wrap_Struct( rb_cRMtx3, &RMtx3_type, v );
|
1011
1081
|
}
|
1012
1082
|
|
1013
1083
|
|
1014
1084
|
static VALUE
|
1015
1085
|
RMtx3_allocate( VALUE klass )
|
1016
1086
|
{
|
1017
|
-
RMtx3* v =
|
1018
|
-
|
1019
|
-
memset( v, 0, sizeof(RMtx3) );
|
1020
|
-
|
1021
|
-
return Data_Wrap_Struct( klass, NULL, RMtx3_free, v );
|
1087
|
+
RMtx3* v = ZALLOC( RMtx3 );
|
1088
|
+
return TypedData_Wrap_Struct( klass, &RMtx3_type, v );
|
1022
1089
|
}
|
1023
1090
|
|
1024
1091
|
|
@@ -1035,7 +1102,7 @@ static VALUE
|
|
1035
1102
|
RMtx3_initialize( int argc, VALUE* argv, VALUE self )
|
1036
1103
|
{
|
1037
1104
|
RMtx3* v = NULL;
|
1038
|
-
|
1105
|
+
TypedData_Get_Struct( self, RMtx3, &RMtx3_type, v );
|
1039
1106
|
|
1040
1107
|
switch( argc )
|
1041
1108
|
{
|
@@ -1071,7 +1138,7 @@ RMtx3_initialize( int argc, VALUE* argv, VALUE self )
|
|
1071
1138
|
{
|
1072
1139
|
/* Copy Constructor */
|
1073
1140
|
RMtx3* other;
|
1074
|
-
|
1141
|
+
TypedData_Get_Struct( arg , RMtx3, &RMtx3_type, other );
|
1075
1142
|
RMtx3Copy( v, other );
|
1076
1143
|
return self;
|
1077
1144
|
}
|
@@ -1152,7 +1219,7 @@ RMtx3_to_s( VALUE self )
|
|
1152
1219
|
int row, col, n;
|
1153
1220
|
rmReal val;
|
1154
1221
|
|
1155
|
-
|
1222
|
+
TypedData_Get_Struct( self, RMtx3, &RMtx3_type, v );
|
1156
1223
|
|
1157
1224
|
p = dest;
|
1158
1225
|
for ( row = 0; row < 3; ++row )
|
@@ -1196,7 +1263,7 @@ RMtx3_to_a( VALUE self )
|
|
1196
1263
|
int row, col;
|
1197
1264
|
RMtx3* v = NULL;
|
1198
1265
|
VALUE dbl[9];
|
1199
|
-
|
1266
|
+
TypedData_Get_Struct( self, RMtx3, &RMtx3_type, v );
|
1200
1267
|
|
1201
1268
|
/* column-major */
|
1202
1269
|
for ( col = 0; col < 3; ++col )
|
@@ -1204,7 +1271,7 @@ RMtx3_to_a( VALUE self )
|
|
1204
1271
|
for ( row = 0; row < 3; ++row )
|
1205
1272
|
{
|
1206
1273
|
int i = 3*col + row;
|
1207
|
-
dbl[i] =
|
1274
|
+
dbl[i] = DBL2NUM(RMtx3GetElement(v,row,col));
|
1208
1275
|
}
|
1209
1276
|
}
|
1210
1277
|
|
@@ -1220,7 +1287,7 @@ static VALUE
|
|
1220
1287
|
RMtx3_coerce( VALUE self, VALUE other )
|
1221
1288
|
{
|
1222
1289
|
RMtx3* v = NULL;
|
1223
|
-
|
1290
|
+
TypedData_Get_Struct( self, RMtx3, &RMtx3_type, v );
|
1224
1291
|
|
1225
1292
|
switch( TYPE(other) )
|
1226
1293
|
{
|
@@ -1267,7 +1334,7 @@ RMtx3_setElements( int argc, VALUE* argv, VALUE self )
|
|
1267
1334
|
}
|
1268
1335
|
#endif
|
1269
1336
|
|
1270
|
-
|
1337
|
+
TypedData_Get_Struct( self, RMtx3, &RMtx3_type, m );
|
1271
1338
|
for ( row = 0; row < 3; ++row )
|
1272
1339
|
{
|
1273
1340
|
for ( col = 0; col < 3; ++col )
|
@@ -1292,7 +1359,7 @@ RMtx3_setElement( VALUE self, VALUE r, VALUE c, VALUE f )
|
|
1292
1359
|
int row, col;
|
1293
1360
|
rmReal flt;
|
1294
1361
|
|
1295
|
-
|
1362
|
+
TypedData_Get_Struct( self, RMtx3, &RMtx3_type, m );
|
1296
1363
|
row = FIX2INT(r);
|
1297
1364
|
col = FIX2INT(c);
|
1298
1365
|
flt = NUM2DBL(f);
|
@@ -1314,12 +1381,12 @@ RMtx3_getElement( VALUE self, VALUE r, VALUE c )
|
|
1314
1381
|
int row, col;
|
1315
1382
|
rmReal flt;
|
1316
1383
|
|
1317
|
-
|
1384
|
+
TypedData_Get_Struct( self, RMtx3, &RMtx3_type, m );
|
1318
1385
|
row = FIX2INT(r);
|
1319
1386
|
col = FIX2INT(c);
|
1320
1387
|
flt = RMtx3GetElement( m, row, col );
|
1321
1388
|
|
1322
|
-
return
|
1389
|
+
return DBL2NUM( flt );
|
1323
1390
|
}
|
1324
1391
|
|
1325
1392
|
/* Returns the element at row 0 and column 0.
|
@@ -1329,9 +1396,9 @@ RMtx3_get_e00( VALUE self )
|
|
1329
1396
|
{
|
1330
1397
|
RMtx3* m;
|
1331
1398
|
|
1332
|
-
|
1399
|
+
TypedData_Get_Struct( self, RMtx3, &RMtx3_type, m );
|
1333
1400
|
|
1334
|
-
return
|
1401
|
+
return DBL2NUM( RMtx3GetElement( m, 0, 0 ) );
|
1335
1402
|
}
|
1336
1403
|
|
1337
1404
|
/* Returns the element at row 0 and column 1.
|
@@ -1341,9 +1408,9 @@ RMtx3_get_e01( VALUE self )
|
|
1341
1408
|
{
|
1342
1409
|
RMtx3* m;
|
1343
1410
|
|
1344
|
-
|
1411
|
+
TypedData_Get_Struct( self, RMtx3, &RMtx3_type, m );
|
1345
1412
|
|
1346
|
-
return
|
1413
|
+
return DBL2NUM( RMtx3GetElement( m, 0, 1 ) );
|
1347
1414
|
}
|
1348
1415
|
|
1349
1416
|
/* Returns the element at row 0 and column 2.
|
@@ -1353,9 +1420,9 @@ RMtx3_get_e02( VALUE self )
|
|
1353
1420
|
{
|
1354
1421
|
RMtx3* m;
|
1355
1422
|
|
1356
|
-
|
1423
|
+
TypedData_Get_Struct( self, RMtx3, &RMtx3_type, m );
|
1357
1424
|
|
1358
|
-
return
|
1425
|
+
return DBL2NUM( RMtx3GetElement( m, 0, 2 ) );
|
1359
1426
|
}
|
1360
1427
|
|
1361
1428
|
/* Returns the element at row 1 and column 0.
|
@@ -1365,9 +1432,9 @@ RMtx3_get_e10( VALUE self )
|
|
1365
1432
|
{
|
1366
1433
|
RMtx3* m;
|
1367
1434
|
|
1368
|
-
|
1435
|
+
TypedData_Get_Struct( self, RMtx3, &RMtx3_type, m );
|
1369
1436
|
|
1370
|
-
return
|
1437
|
+
return DBL2NUM( RMtx3GetElement( m, 1, 0 ) );
|
1371
1438
|
}
|
1372
1439
|
|
1373
1440
|
/* Returns the element at row 1 and column 1.
|
@@ -1377,9 +1444,9 @@ RMtx3_get_e11( VALUE self )
|
|
1377
1444
|
{
|
1378
1445
|
RMtx3* m;
|
1379
1446
|
|
1380
|
-
|
1447
|
+
TypedData_Get_Struct( self, RMtx3, &RMtx3_type, m );
|
1381
1448
|
|
1382
|
-
return
|
1449
|
+
return DBL2NUM( RMtx3GetElement( m, 1, 1 ) );
|
1383
1450
|
}
|
1384
1451
|
|
1385
1452
|
/* Returns the element at row 1 and column 2.
|
@@ -1389,9 +1456,9 @@ RMtx3_get_e12( VALUE self )
|
|
1389
1456
|
{
|
1390
1457
|
RMtx3* m;
|
1391
1458
|
|
1392
|
-
|
1459
|
+
TypedData_Get_Struct( self, RMtx3, &RMtx3_type, m );
|
1393
1460
|
|
1394
|
-
return
|
1461
|
+
return DBL2NUM( RMtx3GetElement( m, 1, 2 ) );
|
1395
1462
|
}
|
1396
1463
|
|
1397
1464
|
/* Returns the element at row 2 and column 0.
|
@@ -1401,9 +1468,9 @@ RMtx3_get_e20( VALUE self )
|
|
1401
1468
|
{
|
1402
1469
|
RMtx3* m;
|
1403
1470
|
|
1404
|
-
|
1471
|
+
TypedData_Get_Struct( self, RMtx3, &RMtx3_type, m );
|
1405
1472
|
|
1406
|
-
return
|
1473
|
+
return DBL2NUM( RMtx3GetElement( m, 2, 0 ) );
|
1407
1474
|
}
|
1408
1475
|
|
1409
1476
|
/* Returns the element at row 2 and column 1.
|
@@ -1413,9 +1480,9 @@ RMtx3_get_e21( VALUE self )
|
|
1413
1480
|
{
|
1414
1481
|
RMtx3* m;
|
1415
1482
|
|
1416
|
-
|
1483
|
+
TypedData_Get_Struct( self, RMtx3, &RMtx3_type, m );
|
1417
1484
|
|
1418
|
-
return
|
1485
|
+
return DBL2NUM( RMtx3GetElement( m, 2, 1 ) );
|
1419
1486
|
}
|
1420
1487
|
|
1421
1488
|
/* Returns the element at row 2 and column 2.
|
@@ -1425,9 +1492,9 @@ RMtx3_get_e22( VALUE self )
|
|
1425
1492
|
{
|
1426
1493
|
RMtx3* m;
|
1427
1494
|
|
1428
|
-
|
1495
|
+
TypedData_Get_Struct( self, RMtx3, &RMtx3_type, m );
|
1429
1496
|
|
1430
|
-
return
|
1497
|
+
return DBL2NUM( RMtx3GetElement( m, 2, 2 ) );
|
1431
1498
|
}
|
1432
1499
|
|
1433
1500
|
|
@@ -1438,7 +1505,7 @@ RMtx3_set_e00( VALUE self, VALUE f )
|
|
1438
1505
|
{
|
1439
1506
|
RMtx3* m;
|
1440
1507
|
|
1441
|
-
|
1508
|
+
TypedData_Get_Struct( self, RMtx3, &RMtx3_type, m );
|
1442
1509
|
|
1443
1510
|
RMtx3SetElement( m, 0, 0, NUM2DBL(f) );
|
1444
1511
|
|
@@ -1452,7 +1519,7 @@ RMtx3_set_e01( VALUE self, VALUE f )
|
|
1452
1519
|
{
|
1453
1520
|
RMtx3* m;
|
1454
1521
|
|
1455
|
-
|
1522
|
+
TypedData_Get_Struct( self, RMtx3, &RMtx3_type, m );
|
1456
1523
|
|
1457
1524
|
RMtx3SetElement( m, 0, 1, NUM2DBL(f) );
|
1458
1525
|
|
@@ -1466,7 +1533,7 @@ RMtx3_set_e02( VALUE self, VALUE f )
|
|
1466
1533
|
{
|
1467
1534
|
RMtx3* m;
|
1468
1535
|
|
1469
|
-
|
1536
|
+
TypedData_Get_Struct( self, RMtx3, &RMtx3_type, m );
|
1470
1537
|
|
1471
1538
|
RMtx3SetElement( m, 0, 2, NUM2DBL(f) );
|
1472
1539
|
|
@@ -1480,7 +1547,7 @@ RMtx3_set_e10( VALUE self, VALUE f )
|
|
1480
1547
|
{
|
1481
1548
|
RMtx3* m;
|
1482
1549
|
|
1483
|
-
|
1550
|
+
TypedData_Get_Struct( self, RMtx3, &RMtx3_type, m );
|
1484
1551
|
|
1485
1552
|
RMtx3SetElement( m, 1, 0, NUM2DBL(f) );
|
1486
1553
|
|
@@ -1494,7 +1561,7 @@ RMtx3_set_e11( VALUE self, VALUE f )
|
|
1494
1561
|
{
|
1495
1562
|
RMtx3* m;
|
1496
1563
|
|
1497
|
-
|
1564
|
+
TypedData_Get_Struct( self, RMtx3, &RMtx3_type, m );
|
1498
1565
|
|
1499
1566
|
RMtx3SetElement( m, 1, 1, NUM2DBL(f) );
|
1500
1567
|
|
@@ -1508,7 +1575,7 @@ RMtx3_set_e12( VALUE self, VALUE f )
|
|
1508
1575
|
{
|
1509
1576
|
RMtx3* m;
|
1510
1577
|
|
1511
|
-
|
1578
|
+
TypedData_Get_Struct( self, RMtx3, &RMtx3_type, m );
|
1512
1579
|
|
1513
1580
|
RMtx3SetElement( m, 1, 2, NUM2DBL(f) );
|
1514
1581
|
|
@@ -1522,7 +1589,7 @@ RMtx3_set_e20( VALUE self, VALUE f )
|
|
1522
1589
|
{
|
1523
1590
|
RMtx3* m;
|
1524
1591
|
|
1525
|
-
|
1592
|
+
TypedData_Get_Struct( self, RMtx3, &RMtx3_type, m );
|
1526
1593
|
|
1527
1594
|
RMtx3SetElement( m, 2, 0, NUM2DBL(f) );
|
1528
1595
|
|
@@ -1536,7 +1603,7 @@ RMtx3_set_e21( VALUE self, VALUE f )
|
|
1536
1603
|
{
|
1537
1604
|
RMtx3* m;
|
1538
1605
|
|
1539
|
-
|
1606
|
+
TypedData_Get_Struct( self, RMtx3, &RMtx3_type, m );
|
1540
1607
|
|
1541
1608
|
RMtx3SetElement( m, 2, 1, NUM2DBL(f) );
|
1542
1609
|
|
@@ -1550,7 +1617,7 @@ RMtx3_set_e22( VALUE self, VALUE f )
|
|
1550
1617
|
{
|
1551
1618
|
RMtx3* m;
|
1552
1619
|
|
1553
|
-
|
1620
|
+
TypedData_Get_Struct( self, RMtx3, &RMtx3_type, m );
|
1554
1621
|
|
1555
1622
|
RMtx3SetElement( m, 2, 2, NUM2DBL(f) );
|
1556
1623
|
|
@@ -1571,7 +1638,7 @@ RMtx3_getRow( VALUE self, VALUE row )
|
|
1571
1638
|
int at;
|
1572
1639
|
RVec3 out;
|
1573
1640
|
|
1574
|
-
|
1641
|
+
TypedData_Get_Struct( self, RMtx3, &RMtx3_type, m );
|
1575
1642
|
at = FIX2INT(row);
|
1576
1643
|
RMtx3GetRow( &out, m, at );
|
1577
1644
|
|
@@ -1590,7 +1657,7 @@ RMtx3_getColumn( VALUE self, VALUE column )
|
|
1590
1657
|
int at;
|
1591
1658
|
RVec3 out;
|
1592
1659
|
|
1593
|
-
|
1660
|
+
TypedData_Get_Struct( self, RMtx3, &RMtx3_type, m );
|
1594
1661
|
at = FIX2INT(column);
|
1595
1662
|
RMtx3GetColumn( &out, m, at );
|
1596
1663
|
|
@@ -1610,8 +1677,8 @@ RMtx3_setRow( VALUE self, VALUE v, VALUE row )
|
|
1610
1677
|
RVec3* in;
|
1611
1678
|
int at;
|
1612
1679
|
|
1613
|
-
|
1614
|
-
|
1680
|
+
TypedData_Get_Struct( self, RMtx3, &RMtx3_type, m );
|
1681
|
+
TypedData_Get_Struct( v, RVec3, &RVec3_type, in );
|
1615
1682
|
at = FIX2INT(row);
|
1616
1683
|
RMtx3SetRow( m, in, at );
|
1617
1684
|
|
@@ -1631,8 +1698,8 @@ RMtx3_setColumn( VALUE self, VALUE v, VALUE column )
|
|
1631
1698
|
RVec3* in;
|
1632
1699
|
int at;
|
1633
1700
|
|
1634
|
-
|
1635
|
-
|
1701
|
+
TypedData_Get_Struct( self, RMtx3, &RMtx3_type, m );
|
1702
|
+
TypedData_Get_Struct( v, RVec3, &RVec3_type, in );
|
1636
1703
|
at = FIX2INT(column);
|
1637
1704
|
RMtx3SetColumn( m, in, at );
|
1638
1705
|
|
@@ -1651,7 +1718,7 @@ RMtx3_setZero( VALUE self )
|
|
1651
1718
|
{
|
1652
1719
|
RMtx3* m = NULL;
|
1653
1720
|
|
1654
|
-
|
1721
|
+
TypedData_Get_Struct( self, RMtx3, &RMtx3_type, m );
|
1655
1722
|
RMtx3Zero( m );
|
1656
1723
|
|
1657
1724
|
return self;
|
@@ -1667,7 +1734,7 @@ RMtx3_setIdentity( VALUE self )
|
|
1667
1734
|
{
|
1668
1735
|
RMtx3* m = NULL;
|
1669
1736
|
|
1670
|
-
|
1737
|
+
TypedData_Get_Struct( self, RMtx3, &RMtx3_type, m );
|
1671
1738
|
RMtx3Identity( m );
|
1672
1739
|
|
1673
1740
|
return self;
|
@@ -1684,10 +1751,10 @@ RMtx3_getDeterminant( VALUE self )
|
|
1684
1751
|
RMtx3* m = NULL;
|
1685
1752
|
rmReal f;
|
1686
1753
|
|
1687
|
-
|
1754
|
+
TypedData_Get_Struct( self, RMtx3, &RMtx3_type, m );
|
1688
1755
|
f = RMtx3Determinant( m );
|
1689
1756
|
|
1690
|
-
return
|
1757
|
+
return DBL2NUM( f );
|
1691
1758
|
}
|
1692
1759
|
|
1693
1760
|
/*
|
@@ -1701,7 +1768,7 @@ RMtx3_transpose( VALUE self )
|
|
1701
1768
|
RMtx3* m = NULL;
|
1702
1769
|
RMtx3 out;
|
1703
1770
|
|
1704
|
-
|
1771
|
+
TypedData_Get_Struct( self, RMtx3, &RMtx3_type, m );
|
1705
1772
|
RMtx3Transpose( &out, m );
|
1706
1773
|
|
1707
1774
|
return RMtx3_from_source( &out );
|
@@ -1717,7 +1784,7 @@ RMtx3_transpose_intrusive( VALUE self )
|
|
1717
1784
|
{
|
1718
1785
|
RMtx3* m = NULL;
|
1719
1786
|
|
1720
|
-
|
1787
|
+
TypedData_Get_Struct( self, RMtx3, &RMtx3_type, m );
|
1721
1788
|
RMtx3Transpose( m, m );
|
1722
1789
|
|
1723
1790
|
return self;
|
@@ -1734,7 +1801,7 @@ RMtx3_inverse( VALUE self )
|
|
1734
1801
|
RMtx3* m = NULL;
|
1735
1802
|
RMtx3 out;
|
1736
1803
|
|
1737
|
-
|
1804
|
+
TypedData_Get_Struct( self, RMtx3, &RMtx3_type, m );
|
1738
1805
|
RMtx3Inverse( &out, m );
|
1739
1806
|
|
1740
1807
|
return RMtx3_from_source( &out );
|
@@ -1750,7 +1817,7 @@ RMtx3_invert( VALUE self )
|
|
1750
1817
|
{
|
1751
1818
|
RMtx3* m = NULL;
|
1752
1819
|
|
1753
|
-
|
1820
|
+
TypedData_Get_Struct( self, RMtx3, &RMtx3_type, m );
|
1754
1821
|
RMtx3Inverse( m, m );
|
1755
1822
|
|
1756
1823
|
return self;
|
@@ -1767,7 +1834,7 @@ RMtx3_rotationX( VALUE self, VALUE radian )
|
|
1767
1834
|
RMtx3* m = NULL;
|
1768
1835
|
rmReal angle_radian;
|
1769
1836
|
|
1770
|
-
|
1837
|
+
TypedData_Get_Struct( self, RMtx3, &RMtx3_type, m );
|
1771
1838
|
angle_radian = NUM2DBL(radian);
|
1772
1839
|
RMtx3RotationX( m, angle_radian );
|
1773
1840
|
|
@@ -1785,7 +1852,7 @@ RMtx3_rotationY( VALUE self, VALUE radian )
|
|
1785
1852
|
RMtx3* m = NULL;
|
1786
1853
|
rmReal angle_radian;
|
1787
1854
|
|
1788
|
-
|
1855
|
+
TypedData_Get_Struct( self, RMtx3, &RMtx3_type, m );
|
1789
1856
|
angle_radian = NUM2DBL(radian);
|
1790
1857
|
RMtx3RotationY( m, angle_radian );
|
1791
1858
|
|
@@ -1803,7 +1870,7 @@ RMtx3_rotationZ( VALUE self, VALUE radian )
|
|
1803
1870
|
RMtx3* m = NULL;
|
1804
1871
|
rmReal angle_radian;
|
1805
1872
|
|
1806
|
-
|
1873
|
+
TypedData_Get_Struct( self, RMtx3, &RMtx3_type, m );
|
1807
1874
|
angle_radian = NUM2DBL(radian);
|
1808
1875
|
RMtx3RotationZ( m, angle_radian );
|
1809
1876
|
|
@@ -1822,8 +1889,8 @@ RMtx3_rotationAxis( VALUE self, VALUE axis, VALUE radian )
|
|
1822
1889
|
RVec3* vAxis = NULL;
|
1823
1890
|
rmReal angle_radian;
|
1824
1891
|
|
1825
|
-
|
1826
|
-
|
1892
|
+
TypedData_Get_Struct( self, RMtx3, &RMtx3_type, m );
|
1893
|
+
TypedData_Get_Struct( axis, RVec3, &RVec3_type, vAxis );
|
1827
1894
|
angle_radian = NUM2DBL(radian);
|
1828
1895
|
RMtx3RotationAxis( m, vAxis, angle_radian );
|
1829
1896
|
|
@@ -1841,8 +1908,8 @@ RMtx3_rotationQuaternion( VALUE self, VALUE quat )
|
|
1841
1908
|
RMtx3* m = NULL;
|
1842
1909
|
RQuat* q = NULL;
|
1843
1910
|
|
1844
|
-
|
1845
|
-
|
1911
|
+
TypedData_Get_Struct( self, RMtx3, &RMtx3_type, m );
|
1912
|
+
TypedData_Get_Struct( quat, RQuat, &RQuat_type, q );
|
1846
1913
|
RMtx3RotationQuaternion( m, q );
|
1847
1914
|
|
1848
1915
|
return self;
|
@@ -1859,7 +1926,7 @@ RMtx3_scaling( VALUE self, VALUE x, VALUE y, VALUE z )
|
|
1859
1926
|
RMtx3* m = NULL;
|
1860
1927
|
rmReal sx, sy, sz;
|
1861
1928
|
|
1862
|
-
|
1929
|
+
TypedData_Get_Struct( self, RMtx3, &RMtx3_type, m );
|
1863
1930
|
sx = NUM2DBL(x);
|
1864
1931
|
sy = NUM2DBL(y);
|
1865
1932
|
sz = NUM2DBL(z);
|
@@ -1890,7 +1957,7 @@ RMtx3_op_unary_minus( VALUE self )
|
|
1890
1957
|
RMtx3* m = NULL;
|
1891
1958
|
RMtx3 out;
|
1892
1959
|
|
1893
|
-
|
1960
|
+
TypedData_Get_Struct( self, RMtx3, &RMtx3_type, m );
|
1894
1961
|
RMtx3Scale( &out, m, (rmReal)(-1) );
|
1895
1962
|
|
1896
1963
|
return RMtx3_from_source( &out );
|
@@ -1919,8 +1986,8 @@ RMtx3_op_binary_plus( VALUE self, VALUE other )
|
|
1919
1986
|
}
|
1920
1987
|
#endif
|
1921
1988
|
|
1922
|
-
|
1923
|
-
|
1989
|
+
TypedData_Get_Struct( self, RMtx3, &RMtx3_type, m1 );
|
1990
|
+
TypedData_Get_Struct( other, RMtx3, &RMtx3_type, m2 );
|
1924
1991
|
RMtx3Add( &result, m1, m2 );
|
1925
1992
|
|
1926
1993
|
return RMtx3_from_source( &result );
|
@@ -1949,8 +2016,8 @@ RMtx3_op_binary_minus( VALUE self, VALUE other )
|
|
1949
2016
|
}
|
1950
2017
|
#endif
|
1951
2018
|
|
1952
|
-
|
1953
|
-
|
2019
|
+
TypedData_Get_Struct( self, RMtx3, &RMtx3_type, m1 );
|
2020
|
+
TypedData_Get_Struct( other, RMtx3, &RMtx3_type, m2 );
|
1954
2021
|
RMtx3Sub( &result, m1, m2 );
|
1955
2022
|
|
1956
2023
|
return RMtx3_from_source( &result );
|
@@ -1969,11 +2036,11 @@ RMtx3_op_binary_mult( VALUE self, VALUE other )
|
|
1969
2036
|
rmReal f;
|
1970
2037
|
RMtx3 result;
|
1971
2038
|
|
1972
|
-
|
2039
|
+
TypedData_Get_Struct( self, RMtx3, &RMtx3_type, m1 );
|
1973
2040
|
|
1974
2041
|
if ( IsRMtx3(other) )
|
1975
2042
|
{
|
1976
|
-
|
2043
|
+
TypedData_Get_Struct( other, RMtx3, &RMtx3_type, m2 );
|
1977
2044
|
RMtx3Mul( &result, m1, m2 );
|
1978
2045
|
}
|
1979
2046
|
else
|
@@ -2007,8 +2074,8 @@ RMtx3_op_binary_eq( VALUE self, VALUE other )
|
|
2007
2074
|
}
|
2008
2075
|
#endif
|
2009
2076
|
|
2010
|
-
|
2011
|
-
|
2077
|
+
TypedData_Get_Struct( self, RMtx3, &RMtx3_type, m1 );
|
2078
|
+
TypedData_Get_Struct( other, RMtx3, &RMtx3_type, m2 );
|
2012
2079
|
|
2013
2080
|
if ( !RMtx3Equal(m1,m2) )
|
2014
2081
|
return Qfalse;
|
@@ -2038,8 +2105,8 @@ RMtx3_op_assign_plus( VALUE self, VALUE other )
|
|
2038
2105
|
}
|
2039
2106
|
#endif
|
2040
2107
|
|
2041
|
-
|
2042
|
-
|
2108
|
+
TypedData_Get_Struct( self, RMtx3, &RMtx3_type, m1 );
|
2109
|
+
TypedData_Get_Struct( other, RMtx3, &RMtx3_type, m2 );
|
2043
2110
|
RMtx3Add( m1, m1, m2 );
|
2044
2111
|
|
2045
2112
|
return self;
|
@@ -2067,8 +2134,8 @@ RMtx3_op_assign_minus( VALUE self, VALUE other )
|
|
2067
2134
|
}
|
2068
2135
|
#endif
|
2069
2136
|
|
2070
|
-
|
2071
|
-
|
2137
|
+
TypedData_Get_Struct( self, RMtx3, &RMtx3_type, m1 );
|
2138
|
+
TypedData_Get_Struct( other, RMtx3, &RMtx3_type, m2 );
|
2072
2139
|
RMtx3Sub( m1, m1, m2 );
|
2073
2140
|
|
2074
2141
|
return self;
|
@@ -2086,11 +2153,11 @@ RMtx3_op_assign_mult( VALUE self, VALUE other )
|
|
2086
2153
|
RMtx3* m2 = NULL;
|
2087
2154
|
rmReal f;
|
2088
2155
|
|
2089
|
-
|
2156
|
+
TypedData_Get_Struct( self, RMtx3, &RMtx3_type, m1 );
|
2090
2157
|
|
2091
2158
|
if ( IsRMtx3(other) )
|
2092
2159
|
{
|
2093
|
-
|
2160
|
+
TypedData_Get_Struct( other, RMtx3, &RMtx3_type, m2 );
|
2094
2161
|
RMtx3Mul( m1, m1, m2 );
|
2095
2162
|
}
|
2096
2163
|
else
|
@@ -2110,7 +2177,7 @@ RMtx3_op_assign_mult( VALUE self, VALUE other )
|
|
2110
2177
|
********************************************************************************/
|
2111
2178
|
|
2112
2179
|
/*
|
2113
|
-
* Document-class:
|
2180
|
+
* Document-class: RMath3D::RMtx4
|
2114
2181
|
* provies 4x4 matrix arithmetic.
|
2115
2182
|
*
|
2116
2183
|
* <b>Notice</b>
|
@@ -2123,25 +2190,27 @@ RMtx4_free( void* ptr )
|
|
2123
2190
|
xfree( ptr );
|
2124
2191
|
}
|
2125
2192
|
|
2193
|
+
static size_t
|
2194
|
+
RMtx4_memsize( const void* ptr )
|
2195
|
+
{
|
2196
|
+
const struct RMtx4* data = ptr;
|
2197
|
+
return data ? sizeof(*data) : 0;
|
2198
|
+
}
|
2199
|
+
|
2126
2200
|
static VALUE
|
2127
2201
|
RMtx4_from_source( RMtx4* src )
|
2128
2202
|
{
|
2129
|
-
RMtx4* v =
|
2130
|
-
|
2203
|
+
RMtx4* v = ZALLOC( struct RMtx4 );
|
2131
2204
|
RMtx4Copy( v, src );
|
2132
|
-
|
2133
|
-
return Data_Wrap_Struct( rb_cRMtx4, NULL, RMtx4_free, v );
|
2205
|
+
return TypedData_Wrap_Struct( rb_cRMtx4, &RMtx4_type, v );
|
2134
2206
|
}
|
2135
2207
|
|
2136
2208
|
|
2137
2209
|
static VALUE
|
2138
2210
|
RMtx4_allocate( VALUE klass )
|
2139
2211
|
{
|
2140
|
-
RMtx4* v =
|
2141
|
-
|
2142
|
-
memset( v, 0, sizeof(RMtx4) );
|
2143
|
-
|
2144
|
-
return Data_Wrap_Struct( klass, NULL, RMtx4_free, v );
|
2212
|
+
RMtx4* v = ZALLOC( RMtx4 );
|
2213
|
+
return TypedData_Wrap_Struct( klass, &RMtx4_type, v );
|
2145
2214
|
}
|
2146
2215
|
|
2147
2216
|
|
@@ -2158,7 +2227,7 @@ static VALUE
|
|
2158
2227
|
RMtx4_initialize( int argc, VALUE* argv, VALUE self )
|
2159
2228
|
{
|
2160
2229
|
RMtx4* v = NULL;
|
2161
|
-
|
2230
|
+
TypedData_Get_Struct( self, RMtx4, &RMtx4_type, v );
|
2162
2231
|
|
2163
2232
|
switch( argc )
|
2164
2233
|
{
|
@@ -2195,7 +2264,7 @@ RMtx4_initialize( int argc, VALUE* argv, VALUE self )
|
|
2195
2264
|
{
|
2196
2265
|
/* Copy Constructor */
|
2197
2266
|
RMtx4* other;
|
2198
|
-
|
2267
|
+
TypedData_Get_Struct( arg , RMtx4, &RMtx4_type, other );
|
2199
2268
|
RMtx4Copy( v, other );
|
2200
2269
|
return self;
|
2201
2270
|
}
|
@@ -2276,7 +2345,7 @@ RMtx4_to_s( VALUE self )
|
|
2276
2345
|
int row, col, n;
|
2277
2346
|
rmReal val;
|
2278
2347
|
|
2279
|
-
|
2348
|
+
TypedData_Get_Struct( self, RMtx4, &RMtx4_type, v );
|
2280
2349
|
|
2281
2350
|
p = dest;
|
2282
2351
|
for ( row = 0; row < 4; ++row )
|
@@ -2322,7 +2391,7 @@ RMtx4_to_a( VALUE self )
|
|
2322
2391
|
int row, col;
|
2323
2392
|
RMtx4* v = NULL;
|
2324
2393
|
VALUE dbl[16];
|
2325
|
-
|
2394
|
+
TypedData_Get_Struct( self, RMtx4, &RMtx4_type, v );
|
2326
2395
|
|
2327
2396
|
/* column-major */
|
2328
2397
|
for ( col = 0; col < 4; ++col )
|
@@ -2330,7 +2399,7 @@ RMtx4_to_a( VALUE self )
|
|
2330
2399
|
for ( row = 0; row < 4; ++row )
|
2331
2400
|
{
|
2332
2401
|
int i = 4*col + row;
|
2333
|
-
dbl[i] =
|
2402
|
+
dbl[i] = DBL2NUM(RMtx4GetElement(v,row,col));
|
2334
2403
|
}
|
2335
2404
|
}
|
2336
2405
|
|
@@ -2346,7 +2415,7 @@ static VALUE
|
|
2346
2415
|
RMtx4_coerce( VALUE self, VALUE other )
|
2347
2416
|
{
|
2348
2417
|
RMtx4* v = NULL;
|
2349
|
-
|
2418
|
+
TypedData_Get_Struct( self, RMtx4, &RMtx4_type, v );
|
2350
2419
|
|
2351
2420
|
switch( TYPE(other) )
|
2352
2421
|
{
|
@@ -2393,7 +2462,7 @@ RMtx4_setElements( int argc, VALUE* argv, VALUE self )
|
|
2393
2462
|
}
|
2394
2463
|
#endif
|
2395
2464
|
|
2396
|
-
|
2465
|
+
TypedData_Get_Struct( self, RMtx4, &RMtx4_type, m );
|
2397
2466
|
for ( row = 0; row < 4; ++row )
|
2398
2467
|
{
|
2399
2468
|
for ( col = 0; col < 4; ++col )
|
@@ -2418,7 +2487,7 @@ RMtx4_setElement( VALUE self, VALUE r, VALUE c, VALUE f )
|
|
2418
2487
|
int row, col;
|
2419
2488
|
rmReal flt;
|
2420
2489
|
|
2421
|
-
|
2490
|
+
TypedData_Get_Struct( self, RMtx4, &RMtx4_type, m );
|
2422
2491
|
row = FIX2INT(r);
|
2423
2492
|
col = FIX2INT(c);
|
2424
2493
|
flt = NUM2DBL(f);
|
@@ -2440,12 +2509,12 @@ RMtx4_getElement( VALUE self, VALUE r, VALUE c )
|
|
2440
2509
|
int row, col;
|
2441
2510
|
rmReal flt;
|
2442
2511
|
|
2443
|
-
|
2512
|
+
TypedData_Get_Struct( self, RMtx4, &RMtx4_type, m );
|
2444
2513
|
row = FIX2INT(r);
|
2445
2514
|
col = FIX2INT(c);
|
2446
2515
|
flt = RMtx4GetElement( m, row, col );
|
2447
2516
|
|
2448
|
-
return
|
2517
|
+
return DBL2NUM( flt );
|
2449
2518
|
}
|
2450
2519
|
|
2451
2520
|
/* Returns the element at row 0 and column 0.
|
@@ -2455,9 +2524,9 @@ RMtx4_get_e00( VALUE self )
|
|
2455
2524
|
{
|
2456
2525
|
RMtx4* m;
|
2457
2526
|
|
2458
|
-
|
2527
|
+
TypedData_Get_Struct( self, RMtx4, &RMtx4_type, m );
|
2459
2528
|
|
2460
|
-
return
|
2529
|
+
return DBL2NUM( RMtx4GetElement( m, 0, 0 ) );
|
2461
2530
|
}
|
2462
2531
|
|
2463
2532
|
|
@@ -2468,9 +2537,9 @@ RMtx4_get_e01( VALUE self )
|
|
2468
2537
|
{
|
2469
2538
|
RMtx4* m;
|
2470
2539
|
|
2471
|
-
|
2540
|
+
TypedData_Get_Struct( self, RMtx4, &RMtx4_type, m );
|
2472
2541
|
|
2473
|
-
return
|
2542
|
+
return DBL2NUM( RMtx4GetElement( m, 0, 1 ) );
|
2474
2543
|
}
|
2475
2544
|
|
2476
2545
|
|
@@ -2481,9 +2550,9 @@ RMtx4_get_e02( VALUE self )
|
|
2481
2550
|
{
|
2482
2551
|
RMtx4* m;
|
2483
2552
|
|
2484
|
-
|
2553
|
+
TypedData_Get_Struct( self, RMtx4, &RMtx4_type, m );
|
2485
2554
|
|
2486
|
-
return
|
2555
|
+
return DBL2NUM( RMtx4GetElement( m, 0, 2 ) );
|
2487
2556
|
}
|
2488
2557
|
|
2489
2558
|
|
@@ -2494,9 +2563,9 @@ RMtx4_get_e03( VALUE self )
|
|
2494
2563
|
{
|
2495
2564
|
RMtx4* m;
|
2496
2565
|
|
2497
|
-
|
2566
|
+
TypedData_Get_Struct( self, RMtx4, &RMtx4_type, m );
|
2498
2567
|
|
2499
|
-
return
|
2568
|
+
return DBL2NUM( RMtx4GetElement( m, 0, 3 ) );
|
2500
2569
|
}
|
2501
2570
|
|
2502
2571
|
|
@@ -2507,9 +2576,9 @@ RMtx4_get_e10( VALUE self )
|
|
2507
2576
|
{
|
2508
2577
|
RMtx4* m;
|
2509
2578
|
|
2510
|
-
|
2579
|
+
TypedData_Get_Struct( self, RMtx4, &RMtx4_type, m );
|
2511
2580
|
|
2512
|
-
return
|
2581
|
+
return DBL2NUM( RMtx4GetElement( m, 1, 0 ) );
|
2513
2582
|
}
|
2514
2583
|
|
2515
2584
|
|
@@ -2520,9 +2589,9 @@ RMtx4_get_e11( VALUE self )
|
|
2520
2589
|
{
|
2521
2590
|
RMtx4* m;
|
2522
2591
|
|
2523
|
-
|
2592
|
+
TypedData_Get_Struct( self, RMtx4, &RMtx4_type, m );
|
2524
2593
|
|
2525
|
-
return
|
2594
|
+
return DBL2NUM( RMtx4GetElement( m, 1, 1 ) );
|
2526
2595
|
}
|
2527
2596
|
|
2528
2597
|
|
@@ -2533,9 +2602,9 @@ RMtx4_get_e12( VALUE self )
|
|
2533
2602
|
{
|
2534
2603
|
RMtx4* m;
|
2535
2604
|
|
2536
|
-
|
2605
|
+
TypedData_Get_Struct( self, RMtx4, &RMtx4_type, m );
|
2537
2606
|
|
2538
|
-
return
|
2607
|
+
return DBL2NUM( RMtx4GetElement( m, 1, 2 ) );
|
2539
2608
|
}
|
2540
2609
|
|
2541
2610
|
|
@@ -2546,9 +2615,9 @@ RMtx4_get_e13( VALUE self )
|
|
2546
2615
|
{
|
2547
2616
|
RMtx4* m;
|
2548
2617
|
|
2549
|
-
|
2618
|
+
TypedData_Get_Struct( self, RMtx4, &RMtx4_type, m );
|
2550
2619
|
|
2551
|
-
return
|
2620
|
+
return DBL2NUM( RMtx4GetElement( m, 1, 3 ) );
|
2552
2621
|
}
|
2553
2622
|
|
2554
2623
|
|
@@ -2559,9 +2628,9 @@ RMtx4_get_e20( VALUE self )
|
|
2559
2628
|
{
|
2560
2629
|
RMtx4* m;
|
2561
2630
|
|
2562
|
-
|
2631
|
+
TypedData_Get_Struct( self, RMtx4, &RMtx4_type, m );
|
2563
2632
|
|
2564
|
-
return
|
2633
|
+
return DBL2NUM( RMtx4GetElement( m, 2, 0 ) );
|
2565
2634
|
}
|
2566
2635
|
|
2567
2636
|
|
@@ -2572,9 +2641,9 @@ RMtx4_get_e21( VALUE self )
|
|
2572
2641
|
{
|
2573
2642
|
RMtx4* m;
|
2574
2643
|
|
2575
|
-
|
2644
|
+
TypedData_Get_Struct( self, RMtx4, &RMtx4_type, m );
|
2576
2645
|
|
2577
|
-
return
|
2646
|
+
return DBL2NUM( RMtx4GetElement( m, 2, 1 ) );
|
2578
2647
|
}
|
2579
2648
|
|
2580
2649
|
|
@@ -2585,9 +2654,9 @@ RMtx4_get_e22( VALUE self )
|
|
2585
2654
|
{
|
2586
2655
|
RMtx4* m;
|
2587
2656
|
|
2588
|
-
|
2657
|
+
TypedData_Get_Struct( self, RMtx4, &RMtx4_type, m );
|
2589
2658
|
|
2590
|
-
return
|
2659
|
+
return DBL2NUM( RMtx4GetElement( m, 2, 2 ) );
|
2591
2660
|
}
|
2592
2661
|
|
2593
2662
|
|
@@ -2598,9 +2667,9 @@ RMtx4_get_e23( VALUE self )
|
|
2598
2667
|
{
|
2599
2668
|
RMtx4* m;
|
2600
2669
|
|
2601
|
-
|
2670
|
+
TypedData_Get_Struct( self, RMtx4, &RMtx4_type, m );
|
2602
2671
|
|
2603
|
-
return
|
2672
|
+
return DBL2NUM( RMtx4GetElement( m, 2, 3 ) );
|
2604
2673
|
}
|
2605
2674
|
|
2606
2675
|
|
@@ -2611,9 +2680,9 @@ RMtx4_get_e30( VALUE self )
|
|
2611
2680
|
{
|
2612
2681
|
RMtx4* m;
|
2613
2682
|
|
2614
|
-
|
2683
|
+
TypedData_Get_Struct( self, RMtx4, &RMtx4_type, m );
|
2615
2684
|
|
2616
|
-
return
|
2685
|
+
return DBL2NUM( RMtx4GetElement( m, 3, 0 ) );
|
2617
2686
|
}
|
2618
2687
|
|
2619
2688
|
|
@@ -2624,9 +2693,9 @@ RMtx4_get_e31( VALUE self )
|
|
2624
2693
|
{
|
2625
2694
|
RMtx4* m;
|
2626
2695
|
|
2627
|
-
|
2696
|
+
TypedData_Get_Struct( self, RMtx4, &RMtx4_type, m );
|
2628
2697
|
|
2629
|
-
return
|
2698
|
+
return DBL2NUM( RMtx4GetElement( m, 3, 1 ) );
|
2630
2699
|
}
|
2631
2700
|
|
2632
2701
|
|
@@ -2637,9 +2706,9 @@ RMtx4_get_e32( VALUE self )
|
|
2637
2706
|
{
|
2638
2707
|
RMtx4* m;
|
2639
2708
|
|
2640
|
-
|
2709
|
+
TypedData_Get_Struct( self, RMtx4, &RMtx4_type, m );
|
2641
2710
|
|
2642
|
-
return
|
2711
|
+
return DBL2NUM( RMtx4GetElement( m, 3, 2 ) );
|
2643
2712
|
}
|
2644
2713
|
|
2645
2714
|
|
@@ -2650,9 +2719,9 @@ RMtx4_get_e33( VALUE self )
|
|
2650
2719
|
{
|
2651
2720
|
RMtx4* m;
|
2652
2721
|
|
2653
|
-
|
2722
|
+
TypedData_Get_Struct( self, RMtx4, &RMtx4_type, m );
|
2654
2723
|
|
2655
|
-
return
|
2724
|
+
return DBL2NUM( RMtx4GetElement( m, 3, 3 ) );
|
2656
2725
|
}
|
2657
2726
|
|
2658
2727
|
/* Replaces the element at row 0 and column 0 by +value+.
|
@@ -2662,7 +2731,7 @@ RMtx4_set_e00( VALUE self, VALUE f )
|
|
2662
2731
|
{
|
2663
2732
|
RMtx4* m;
|
2664
2733
|
|
2665
|
-
|
2734
|
+
TypedData_Get_Struct( self, RMtx4, &RMtx4_type, m );
|
2666
2735
|
|
2667
2736
|
RMtx4SetElement( m, 0, 0, NUM2DBL(f) );
|
2668
2737
|
|
@@ -2677,7 +2746,7 @@ RMtx4_set_e01( VALUE self, VALUE f )
|
|
2677
2746
|
{
|
2678
2747
|
RMtx4* m;
|
2679
2748
|
|
2680
|
-
|
2749
|
+
TypedData_Get_Struct( self, RMtx4, &RMtx4_type, m );
|
2681
2750
|
|
2682
2751
|
RMtx4SetElement( m, 0, 1, NUM2DBL(f) );
|
2683
2752
|
|
@@ -2692,7 +2761,7 @@ RMtx4_set_e02( VALUE self, VALUE f )
|
|
2692
2761
|
{
|
2693
2762
|
RMtx4* m;
|
2694
2763
|
|
2695
|
-
|
2764
|
+
TypedData_Get_Struct( self, RMtx4, &RMtx4_type, m );
|
2696
2765
|
|
2697
2766
|
RMtx4SetElement( m, 0, 2, NUM2DBL(f) );
|
2698
2767
|
|
@@ -2707,7 +2776,7 @@ RMtx4_set_e03( VALUE self, VALUE f )
|
|
2707
2776
|
{
|
2708
2777
|
RMtx4* m;
|
2709
2778
|
|
2710
|
-
|
2779
|
+
TypedData_Get_Struct( self, RMtx4, &RMtx4_type, m );
|
2711
2780
|
|
2712
2781
|
RMtx4SetElement( m, 0, 3, NUM2DBL(f) );
|
2713
2782
|
|
@@ -2722,7 +2791,7 @@ RMtx4_set_e10( VALUE self, VALUE f )
|
|
2722
2791
|
{
|
2723
2792
|
RMtx4* m;
|
2724
2793
|
|
2725
|
-
|
2794
|
+
TypedData_Get_Struct( self, RMtx4, &RMtx4_type, m );
|
2726
2795
|
|
2727
2796
|
RMtx4SetElement( m, 1, 0, NUM2DBL(f) );
|
2728
2797
|
|
@@ -2737,7 +2806,7 @@ RMtx4_set_e11( VALUE self, VALUE f )
|
|
2737
2806
|
{
|
2738
2807
|
RMtx4* m;
|
2739
2808
|
|
2740
|
-
|
2809
|
+
TypedData_Get_Struct( self, RMtx4, &RMtx4_type, m );
|
2741
2810
|
|
2742
2811
|
RMtx4SetElement( m, 1, 1, NUM2DBL(f) );
|
2743
2812
|
|
@@ -2752,7 +2821,7 @@ RMtx4_set_e12( VALUE self, VALUE f )
|
|
2752
2821
|
{
|
2753
2822
|
RMtx4* m;
|
2754
2823
|
|
2755
|
-
|
2824
|
+
TypedData_Get_Struct( self, RMtx4, &RMtx4_type, m );
|
2756
2825
|
|
2757
2826
|
RMtx4SetElement( m, 1, 2, NUM2DBL(f) );
|
2758
2827
|
|
@@ -2767,7 +2836,7 @@ RMtx4_set_e13( VALUE self, VALUE f )
|
|
2767
2836
|
{
|
2768
2837
|
RMtx4* m;
|
2769
2838
|
|
2770
|
-
|
2839
|
+
TypedData_Get_Struct( self, RMtx4, &RMtx4_type, m );
|
2771
2840
|
|
2772
2841
|
RMtx4SetElement( m, 1, 3, NUM2DBL(f) );
|
2773
2842
|
|
@@ -2782,7 +2851,7 @@ RMtx4_set_e20( VALUE self, VALUE f )
|
|
2782
2851
|
{
|
2783
2852
|
RMtx4* m;
|
2784
2853
|
|
2785
|
-
|
2854
|
+
TypedData_Get_Struct( self, RMtx4, &RMtx4_type, m );
|
2786
2855
|
|
2787
2856
|
RMtx4SetElement( m, 2, 0, NUM2DBL(f) );
|
2788
2857
|
|
@@ -2797,7 +2866,7 @@ RMtx4_set_e21( VALUE self, VALUE f )
|
|
2797
2866
|
{
|
2798
2867
|
RMtx4* m;
|
2799
2868
|
|
2800
|
-
|
2869
|
+
TypedData_Get_Struct( self, RMtx4, &RMtx4_type, m );
|
2801
2870
|
|
2802
2871
|
RMtx4SetElement( m, 2, 1, NUM2DBL(f) );
|
2803
2872
|
|
@@ -2812,7 +2881,7 @@ RMtx4_set_e22( VALUE self, VALUE f )
|
|
2812
2881
|
{
|
2813
2882
|
RMtx4* m;
|
2814
2883
|
|
2815
|
-
|
2884
|
+
TypedData_Get_Struct( self, RMtx4, &RMtx4_type, m );
|
2816
2885
|
|
2817
2886
|
RMtx4SetElement( m, 2, 2, NUM2DBL(f) );
|
2818
2887
|
|
@@ -2827,7 +2896,7 @@ RMtx4_set_e23( VALUE self, VALUE f )
|
|
2827
2896
|
{
|
2828
2897
|
RMtx4* m;
|
2829
2898
|
|
2830
|
-
|
2899
|
+
TypedData_Get_Struct( self, RMtx4, &RMtx4_type, m );
|
2831
2900
|
|
2832
2901
|
RMtx4SetElement( m, 2, 3, NUM2DBL(f) );
|
2833
2902
|
|
@@ -2842,7 +2911,7 @@ RMtx4_set_e30( VALUE self, VALUE f )
|
|
2842
2911
|
{
|
2843
2912
|
RMtx4* m;
|
2844
2913
|
|
2845
|
-
|
2914
|
+
TypedData_Get_Struct( self, RMtx4, &RMtx4_type, m );
|
2846
2915
|
|
2847
2916
|
RMtx4SetElement( m, 3, 0, NUM2DBL(f) );
|
2848
2917
|
|
@@ -2857,7 +2926,7 @@ RMtx4_set_e31( VALUE self, VALUE f )
|
|
2857
2926
|
{
|
2858
2927
|
RMtx4* m;
|
2859
2928
|
|
2860
|
-
|
2929
|
+
TypedData_Get_Struct( self, RMtx4, &RMtx4_type, m );
|
2861
2930
|
|
2862
2931
|
RMtx4SetElement( m, 3, 1, NUM2DBL(f) );
|
2863
2932
|
|
@@ -2872,7 +2941,7 @@ RMtx4_set_e32( VALUE self, VALUE f )
|
|
2872
2941
|
{
|
2873
2942
|
RMtx4* m;
|
2874
2943
|
|
2875
|
-
|
2944
|
+
TypedData_Get_Struct( self, RMtx4, &RMtx4_type, m );
|
2876
2945
|
|
2877
2946
|
RMtx4SetElement( m, 3, 2, NUM2DBL(f) );
|
2878
2947
|
|
@@ -2887,7 +2956,7 @@ RMtx4_set_e33( VALUE self, VALUE f )
|
|
2887
2956
|
{
|
2888
2957
|
RMtx4* m;
|
2889
2958
|
|
2890
|
-
|
2959
|
+
TypedData_Get_Struct( self, RMtx4, &RMtx4_type, m );
|
2891
2960
|
|
2892
2961
|
RMtx4SetElement( m, 3, 3, NUM2DBL(f) );
|
2893
2962
|
|
@@ -2907,7 +2976,7 @@ RMtx4_getRow( VALUE self, VALUE row )
|
|
2907
2976
|
int at;
|
2908
2977
|
RVec4 out;
|
2909
2978
|
|
2910
|
-
|
2979
|
+
TypedData_Get_Struct( self, RMtx4, &RMtx4_type, m );
|
2911
2980
|
at = FIX2INT(row);
|
2912
2981
|
RMtx4GetRow( &out, m, at );
|
2913
2982
|
|
@@ -2926,7 +2995,7 @@ RMtx4_getColumn( VALUE self, VALUE column )
|
|
2926
2995
|
int at;
|
2927
2996
|
RVec4 out;
|
2928
2997
|
|
2929
|
-
|
2998
|
+
TypedData_Get_Struct( self, RMtx4, &RMtx4_type, m );
|
2930
2999
|
at = FIX2INT(column);
|
2931
3000
|
RMtx4GetColumn( &out, m, at );
|
2932
3001
|
|
@@ -2946,8 +3015,8 @@ RMtx4_setRow( VALUE self, VALUE v, VALUE row )
|
|
2946
3015
|
RVec4* in;
|
2947
3016
|
int at;
|
2948
3017
|
|
2949
|
-
|
2950
|
-
|
3018
|
+
TypedData_Get_Struct( self, RMtx4, &RMtx4_type, m );
|
3019
|
+
TypedData_Get_Struct( v, RVec4, &RVec4_type, in );
|
2951
3020
|
at = FIX2INT(row);
|
2952
3021
|
RMtx4SetRow( m, in, at );
|
2953
3022
|
|
@@ -2967,8 +3036,8 @@ RMtx4_setColumn( VALUE self, VALUE v, VALUE column )
|
|
2967
3036
|
RVec4* in;
|
2968
3037
|
int at;
|
2969
3038
|
|
2970
|
-
|
2971
|
-
|
3039
|
+
TypedData_Get_Struct( self, RMtx4, &RMtx4_type, m );
|
3040
|
+
TypedData_Get_Struct( v, RVec4, &RVec4_type, in );
|
2972
3041
|
at = FIX2INT(column);
|
2973
3042
|
RMtx4SetColumn( m, in, at );
|
2974
3043
|
|
@@ -2987,7 +3056,7 @@ RMtx4_getUpper3x3( VALUE self )
|
|
2987
3056
|
RMtx4* mtx4x4 = NULL;
|
2988
3057
|
RMtx3 out;
|
2989
3058
|
|
2990
|
-
|
3059
|
+
TypedData_Get_Struct( self, RMtx4, &RMtx4_type, mtx4x4 );
|
2991
3060
|
RMtx4GetUpper3x3( &out, mtx4x4 );
|
2992
3061
|
|
2993
3062
|
return RMtx3_from_source( &out );
|
@@ -3005,8 +3074,8 @@ RMtx4_setUpper3x3( VALUE self, VALUE in )
|
|
3005
3074
|
RMtx3* mtx3x3 = NULL;
|
3006
3075
|
RMtx4* mtx4x4 = NULL;
|
3007
3076
|
|
3008
|
-
|
3009
|
-
|
3077
|
+
TypedData_Get_Struct( in, RMtx3, &RMtx3_type, mtx3x3 );
|
3078
|
+
TypedData_Get_Struct( self, RMtx4, &RMtx4_type, mtx4x4 );
|
3010
3079
|
RMtx4SetUpper3x3( mtx4x4, mtx3x3 );
|
3011
3080
|
|
3012
3081
|
return self;
|
@@ -3024,7 +3093,7 @@ RMtx4_setZero( VALUE self )
|
|
3024
3093
|
{
|
3025
3094
|
RMtx4* m = NULL;
|
3026
3095
|
|
3027
|
-
|
3096
|
+
TypedData_Get_Struct( self, RMtx4, &RMtx4_type, m );
|
3028
3097
|
RMtx4Zero( m );
|
3029
3098
|
|
3030
3099
|
return self;
|
@@ -3040,7 +3109,7 @@ RMtx4_setIdentity( VALUE self )
|
|
3040
3109
|
{
|
3041
3110
|
RMtx4* m = NULL;
|
3042
3111
|
|
3043
|
-
|
3112
|
+
TypedData_Get_Struct( self, RMtx4, &RMtx4_type, m );
|
3044
3113
|
RMtx4Identity( m );
|
3045
3114
|
|
3046
3115
|
return self;
|
@@ -3057,10 +3126,10 @@ RMtx4_getDeterminant( VALUE self )
|
|
3057
3126
|
RMtx4* m = NULL;
|
3058
3127
|
rmReal f;
|
3059
3128
|
|
3060
|
-
|
3129
|
+
TypedData_Get_Struct( self, RMtx4, &RMtx4_type, m );
|
3061
3130
|
f = RMtx4Determinant( m );
|
3062
3131
|
|
3063
|
-
return
|
3132
|
+
return DBL2NUM( f );
|
3064
3133
|
}
|
3065
3134
|
|
3066
3135
|
/*
|
@@ -3074,7 +3143,7 @@ RMtx4_transpose( VALUE self )
|
|
3074
3143
|
RMtx4* m = NULL;
|
3075
3144
|
RMtx4 out;
|
3076
3145
|
|
3077
|
-
|
3146
|
+
TypedData_Get_Struct( self, RMtx4, &RMtx4_type, m );
|
3078
3147
|
RMtx4Transpose( &out, m );
|
3079
3148
|
|
3080
3149
|
return RMtx4_from_source( &out );
|
@@ -3090,7 +3159,7 @@ RMtx4_transpose_intrusive( VALUE self )
|
|
3090
3159
|
{
|
3091
3160
|
RMtx4* m = NULL;
|
3092
3161
|
|
3093
|
-
|
3162
|
+
TypedData_Get_Struct( self, RMtx4, &RMtx4_type, m );
|
3094
3163
|
RMtx4Transpose( m, m );
|
3095
3164
|
|
3096
3165
|
return self;
|
@@ -3107,7 +3176,7 @@ RMtx4_inverse( VALUE self )
|
|
3107
3176
|
RMtx4* m = NULL;
|
3108
3177
|
RMtx4 out;
|
3109
3178
|
|
3110
|
-
|
3179
|
+
TypedData_Get_Struct( self, RMtx4, &RMtx4_type, m );
|
3111
3180
|
RMtx4Inverse( &out, m );
|
3112
3181
|
|
3113
3182
|
return RMtx4_from_source( &out );
|
@@ -3123,7 +3192,7 @@ RMtx4_inverse_intrusive( VALUE self )
|
|
3123
3192
|
{
|
3124
3193
|
RMtx4* m = NULL;
|
3125
3194
|
|
3126
|
-
|
3195
|
+
TypedData_Get_Struct( self, RMtx4, &RMtx4_type, m );
|
3127
3196
|
RMtx4Inverse( m, m );
|
3128
3197
|
|
3129
3198
|
return self;
|
@@ -3140,7 +3209,7 @@ RMtx4_translation( VALUE self, VALUE x, VALUE y, VALUE z )
|
|
3140
3209
|
RMtx4* m = NULL;
|
3141
3210
|
rmReal tx, ty, tz;
|
3142
3211
|
|
3143
|
-
|
3212
|
+
TypedData_Get_Struct( self, RMtx4, &RMtx4_type, m );
|
3144
3213
|
tx = NUM2DBL(x);
|
3145
3214
|
ty = NUM2DBL(y);
|
3146
3215
|
tz = NUM2DBL(z);
|
@@ -3160,7 +3229,7 @@ RMtx4_rotationX( VALUE self, VALUE radian )
|
|
3160
3229
|
RMtx4* m = NULL;
|
3161
3230
|
rmReal angle_radian;
|
3162
3231
|
|
3163
|
-
|
3232
|
+
TypedData_Get_Struct( self, RMtx4, &RMtx4_type, m );
|
3164
3233
|
angle_radian = NUM2DBL(radian);
|
3165
3234
|
RMtx4RotationX( m, angle_radian );
|
3166
3235
|
|
@@ -3178,7 +3247,7 @@ RMtx4_rotationY( VALUE self, VALUE radian )
|
|
3178
3247
|
RMtx4* m = NULL;
|
3179
3248
|
rmReal angle_radian;
|
3180
3249
|
|
3181
|
-
|
3250
|
+
TypedData_Get_Struct( self, RMtx4, &RMtx4_type, m );
|
3182
3251
|
angle_radian = NUM2DBL(radian);
|
3183
3252
|
RMtx4RotationY( m, angle_radian );
|
3184
3253
|
|
@@ -3196,7 +3265,7 @@ RMtx4_rotationZ( VALUE self, VALUE radian )
|
|
3196
3265
|
RMtx4* m = NULL;
|
3197
3266
|
rmReal angle_radian;
|
3198
3267
|
|
3199
|
-
|
3268
|
+
TypedData_Get_Struct( self, RMtx4, &RMtx4_type, m );
|
3200
3269
|
angle_radian = NUM2DBL(radian);
|
3201
3270
|
RMtx4RotationZ( m, angle_radian );
|
3202
3271
|
|
@@ -3215,8 +3284,8 @@ RMtx4_rotationAxis( VALUE self, VALUE axis, VALUE radian )
|
|
3215
3284
|
RVec3* vAxis = NULL;
|
3216
3285
|
rmReal angle_radian;
|
3217
3286
|
|
3218
|
-
|
3219
|
-
|
3287
|
+
TypedData_Get_Struct( self, RMtx4, &RMtx4_type, m );
|
3288
|
+
TypedData_Get_Struct( axis, RVec3, &RVec3_type, vAxis );
|
3220
3289
|
angle_radian = NUM2DBL(radian);
|
3221
3290
|
RMtx4RotationAxis( m, vAxis, angle_radian );
|
3222
3291
|
|
@@ -3234,8 +3303,8 @@ RMtx4_rotationQuaternion( VALUE self, VALUE q )
|
|
3234
3303
|
RMtx4* m = NULL;
|
3235
3304
|
RQuat* quat = NULL;
|
3236
3305
|
|
3237
|
-
|
3238
|
-
|
3306
|
+
TypedData_Get_Struct( self, RMtx4, &RMtx4_type, m );
|
3307
|
+
TypedData_Get_Struct( q, RQuat, &RQuat_type, quat );
|
3239
3308
|
RMtx4RotationQuaternion( m, quat );
|
3240
3309
|
|
3241
3310
|
return self;
|
@@ -3252,7 +3321,7 @@ RMtx4_scaling( VALUE self, VALUE x, VALUE y, VALUE z )
|
|
3252
3321
|
RMtx4* m = NULL;
|
3253
3322
|
rmReal sx, sy, sz;
|
3254
3323
|
|
3255
|
-
|
3324
|
+
TypedData_Get_Struct( self, RMtx4, &RMtx4_type, m );
|
3256
3325
|
sx = NUM2DBL(x);
|
3257
3326
|
sy = NUM2DBL(y);
|
3258
3327
|
sz = NUM2DBL(z);
|
@@ -3277,10 +3346,10 @@ RMtx4_lookAtRH( VALUE self, VALUE e, VALUE a, VALUE u )
|
|
3277
3346
|
RVec3* at = NULL;
|
3278
3347
|
RVec3* up = NULL;
|
3279
3348
|
|
3280
|
-
|
3281
|
-
|
3282
|
-
|
3283
|
-
|
3349
|
+
TypedData_Get_Struct( self, RMtx4, &RMtx4_type, m );
|
3350
|
+
TypedData_Get_Struct( e, RVec3, &RVec3_type, eye );
|
3351
|
+
TypedData_Get_Struct( a, RVec3, &RVec3_type, at );
|
3352
|
+
TypedData_Get_Struct( u, RVec3, &RVec3_type, up );
|
3284
3353
|
RMtx4LookAtRH( m, eye, at, up );
|
3285
3354
|
|
3286
3355
|
return self;
|
@@ -3301,7 +3370,7 @@ RMtx4_perspectiveRH( VALUE self, VALUE w, VALUE h, VALUE zn, VALUE zf )
|
|
3301
3370
|
RMtx4* m = NULL;
|
3302
3371
|
rmReal width, height, znear, zfar;
|
3303
3372
|
|
3304
|
-
|
3373
|
+
TypedData_Get_Struct( self, RMtx4, &RMtx4_type, m );
|
3305
3374
|
width = NUM2DBL(w);
|
3306
3375
|
height = NUM2DBL(h);
|
3307
3376
|
znear = NUM2DBL(zn);
|
@@ -3327,7 +3396,7 @@ RMtx4_perspectiveFovRH( VALUE self, VALUE fovy, VALUE asp, VALUE zn, VALUE zf )
|
|
3327
3396
|
RMtx4* m = NULL;
|
3328
3397
|
rmReal fovy_radian, aspect, znear, zfar;
|
3329
3398
|
|
3330
|
-
|
3399
|
+
TypedData_Get_Struct( self, RMtx4, &RMtx4_type, m );
|
3331
3400
|
fovy_radian = NUM2DBL(fovy);
|
3332
3401
|
aspect = NUM2DBL(asp);
|
3333
3402
|
znear = NUM2DBL(zn);
|
@@ -3355,7 +3424,7 @@ RMtx4_perspectiveOffCenterRH( VALUE self, VALUE l, VALUE r, VALUE b, VALUE t, VA
|
|
3355
3424
|
RMtx4* m = NULL;
|
3356
3425
|
rmReal left, right, bottom, top, znear, zfar;
|
3357
3426
|
|
3358
|
-
|
3427
|
+
TypedData_Get_Struct( self, RMtx4, &RMtx4_type, m );
|
3359
3428
|
left = NUM2DBL(l);
|
3360
3429
|
right = NUM2DBL(r);
|
3361
3430
|
bottom = NUM2DBL(b);
|
@@ -3382,7 +3451,7 @@ RMtx4_orthoRH( VALUE self, VALUE w, VALUE h, VALUE zn, VALUE zf )
|
|
3382
3451
|
RMtx4* m = NULL;
|
3383
3452
|
rmReal width, height, znear, zfar;
|
3384
3453
|
|
3385
|
-
|
3454
|
+
TypedData_Get_Struct( self, RMtx4, &RMtx4_type, m );
|
3386
3455
|
width = NUM2DBL(w);
|
3387
3456
|
height = NUM2DBL(h);
|
3388
3457
|
znear = NUM2DBL(zn);
|
@@ -3410,7 +3479,7 @@ RMtx4_orthoOffCenterRH( VALUE self, VALUE l, VALUE r, VALUE b, VALUE t, VALUE zn
|
|
3410
3479
|
RMtx4* m = NULL;
|
3411
3480
|
rmReal left, right, bottom, top, znear, zfar;
|
3412
3481
|
|
3413
|
-
|
3482
|
+
TypedData_Get_Struct( self, RMtx4, &RMtx4_type, m );
|
3414
3483
|
left = NUM2DBL(l);
|
3415
3484
|
right = NUM2DBL(r);
|
3416
3485
|
bottom = NUM2DBL(b);
|
@@ -3444,7 +3513,7 @@ RMtx4_op_unary_minus( VALUE self )
|
|
3444
3513
|
RMtx4* m = NULL;
|
3445
3514
|
RMtx4 out;
|
3446
3515
|
|
3447
|
-
|
3516
|
+
TypedData_Get_Struct( self, RMtx4, &RMtx4_type, m );
|
3448
3517
|
RMtx4Scale( &out, m, (rmReal)(-1) );
|
3449
3518
|
|
3450
3519
|
return RMtx4_from_source( &out );
|
@@ -3473,8 +3542,8 @@ RMtx4_op_binary_plus( VALUE self, VALUE other )
|
|
3473
3542
|
}
|
3474
3543
|
#endif
|
3475
3544
|
|
3476
|
-
|
3477
|
-
|
3545
|
+
TypedData_Get_Struct( self, RMtx4, &RMtx4_type, m1 );
|
3546
|
+
TypedData_Get_Struct( other, RMtx4, &RMtx4_type, m2 );
|
3478
3547
|
RMtx4Add( &result, m1, m2 );
|
3479
3548
|
|
3480
3549
|
return RMtx4_from_source( &result );
|
@@ -3503,8 +3572,8 @@ RMtx4_op_binary_minus( VALUE self, VALUE other )
|
|
3503
3572
|
}
|
3504
3573
|
#endif
|
3505
3574
|
|
3506
|
-
|
3507
|
-
|
3575
|
+
TypedData_Get_Struct( self, RMtx4, &RMtx4_type, m1 );
|
3576
|
+
TypedData_Get_Struct( other, RMtx4, &RMtx4_type, m2 );
|
3508
3577
|
RMtx4Sub( &result, m1, m2 );
|
3509
3578
|
|
3510
3579
|
return RMtx4_from_source( &result );
|
@@ -3523,11 +3592,11 @@ RMtx4_op_binary_mult( VALUE self, VALUE other )
|
|
3523
3592
|
rmReal f;
|
3524
3593
|
RMtx4 result;
|
3525
3594
|
|
3526
|
-
|
3595
|
+
TypedData_Get_Struct( self, RMtx4, &RMtx4_type, m1 );
|
3527
3596
|
|
3528
3597
|
if ( IsRMtx4(other) )
|
3529
3598
|
{
|
3530
|
-
|
3599
|
+
TypedData_Get_Struct( other, RMtx4, &RMtx4_type, m2 );
|
3531
3600
|
RMtx4Mul( &result, m1, m2 );
|
3532
3601
|
}
|
3533
3602
|
else
|
@@ -3561,8 +3630,8 @@ RMtx4_op_binary_eq( VALUE self, VALUE other )
|
|
3561
3630
|
}
|
3562
3631
|
#endif
|
3563
3632
|
|
3564
|
-
|
3565
|
-
|
3633
|
+
TypedData_Get_Struct( self, RMtx4, &RMtx4_type, m1 );
|
3634
|
+
TypedData_Get_Struct( other, RMtx4, &RMtx4_type, m2 );
|
3566
3635
|
|
3567
3636
|
if ( !RMtx4Equal(m1,m2) )
|
3568
3637
|
return Qfalse;
|
@@ -3592,8 +3661,8 @@ RMtx4_op_assign_plus( VALUE self, VALUE other )
|
|
3592
3661
|
}
|
3593
3662
|
#endif
|
3594
3663
|
|
3595
|
-
|
3596
|
-
|
3664
|
+
TypedData_Get_Struct( self, RMtx4, &RMtx4_type, m1 );
|
3665
|
+
TypedData_Get_Struct( other, RMtx4, &RMtx4_type, m2 );
|
3597
3666
|
RMtx4Add( m1, m1, m2 );
|
3598
3667
|
|
3599
3668
|
return self;
|
@@ -3621,8 +3690,8 @@ RMtx4_op_assign_minus( VALUE self, VALUE other )
|
|
3621
3690
|
}
|
3622
3691
|
#endif
|
3623
3692
|
|
3624
|
-
|
3625
|
-
|
3693
|
+
TypedData_Get_Struct( self, RMtx4, &RMtx4_type, m1 );
|
3694
|
+
TypedData_Get_Struct( other, RMtx4, &RMtx4_type, m2 );
|
3626
3695
|
RMtx4Sub( m1, m1, m2 );
|
3627
3696
|
|
3628
3697
|
return self;
|
@@ -3640,11 +3709,11 @@ RMtx4_op_assign_mult( VALUE self, VALUE other )
|
|
3640
3709
|
RMtx4* m2 = NULL;
|
3641
3710
|
rmReal f;
|
3642
3711
|
|
3643
|
-
|
3712
|
+
TypedData_Get_Struct( self, RMtx4, &RMtx4_type, m1 );
|
3644
3713
|
|
3645
3714
|
if ( IsRMtx4(other) )
|
3646
3715
|
{
|
3647
|
-
|
3716
|
+
TypedData_Get_Struct( other, RMtx4, &RMtx4_type, m2 );
|
3648
3717
|
RMtx4Mul( m1, m1, m2 );
|
3649
3718
|
}
|
3650
3719
|
else
|
@@ -3664,7 +3733,7 @@ RMtx4_op_assign_mult( VALUE self, VALUE other )
|
|
3664
3733
|
********************************************************************************/
|
3665
3734
|
|
3666
3735
|
/*
|
3667
|
-
* Document-class:
|
3736
|
+
* Document-class: RMath3D::RQuat
|
3668
3737
|
* provies quaternion arithmetic.
|
3669
3738
|
*/
|
3670
3739
|
|
@@ -3674,25 +3743,27 @@ RQuat_free( void* ptr )
|
|
3674
3743
|
xfree( ptr );
|
3675
3744
|
}
|
3676
3745
|
|
3746
|
+
static size_t
|
3747
|
+
RQuat_memsize( const void* ptr )
|
3748
|
+
{
|
3749
|
+
const struct RQuat* data = ptr;
|
3750
|
+
return data ? sizeof(*data) : 0;
|
3751
|
+
}
|
3752
|
+
|
3677
3753
|
static VALUE
|
3678
3754
|
RQuat_from_source( RQuat* src )
|
3679
3755
|
{
|
3680
|
-
RQuat* v =
|
3681
|
-
|
3756
|
+
RQuat* v = ZALLOC( struct RQuat );
|
3682
3757
|
RQuatCopy( v, src );
|
3683
|
-
|
3684
|
-
return Data_Wrap_Struct( rb_cRQuat, NULL, RQuat_free, v );
|
3758
|
+
return TypedData_Wrap_Struct( rb_cRQuat, &RQuat_type, v );
|
3685
3759
|
}
|
3686
3760
|
|
3687
3761
|
|
3688
3762
|
static VALUE
|
3689
3763
|
RQuat_allocate( VALUE klass )
|
3690
3764
|
{
|
3691
|
-
RQuat* v =
|
3692
|
-
|
3693
|
-
memset( v, 0, sizeof(RQuat) );
|
3694
|
-
|
3695
|
-
return Data_Wrap_Struct( klass, NULL, RQuat_free, v );
|
3765
|
+
RQuat* v = ZALLOC( RQuat );
|
3766
|
+
return TypedData_Wrap_Struct( klass, &RQuat_type, v );
|
3696
3767
|
}
|
3697
3768
|
|
3698
3769
|
|
@@ -3709,7 +3780,7 @@ static VALUE
|
|
3709
3780
|
RQuat_initialize( int argc, VALUE* argv, VALUE self )
|
3710
3781
|
{
|
3711
3782
|
RQuat* v = NULL;
|
3712
|
-
|
3783
|
+
TypedData_Get_Struct( self, RQuat, &RQuat_type, v );
|
3713
3784
|
|
3714
3785
|
switch( argc )
|
3715
3786
|
{
|
@@ -3742,7 +3813,7 @@ RQuat_initialize( int argc, VALUE* argv, VALUE self )
|
|
3742
3813
|
{
|
3743
3814
|
/* Copy Constructor */
|
3744
3815
|
RQuat* other;
|
3745
|
-
|
3816
|
+
TypedData_Get_Struct( arg , RQuat, &RQuat_type, other );
|
3746
3817
|
RQuatSetElements( v, other->x, other->y, other->z, other->w );
|
3747
3818
|
return self;
|
3748
3819
|
}
|
@@ -3818,7 +3889,7 @@ RQuat_to_s( VALUE self )
|
|
3818
3889
|
char dest[128], work[4][32];
|
3819
3890
|
int i;
|
3820
3891
|
|
3821
|
-
|
3892
|
+
TypedData_Get_Struct( self, RQuat, &RQuat_type, q );
|
3822
3893
|
|
3823
3894
|
for ( i = 0; i < 4; ++i )
|
3824
3895
|
{
|
@@ -3855,12 +3926,12 @@ RQuat_to_a( VALUE self )
|
|
3855
3926
|
{
|
3856
3927
|
RQuat* v = NULL;
|
3857
3928
|
VALUE dbl[4];
|
3858
|
-
|
3929
|
+
TypedData_Get_Struct( self, RQuat, &RQuat_type, v );
|
3859
3930
|
|
3860
|
-
dbl[0] =
|
3861
|
-
dbl[1] =
|
3862
|
-
dbl[2] =
|
3863
|
-
dbl[3] =
|
3931
|
+
dbl[0] = DBL2NUM(RQuatGetElement(v,0));
|
3932
|
+
dbl[1] = DBL2NUM(RQuatGetElement(v,1));
|
3933
|
+
dbl[2] = DBL2NUM(RQuatGetElement(v,2));
|
3934
|
+
dbl[3] = DBL2NUM(RQuatGetElement(v,3));
|
3864
3935
|
|
3865
3936
|
return rb_ary_new4( 4, dbl );
|
3866
3937
|
}
|
@@ -3874,7 +3945,7 @@ static VALUE
|
|
3874
3945
|
RQuat_coerce( VALUE self, VALUE other )
|
3875
3946
|
{
|
3876
3947
|
RQuat* v = NULL;
|
3877
|
-
|
3948
|
+
TypedData_Get_Struct( self, RQuat, &RQuat_type, v );
|
3878
3949
|
|
3879
3950
|
switch( TYPE(other) )
|
3880
3951
|
{
|
@@ -3913,7 +3984,7 @@ RQuat_setElements( VALUE self, VALUE x, VALUE y, VALUE z, VALUE w )
|
|
3913
3984
|
RQuat* v = NULL;
|
3914
3985
|
rmReal flt0, flt1, flt2, flt3;
|
3915
3986
|
|
3916
|
-
|
3987
|
+
TypedData_Get_Struct( self, RQuat, &RQuat_type, v );
|
3917
3988
|
flt0 = NUM2DBL(x);
|
3918
3989
|
flt1 = NUM2DBL(y);
|
3919
3990
|
flt2 = NUM2DBL(z);
|
@@ -3936,7 +4007,7 @@ RQuat_setElement( VALUE self, VALUE i, VALUE f )
|
|
3936
4007
|
int at;
|
3937
4008
|
rmReal flt;
|
3938
4009
|
|
3939
|
-
|
4010
|
+
TypedData_Get_Struct( self, RQuat, &RQuat_type, v );
|
3940
4011
|
at = NUM2INT(i);
|
3941
4012
|
flt = NUM2DBL(f);
|
3942
4013
|
|
@@ -3956,7 +4027,7 @@ RQuat_setX( VALUE self, VALUE x )
|
|
3956
4027
|
RQuat* v = NULL;
|
3957
4028
|
rmReal flt0;
|
3958
4029
|
|
3959
|
-
|
4030
|
+
TypedData_Get_Struct( self, RQuat, &RQuat_type, v );
|
3960
4031
|
flt0 = NUM2DBL(x);
|
3961
4032
|
|
3962
4033
|
RQuatSetX( v, flt0 );
|
@@ -3975,7 +4046,7 @@ RQuat_setY( VALUE self, VALUE y )
|
|
3975
4046
|
RQuat* v = NULL;
|
3976
4047
|
rmReal flt0;
|
3977
4048
|
|
3978
|
-
|
4049
|
+
TypedData_Get_Struct( self, RQuat, &RQuat_type, v );
|
3979
4050
|
flt0 = NUM2DBL(y);
|
3980
4051
|
|
3981
4052
|
RQuatSetY( v, flt0 );
|
@@ -3994,7 +4065,7 @@ RQuat_setZ( VALUE self, VALUE z )
|
|
3994
4065
|
RQuat* v = NULL;
|
3995
4066
|
rmReal flt0;
|
3996
4067
|
|
3997
|
-
|
4068
|
+
TypedData_Get_Struct( self, RQuat, &RQuat_type, v );
|
3998
4069
|
flt0 = NUM2DBL(z);
|
3999
4070
|
|
4000
4071
|
RQuatSetZ( v, flt0 );
|
@@ -4013,7 +4084,7 @@ RQuat_setW( VALUE self, VALUE w )
|
|
4013
4084
|
RQuat* v = NULL;
|
4014
4085
|
rmReal flt0;
|
4015
4086
|
|
4016
|
-
|
4087
|
+
TypedData_Get_Struct( self, RQuat, &RQuat_type, v );
|
4017
4088
|
flt0 = NUM2DBL(w);
|
4018
4089
|
|
4019
4090
|
RQuatSetW( v, flt0 );
|
@@ -4032,8 +4103,8 @@ RQuat_setXYZ( VALUE self, VALUE xyz )
|
|
4032
4103
|
RQuat* v = NULL;
|
4033
4104
|
RVec3* in = NULL;
|
4034
4105
|
|
4035
|
-
|
4036
|
-
|
4106
|
+
TypedData_Get_Struct( self, RQuat, &RQuat_type, v );
|
4107
|
+
TypedData_Get_Struct( xyz, RVec3, &RVec3_type, in );
|
4037
4108
|
|
4038
4109
|
RQuatSetXYZ( v, in );
|
4039
4110
|
|
@@ -4052,11 +4123,11 @@ RQuat_getElement( VALUE self, VALUE i )
|
|
4052
4123
|
int at;
|
4053
4124
|
rmReal flt0;
|
4054
4125
|
|
4055
|
-
|
4126
|
+
TypedData_Get_Struct( self, RQuat, &RQuat_type, v );
|
4056
4127
|
at = FIX2INT(i);
|
4057
4128
|
flt0 = RQuatGetElement( v, at );
|
4058
4129
|
|
4059
|
-
return
|
4130
|
+
return DBL2NUM( flt0 );
|
4060
4131
|
}
|
4061
4132
|
|
4062
4133
|
/*
|
@@ -4070,10 +4141,10 @@ RQuat_getX( VALUE self )
|
|
4070
4141
|
RQuat* v = NULL;
|
4071
4142
|
rmReal flt0;
|
4072
4143
|
|
4073
|
-
|
4144
|
+
TypedData_Get_Struct( self, RQuat, &RQuat_type, v );
|
4074
4145
|
flt0 = RQuatGetX( v );
|
4075
4146
|
|
4076
|
-
return
|
4147
|
+
return DBL2NUM( flt0 );
|
4077
4148
|
}
|
4078
4149
|
|
4079
4150
|
/*
|
@@ -4087,10 +4158,10 @@ RQuat_getY( VALUE self )
|
|
4087
4158
|
RQuat* v = NULL;
|
4088
4159
|
rmReal flt0;
|
4089
4160
|
|
4090
|
-
|
4161
|
+
TypedData_Get_Struct( self, RQuat, &RQuat_type, v );
|
4091
4162
|
flt0 = RQuatGetY( v );
|
4092
4163
|
|
4093
|
-
return
|
4164
|
+
return DBL2NUM( flt0 );
|
4094
4165
|
}
|
4095
4166
|
|
4096
4167
|
/*
|
@@ -4104,10 +4175,10 @@ RQuat_getZ( VALUE self )
|
|
4104
4175
|
RQuat* v = NULL;
|
4105
4176
|
rmReal flt0;
|
4106
4177
|
|
4107
|
-
|
4178
|
+
TypedData_Get_Struct( self, RQuat, &RQuat_type, v );
|
4108
4179
|
flt0 = RQuatGetZ( v );
|
4109
4180
|
|
4110
|
-
return
|
4181
|
+
return DBL2NUM( flt0 );
|
4111
4182
|
}
|
4112
4183
|
|
4113
4184
|
/*
|
@@ -4121,10 +4192,10 @@ RQuat_getW( VALUE self )
|
|
4121
4192
|
RQuat* v = NULL;
|
4122
4193
|
rmReal flt0;
|
4123
4194
|
|
4124
|
-
|
4195
|
+
TypedData_Get_Struct( self, RQuat, &RQuat_type, v );
|
4125
4196
|
flt0 = RQuatGetW( v );
|
4126
4197
|
|
4127
|
-
return
|
4198
|
+
return DBL2NUM( flt0 );
|
4128
4199
|
}
|
4129
4200
|
|
4130
4201
|
/*
|
@@ -4138,7 +4209,7 @@ RQuat_getXYZ( VALUE self )
|
|
4138
4209
|
RQuat* v = NULL;
|
4139
4210
|
RVec3 out;
|
4140
4211
|
|
4141
|
-
|
4212
|
+
TypedData_Get_Struct( self, RQuat, &RQuat_type, v );
|
4142
4213
|
|
4143
4214
|
RQuatGetXYZ( &out, v );
|
4144
4215
|
|
@@ -4156,10 +4227,10 @@ RQuat_getLength( VALUE self )
|
|
4156
4227
|
RQuat* v = NULL;
|
4157
4228
|
rmReal flt0;
|
4158
4229
|
|
4159
|
-
|
4230
|
+
TypedData_Get_Struct( self, RQuat, &RQuat_type, v );
|
4160
4231
|
flt0 = RQuatLength( v );
|
4161
4232
|
|
4162
|
-
return
|
4233
|
+
return DBL2NUM( flt0 );
|
4163
4234
|
}
|
4164
4235
|
|
4165
4236
|
/*
|
@@ -4173,10 +4244,10 @@ RQuat_getLengthSq( VALUE self )
|
|
4173
4244
|
RQuat* v = NULL;
|
4174
4245
|
rmReal flt0;
|
4175
4246
|
|
4176
|
-
|
4247
|
+
TypedData_Get_Struct( self, RQuat, &RQuat_type, v );
|
4177
4248
|
flt0 = RQuatLengthSq( v );
|
4178
4249
|
|
4179
|
-
return
|
4250
|
+
return DBL2NUM( flt0 );
|
4180
4251
|
}
|
4181
4252
|
|
4182
4253
|
/*
|
@@ -4191,11 +4262,11 @@ RQuat_dot( VALUE self, VALUE q1, VALUE q2 )
|
|
4191
4262
|
RQuat* quat2 = NULL;
|
4192
4263
|
rmReal result;
|
4193
4264
|
|
4194
|
-
|
4195
|
-
|
4265
|
+
TypedData_Get_Struct( q1, RQuat, &RQuat_type, quat1 );
|
4266
|
+
TypedData_Get_Struct( q2, RQuat, &RQuat_type, quat2 );
|
4196
4267
|
result = RQuatDot( quat1, quat2 );
|
4197
4268
|
|
4198
|
-
return
|
4269
|
+
return DBL2NUM( result );
|
4199
4270
|
}
|
4200
4271
|
|
4201
4272
|
/*
|
@@ -4212,8 +4283,8 @@ RQuat_slerp( VALUE self, VALUE q1, VALUE q2, VALUE t )
|
|
4212
4283
|
rmReal time;
|
4213
4284
|
RQuat result;
|
4214
4285
|
|
4215
|
-
|
4216
|
-
|
4286
|
+
TypedData_Get_Struct( q1, RQuat, &RQuat_type, quat1 );
|
4287
|
+
TypedData_Get_Struct( q2, RQuat, &RQuat_type, quat2 );
|
4217
4288
|
time = NUM2DBL( t );
|
4218
4289
|
RQuatSlerp( &result, quat1, quat2, time );
|
4219
4290
|
|
@@ -4230,7 +4301,7 @@ RQuat_setIdentity( VALUE self )
|
|
4230
4301
|
{
|
4231
4302
|
RQuat* q = NULL;
|
4232
4303
|
|
4233
|
-
|
4304
|
+
TypedData_Get_Struct( self, RQuat, &RQuat_type, q );
|
4234
4305
|
RQuatIdentity( q );
|
4235
4306
|
|
4236
4307
|
return self;
|
@@ -4247,7 +4318,7 @@ RQuat_conjugate( VALUE self )
|
|
4247
4318
|
RQuat* q = NULL;
|
4248
4319
|
RQuat out;
|
4249
4320
|
|
4250
|
-
|
4321
|
+
TypedData_Get_Struct( self, RQuat, &RQuat_type, q );
|
4251
4322
|
RQuatConjugate( &out, q );
|
4252
4323
|
|
4253
4324
|
return RQuat_from_source( &out );
|
@@ -4263,7 +4334,7 @@ RQuat_conjugate_intrusive( VALUE self )
|
|
4263
4334
|
{
|
4264
4335
|
RQuat* q = NULL;
|
4265
4336
|
|
4266
|
-
|
4337
|
+
TypedData_Get_Struct( self, RQuat, &RQuat_type, q );
|
4267
4338
|
RQuatConjugate( q, q );
|
4268
4339
|
|
4269
4340
|
return self;
|
@@ -4280,7 +4351,7 @@ RQuat_inverse( VALUE self )
|
|
4280
4351
|
RQuat* q = NULL;
|
4281
4352
|
RQuat out;
|
4282
4353
|
|
4283
|
-
|
4354
|
+
TypedData_Get_Struct( self, RQuat, &RQuat_type, q );
|
4284
4355
|
RQuatInverse( &out, q );
|
4285
4356
|
|
4286
4357
|
return RQuat_from_source( &out );
|
@@ -4296,7 +4367,7 @@ RQuat_inverse_intrusive( VALUE self )
|
|
4296
4367
|
{
|
4297
4368
|
RQuat* q = NULL;
|
4298
4369
|
|
4299
|
-
|
4370
|
+
TypedData_Get_Struct( self, RQuat, &RQuat_type, q );
|
4300
4371
|
RQuatInverse( q, q );
|
4301
4372
|
|
4302
4373
|
return self;
|
@@ -4313,7 +4384,7 @@ RQuat_normalize( VALUE self )
|
|
4313
4384
|
RQuat* v = NULL;
|
4314
4385
|
RQuat out;
|
4315
4386
|
|
4316
|
-
|
4387
|
+
TypedData_Get_Struct( self, RQuat, &RQuat_type, v );
|
4317
4388
|
RQuatNormalize( &out, v );
|
4318
4389
|
|
4319
4390
|
return RQuat_from_source( &out );
|
@@ -4329,7 +4400,7 @@ RQuat_normalize_intrusive( VALUE self )
|
|
4329
4400
|
{
|
4330
4401
|
RQuat* v = NULL;
|
4331
4402
|
|
4332
|
-
|
4403
|
+
TypedData_Get_Struct( self, RQuat, &RQuat_type, v );
|
4333
4404
|
RQuatNormalize( v, v );
|
4334
4405
|
|
4335
4406
|
return self;
|
@@ -4357,7 +4428,7 @@ RQuat_op_unary_minus( VALUE self )
|
|
4357
4428
|
RQuat* v = NULL;
|
4358
4429
|
RQuat out;
|
4359
4430
|
|
4360
|
-
|
4431
|
+
TypedData_Get_Struct( self, RQuat, &RQuat_type, v );
|
4361
4432
|
RQuatScale( &out, v, (rmReal)(-1) );
|
4362
4433
|
|
4363
4434
|
return RQuat_from_source( &out );
|
@@ -4386,8 +4457,8 @@ RQuat_op_binary_plus( VALUE self, VALUE other )
|
|
4386
4457
|
}
|
4387
4458
|
#endif
|
4388
4459
|
|
4389
|
-
|
4390
|
-
|
4460
|
+
TypedData_Get_Struct( self, RQuat, &RQuat_type, v1 );
|
4461
|
+
TypedData_Get_Struct( other, RQuat, &RQuat_type, v2 );
|
4391
4462
|
RQuatAdd( &result, v1, v2 );
|
4392
4463
|
|
4393
4464
|
return RQuat_from_source( &result );
|
@@ -4416,8 +4487,8 @@ RQuat_op_binary_minus( VALUE self, VALUE other )
|
|
4416
4487
|
}
|
4417
4488
|
#endif
|
4418
4489
|
|
4419
|
-
|
4420
|
-
|
4490
|
+
TypedData_Get_Struct( self, RQuat, &RQuat_type, v1 );
|
4491
|
+
TypedData_Get_Struct( other, RQuat, &RQuat_type, v2 );
|
4421
4492
|
RQuatSub( &result, v1, v2 );
|
4422
4493
|
|
4423
4494
|
return RQuat_from_source( &result );
|
@@ -4435,11 +4506,11 @@ RQuat_op_binary_mult( VALUE self, VALUE other )
|
|
4435
4506
|
RQuat result;
|
4436
4507
|
rmReal f;
|
4437
4508
|
|
4438
|
-
|
4509
|
+
TypedData_Get_Struct( self, RQuat, &RQuat_type, v );
|
4439
4510
|
if ( IsRQuat(other) )
|
4440
4511
|
{
|
4441
4512
|
RQuat* q = NULL;
|
4442
|
-
|
4513
|
+
TypedData_Get_Struct( other, RQuat, &RQuat_type, q );
|
4443
4514
|
RQuatMul( &result, v, q );
|
4444
4515
|
|
4445
4516
|
return RQuat_from_source( &result );
|
@@ -4492,8 +4563,8 @@ RQuat_op_binary_eq( VALUE self, VALUE other )
|
|
4492
4563
|
}
|
4493
4564
|
#endif
|
4494
4565
|
|
4495
|
-
|
4496
|
-
|
4566
|
+
TypedData_Get_Struct( self, RQuat, &RQuat_type, v1 );
|
4567
|
+
TypedData_Get_Struct( other, RQuat, &RQuat_type, v2 );
|
4497
4568
|
|
4498
4569
|
if ( !RQuatEqual(v1,v2) )
|
4499
4570
|
return Qfalse;
|
@@ -4523,8 +4594,8 @@ RQuat_op_assign_plus( VALUE self, VALUE other )
|
|
4523
4594
|
}
|
4524
4595
|
#endif
|
4525
4596
|
|
4526
|
-
|
4527
|
-
|
4597
|
+
TypedData_Get_Struct( self, RQuat, &RQuat_type, v1 );
|
4598
|
+
TypedData_Get_Struct( other, RQuat, &RQuat_type, v2 );
|
4528
4599
|
|
4529
4600
|
RQuatAdd( v1, v1, v2 );
|
4530
4601
|
|
@@ -4553,8 +4624,8 @@ RQuat_op_assign_minus( VALUE self, VALUE other )
|
|
4553
4624
|
}
|
4554
4625
|
#endif
|
4555
4626
|
|
4556
|
-
|
4557
|
-
|
4627
|
+
TypedData_Get_Struct( self, RQuat, &RQuat_type, v1 );
|
4628
|
+
TypedData_Get_Struct( other, RQuat, &RQuat_type, v2 );
|
4558
4629
|
|
4559
4630
|
RQuatSub( v1, v1, v2 );
|
4560
4631
|
|
@@ -4572,11 +4643,11 @@ RQuat_op_assign_mult( VALUE self, VALUE other )
|
|
4572
4643
|
RQuat* v = NULL;
|
4573
4644
|
rmReal f;
|
4574
4645
|
|
4575
|
-
|
4646
|
+
TypedData_Get_Struct( self, RQuat, &RQuat_type, v );
|
4576
4647
|
if ( IsRQuat(other) )
|
4577
4648
|
{
|
4578
4649
|
RQuat* q = NULL;
|
4579
|
-
|
4650
|
+
TypedData_Get_Struct( other, RQuat, &RQuat_type, q );
|
4580
4651
|
RQuatMul( v, v, q );
|
4581
4652
|
|
4582
4653
|
return self;
|
@@ -4611,8 +4682,8 @@ RQuat_rotationMatrix( VALUE self, VALUE mtx )
|
|
4611
4682
|
RQuat* q = NULL;
|
4612
4683
|
RMtx4* m = NULL;
|
4613
4684
|
|
4614
|
-
|
4615
|
-
|
4685
|
+
TypedData_Get_Struct( self, RQuat, &RQuat_type, q );
|
4686
|
+
TypedData_Get_Struct( mtx, RMtx4, &RMtx4_type, m );
|
4616
4687
|
|
4617
4688
|
RQuatRotationMatrix( q, m );
|
4618
4689
|
|
@@ -4631,8 +4702,8 @@ RQuat_rotationAxis( VALUE self, VALUE axis, VALUE radian )
|
|
4631
4702
|
RVec3* vAxis = NULL;
|
4632
4703
|
rmReal angle_radian;
|
4633
4704
|
|
4634
|
-
|
4635
|
-
|
4705
|
+
TypedData_Get_Struct( self, RQuat, &RQuat_type, q );
|
4706
|
+
TypedData_Get_Struct( axis, RVec3, &RVec3_type, vAxis );
|
4636
4707
|
angle_radian = NUM2DBL( radian );
|
4637
4708
|
|
4638
4709
|
RQuatRotationAxis( q, vAxis, angle_radian );
|
@@ -4652,11 +4723,11 @@ RQuat_toAxisAngle( VALUE self )
|
|
4652
4723
|
RVec3 axis;
|
4653
4724
|
rmReal radian;
|
4654
4725
|
|
4655
|
-
|
4726
|
+
TypedData_Get_Struct( self, RQuat, &RQuat_type, q );
|
4656
4727
|
|
4657
4728
|
RQuatToAxisAngle( q, &axis, &radian );
|
4658
4729
|
|
4659
|
-
return rb_ary_new3( 2, RVec3_from_source(&axis),
|
4730
|
+
return rb_ary_new3( 2, RVec3_from_source(&axis), DBL2NUM(radian) );
|
4660
4731
|
}
|
4661
4732
|
|
4662
4733
|
|
@@ -4667,7 +4738,7 @@ RQuat_toAxisAngle( VALUE self )
|
|
4667
4738
|
********************************************************************************/
|
4668
4739
|
|
4669
4740
|
/*
|
4670
|
-
* Document-class:
|
4741
|
+
* Document-class: RMath3D::RVec2
|
4671
4742
|
* provies 3 element vector arithmetic.
|
4672
4743
|
*/
|
4673
4744
|
|
@@ -4677,25 +4748,27 @@ RVec2_free( void* ptr )
|
|
4677
4748
|
xfree( ptr );
|
4678
4749
|
}
|
4679
4750
|
|
4751
|
+
static size_t
|
4752
|
+
RVec2_memsize( const void* ptr )
|
4753
|
+
{
|
4754
|
+
const struct RVec2* data = ptr;
|
4755
|
+
return data ? sizeof(*data) : 0;
|
4756
|
+
}
|
4757
|
+
|
4680
4758
|
static VALUE
|
4681
4759
|
RVec2_from_source( RVec2* src )
|
4682
4760
|
{
|
4683
|
-
RVec2* v =
|
4684
|
-
|
4761
|
+
RVec2* v = ZALLOC( struct RVec2 );
|
4685
4762
|
RVec2Copy( v, src );
|
4686
|
-
|
4687
|
-
return Data_Wrap_Struct( rb_cRVec2, NULL, RVec2_free, v );
|
4763
|
+
return TypedData_Wrap_Struct( rb_cRVec2, &RVec2_type, v );
|
4688
4764
|
}
|
4689
4765
|
|
4690
4766
|
|
4691
4767
|
static VALUE
|
4692
4768
|
RVec2_allocate( VALUE klass )
|
4693
4769
|
{
|
4694
|
-
RVec2* v =
|
4695
|
-
|
4696
|
-
memset( v, 0, sizeof(RVec2) );
|
4697
|
-
|
4698
|
-
return Data_Wrap_Struct( klass, NULL, RVec2_free, v );
|
4770
|
+
RVec2* v = ZALLOC( RVec2 );
|
4771
|
+
return TypedData_Wrap_Struct( klass, &RVec2_type, v );
|
4699
4772
|
}
|
4700
4773
|
|
4701
4774
|
|
@@ -4712,7 +4785,7 @@ static VALUE
|
|
4712
4785
|
RVec2_initialize( int argc, VALUE* argv, VALUE self )
|
4713
4786
|
{
|
4714
4787
|
RVec2* v = NULL;
|
4715
|
-
|
4788
|
+
TypedData_Get_Struct( self, RVec2, &RVec2_type, v );
|
4716
4789
|
|
4717
4790
|
switch( argc )
|
4718
4791
|
{
|
@@ -4745,7 +4818,7 @@ RVec2_initialize( int argc, VALUE* argv, VALUE self )
|
|
4745
4818
|
{
|
4746
4819
|
/* Copy Constructor */
|
4747
4820
|
RVec2* other;
|
4748
|
-
|
4821
|
+
TypedData_Get_Struct( arg , RVec2, &RVec2_type, other );
|
4749
4822
|
RVec2SetElements( v, other->x, other->y );
|
4750
4823
|
return self;
|
4751
4824
|
}
|
@@ -4821,7 +4894,7 @@ RVec2_to_s( VALUE self )
|
|
4821
4894
|
char dest[128], work[2][32];
|
4822
4895
|
int i;
|
4823
4896
|
|
4824
|
-
|
4897
|
+
TypedData_Get_Struct( self, RVec2, &RVec2_type, v );
|
4825
4898
|
|
4826
4899
|
for ( i = 0; i < 2; ++i )
|
4827
4900
|
{
|
@@ -4858,10 +4931,10 @@ RVec2_to_a( VALUE self )
|
|
4858
4931
|
{
|
4859
4932
|
RVec2* v = NULL;
|
4860
4933
|
VALUE dbl[2];
|
4861
|
-
|
4934
|
+
TypedData_Get_Struct( self, RVec2, &RVec2_type, v );
|
4862
4935
|
|
4863
|
-
dbl[0] =
|
4864
|
-
dbl[1] =
|
4936
|
+
dbl[0] = DBL2NUM(RVec2GetElement(v,0));
|
4937
|
+
dbl[1] = DBL2NUM(RVec2GetElement(v,1));
|
4865
4938
|
|
4866
4939
|
return rb_ary_new4( 2, dbl );
|
4867
4940
|
}
|
@@ -4875,7 +4948,7 @@ static VALUE
|
|
4875
4948
|
RVec2_coerce( VALUE self, VALUE other )
|
4876
4949
|
{
|
4877
4950
|
RVec2* v = NULL;
|
4878
|
-
|
4951
|
+
TypedData_Get_Struct( self, RVec2, &RVec2_type, v );
|
4879
4952
|
|
4880
4953
|
switch( TYPE(other) )
|
4881
4954
|
{
|
@@ -4914,7 +4987,7 @@ RVec2_setElements( VALUE self, VALUE x, VALUE y )
|
|
4914
4987
|
RVec2* v = NULL;
|
4915
4988
|
rmReal flt0, flt1;
|
4916
4989
|
|
4917
|
-
|
4990
|
+
TypedData_Get_Struct( self, RVec2, &RVec2_type, v );
|
4918
4991
|
flt0 = NUM2DBL(x);
|
4919
4992
|
flt1 = NUM2DBL(y);
|
4920
4993
|
|
@@ -4935,7 +5008,7 @@ RVec2_setElement( VALUE self, VALUE i, VALUE f )
|
|
4935
5008
|
int at;
|
4936
5009
|
rmReal flt;
|
4937
5010
|
|
4938
|
-
|
5011
|
+
TypedData_Get_Struct( self, RVec2, &RVec2_type, v );
|
4939
5012
|
at = NUM2INT(i);
|
4940
5013
|
flt = NUM2DBL(f);
|
4941
5014
|
|
@@ -4955,7 +5028,7 @@ RVec2_setX( VALUE self, VALUE x )
|
|
4955
5028
|
RVec2* v = NULL;
|
4956
5029
|
rmReal flt0;
|
4957
5030
|
|
4958
|
-
|
5031
|
+
TypedData_Get_Struct( self, RVec2, &RVec2_type, v );
|
4959
5032
|
flt0 = NUM2DBL(x);
|
4960
5033
|
|
4961
5034
|
RVec2SetX( v, flt0 );
|
@@ -4974,7 +5047,7 @@ RVec2_setY( VALUE self, VALUE y )
|
|
4974
5047
|
RVec2* v = NULL;
|
4975
5048
|
rmReal flt0;
|
4976
5049
|
|
4977
|
-
|
5050
|
+
TypedData_Get_Struct( self, RVec2, &RVec2_type, v );
|
4978
5051
|
flt0 = NUM2DBL(y);
|
4979
5052
|
|
4980
5053
|
RVec2SetY( v, flt0 );
|
@@ -4994,11 +5067,11 @@ RVec2_getElement( VALUE self, VALUE i )
|
|
4994
5067
|
int at;
|
4995
5068
|
rmReal flt0;
|
4996
5069
|
|
4997
|
-
|
5070
|
+
TypedData_Get_Struct( self, RVec2, &RVec2_type, v );
|
4998
5071
|
at = FIX2INT(i);
|
4999
5072
|
flt0 = RVec2GetElement( v, at );
|
5000
5073
|
|
5001
|
-
return
|
5074
|
+
return DBL2NUM( flt0 );
|
5002
5075
|
}
|
5003
5076
|
|
5004
5077
|
/*
|
@@ -5012,10 +5085,10 @@ RVec2_getX( VALUE self )
|
|
5012
5085
|
RVec2* v = NULL;
|
5013
5086
|
rmReal flt0;
|
5014
5087
|
|
5015
|
-
|
5088
|
+
TypedData_Get_Struct( self, RVec2, &RVec2_type, v );
|
5016
5089
|
flt0 = RVec2GetX( v );
|
5017
5090
|
|
5018
|
-
return
|
5091
|
+
return DBL2NUM( flt0 );
|
5019
5092
|
}
|
5020
5093
|
|
5021
5094
|
/*
|
@@ -5029,10 +5102,10 @@ RVec2_getY( VALUE self )
|
|
5029
5102
|
RVec2* v = NULL;
|
5030
5103
|
rmReal flt0;
|
5031
5104
|
|
5032
|
-
|
5105
|
+
TypedData_Get_Struct( self, RVec2, &RVec2_type, v );
|
5033
5106
|
flt0 = RVec2GetY( v );
|
5034
5107
|
|
5035
|
-
return
|
5108
|
+
return DBL2NUM( flt0 );
|
5036
5109
|
}
|
5037
5110
|
|
5038
5111
|
/*
|
@@ -5046,10 +5119,10 @@ RVec2_getLength( VALUE self )
|
|
5046
5119
|
RVec2* v = NULL;
|
5047
5120
|
rmReal flt0;
|
5048
5121
|
|
5049
|
-
|
5122
|
+
TypedData_Get_Struct( self, RVec2, &RVec2_type, v );
|
5050
5123
|
flt0 = RVec2Length( v );
|
5051
5124
|
|
5052
|
-
return
|
5125
|
+
return DBL2NUM( flt0 );
|
5053
5126
|
}
|
5054
5127
|
|
5055
5128
|
/*
|
@@ -5063,10 +5136,10 @@ RVec2_getLengthSq( VALUE self )
|
|
5063
5136
|
RVec2* v = NULL;
|
5064
5137
|
rmReal flt0;
|
5065
5138
|
|
5066
|
-
|
5139
|
+
TypedData_Get_Struct( self, RVec2, &RVec2_type, v );
|
5067
5140
|
flt0 = RVec2LengthSq( v );
|
5068
5141
|
|
5069
|
-
return
|
5142
|
+
return DBL2NUM( flt0 );
|
5070
5143
|
}
|
5071
5144
|
|
5072
5145
|
/*
|
@@ -5081,11 +5154,11 @@ RVec2_dot( VALUE self, VALUE v1, VALUE v2 )
|
|
5081
5154
|
RVec2* vec2 = NULL;
|
5082
5155
|
rmReal result;
|
5083
5156
|
|
5084
|
-
|
5085
|
-
|
5157
|
+
TypedData_Get_Struct( v1, RVec2, &RVec2_type, vec1 );
|
5158
|
+
TypedData_Get_Struct( v2, RVec2, &RVec2_type, vec2 );
|
5086
5159
|
result = RVec2Dot( vec1, vec2 );
|
5087
5160
|
|
5088
|
-
return
|
5161
|
+
return DBL2NUM( result );
|
5089
5162
|
}
|
5090
5163
|
|
5091
5164
|
/*
|
@@ -5100,11 +5173,11 @@ RVec2_cross( VALUE self, VALUE v1, VALUE v2 )
|
|
5100
5173
|
RVec2* vec2 = NULL;
|
5101
5174
|
rmReal result;
|
5102
5175
|
|
5103
|
-
|
5104
|
-
|
5176
|
+
TypedData_Get_Struct( v1, RVec2, &RVec2_type, vec1 );
|
5177
|
+
TypedData_Get_Struct( v2, RVec2, &RVec2_type, vec2 );
|
5105
5178
|
result = RVec2Cross( vec1, vec2 );
|
5106
5179
|
|
5107
|
-
return
|
5180
|
+
return DBL2NUM( result );
|
5108
5181
|
}
|
5109
5182
|
|
5110
5183
|
/*
|
@@ -5120,8 +5193,8 @@ RVec2_transform( VALUE self, VALUE mtx )
|
|
5120
5193
|
RMtx2* m;
|
5121
5194
|
RVec2 out;
|
5122
5195
|
|
5123
|
-
|
5124
|
-
|
5196
|
+
TypedData_Get_Struct( self, RVec2, &RVec2_type, v );
|
5197
|
+
TypedData_Get_Struct( mtx, RMtx2, &RMtx2_type, m );
|
5125
5198
|
RVec2Transform( &out, m, v );
|
5126
5199
|
|
5127
5200
|
return RVec2_from_source( &out );
|
@@ -5138,7 +5211,7 @@ RVec2_normalize( VALUE self )
|
|
5138
5211
|
RVec2* v = NULL;
|
5139
5212
|
RVec2 out;
|
5140
5213
|
|
5141
|
-
|
5214
|
+
TypedData_Get_Struct( self, RVec2, &RVec2_type, v );
|
5142
5215
|
RVec2Normalize( &out, v );
|
5143
5216
|
|
5144
5217
|
return RVec2_from_source( &out );
|
@@ -5154,7 +5227,7 @@ RVec2_normalize_intrusive( VALUE self )
|
|
5154
5227
|
{
|
5155
5228
|
RVec2* v = NULL;
|
5156
5229
|
|
5157
|
-
|
5230
|
+
TypedData_Get_Struct( self, RVec2, &RVec2_type, v );
|
5158
5231
|
RVec2Normalize( v, v );
|
5159
5232
|
|
5160
5233
|
return self;
|
@@ -5182,7 +5255,7 @@ RVec2_op_unary_minus( VALUE self )
|
|
5182
5255
|
RVec2* v = NULL;
|
5183
5256
|
RVec2 out;
|
5184
5257
|
|
5185
|
-
|
5258
|
+
TypedData_Get_Struct( self, RVec2, &RVec2_type, v );
|
5186
5259
|
RVec2Scale( &out, v, (rmReal)(-1) );
|
5187
5260
|
|
5188
5261
|
return RVec2_from_source( &out );
|
@@ -5211,8 +5284,8 @@ RVec2_op_binary_plus( VALUE self, VALUE other )
|
|
5211
5284
|
}
|
5212
5285
|
#endif
|
5213
5286
|
|
5214
|
-
|
5215
|
-
|
5287
|
+
TypedData_Get_Struct( self, RVec2, &RVec2_type, v1 );
|
5288
|
+
TypedData_Get_Struct( other, RVec2, &RVec2_type, v2 );
|
5216
5289
|
RVec2Add( &result, v1, v2 );
|
5217
5290
|
|
5218
5291
|
return RVec2_from_source( &result );
|
@@ -5241,8 +5314,8 @@ RVec2_op_binary_minus( VALUE self, VALUE other )
|
|
5241
5314
|
}
|
5242
5315
|
#endif
|
5243
5316
|
|
5244
|
-
|
5245
|
-
|
5317
|
+
TypedData_Get_Struct( self, RVec2, &RVec2_type, v1 );
|
5318
|
+
TypedData_Get_Struct( other, RVec2, &RVec2_type, v2 );
|
5246
5319
|
RVec2Sub( &result, v1, v2 );
|
5247
5320
|
|
5248
5321
|
return RVec2_from_source( &result );
|
@@ -5265,7 +5338,7 @@ RVec2_op_binary_mult( VALUE self, VALUE other )
|
|
5265
5338
|
case T_FIXNUM:
|
5266
5339
|
case T_FLOAT:
|
5267
5340
|
{
|
5268
|
-
|
5341
|
+
TypedData_Get_Struct( self, RVec2, &RVec2_type, v );
|
5269
5342
|
f = NUM2DBL( other );
|
5270
5343
|
RVec2Scale( &result, v, f );
|
5271
5344
|
|
@@ -5306,8 +5379,8 @@ RVec2_op_binary_eq( VALUE self, VALUE other )
|
|
5306
5379
|
}
|
5307
5380
|
#endif
|
5308
5381
|
|
5309
|
-
|
5310
|
-
|
5382
|
+
TypedData_Get_Struct( self, RVec2, &RVec2_type, v1 );
|
5383
|
+
TypedData_Get_Struct( other, RVec2, &RVec2_type, v2 );
|
5311
5384
|
|
5312
5385
|
if ( !RVec2Equal(v1,v2) )
|
5313
5386
|
return Qfalse;
|
@@ -5337,8 +5410,8 @@ RVec2_op_assign_plus( VALUE self, VALUE other )
|
|
5337
5410
|
}
|
5338
5411
|
#endif
|
5339
5412
|
|
5340
|
-
|
5341
|
-
|
5413
|
+
TypedData_Get_Struct( self, RVec2, &RVec2_type, v1 );
|
5414
|
+
TypedData_Get_Struct( other, RVec2, &RVec2_type, v2 );
|
5342
5415
|
|
5343
5416
|
RVec2Add( v1, v1, v2 );
|
5344
5417
|
|
@@ -5367,8 +5440,8 @@ RVec2_op_assign_minus( VALUE self, VALUE other )
|
|
5367
5440
|
}
|
5368
5441
|
#endif
|
5369
5442
|
|
5370
|
-
|
5371
|
-
|
5443
|
+
TypedData_Get_Struct( self, RVec2, &RVec2_type, v1 );
|
5444
|
+
TypedData_Get_Struct( other, RVec2, &RVec2_type, v2 );
|
5372
5445
|
|
5373
5446
|
RVec2Sub( v1, v1, v2 );
|
5374
5447
|
|
@@ -5397,7 +5470,7 @@ RVec2_op_assign_mult( VALUE self, VALUE other )
|
|
5397
5470
|
}
|
5398
5471
|
#endif
|
5399
5472
|
|
5400
|
-
|
5473
|
+
TypedData_Get_Struct( self, RVec2, &RVec2_type, v );
|
5401
5474
|
f = NUM2DBL( other );
|
5402
5475
|
RVec2Scale( v, v, f );
|
5403
5476
|
|
@@ -5412,7 +5485,7 @@ RVec2_op_assign_mult( VALUE self, VALUE other )
|
|
5412
5485
|
********************************************************************************/
|
5413
5486
|
|
5414
5487
|
/*
|
5415
|
-
* Document-class:
|
5488
|
+
* Document-class: RMath3D::RVec3
|
5416
5489
|
* provies 3 element vector arithmetic.
|
5417
5490
|
*/
|
5418
5491
|
|
@@ -5422,25 +5495,27 @@ RVec3_free( void* ptr )
|
|
5422
5495
|
xfree( ptr );
|
5423
5496
|
}
|
5424
5497
|
|
5498
|
+
static size_t
|
5499
|
+
RVec3_memsize( const void* ptr )
|
5500
|
+
{
|
5501
|
+
const struct RVec3* data = ptr;
|
5502
|
+
return data ? sizeof(*data) : 0;
|
5503
|
+
}
|
5504
|
+
|
5425
5505
|
static VALUE
|
5426
5506
|
RVec3_from_source( RVec3* src )
|
5427
5507
|
{
|
5428
|
-
RVec3* v =
|
5429
|
-
|
5508
|
+
RVec3* v = ZALLOC( struct RVec3 );
|
5430
5509
|
RVec3Copy( v, src );
|
5431
|
-
|
5432
|
-
return Data_Wrap_Struct( rb_cRVec3, NULL, RVec3_free, v );
|
5510
|
+
return TypedData_Wrap_Struct( rb_cRVec3, &RVec3_type, v );
|
5433
5511
|
}
|
5434
5512
|
|
5435
5513
|
|
5436
5514
|
static VALUE
|
5437
5515
|
RVec3_allocate( VALUE klass )
|
5438
5516
|
{
|
5439
|
-
RVec3* v =
|
5440
|
-
|
5441
|
-
memset( v, 0, sizeof(RVec3) );
|
5442
|
-
|
5443
|
-
return Data_Wrap_Struct( klass, NULL, RVec3_free, v );
|
5517
|
+
RVec3* v = ZALLOC( RVec3 );
|
5518
|
+
return TypedData_Wrap_Struct( klass, &RVec3_type, v );
|
5444
5519
|
}
|
5445
5520
|
|
5446
5521
|
|
@@ -5457,7 +5532,7 @@ static VALUE
|
|
5457
5532
|
RVec3_initialize( int argc, VALUE* argv, VALUE self )
|
5458
5533
|
{
|
5459
5534
|
RVec3* v = NULL;
|
5460
|
-
|
5535
|
+
TypedData_Get_Struct( self, RVec3, &RVec3_type, v );
|
5461
5536
|
|
5462
5537
|
switch( argc )
|
5463
5538
|
{
|
@@ -5490,7 +5565,7 @@ RVec3_initialize( int argc, VALUE* argv, VALUE self )
|
|
5490
5565
|
{
|
5491
5566
|
/* Copy Constructor */
|
5492
5567
|
RVec3* other;
|
5493
|
-
|
5568
|
+
TypedData_Get_Struct( arg , RVec3, &RVec3_type, other );
|
5494
5569
|
RVec3SetElements( v, other->x, other->y, other->z );
|
5495
5570
|
return self;
|
5496
5571
|
}
|
@@ -5566,7 +5641,7 @@ RVec3_to_s( VALUE self )
|
|
5566
5641
|
char dest[128], work[3][32];
|
5567
5642
|
int i;
|
5568
5643
|
|
5569
|
-
|
5644
|
+
TypedData_Get_Struct( self, RVec3, &RVec3_type, v );
|
5570
5645
|
|
5571
5646
|
for ( i = 0; i < 3; ++i )
|
5572
5647
|
{
|
@@ -5603,11 +5678,11 @@ RVec3_to_a( VALUE self )
|
|
5603
5678
|
{
|
5604
5679
|
RVec3* v = NULL;
|
5605
5680
|
VALUE dbl[3];
|
5606
|
-
|
5681
|
+
TypedData_Get_Struct( self, RVec3, &RVec3_type, v );
|
5607
5682
|
|
5608
|
-
dbl[0] =
|
5609
|
-
dbl[1] =
|
5610
|
-
dbl[2] =
|
5683
|
+
dbl[0] = DBL2NUM(RVec3GetElement(v,0));
|
5684
|
+
dbl[1] = DBL2NUM(RVec3GetElement(v,1));
|
5685
|
+
dbl[2] = DBL2NUM(RVec3GetElement(v,2));
|
5611
5686
|
|
5612
5687
|
return rb_ary_new4( 3, dbl );
|
5613
5688
|
}
|
@@ -5621,7 +5696,7 @@ static VALUE
|
|
5621
5696
|
RVec3_coerce( VALUE self, VALUE other )
|
5622
5697
|
{
|
5623
5698
|
RVec3* v = NULL;
|
5624
|
-
|
5699
|
+
TypedData_Get_Struct( self, RVec3, &RVec3_type, v );
|
5625
5700
|
|
5626
5701
|
switch( TYPE(other) )
|
5627
5702
|
{
|
@@ -5660,7 +5735,7 @@ RVec3_setElements( VALUE self, VALUE x, VALUE y, VALUE z )
|
|
5660
5735
|
RVec3* v = NULL;
|
5661
5736
|
rmReal flt0, flt1, flt2;
|
5662
5737
|
|
5663
|
-
|
5738
|
+
TypedData_Get_Struct( self, RVec3, &RVec3_type, v );
|
5664
5739
|
flt0 = NUM2DBL(x);
|
5665
5740
|
flt1 = NUM2DBL(y);
|
5666
5741
|
flt2 = NUM2DBL(z);
|
@@ -5682,7 +5757,7 @@ RVec3_setElement( VALUE self, VALUE i, VALUE f )
|
|
5682
5757
|
int at;
|
5683
5758
|
rmReal flt;
|
5684
5759
|
|
5685
|
-
|
5760
|
+
TypedData_Get_Struct( self, RVec3, &RVec3_type, v );
|
5686
5761
|
at = NUM2INT(i);
|
5687
5762
|
flt = NUM2DBL(f);
|
5688
5763
|
|
@@ -5702,7 +5777,7 @@ RVec3_setX( VALUE self, VALUE x )
|
|
5702
5777
|
RVec3* v = NULL;
|
5703
5778
|
rmReal flt0;
|
5704
5779
|
|
5705
|
-
|
5780
|
+
TypedData_Get_Struct( self, RVec3, &RVec3_type, v );
|
5706
5781
|
flt0 = NUM2DBL(x);
|
5707
5782
|
|
5708
5783
|
RVec3SetX( v, flt0 );
|
@@ -5721,7 +5796,7 @@ RVec3_setY( VALUE self, VALUE y )
|
|
5721
5796
|
RVec3* v = NULL;
|
5722
5797
|
rmReal flt0;
|
5723
5798
|
|
5724
|
-
|
5799
|
+
TypedData_Get_Struct( self, RVec3, &RVec3_type, v );
|
5725
5800
|
flt0 = NUM2DBL(y);
|
5726
5801
|
|
5727
5802
|
RVec3SetY( v, flt0 );
|
@@ -5740,7 +5815,7 @@ RVec3_setZ( VALUE self, VALUE z )
|
|
5740
5815
|
RVec3* v = NULL;
|
5741
5816
|
rmReal flt0;
|
5742
5817
|
|
5743
|
-
|
5818
|
+
TypedData_Get_Struct( self, RVec3, &RVec3_type, v );
|
5744
5819
|
flt0 = NUM2DBL(z);
|
5745
5820
|
|
5746
5821
|
RVec3SetZ( v, flt0 );
|
@@ -5760,11 +5835,11 @@ RVec3_getElement( VALUE self, VALUE i )
|
|
5760
5835
|
int at;
|
5761
5836
|
rmReal flt0;
|
5762
5837
|
|
5763
|
-
|
5838
|
+
TypedData_Get_Struct( self, RVec3, &RVec3_type, v );
|
5764
5839
|
at = FIX2INT(i);
|
5765
5840
|
flt0 = RVec3GetElement( v, at );
|
5766
5841
|
|
5767
|
-
return
|
5842
|
+
return DBL2NUM( flt0 );
|
5768
5843
|
}
|
5769
5844
|
|
5770
5845
|
/*
|
@@ -5778,10 +5853,10 @@ RVec3_getX( VALUE self )
|
|
5778
5853
|
RVec3* v = NULL;
|
5779
5854
|
rmReal flt0;
|
5780
5855
|
|
5781
|
-
|
5856
|
+
TypedData_Get_Struct( self, RVec3, &RVec3_type, v );
|
5782
5857
|
flt0 = RVec3GetX( v );
|
5783
5858
|
|
5784
|
-
return
|
5859
|
+
return DBL2NUM( flt0 );
|
5785
5860
|
}
|
5786
5861
|
|
5787
5862
|
/*
|
@@ -5795,10 +5870,10 @@ RVec3_getY( VALUE self )
|
|
5795
5870
|
RVec3* v = NULL;
|
5796
5871
|
rmReal flt0;
|
5797
5872
|
|
5798
|
-
|
5873
|
+
TypedData_Get_Struct( self, RVec3, &RVec3_type, v );
|
5799
5874
|
flt0 = RVec3GetY( v );
|
5800
5875
|
|
5801
|
-
return
|
5876
|
+
return DBL2NUM( flt0 );
|
5802
5877
|
}
|
5803
5878
|
|
5804
5879
|
/*
|
@@ -5812,10 +5887,10 @@ RVec3_getZ( VALUE self )
|
|
5812
5887
|
RVec3* v = NULL;
|
5813
5888
|
rmReal flt0;
|
5814
5889
|
|
5815
|
-
|
5890
|
+
TypedData_Get_Struct( self, RVec3, &RVec3_type, v );
|
5816
5891
|
flt0 = RVec3GetZ( v );
|
5817
5892
|
|
5818
|
-
return
|
5893
|
+
return DBL2NUM( flt0 );
|
5819
5894
|
}
|
5820
5895
|
|
5821
5896
|
/*
|
@@ -5829,10 +5904,10 @@ RVec3_getLength( VALUE self )
|
|
5829
5904
|
RVec3* v = NULL;
|
5830
5905
|
rmReal flt0;
|
5831
5906
|
|
5832
|
-
|
5907
|
+
TypedData_Get_Struct( self, RVec3, &RVec3_type, v );
|
5833
5908
|
flt0 = RVec3Length( v );
|
5834
5909
|
|
5835
|
-
return
|
5910
|
+
return DBL2NUM( flt0 );
|
5836
5911
|
}
|
5837
5912
|
|
5838
5913
|
/*
|
@@ -5846,10 +5921,10 @@ RVec3_getLengthSq( VALUE self )
|
|
5846
5921
|
RVec3* v = NULL;
|
5847
5922
|
rmReal flt0;
|
5848
5923
|
|
5849
|
-
|
5924
|
+
TypedData_Get_Struct( self, RVec3, &RVec3_type, v );
|
5850
5925
|
flt0 = RVec3LengthSq( v );
|
5851
5926
|
|
5852
|
-
return
|
5927
|
+
return DBL2NUM( flt0 );
|
5853
5928
|
}
|
5854
5929
|
|
5855
5930
|
/*
|
@@ -5864,11 +5939,11 @@ RVec3_dot( VALUE self, VALUE v1, VALUE v2 )
|
|
5864
5939
|
RVec3* vec2 = NULL;
|
5865
5940
|
rmReal result;
|
5866
5941
|
|
5867
|
-
|
5868
|
-
|
5942
|
+
TypedData_Get_Struct( v1, RVec3, &RVec3_type, vec1 );
|
5943
|
+
TypedData_Get_Struct( v2, RVec3, &RVec3_type, vec2 );
|
5869
5944
|
result = RVec3Dot( vec1, vec2 );
|
5870
5945
|
|
5871
|
-
return
|
5946
|
+
return DBL2NUM( result );
|
5872
5947
|
}
|
5873
5948
|
|
5874
5949
|
/*
|
@@ -5883,8 +5958,8 @@ RVec3_cross( VALUE self, VALUE v1, VALUE v2 )
|
|
5883
5958
|
RVec3* vec2 = NULL;
|
5884
5959
|
RVec3 out;
|
5885
5960
|
|
5886
|
-
|
5887
|
-
|
5961
|
+
TypedData_Get_Struct( v1, RVec3, &RVec3_type, vec1 );
|
5962
|
+
TypedData_Get_Struct( v2, RVec3, &RVec3_type, vec2 );
|
5888
5963
|
RVec3Cross( &out, vec1, vec2 );
|
5889
5964
|
|
5890
5965
|
return RVec3_from_source( &out );
|
@@ -5903,8 +5978,8 @@ RVec3_transform( VALUE self, VALUE mtx )
|
|
5903
5978
|
RMtx4* m;
|
5904
5979
|
RVec4 out;
|
5905
5980
|
|
5906
|
-
|
5907
|
-
|
5981
|
+
TypedData_Get_Struct( self, RVec3, &RVec3_type, v );
|
5982
|
+
TypedData_Get_Struct( mtx, RMtx4, &RMtx4_type, m );
|
5908
5983
|
RVec3Transform( &out, m, v );
|
5909
5984
|
|
5910
5985
|
return RVec4_from_source( &out );
|
@@ -5924,8 +5999,8 @@ RVec3_transformCoord( VALUE self, VALUE mtx )
|
|
5924
5999
|
RMtx4* m;
|
5925
6000
|
RVec3 out;
|
5926
6001
|
|
5927
|
-
|
5928
|
-
|
6002
|
+
TypedData_Get_Struct( self, RVec3, &RVec3_type, v );
|
6003
|
+
TypedData_Get_Struct( mtx, RMtx4, &RMtx4_type, m );
|
5929
6004
|
RVec3TransformCoord( &out, m, v );
|
5930
6005
|
|
5931
6006
|
return RVec3_from_source( &out );
|
@@ -5944,8 +6019,8 @@ RVec3_transformCoord_intrusive( VALUE self, VALUE mtx )
|
|
5944
6019
|
RVec3* v;
|
5945
6020
|
RMtx4* m;
|
5946
6021
|
|
5947
|
-
|
5948
|
-
|
6022
|
+
TypedData_Get_Struct( self, RVec3, &RVec3_type, v );
|
6023
|
+
TypedData_Get_Struct( mtx, RMtx4, &RMtx4_type, m );
|
5949
6024
|
RVec3TransformCoord( v, m, v );
|
5950
6025
|
|
5951
6026
|
return self;
|
@@ -5967,8 +6042,8 @@ RVec3_transformNormal( VALUE self, VALUE mtx )
|
|
5967
6042
|
RMtx4* m;
|
5968
6043
|
RVec3 out;
|
5969
6044
|
|
5970
|
-
|
5971
|
-
|
6045
|
+
TypedData_Get_Struct( self, RVec3, &RVec3_type, v );
|
6046
|
+
TypedData_Get_Struct( mtx, RMtx4, &RMtx4_type, m );
|
5972
6047
|
RVec3TransformNormal( &out, m, v );
|
5973
6048
|
|
5974
6049
|
return RVec3_from_source( &out );
|
@@ -5989,8 +6064,8 @@ RVec3_transformNormal_intrusive( VALUE self, VALUE mtx )
|
|
5989
6064
|
RVec3* v;
|
5990
6065
|
RMtx4* m;
|
5991
6066
|
|
5992
|
-
|
5993
|
-
|
6067
|
+
TypedData_Get_Struct( self, RVec3, &RVec3_type, v );
|
6068
|
+
TypedData_Get_Struct( mtx, RMtx4, &RMtx4_type, m );
|
5994
6069
|
RVec3TransformNormal( v, m, v );
|
5995
6070
|
|
5996
6071
|
return self;
|
@@ -6014,8 +6089,8 @@ RVec3_transformRS( VALUE self, VALUE mtx )
|
|
6014
6089
|
RMtx3* m;
|
6015
6090
|
RVec3 out;
|
6016
6091
|
|
6017
|
-
|
6018
|
-
|
6092
|
+
TypedData_Get_Struct( self, RVec3, &RVec3_type, v );
|
6093
|
+
TypedData_Get_Struct( mtx, RMtx3, &RMtx3_type, m );
|
6019
6094
|
RVec3TransformRS( &out, m, v );
|
6020
6095
|
|
6021
6096
|
return RVec3_from_source( &out );
|
@@ -6038,8 +6113,8 @@ RVec3_transformRS_intrusive( VALUE self, VALUE mtx )
|
|
6038
6113
|
RVec3* v;
|
6039
6114
|
RMtx3* m;
|
6040
6115
|
|
6041
|
-
|
6042
|
-
|
6116
|
+
TypedData_Get_Struct( self, RVec3, &RVec3_type, v );
|
6117
|
+
TypedData_Get_Struct( mtx, RMtx3, &RMtx3_type, m );
|
6043
6118
|
RVec3TransformRS( v, m, v );
|
6044
6119
|
|
6045
6120
|
return self;
|
@@ -6063,8 +6138,8 @@ RVec3_transformRSTransposed( VALUE self, VALUE mtx )
|
|
6063
6138
|
RMtx3* m;
|
6064
6139
|
RVec3 out;
|
6065
6140
|
|
6066
|
-
|
6067
|
-
|
6141
|
+
TypedData_Get_Struct( self, RVec3, &RVec3_type, v );
|
6142
|
+
TypedData_Get_Struct( mtx, RMtx3, &RMtx3_type, m );
|
6068
6143
|
RVec3TransformRSTransposed( &out, m, v );
|
6069
6144
|
|
6070
6145
|
return RVec3_from_source( &out );
|
@@ -6087,8 +6162,8 @@ RVec3_transformRSTransposed_intrusive( VALUE self, VALUE mtx )
|
|
6087
6162
|
RVec3* v;
|
6088
6163
|
RMtx3* m;
|
6089
6164
|
|
6090
|
-
|
6091
|
-
|
6165
|
+
TypedData_Get_Struct( self, RVec3, &RVec3_type, v );
|
6166
|
+
TypedData_Get_Struct( mtx, RMtx3, &RMtx3_type, m );
|
6092
6167
|
RVec3TransformRSTransposed( v, m, v );
|
6093
6168
|
|
6094
6169
|
return self;
|
@@ -6104,8 +6179,8 @@ RVec3_transformByQuaternion( VALUE self, VALUE quat )
|
|
6104
6179
|
RQuat* q;
|
6105
6180
|
RVec3 out;
|
6106
6181
|
|
6107
|
-
|
6108
|
-
|
6182
|
+
TypedData_Get_Struct( self, RVec3, &RVec3_type, v );
|
6183
|
+
TypedData_Get_Struct( quat, RQuat, &RQuat_type, q );
|
6109
6184
|
RVec3TransformByQuaternion( &out, q, v );
|
6110
6185
|
|
6111
6186
|
return RVec3_from_source( &out );
|
@@ -6120,8 +6195,8 @@ RVec3_transformByQuaternion_intrusive( VALUE self, VALUE quat )
|
|
6120
6195
|
RVec3* v;
|
6121
6196
|
RQuat* q;
|
6122
6197
|
|
6123
|
-
|
6124
|
-
|
6198
|
+
TypedData_Get_Struct( self, RVec3, &RVec3_type, v );
|
6199
|
+
TypedData_Get_Struct( quat, RQuat, &RQuat_type, q );
|
6125
6200
|
RVec3TransformByQuaternion( v, q, v );
|
6126
6201
|
|
6127
6202
|
return self;
|
@@ -6138,7 +6213,7 @@ RVec3_normalize( VALUE self )
|
|
6138
6213
|
RVec3* v = NULL;
|
6139
6214
|
RVec3 out;
|
6140
6215
|
|
6141
|
-
|
6216
|
+
TypedData_Get_Struct( self, RVec3, &RVec3_type, v );
|
6142
6217
|
RVec3Normalize( &out, v );
|
6143
6218
|
|
6144
6219
|
return RVec3_from_source( &out );
|
@@ -6154,7 +6229,7 @@ RVec3_normalize_intrusive( VALUE self )
|
|
6154
6229
|
{
|
6155
6230
|
RVec3* v = NULL;
|
6156
6231
|
|
6157
|
-
|
6232
|
+
TypedData_Get_Struct( self, RVec3, &RVec3_type, v );
|
6158
6233
|
RVec3Normalize( v, v );
|
6159
6234
|
|
6160
6235
|
return self;
|
@@ -6182,7 +6257,7 @@ RVec3_op_unary_minus( VALUE self )
|
|
6182
6257
|
RVec3* v = NULL;
|
6183
6258
|
RVec3 out;
|
6184
6259
|
|
6185
|
-
|
6260
|
+
TypedData_Get_Struct( self, RVec3, &RVec3_type, v );
|
6186
6261
|
RVec3Scale( &out, v, (rmReal)(-1) );
|
6187
6262
|
|
6188
6263
|
return RVec3_from_source( &out );
|
@@ -6211,8 +6286,8 @@ RVec3_op_binary_plus( VALUE self, VALUE other )
|
|
6211
6286
|
}
|
6212
6287
|
#endif
|
6213
6288
|
|
6214
|
-
|
6215
|
-
|
6289
|
+
TypedData_Get_Struct( self, RVec3, &RVec3_type, v1 );
|
6290
|
+
TypedData_Get_Struct( other, RVec3, &RVec3_type, v2 );
|
6216
6291
|
RVec3Add( &result, v1, v2 );
|
6217
6292
|
|
6218
6293
|
return RVec3_from_source( &result );
|
@@ -6241,8 +6316,8 @@ RVec3_op_binary_minus( VALUE self, VALUE other )
|
|
6241
6316
|
}
|
6242
6317
|
#endif
|
6243
6318
|
|
6244
|
-
|
6245
|
-
|
6319
|
+
TypedData_Get_Struct( self, RVec3, &RVec3_type, v1 );
|
6320
|
+
TypedData_Get_Struct( other, RVec3, &RVec3_type, v2 );
|
6246
6321
|
RVec3Sub( &result, v1, v2 );
|
6247
6322
|
|
6248
6323
|
return RVec3_from_source( &result );
|
@@ -6265,7 +6340,7 @@ RVec3_op_binary_mult( VALUE self, VALUE other )
|
|
6265
6340
|
case T_FIXNUM:
|
6266
6341
|
case T_FLOAT:
|
6267
6342
|
{
|
6268
|
-
|
6343
|
+
TypedData_Get_Struct( self, RVec3, &RVec3_type, v );
|
6269
6344
|
f = NUM2DBL( other );
|
6270
6345
|
RVec3Scale( &result, v, f );
|
6271
6346
|
|
@@ -6306,8 +6381,8 @@ RVec3_op_binary_eq( VALUE self, VALUE other )
|
|
6306
6381
|
}
|
6307
6382
|
#endif
|
6308
6383
|
|
6309
|
-
|
6310
|
-
|
6384
|
+
TypedData_Get_Struct( self, RVec3, &RVec3_type, v1 );
|
6385
|
+
TypedData_Get_Struct( other, RVec3, &RVec3_type, v2 );
|
6311
6386
|
|
6312
6387
|
if ( !RVec3Equal(v1,v2) )
|
6313
6388
|
return Qfalse;
|
@@ -6337,8 +6412,8 @@ RVec3_op_assign_plus( VALUE self, VALUE other )
|
|
6337
6412
|
}
|
6338
6413
|
#endif
|
6339
6414
|
|
6340
|
-
|
6341
|
-
|
6415
|
+
TypedData_Get_Struct( self, RVec3, &RVec3_type, v1 );
|
6416
|
+
TypedData_Get_Struct( other, RVec3, &RVec3_type, v2 );
|
6342
6417
|
|
6343
6418
|
RVec3Add( v1, v1, v2 );
|
6344
6419
|
|
@@ -6367,8 +6442,8 @@ RVec3_op_assign_minus( VALUE self, VALUE other )
|
|
6367
6442
|
}
|
6368
6443
|
#endif
|
6369
6444
|
|
6370
|
-
|
6371
|
-
|
6445
|
+
TypedData_Get_Struct( self, RVec3, &RVec3_type, v1 );
|
6446
|
+
TypedData_Get_Struct( other, RVec3, &RVec3_type, v2 );
|
6372
6447
|
|
6373
6448
|
RVec3Sub( v1, v1, v2 );
|
6374
6449
|
|
@@ -6397,7 +6472,7 @@ RVec3_op_assign_mult( VALUE self, VALUE other )
|
|
6397
6472
|
}
|
6398
6473
|
#endif
|
6399
6474
|
|
6400
|
-
|
6475
|
+
TypedData_Get_Struct( self, RVec3, &RVec3_type, v );
|
6401
6476
|
f = NUM2DBL( other );
|
6402
6477
|
RVec3Scale( v, v, f );
|
6403
6478
|
|
@@ -6412,7 +6487,7 @@ RVec3_op_assign_mult( VALUE self, VALUE other )
|
|
6412
6487
|
********************************************************************************/
|
6413
6488
|
|
6414
6489
|
/*
|
6415
|
-
* Document-class:
|
6490
|
+
* Document-class: RMath3D::RVec4
|
6416
6491
|
* provies 4 element vector arithmetic.
|
6417
6492
|
*/
|
6418
6493
|
|
@@ -6422,25 +6497,27 @@ RVec4_free( void* ptr )
|
|
6422
6497
|
xfree( ptr );
|
6423
6498
|
}
|
6424
6499
|
|
6500
|
+
static size_t
|
6501
|
+
RVec4_memsize( const void* ptr )
|
6502
|
+
{
|
6503
|
+
const struct RVec4* data = ptr;
|
6504
|
+
return data ? sizeof(*data) : 0;
|
6505
|
+
}
|
6506
|
+
|
6425
6507
|
static VALUE
|
6426
6508
|
RVec4_from_source( RVec4* src )
|
6427
6509
|
{
|
6428
|
-
RVec4* v =
|
6429
|
-
|
6510
|
+
RVec4* v = ZALLOC( struct RVec4 );
|
6430
6511
|
RVec4Copy( v, src );
|
6431
|
-
|
6432
|
-
return Data_Wrap_Struct( rb_cRVec4, NULL, RVec4_free, v );
|
6512
|
+
return TypedData_Wrap_Struct( rb_cRVec4, &RVec4_type, v );
|
6433
6513
|
}
|
6434
6514
|
|
6435
6515
|
|
6436
6516
|
static VALUE
|
6437
6517
|
RVec4_allocate( VALUE klass )
|
6438
6518
|
{
|
6439
|
-
RVec4* v =
|
6440
|
-
|
6441
|
-
memset( v, 0, sizeof(RVec4) );
|
6442
|
-
|
6443
|
-
return Data_Wrap_Struct( klass, NULL, RVec4_free, v );
|
6519
|
+
RVec4* v = ZALLOC( RVec4 );
|
6520
|
+
return TypedData_Wrap_Struct( klass, &RVec4_type, v );
|
6444
6521
|
}
|
6445
6522
|
|
6446
6523
|
|
@@ -6457,7 +6534,7 @@ static VALUE
|
|
6457
6534
|
RVec4_initialize( int argc, VALUE* argv, VALUE self )
|
6458
6535
|
{
|
6459
6536
|
RVec4* v = NULL;
|
6460
|
-
|
6537
|
+
TypedData_Get_Struct( self, RVec4, &RVec4_type, v );
|
6461
6538
|
|
6462
6539
|
switch( argc )
|
6463
6540
|
{
|
@@ -6490,7 +6567,7 @@ RVec4_initialize( int argc, VALUE* argv, VALUE self )
|
|
6490
6567
|
{
|
6491
6568
|
/* Create from RVec3 */
|
6492
6569
|
RVec3* other;
|
6493
|
-
|
6570
|
+
TypedData_Get_Struct( arg , RVec3, &RVec3_type, other );
|
6494
6571
|
RVec4SetElements( v, other->x, other->y, other->z, 0.0f );
|
6495
6572
|
return self;
|
6496
6573
|
}
|
@@ -6498,7 +6575,7 @@ RVec4_initialize( int argc, VALUE* argv, VALUE self )
|
|
6498
6575
|
{
|
6499
6576
|
/* Copy Constructor */
|
6500
6577
|
RVec4* other;
|
6501
|
-
|
6578
|
+
TypedData_Get_Struct( arg , RVec4, &RVec4_type, other );
|
6502
6579
|
RVec4SetElements( v, other->x, other->y, other->z, other->w );
|
6503
6580
|
return self;
|
6504
6581
|
}
|
@@ -6574,7 +6651,7 @@ RVec4_to_s( VALUE self )
|
|
6574
6651
|
char dest[128], work[4][32];
|
6575
6652
|
int i;
|
6576
6653
|
|
6577
|
-
|
6654
|
+
TypedData_Get_Struct( self, RVec4, &RVec4_type, v );
|
6578
6655
|
|
6579
6656
|
for ( i = 0; i < 4; ++i )
|
6580
6657
|
{
|
@@ -6611,12 +6688,12 @@ RVec4_to_a( VALUE self )
|
|
6611
6688
|
{
|
6612
6689
|
RVec4* v = NULL;
|
6613
6690
|
VALUE dbl[4];
|
6614
|
-
|
6691
|
+
TypedData_Get_Struct( self, RVec4, &RVec4_type, v );
|
6615
6692
|
|
6616
|
-
dbl[0] =
|
6617
|
-
dbl[1] =
|
6618
|
-
dbl[2] =
|
6619
|
-
dbl[3] =
|
6693
|
+
dbl[0] = DBL2NUM(RVec4GetElement(v,0));
|
6694
|
+
dbl[1] = DBL2NUM(RVec4GetElement(v,1));
|
6695
|
+
dbl[2] = DBL2NUM(RVec4GetElement(v,2));
|
6696
|
+
dbl[3] = DBL2NUM(RVec4GetElement(v,3));
|
6620
6697
|
|
6621
6698
|
return rb_ary_new4( 4, dbl );
|
6622
6699
|
}
|
@@ -6630,7 +6707,7 @@ static VALUE
|
|
6630
6707
|
RVec4_coerce( VALUE self, VALUE other )
|
6631
6708
|
{
|
6632
6709
|
RVec4* v = NULL;
|
6633
|
-
|
6710
|
+
TypedData_Get_Struct( self, RVec4, &RVec4_type, v );
|
6634
6711
|
|
6635
6712
|
switch( TYPE(other) )
|
6636
6713
|
{
|
@@ -6669,7 +6746,7 @@ RVec4_setElements( VALUE self, VALUE x, VALUE y, VALUE z, VALUE w )
|
|
6669
6746
|
RVec4* v = NULL;
|
6670
6747
|
rmReal flt0, flt1, flt2, flt3;
|
6671
6748
|
|
6672
|
-
|
6749
|
+
TypedData_Get_Struct( self, RVec4, &RVec4_type, v );
|
6673
6750
|
flt0 = NUM2DBL(x);
|
6674
6751
|
flt1 = NUM2DBL(y);
|
6675
6752
|
flt2 = NUM2DBL(z);
|
@@ -6692,7 +6769,7 @@ RVec4_setElement( VALUE self, VALUE i, VALUE f )
|
|
6692
6769
|
int at;
|
6693
6770
|
rmReal flt;
|
6694
6771
|
|
6695
|
-
|
6772
|
+
TypedData_Get_Struct( self, RVec4, &RVec4_type, v );
|
6696
6773
|
at = NUM2INT(i);
|
6697
6774
|
flt = NUM2DBL(f);
|
6698
6775
|
|
@@ -6712,7 +6789,7 @@ RVec4_setX( VALUE self, VALUE x )
|
|
6712
6789
|
RVec4* v = NULL;
|
6713
6790
|
rmReal flt0;
|
6714
6791
|
|
6715
|
-
|
6792
|
+
TypedData_Get_Struct( self, RVec4, &RVec4_type, v );
|
6716
6793
|
flt0 = NUM2DBL(x);
|
6717
6794
|
|
6718
6795
|
RVec4SetX( v, flt0 );
|
@@ -6731,7 +6808,7 @@ RVec4_setY( VALUE self, VALUE y )
|
|
6731
6808
|
RVec4* v = NULL;
|
6732
6809
|
rmReal flt0;
|
6733
6810
|
|
6734
|
-
|
6811
|
+
TypedData_Get_Struct( self, RVec4, &RVec4_type, v );
|
6735
6812
|
flt0 = NUM2DBL(y);
|
6736
6813
|
|
6737
6814
|
RVec4SetY( v, flt0 );
|
@@ -6750,7 +6827,7 @@ RVec4_setZ( VALUE self, VALUE z )
|
|
6750
6827
|
RVec4* v = NULL;
|
6751
6828
|
rmReal flt0;
|
6752
6829
|
|
6753
|
-
|
6830
|
+
TypedData_Get_Struct( self, RVec4, &RVec4_type, v );
|
6754
6831
|
flt0 = NUM2DBL(z);
|
6755
6832
|
|
6756
6833
|
RVec4SetZ( v, flt0 );
|
@@ -6769,7 +6846,7 @@ RVec4_setW( VALUE self, VALUE w )
|
|
6769
6846
|
RVec4* v = NULL;
|
6770
6847
|
rmReal flt0;
|
6771
6848
|
|
6772
|
-
|
6849
|
+
TypedData_Get_Struct( self, RVec4, &RVec4_type, v );
|
6773
6850
|
flt0 = NUM2DBL(w);
|
6774
6851
|
|
6775
6852
|
RVec4SetW( v, flt0 );
|
@@ -6788,8 +6865,8 @@ RVec4_setXYZ( VALUE self, VALUE xyz )
|
|
6788
6865
|
RVec4* v = NULL;
|
6789
6866
|
RVec3* in = NULL;
|
6790
6867
|
|
6791
|
-
|
6792
|
-
|
6868
|
+
TypedData_Get_Struct( self, RVec4, &RVec4_type, v );
|
6869
|
+
TypedData_Get_Struct( xyz, RVec3, &RVec3_type, in );
|
6793
6870
|
|
6794
6871
|
RVec4SetXYZ( v, in );
|
6795
6872
|
|
@@ -6808,11 +6885,11 @@ RVec4_getElement( VALUE self, VALUE i )
|
|
6808
6885
|
int at;
|
6809
6886
|
rmReal flt0;
|
6810
6887
|
|
6811
|
-
|
6888
|
+
TypedData_Get_Struct( self, RVec4, &RVec4_type, v );
|
6812
6889
|
at = FIX2INT(i);
|
6813
6890
|
flt0 = RVec4GetElement( v, at );
|
6814
6891
|
|
6815
|
-
return
|
6892
|
+
return DBL2NUM( flt0 );
|
6816
6893
|
}
|
6817
6894
|
|
6818
6895
|
/*
|
@@ -6826,10 +6903,10 @@ RVec4_getX( VALUE self )
|
|
6826
6903
|
RVec4* v = NULL;
|
6827
6904
|
rmReal flt0;
|
6828
6905
|
|
6829
|
-
|
6906
|
+
TypedData_Get_Struct( self, RVec4, &RVec4_type, v );
|
6830
6907
|
flt0 = RVec4GetX( v );
|
6831
6908
|
|
6832
|
-
return
|
6909
|
+
return DBL2NUM( flt0 );
|
6833
6910
|
}
|
6834
6911
|
|
6835
6912
|
/*
|
@@ -6843,10 +6920,10 @@ RVec4_getY( VALUE self )
|
|
6843
6920
|
RVec4* v = NULL;
|
6844
6921
|
rmReal flt0;
|
6845
6922
|
|
6846
|
-
|
6923
|
+
TypedData_Get_Struct( self, RVec4, &RVec4_type, v );
|
6847
6924
|
flt0 = RVec4GetY( v );
|
6848
6925
|
|
6849
|
-
return
|
6926
|
+
return DBL2NUM( flt0 );
|
6850
6927
|
}
|
6851
6928
|
|
6852
6929
|
/*
|
@@ -6860,10 +6937,10 @@ RVec4_getZ( VALUE self )
|
|
6860
6937
|
RVec4* v = NULL;
|
6861
6938
|
rmReal flt0;
|
6862
6939
|
|
6863
|
-
|
6940
|
+
TypedData_Get_Struct( self, RVec4, &RVec4_type, v );
|
6864
6941
|
flt0 = RVec4GetZ( v );
|
6865
6942
|
|
6866
|
-
return
|
6943
|
+
return DBL2NUM( flt0 );
|
6867
6944
|
}
|
6868
6945
|
|
6869
6946
|
/*
|
@@ -6877,10 +6954,10 @@ RVec4_getW( VALUE self )
|
|
6877
6954
|
RVec4* v = NULL;
|
6878
6955
|
rmReal flt0;
|
6879
6956
|
|
6880
|
-
|
6957
|
+
TypedData_Get_Struct( self, RVec4, &RVec4_type, v );
|
6881
6958
|
flt0 = RVec4GetW( v );
|
6882
6959
|
|
6883
|
-
return
|
6960
|
+
return DBL2NUM( flt0 );
|
6884
6961
|
}
|
6885
6962
|
|
6886
6963
|
/*
|
@@ -6894,7 +6971,7 @@ RVec4_getXYZ( VALUE self )
|
|
6894
6971
|
RVec4* v = NULL;
|
6895
6972
|
RVec3 out;
|
6896
6973
|
|
6897
|
-
|
6974
|
+
TypedData_Get_Struct( self, RVec4, &RVec4_type, v );
|
6898
6975
|
|
6899
6976
|
RVec4GetXYZ( &out, v );
|
6900
6977
|
|
@@ -6912,10 +6989,10 @@ RVec4_getLength( VALUE self )
|
|
6912
6989
|
RVec4* v = NULL;
|
6913
6990
|
rmReal flt0;
|
6914
6991
|
|
6915
|
-
|
6992
|
+
TypedData_Get_Struct( self, RVec4, &RVec4_type, v );
|
6916
6993
|
flt0 = RVec4Length( v );
|
6917
6994
|
|
6918
|
-
return
|
6995
|
+
return DBL2NUM( flt0 );
|
6919
6996
|
}
|
6920
6997
|
|
6921
6998
|
/*
|
@@ -6929,10 +7006,10 @@ RVec4_getLengthSq( VALUE self )
|
|
6929
7006
|
RVec4* v = NULL;
|
6930
7007
|
rmReal flt0;
|
6931
7008
|
|
6932
|
-
|
7009
|
+
TypedData_Get_Struct( self, RVec4, &RVec4_type, v );
|
6933
7010
|
flt0 = RVec4LengthSq( v );
|
6934
7011
|
|
6935
|
-
return
|
7012
|
+
return DBL2NUM( flt0 );
|
6936
7013
|
}
|
6937
7014
|
|
6938
7015
|
/*
|
@@ -6947,11 +7024,11 @@ RVec4_dot( VALUE self, VALUE v1, VALUE v2 )
|
|
6947
7024
|
RVec4* vec2 = NULL;
|
6948
7025
|
rmReal result;
|
6949
7026
|
|
6950
|
-
|
6951
|
-
|
7027
|
+
TypedData_Get_Struct( v1, RVec4, &RVec4_type, vec1 );
|
7028
|
+
TypedData_Get_Struct( v2, RVec4, &RVec4_type, vec2 );
|
6952
7029
|
result = RVec4Dot( vec1, vec2 );
|
6953
7030
|
|
6954
|
-
return
|
7031
|
+
return DBL2NUM( result );
|
6955
7032
|
}
|
6956
7033
|
|
6957
7034
|
/*
|
@@ -6966,8 +7043,8 @@ RVec4_transform( VALUE self, VALUE mtx )
|
|
6966
7043
|
RMtx4* m;
|
6967
7044
|
RVec4 out;
|
6968
7045
|
|
6969
|
-
|
6970
|
-
|
7046
|
+
TypedData_Get_Struct( self, RVec4, &RVec4_type, v );
|
7047
|
+
TypedData_Get_Struct( mtx, RMtx4, &RMtx4_type, m );
|
6971
7048
|
RVec4Transform( &out, m, v );
|
6972
7049
|
|
6973
7050
|
return RVec4_from_source( &out );
|
@@ -6984,8 +7061,8 @@ RVec4_transform_intrusive( VALUE self, VALUE mtx )
|
|
6984
7061
|
RVec4* v;
|
6985
7062
|
RMtx4* m;
|
6986
7063
|
|
6987
|
-
|
6988
|
-
|
7064
|
+
TypedData_Get_Struct( self, RVec4, &RVec4_type, v );
|
7065
|
+
TypedData_Get_Struct( mtx, RMtx4, &RMtx4_type, m );
|
6989
7066
|
RVec4Transform( v, m, v );
|
6990
7067
|
|
6991
7068
|
return self;
|
@@ -7003,8 +7080,8 @@ RVec4_transformTransposed( VALUE self, VALUE mtx )
|
|
7003
7080
|
RMtx4* m;
|
7004
7081
|
RVec4 out;
|
7005
7082
|
|
7006
|
-
|
7007
|
-
|
7083
|
+
TypedData_Get_Struct( self, RVec4, &RVec4_type, v );
|
7084
|
+
TypedData_Get_Struct( mtx, RMtx4, &RMtx4_type, m );
|
7008
7085
|
RVec4TransformTransposed( &out, m, v );
|
7009
7086
|
|
7010
7087
|
return RVec4_from_source( &out );
|
@@ -7021,8 +7098,8 @@ RVec4_transformTransposed_intrusive( VALUE self, VALUE mtx )
|
|
7021
7098
|
RVec4* v;
|
7022
7099
|
RMtx4* m;
|
7023
7100
|
|
7024
|
-
|
7025
|
-
|
7101
|
+
TypedData_Get_Struct( self, RVec4, &RVec4_type, v );
|
7102
|
+
TypedData_Get_Struct( mtx, RMtx4, &RMtx4_type, m );
|
7026
7103
|
RVec4TransformTransposed( v, m, v );
|
7027
7104
|
|
7028
7105
|
return self;
|
@@ -7039,7 +7116,7 @@ RVec4_normalize( VALUE self )
|
|
7039
7116
|
RVec4* v = NULL;
|
7040
7117
|
RVec4 out;
|
7041
7118
|
|
7042
|
-
|
7119
|
+
TypedData_Get_Struct( self, RVec4, &RVec4_type, v );
|
7043
7120
|
RVec4Normalize( &out, v );
|
7044
7121
|
|
7045
7122
|
return RVec4_from_source( &out );
|
@@ -7055,7 +7132,7 @@ RVec4_normalize_intrusive( VALUE self )
|
|
7055
7132
|
{
|
7056
7133
|
RVec4* v = NULL;
|
7057
7134
|
|
7058
|
-
|
7135
|
+
TypedData_Get_Struct( self, RVec4, &RVec4_type, v );
|
7059
7136
|
RVec4Normalize( v, v );
|
7060
7137
|
|
7061
7138
|
return self;
|
@@ -7083,7 +7160,7 @@ RVec4_op_unary_minus( VALUE self )
|
|
7083
7160
|
RVec4* v = NULL;
|
7084
7161
|
RVec4 out;
|
7085
7162
|
|
7086
|
-
|
7163
|
+
TypedData_Get_Struct( self, RVec4, &RVec4_type, v );
|
7087
7164
|
RVec4Scale( &out, v, (rmReal)(-1) );
|
7088
7165
|
|
7089
7166
|
return RVec4_from_source( &out );
|
@@ -7112,8 +7189,8 @@ RVec4_op_binary_plus( VALUE self, VALUE other )
|
|
7112
7189
|
}
|
7113
7190
|
#endif
|
7114
7191
|
|
7115
|
-
|
7116
|
-
|
7192
|
+
TypedData_Get_Struct( self, RVec4, &RVec4_type, v1 );
|
7193
|
+
TypedData_Get_Struct( other, RVec4, &RVec4_type, v2 );
|
7117
7194
|
RVec4Add( &result, v1, v2 );
|
7118
7195
|
|
7119
7196
|
return RVec4_from_source( &result );
|
@@ -7142,8 +7219,8 @@ RVec4_op_binary_minus( VALUE self, VALUE other )
|
|
7142
7219
|
}
|
7143
7220
|
#endif
|
7144
7221
|
|
7145
|
-
|
7146
|
-
|
7222
|
+
TypedData_Get_Struct( self, RVec4, &RVec4_type, v1 );
|
7223
|
+
TypedData_Get_Struct( other, RVec4, &RVec4_type, v2 );
|
7147
7224
|
RVec4Sub( &result, v1, v2 );
|
7148
7225
|
|
7149
7226
|
return RVec4_from_source( &result );
|
@@ -7166,7 +7243,7 @@ RVec4_op_binary_mult( VALUE self, VALUE other )
|
|
7166
7243
|
case T_FIXNUM:
|
7167
7244
|
case T_FLOAT:
|
7168
7245
|
{
|
7169
|
-
|
7246
|
+
TypedData_Get_Struct( self, RVec4, &RVec4_type, v );
|
7170
7247
|
f = NUM2DBL( other );
|
7171
7248
|
RVec4Scale( &result, v, f );
|
7172
7249
|
|
@@ -7207,8 +7284,8 @@ RVec4_op_binary_eq( VALUE self, VALUE other )
|
|
7207
7284
|
}
|
7208
7285
|
#endif
|
7209
7286
|
|
7210
|
-
|
7211
|
-
|
7287
|
+
TypedData_Get_Struct( self, RVec4, &RVec4_type, v1 );
|
7288
|
+
TypedData_Get_Struct( other, RVec4, &RVec4_type, v2 );
|
7212
7289
|
|
7213
7290
|
if ( !RVec4Equal(v1,v2) )
|
7214
7291
|
return Qfalse;
|
@@ -7238,8 +7315,8 @@ RVec4_op_assign_plus( VALUE self, VALUE other )
|
|
7238
7315
|
}
|
7239
7316
|
#endif
|
7240
7317
|
|
7241
|
-
|
7242
|
-
|
7318
|
+
TypedData_Get_Struct( self, RVec4, &RVec4_type, v1 );
|
7319
|
+
TypedData_Get_Struct( other, RVec4, &RVec4_type, v2 );
|
7243
7320
|
|
7244
7321
|
RVec4Add( v1, v1, v2 );
|
7245
7322
|
|
@@ -7268,8 +7345,8 @@ RVec4_op_assign_minus( VALUE self, VALUE other )
|
|
7268
7345
|
}
|
7269
7346
|
#endif
|
7270
7347
|
|
7271
|
-
|
7272
|
-
|
7348
|
+
TypedData_Get_Struct( self, RVec4, &RVec4_type, v1 );
|
7349
|
+
TypedData_Get_Struct( other, RVec4, &RVec4_type, v2 );
|
7273
7350
|
|
7274
7351
|
RVec4Sub( v1, v1, v2 );
|
7275
7352
|
|
@@ -7298,7 +7375,7 @@ RVec4_op_assign_mult( VALUE self, VALUE other )
|
|
7298
7375
|
}
|
7299
7376
|
#endif
|
7300
7377
|
|
7301
|
-
|
7378
|
+
TypedData_Get_Struct( self, RVec4, &RVec4_type, v );
|
7302
7379
|
f = NUM2DBL( other );
|
7303
7380
|
RVec4Scale( v, v, f );
|
7304
7381
|
|
@@ -7346,7 +7423,7 @@ Init_rmath3d()
|
|
7346
7423
|
rb_cRMtx3 = rb_define_class_under( rb_mRMath, "RMtx3", rb_cObject );
|
7347
7424
|
rb_cRMtx4 = rb_define_class_under( rb_mRMath, "RMtx4", rb_cObject );
|
7348
7425
|
|
7349
|
-
rb_define_const( rb_mRMath, "TOLERANCE",
|
7426
|
+
rb_define_const( rb_mRMath, "TOLERANCE", DBL2NUM(RMATH_TOLERANCE) );
|
7350
7427
|
|
7351
7428
|
/********************************************************************************
|
7352
7429
|
* RMtx2
|