SnakeShake
New member
- Joined
- May 14, 2015
- Messages
- 3
Hello,
first post and I hope I'm in the right section.
My problem is as follows, I have a variable rectangle (a smartphone screen to be precise) and I need to fit 4 circular buttons in it. I'd like them to have the largest radius possible without having them overlap.
So my givens are : rectangle width, rectangle height and the number of circles (4) (and that the circles will be the same size).
I can ignore any rectangles where (width > height) and (height > width * 4).
My two extremes thus are two aligned rows of 2 and one column of 4.
I've figured out that if I can get the angle of an imaginary line going through the centres of the top two circles I can Sine that number to get the percentage of width of the second circle that goes "below" the first circle and using that percentage along with the width of the rectangle I can determine the radius but I haven't figured out a way of getting that angle.
I really hope I've explained my problem in a clear way and that someone can help...
Thanks in advance anyone!
EDIT FOR SOLUTION:
Well, after some puzzling and getting other minds to work alongside me (with the other minds doing most of the work I'll admit) it boiled down to this:
W = 2r + 2r sin (alpha)
H = 2r + 6r cos (alpha)
Which was then finalised as:
r = (9*W+H)/2 - (3/2) * square-root-of(8*W2+2*W*H)
So there you have it, thanks for all the replies!
first post and I hope I'm in the right section.
My problem is as follows, I have a variable rectangle (a smartphone screen to be precise) and I need to fit 4 circular buttons in it. I'd like them to have the largest radius possible without having them overlap.
So my givens are : rectangle width, rectangle height and the number of circles (4) (and that the circles will be the same size).
I can ignore any rectangles where (width > height) and (height > width * 4).
My two extremes thus are two aligned rows of 2 and one column of 4.
I've figured out that if I can get the angle of an imaginary line going through the centres of the top two circles I can Sine that number to get the percentage of width of the second circle that goes "below" the first circle and using that percentage along with the width of the rectangle I can determine the radius but I haven't figured out a way of getting that angle.
I really hope I've explained my problem in a clear way and that someone can help...
Thanks in advance anyone!
EDIT FOR SOLUTION:
Well, after some puzzling and getting other minds to work alongside me (with the other minds doing most of the work I'll admit) it boiled down to this:
W = 2r + 2r sin (alpha)
H = 2r + 6r cos (alpha)
Which was then finalised as:
r = (9*W+H)/2 - (3/2) * square-root-of(8*W2+2*W*H)
So there you have it, thanks for all the replies!
Last edited: