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

From STX Wiki
Jump to navigationJump to search
No edit summary
Line 1: Line 1:
{{DISPLAYTITLE:{{SUBPAGENAME}}}}
{{DISPLAYTITLE:{{SUBPAGENAME}}}}
=====pgiline - detect line intersection=====
Find all intersections of a line, defined by the starting and the ending point, with the polygon ''x''.
;Usage:
:<code>pgiline(<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>


=====Usage:=====
:;<var>PX1, PY1, PX2, PY2</var>: The start point <''PX1'',''PY1''> and the end point <''PX2'',''PY2''> of 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 <= <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]]


<code><var>IS</var> := pgILine( {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:=====
[[../#Functions|<function list>]]
 
Detect intersections of a simple-polygon with a straight line.
 
=====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>X1, Y1</var>
 
:The x/y coordinate of the first point in the line.


;<var>X2, Y2</var>
;<var>X2, Y2</var>

Revision as of 08:15, 20 April 2011

Find all intersections of a line, defined by the starting and the ending point, with the polygon x.

Usage
pgiline(X, IX, PX1scalar, PY1scalar), PX2scalar, PY2scalar)
PX1, PY1, PX2, PY2
The start point <PX1,PY1> and the end point <PX2,PY2> of 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>

X2, Y2
The x/y coordinate of the last point in the line.
Result:

Detect intersections of the line <X1,Y1>..<X2,Y2> and the polygon XS[IX].

The result IS is an "N x 3" matrix:

row 0: col0,col1 x and y of start-point

col2 0 if start-point outside and 1 if start-point inside the polygon

...

row i: col0,col1 x and y of intersection point i (i = 1 .. N-2)

col2 0 if the line leaves and 1 if the line enters the polygon

...

row N-1: col0,col1 x and y of end-point

col2 0 if end-point outside and 1 if end-point inside the polygon

Navigation menu

Personal tools