calculating angles correctly in the flattener