<div dir="ltr"><div><span style="font-family:arial,sans-serif;font-size:13px">Okay I'll try. What the main job is to do an algorithm which simples a line. Algorithm deletes points which are unnecessary accurate according to tolerance distance user gives.</span></div>
<div><br></div><div><div style="font-family:arial,sans-serif;font-size:13px">>> I started by converting the pseudocode I had to python. </div><div style="font-family:arial,sans-serif;font-size:13px"><br></div><div style="font-family:arial,sans-serif;font-size:13px">
Pseudocode: <a href="http://web.cs.sunyit.edu/~poissad/projects/Curve/about_algorithms/lang" target="_blank">http://web.cs.sunyit.edu/~poissad/projects/Curve/about_algorithms/lang</a> </div></div><div style="font-family:arial,sans-serif;font-size:13px">
<br></div><div style="font-family:arial,sans-serif;font-size:13px">
<ol style="font-size:medium;background-color:rgb(221,221,221);white-space:pre-wrap;font-family:monospace"><li style="margin:10px;vertical-align:top"><div style="font-size:1em;line-height:1.2em;margin:0px;padding:0px;background-image:none;vertical-align:top">

<span style="color:rgb(0,0,102);font-weight:bold">function</span> lang<span style="color:rgb(0,153,0)">(</span>PointList<span style="color:rgb(0,153,0)">[</span><span style="color:rgb(0,153,0)">]</span><span style="color:rgb(51,153,51)">,</span> Tolerance<span style="color:rgb(0,153,0)">)</span></div>

</li><li style="margin:10px;vertical-align:top"><div style="font-size:1em;line-height:1.2em;margin:0px;padding:0px;background-image:none;vertical-align:top">  key<span style="color:rgb(51,153,51)">=</span><span style="color:rgb(204,0,0)">0</span></div>

</li><li style="margin:10px;vertical-align:top"><div style="font-size:1em;line-height:1.2em;margin:0px;padding:0px;background-image:none;vertical-align:top">  endP<span style="color:rgb(51,153,51)">=</span> PointList.<span style="color:rgb(102,0,102)">length</span><span style="color:rgb(51,153,51)">-</span><span style="color:rgb(204,0,0)">1</span></div>

