add angle calculation function