Ramer-Douglas-Peucker line simplification: Difference between revisions

add RPL
(add RPL)
Line 1,337:
points specified: (0,0) (1,0.1) (2,-0.1) (3,5) (4,6) (5,7) (6,8.1) (7,9) (8,9) (9,9)
points simplified: (0,0) (2,-0.1) (3,5) (7,9) (9,9)
</pre>
 
=={{header|RPL}}==
{{works with|Halcyon Calc|4.2.9}}
3 PICK - CONJ SWAP ROT
- (0,1) * DUP ABS /
* RE ABS
≫ ≫ '<span style="color:blue">DM→AB</span>' STO
≪ OVER SIZE 0 → points epsilon nb dmax
≪ '''IF''' nb 2 ≤ '''THEN''' points '''ELSE'''
0 points 1 GET points nb GET
2 nb 1 - '''FOR''' j
DUP2 points j GET <span style="color:blue">DM→AB</span>
'''IF''' DUP dmax < '''THEN''' DROP '''ELSE'''
'dmax' STO ROT DROP j ROT ROT '''END'''
'''NEXT'''
'''IF''' dmax epsilon < '''THEN'''
{ } + + SWAP DROP
'''ELSE'''
DROP2 points 1 3 PICK SUB <span style="color:blue">RDP</span>
points ROT nb SUB <span style="color:blue">RDP</span> 2 nb SUB +
'''END END'''
≫ ≫ '<span style="color:blue">RDP</span>' STO
 
{ (0,0) (1,0.1) (2,-0.1) (3,5) (4,6) (5,7) (6,8.1) (7,9) (8,9) (9,9) } 1 <span style="color:blue">RDP</span>
{{out}}
<pre>
1: { (0, 0) (2, -0.1) (3, 5) (7, 9) (9, 9) }
</pre>
 
1,150

edits