private static double AbsSinPi(double v0) {
double res = Math.Abs(v0) % 1.0;
if (res < 0.25) {
res = Math.Sin(res * Math.PI);
} else if (res < 0.75) {
res = Math.Cos((res - 0.5) * Math.PI);
} else {
res = Math.Sin((res - 1.0) * Math.PI);
}
return Math.Abs(res);
}