## Centres - returns centres of a 2d triangle

Post your working scripts, libraries and tools
Avi
Posts: 193
Joined: 30 Sep 2013, 09:51
GitHub: aviaryan
Location: India
Contact:

### Centres - returns centres of a 2d triangle

Centres is a little function that returns Incentre, Orthocentre, Centroid or Circumcentre of a given 2d triangle.
It can also return Euler line's equation for a triangle.

someone @ stack overflow wrote:The incenter is the intersection of the angle bisectors of the triangle. The centroid is the intersection of the lines from each vertex of the triangle to the middle of its opposite side. The circumcenter is the intersection of the perpendicular bisectors of the sides. The orthocenter is the intersection of the altitudes of the triangle.

Euler later proved that the centroid, circumcenter and orthocenter are collinear in any triangle. The line that these three points are on in a triangle is called the Euler Line. It is defined for every triangle except an equilateral triangle, where all the points coincide.

EXAMPLE

PERMANENTLY STORED AT-
GITHUB
Clipjump Clipboard Manager : More Scripts

Morpheus
Posts: 119
Joined: 04 Oct 2013, 05:09

### Re: Centres - returns centres of a 2d triangle

Just out of curiosity, assuming that mass is distributed equally across the surface of the triangle, which of the above centers (If any) would be the center of gravity?
Alibaba
Posts: 427
Joined: 29 Sep 2013, 16:15
Location: Germany

### Re: Centres - returns centres of a 2d triangle

I'm very sure it's the centroid...
"Nothing is quieter than a loaded gun." - Heinrich Heine
Avi
Posts: 193
Joined: 30 Sep 2013, 09:51
GitHub: aviaryan
Location: India
Contact:

### Re: Centres - returns centres of a 2d triangle

It's not orthocentre and circumcentre as they are present at a vertex and side respectively in a right-angled triangle.
I am confused between incentre and centroid as both look to be candidates for C.O.M location when tested with few simple triangles (equilateral, isoceles, right-angled) . There should be proof with integration.

@Alibaba_ any reason why you are sure ?
Clipjump Clipboard Manager : More Scripts

strobo
Posts: 125
Joined: 30 Sep 2013, 15:24

### Re: Centres - returns centres of a 2d triangle

One can parametrize
f(t, s) := a+(b-a)t+(c-b)s , for 0 <= t <= 1 and 0 <= s <= t
where a, b, c are the vertices of the triangle. If the triangle has nonvanishing 2 dimensional Volume, i.e. det(b-a, c-b) != 0, one can use f(t, s) to integrate over the triangle.
(1/Volume)*\int_0^1 dt \int_0^t ds |det(Df)|*f(t, s) == (a+b+c)/3
which is the center of mass (in case it is distributed as Morpheus said).