You'll have to specify the number of sides you want in addition to the length of one side.
Let N be the number of sides.
Calculate the length of one side:
Side_Length# = Sqr((V1x-VNx)^2 + (V1y-VNy)^2)
Assuming a counter-clockwise winding of the vertices, we know which side of the line to draw the polygon on.
We can calculate the inside angle between each segment like so:
InsideAngle# = 360.0 / Float(N)
Now you could get tricky here and try to find the center of the polygon, but I'm just gonna take the cheap way out.
Now we just need to step from the first point around the circle, incrementing our angle as we go.
Vx#[0] = First Point X
Vy#[0] = First Point Y
Vx#[N-1] = Last Point X
Vy#[N-1] = Last Point Y
For Loop = N-1 to 0 Step -1
LastSideAngle# = RayAngle#(Vx#[Loop-1], Vy#[Loop-1], Vx#[Loop], Vy#[Loop])
Vx#[Loop] = Vx[Loop-1] + Radius#*Cos(InsideAngle#)
; This function calculates the angle of a ray defined by two points in screen space.
Function RayAngle#(X1#, Y1#, X2#, Y2#)
Return ATan2#(-(Y2#-Y1#), X2#-X1#)
End Function
I'm too tired to finish this right now. It would be easier to make that loop if you had the first and second point instead of the first and last.
The pertinent equation is this:
V2x# = V1x# + Radius#*Cos(Angle)
V2y# = V1y# + Radius#*Sin(Angle)
Calculate the angle between the first and second vertex, and then add the inside angle to that value. That is what you would input into angle in the above equation. Except you might need to subtract the inside angle instead. I'm too tired to think right now. :-)