- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- 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 mirror image of a point in 2-D plane in C++
In this problem, we are given a point P in a 2-D plane and the points a, b, c of the equation ax + by + c = 0. Our task is to find a mirror image of a point in 2-D plane.
Let’s take an example to understand the problem,
Input
P = (2, 1), a = 1, b = -1, c = 0
Output
(1, 2)
Explanation
The plane looks like,
Solution Approach
To solve the problem, we need to find the equation point P' with coordinates (x', y'). So, we have R, the midpoint where the line form P - P' intersects the mirror line.
The line P-R-P' is perpendicular to the mirror. Hence, the equation of line will be,
ay - by + d = 0
The points are P(x, y) ; P'(x', y') ; R(xm, ym).
The points P and R are known. So, using the equations we will find P’ as,
$$\left(\frac{??'-??}{??}\right)=\left(\frac{??'-??}{??}\right)=\left(\frac{????-????+??}{??^2+x^2}\right)$$
Program to illustrate the working of our solution,
Example
#include <iostream> using namespace std; void findMirrorImage( double a, double b, double c, double x, double y){ double points = -2 * (a * x + b * y + c) / (a * a + b * b); double xm = points * a + x; double ym = points * b + y; cout<<"("<<xm<<","<<ym<<")"; } int main(){ double a = -1.0; double b = 1.0; double c = 0.0; double x = 1.0; double y = 0.0; cout<<"Image of point ("<<x<<", "<<y<<") using mirror ("<<a<<")x + ("<<b<<")y + ("<<c<< ") = 0, is :"; findMirrorImage(a, b, c, x, y); return 0; }
Output
Image of point (1, 0) using mirror (-1)x + (1)y + (0) = 0, is :(0,1)
- Related Articles
- The mirror which can form a magnified image of an object is:(a) convex mirror (b) plane mirror (c) concave mirror (d) both convex and concave mirror
- With the help of a labelled ray-diagram, describe how a plane mirror forms an image of a point source of light placed in front of it. State the characteristics of the image formed in a plane mirror.
- Which mirror can produce a virtual, erect, and magnified image of an object?(a) Concave mirror(b) Convex mirror(c) Plane mirror(d) Both concave and convex mirror
- Explain the characteristics of Image formed by a Plane Mirror"."
- A perging mirror is:(a) a plane mirror (b) a convex mirror (c) a concave mirror (d) a shaving mirror
- The image of an object formed by a plane mirror is:(a) virtual (b) real (c) diminished (d) upside-down
- State the characteristics of the image formed by a plane mirror.
- Boojho and Paheli were given one mirror each by their teacher. Boojho found his image to be erect and of the same size whereas Paheli found her image erect and smaller in size. This means that the mirrors of Boojho and Paheli are, respectively$(a)$. plane mirror and concave mirror.$(b)$. concave mirror and convex mirror.$(c)$. plane mirror and convex mirror.$(d)$. convex mirror and plane mirror.
- What are the characteristics of an image formed on a plane mirror?
- Which of the following can be used to form a real image?$(a)$. Concave mirror only.$(b)$. Plane mirror only.$(c)$. Convex mirror only.$(d)$. Both concave and convex mirrors.
- What type of image is formed:(a) in a plane mirror?(b) on a cinema screen?
- Explain why, though both a plane mirror and a sheet of paper reflect light but we can see the image of our face in a plane mirror but not in a sheet of paper.The image in a plane mirror is virtual and laterally inverted. What does this statement mean?Write all the capital letters of the alphabet which look the same in a plane mirror.
- An erect and enlarged image can be formed by$(a)$. only a convex mirror.$(b)$. only a concave mirror.$(c)$. only a plane mirror.$(d)$. both convex and concave mirrors.
- Find foot of perpendicular from a point in 2D plane to a Line in C++
- Find the mirror image of the point $( 4, 5)$ along $x-axis$.
