an algorithm to offset a polyline, the same funtion you can see in AutoCAD, command offset.