AI Angle Calculation Function