- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP

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

"Point reflection" or "point symmetry" is a basic concept in geometry where a given point, P, at a given position relative to a midpoint, Q has a corresponding point, P1, which is the same distance from Q but in the opposite direction.

We are required to write a JavaScript function that takes in two objects P and Q specifying two points in a 2-D plane.

Our function should output the symmetric point of point P about Q.

Following is the code −

const p = { x: 6, y: -4 }; const q = { x: 11, y: 5 }; const findReflection = (p = {}, q = {}) => { const res = {}; const Xdistance = p['x'] - q['x']; res['x'] = q['x'] - Xdistance; let Ydistance = p['y'] - q['y']; res['y'] = q['y'] - Ydistance; return res; }; console.log(findReflection(p, q));

Following is the console output −

{ x: 16, y: 14 }

- Related Questions & Answers
- Rotation of a point about another point in C++
- Android image scale animation relative to center point?
- Point-to-Point Protocol (PPP)
- Difference between Point-to-Point and Multi-point Communication
- What is Point-to-Point Protocol (PPP)?
- How to create a point chart with point size increment based on the position of the point in R?
- Fixed Point and Floating Point Number Representations
- What is Point to Point Protocol (PPP) in Computer Network?
- Decimal fixed point and floating point arithmetic in Python
- Counting numbers after decimal point in JavaScript
- Working Principle of a Three-Point Starter
- Differentiate between accounting breakeven point and financial breakeven point.
- Difference between Point-To-Point and Publish/Subscribe JMS Messaging Models
- How to convert a string to a floating point number in JavaScript?
- Find the Number of Ways to go From One Point to Another in a Grid using C++

Advertisements