00:01
Hello, for problem 28, you're being asked to write a program that will take the x and y coordinates, as well as the width and height of two rectangles from a user and determine whether or not the second rectangle is inside the first or overlaps with the first.
00:22
And we want to, of course, test this program for lots of different cases.
00:27
So we will get the x, y, width, and height for triangle one and triangle two from the user, where we ask them to enter r1's center xy coordinates with and height, and the same for r2.
00:43
And then we need to check what's going on here.
00:48
So first, we're going to check if r1 is inside r2.
00:52
Then we'll check if r2 is inside r1.
00:55
I chose to do it this way.
00:58
It seems like in the question, it just wants you to determine whether the second rectangle is inside the first.
01:06
But i thought that it would be useful to know whether or not the first rectangle is inside the second.
01:11
And then we want to check if they overlap.
01:15
So how do we know if r1 is inside r2? well, if we start at the center of r1 and move out.
01:25
Out its width if that value is less than starting at the center of r2 and moving out its width.
01:34
And in the opposite direction, we have the same.
01:39
And in the y direction, that's true...