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

From STX Wiki
Jump to navigationJump to search
m (1 revision: Initial import)
No edit summary
 
(10 intermediate revisions by 2 users not shown)
Line 1: Line 1:
{{DISPLAYTITLE:{{SUBPAGENAME}}}}
{{DISPLAYTITLE:{{SUBPAGENAME}}}}
=====pgxgrid - compute polygon grid=====
Find all parts of the vertical lines of a grid inside a polygon. The grid is defined by the vectors ''x'' (length ''nx'' and ''y'' (length ''ny''). The function detects all parts of the vertical grid lines <code><''x''[i],''y''[0]>..<''x''[i],''y''[''ny''-1]> (i=0..''nx''-1)</code>, which are inside the polygon ''p''.
;Usage:
:<code>pgxgrid(<var>P</var>, <var>IP</var>, <var>X<sub>vector</sub></var>, <var>Y<sub>vector</sub></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>
:;<var>X</var>: The x-scale vector of the grid.
:;<var>Y</var>: The y-scale vector of the grid.
;Result: The result ''r'' is a (N+1)x3 matrix, with N is the number of vertical grid lines intersecting the polygon.
:Content of ''r''[0,*]:
::{|class="einrahmen"
|''r''[0,0] ||''ixmin''
|the ''X'' index of the first vertical line intersecting ''P<sub>IP</sub>''
|-
|''r''[0,1] ||''ixmax''
|the ''X'' index of the last vertical line intersecting ''P<sub>IP</sub>''
|-
|''r''[0,2] ||''iymin''
|the index of the minimum ''Y'' value of an intersection line
|-
|''r''[0,3] ||''iymax''
|the index of the maximum ''Y'' value of an intersection line
|-
|''r''[0,4] ||''ngrid''
|the accumlated number of grid points inside ''P<sub>IP</sub>''
|-
|''r''[0,5] ||''aclen''
|the absolute length of the centerline
|-
|''r''[0,6] ||''rclen''
|the relative length of the centerline
|}
:Content of ''r''[i,*], i=1..N (one row for each intersection line):
::{|class="einrahmen"
|''r''[i,0] ||''ix''
|the ''X'' index of the intersection line i
|-
|''r''[i,1] ||''iy''
|the ''Y'' index of the first point <''X''[''ix''],''Y''[''iy'']> i inside ''P<sub>IP</sub>''
|-
|''r''[i,2] ||''ny''
|the number of ''Y'' points inside ''P<sub>IP</sub>''
|-
|''r''[i,3] ||''ymin''
|the y value of the point where the intersection line i enters the polygon ''P<sub>IP</sub>''
|-
|''r''[i,4] ||''ymax''
|the y value of the point where the intersection line i leaves the polygon ''P<sub>IP</sub>''
|-
|''r''[i,5] ||''acofs''
|the absolute length of the centerline from the begin to intersection line i
|-
|''r''[i,6] ||''rclen''
|the relative length of the centerline from the begin to intersection line i
|}
:Notes:
:*The centerline is the line defined by the centerpoints <''X''[i],(''ymin''<sub>i</sub>+''ymax''<sub>i</sub>)/2> of all intersection lines. For the computation of ''aclen'' and ''acofs''<sub>i</sub> the x- and y-values of the points are used, while ''rclen'' and ''rcofs''<sub>i</sub> are computed from the x- and y-indices.
:*The function fails if a vertical grid line intersects the polygon more than 2 times.
;See also: [[../pginit|pginit]], [[../pgget|pgget]], [[../pgitest|pgitest]], [[../pgiline|pgiline]], [[../pgsplit|pgsplit]], [[../pgtrans|pgtrans]], [[../pghull|pghull]]


=====Usage:=====
[[../#Functions|<function list>]]
 
<code><var>XG</var> := pgXGrid( {pg_stream}<var>PS</var>, {number}<var>IPG</var>, {vector}<var>X</var>, {vector}<var>Y</var> )</code>
 
=====Description:=====
 
Compute x grid inside polygon (vertical grid lines).
 
=====Parameters:=====
 
=====Result:=====
 
A matrix (N+1) x 7, N = number of vertical grid lines
 
row 0: general grid information
 
XG[0,0]=ixmin minimum x-index
 
XG[0,1]=ixmax maximum x-index
 
XG[0,2]=iymin minimum y-index
 
XG[0,3]=iymax maximum y-index
 
XG[0,4]=ngrid number of grid points inside polygon
 
XG[0,5]=clen abs. length of centerline
 
XG[0,6]=iclen rel. length of centerline
 
for each verical grid line i (=1..N) the following information is stored:
 
XG[i,0]=ix x index
 
XG[i,1]=iy the index of the first y point inside
 
XG[i,2]=ny the number of y points inside
 
XG[i,3]=y0 the y value of the enter-point
 
XG[i,4]=y1 the y value of the leave-point
 
XG[i,5]=cofs abs. length of centerline from begin to grid line i
 
XG[i,6]=icofs rel. length of centerline from begin to grid line i
 
=====Notes:=====
 
The function fails if a vertical gridline intersects the polygon more than twice.

Latest revision as of 20:09, 21 April 2011

Find all parts of the vertical lines of a grid inside a polygon. The grid is defined by the vectors x (length nx and y (length ny). The function detects all parts of the vertical grid lines <x[i],y[0]>..<x[i],y[ny-1]> (i=0..nx-1), which are inside the polygon p.

Usage
pgxgrid(P, IP, Xvector, Yvector)
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)
X
The x-scale vector of the grid.
Y
The y-scale vector of the grid.
Result
The result r is a (N+1)x3 matrix, with N is the number of vertical grid lines intersecting the polygon.
Content of r[0,*]:
r[0,0] ixmin the X index of the first vertical line intersecting PIP
r[0,1] ixmax the X index of the last vertical line intersecting PIP
r[0,2] iymin the index of the minimum Y value of an intersection line
r[0,3] iymax the index of the maximum Y value of an intersection line
r[0,4] ngrid the accumlated number of grid points inside PIP
r[0,5] aclen the absolute length of the centerline
r[0,6] rclen the relative length of the centerline
Content of r[i,*], i=1..N (one row for each intersection line):
r[i,0] ix the X index of the intersection line i
r[i,1] iy the Y index of the first point <X[ix],Y[iy]> i inside PIP
r[i,2] ny the number of Y points inside PIP
r[i,3] ymin the y value of the point where the intersection line i enters the polygon PIP
r[i,4] ymax the y value of the point where the intersection line i leaves the polygon PIP
r[i,5] acofs the absolute length of the centerline from the begin to intersection line i
r[i,6] rclen the relative length of the centerline from the begin to intersection line i
Notes:
  • The centerline is the line defined by the centerpoints <X[i],(ymini+ymaxi)/2> of all intersection lines. For the computation of aclen and acofsi the x- and y-values of the points are used, while rclen and rcofsi are computed from the x- and y-indices.
  • The function fails if a vertical grid line intersects the polygon more than 2 times.
See also
pginit, pgget, pgitest, pgiline, pgsplit, pgtrans, pghull

<function list>

Navigation menu

Personal tools