Getting triangle height

Share your advanced PureBasic knowledge/code with the community.
User avatar
Psychophanta
Addict
Addict
Posts: 4997
Joined: Wed Jun 11, 2003 9:33 pm
Location: Lípetsk, Russian Federation
Contact:

Getting triangle height

Post by Psychophanta »

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. :o

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
http://www.zeitgeistmovie.com

While world=business:world+mafia:Wend
Will never leave this forum until the absolute bugfree PB :mrgreen: