<div dir="ltr"><div><div><div><div><div>Thanks a lot for all the help! I got the courage to start at least..  <br><br></div>I started by converting the pseudocode I had to python. <br><br></div>Still I have problems with perpendicular distance and creating a line with python. <br>
</div>I need to create a line between two points and then check what is the distance between a line and intermediate points which were between lines start and end point. If someone could help me with this? I could not understand can I do this without math library or not?<br>
<br></div>I'm a geographer student so all possible library suggestions concerning spatial data is also appreciated.<br><br><br></div><div>Laura</div><div><div><div><div><br><br><br><br></div></div></div></div></div><div class="gmail_extra">
<br><br><div class="gmail_quote">2014-04-06 21:30 GMT+03:00 Danny Yoo <span dir="ltr"><<a href="mailto:dyoo@hashcollision.org" target="_blank">dyoo@hashcollision.org</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hi Laura,<br>
<br>
<br>
Algorithmic code typically is simple enough that standard language<br>
features should suffice.  I think you might pick up an external<br>
library to make it easier to visualize graphical output, but the core<br>
algorithms there appear fairly straightforward.<br>
<br>
To get some familiarity with basic Python programming, take a look at<br>
a tutorial like:<br>
<br>
    <a href="http://www.greenteapress.com/thinkpython/thinkpython.html" target="_blank">http://www.greenteapress.com/thinkpython/thinkpython.html</a><br>
<br>
and see if you can pick up the basic language features of Python.  If<br>
you have questions with that tutorial, feel free to ask here.<br>
<br>
<br>
It looks like you need enough to work with structured data (classes)<br>
and the basic data structures (lists, numbers).  At least from my<br>
reading of the "curve simplification" page you pointed us to, I don't<br>
see anything there that's too bad.<br>
<br>
*  You'll want a way to represent points.  I think a structured value<br>
would be appropriate.  Think classes.<br>
<br>
*  You'll want to represent a sequence of these points.  In Java, you<br>
can hold that collection with ArrayLists or some other list<br>
implementation.  In Python, there's a generic list data structure that<br>
serves a similar purpose.<br>
<br>
<br>
For example, in Java, you'd represent structured data with classes,<br>
and a collection of these with a List<Person>:<br>
<br>
///////////////////////////////////////////////////////////////<br>
class Person {<br>
    private String name;<br>
    public Person(String name) { <a href="http://this.name" target="_blank">this.name</a> = name; }<br>
    public void greet() { System.out.println("Hello, my name is " + name); }<br>
}<br>
<br>
// Usage:<br>
Person p = new Person("Laura");<br>
p.sayHello();<br>
Person p2 = new Person("Lydia");<br>
List<Person> people = new ArrayList<>();<br>
people.add(p);<br>
people.add(p2);<br>
///////////////////////////////////////////////////////////////<br>
<br>
<br>
And in Python, you can do an analogous construction:<br>
<br>
#####################################<br>
class Person(object):<br>
    def __init__(self, name):<br>
        <a href="http://self.name" target="_blank">self.name</a> = name<br>
    def greet(self):<br>
        print("Hello, my name is " + <a href="http://self.name" target="_blank">self.name</a>)<br>
<br>
## Usage<br>
p = Person("Laura")<br>
p.sayHello()<br>
p2 = Person("Lydia")<br>
people = []<br>
people.append(p)<br>
people.append(p2)<br>
#####################################<br>
<br>
<br>
So there should be a lot of transfer of basic knowledge between what<br>
you've learned in Java to Python programming.  Many of the concepts<br>
are the same, but the names are just different because of the Tower of<br>
Babel effect.  A basic tutorial of Python will cover these general<br>
topics.<br>
<br>
<br>
What might be domain-specific here is the visualization part: you'll<br>
want to make it easy to visually see the output of these graphical<br>
algorithms.  You may want to visualize these points on a graphical<br>
canvas on screen.  You could have your program generate an image file<br>
like a .png, .gif, or .svg file.<br>
<br>
Another approach may be to use a GUI toolkit that opens up a canvas as<br>
part of the program, where you can then manipulate the canvas.  If you<br>
want to take that approach, you might consider Tkinter, which is a GUI<br>
library that should come bundled with Python if I'm not mistaken.<br>
See:<br>
<br>
    <a href="http://effbot.org/tkinterbook/canvas.htm" target="_blank">http://effbot.org/tkinterbook/canvas.htm</a><br>
<br>
for a canvas example.  So once you have the basic algorithms down, you<br>
might use a Tkinter canvas to visualize and see that your algorithms<br>
are doing something reasonable.<br>
</blockquote></div><br></div>