power2
power2

Reputation: 999

Determine 4th point from 3 unordered points

Assume I have a parallelogram. I want to find the 4th point from 3 points. How is this possible.

Essentially, I have an array of 3 XY points. It is a paralleogram. I need to get the 4th point.

I have this so far:

            print "***********"
            point1 = finalArray[0]["Point"]
            point2 = finalArray[1]["Point"]
            point3 = finalArray[2]["Point"]

            def get_angle(p1, p2):
                ang = np.arctan2((p2[1]-p1[1]), (p2[0]-p1[0])) * 180 / np.pi
                return abs(ang - 90)

            if get_angle(point1, point2) < 10:
                cv2.circle(cameraProcessed,point1, 20, (0,0,255), 10)
            if get_angle(point2, point1) < 10:
                cv2.circle(cameraProcessed,point2, 20, (0,0,255), 10)


            if get_angle(point1, point3) < 10:
                cv2.circle(cameraProcessed,point1, 20, (0,0,255), 10)
            if get_angle(point3, point1) < 10:
                cv2.circle(cameraProcessed,point3, 20, (0,0,255), 10)

            if get_angle(point2, point3) < 10:
                cv2.circle(cameraProcessed,point2, 20, (0,0,255), 10)
            if get_angle(point3, point2) < 10:
                cv2.circle(cameraProcessed,point3, 20, (0,0,255), 10)

Upvotes: 1

Views: 1533

Answers (1)

jimifiki
jimifiki

Reputation: 5534

Is this what you need?

point4.x = point1.x + (point3.x - point2.x) 
point4.y = point1.y + (point3.y - point2.y) 

by the way, given 3 points there are three parallelograms you can construct, the other two are given by

point4.x = point2.x + (point1.x - point3.x) 
point4.y = point2.y + (point1.y - point3.y) 

and

point4.x = point3.x + (point2.x - point1.x) 
point4.y = point3.y + (point2.y - point1.y) 

Upvotes: 3

Related Questions