Closely inspect your formula:


tempX[j]=tempX[j]*cosF-tempY[j]*sinF; //using online formula
tempY[j]=tempY[j]*cosF+tempX[j]*sinF;

The formula is technically correct...