Answer the question
In order to leave comments, you need to log in
Will the parallelepiped fit into a quarter cylinder?
Good evening, I have a task.
Given a cylinder divided into 4 equal parts (vertically), consider a classic door at the entrance to the shopping center, with a given radius and height. And also a parallelepiped is given, with a given width, length and height. We need to find out if the parallelepiped will fit into a quarter of the cylinder. In this case, the box can be carried if it stands on one of the faces.
What is actually the snag: I decided to initially assume that the box (hereinafter simply the box) fits into a quarter of the cylinder. The box should not fit in the following cases:
1) If at least one side is greater than max(radius, height)
2) If three sides are greater than min(radius, height)
However, there are still failed tests for the problem. What other cases can be considered in addition to mine?
Thanks in advance :)
Answer the question
In order to leave comments, you need to log in
The box must not fit in the following cases:
1) If at least one side is greater than max(radius, height)
2) If three sides are greater than min(radius, height)
Since the box should have one face on the floor, then you can sort out which of them is on the floor, check that the rectangle fits into the sector of the circle and the third dimension of the box does not exceed the height of the cylinder.
How to check if a rectangle fits into a sector? If the box fits, it can be rotated and moved in the sector until it touches the sector boundary with three vertices. There are cases: the corner of the box coincides with the corner of the sector (diagonal of the rectangle <= radius), one point on the straight side of the sector and two on the round one, 2 corners on two straight sides and one on the round one.
You need to draw the last two cases, introduce some variables (for example, in the second case, you can enter x and y - the lengths of the segments from the corner of the sector to the corners of the rectangle), solve the system of quadratic equations (the lengths of the sides are given, the third point lies on the circle) and check that the fourth, free point lies inside.
In order not to produce more cases with the order of vertices, I advise you to sort out 3! permutations of all lengths of the parallelepipid. The third one will always be the height, the other two in the given order define the location of the points. For example, in the first case, the first length will be the width of the rectangle, and the second will be the height. If two points touch two straight sides, the first length will be the side that cuts off the corner, and so on.
So, going through all the cases of different box locations, you need to check that at least one of them fits into your cylinder.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question