C++ Programming Articles

Submit Article
Home » Articles » C++ Programming » Computer GraphicsRSS Feeds

Program of reflection on any line

Posted By: Easy Tutor     Category: C++ Programming     Views: 19960

Write a program of reflection on any line.

Code for Program of reflection on any line in C++ Programming

# include <iostream.h>
# include <conio.h>
# include <graphics.h>
# include <math.h>

char IncFlag;
int PolygonPoints[3][2] =

int x1=10;
int y1=10;
int x2=100;
int y2=100;

void PolyLine()
    int iCnt;
    for (iCnt=0; iCnt<3; iCnt++)
void Reflect()
    float Angle,Slope,Hx,Hy,B;
    int iCnt;
    int Tx,Ty;

    Angle = atan((y2-y1)/(x2-x1));
    Angle *= (M_PI)/180.0;

    Slope = tan(Angle);
    B = y2 - x2*Slope;

    Hx = -B*sin(2.0 * Angle);
    Hy = B*(cos(2.0 * Angle)+1);

    for (iCnt=0; iCnt<3; iCnt++)
        Tx = PolygonPoints[iCnt][0];
        Ty = PolygonPoints[iCnt][1];

        PolygonPoints[iCnt][0] = Tx*cos(2.0*Angle);
            + Ty*sin(2.0*Angle) + Hx;

        PolygonPoints[iCnt][0] = Tx*sin(2.0*Angle);
            - Ty*cos(2.0*Angle) + Hy;

void main()
    int gDriver = DETECT, gMode;
    int iCnt;
    initgraph(&gDriver, &gMode, "C:\\TC\\BGI");
    for (iCnt=0; iCnt<3; iCnt++)
        PolygonPoints[iCnt][0] += 320;
        PolygonPoints[iCnt][1] = 240 - PolygonPoints[iCnt][1];

Didn't find what you were looking for? Find more on Program of reflection on any line Or get search suggestion and latest updates.

Easy Tutor
Easy Tutor author of Program of reflection on any line is from United States. Easy Tutor says

Hello Friends,

I am Free Lance Tutor, who helped student in completing their homework.

I have 4 Years of hands on experience on helping student in completing their homework. I also guide them in doing their final year projects.

I have share many programs on this website for everyone to use freely, if you need further assistance, than please contact me on easytutor.2ya [at the rate] gmail [dot] com

I have special discount scheme for providing tutor services. I am providing tutor service to students from various contries, currently most of my students are from United States, India, Australia, Pakistan, Germany, UK and Canada.

I am also here to expand my technical network to receive more opportunity in my career, make friends to help them in resolving their technical problem, learn and share my knowledge, If you like to be my friend, Please send me friend request.

Happy Programming :)

View All Articles

Related Articles and Code:


Other Interesting Articles in C++ Programming:

Please enter your Comment

  • Comment should be atleast 30 Characters.
  • Please put code inside [Code] your code [/Code].

No Comment Found, Be the First to post comment!