   Center of 3 vector points?
  Hi everyone,  I was just wondering about solving for a simple 3d problem.  If I have three 3D points...p0,p1,p2 and I want the center of the points...so in theory the center of the triangle that is made up of 3 points.Is this how to go about solving for it:vA = p2-p0vB = p1-p0vX = (vA-vB)/2Normalize this value, so we have|vX|So this directoin, vX points to our center point in theoryIf I use our old 3d friend the dot product:vB dot |vX| = pXpX is a point that is on the line between p1 and p2. (This is where I'm unsure if the value of pX is right and if where going in the right direction)So our middle point, pM = (pX-p0)/2If we put it all together we get:  pM = [ vBdot{(vA+vB)/2}- p0 ] /2Is this right?I mean its not so easy to see what I'm talking aobut...all these math vectors and things...so I did a sketch as well to show what I'm doing?I also did a sketch at:http://www.xbdev.net/maths_of_3d/center_of_3_points.jpgIf someone could just look at it and see that it could be right?  Or is there another way of solving for it using possibly the plane equation?Thanks,Ben   
  Is there any reason that you aren't just averaging the coordinates?   ;  how about cx = (v1.x + v2.x + v3.x) / 3cy = ...?   ;  Hi SiCrane,  my 3d maths is a little rusty...but am right in some of my assumptions I hope..like if I have two direction vectors, vA and vB...then the middle direction would be(vA+vB)/2  ?Its when applying the dot product to this normalized directoin and one side vB.....sort of visualising if its doing what I want to do isn't so easy...and if the value would be correct.Hmmmmm //---------------------------Hi incinI thought about averaging p0, p1 and p2, someone else suggested it to me.e.g.pM = (p0 + p1 + p2)/3But it wouldn't really work, as for example, if p0 is at the origin, (0,0,0), then you'd in effect have (p1+p2)/3 which wouldn't really be the center of the 3 points.;  It will give you a 'weighted' center.  If that isn't what you want, just do...cx = (min(v1.x, v2.x, v3.x) + max(v1.x, v2.x, v3.x)) / 2...   ;  You could either take the standard arithmetic mean of the points or you could interpret the points as a triangle (which you probably already are) and find one of the following:- circumcenter (center of the circle passing through all three vertices), - orthocenter (intersection of the altitudes), or- incenter (center of the incircle, or equivalently the intersection of the angle bisectors).I think just averaging the values, however, will be what you want.   ;  I disagree....  I tried averaging the points pM = (p1+p2+p3)/3 and got the "supposed" center point, but after finding the distance to each point with vec = p[n] - pM.... dist = sqrt(vec.x^2 + vec.y^2 + vec.z^2) each distance was different.... :-/   ;Quote:Original post by lazmikeI disagree....  I tried averaging the points pM = (p1+p2+p3)/3 and got the "supposed" center point, but after finding the distance to each point with vec = p[n] - pM.... dist = sqrt(vec.x^2 + vec.y^2 + vec.z^2) each distance was different.... :-/Sounds like you want the orthocenter of the three points. Unfortunately, the orthocenter has the interesting property that it doesn't always lie inside the triangle formed by the three points, which means that it often doesn't pass muster as a "center" either.   ;  http://www.gamedev.net/community/forums/topic.asp?topic_id=319290&whichpage=1&#2064079;  Well its certainly given me something to think about...as it says, I think I want the orthocenter I'm looking forSo if pM is the middle point, then the length from the 3 points is all the same!I've tried some test code in a simple c program using vector maths(http://rafb.net/paste/results/xcagBG21.html)Guess I'm just going to have to play around with the idea...can't seem to see a solution to it yet...but hopefully a lot of coffee and a few scribbles on paper will help me.Thanks everyone:)