My Math Forum Calculating the side length of a hexagon from a rect.w/h?

 Algebra Pre-Algebra and Basic Algebra Math Forum

 March 9th, 2009, 07:34 AM #1 Newbie   Joined: Mar 2009 Posts: 2 Thanks: 0 Calculating the side length of a hexagon from a rect.w/h? Hi, I need to calculate the side length of a hexagon. To make things easy let's say I want to create a hexagon whose six sides have all the same length and I want to get the side length by providing values for the width and height of a rectangle in that the hexagon fits in... To give an example let's say I decide a rectangle area with a width and height of 80 pixels and I want to create a hexagon that fits into this rectangle. The hexagon should be a vertical one, where the top/bottom has straight lines e.g. like this http://en.wikipedia.org/wiki/File:Regular_hexagon.svg Could anyone give me a hint on how to calculate this? I know I have to calculate the right triangle and the hypotenuse of it etc. but so far I haven't been really successful. Another question I'm wondering is if it's possible to calculate a hexagon the same way from a rectangle that has different values for width and height? Some help would be very appreciated! Thanks a lot!
 March 9th, 2009, 09:14 AM #2 Senior Member   Joined: Feb 2009 From: Adelaide, Australia Posts: 1,519 Thanks: 3 Re: Calculating the side length of a hexagon from a rect.w/h? The regular hexagon is just six equilateral triangles glued together. In that diagram, the height is one side times root 3, and the width is twice one side. So if you put a regular hexagon in a rectangle, each side of the hexagon will be equal to the shorter side of the rectangle divided by root 3. Two of the hexagon's sides will be flat against, or parallel to, the longer sides of the rectangle. If you want the largest possible regular hexagon that will fit into the rectangle, the solution is the same unless the rectangle is almost a square. In that case, the hexagon has to be slightly squint. That's an interesting problem itself.
 March 11th, 2009, 05:19 AM #3 Newbie   Joined: Mar 2009 Posts: 2 Thanks: 0 Re: Calculating the side length of a hexagon from a rect.w/h? Thanks a lot aswoods! I think I figured it out. Probably different than your explanation but it works. I've calculated the triangle (that is one corner of the 'square' the hexagon fits in) from a specified height. The width then results automatically from it (do not wonder! i write this in ActionScript3, hence the Math functions etc.)... Code: // angle in Radians angle = 30 * Math.PI / 180 height = 42 oppositeLeg = height / 2 adjacentLeg = Math.round(oppositeLeg * Math.tan(angle)); hypotenuse = Math.round(Math.sqrt(Math.pow(oppositeLeg , 2) + Math.pow(adjacentLeg , 2))); width = (a * 2) + h; ... the hypotenuse is equal to the length of one side of the hexagon. The Math.rounds are necessary to have it on a pixel-perfect position. And as I figured out I don't need to have 'distorted' hexagos, i.e. with a different width/height ratio than the calculated one.

 Tags calculating, hexagon, length, rectw or h, side

,

,

,

,

,

,

,

,

,

,

,

,

,

,

### how to get hexagon flat length

Click on a term to search for related topics.
 Thread Tools Display Modes Linear Mode

 Similar Threads Thread Thread Starter Forum Replies Last Post Spaghett Algebra 8 June 24th, 2011 07:52 PM Riazy Calculus 5 March 10th, 2011 09:08 AM lesterxburnham Algebra 5 June 15th, 2010 09:31 AM mollymcf2009 Calculus 1 February 27th, 2009 06:29 PM Mr Spot Algebra 15 November 20th, 2008 05:56 PM

 Contact - Home - Forums - Cryptocurrency Forum - Top