#### Archived

This topic is now archived and is closed to further replies.

# Finding the midpoint of a triangle?

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

## Recommended Posts

Does anybody know how to find the middle point of a triangle in 3-d space? it doesnt have to be the exact middle, just near the middle. thanx in advance. As Kent Brockman says: "ONLY TIME WILL TELL."

##### Share on other sites
Bisect the three angles and see where the lines cross. Ta Da! Simple as

##### Share on other sites
P.S. The faster the better! i need this for a realtime radiosity engine im working on.

##### Share on other sites
Define middle? The center of gravity? The center of the smallest enclosing circle? Center of the biggest enclosed circle?

The middle of two points is the point is their isobarycentric point, so this should be the same for three points :

xM = ( xA + xB + xC ) / 3
yM = ( yA + yB + yC ) / 3

ToohrVyk

##### Share on other sites
Sorry, but im not a bloody mathmatition. can you explain how to do it in terms of a function

As Kent Brockman says:
"ONLY TIME WILL TELL."

##### Share on other sites
Ok, I''ll rephrase the question: If I have 3 sets of 3 co-ordinates representing 3 points of a triangle in 3d space, how can i create a function that will spit out 3 co-ordinates that represent the mid-point of that triangle?

As Kent Brockman says:
"ONLY TIME WILL TELL."

##### Share on other sites
Almost exactly as was written above. If your function takes in 3 points, p1, p2, and p3, and returns another point p then it is just:

p.x=(p1.x+p2.x+p3.x)/3;

and the same for y and z.

##### Share on other sites
a function would be:
POINT Find_Center (TRIANGLE T){// variablesPOINT center ;// the math and rest of codecenter.x = (T.x[0] +T.x[1] +T.x[2] )/3;center.y = (T.y[0] +T.y[1] +T.y[2] )/3;center.z = (T.z[0] +T.z[1] +T.z[2] )/3;return center ;}

##### Share on other sites
thank you all. i know how to do it now.
now for a cup of coffee!

As Kent Brockman says:
"ONLY TIME WILL TELL."

##### Share on other sites
The average has some flaws. Imagine a triangle with a very short side, comparatively. The center will be biased towards it.

I would use the center defined by the medians.

Cédric

EDIT: The medians do define a center, do they?

[edited by - Cedric on August 16, 2003 11:25:36 AM]

##### Share on other sites
The medians define the center of gravity, which is computed through the average of the three points.

You can, however, try and use the center of the smallest enclosing circle to get something more towards the middle - although it can happen it''s outside of the triangle.

ToohrVyk

##### Share on other sites
quote:
Original post by ToohrVyk
The medians define the center of gravity, which is computed through the average of the three points.

...

D''oh?

Oh, High School Geometry, where art thou?

##### Share on other sites
The average of the vertices is called a centroid and is the centre (sorry for my non-American spelling) of gravity and is easiest to calculate. There are a couple of other ways of calculating centres (like the intersection of the lines perpindicular from each edge to the opposite vertex or the intersection of the lines that go from the centre of each edge to the opposite vertex), but to calculate those, it would be much more complicated to calculate and would in involve finding the formula of the lines that need to be intersected and then actually calculating the intersection (which is hard enough on paper, never mind solving for the general case and coding it). In short, listen to everyone else if you don''t mind using any definition of a centre of a triangle.

##### Share on other sites
quote:
Original post by clum
or the intersection of the lines that go from the centre of each edge to the opposite vertex

This is precisely the centroid. It''s easy to prove that the intersection of these three lines is actually the average of the vertices (using barycentric relationships).

ToohrVyk

##### Share on other sites
quote:
Original post by ToohrVyk
quote:
Original post by clum
or the intersection of the lines that go from the centre of each edge to the opposite vertex

This is precisely the centroid. It''s easy to prove that the intersection of these three lines is actually the average of the vertices (using barycentric relationships).

ToohrVyk

You''re right. I meant the intersection of the lines that start from the centre of each each and are perpendicular (and don''t hit the opposite vertex).