Getting triangle height
Posted: Mon Nov 01, 2004 11:34 pm
Code updated For 5.20+
A tip to show math formula to get the height of any 2D triangle knowing the rectangular 2D coordenates of its vertex.
BTW, the formula could be added in Mathematical formulas in PBhelp,
because it is not easy to found it in the web.
A tip to show math formula to get the height of any 2D triangle knowing the rectangular 2D coordenates of its vertex.
BTW, the formula could be added in Mathematical formulas in PBhelp,
because it is not easy to found it in the web.

Code: Select all
Procedure.f TriangleHeight2D(x0.f,y0.f,x1.f,y1.f,x2.f,y2.f)
ProcedureReturn ((x0-x1)*(y1-y2)+(y0-y1)*(x2-x1))/Sqr(Pow(x2-x1,2)+Pow(y1-y2,2));Note that points (x1,y1) and (x2,y2) are the base of the triangle
EndProcedure