I am having some difficulty adding in armour angling and i need to calculate the “Effective” armour values.

Looking around I need to get the cosine but i am unsure about how to code it. I know the rest of my code works because i am getting the right figures.

I need to calculate the cosine value from the impact point.

on a perfect dead on shot (0 angling), it should be 0°. as it gets more angled it will start increasing the effectiveness of the armour.

I am also unsure of where i need to start the impact point and calculate that from as well. Ideas /help?