It's late, and I got (the texture coordinate part of) this code from wherever, and it works just fine, but I'm not sure why the equation for the texture coordinates is what it is. Why "+1 * 0.5"? (Java)
They're just mapping sin and cos, which have a [-1, 1] range to something more usable for a texture lookup [0, 1].
More conventionally you'd see it as " * 0.5 + 0.5" (eg: cosr * 0.5 + 0.5) so that -1 maps to 0 and 1 maps to 1. The way they've presented it there works just the same.