Programmer Guide/Command Reference/EVAL/pgitest: Difference between revisions

From STX Wiki
Jump to navigationJump to search
No edit summary
Line 1: Line 1:
{{DISPLAYTITLE:{{SUBPAGENAME}}}}
{{DISPLAYTITLE:{{SUBPAGENAME}}}}
=====pgitest - detect point in polygon=====
Check the relation (outside, inside, overlap) of a given point, line or simple polygon ''p'' to the polygon ''x''.
----
;Usage 1:
:<code>pgitest(<var>X</var>, <var>IX</var>, <var>PX<sub>scalar</sub></var>, <var>PY<sub>scalar</sub></var>)</code>
:;<var>X</var>:a [[../#polygons|closed point-list]] or a [[../#polygons|polygon-stream]] defining one or more polygons.
:;<var>IX</var>:The index of the polygon of ''X'' to be tested; 0 <= <var>IX</var> < ''N'' (= <code>[[../pgget|pgget]](''X'')</code>)
:;<var>PX, PY</var>: The point ''P''=<''PX'',''PY''> to be tested.
;Result 1: The result ''r'' is a scaler.
:{|class="keinrahmen"
|''r''='''0''' | ... point ''P'' is outside the polygon
|''r''='''1''' | ... point ''P'' is inside the polygon
|}


=====Usage:=====
:<code>pgitest(<var>X</var>, <var>I</var>, <var>PX<sub>scalar</sub></var>, <var>PY<sub>vector</sub></var>)</code>
:<code>pgitest(<var>X</var>, <var>I</var>, <var>PX<sub>vector</sub></var>, <var>PY<sub>scalar</sub></var>)</code>
:<code>pgitest(<var>X</var>, <var>I</var>, <var>PX<sub>vector</sub></var>, <var>PY<sub>vector</sub></var>)</code>


<code><var>I</var> := pgITest( {pg_stream|pg_cplist}<var>XS</var>, {number}<var>IX</var>, {number}<var>XP</var>, {number}<var>YP</var> )</code>


=====Description:=====
:;<var>X</var>:A [[../#polygons|closed point-list]] or a [[../#polygons|polygon-stream]] defining one or more polygons.
;Result 1: The number of [[../#polygons|simple polygons]] ''N'' stored in ''X''. If the result is '''0''', ''X'' contains no valid polygons.
----
;Usage 2:<code>pgget(<var>X</var>, <var>I</var>, <var>fmt</var>)</code>
:;<var>X</var>:A [[../#polygons|closed point-list]] or a [[../#polygons|polygon-stream]] defining one or more polygons.
:;<var>I</var>:The index of the polygon to be returned; 0 <= <var>I</var> < ''N'' (= <code>pgget(''X'')</code>)
:;<var>fmt</var>:The format of the result.:
::{|class="keinrahmen"
|''fmt''=0 ||... return the ''I''-th polygon of ''X'' as [[../#polygons|polygon-stream]]
|-
|''fmt''=1 ||... return the [[../#polygons|polygon-stream]] header (a 8x2 matrix) of the ''I''-th polygon of ''X''
|}
;Result 2: The ''I''-th polygon stored in ''X'' in the format selected by ''fmt''.
----
;See also: [[../pginit|pginit]], [[../pgitest|pgitest]], [[../pgiline|pgiline]], [[../pgxgrid|pgxgrid]], [[../pgsplit|pgsplit]], [[../pgtrans|pgtrans]], [[../pghull|pghull]]


Detect if a point is inside a simple polygon.


=====Parameters:=====
[[../#Functions|<function list>]]
 
;<var>XS</var>
 
:The polygon stream containing the simple polygon, or point list describing the simple polygon.
 
;<var>IX</var>
 
:The index of the polygon describing the simple polygon.
 
;<var>XP</var>
 
:The x point to test.
 
;<var>YP</var>
 
:The y point to test.
 
=====Result:=====
 
<code>0</code> if the point <<var>XP</var>,<var>YP</var>> is outside the polygon <var>XS</var>[<var>IX</var>]
 
<code>1</code> if the point <<var>XP</var>,<var>YP</var>> is inside the polygon <var>XS</var>[<var>IX</var>]
 
=====Usage:=====
 
<code><var>I</var> := pgITest( {pg_stream|pg_cplist}<var>XS</var>, {number}<var>IX</var>, {vector}<var>XP</var>, {vector}<var>YP</var> )</code>
 
<code><var>I</var> := pgITest( {pg_stream|pg_cplist}<var>XS</var>, {number}<var>IX</var>, {number}<var>XP</var>, {vector}<var>YP</var> )</code>
 
<code><var>I</var> := pgITest( {pg_stream|pg_cplist}<var>XS</var>, {number}<var>IX</var>, {vector}<var>XP</var>, {number}<var>YP</var> )</code>
 
=====Description:=====
 
Detect if a line is inside a simple polygon.
 
=====Parameters:=====
 
=====Result:=====
 
A vector I with I[j]=0 if <XP[j],YP[j]> is outside the polygon XS[IX] and
 
I[j]=1 if <XP[j],YP[j]> is inside the polygon XS[IX]
 
=====Usage:=====
 
<code>I := pgITest( {pg_stream|pg_cplist}XS, {number}IX, {number}X1, {number}Y1, {number}X2, number{Y2} )</code>
 
=====Description:=====
 
Detect if a line is inside a simple polygon.
 
=====Parameters:=====
 
=====Result:=====
 
0 if all points of the line <X1,Y1>..<X2,Y2> are outside the polygon XS[IX]
 
1 if all points of the line <X1,Y1>..<X2,Y2> are inside the polygon XS[IX]
 
2 if the line <X1,Y1>..<X2,Y2> is intersects the polygon XS[IX]
 
=====Usage:=====
 
<code>I := pgITest( {pg_stream|pg_cplist}XS, {number}IX, {pg_stream|pg_cplist}YS, {number}IY )</code>
 
=====Description:=====
 
Detect if a simple polygon is inside a simple polygon.
 
=====Parameters:=====
 
=====Result:=====
 
0 if polygon YS[IX] is outside of polygon XS[IX]
 
1 if polygon YS[IX] is included in polygon XS[IX]
 
2 if polygon YS[IX] and XS[IX] are partly overlapping
 
3 if polygon XS[IX] is included in polygon YS[IX]
 
=====pgsplit - split polygon through line=====
 
=====Usage:=====
 
<code><var>YS</var> := pgSplit( {pg_stream}<var>XS</var>, {number}<var>IX</var>, {number}<var>X1</var>, {number}<var>Y1</var>, {number}<var>X2</var>, {number}<var>Y2</var> )</code>
 
=====Description:=====
 
Use a line to split a polygon into two polygons.
 
=====Result:=====
 
The pg_stream <var>YS</var> containing the two polygon parts of the polygon <var>XS</var>[<var>IX</var>]
 
=====pgtrans - shift, scale or rotate polygon=====
 
=====Usage:=====
 
<code><var>YS</var> := pgTrans( {pg_stream}<var>XS</var>, {number}<var>IX</var>, {number}<var>DX</var>=0, {number}<var>DY</var>=0, {number}<var>KX</var>=1, {number}<var>KY</var>=1, {number}<var>A</var>=0)</code>
 
=====Description:=====
 
Shift (dx/dy) / scale (kx/ky) / rotate polygon (a).
 
=====Parameters:=====
 
;<var>XS</var>
 
:The polygon stream containing the simple polygon, or point list describing the simple polygon.
 
;<var>IX</var>
 
:The index of the polygon describing the simple polygon.
 
;<var>DX</var>
 
;<var></var>
 
;<var>DY</var>
 
;<var></var>
 
;<var>KX</var>
 
;<var></var>
 
;<var>KY</var>
 
;<var></var>
 
;<var>A</var>
 
;<var></var>
 
=====Result:=====
 
The resulting polygon.

Revision as of 07:48, 20 April 2011

Check the relation (outside, inside, overlap) of a given point, line or simple polygon p to the polygon x.


Usage 1
pgitest(X, IX, PXscalar, PYscalar)
X
a closed point-list or a polygon-stream defining one or more polygons.
IX
The index of the polygon of X to be tested; 0 <= IX < N (= pgget(X))
PX, PY
The point P=<PX,PY> to be tested.
Result 1
The result r is a scaler.
... point P is outside the polygon ... point P is inside the polygon
pgitest(X, I, PXscalar, PYvector)
pgitest(X, I, PXvector, PYscalar)
pgitest(X, I, PXvector, PYvector)


X
A closed point-list or a polygon-stream defining one or more polygons.
Result 1
The number of simple polygons N stored in X. If the result is 0, X contains no valid polygons.

Usage 2
pgget(X, I, fmt)
X
A closed point-list or a polygon-stream defining one or more polygons.
I
The index of the polygon to be returned; 0 <= I < N (= pgget(X))
fmt
The format of the result.:
fmt=0 ... return the I-th polygon of X as polygon-stream
fmt=1 ... return the polygon-stream header (a 8x2 matrix) of the I-th polygon of X
Result 2
The I-th polygon stored in X in the format selected by fmt.

See also
pginit, pgitest, pgiline, pgxgrid, pgsplit, pgtrans, pghull


<function list>

Navigation menu

Personal tools