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

From STX Wiki
Jump to navigationJump to search
m (1 revision: Initial import)
No edit summary
 
(12 intermediate revisions by 2 users not shown)
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 &le; <var>IX</var> < <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 ''X<sub>IX</sub>''
|-
|''r''='''1''' || ... point ''P'' is inside the polygon ''X<sub>IX</sub>''
|}
----
;Usage 2:
:<code>pgitest(<var>X</var>, <var>IX</var>, <var>PX<sub>scalar</sub></var>, <var>PY<sub>vector</sub></var>)</code>
:<code>pgitest(<var>X</var>, <var>IX</var>, <var>PX<sub>vector</sub></var>, <var>PY<sub>scalar</sub></var>)</code>
:<code>pgitest(<var>X</var>, <var>IX</var>, <var>PX<sub>vector</sub></var>, <var>PY<sub>vector</sub></var>)</code>
:;<var>PX, PY</var>: The points ''P''[i]=<''PX''[i],''PY''[i]> to be tested. One of these arguments must be a vector.
;Result 2: The result ''r'' is a vector containing the test result for each point ''P''[i].
::{|class="keinrahmen"
|''r''[i]='''0''' || ... point ''P''[i] is outside the polygon ''X<sub>IX</sub>''
|-
|''r''[i]='''1''' || ... point ''P''[i] is inside the polygon ''X<sub>IX</sub>''
|}
----
;Usage 3:
:<code>pgitest(<var>X</var>, <var>IX</var>, <var>PX1<sub>scalar</sub></var>, <var>PY1<sub>scalar</sub></var>), <var>PX2<sub>scalar</sub></var>, <var>PY2<sub>scalar</sub></var>)</code>
:;<var>PX1, PY1, PX2, PY2</var>: The points <''PX1'',''PY1''> and <''PX2'',''PY2''> defining the line ''P'' to be tested.
;Result 3: The result ''r'' is a scalar.
::{|class="keinrahmen"
|''r''='''0''' || ... the line ''P'' is outside the polygon ''X<sub>IX</sub>''
|-
|''r''='''1''' || ... the line ''P'' is inside the polygon ''X<sub>IX</sub>''
|-
|''r''='''2''' || ... the line ''P'' intersects the polygon ''X<sub>IX</sub>''
|}
----
;Usage 4:
:<code>pgitest(<var>X</var>, <var>IX</var>, <var>P</var>, <var>IP</var>)</code>
:;<var>P</var>:a [[../#polygons|closed point-list]] or a [[../#polygons|polygon-stream]] defining one or more polygons.
:;<var>IP</var>:The index of the polygon of ''P'' to be tested; 0 &le; <var>IP</var> < <code>[[../pgget|pgget]](''P'')</code>)
;Result 4: The result ''r'' is a scalar.
::{|class="keinrahmen"
|''r''='''0''' || ... the polygon ''P<sub>IP</sub>'' is outside the polygon ''X<sub>IX</sub>''
|-
|''r''='''1''' || ... the polygon ''P<sub>IP</sub>'' is included in the polygon ''X<sub>IX</sub>''
|-
|''r''='''2''' || ... the polygons ''P<sub>IP</sub>'' and ''X<sub>IX</sub>'' are partly overlapping
|-
|''r''='''3''' || ... the polygon ''X<sub>IX</sub>'' is included in the polygon ''P<sub>IP</sub>''
|}
----
;See also: [[../pginit|pginit]], [[../pgget|pgget]], [[../pgiline|pgiline]], [[../pgxgrid|pgxgrid]], [[../pgsplit|pgsplit]], [[../pgtrans|pgtrans]], [[../pghull|pghull]]


=====Usage:=====
[[../#Functions|<function list>]]
 
<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:=====
 
Detect if a point is inside a simple polygon.
 
=====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>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.

Latest revision as of 19:10, 21 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 < pgget(X)
PX, PY
The point P=<PX,PY> to be tested.
Result 1
The result r is a scaler.
r=0 ... point P is outside the polygon XIX
r=1 ... point P is inside the polygon XIX

Usage 2
pgitest(X, IX, PXscalar, PYvector)
pgitest(X, IX, PXvector, PYscalar)
pgitest(X, IX, PXvector, PYvector)
PX, PY
The points P[i]=<PX[i],PY[i]> to be tested. One of these arguments must be a vector.
Result 2
The result r is a vector containing the test result for each point P[i].
r[i]=0 ... point P[i] is outside the polygon XIX
r[i]=1 ... point P[i] is inside the polygon XIX

Usage 3
pgitest(X, IX, PX1scalar, PY1scalar), PX2scalar, PY2scalar)
PX1, PY1, PX2, PY2
The points <PX1,PY1> and <PX2,PY2> defining the line P to be tested.
Result 3
The result r is a scalar.
r=0 ... the line P is outside the polygon XIX
r=1 ... the line P is inside the polygon XIX
r=2 ... the line P intersects the polygon XIX

Usage 4
pgitest(X, IX, P, IP)
P
a closed point-list or a polygon-stream defining one or more polygons.
IP
The index of the polygon of P to be tested; 0 ≤ IP < pgget(P))
Result 4
The result r is a scalar.
r=0 ... the polygon PIP is outside the polygon XIX
r=1 ... the polygon PIP is included in the polygon XIX
r=2 ... the polygons PIP and XIX are partly overlapping
r=3 ... the polygon XIX is included in the polygon PIP

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

<function list>

Navigation menu

Personal tools