New algorithm for polyline offset calculation