- Related Questions & Answers
- Program to find the Area of a Parallelogram in C++
- Find all possible outcomes of a given expression in C++
- Find minimum area of rectangle with given set of coordinates in C++
- Find coordinates of the triangle given midpoint of each side in C++
- C Program for Circumference of a Parallelogram
- Sum of XOR of all possible subsets in C++
- Find area of parallelogram if vectors of two adjacent sides are given using C++.
- Find the other-end coordinates of diameter in a circler in C++
- Area of a triangle inside a parallelogram in C++
- Sum of the products of all possible Subsets in C++
- C++ program to find whether only two parallel lines contain all coordinates points or not
- How to find all possible permutations of a given string in Python?
- Program to find maximum possible population of all the cities in python
- All Possible Full Binary Trees in C++
- How to find the coordinates of the cursor with JavaScript?

- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who

Find the all of the possible coordinates from the given three coordinates to make e parallelogram of a non-zero area. Suppose A, B, C are three given points we can have only three possible situations.

- AB, AC are sides, and BC is diagonal
- AB, BC are sides, and AC is diagonal
- BC, AC are sides, and AB is diagonal

So we can say that only three coordinates are possible, from which we can generate a parallelogram, if three coordinates are given. Since the opposite sides are equal, then AD = BC, and AB = CD, we will calculate the coordinate of the missing points D like below −

(Dx-Ax,Dy-Ay) = (Cx-Bx,Cy-By) Dx = Ax+Cx-Bx Dy = Ay+Cy-By

#include<iostream> using namespace std; void printPoints(int ax, int ay, int bx, int by, int cx, int cy){ cout << ax + bx - cx << ", " << ay + by - cy <<endl; cout << ax + cx - bx << ", " << ay + cy - by <<endl; cout << cx + bx - ax << ", " << cy + by - ax <<endl; } 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 printPoints(ax, ay, bx, by, cx, cy); }

4, -4 6, 4 -2, 1

Advertisements