Given two points coordinates **(x _{1}, y_{1})** and

**(x**on 2D plane. The task is to find the reflection of (x

_{2}, y_{2})_{1}, y

_{1}) at 180 degree rotation of (x

_{2}, y

_{2}).

**Examples:**

Input : x_{1}= 0, y_{1}= 0, x_{2}= 1, y_{2}= 1 Output : (2, 2) Input : x_{1}= 1, y_{1}= 1, x_{2}= 2, y_{2}= 2 Output : (3, 3)

Let the reflection point of point (x_{1}, y_{1}) about (x_{2}, y_{2}) be (x’, y’).

For (x’, y’) be the 180 degree rotation of point (x_{1}, y_{1}) around point (x_{2}, y_{2}), they all must be collinear i.e all the three point must lie on a same straight line. Also, observe (x_{2}, y_{2}) will became mid point between (x_{1}, y_{1}) and (x’, y’).

So,

x’ – x_{2} = x_{2} – x_{1}

y’ – y_{2} = y_{2} – y_{1}

x’ = 2 * x_{2} – x_{1}

y’ = 2 * y_{2} – y_{1}

Below is the implementation of this approach:

## C++

`// CPP Program tof find the 180 degree reflection ` `// of one point around another point. ` `#include <bits/stdc++.h> ` `using` `namespace` `std; ` ` ` `void` `findPoint(` `int` `x1, ` `int` `y1, ` `int` `x2, ` `int` `y2) ` `{ ` ` ` `cout << ` `"("` `<< 2 * x2 - x1 << ` `", "` ` ` `<< 2 * y2 - y1 << ` `")"` `; ` `} ` ` ` ` ` `int` `main() ` `{ ` ` ` `int` `x1 = 0, y1 = 0, x2 = 1, y2 = 1; ` ` ` `findPoint(x1, y1, x2, y2); ` ` ` `return` `0; ` `} ` |

*chevron_right*

*filter_none*

## Java

`// Java Program to find the 180 degree ` `// reflection of one point around ` `// another point. ` `class` `GFG { ` ` ` ` ` `static` `void` `findPoint(` `int` `x1, ` `int` `y1, ` ` ` `int` `x2, ` `int` `y2) ` ` ` `{ ` ` ` `System.out.println(` `"("` `+ (` `int` `)(` `2` `* x2 - x1) ` ` ` `+ ` `","` `+ (` `int` `)(` `2` `* y2 - y1 ) + ` `" )"` `); ` ` ` `} ` ` ` ` ` `// Driver code ` ` ` `public` `static` `void` `main(String args[]) ` ` ` `{ ` ` ` `int` `x1 = ` `0` `, y1 = ` `0` `, x2 = ` `1` `, y2 = ` `1` `; ` ` ` ` ` `findPoint(x1, y1, x2, y2); ` ` ` `} ` `} ` ` ` `// This code is contributed by Arnab Kundu. ` |

*chevron_right*

*filter_none*

## Python3

`# Python3 Program for find the 180 ` `# degree reflection of one point ` `# around another point. ` ` ` `def` `findPoint(x1, y1, x2, y2): ` ` ` `print` `(` `"("` `, ` `2` `*` `x2 ` `-` `x1 , ` `","` `, ` ` ` `2` `*` `y2 ` `-` `y1 ,` `")"` `); ` ` ` `# Driver Code ` `x1 ` `=` `0` `; ` `y1 ` `=` `0` `; ` `x2 ` `=` `1` `; ` `y2 ` `=` `1` `; ` `findPoint(x1, y1, x2, y2); ` ` ` `# This code is contributed by mits ` |

*chevron_right*

*filter_none*

## C#

`// C# Program to find the 180 degree reflection ` `// of one point around another point. ` `using` `System; ` ` ` `public` `class` `GFG { ` ` ` ` ` `static` `void` `findPoint(` `int` `x1, ` `int` `y1, ` ` ` `int` `x2, ` `int` `y2) ` ` ` `{ ` ` ` `Console.WriteLine(` `"("` `+ (` `int` `)(2 * x2 - x1) ` ` ` `+ ` `","` `+ (` `int` `)(2 * y2 - y1 ) + ` `" )"` `); ` ` ` `} ` ` ` ` ` `// Driver code ` ` ` `static` `public` `void` `Main(String []args) ` ` ` `{ ` ` ` `int` `x1 = 0, y1 = 0, x2 = 1, y2 = 1; ` ` ` ` ` `findPoint(x1, y1, x2, y2); ` ` ` `} ` `} ` ` ` `// This code is contributed by Arnab Kundu. ` |

*chevron_right*

*filter_none*

## PHP

`<?php ` `// PHP Program for find the 180 ` `// degree reflection of one point ` `// around another point. ` ` ` `function` `findPoint(` `$x1` `, ` `$y1` `, ` `$x2` `, ` `$y2` `) ` `{ ` ` ` `echo` `"("` `, 2 * ` `$x2` `- ` `$x1` `, ` `", "` ` ` `, 2 * ` `$y2` `- ` `$y1` `,` `")"` `; ` `} ` ` ` ` ` `// Driver Code ` ` ` `$x1` `= 0; ` ` ` `$y1` `= 0; ` ` ` `$x2` `= 1; ` ` ` `$y2` `= 1; ` ` ` `findPoint(` `$x1` `, ` `$y1` `, ` `$x2` `, ` `$y2` `); ` ` ` `// This code is contributed by anuj_67 ` `?> ` |

*chevron_right*

*filter_none*

**Output:**

(2, 2)

**Time Complexity : **O(1)

Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the **DSA Self Paced Course** at a student-friendly price and become industry ready.

## Recommended Posts:

- Rotate a Matrix by 180 degree
- Rotation of a point about another point in C++
- Reflection of a point about a line in C++
- Program to Convert Radian to Degree
- Program to convert temperature from degree Celsius to Kelvin
- Check if a line at 45 degree can divide the plane into two equal weight parts
- Make a tree with n vertices , d diameter and at most vertex degree k
- Find if a degree sequence can form a simple graph | Havel-Hakimi Algorithm
- Program to convert Degree to Radian
- Find determinant of matrix generated by array rotation
- Minimum number of flips with rotation to make binary string alternating
- Longest subsequence of a number having same left and right rotation
- Check if a number is a power of another number
- Check if a number is divisible by all prime divisors of another number
- Number of visible boxes after putting one inside another
- Find if a string starts and ends with another given string
- Find ΔX which is added to numerator and denominator both of fraction (a/b) to convert it to another fraction (c/d)
- Check if permutaion of one string can break permutation of another
- GCD of a number raised to some power and another number
- Sum of elements in an array whose difference with the mean of another array is less than k

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.