Loop pnt(n) test against pnt(n+1) & pnt(n-1)

Loop pnt(n) test against pnt(n+1) & pnt(n-1)

mdhutchinson
Advisor Advisor
295 Views
1 Reply
Message 1 of 2

Loop pnt(n) test against pnt(n+1) & pnt(n-1)

mdhutchinson
Advisor
Advisor
I have a set of vertices extracted from a closed non-intersecting polyline and am struggling with this loop... I want to test each pnt against its neighboring points ... if the test fails then eliminate the point.

In pseudo code:

[code]
For i = 0 to UBound(pnts)
test(pnt(i), pnt(i+1), pnt(i-1))
if test fails then eliminate pnt(i)
Next i
[/code]
0 Likes
296 Views
1 Reply
Reply (1)
Message 2 of 2

Anonymous
Not applicable
Hi,

Still in pseudo code:

Set colData = New Collection
FuzzFactor = 0.0000001
pnt = Polyline.Coordinates
If typeof Polyline is LWPolyline then
colData.Add pnt(0)
colData.Add pnt(1)
for i = 0 to ubound(pnt) -2 Step 2
if abs(pnt(i) - pnt(i + 2)) > FuzzFactor or abs(pnt(i + 1) - pnt(i
+ 3)) > FuzzFactor then
colData.Add pnt(i + 2)
colData.Add pnt(i + 3)
end if
next i
else
colData.Add pnt(0)
colData.Add pnt(1)
colData.Add pnt(3)
for i = 0 to ubound(pnt) -3 Step 3
if abs(pnt(i) - pnt(i + 3)) > FuzzFactor or abs(pnt(i + 1) - pnt(i
+ 4)) > FuzzFactor or abs(pnt(i + 2) - pnt(i + 5)) > FuzzFactor then
colData.Add pnt(i + 3)
colData.Add pnt(i + 4)
colData.Add pnt(i + 5)
end if
next i
end if
redim pnt(0 to coldata.count - 1)
for i = 0 to ubound(pnt) -1
pnt(i) = coldata.item(i)
next i
Polyline.Coordinates = pnt

--

Laurie Comerford
CADApps
www.cadapps.com.au
www.civil3Dtools.com
wrote in message news:[email protected]...
I have a set of vertices extracted from a closed non-intersecting polyline
and am struggling with this loop... I want to test each pnt against its
neighboring points ... if the test fails then eliminate the point.

In pseudo code:

[code]
For i = 0 to UBound(pnts)
test(pnt(i), pnt(i+1), pnt(i-1))
if test fails then eliminate pnt(i)
Next i
[/code]
0 Likes