180 turn, jibe

Hello.

I need help.

in my windsurf APP, I want to count how many jibes and tack the rider did.

Jibe is a 180 downwind turn

Tack is a 180 upwind turn

maybe to see if is a jibe or a tack my app needs to know where the wind comes from... 

ok, but lets say, I only want to detect a 180 turn, how can I do it?

I will need 3 variables to compare each other to see if I'm doing a circle??

var1 = location;

var2 = location;

var3 = location;

while (var1 == var2 || var1 == 3 || var2 == var3 || var2 == var1 )

return you're going straight 

else

if (var1 == var3*180degree ) you're doing a jibe :D

Thanks!!