
-----------------------------------
Danjen
Sat Jan 06, 2007 2:21 am

I need help with a Math problem
-----------------------------------
Okay, so what I'm trying to do is have three dots that can rotate on a circle, with a line drawn between them, forming a triangle inside the circle. What I need to figure out is a formula for calculating the percent of the circle that the triangle takes up. So like, when the points are at any given position on the circle, the formed triangle will take up X% of that circle.

-----------------------------------
ericfourfour
Sat Jan 06, 2007 4:09 am


-----------------------------------
Area of triangle / Area of Circle * 100

To calculate the area of a triangle the formula (I think) is:
Area of Triangle = abs (x1 * y3 + x2 * y1 + x3 * y2 - x3 * y1 - x1 * y2 - x2 * y3)

-----------------------------------
BenLi
Sat Jan 06, 2007 1:13 pm


-----------------------------------
ever heard of (down product - up product) divided by 2?

-----------------------------------
BenLi
Sat Jan 06, 2007 1:14 pm


-----------------------------------
btw, that works for any polygon in which any point can be connected to any other point with an uninterrupted line.

-----------------------------------
neufelni
Sat Jan 06, 2007 1:39 pm


-----------------------------------
The Formula for area of a triangle is A = (b * h) / 2.
So in Turing that would be:
area := (x2 - x1) * (y3 - y2) / 2

And the area of a circle is A = pi r ** 2.

And then you just use the formula ericfourfour gave:
Area of triangle / Area of Circle * 100

-----------------------------------
ericfourfour
Sat Jan 06, 2007 5:53 pm


-----------------------------------
Nick try using that formula with this triangle:
A(0, 0), B(10, 5), C (5, 10)

-----------------------------------
BenLi
Mon Jan 08, 2007 8:53 am

RE:I need help with a Math problem
-----------------------------------
Okay, if you use the (abs(down product - up product)) divided by 2, you don't have to find the height and the base and stuff

-----------------------------------
Danjen
Mon Jan 08, 2007 9:29 am

Re: I need help with a Math problem
-----------------------------------
Ok, that works. But what's with down product and up product?

-----------------------------------
BenLi
Mon Jan 08, 2007 12:55 pm

Re: I need help with a Math problem
-----------------------------------
its hard to explain but in a nutshell:

1. List numbers on the polygon in a counterclockwise fashion repeating one point
2. Downproduct is the sum of all the numbers in the first column multiplied by those in the second column one row down.
3. Upproduct is the sum of all the numbers in the first column multiplied by those in the second column one row up.
4. Follow the formula abs(dp - up) / 2

Note: the abs is just an extra, done properly, you could omit the abs.

-----------------------------------
Danjen
Mon Jan 08, 2007 1:09 pm

Re: I need help with a Math problem
-----------------------------------
Well you explained it in a coherent manner, so I'm pretty sure I get it . :)
