# Find all possible coordinates of parallelogram

Find the all the possible coordinate from the given three coordinates to make a parallelogram of a non-zero area.

Let’s call A,B,C are the three given points. We can have only the three possible situations:

(1) AB and AC are sides, and BC a diagonal (2) AB and BC are sides, and AC a diagonal (3) BC and AC are sides, and AB a diagonal

Hence, we can say that only 3 coordinates are possible from which we can generate a parallelogram if three coordinates are given.

To prove that all the three points are different let’s suppose it’s wrong. Without losing of generality suppose that the points got in cases AD and BC are equal.

Consider the system of two equations for the equality of these points:

B_{x}+ C_{x}- A_{x}= A_{x}+ C_{x}- B_{x}B_{y}+ C_{y}- A_{y}= A_{y}+ C_{y}- B_{y}It can be simplified as- A_{x}= B_{x}A_{y}= B_{y}

And we got a contradiction, as all the points A, B, C are distinct.

Examples:

Input : A = (0 0) B = (1 0) C = (0 1) Output : 1 -1 -1 1 1 1 Input : A = (-1 -1) B = (0 1) C = (1 1) Output : -2 -1 0 -1 2 3

Since the opposite sides are equal, AD = BC and AB = CD, we can calculate the co-ordinates of the missing point (D) as:

AD = BC(D_{x}- A_{x}, D_{y}- A_{y}) = (C_{x}- B_{x}, C_{y}- B_{y}) D_{x}= A_{x}+ C_{x}- B_{x}D_{y}= A_{y}+ C_{y}- B_{y}

The cases where the diagonals are AD and BC, CD and AB are processed in the same way.

**Reference: **https://math.stackexchange.com/questions/1322535/how-many-different-parallelograms-can-be-drawn-if-given-three-co-ordinates-in-3d

Below is the implementation of above approach:

## C++

`// C++ program to all possible points ` `// of a parallelogram ` `#include <bits/stdc++.h> ` `using` `namespace` `std; ` ` ` `// main method ` `int` `main() ` `{ ` ` ` `int` `ax = 5, ay = 0; ` `//coordinates of A ` ` ` `int` `bx = 1, by = 1; ` `//coordinates of B ` ` ` `int` `cx = 2, cy = 5; ` `//coordinates of C ` ` ` `cout << ax + bx - cx << ` `", "` ` ` `<< ay + by - cy <<endl; ` ` ` `cout << ax + cx - bx << ` `", "` ` ` `<< ay + cy - by <<endl; ` ` ` `cout << cx + bx - ax << ` `", "` ` ` `<< cy + by - ax <<endl; ` ` ` `return` `0; ` `} ` |

*chevron_right*

*filter_none*

## Java

`// Java program to all possible ` `// points of a parallelogram ` `public` `class` `ParallelogramPoints{ ` ` ` ` ` `// Driver code ` ` ` `public` `static` `void` `main(String[] s) ` ` ` `{ ` ` ` `int` `ax = ` `5` `, ay = ` `0` `; ` `//coordinates of A ` ` ` `int` `bx = ` `1` `, by = ` `1` `; ` `//coordinates of B ` ` ` `int` `cx = ` `2` `, cy = ` `5` `; ` `//coordinates of C ` ` ` `System.out.println(ax + bx - cx + ` `", "` ` ` `+ (ay + by - cy)); ` ` ` `System.out.println(ax + cx - bx + ` `", "` ` ` `+ (ay + cy - by)); ` ` ` `System.out.println(cx + bx - ax + ` `", "` ` ` `+ (cy + by - ax)); ` ` ` `} ` `} ` ` ` `// This code is contributed by Prerna Saini ` |

*chevron_right*

*filter_none*

## Python3

`# Python3 program to find all possible points ` `# of a parallelogram ` ` ` `ax ` `=` `5` `ay ` `=` `0` `#coordinates of A ` `bx ` `=` `1` `by ` `=` `1` `#coordinates of B ` `cx ` `=` `2` `cy ` `=` `5` `#coordinates of C ` `print` `(ax ` `+` `bx ` `-` `cx, ` `", "` `, ay ` `+` `by ` `-` `cy) ` `print` `(ax ` `+` `cx ` `-` `bx, ` `", "` `, ay ` `+` `cy ` `-` `by) ` `print` `(cx ` `+` `bx ` `-` `ax, ` `", "` `, cy ` `+` `by ` `-` `ax) ` |

*chevron_right*

*filter_none*

## C#

`// C# program to all possible ` `// points of a parallelogram ` `using` `System; ` ` ` `public` `class` `ParallelogramPoints ` `{ ` ` ` ` ` `// Driver code ` ` ` `public` `static` `void` `Main() ` ` ` `{ ` ` ` ` ` `//coordinates of A ` ` ` `int` `ax = 5, ay = 0; ` ` ` ` ` `//coordinates of B ` ` ` `int` `bx = 1, ` `by` `= 1; ` ` ` ` ` `//coordinates of C ` ` ` `int` `cx = 2, cy = 5; ` ` ` ` ` `Console.WriteLine(ax + bx - cx + ` `", "` ` ` `+ (ay + ` `by` `- cy)); ` ` ` `Console.WriteLine(ax + cx - bx + ` `", "` ` ` `+ (ay + cy - ` `by` `)); ` ` ` `Console.WriteLine(cx + bx - ax + ` `", "` ` ` `+ (cy + ` `by` `- ax)); ` ` ` `} ` `} ` ` ` `// This code is contributed by vt_m. ` |

*chevron_right*

*filter_none*

## PHP

`<?php ` `// PHP program to all ` `// possible points ` `// of a parallelogram ` ` ` `// Driver Code ` ` ` `//coordinates of A ` `$ax` `= 5; ` `$ay` `= 0; ` ` ` `//coordinates of B ` `$bx` `= 1; ` `$by` `= 1; ` ` ` `//coordinates of C ` `$cx` `= 2; ` `$cy` `= 5; ` ` ` ` ` `echo` `$ax` `+ ` `$bx` `- ` `$cx` `, ` `", "` ` ` `, ` `$ay` `+ ` `$by` `- ` `$cy` `,` `"\n"` `; ` ` ` `echo` `$ax` `+ ` `$cx` `- ` `$bx` `, ` `", "` ` ` `, ` `$ay` `+ ` `$cy` `- ` `$by` `,` `"\n"` `; ` ` ` `echo` `$cx` `+ ` `$bx` `- ` `$ax` `, ` `", "` ` ` `, ` `$cy` `+ ` `$by` `- ` `$ax` `; ` ` ` `// This code is contributed by anuj_67. ` `?> ` |

*chevron_right*

*filter_none*

Output:

4, -4 6, 4 -2, 1

** Time Complexity: ** O(1)

## Recommended Posts:

- Program to find the Area of a Parallelogram
- Find the Missing Point of Parallelogram
- Find area of parallelogram if vectors of two adjacent sides are given
- Find the other-end coordinates of diameter in a circle
- Find coordinates of the triangle given midpoint of each side
- Find whether only two parallel lines contain all coordinates points or not
- Find minimum area of rectangle with given set of coordinates
- Find the original coordinates whose Manhattan distances are given
- Find coordinates of a prime number in a Prime Spiral
- Program for Circumference of a Parallelogram
- Perimeter and Area of Varignon's Parallelogram
- Check whether four points make a parallelogram
- Area of a triangle inside a parallelogram
- Coordinates of rectangle with given points lie inside
- Minimum length of square to contain at least half of the given Coordinates

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.