chipmunk 4.1.0 → 5.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +20 -0
- data/README +60 -0
- data/Rakefile +47 -40
- data/ext/chipmunk/chipmunk.c +39 -3
- data/ext/chipmunk/cpArbiter.c +91 -80
- data/ext/chipmunk/cpArray.c +24 -10
- data/ext/chipmunk/cpBB.c +5 -4
- data/ext/chipmunk/cpBody.c +30 -22
- data/ext/chipmunk/cpCollision.c +54 -53
- data/ext/chipmunk/cpConstraint.c +54 -0
- data/ext/chipmunk/cpDampedRotarySpring.c +106 -0
- data/ext/chipmunk/cpDampedSpring.c +117 -0
- data/ext/chipmunk/cpGearJoint.c +114 -0
- data/ext/chipmunk/cpGrooveJoint.c +138 -0
- data/ext/chipmunk/cpHashSet.c +74 -40
- data/ext/chipmunk/cpPinJoint.c +117 -0
- data/ext/chipmunk/cpPivotJoint.c +114 -0
- data/ext/chipmunk/cpPolyShape.c +117 -15
- data/ext/chipmunk/cpRatchetJoint.c +128 -0
- data/ext/chipmunk/cpRotaryLimitJoint.c +122 -0
- data/ext/chipmunk/cpShape.c +174 -18
- data/ext/chipmunk/cpSimpleMotor.c +99 -0
- data/ext/chipmunk/cpSlideJoint.c +131 -0
- data/ext/chipmunk/cpSpace.c +584 -215
- data/ext/chipmunk/cpSpaceHash.c +191 -105
- data/ext/chipmunk/cpVect.c +18 -10
- data/ext/chipmunk/extconf.rb +34 -4
- data/ext/chipmunk/{chipmunk.h → include/chipmunk/chipmunk.h} +63 -6
- data/ext/chipmunk/include/chipmunk/chipmunk_ffi.h +42 -0
- data/ext/chipmunk/include/chipmunk/chipmunk_types.h +80 -0
- data/ext/chipmunk/include/chipmunk/chipmunk_unsafe.h +54 -0
- data/ext/chipmunk/include/chipmunk/constraints/cpConstraint.h +92 -0
- data/ext/chipmunk/include/chipmunk/constraints/cpDampedRotarySpring.h +46 -0
- data/ext/chipmunk/include/chipmunk/constraints/cpDampedSpring.h +53 -0
- data/ext/chipmunk/include/chipmunk/constraints/cpGearJoint.h +41 -0
- data/ext/chipmunk/include/chipmunk/constraints/cpGrooveJoint.h +44 -0
- data/ext/chipmunk/include/chipmunk/constraints/cpPinJoint.h +43 -0
- data/ext/chipmunk/include/chipmunk/constraints/cpPivotJoint.h +42 -0
- data/ext/chipmunk/include/chipmunk/constraints/cpRatchetJoint.h +40 -0
- data/ext/chipmunk/include/chipmunk/constraints/cpRotaryLimitJoint.h +39 -0
- data/ext/chipmunk/include/chipmunk/constraints/cpSimpleMotor.h +37 -0
- data/ext/chipmunk/include/chipmunk/constraints/cpSlideJoint.h +44 -0
- data/ext/chipmunk/include/chipmunk/constraints/util.h +116 -0
- data/ext/chipmunk/{cpArbiter.h → include/chipmunk/cpArbiter.h} +66 -15
- data/ext/chipmunk/{cpArray.h → include/chipmunk/cpArray.h} +2 -1
- data/ext/chipmunk/{cpBB.h → include/chipmunk/cpBB.h} +21 -0
- data/ext/chipmunk/{cpBody.h → include/chipmunk/cpBody.h} +37 -9
- data/ext/chipmunk/{cpCollision.h → include/chipmunk/cpCollision.h} +1 -1
- data/ext/chipmunk/{cpHashSet.h → include/chipmunk/cpHashSet.h} +12 -9
- data/ext/chipmunk/{cpPolyShape.h → include/chipmunk/cpPolyShape.h} +13 -2
- data/ext/chipmunk/{cpShape.h → include/chipmunk/cpShape.h} +51 -18
- data/ext/chipmunk/include/chipmunk/cpSpace.h +180 -0
- data/ext/chipmunk/{cpSpaceHash.h → include/chipmunk/cpSpaceHash.h} +18 -9
- data/ext/chipmunk/{cpVect.h → include/chipmunk/cpVect.h} +61 -10
- data/ext/chipmunk/prime.h +32 -32
- data/ext/chipmunk/rb_chipmunk.c +125 -109
- data/ext/chipmunk/rb_chipmunk.h +96 -77
- data/ext/chipmunk/rb_cpArbiter.c +225 -0
- data/ext/chipmunk/rb_cpBB.c +174 -154
- data/ext/chipmunk/rb_cpBody.c +347 -239
- data/ext/chipmunk/rb_cpConstraint.c +346 -0
- data/ext/chipmunk/rb_cpShape.c +455 -292
- data/ext/chipmunk/rb_cpSpace.c +544 -330
- data/ext/chipmunk/rb_cpVect.c +321 -250
- data/lib/chipmunk.rb +28 -15
- data/lib/chipmunk/version.rb +3 -0
- metadata +74 -34
- data/ext/chipmunk/cpJoint.c +0 -553
- data/ext/chipmunk/cpJoint.h +0 -122
- data/ext/chipmunk/cpSpace.h +0 -120
- data/ext/chipmunk/rb_cpJoint.c +0 -136
data/ext/chipmunk/rb_cpVect.c
CHANGED
@@ -1,250 +1,321 @@
|
|
1
|
-
/* Copyright (c) 2007 Scott Lembcke
|
2
|
-
*
|
3
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
-
* of this software and associated documentation files (the "Software"), to deal
|
5
|
-
* in the Software without restriction, including without limitation the rights
|
6
|
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
-
* copies of the Software, and to permit persons to whom the Software is
|
8
|
-
* furnished to do so, subject to the following conditions:
|
9
|
-
*
|
10
|
-
* The above copyright notice and this permission notice shall be included in
|
11
|
-
* all copies or substantial portions of the Software.
|
12
|
-
*
|
13
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
19
|
-
* SOFTWARE.
|
20
|
-
*/
|
21
|
-
|
22
|
-
#include
|
23
|
-
|
24
|
-
|
25
|
-
#include "
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
v
|
47
|
-
v->
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
*v =
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
1
|
+
/* Copyright (c) 2007 Scott Lembcke
|
2
|
+
*
|
3
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
+
* of this software and associated documentation files (the "Software"), to deal
|
5
|
+
* in the Software without restriction, including without limitation the rights
|
6
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
+
* copies of the Software, and to permit persons to whom the Software is
|
8
|
+
* furnished to do so, subject to the following conditions:
|
9
|
+
*
|
10
|
+
* The above copyright notice and this permission notice shall be included in
|
11
|
+
* all copies or substantial portions of the Software.
|
12
|
+
*
|
13
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
19
|
+
* SOFTWARE.
|
20
|
+
*/
|
21
|
+
|
22
|
+
#include <stdlib.h>
|
23
|
+
#include "chipmunk.h"
|
24
|
+
|
25
|
+
#include "ruby.h"
|
26
|
+
#include "rb_chipmunk.h"
|
27
|
+
|
28
|
+
VALUE c_cpVect;
|
29
|
+
|
30
|
+
static VALUE
|
31
|
+
rb_cpVectForAngle(VALUE self, VALUE angle)
|
32
|
+
{
|
33
|
+
return VNEW(cpvforangle(NUM2DBL(angle)));
|
34
|
+
}
|
35
|
+
|
36
|
+
static VALUE
|
37
|
+
rb_cpVectAlloc(VALUE klass)
|
38
|
+
{
|
39
|
+
cpVect *v = malloc(sizeof(cpVect));
|
40
|
+
return Data_Wrap_Struct(klass, NULL, free, v);
|
41
|
+
}
|
42
|
+
|
43
|
+
static VALUE
|
44
|
+
rb_cpVectInitialize(VALUE self, VALUE x, VALUE y)
|
45
|
+
{
|
46
|
+
cpVect *v = VGET(self);
|
47
|
+
v->x = NUM2DBL(x);
|
48
|
+
v->y = NUM2DBL(y);
|
49
|
+
|
50
|
+
return self;
|
51
|
+
}
|
52
|
+
|
53
|
+
static VALUE
|
54
|
+
rb_cpVectGetX(VALUE self)
|
55
|
+
{
|
56
|
+
return rb_float_new(VGET(self)->x);
|
57
|
+
}
|
58
|
+
|
59
|
+
static VALUE
|
60
|
+
rb_cpVectGetY(VALUE self)
|
61
|
+
{
|
62
|
+
return rb_float_new(VGET(self)->y);
|
63
|
+
}
|
64
|
+
|
65
|
+
static VALUE
|
66
|
+
rb_cpVectSetX(VALUE self, VALUE x)
|
67
|
+
{
|
68
|
+
VGET(self)->x = NUM2DBL(x);
|
69
|
+
return self;
|
70
|
+
}
|
71
|
+
|
72
|
+
static VALUE
|
73
|
+
rb_cpVectSetY(VALUE self, VALUE y)
|
74
|
+
{
|
75
|
+
VGET(self)->y = NUM2DBL(y);
|
76
|
+
return self;
|
77
|
+
}
|
78
|
+
|
79
|
+
static VALUE
|
80
|
+
rb_cpVectToString(VALUE self)
|
81
|
+
{
|
82
|
+
char str[256];
|
83
|
+
cpVect *v = VGET(self);
|
84
|
+
|
85
|
+
sprintf(str, "(% .3f, % .3f)", v->x, v->y);
|
86
|
+
|
87
|
+
return rb_str_new2(str);
|
88
|
+
}
|
89
|
+
|
90
|
+
static VALUE
|
91
|
+
rb_cpVectToArray(VALUE self)
|
92
|
+
{
|
93
|
+
cpVect *v = VGET(self);
|
94
|
+
return rb_ary_new3(2, rb_float_new(v->x), rb_float_new(v->y));
|
95
|
+
}
|
96
|
+
|
97
|
+
static VALUE
|
98
|
+
rb_cpVectToAngle(VALUE self)
|
99
|
+
{
|
100
|
+
return rb_float_new(cpvtoangle(*VGET(self)));
|
101
|
+
}
|
102
|
+
|
103
|
+
|
104
|
+
static VALUE
|
105
|
+
rb_cpVectNegate(VALUE self)
|
106
|
+
{
|
107
|
+
return VNEW(cpvneg(*VGET(self)));
|
108
|
+
}
|
109
|
+
|
110
|
+
static VALUE
|
111
|
+
rb_cpVectAdd(VALUE self, VALUE v)
|
112
|
+
{
|
113
|
+
return VNEW(cpvadd(*VGET(self), *VGET(v)));
|
114
|
+
}
|
115
|
+
|
116
|
+
static VALUE
|
117
|
+
rb_cpVectSub(VALUE self, VALUE v)
|
118
|
+
{
|
119
|
+
return VNEW(cpvsub(*VGET(self), *VGET(v)));
|
120
|
+
}
|
121
|
+
|
122
|
+
static VALUE
|
123
|
+
rb_cpVectSMult(VALUE self, VALUE s)
|
124
|
+
{
|
125
|
+
return VNEW(cpvmult(*VGET(self), NUM2DBL(s)));
|
126
|
+
}
|
127
|
+
|
128
|
+
static VALUE
|
129
|
+
rb_cpVectSDiv(VALUE self, VALUE s)
|
130
|
+
{
|
131
|
+
cpFloat factor = 1.0f/(float)NUM2DBL(s);
|
132
|
+
return VNEW(cpvmult(*VGET(self), factor));
|
133
|
+
}
|
134
|
+
|
135
|
+
static VALUE
|
136
|
+
rb_cpVectDot(VALUE self, VALUE v)
|
137
|
+
{
|
138
|
+
return rb_float_new(cpvdot(*VGET(self), *VGET(v)));
|
139
|
+
}
|
140
|
+
|
141
|
+
static VALUE
|
142
|
+
rb_cpVectCross(VALUE self, VALUE v)
|
143
|
+
{
|
144
|
+
return rb_float_new(cpvcross(*VGET(self), *VGET(v)));
|
145
|
+
}
|
146
|
+
|
147
|
+
static VALUE
|
148
|
+
rb_cpVectLength(VALUE self)
|
149
|
+
{
|
150
|
+
cpVect *v;
|
151
|
+
Data_Get_Struct(self, cpVect, v);
|
152
|
+
return rb_float_new(cpvlength(*v));
|
153
|
+
}
|
154
|
+
|
155
|
+
static VALUE
|
156
|
+
rb_cpVectLengthsq(VALUE self)
|
157
|
+
{
|
158
|
+
cpVect *v;
|
159
|
+
Data_Get_Struct(self, cpVect, v);
|
160
|
+
return rb_float_new(cpvlengthsq(*v));
|
161
|
+
}
|
162
|
+
|
163
|
+
static VALUE
|
164
|
+
rb_cpVectNorm(VALUE self)
|
165
|
+
{
|
166
|
+
return VNEW(cpvnormalize(*VGET(self)));
|
167
|
+
}
|
168
|
+
|
169
|
+
static VALUE
|
170
|
+
rb_cpVectNormBang(VALUE self)
|
171
|
+
{
|
172
|
+
cpVect *v = VGET(self);
|
173
|
+
*v = cpvnormalize(*v);
|
174
|
+
return self;
|
175
|
+
}
|
176
|
+
|
177
|
+
static VALUE
|
178
|
+
rb_cpVectNormSafe(VALUE self)
|
179
|
+
{
|
180
|
+
return VNEW(cpvnormalize_safe(*VGET(self)));
|
181
|
+
}
|
182
|
+
|
183
|
+
static VALUE
|
184
|
+
rb_cpVectNormSafeBang(VALUE self)
|
185
|
+
{
|
186
|
+
cpVect *v = VGET(self);
|
187
|
+
*v = cpvnormalize_safe(*v);
|
188
|
+
return self;
|
189
|
+
}
|
190
|
+
|
191
|
+
static VALUE
|
192
|
+
rb_cpVectPerp(VALUE self)
|
193
|
+
{
|
194
|
+
return VNEW(cpvperp(*VGET(self)));
|
195
|
+
}
|
196
|
+
|
197
|
+
static VALUE
|
198
|
+
rb_cpVectProject(VALUE self, VALUE v)
|
199
|
+
{
|
200
|
+
return VNEW(cpvproject(*VGET(self), *VGET(v)));
|
201
|
+
}
|
202
|
+
|
203
|
+
static VALUE
|
204
|
+
rb_cpVectRotate(VALUE self, VALUE v)
|
205
|
+
{
|
206
|
+
return VNEW(cpvrotate(*VGET(self), *VGET(v)));
|
207
|
+
}
|
208
|
+
|
209
|
+
static VALUE
|
210
|
+
rb_cpVectUnRotate(VALUE self, VALUE v)
|
211
|
+
{
|
212
|
+
return VNEW(cpvunrotate(*VGET(self), *VGET(v)));
|
213
|
+
}
|
214
|
+
|
215
|
+
static VALUE
|
216
|
+
rb_cpVectNear(VALUE self, VALUE v, VALUE d)
|
217
|
+
{
|
218
|
+
cpFloat dist = NUM2DBL(d);
|
219
|
+
cpVect delta = cpvsub(*VGET(self), *VGET(v));
|
220
|
+
return (cpvdot(delta, delta) <= dist*dist) ? Qtrue : Qfalse;
|
221
|
+
}
|
222
|
+
|
223
|
+
static VALUE
|
224
|
+
rb_vec2(VALUE self, VALUE x, VALUE y)
|
225
|
+
{
|
226
|
+
return VNEW(cpv(NUM2DBL(x), NUM2DBL(y)));
|
227
|
+
}
|
228
|
+
|
229
|
+
static VALUE
|
230
|
+
rb_cpVectDist(VALUE self, VALUE v)
|
231
|
+
{
|
232
|
+
return rb_float_new(cpvdist(*VGET(self), *VGET(v)));
|
233
|
+
}
|
234
|
+
|
235
|
+
static VALUE
|
236
|
+
rb_cpVectDistsq(VALUE self, VALUE v)
|
237
|
+
{
|
238
|
+
return rb_float_new(cpvdistsq(*VGET(self), *VGET(v)));
|
239
|
+
}
|
240
|
+
|
241
|
+
static VALUE
|
242
|
+
rb_cpVectRperp(VALUE self)
|
243
|
+
{
|
244
|
+
return VNEW(cpvrperp(*VGET(self)));
|
245
|
+
}
|
246
|
+
|
247
|
+
static VALUE
|
248
|
+
rb_cpVectLerp(VALUE self, VALUE v, VALUE t)
|
249
|
+
{
|
250
|
+
return VNEW(cpvlerp(*VGET(self), *VGET(v), NUM2DBL(t)));
|
251
|
+
}
|
252
|
+
|
253
|
+
static VALUE
|
254
|
+
rb_cpVectLerpconst(VALUE self, VALUE v, VALUE d)
|
255
|
+
{
|
256
|
+
return VNEW(cpvlerpconst(*VGET(self), *VGET(v), NUM2DBL(d)));
|
257
|
+
}
|
258
|
+
|
259
|
+
static VALUE
|
260
|
+
rb_cpVectSlerp(VALUE self, VALUE v, VALUE t)
|
261
|
+
{
|
262
|
+
return VNEW(cpvslerp(*VGET(self), *VGET(v), NUM2DBL(t)));
|
263
|
+
}
|
264
|
+
|
265
|
+
static VALUE
|
266
|
+
rb_cpVectSlerpconst(VALUE self, VALUE v, VALUE d)
|
267
|
+
{
|
268
|
+
return VNEW(cpvslerpconst(*VGET(self), *VGET(v), NUM2DBL(d)));
|
269
|
+
}
|
270
|
+
|
271
|
+
|
272
|
+
void
|
273
|
+
Init_cpVect(void)
|
274
|
+
{
|
275
|
+
c_cpVect = rb_define_class_under(m_Chipmunk, "Vec2", rb_cObject);
|
276
|
+
rb_define_singleton_method(c_cpVect, "for_angle", rb_cpVectForAngle, 1);
|
277
|
+
|
278
|
+
rb_define_alloc_func(c_cpVect, rb_cpVectAlloc);
|
279
|
+
rb_define_method(c_cpVect, "initialize", rb_cpVectInitialize, 2);
|
280
|
+
|
281
|
+
rb_define_method(c_cpVect, "x", rb_cpVectGetX, 0);
|
282
|
+
rb_define_method(c_cpVect, "y", rb_cpVectGetY, 0);
|
283
|
+
rb_define_method(c_cpVect, "x=", rb_cpVectSetX, 1);
|
284
|
+
rb_define_method(c_cpVect, "y=", rb_cpVectSetY, 1);
|
285
|
+
|
286
|
+
rb_define_method(c_cpVect, "to_s", rb_cpVectToString, 0);
|
287
|
+
rb_define_method(c_cpVect, "to_a", rb_cpVectToArray, 0);
|
288
|
+
rb_define_method(c_cpVect, "to_angle", rb_cpVectToAngle, 0);
|
289
|
+
|
290
|
+
rb_define_method(c_cpVect, "-@", rb_cpVectNegate, 0);
|
291
|
+
rb_define_method(c_cpVect, "+", rb_cpVectAdd, 1);
|
292
|
+
rb_define_method(c_cpVect, "-", rb_cpVectSub, 1);
|
293
|
+
rb_define_method(c_cpVect, "*", rb_cpVectSMult, 1);
|
294
|
+
rb_define_method(c_cpVect, "/", rb_cpVectSDiv, 1);
|
295
|
+
|
296
|
+
rb_define_method(c_cpVect, "dot" , rb_cpVectDot, 1);
|
297
|
+
rb_define_method(c_cpVect, "cross" , rb_cpVectCross, 1);
|
298
|
+
rb_define_method(c_cpVect, "dist" , rb_cpVectDist, 1);
|
299
|
+
rb_define_method(c_cpVect, "distsq" , rb_cpVectDistsq, 1);
|
300
|
+
rb_define_method(c_cpVect, "length" , rb_cpVectLength, 0);
|
301
|
+
rb_define_method(c_cpVect, "lengthsq" , rb_cpVectLengthsq, 0);
|
302
|
+
rb_define_method(c_cpVect, "lerp" , rb_cpVectLerp, 2);
|
303
|
+
rb_define_method(c_cpVect, "lerpconst" , rb_cpVectLerpconst, 2);
|
304
|
+
rb_define_method(c_cpVect, "normalize" , rb_cpVectNorm, 0);
|
305
|
+
rb_define_method(c_cpVect, "normalize!" , rb_cpVectNormBang, 0);
|
306
|
+
rb_define_method(c_cpVect, "normalize_safe" , rb_cpVectNormSafe, 0);
|
307
|
+
rb_define_method(c_cpVect, "normalize_safe!" , rb_cpVectNormSafeBang, 0);
|
308
|
+
|
309
|
+
rb_define_method(c_cpVect, "perp" , rb_cpVectPerp, 0);
|
310
|
+
rb_define_method(c_cpVect, "project" , rb_cpVectProject, 1);
|
311
|
+
rb_define_method(c_cpVect, "rotate" , rb_cpVectRotate, 1);
|
312
|
+
rb_define_method(c_cpVect, "rperp" , rb_cpVectRperp, 0);
|
313
|
+
rb_define_method(c_cpVect, "slerp" , rb_cpVectSlerp, 2);
|
314
|
+
rb_define_method(c_cpVect, "slerpconst" , rb_cpVectSlerpconst, 2);
|
315
|
+
|
316
|
+
|
317
|
+
rb_define_method(c_cpVect, "unrotate" , rb_cpVectUnRotate, 1);
|
318
|
+
rb_define_method(c_cpVect, "near?" , rb_cpVectNear, 2);
|
319
|
+
|
320
|
+
rb_define_global_function("vec2", rb_vec2, 2);
|
321
|
+
}
|