A start on chew's algorithm (not working yet)