Today is an other article about how to do something in Google Sketchup. I wrote once about how to center an octagon so it's edges lined up with the edges of a square. Last night I was making a design and decided I needed something a little different.
What we see here is an octagon such that upper left edge (point A), and lower right edge (point C) line up with the left side (X) and bottom side (Y) of a square, and the top right corner of the square (point B) is in the middle of the upper right side of the octagon. This is pretty easy to do if you have the octagon first, but in my situation I have the square first.
There are no nice even angles in this calculation, and in order to solve this problem we will need a little trigonometry. We start with a line between point B and point D. This is a 45 degree angle across the box. Because of alignment, it will also cross the lower left side of the octagon in the middle of the line, just as it crosses the middle of the upper right side of the octagon. This will serve as the foundation for our next step. What we are looking for is angle EBG and angle GBF, which should be identical.
In order to solve this problem, let us think about what the lengths of these lines are. Line BG is the octagon's span. Line EF is just the length of one of the side of the octagon—all of which are equal. Line EG and GF are just ½ this length. With this information we have enough data to draw a triangle.
Here is triangle BFG. We have two known sides, ½ N and S. I say ½ N because it is ½ the length of the octagon's sides. Side S is the octagon's span. With some searching, we can find the relationship between the span and the side length. . Now everything can be expressed in terms of the side length. Since we don't want to measure anything but angles, my hopes are that length terms will cancel out when we solve the equation.
To be clear: line S is the triangle's base, and ½ N is the leg. What we want is angle GBF, and we have the adjacent and opposite sides. So we can use the identity .
. Notice my hope was true—the side length (N) cancels out. So after we reduce, we get
. And solve for the angle:
.
Now we have a pretty exact angle that can be used.
So here is how the center point is found. Remember we are given the square. From the square, draw a 45 degree angle (protractor tool) from point B to point D. Using this guide ( line through BD), measure angles EBG and GBF. We calculated that those are both about 11.7 degrees. So using the protractor, start at point B, then click on point D, and then measure up/down the 11.7 degrees. Add guides along lines X and Y. Where these guides intersect the EBG and GBF, draw a guide—so between points E and F. This line is the lower left side of the octagon. Now using line X starting at point F, measure 22.5 degrees to the right. Where this guide intersects guide GB is the center of the octagon. Using the polygon tool with 8 sides, start from the center and pull the polygon to either point E of F. The results: