ios - How to calculate area of an organic shape? -


i want know possible calculate area of organic shape. shape im trying calculate looks this:

imagine drawn cgpoints

is there special function this? im thinking maybe coreimage or quartz or maybe opengl.

if boundary path consists of straight line segments , not intersect can use following formula compute area of enclosed region (from https://en.wikipedia.org/wiki/polygon#area_and_centroid):

cgpoint points[n];   cgfloat area = 0; (int = 0; < n; i++) {     area += (points[i].x * points[(i+1) % n].y - points[(i+1) % n].x * points[i].y)/2.0; } 

where points[0], ... , points[n-1] starting points of line segments in counter-clockwise order.

for more complicate path segments such bézier curves, can subdivide each segment small parts can approximated line segments.


Comments

Popular posts from this blog

css - Which browser returns the correct result for getBoundingClientRect of an SVG element? -

gcc - Calling fftR4() in c from assembly -

Function that returns a formatted array in VBA -