Improved triangle determination, implemented figure rotation