While giving a physics talk for high school students five years ago at the Massachusetts Institute of Technology, Randall Munroe could tell that his audience was, in his words, “not totally with me.”

He was trying to explain potential energy and power — not complex concepts, but abstruse.

So, in the middle of his three-hour presentation, Mr. Munroe, who is best known as the creator of the Web comic xkcd, switched gears to “Star Wars.”

“I thought about the scene in ‘The Empire Strikes Back’ when Yoda lifts the X-wing out of the swamp,” he said in an interview. “It occurred to me as I was lecturing.”