In this AnswerHUB Post is an answer with C++ code:
That should help people who are still struggling (: