Method: CP.poly_area
- Defined in:
- ext/chipmunk/rb_chipmunk.c
.poly_area(arr) ⇒ Object
95 96 97 98 99 100 101 102 103 104 105 106 107 108 |
# File 'ext/chipmunk/rb_chipmunk.c', line 95 static VALUE rb_cpAreaForPoly(VALUE self, VALUE arr) { Check_Type(arr, T_ARRAY); // TODO do not cast... use stdint.h in chipmunk int numVerts = (int)RARRAY_LEN(arr); VALUE *ary_ptr = RARRAY_PTR(arr); cpVect verts[numVerts]; for(int i = 0; i < numVerts; i++) { verts[i] = *VGET(ary_ptr[i]); } cpFloat area = cpAreaForPoly(numVerts, verts); return rb_float_new(area); } |