Hard Light Productions Forums
Off-Topic Discussion => General Discussion => Topic started by: Sandwich on April 07, 2016, 08:24:59 am
-
I'm trying to figure out SVG hexagons. I want to find some size values that result in integers. I know that the height of a hexagon is height = sqrt(3)/2 * width. I'd like 'height' and 'width' to be integers.
So the question is, can the square root of 3, divided by 2, be multiplied by some integer to result in another integer? :)
-
Short answer: No.
Slightly longer answer: Given that sqrt(3) is an irrational number, no integer exists that, when multiplied by sqrt(3), results in another integer.
-
Longer answer still: no, and you can't trisect the angle on its corner with a straightedge and compass either.
-
No integer except zero. :p
-
You know... I didn't see a constraint about this needing to be a regular hexagon.
You can just squish the thing to be any integer in any direction you want.
-
Well, floating point numbers only have like 8 digit precision, and double 15-16 so some 9 or 17+ digit integer should work for whatever you need that, and 64bit type has 19 IIRC.
-
Are you volunteering to search that number space for possible solutions?
-
Well, floating point numbers only have like 8 digit precision, and double 15-16 so some 9 or 17+ digit integer should work for whatever you need that, and 64bit type has 19 IIRC.
OK you've misunderstood floats a fair bit here; anyway, what you're describing is basically no different to just using the float approximation of sqrt(3).
-
Given that sqrt(3) is an irrational number...
It makes perfect sense though.... :nervous:
Ok, thanks guys. Just checking. I found a few options that are "close enough" (one integer in the 100-200 range resulted in a number that had .0023###-something tacked on to it, which is near enough for web accuracy IMO).