PaganX 128 Report post Posted May 29, 2005 How do I got about finding the center of 4 points? 0 Share this post Link to post Share on other sites
Hexed 175 Report post Posted May 29, 2005 Easily. Average them out. Assuming you are working in 3D:m.x = (p1.x + p2.x + p3.x + p4.x) / 4;m.y = (p1.y + p2.y + p3.y + p4.y) / 4;m.z = (p1.z + p2.z + p3.z + p4.z) / 4; 0 Share this post Link to post Share on other sites
PaganX 128 Report post Posted May 29, 2005 You rock. I had the right idea, but I was going about it incorrectly.Thank you 0 Share this post Link to post Share on other sites
hplus0603 11373 Report post Posted May 29, 2005 There is no well-defined center of 4 points in 3 dimensions; the problem is over-constrained. There's a centroid, which is what the formula given calculates; that's usually good enough (but could theoretically, actually be outside the polygon circumscribed by p1,p2,p3,p4 !) 0 Share this post Link to post Share on other sites
Hexed 175 Report post Posted May 29, 2005 Yea what he said. 0 Share this post Link to post Share on other sites
Genjix 100 Report post Posted May 30, 2005 (0,0)(10,0)(10,8)(10,1)(10,2)(10,3)(10,5)should give you an idea of finding the centre of some points.try to tell me where the centre of a triangle is and how to find it. 0 Share this post Link to post Share on other sites
SpaceDude 208 Report post Posted May 30, 2005 If by center you mean the point which has the smallest maximum distance to all other points, then taking the average will not work for anything more than 2 points.Imagine 3 of your points are at coordinates (0,0,0) and 1 points is at (1,0,0). The coordinate you will get by taking the average of the 4 is (0.25, 0, 0). But you might consider the center to be (0.5, 0, 0). 0 Share this post Link to post Share on other sites
kSquared 1356 Report post Posted June 5, 2005 Quote:Original post by hplus0603There is no well-defined center of 4 points in 3 dimensions; the problem is over-constrained. There's a centroid, which is what the formula given calculates; that's usually good enough (but could theoretically, actually be outside the polygon circumscribed by p1,p2,p3,p4 !)Can you give an example where this would be the case? I'm having a hard time visualizing that. 0 Share this post Link to post Share on other sites
baldurk 1028 Report post Posted June 5, 2005 1) Take a piece of normal paper2) Fold it across a diagonal, so that each half is at right angles to the other3) Mentally estimate the average of the points.That should be off the polygon(s) described by the four points. The more points you have the easier, but I'm not sure if it's possible for 3 or less.bad diagram: 0 Share this post Link to post Share on other sites
__fold 202 Report post Posted June 5, 2005 May I also add some thoughts?If the four points are a quad then...Draw any quad and draw a line between point 1 and point 3, call it D1. Then draw a line between point 2 and point 4, call it D2.The center of D1:d1.x = (p1.x + p3.x) / 2d1.y = (p1.y + p3.y) / 2d1.z = (p1.z + p3.z) / 2The center of D2:d2.x = (p2.x + p4.x) / 2d2.y = (p2.y + p4.y) / 2d2.z = (p2.z + p4.z) / 2The center (q1) of a line between d1 and d2 is.q1.x = (d1.x + d2.x) / 2q1.y = (d1.y + d2.y) / 2q1.z = (d1.z + d2.z) / 2Substitute it:q1.x = ((p1.x + p3.x) / 2 + (p2.x + p4.x) / 2) / 2q1.y = ((p1.y + p3.y) / 2 + (p2.y + p4.y) / 2) / 2q1.z = ((p1.z + p3.z) / 2 + (p2.z + p4.z) / 2) / 2Simplifies to:q1.x = (p1.x + p2.x + p3.x + p4.x) / 4;q1.y = (p1.y + p2.y + p3.y + p4.y) / 4;q1.z = (p1.z + p2.z + p3.z + p4.z) / 4;...and as everybody can see. This will only make sense for quads where all the points are in the same plane. The point q1 will always be inside the quad only if the quad is convex.EDIT: Small errors... 0 Share this post Link to post Share on other sites
kSquared 1356 Report post Posted June 5, 2005 Quote:Original post by baldurk1) Take a piece of normal paper2) Fold it across a diagonal, so that each half is at right angles to the other3) Mentally estimate the average of the points.That should be off the polygon(s) described by the four points. The more points you have the easier, but I'm not sure if it's possible for 3 or less.bad diagram:I don't think that's a counterexample, since the centroid would still be inside the polyhedron as described. 0 Share this post Link to post Share on other sites
baldurk 1028 Report post Posted June 5, 2005 Quote:Original post by kSquaredQuote:Original post by baldurk1) Take a piece of normal paper2) Fold it across a diagonal, so that each half is at right angles to the other3) Mentally estimate the average of the points.That should be off the polygon(s) described by the four points. The more points you have the easier, but I'm not sure if it's possible for 3 or less.bad diagram:I don't think that's a counterexample, since the centroid would still be inside the polyhedron as described.Hmm I thought that hplus meant that the centroid wouldn't necessarily lie on the polygon. Otherwise, I don't see how it could lie outside. 0 Share this post Link to post Share on other sites
__fold 202 Report post Posted June 5, 2005 EDIT: WRONG!counterexample...(0, 0, a) (1, 0, b) (1, 1, c) (0.75, 0.25, d)Center point c:c.x = (0 + 1 + 1 + 0.75) / 4 = 0.6875c.y = (0 + 0 + 1 + 0.25) / 4 = 0.3125c.z = (a + b + c + d) / 4And as you can see, c will always be outside any volume created by the points given.EDIT: No, I'm wrong... It will always be inside the volume created. As I actuallly showed before, the center of a line segment from d1 to d2 will always be inside the volume.[Edited by - __fold on June 6, 2005 5:14:28 AM] 0 Share this post Link to post Share on other sites
John Schultz 811 Report post Posted June 5, 2005 Given the question:Quote:Original post by PaganXHow do I got about finding the center of 4 points?The exact and correct answer is^{*}:Quote:Original post by HexedEasily. Average them out. Assuming you are working in 3D:m.x = (p1.x + p2.x + p3.x + p4.x) / 4;m.y = (p1.y + p2.y + p3.y + p4.y) / 4;m.z = (p1.z + p2.z + p3.z + p4.z) / 4;See http://mathworld.wolfram.com/GeometricCentroid.htmlThe center for N points is the average, and when used with weighting, can be used for optimization problems as shown below, from the Wolfram link above:Quote:The centroid of n point masses also gives the location at which a school should be built in order to minimize the distance travelled by children from n cities, located at the positions of the masses, and with m_{i} equal to the number of students from city i (Steinhaus 1999, pp. 113-116).4 points can be use to define tetrahedral barycentric coordinates, for which the barycentric center is (.25,.25,.25,.25), or the average of the 4 points.^{*}No planar/polygonal constraint was given. 0 Share this post Link to post Share on other sites