## The Centers of a Triangle

**Moderators:** Zomis, Flumminator

### The Centers of a Triangle

Hi all,

I am back with another toy program.

I was improving the "Koch's snowflake" program, to show something very nice - building the snowflake as a bunch of triangles and then rotating them a bit results in a very nice image - but then I asked myself: how can I compute the center of an arbitrary triangle? Searching the web I have found Jim Loy's geometry pages, which inspired me the following program:

http://www.zomis.net/rnd/download.php?id=660

Developing this program has been very instructive and very fun - I recall Holger's words of some months ago

Again, for what is worth, enjoy this program.

I am back with another toy program.

I was improving the "Koch's snowflake" program, to show something very nice - building the snowflake as a bunch of triangles and then rotating them a bit results in a very nice image - but then I asked myself: how can I compute the center of an arbitrary triangle? Searching the web I have found Jim Loy's geometry pages, which inspired me the following program:

http://www.zomis.net/rnd/download.php?id=660

Developing this program has been very instructive and very fun - I recall Holger's words of some months ago

Again, for what is worth, enjoy this program.

*Anyway, by the way, have fun!*

Francesco

At first I thought that the triangle wasn't moveable, but after a while I found out that it actually was moveable

I gotta say that I have no clue about how to calculate some of those things, and honestly I don't know what to use all those things for. Do you have a link to those geometry pages? They sound interesting

I am glad you liked it, Zomis.

Those pages can be found at www.jimloy.com , just as stated in the program info (I should have publicized better the "TAB - Program information" button ).

Well, in the way they are shown in that program, they are just a delight for the eye - for those eyes who like maths and alike - but just like any math, the nicest part is that all of them have some useful aspect. For example, the Fermat's point is the point where the sum of distances towards the three corners is minimal.

In practice, it represents the best point to connect three towns (or three houses, as well) using the minimum amount of material - electricity wires, telephony cables, water pipes and so forth.

If someone plans to use that information, I'll say here that the point can be found building two equilaterals on two sides of the triangle (they have to be built towards the outside) - the Fermat's point is the intersection between the two lines connecting the fartest corners of these equilaterals to the relative corners on the opposite side of the given triangle - just like shown in my program. It is not necessary to calculate the third equilateral - the resulting line will pass through the Fermat's point in any case.

I'll add also that if the given triangle is

To make the program a bit more useful, I could allow the user to specify and see the coordinates of the three points of the triangle, as well as the coordinates and the sizes of the various entities shown in the program, but once again, the biggest problem is realizing such things with C++ and put them on the screen in a good way - now I can perfectly understand the hassle when it comes to widgets, coordinates and so on... it isn't that hard, but it's extremely boring...

Those pages can be found at www.jimloy.com , just as stated in the program info (I should have publicized better the "TAB - Program information" button ).

Well, in the way they are shown in that program, they are just a delight for the eye - for those eyes who like maths and alike - but just like any math, the nicest part is that all of them have some useful aspect. For example, the Fermat's point is the point where the sum of distances towards the three corners is minimal.

In practice, it represents the best point to connect three towns (or three houses, as well) using the minimum amount of material - electricity wires, telephony cables, water pipes and so forth.

If someone plans to use that information, I'll say here that the point can be found building two equilaterals on two sides of the triangle (they have to be built towards the outside) - the Fermat's point is the intersection between the two lines connecting the fartest corners of these equilaterals to the relative corners on the opposite side of the given triangle - just like shown in my program. It is not necessary to calculate the third equilateral - the resulting line will pass through the Fermat's point in any case.

I'll add also that if the given triangle is

*not*acute - that is, if there is an obtuse angle at one corner - then the best point is not the Fermat's point, but the point on the corner with the obtuse angle. [edit: wrong, the point is valid even for an obtuse triangle, as long as the obtuse angle is not wider than 120°, see Jannik's note below - at least it wasn't my fault ]To make the program a bit more useful, I could allow the user to specify and see the coordinates of the three points of the triangle, as well as the coordinates and the sizes of the various entities shown in the program, but once again, the biggest problem is realizing such things with C++ and put them on the screen in a good way - now I can perfectly understand the hassle when it comes to widgets, coordinates and so on... it isn't that hard, but it's extremely boring...

Last edited by Francesco on Mon Jun 11, 2007 2:38 pm, edited 1 time in total.

*Anyway, by the way, have fun!*

Francesco

Especially the real-time movability is funny!

Jim Loy's Mathematics Page is really interesting ... I wished I had found this fascination of maths in my school time ...

