Author |
Message |
Danjen
|
Posted: Sat Jan 06, 2007 2:21 am Post subject: 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. |
|
|
|
|
|
Sponsor Sponsor
|
|
|
ericfourfour
|
Posted: Sat Jan 06, 2007 4:09 am Post subject: (No subject) |
|
|
Area of triangle / Area of Circle * 100
To calculate the area of a triangle the formula (I think) is:
code: | Area of Triangle = abs (x1 * y3 + x2 * y1 + x3 * y2 - x3 * y1 - x1 * y2 - x2 * y3) |
|
|
|
|
|
|
BenLi
|
Posted: Sat Jan 06, 2007 1:13 pm Post subject: (No subject) |
|
|
ever heard of (down product - up product) divided by 2? |
|
|
|
|
|
BenLi
|
Posted: Sat Jan 06, 2007 1:14 pm Post subject: (No subject) |
|
|
btw, that works for any polygon in which any point can be connected to any other point with an uninterrupted line. |
|
|
|
|
|
neufelni
|
Posted: Sat Jan 06, 2007 1:39 pm Post subject: (No subject) |
|
|
The Formula for area of a triangle is A = (b * h) / 2.
So in Turing that would be:
code: | 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
|
Posted: Sat Jan 06, 2007 5:53 pm Post subject: (No subject) |
|
|
Nick try using that formula with this triangle:
code: | A(0, 0), B(10, 5), C (5, 10) |
|
|
|
|
|
|
BenLi
|
Posted: Mon Jan 08, 2007 8:53 am Post subject: 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
|
Posted: Mon Jan 08, 2007 9:29 am Post subject: Re: I need help with a Math problem |
|
|
Ok, that works. But what's with down product and up product? |
|
|
|
|
|
Sponsor Sponsor
|
|
|
BenLi
|
Posted: Mon Jan 08, 2007 12:55 pm Post subject: 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
|
Posted: Mon Jan 08, 2007 1:09 pm Post subject: Re: I need help with a Math problem |
|
|
Well you explained it in a coherent manner, so I'm pretty sure I get it . |
|
|
|
|
|
|