Difference between revisions of "InTriangle"

From SCAR Divi Manual
Jump to: navigation, search
 
Line 1: Line 1:
 
==Definition==
 
==Definition==
 
<source lang="scar" lines="false">
 
<source lang="scar" lines="false">
function InTriangle(const x, y, x1, y1, x2, y2, x3, y3: Integer): Boolean;
+
function InTriangle(const X, Y, X1, Y1, X2, Y2, X3, Y3: Integer): Boolean;
 
</source>
 
</source>
  
Line 8: Line 8:
  
 
==Description==
 
==Description==
This function determines whether a coordinate specified by ('''x''', '''y''') can be found inside of the [http://en.wikipedia.org/wiki/Triangle triangle] specified by the points ('''x1''', '''y1'''), ('''x2''', '''y2''') and ('''x3''', '''y3'''). If the coordinate is outside or on top of the triangle, [[False]] is returned.
+
This function determines whether a coordinate specified by ('''X''', '''Y''') can be found inside of the [http://en.wikipedia.org/wiki/Triangle triangle] specified by the points ('''X1''', '''Y1'''), ('''X2''', '''Y2''') and ('''X3''', '''Y3'''). If the coordinate is outside or on top of the triangle, [[False]] is returned.
  
 
==Example==
 
==Example==

Latest revision as of 16:14, 9 July 2012

Definition

function InTriangle(const X, Y, X1, Y1, X2, Y2, X3, Y3: Integer): Boolean;

Availability

SCAR Divi 3.00 > Current

Description

This function determines whether a coordinate specified by (X, Y) can be found inside of the triangle specified by the points (X1, Y1), (X2, Y2) and (X3, Y3). If the coordinate is outside or on top of the triangle, False is returned.

Example

begin
  if InTriangle(2, 2, 1, 1, 0, 3, 6, 3) then
    WriteLn('The point can be found in the triangle')
  else
    WriteLn('The point is outside or on top of the triangle');
end.

Output:

The point can be found in the triangle

See Also