Author Topic: A "new" way of looking at the formula for the area of a triangle  (Read 15881 times)

0 Members and 1 Guest are viewing this topic.

Offline Quigibo

  • The Executioner
  • CoT Emeritus
  • LV11 Super Veteran (Next: 3000)
  • *
  • Posts: 2031
  • Rating: +1075/-24
  • I wish real life had a "Save" and "Load" button...
    • View Profile
Re: A "new" way of looking at the formula for the area of a triangle
« Reply #15 on: January 11, 2011, 08:18:44 pm »
There is a really amazing algorithm for finding the area of ANY closed shape, not just triangles, if you know the coordinates of all the verticies.  For instance, take any pentagon with verticies (X1,Y1) through (X5,Y5).  You can find the area by listing the pairs clockwise and making the first point appear at the end too:

Code: [Select]
X1 Y1
X2 Y2
X3 Y3
X4 Y4
X5 Y5
X1 Y1

Then you multiply diagonally down on each side and find the sums of those 2 columns:

Code: [Select]
       X1 Y1
Y1*X2 / X2 Y2 \ X1*Y2
Y2*X3 / X3 Y3 \ X2*Y3
Y3*X4 / X4 Y4 \ X3*Y4
Y4*X5 / X5 Y5 \ X4*Y5
Y5*X1 / X1 Y1 \ X5*Y1
______         ______
SumLeft        SumRight

The area of the shape is simply the difference of these 2 sums divided by 2:  |SumLeft - SumRight|/2

It even works if the lines pass through each other or the shape has holes in it.

EDIT: Oops, forgot the /2 hehe
« Last Edit: January 11, 2011, 08:27:40 pm by Quigibo »
___Axe_Parser___
Today the calculator, tomorrow the world!

Offline Hot_Dog

  • CoT Emeritus
  • LV12 Extreme Poster (Next: 5000)
  • *
  • Posts: 3006
  • Rating: +445/-10
    • View Profile
Re: A "new" way of looking at the formula for the area of a triangle
« Reply #16 on: January 11, 2011, 08:20:23 pm »
There is a really amazing algorithm for finding the area of ANY closed shape, not just triangles, if you know the coordinates of all the verticies.  For instance, take any pentagon with verticies (X1,Y1) through (X5,Y5).  You can find the area by listing the pairs clockwise and making the first point appear at the end too:

Code: [Select]
X1 Y1
X2 Y2
X3 Y3
X4 Y4
X5 Y5
X1 Y1

Then you multiply diagonally down on each side and find the sums of those 2 columns:

Code: [Select]
        X1 Y1
Y1*X2 / X2 Y2 \ X1*Y2
Y2*X3 / X3 Y3 \ X2*Y3
Y3*X4 / X4 Y4 \ X3*Y4
Y4*X5 / X5 Y5 \ X4*Y5
Y5*X1 / X1 Y1 \ X5*Y1
______         ______
SumLeft        SumRight

The area of the shape is simply the difference of these 2 sums:  |SumLeft - SumRight|

It even works if the lines pass through each other or the shape has holes in it.

Ah yes, I could be wrong, but I think I recall something like that done to find an approximate value for Pi

Offline apcalc

  • The Game
  • CoT Emeritus
  • LV10 31337 u53r (Next: 2000)
  • *
  • Posts: 1393
  • Rating: +120/-2
  • VGhlIEdhbWUh (Base 64 :))
    • View Profile
Re: A "new" way of looking at the formula for the area of a triangle
« Reply #17 on: January 11, 2011, 08:22:30 pm »
There is a really amazing algorithm for finding the area of ANY closed shape, not just triangles, if you know the coordinates of all the verticies.  For instance, take any pentagon with verticies (X1,Y1) through (X5,Y5).  You can find the area by listing the pairs clockwise and making the first point appear at the end too:

Code: [Select]
X1 Y1
X2 Y2
X3 Y3
X4 Y4
X5 Y5
X1 Y1

Then you multiply diagonally down on each side and find the sums of those 2 columns:

Code: [Select]
        X1 Y1
Y1*X2 / X2 Y2 \ X1*Y2
Y2*X3 / X3 Y3 \ X2*Y3
Y3*X4 / X4 Y4 \ X3*Y4
Y4*X5 / X5 Y5 \ X4*Y5
Y5*X1 / X1 Y1 \ X5*Y1
______         ______
SumLeft        SumRight

The area of the shape is simply the difference of these 2 sums:  |SumLeft - SumRight|

It even works if the lines pass through each other or the shape has holes in it.

That is the Shoelace formula I was talking about earlier! :D
After writing that post, I made a nice Java program to do that formula for you!

Ah yes, I could be wrong, but I think I recall something like that done to find an approximate value for Pi

Do you mean when they used shapes like a regular 100-gon, found the area of that, and used that to estimate Pi?
« Last Edit: January 11, 2011, 08:23:55 pm by apcalc »


Offline squidgetx

  • Food.
  • CoT Emeritus
  • LV10 31337 u53r (Next: 2000)
  • *
  • Posts: 1881
  • Rating: +503/-17
  • rawr.
    • View Profile
Re: A "new" way of looking at the formula for the area of a triangle
« Reply #18 on: January 11, 2011, 08:23:01 pm »
« Last Edit: January 11, 2011, 08:23:11 pm by squidgetx »

Offline Michael_Lee

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1019
  • Rating: +124/-9
    • View Profile
