Fixed bug in signed distance calculation in CP