Cats are notorious for being able to sleep practically anywhere. Regardless of the location, however, the sleeping position is definitely related to whatever the temperature happens to be. The basic rule: they stretch out when it is warm, curl up when it is cool.
So you’ll see a cat stretched out in the sun, but never curled up in the sun. If the room is cool, the cat will curl up into a ball, keeping his body heat turned in on himself. Even better, he will curl up into a human lap—or sidle up to an unaggressive dog, or even another cat.