Find the area between any 3 points by Code Dragon18th Oct 2006 19:38
|
---|
Summary Finds the area of a triangle Description This function will return the area of a triangle. Call it with the coordinates of the points of the triangle. Code ` This code was downloaded from The Game Creators ` It is reproduced here with full permission ` http://www.thegamecreators.com sync on sync rate 30 hide mouse do cls text 0, 0, "Area = " + str$(TriangleArea(0, 0, 300, 200, mousex(), mousey())) line 0, 0, 300, 200 line 300, 200, mousex(), mousey() line mousex(), mousey(), 0, 0 text mousex(), mousey(), str$(mousex()) + ", " + str$(mousey()) sync loop function TriangleArea(x1 as float, y1 as float, x2 as float, y2 as float, x3 as float, y3 as float) local area as float area = abs(x1 * y2 + y1 * x3 + x2 * y3 - y2 * x3 - x1 * y3 - y1 * x2) / 2 endfunction area |