5

I'm trying to make a nice graphical gimmick for my game, but for it to work I need to find a way to get the distance from the center of a hexagon to it's edge, based on the angle.

For example, if I'd draw a line from the center to the edge at an angle of 5 degrees, how long would that line be? And what would it be when I draw a line at 45 degrees? How would one calculate that number based on the angle and radius of the hexagon?

enter image description here

1 Answers1

5

If $d$ is the distance for radius $r$ and angle $t$ (measured from the point on the right counterclockwise) then in degrees assume $0\le t \le 60$ since other cases can be reduced to this. Now the point of intersection is of the form $(d\cos t, d\sin t)$ and one can get the equation for the line joining the rightmost point $(r,0)$ of the hexagon to the next point (in counterclockwise direction) $(r/2,r\sqrt{3}/2).$ After doing this and plugging in, solving for $d$ one gets $$d=\frac{\sqrt{3}r}{\sqrt{3}\cos t + \sin t}.$$ If the hexagon radius is $r=1$ and $t=5$ this gives about $d=0.955,$ and for $t=45$ it gives $(3 \sqrt{2}-\sqrt{6})/2$ or about $0.896.$ When $t=30$ it gives the expected $\sqrt{3}/2.$

coffeemath
  • 29,884
  • 2
  • 31
  • 52