</li><li style="margin:10px;vertical-align:top"><div style="font-size:1em;line-height:1.2em;margin:0px;padding:0px;background-image:none;vertical-align:top">  <span style="color:rgb(0,0,102);font-weight:bold">do</span> <span style="color:rgb(0,153,0)">{</span></div>

</li><li style="margin:10px;font-weight:bold;vertical-align:top"><div style="font-weight:normal;font-size:1em;line-height:1.2em;margin:0px;padding:0px;background-image:none;vertical-align:top">    endP<span style="color:rgb(51,153,51)">=</span> PointList.<span style="color:rgb(102,0,102)">length</span><span style="color:rgb(51,153,51)">-</span><span style="color:rgb(204,0,0)">1</span></div>

</li><li style="margin:10px;vertical-align:top"><div style="font-size:1em;line-height:1.2em;margin:0px;padding:0px;background-image:none;vertical-align:top">    <span style="color:rgb(0,0,102);font-weight:bold">if</span> <span style="color:rgb(0,153,0)">(</span>key<span style="color:rgb(51,153,51)">+</span><span style="color:rgb(204,0,0)">1</span> <span style="color:rgb(51,153,51)">!=</span> endP<span style="color:rgb(0,153,0)">)</span> <span style="color:rgb(0,102,0);font-style:italic">// If there are intermediate points</span></div>

</li><li style="margin:10px;vertical-align:top"><div style="font-size:1em;line-height:1.2em;margin:0px;padding:0px;background-image:none;vertical-align:top">      line<span style="color:rgb(51,153,51)">=</span> <span style="color:rgb(0,0,102);font-weight:bold">new</span> Line<span style="color:rgb(0,153,0)">(</span> PointList<span style="color:rgb(0,153,0)">[</span>key<span style="color:rgb(0,153,0)">]</span><span style="color:rgb(51,153,51)">,</span> PointList<span style="color:rgb(0,153,0)">[</span>endP<span style="color:rgb(0,153,0)">]</span><span style="color:rgb(0,153,0)">)</span></div>

</li><li style="margin:10px;vertical-align:top"><div style="font-size:1em;line-height:1.2em;margin:0px;padding:0px;background-image:none;vertical-align:top">      <span style="color:rgb(0,102,0);font-style:italic">/* Find the point with the furthest perpendicular distance */</span></div>

</li><li style="margin:10px;vertical-align:top"><div style="font-size:1em;line-height:1.2em;margin:0px;padding:0px;background-image:none;vertical-align:top">      maxIndex<span style="color:rgb(51,153,51)">=</span> key<span style="color:rgb(51,153,51)">+</span><span style="color:rgb(204,0,0)">1</span></div>

</li><li style="margin:10px;font-weight:bold;vertical-align:top"><div style="font-weight:normal;font-size:1em;line-height:1.2em;margin:0px;padding:0px;background-image:none;vertical-align:top">      maxD<span style="color:rgb(51,153,51)">=</span> perpendicularDistance<span style="color:rgb(0,153,0)">(</span>line<span style="color:rgb(51,153,51)">,</span> PointList<span style="color:rgb(0,153,0)">[</span>maxIndex<span style="color:rgb(0,153,0)">]</span><span style="color:rgb(0,153,0)">)</span></div>

</li><li style="margin:10px;vertical-align:top"><div style="font-size:1em;line-height:1.2em;margin:0px;padding:0px;background-image:none;vertical-align:top">      <span style="color:rgb(0,0,102);font-weight:bold">for</span> <span style="color:rgb(0,153,0)">(</span>i<span style="color:rgb(51,153,51)">=</span>maxIndex<span style="color:rgb(51,153,51)">+</span><span style="color:rgb(204,0,0)">1</span><span style="color:rgb(51,153,51)">;</span> i<span style="color:rgb(51,153,51)"><</span>endP<span style="color:rgb(51,153,51)">;</span> i<span style="color:rgb(51,153,51)">++</span><span style="color:rgb(0,153,0)">)</span></div>

</li><li style="margin:10px;vertical-align:top"><div style="font-size:1em;line-height:1.2em;margin:0px;padding:0px;background-image:none;vertical-align:top">        d<span style="color:rgb(51,153,51)">=</span> perpendicularDistance<span style="color:rgb(0,153,0)">(</span>line<span style="color:rgb(51,153,51)">,</span> PointList<span style="color:rgb(0,153,0)">[</span>i<span style="color:rgb(0,153,0)">]</span><span style="color:rgb(0,153,0)">)</span></div>

</li><li style="margin:10px;vertical-align:top"><div style="font-size:1em;line-height:1.2em;margin:0px;padding:0px;background-image:none;vertical-align:top">        <span style="color:rgb(0,0,102);font-weight:bold">if</span> <span style="color:rgb(0,153,0)">(</span>d <span style="color:rgb(51,153,51)">></span> maxD<span style="color:rgb(0,153,0)">)</span></div>

</li><li style="margin:10px;vertical-align:top"><div style="font-size:1em;line-height:1.2em;margin:0px;padding:0px;background-image:none;vertical-align:top">          maxIndex<span style="color:rgb(51,153,51)">=</span>i</div>

</li><li style="margin:10px;font-weight:bold;vertical-align:top"><div style="font-weight:normal;font-size:1em;line-height:1.2em;margin:0px;padding:0px;background-image:none;vertical-align:top">          maxD<span style="color:rgb(51,153,51)">=</span>d</div>

</li><li style="margin:10px;vertical-align:top"><div style="font-size:1em;line-height:1.2em;margin:0px;padding:0px;background-image:none;vertical-align:top">      <span style="color:rgb(0,0,102);font-weight:bold">if</span> <span style="color:rgb(0,153,0)">(</span>maxD <span style="color:rgb(51,153,51)">></span> Tolerance<span style="color:rgb(0,153,0)">)</span></div>

</li><li style="margin:10px;vertical-align:top"><div style="font-size:1em;line-height:1.2em;margin:0px;padding:0px;background-image:none;vertical-align:top">        endP<span style="color:rgb(51,153,51)">--;</span></div>
</li>
<li style="margin:10px;vertical-align:top"><div style="font-size:1em;line-height:1.2em;margin:0px;padding:0px;background-image:none;vertical-align:top">      <span style="color:rgb(0,0,102);font-weight:bold">else</span> </div>

</li><li style="margin:10px;vertical-align:top"><div style="font-size:1em;line-height:1.2em;margin:0px;padding:0px;background-image:none;vertical-align:top">        <span style="color:rgb(0,0,102);font-weight:bold">for</span> <span style="color:rgb(0,153,0)">(</span>i<span style="color:rgb(51,153,51)">=</span>key<span style="color:rgb(51,153,51)">+</span><span style="color:rgb(204,0,0)">1</span><span style="color:rgb(51,153,51)">;</span> i<span style="color:rgb(51,153,51)"><</span>endP<span style="color:rgb(51,153,51)">;</span> i<span style="color:rgb(51,153,51)">++</span><span style="color:rgb(0,153,0)">)</span></div>

</li><li style="margin:10px;font-weight:bold;vertical-align:top"><div style="font-weight:normal;font-size:1em;line-height:1.2em;margin:0px;padding:0px;background-image:none;vertical-align:top">          PointList.<span style="color:rgb(102,0,102)">remove</span><span style="color:rgb(0,153,0)">(</span>i<span style="color:rgb(0,153,0)">)</span></div>

</li><li style="margin:10px;vertical-align:top"><div style="font-size:1em;line-height:1.2em;margin:0px;padding:0px;background-image:none;vertical-align:top">        key<span style="color:rgb(51,153,51)">=</span> endP</div>

</li><li style="margin:10px;vertical-align:top"><div style="font-size:1em;line-height:1.2em;margin:0px;padding:0px;background-image:none;vertical-align:top">  <span style="color:rgb(0,153,0)">}</span> while <span style="color:rgb(0,153,0)">(</span> endP <span style="color:rgb(51,153,51)">!=</span> PointList.<span style="color:rgb(102,0,102)">length</span><span style="color:rgb(51,153,51)">-</span><span style="color:rgb(204,0,0)">1</span> <span style="color:rgb(0,153,0)">)</span></div>

