Depends on what you mean by "center point", I'd say. If your curve does not intersect itself (i.e. if it forms a
simple polygon), then one usually refers to its
centroid (aka center of mass) as its center point. According to
this Wikipedia page, you can compute the centroid of a simple polygon as follows:
- /*
- Assume x[] and y[] are the vertices of your polygon, and that
- the polygon is not closed, i.e. x[0] != x[x.length - 1] or
- y[0] != y[y.length - 1]. Also assume that x and y have the same
- number of elements.
- */
- float centerX = 0;
- float centerY = 0;
- float area = 0;
- for (int i = 0; i < x.length - 1; i++) {
- float f = x[i] * y[i + 1] - x[i + 1] * y[i];
- area += f;
- centerX += (x[i] + x[i + 1]) * f;
- centerY += (y[i] + y[i + 1]) * f;
- }
- area /= 2;
- centerX /= 6 * area;
- centerY /= 6 * area;
You may have to some adjustments depending on whether the vertices are in clockwise or counterclockwise order, see the Wikipedia page cited above.
Is this what you were looking for?