I have classes of point,line and vector and i have to find area of triangle. anybody can help me.

IIRC, area of triangle = (0.5 * base) * height; dunno what is defined in your classes though... -------------------------------------------

I have no aspiration for preaching. ;-)

I have Point class with members as double x,y,z; and line have Point sp1,sp2; except this i do't have anything in my class

For area plotted as points on a graph, you can try the determinant. Not really tested as it's been a long time since I did any of this type of stuff. typedef struct { double x; double y; } vector; double findDet(vector *v1, vector *v2, vector *v3) { double tmp = ((v1->x * pow(-1, 2)) * ((v2->y * 1) - (v3->y * 1))) + ((v1->y * pow(-1, 3)) * ((v2->x * 1) - (v3->x * 1))) + pow(-1, 4) * ((v2->x * v3->y) - (v3->x * v2->y)); return (tmp != 0 ? (tmp < 0 ? tmp * -1 : tmp) : 0); } ... vector pt1, pt2, pt3; // assign values first double area = 0.5 * findDet(&pt1, &pt2, &pt3);note that this is C and not CPP; "vector" should not be confused with cpp's vector class. I don't care much for cpp and seldom use it. :P In all honesty, I don't remember how to manipulate an object in space... that is, the z-plane. I've forgotten most of that stuff now.

Good luck. :)

-------------------------------------------

I have no aspiration for preaching. ;-)

Ask Your Question

Weekly Poll

Do you think manufacturers should do more to reduce phone and tablet usage among kids?

Discuss in The Lounge

Poll History