</li><li style="margin:10px;vertical-align:top"><div style="font-size:1em;line-height:1.2em;margin:0px;padding:0px;background-image:none;vertical-align:top">end</div></li></ol></div><div><div style="font-family:arial,sans-serif;font-size:13px">

<br>>> Still I have problems with perpendicular distance and creating a line<br>>> with python.</div><div style="font-family:arial,sans-serif;font-size:13px"><br></div><div style="font-family:arial,sans-serif;font-size:13px">

What I mean by creating a line is what Alan answered "checking<span style="color:rgb(34,34,34)"> distances/intersections etc only requires the math model." I need the mathematical model not a picture/graph. I'll try move forward with Bens suggestion of</span><span style="color:rgb(34,34,34)"> ‘math’ module which probably help me with both mathematical line model between two points and its distance between the intermediate points.</span></div>
<div style="font-family:arial,sans-serif;font-size:13px">> <URL:<a href="http://docs.python.org/3/library/math.html#trigonometric-functions" target="_blank">http://docs.python.org/3/library/math.html#trigonometric-functions</a>>.<br>
</div><div style="font-family:arial,sans-serif;font-size:13px"><br></div><div style="font-family:arial,sans-serif;font-size:13px">Here is a picture of the lang algorithm, where you can see distance of interest by purple</div>
<div style><font face="arial, sans-serif"><a href="http://psimpl.sourceforge.net/lang.html">http://psimpl.sourceforge.net/lang.html</a>. </font></div></div><div style><font face="arial, sans-serif"><br></font></div><div style>
<font face="arial, sans-serif">I'll ask later if I can't get this work.</font></div><div><br></div><div>Cheers!</div><div><br></div><div><br></div><div><br></div>
</div><div class="gmail_extra"><br><br><div class="gmail_quote">2014-04-15 3:23 GMT+03:00 Ben Finney <span dir="ltr"><<a href="mailto:ben+python@benfinney.id.au" target="_blank">ben+python@benfinney.id.au</a>></span>:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="">Laura Kauria <<a href="mailto:lacation@gmail.com">lacation@gmail.com</a>> writes:<br>
<br>
> Thanks a lot for all the help! I got the courage to start at least..<br>
<br>
</div>Congratulations! Courage is a necessary ingredient when starting :-)<br>
<br>
Could you please avoid  top-posting, and instead use interleaved style<br>
<URL:<a href="https://en.wikipedia.org/wiki/Posting_style#Interleaved_style" target="_blank">https://en.wikipedia.org/wiki/Posting_style#Interleaved_style</a>> for<br>
your replies, so the conversation is in a natural order.<br>
<div class=""><br>
> I started by converting the pseudocode I had to python.<br>
<br>
</div>If it's short and simple, please post it here so we can discuss it in<br>
context.<br>
<div class=""><br>
> Still I have problems with perpendicular distance and creating a line<br>
> with python.<br>
> I need to create a line between two points and then check what is the<br>
> distance between a line and intermediate points which were between lines<br>
> start and end point. If someone could help me with this? I could not<br>
> understand can I do this without math library or not?<br>
<br>
</div>The ‘math’ module in the standard library has trigonometric functions<br>
<URL:<a href="http://docs.python.org/3/library/math.html#trigonometric-functions" target="_blank">http://docs.python.org/3/library/math.html#trigonometric-functions</a>>.<br>
If you have co-ordinate data and know how to use trigonometry, then<br>
those functions will do what you expect.<br>
<span class="HOEnZb"><font color="#888888"><br>
--<br>
 \        “If I melt dry ice, can I swim without getting wet?” —Steven |<br>
  `\                                                            Wright |<br>
_o__)                                                                  |<br>
Ben Finney<br>
</font></span><div class="HOEnZb"><div class="h5"><br>
_______________________________________________<br>
Tutor maillist  -  <a href="mailto:Tutor@python.org">Tutor@python.org</a><br>
To unsubscribe or change subscription options:<br>
<a href="https://mail.python.org/mailman/listinfo/tutor" target="_blank">https://mail.python.org/mailman/listinfo/tutor</a><br>
</div></div></blockquote></div><br></div>