Centres - returns centres of a 2d triangle

Post your working scripts, libraries and tools
User avatar
Avi
Posts: 192
Joined: 30 Sep 2013, 09:51
Facebook: avi.aryan.ap
Google: +AviAryan
GitHub: aviaryan
Location: India
Contact:

Centres - returns centres of a 2d triangle

28 Dec 2013, 07:59

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

Code: [Select all] [Expand] [Download] (Script.ahk)GeSHi © Codebox Plus




PERMANENTLY STORED AT-
GITHUB
Raw Direct Download link
Clipjump Clipboard Manager : More Scripts

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

Re: Centres - returns centres of a 2d triangle

28 Dec 2013, 10:34

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

28 Dec 2013, 12:33

I'm very sure it's the centroid...
"Nothing is quieter than a loaded gun." - Heinrich Heine
User avatar
Avi
Posts: 192
Joined: 30 Sep 2013, 09:51
Facebook: avi.aryan.ap
Google: +AviAryan
GitHub: aviaryan
Location: India
Contact:

Re: Centres - returns centres of a 2d triangle

29 Dec 2013, 08:49

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

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

Re: Centres - returns centres of a 2d triangle

29 Dec 2013, 13:20

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

Return to “Scripts and Functions”

Who is online

Users browsing this forum: No registered users and 8 guests