Reputation: 4565
I am stumped by this problem which looks very simple. I have a 2D bounding box of which I have two corner points. I wish to determine the remaining two corner points. An important constraint: the bounding box can be oriented in any way and not necessarily aligned to the horizontal and vertical axes (i.e. x and y axes).
I wish to do this as I want to raster scan the bounding box.
Upvotes: 4
Views: 2437
Reputation: 1915
As mentioned in the comments, you don't have complete information. Let me explain: Draw a dummy rectangle that you want to find the points for -- make sure the rectangle is rotated i.e. not "flat".
Now, pick the top-left and bottom-right points -- treat them as the top-left and bottom-right points of a rectangle that is sitting flat on the x-axis. This shows that you can have at least two rectangles with the same two opposing points. Similarly, you can alter the angle of tilt and get an infinite number of points.
If you want a unique rectangle, you need to define at least the tilt. Hope that helps.
Upvotes: -1
Reputation: 57316
I'm sure this is not an answer you want to hear, however, as mentioned here before, two diagonally opposite points are not enough to define a rectangle on a 2D surface. As a picture is worth a thousand words, here's a picture of two different rectangles sharing the same diagonally opposite points.
Upvotes: 6