Azraels-Art/Vimeo When someone wants to get male-to-female sex reassignment surgery, doctors can actually turn a penis into a vagina by basically flipping it inside out.

We first saw this incredible video on Cosmopolitan's website, and we decided to find out a bit more about what was going on in the animation, which demonstrates a surgical technique described by a team of urologists at the University of Tübingen in Germany.

Plastic surgeon Dr. Gary Alter, who has practices in both New York and Beverly Hills, explains on his website how he does the procedure.

First, patients have to undergo electrolysis treatments to permanently remove their pubic hair so it doesn't grow inside the vagina. Then, they go under sedation and the surgery, which lasts three to seven hours, begins.

Surgeons remove the testicles, then turn the head of the penis into the clitoris, since they actually develop from the same embryonic cells.

"A portion of the glans (head of the penis) with its nerve supply is converted into the clitoris," Alter writes. "This sensitive clitoris maintains normal erogenous sexual sensation and allows my patients to have orgasms."

Alter said he then inverts the penis skin to create the vagina, as you can see in the GIF below. The head of the penis, still attached to the nerves, is threaded through a newly made hole in the penis skin to make the clitoris:

The urethra is then pulled through the other hole, and the entire inverted penis is pulled into the body to create the vagina, like this:

Sometimes, Alter writes on his website, inverting the penis doesn't result in a deep enough vagina.

"Traditionally, the depth of the vagina is determined by the amount of shaft skin," he explains. "Since many patients with a smaller penis did not have adequate depth for satisfactory intercourse ... I routinely use a skin graft from extra scrotal skin and attach it to the deepest part of the penile skin to make the vagina deeper."

Then, Alter writes, he uses what's left of the scrotum to form the outer lips of the vagina, and adds some finishing touches to reduce scarring.

Patient satisfaction "is highly dependent on sufficient neovaginal depth and neoclitoral sensation to achieve orgasm, as well as an attractive cosmetic result that fulfills the patient's aesthetic expectations," the University of Tübingen researchers wrote, after analyzing the results of the surgery in 24 patients.

Here's the full, five-minute animation of the entire procedure, which was first published as part of a 2013 paper by the German researchers in the journal European Urology. The scissors and scalpels might make some people a bit squeamish, but the procedure overall is an impressive surgical feat.

Uniklinikum Tübingen: Sex-Reassignment: Male to Female Surgery 2009 from Azraels-Art on Vimeo.