To anyone else with the same problem; I found the following algorithms that seem to be exactly what I'm looking for: