Actually this is more true than most realize.
The body uses the same neurotransmitter receptors to tell the brain that there is stimulation occurring. The brain then decides if it is pleasure, pain or combination thereof.
Some find being flogged, spanked, stuck with needles and what most would consider painful, to actually be pleasurable and orgasms, which are pleasurable, can become painful if one is ****** to endure more than they can handle. It all the same information going to the brain, it's just deciphered differently depending on the circumstance.