### Regular Polygons

*by DarthDoctor*

Problem: You want a chamber with 8 walls, all 8 DFU EXECTLY. How to do this? WDFUSE has a polygon drawer, but it goes by radius...

But, with simple trig, you can plot perfect polygons in less than two minutes.

First: look at the polygon. How many sides? (for the purposes of this example, 8). Draw it out, if you like. Now, draw lines from each vertex the center of the figure. Now your figure looks like a bunch of triangles, huh? Good. Count the triangles. (In our 8 sided polygon, 8 triangles.)

Now look at the center. If you were to measure all around the vertex (go completely around) you'd have 360 degrees. (Trust me. Or trust a math book...)

Now, if we have 8 different triangles that make up the center angle, and the angle measure 360 degrees, then 1 angle should be 360 divided by 8. If this doesn't make sense, think about it for a second.

So, the top angle of the triangle is 360/8, or 45 degrees. Now another tricky part. We know that the sides to either side are the same (we drew these sides between the vertices and the center - WDFUSE made sure they're the same), so what are our angles in our little triangle? The top one is 45, and we know the bottem two are equal. So: a trick.

Draw a line smack in the middle of the top angle and continue it to the bottem side. Sit back and look at your figure. Cover the left side. Why, that's a right triangle! So, whats the measure of the top angle? half of the larger triangle, or 45/2 or 22.5 degrees. The right angle is 90 degrees (as always), so the third angle must be 180 (all angles in a triangle add up to 180 degrees) - 22.5 (top angle of right triangle) - 90 (right angle) = 67.5 degrees.

Now the funky variables.

I'll call our radius R and side X (considered on the smaller, right triangle). Remember: the desired length of the polygon is twice the length of X.

So, our trig equation:

Cos 67.5 = X (adjancent) / R(Hypotuense) cos 67.5 = 4 (half of desired length) / R (variable) R * cos 67.5 = 4 R * 0.3827 = 4 R = 4 / .3826 R = 10.4525

Whew! I only used 4 decimal places, so it might not be too accurate. If you need it more accurate, carry it to more decimal places.

So, let's wrap up with a handy dandy formula:

cos(90-((360/sides)/2)) * radius entered = length of side / 2

Length of side given by the equation:

X(side) = 2 * cos ( 90 - (180 / sides) ) * radiusRadius = X(length of side) / ( 2 * cos ( 90 - (180 / sides) ) )