Asked • 03/15/19

Find the corners of a deformed rectangle?

I am trying to make a program that automatically corrects the perspective of a rectangle. I have managed to get the silhouette of the rectangle, and have the code to correct the perspective, but I can't find the corners. The biggest problem is that, because it has been deformed, I can't use the following "code": c1 = min(x), min(y) c2 = max(x), min(y) c3 = min(x), max(y) c4 = max(x), max(y) This wouldn't work with this situation (X represents a corner): X0000000000X .00000000000 ..X000000000 .....0000000 ........0000 ...........X Does anyone know how to do this?

K.J. P.

tutor
If you have 1 corner, say the one along the xmin line, just up from ymin, then you can come down from xmax, ymax along the xmax line. To find the other two points is trickier. Take the midpoint of the two points you have already. The distance from that midpoint to the two mystery points will be the same as the distance from the midpoint to either of our two known points. So find the two points along ymax and ymin that are that distance away from the midpoint and you're set.
Report

03/28/19

1 Expert Answer

By:

Patrick B. answered • 03/15/19

Tutor
4.7 (31)

Math and computer tutor/teacher

Still looking for help? Get the right answer, fast.

Ask a question for free

Get a free answer to a quick problem.
Most questions answered within 4 hours.

OR

Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.