Re: A "new" way of looking at the formula for the area of a triangle
« Reply #19 on: January 11, 2011, 08:25:46 pm »
There is a really amazing algorithm for finding the area of ANY closed shape, not just triangles, if you know the coordinates of all the verticies.  For instance, take any pentagon with verticies (X1,Y1) through (X5,Y5).  You can find the area by listing the pairs clockwise and making the first point appear at the end too:

Code: [Select]
X1 Y1
X2 Y2
X3 Y3
X4 Y4
X5 Y5
X1 Y1

Then you multiply diagonally down on each side and find the sums of those 2 columns:

Code: [Select]
        X1 Y1
Y1*X2 / X2 Y2 \ X1*Y2
Y2*X3 / X3 Y3 \ X2*Y3
Y3*X4 / X4 Y4 \ X3*Y4
Y4*X5 / X5 Y5 \ X4*Y5
Y5*X1 / X1 Y1 \ X5*Y1
______         ______
SumLeft        SumRight

The area of the shape is simply the difference of these 2 sums:  |SumLeft - SumRight|

It even works if the lines pass through each other or the shape has holes in it.

o.o That is awesome!
* Michael_Lee memorizes
My website: Currently boring.

Projects:
Axe Interpreter
   > Core: Done
   > Memory: Need write code to add constants.
   > Graphics: Rewritten.  Needs to integrate sprites with constants.
   > IO: GetKey done.  Need to add mostly homescreen IO stuff.
Croquette:
   > Stomping bugs
   > Internet version: On hold until I can make my website less boring/broken.

Offline Happybobjr

  • James Oldiges
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2325
  • Rating: +128/-20
  • Howdy :)
    • View Profile
Re: A "new" way of looking at the formula for the area of a triangle
« Reply #20 on: January 11, 2011, 08:41:49 pm »
I smell first place in academic team this year with this.
thank you so much.
« Last Edit: January 11, 2011, 08:49:43 pm by happybobjr »
School: East Central High School
 
Axe: 1.0.0
TI-84 +SE  ||| OS: 2.53 MP (patched) ||| Version: "M"
TI-Nspire    |||  Lent out, and never returned
____________________________________________________________

Offline fb39ca4

  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1749
  • Rating: +60/-3
    • View Profile
Re: A "new" way of looking at the formula for the area of a triangle
« Reply #21 on: January 12, 2011, 12:09:04 am »
I see why its called the shoelace algorithm. How would you list the points for a shape with a hole?

Offline Happybobjr

  • James Oldiges
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2325
  • Rating: +128/-20
  • Howdy :)
    • View Profile
Re: A "new" way of looking at the formula for the area of a triangle
« Reply #22 on: January 12, 2011, 11:31:03 am »
I assumed you just did the two shapes and subtracted them.
School: East Central High School
 
Axe: 1.0.0
TI-84 +SE  ||| OS: 2.53 MP (patched) ||| Version: "M"
TI-Nspire    |||  Lent out, and never returned
____________________________________________________________

Offline fb39ca4

  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1749
  • Rating: +60/-3
    • View Profile
Re: A "new" way of looking at the formula for the area of a triangle
« Reply #23 on: January 13, 2011, 05:31:03 pm »
Oh, I knew that. :P

i am a troll

  • Guest
Re: A "new" way of looking at the formula for the area of a triangle
« Reply #24 on: January 19, 2011, 12:15:35 am »
Or, use Hero's formula:
Area = the square root of ( s (s-a) (s-b) (s-c) ) when a, b, and c are the three sides and s is the semi-perimeter ( 1/2(a+b+c) )
There's also a formula for cyclic quadrilaterals: area=sqrt(s-a)(s-b)(s-c)(s-d) where s=(a+b+c+d)/2 and a,b,c, and d are the side lengths of the cyclic quadrilateral.

Offline Xeda112358

  • they/them
  • Moderator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 4704
  • Rating: +719/-6
  • Calc-u-lator, do doo doo do do do.
    • View Profile
Re: A "new" way of looking at the formula for the area of a triangle
« Reply #25 on: January 19, 2011, 12:18:13 am »
Jeez, that's just out of my league...

Offline phenomist

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 132
  • Rating: +46/-3
    • View Profile
Re: A "new" way of looking at the formula for the area of a triangle
« Reply #26 on: January 30, 2011, 03:34:18 am »
Or, use Hero's formula:
Area = the square root of ( s (s-a) (s-b) (s-c) ) when a, b, and c are the three sides and s is the semi-perimeter ( 1/2(a+b+c) )
There's also a formula for cyclic quadrilaterals: area=sqrt(s-a)(s-b)(s-c)(s-d) where s=(a+b+c+d)/2 and a,b,c, and d are the side lengths of the cyclic quadrilateral.
That's Brahmagupta's Theorem

BTW, for shoelace you need to divide by 1/2; it's a common mistake to forget that.

Shoelace can also be considered the determinant of the following matrix:
[[1 1 1 ... 1 x1 y1]
[1 1 1 ... 1 x2 y2]
[1 1 1 ... 1 x3 y3]
...
[1 1 1 ... 1 xn yn]]
One half the absolute value of the determinant = area.

This is probably really useless, but if you know the circumradius (radius of circle passing through three points of the triangle) and the sidelengths, then the area is (abc)/4R.

If you have a lot of time to waste, and you know that all vertices are on lattice points (integer coordinates), then use Pick's theorem! Count up the number of interior points and then the boundary points; the area is I+B/2-1.
Level Designer for Graviter

[Disclaimer: I can't program for my life.]