×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
• Talk With Other Members
• Be Notified Of Responses
• Keyword Search
Favorite Forums
• Automated Signatures
• Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

#### Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

# Diagonal Placement of boxes

## Diagonal Placement of boxes

(OP)
I am working on a problem related to fitting a rectangular box diagonally inside another, larger, rectangular box.  Please see diagram here.

I have searched the web for similar problems/solutions, but have only found notes indicating that the solution will be based on a quartic equation which will be difficult to solve.

But I am hopeful that there might be some simple approximation that might yield reasonable results.

Any suggestions or insights on how to solve this problem would be much appreciated.

Code what you mean,
and mean what you code!
But by all means post your code!

Razalas

### RE: Diagonal Placement of boxes

I don't understand your question and there is no diagram at that link.

mmerlinn

http://mmerlinn.com

"We've found by experience that people who are careless and sloppy writers are usually also careless and sloppy at thinking and coding. Answering questions for careless and sloppy thinkers is not rewarding." - Eric Steven Raymond

### RE: Diagonal Placement of boxes

One more known would be that the MAX L value would be...

MAX L: < (P2 + Q2).5

Skip,

Just traded in my old subtlety...
for a NUANCE!

### RE: Diagonal Placement of boxes

(OP)
Mmerlin,

my apologies for the difficulty in reaching the diagram.

When you click that link, under the section called "Stuff", there is a button, labelled "Diagonal Placement", which opens a pdf file containing the diagram.

Code what you mean,
and mean what you code!
But by all means post your code!

Razalas

### RE: Diagonal Placement of boxes

Nothing happens when I click that link.

mmerlinn

http://mmerlinn.com

"We've found by experience that people who are careless and sloppy writers are usually also careless and sloppy at thinking and coding. Answering questions for careless and sloppy thinkers is not rewarding." - Eric Steven Raymond

### RE: Diagonal Placement of boxes

I clicked the link and got the .pdf file.

Skip,

Just traded in my old subtlety...
for a NUANCE!

### RE: Diagonal Placement of boxes

You have 4 unknowns (a, b, c, d) and only 3 equations defining.

The FOURTH might be...

P * Q = a * b + c * d + L * W

Skip,

Just traded in my old subtlety...
for a NUANCE!

### RE: Diagonal Placement of boxes

never trust a Friday afternoon suggestion based on 30 sec thought, but:

if you hate geometry and don't like solving things precisely, you can relatively easily turn this into a binary search. For example: consider the bottom edge of the smaller box (as a line). Assuming it's an interesting length, it can be placed leftmost with its left end in the bottom left corner of the big box, and then it can be pushed rightwards until its right end hits the top right corner of the big box.

In any position, we can extend the small box's sides at rightangles upwards until either the left edge hits the left side of the big box, or until the right edge hits the top of the big box. Obviously in the leftmost position, it's the left edge that rules (giving width zero) and in the rightmost, it's the right edge that rules (also giving width zero).

Somewhere between the two, there's a position where both edges touch simultaneously, and this is the best-fit widest box (I think, I'm right aren't I??).

If all this is true, then you could, inefficiently, solve this just by doing a binary search where you look to see if a new position of the bottom edge is a left or right cut-off, and then search whichever side of the new position you need. Eventually either the length of the left side of the small box will become indistinguishable from the length of the right, or the change in position will become too tiny to see. This should correspond to the best width.

But this would be a strange and contorted way to do things, I think.

#### Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

#### Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Close Box

# Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

• Talk To Other Members
• Notification Of Responses To Questions
• Favorite Forums One Click Access
• Keyword Search Of All Posts, And More...

Register now while it's still free!