I noticed when using the wrapdateline mode the X values go past -180 and 180. To fix this I used:
if (x < -180 || x > 180)
{
x %= 180;
}
However, this doesn’t really work because once you go past 180 it should hit -179, instead it hits 181 which would give 1 using the formula above. I feel like this is something that should be figured out automatically when using the wrap mode.
private int convert(int value)
{
if (value < -180 || value > 180)
{
value += 180;
if (value < 0)
{
value %= 360;
value += 180;
}
else if (value > 360)
{
value %= 360;
value -= 180;
}
}
return value;
}