If one angle of the triangle is 120° or bigger, the Fermat's point will be outside the triangle and the point, where the sum of distances towards the three corners is minimal, will be the corner of the triangle with the big angle.For example, the Fermat's point is the point where the sum of distances towards the three corners is minimal.

Thank you Jannik, I am happy you liked my program.

About the 120° thing, you're right - I have checked it measuring the sum in my program.

In fact, an angle should be considered obtuse if it's wider than 90°, so my definition is not correct. Well, it is not

[edit: definitely this is the case, I was wrong just like Wolfram's website, I am about to send an e-mail to point this out]

About the 120° thing, you're right - I have checked it measuring the sum in my program.

In fact, an angle should be considered obtuse if it's wider than 90°, so my definition is not correct. Well, it is not

*my*definition, I have just reported the words of Wolfram's math pages... now the problem is whether the words "obtuse" and "acute" mean something different when applied to a triangle instead that to a single angle... I'll have to check it out - eventually we'll have to point this out to Wolfram's website[edit: definitely this is the case, I was wrong just like Wolfram's website, I am about to send an e-mail to point this out]

*Anyway, by the way, have fun!*

Francesco

Well, thinking better... I have my part of fault. The Wolfram's page about the Fermat's point states

I have wrongly deduced that - but that page is incomplete, as a minimum

Could the Wolfram website's team forgive me - that site is great!

It doesn't state that the point is not valid for an obtuse triangle.In a given acute triangle ABC, the first Fermat point X [...] is the point X which minimizes the sum of distances from A, B, and C

I have wrongly deduced that - but that page is incomplete, as a minimum

Could the Wolfram website's team forgive me - that site is great!

*Anyway, by the way, have fun!*

Francesco

But Jim Loy's page completely misses the angle issue, so if you still want to write an email, Francesco ...

Currently, I wonder, if a triangle would be completely defined by only Circum- and Orthocenter. These would easily lead to the Centroid and Nine Points Center. And there are so many relations ... and just 6 unkown variables (ax, ay, bx, by, cx, cy) ... in other words, are there two different triangles with the same (directed) Euler's line?

I just discovered by accident, that you can even change the colours of the dots, lines and circles ...

I did some calculations to answer my question in my last post. Now I have 4 equations and 4 unknown variables. I hope these equations are independent, then it should be solvable ...

known:

Circumcenter D=(DX/DY)=(D1/D2)

Orthocenter O=(OX/OY)=(O1/O2)

unkown:

2 points of triangle: B1, B2, C1, C2

(A1 and A2 are then easy to compute)

4 equations:

O1=B1+((2*D2+O2-B2-C2)-C2)*((C2-B2)*(B2-(2*D2+O2-B2-C2))-(B1-(2*D1+O1-B1-C1))*(B1-C1))/(((2*D2+O2-B2-C2)-C2)*(B1-C1)-(C1-(2*D1+O1-B1-C1))*(C2-B2))

O2=B2+(C1-(2*D1+O1-B1-C1))*((C2-B2)*(B2-(2*D2+O2-B2-C2))-(B1-(2*D1+O1-B1-C1))*(B1-C1))/(((2*D2+O2-B2-C2)-C2)*(B1-C1)-(C1-(2*D1+O1-B1-C1))*(C2-B2))

D1=((2*D1+O1-B1-C1)+C1)/2+(((2*D2+O2-B2-C2)-C2)*(((2*D2+O2-B2-C2)-B2)*(C2-B2)-((2*D1+O1-B1-C1)-B1)*(B1-C1)))/(2*((B1-C1)*((2*D2+O2-B2-C2)-C2)-(C1-(2*D1+O1-B1-C1))*(C2-B2)))

D2=((2*D2+O2-B2-C2)+C2)/2+((C1-(2*D1+O1-B1-C1))*(((2*D2+O2-B2-C2)-B2)*(C2-B2)-((2*D1+O1-B1-C1)-B1)*(B1-C1)))/(2*((B1-C1)*((2*D2+O2-B2-C2)-C2)-(C1-(2*D1+O1-B1-C1))*(C2-B2)))

Is anybody here who wants to solve them to B1, B2, C1 and C2? I'm a little bit lazy right now ...

That would make the program really perfect!To make the program a bit more useful, I could allow the user to specify and see the coordinates of the three points of the triangle, as well as the coordinates and the sizes of the various entities shown in the program

I did some calculations to answer my question in my last post. Now I have 4 equations and 4 unknown variables. I hope these equations are independent, then it should be solvable ...

known:

Circumcenter D=(DX/DY)=(D1/D2)

Orthocenter O=(OX/OY)=(O1/O2)

unkown:

2 points of triangle: B1, B2, C1, C2

(A1 and A2 are then easy to compute)

4 equations:

O1=B1+((2*D2+O2-B2-C2)-C2)*((C2-B2)*(B2-(2*D2+O2-B2-C2))-(B1-(2*D1+O1-B1-C1))*(B1-C1))/(((2*D2+O2-B2-C2)-C2)*(B1-C1)-(C1-(2*D1+O1-B1-C1))*(C2-B2))

O2=B2+(C1-(2*D1+O1-B1-C1))*((C2-B2)*(B2-(2*D2+O2-B2-C2))-(B1-(2*D1+O1-B1-C1))*(B1-C1))/(((2*D2+O2-B2-C2)-C2)*(B1-C1)-(C1-(2*D1+O1-B1-C1))*(C2-B2))

D1=((2*D1+O1-B1-C1)+C1)/2+(((2*D2+O2-B2-C2)-C2)*(((2*D2+O2-B2-C2)-B2)*(C2-B2)-((2*D1+O1-B1-C1)-B1)*(B1-C1)))/(2*((B1-C1)*((2*D2+O2-B2-C2)-C2)-(C1-(2*D1+O1-B1-C1))*(C2-B2)))

D2=((2*D2+O2-B2-C2)+C2)/2+((C1-(2*D1+O1-B1-C1))*(((2*D2+O2-B2-C2)-B2)*(C2-B2)-((2*D1+O1-B1-C1)-B1)*(B1-C1)))/(2*((B1-C1)*((2*D2+O2-B2-C2)-C2)-(C1-(2*D1+O1-B1-C1))*(C2-B2)))

Is anybody here who wants to solve them to B1, B2, C1 and C2? I'm a little bit lazy right now ...

Last edited by Jannik on Sun Jun 17, 2007 5:31 am, edited 1 time in total.

Yes, that page on Jim Loy's website misses completely that issue - but Jim's website has also lower claims

About your equations... I must admit that I am not so used to resolving such things, I prefer to look up the answers from the web

I am adding the coords to the program.

About your equations... I must admit that I am not so used to resolving such things, I prefer to look up the answers from the web

I am adding the coords to the program.

*Anyway, by the way, have fun!*

Francesco

My equations aren't linear, so it's really hard to solve them. Maybe with numerical analysis, but these are often erroneous or misleading ...

I transformed the first equation to a quadratic equation of B1:

0=B1^2*(-2*D2-O2+C2+2*B2)+B1*(-2*D2*C1-O2*C1+B2*C1+2*C2*C1-2*C1*C2+2*D1*C2+O1*C2+2*C1*B2-2*D1*B2-O1*B2-2*D2*O1-O1*O2+O1*B2+2*O1*C2+C2*O1-O1*B2+4*D1*D2+2*D2*O1+2*D2*C1+2*D1*O2+O1*O2+O2*C1-2*D1*B2-O1*B2-C1*B2-4*D1*C2-2*O1*C2-2*C1*C2)-O1*(-2*D2*C1-O2*C1+B2*C1+2*C2*C1-2*C1*C2+2*D1*C2+O1*C2+2*C1*B2-2*D1*B2-O1*B2)+(2*D2+O2-B2-2*C2)*(2*B2*C2-2*D2*C2-O2*C2+C2^2-2*B2^2+2*D2*B2+O2*B2-C2*B2-2*D1*C1-O1*C1+C1^2)

You could put these two possible solutions into equations 2-4, so you would have only 3 equations with 3 unkown variables ... but these equations would be really cruel ...

By the way, here are my formulas for Centroid T, Orthocenter O, Circumcenter D I used above:

T1=(A1+B1+C1)/3

T2=(A2+B2+C2)/3

O1=B1+(A2-C2)*((C2-B2)*(B2-A2)-(B1-A1)*(B1-C1))/((A2-C2)*(B1-C1)-(C1-A1)*(C2-B2))

O2=B2+(C1-A1)*((C2-B2)*(B2-A2)-(B1-A1)*(B1-C1))/((A2-C2)*(B1-C1)-(C1-A1)*(C2-B2))

D1=(A1+C1)/2+((A2-C2)*((A2-B2)*(C2-B2)-(A1-B1)*(B1-C1)))/(2*((B1-C1)*(A2-C2)-(C1-A1)*(C2-B2)))

D2=(A2+C2)/2+((C1-A1)*((A2-B2)*(C2-B2)-(A1-B1)*(B1-C1)))/(2*((B1-C1)*(A2-C2)-(C1-A1)*(C2-B2)))