0

How do i find the center point from a group of xy coordinates? i have a number of image maps stored in a database. i would like to to find the center point of each so i can move the image to correspond to the selected map. below is an example of the coordinate i have. is this possible?

thanks

1638,3227,1637,3221,1648,3210,1653,3213,1657,3208,1663,3216,1668,3218,1670,3220,1668,3226,1680,3230,1681,3237,1689,3236,1690,3240,1703,3244,1703,3249,1707,3249,1710,3255,1708,3257,1713,3264,1713,3281,1727,3285,1736,3293,1733,3301,1736,3306,1731,3317,1733,3322,1719,3318,1712,3323,1704,3313,1691,3313,1688,3318,1692,3325,1683,3340,1680,3342,1677,3337,1660,3334,1656,3337,1659,3347,1648,3358,1648,3362,1656,3368,1648,3374,1640,3373,1635,3367,1638,3362,1633,3361,1631,3354,1631,3354,1620,3356,1613,3370,1610,3367,1606,3369,1606,3382,1604,3385,1604,3385,1607,3390,1602,3397,1607,3403,1603,3401,1595,3410,1583,3411,1583,3408,1586,3404,1576,3392,1579,3387,1581,3383,1586,3375,1583,3375,1580,3376,1577,3375,1577,3371,1579,3370,1580,3360,1585,3356,1592,3353,1592,3348,1596,3345,1605,3348,1608,3339,1605,3334,1607,3331,1603,3328,1599,3331,1594,3327,1585,3336,1581,3325,1569,3329,1565,3327,1568,3322,1567,3313,1565,3308,1558,3305,1559,3299,1569,3296,1571,3290,1577,3287,1581,3274,1576,3264,1584,3262,1595,3272,1598,3269,1608,3260,1612,3262,1614,3259,1624,3264,1630,3254,1621,3245,1625,3243,1629,3233,1638,3227
gareth
  • 179
  • 2
  • 18
  • This is essentially finding the center of a polygon. I'd concentrate my search on that area. E.g.: [Center of gravity of a polygon](http://stackoverflow.com/q/5271583) (doesn't look trivial tho) also Googling `php center polygon` turns up some interesting results – Pekka Jan 11 '13 at 10:43
  • http://en.wikipedia.org/wiki/Centroid – Mark Baker Jan 11 '13 at 10:44
  • 1
    @Pekka - it's surprisingly straightforward – Mark Baker Jan 11 '13 at 10:45

1 Answers1

0

I think this is a similar question: What is the fastest way to find the center of an irregularly shaped polygon?

Or maybe try this article on wikipedia and do it on your own: Centroid

Community
  • 1
  • 1
martin
  • 93,354
  • 25
  • 191
  • 226