- 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

# Finding reflection of a point relative to another point in JavaScript

## Point Of Symmetry

"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.

## Problem

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.

## Example

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));

## Output

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
- C++ Program to find out the moves to read a point from another point in a 2D plane
- 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 the Point-to-Point Tunneling Protocol(PPTP)?
- 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
- Differentiate between accounting breakeven point and financial breakeven point.
- Working Principle of a Three-Point Starter
- Difference between Point-To-Point and Publish/Subscribe JMS Messaging Models

Advertisements