Archived

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

Jallen

Center of a triangle

Recommended Posts

Hi, Anyone know of a quick way to find the center of an arbitrary triangle? Thanks, Jason A. --- I write code. DelphiGL (http://delphigl.cfxweb.net)

Share this post


Link to post
Share on other sites
There are many different types of center...

The center of gravity of the entire triangle?
It''s at the point where the three lines joining corners to the midpoints of their opposite sides meet.

The center of gravity of the three corners?
It''s at the point where the three angular bisectors meet.

The orthocenter?
It''s at the point where the lines from the corners cast perpendicularly to the opposite sides all meet.

The circumcenter?
It''s at the point where the three perpendicular bisectors of the sides all meet.

The incenter?
I''m not entirely sure, to be honest. It might be one of the first two, but don''t bet on it.

Share this post


Link to post
Share on other sites
Whichever is fastest/easiest to calculate. I just want the rough center of the triangle, its just for looks.

Jason A.

---
I write code.
DelphiGL (http://delphigl.cfxweb.net)

Share this post


Link to post
Share on other sites
i have no idea what this does, nor do i know if it''s the fastest or best routine, but i just average the points. i don''t know what consequences this issues, because i haven''t run into any problems yet. like this:

(this is fairly pseudo, so please don''t criticize on the syntax)
(but go ahead and criticize the algorithm, cuz i''m sure it''s not the best way to do anything.)

int numpoints = 3; //3 vertices
int x = 0;
int y = 0;
int z = 0;
for(int i = 0; i < numpoints; i++)
{
x += point.x;
y += point[i].y;
z += point[i].z;
}

x /= numpoints;
y /= numpoints;
z /= numpoints;

a2k

Share this post


Link to post
Share on other sites