finding coordinates of hexagon

Roman Thilenius's icon

as usual, the the simple problems turn out to be the most difficult part.

how can i find the coordinates of the corners of a hexagon with a given radius, for example to draw one into a jit.lcd?

i know how to calculate between the inner and outer circle and a hexagon, but i would like to find the corners in an X/Y manner, when the size of the hexagon is given (i use multiples of 13/15 for inner and outer radius, as i want to work with integer numbers of course)

hz37's icon

[cos] and [sin] will get you there. Just iterate through the unit circle in steps of pi/3 and you'll have the coordinates of the unit circle, so you can multiply those by r and add the center coordinates. I tried to check if it would be easy to get there so here is my attempt, albeit kinda messy, but you get the picture. Have fun,

Hens Zimmerman

Max Patch
Copy patch and select New From Clipboard in Max.

Roman Thilenius's icon

until now i tried to avoid calculating circles and went the way over the triangles and rects when constructing the hex.

thats why i first missed that it is THREE values i have to check for beeing close to the next integer and not only two. i thought i am fine with the side length and in outer circle. :) and missed that i also need the height of the damned thing, (which is is √3*a)

well, i guess a bit of unaccuracy will be ok for sizes over 15 pixels. ;/

you are right, it seems to be easier to find the points of the circle by dividing the outline /6, then manually decide which dimension i like.