<< NL_F_Histogram NL_F: Function NL_F_Intersection2Lines >>

NARVAL >> NL_F: Function > NL_F_InterPolygonLine

NL_F_InterPolygonLine

Compute the coordinates of the intersection between a line and a polygon.

Calling Sequence

[I,IP] = NL_F_InterPolygonLine(P,a,b,Lx,Ly,d)

Arguments

P :

Polygon.

a :

slope of the line.

b :

y-intercept of the line.

Lx :

Area width.

Ly :

Area height.

d :

Precision.

I :

Vector of intersection points.

IP :

Vector of intersection points inluded in P.

Description

NL_F_InterPolygonLine computes the list of intersection point between the convex polygon P=(P1x P1y P2x P2y ... Pnx Pny) defined by the list of its successive points' coordinates and the line defined by its equation y=a.x+b. We consider each segment of the polygon and compute the list I of intersection points between the previous line and all segments of P whose coordinates belong to the rectangle of size (Lx,Ly). IP is a subset of I where intersection points also belongs to the polygon P.

Examples

P=[200 400 300 600 500 600 700 500 800 200 500 100];
nx=P(1:2:$);
ny=P(2:2:$);
a=1;
b=0;
Lx=1000;
Ly=1000;
d=0.01;
[I,IP]=NL_F_InterPolygonLine(P,a,b,Lx,Ly,d);//application of NL_F_InterPolygonLine
g=NL_G_MakeGraph('NL_F_InterPolygonLine',length(nx),[],[],nx,ny);
f=NL_G_ShowGraphN(g,1);
xpoly(nx,ny,"lines",close=1);
e=gce();
set(e,"foreground",5);
ix=linspace(0,Lx,10);
iy=a*ix+b;
plot2d(ix,iy);

Dependency

NL_F_Line2Points, NL_F_Intersection2Lines, NL_F_PointOfPolygon

Report an issue
<< NL_F_Histogram NL_F: Function NL_F_Intersection2Lines >>