I dont even have a clue, any tips how to begin?????
I need to find an area of a triangle.
User inputs x and y for Side A, B, C.
I know how to do with just sides AB and C but how do I do it with xy for each point ABC.
Lost
Printable View
I dont even have a clue, any tips how to begin?????
I need to find an area of a triangle.
User inputs x and y for Side A, B, C.
I know how to do with just sides AB and C but how do I do it with xy for each point ABC.
Lost
create a function that uses the distance formula
distance = sqrt(((x2-x1)*(x2-x1))+((y2-y1)*(y2-f1)))
I think this is correct.
a = b * h / 2
/|\
/ | \
B / | \ C
/ |h \
/ | \
‾‾‾‾‾‾‾‾‾‾
A(b)
ah, crap
a = b * h / 2
********** /|\
********* /* | \
*******B /**| *\ C
********/** |h* \
*******/*** |*** \
*******‾‾‾‾‾‾‾‾‾‾
**********A(b)
(sorry, its messy, i know)
The height will be the difference of the 2 most extreme y coordinates, and the base will be the difference of the 2 most extreme x coordinates.
area = (base/2) * height
ok, i worked out the code. Had to go with govtcheese's formula.
But everything works now except answer comes as something like a hexadecimal number.
Area = 1.04635e+34, it should say 7. Any clues.????? it is a float.
That's not a hex number - that's a huge number.
Show your code - you must have done something wrong.
here is function code
float area(Point& A, Point& B, Point& C)
{
int x2 = B.GetX() - A.GetX();
int x3 = C.GetX() - A.GetX();
int y3 = C.GetX() - A.GetX();
int y2 = B.GetX() - A.GetX();
return sqrt((x2*3) - (y3*y2)/2.0);
}
Does this help??
> Does this help??
Not at all....
What's "Point"?
Where the hell did that formula come from?
Why are you only saying GetX?
point comes from the class........sorry for wasting your time, but I worked it out. How embarrassing I forgot to include <cmath> for sqrt.
anyway thanks for the area help.