Polygon line algorithm

I have a polygon drawn with OpenGL line by line. However, I need to draw an extending line from the middle of each edge towrd the center of the polygon. As you can see in the picture below, the green and black lines are pointing in the right direction, but the white and blue ones are not.

http://img816.imageshack.us/img816/7402/linesl.jpg

What mathematical alogrithm should I use to correct this issue?

Here is the code:
//this draws an edge

//ortarr[j] is an array that stores each edge, x1 y1 and x2 y2 are the points of the edge, so x2 y2 correspond to the next edge’s x1 and y2.

float slope = (ortarr[j].y2 - ortarr[j].y1) / (ortarr[j].x2 - ortarr[j].x1);//slope of edge
float angle = atan2(ortarr[j].y2 - ortarr[j].y1, ortarr[j].x2 - ortarr[j].x1);//angle of edge
float angle2 = atan(-1.0f / slope);//angle of the small line, negative reciprocal

//this draws the small extending line
x1 = mx + (cos(angle));//middle line coordinates
y1 = my + (sin(angle));
x2 = x1 + (cos(angle2) * 1.6f);//middle line extending coordinates, this is where it sometimes fails
y2 = y1 + (sin(angle2) * 1.6f);
DrawLine(coltmp, x1, y1, x2, y2, 3.0f);

I’ve responded to this question (“Calculating polygon lines”) in the OpenGL coding: beginners forum:

http://www.opengl.org/discussion_boards/ubbthreads.php?ubb=showflat&Number=283802#Post283802