Jump to content
  • Advertisement
Sign in to follow this  
bkenwright

Center of 3 vector points?

This topic is 4856 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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-p0 vB = p1-p0 vX = (vA-vB)/2 Normalize this value, so we have |vX| So this directoin, vX points to our center point in theory If I use our old 3d friend the dot product: vB dot |vX| = pX pX 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)/2 If we put it all together we get: pM = [ vBdot{(vA+vB)/2}- p0 ] /2 Is 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.jpg If 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

Share this post


Link to post
Share on other sites
Advertisement
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 incin
I thought about averaging p0, p1 and p2, someone else suggested it to me.

e.g.

pM = (p0 + p1 + p2)/3

But 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.

Share this post


Link to post
Share on other sites
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
...

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.... :-/

Share this post


Link to post
Share on other sites
Quote:
Original post by lazmike
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.... :-/


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.

Share this post


Link to post
Share on other sites
Well its certainly given me something to think about...as it says, I think I want the orthocenter I'm looking for

So 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

:)

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!