Rotate line around center point given two vertices

I’ve been trying to rotate a bunch of lines by 90 degrees (that together form a polyline). Each line contains two vertices, say (x1, y1) and (x2, y2). What I’m currently trying to do is rotate around the center point of the line, given center points |x1 – x2| and |y1 – y2|. For some reason (I’m not very mathematically savvy) I can’t get the lines to rotate correctly.