Please note, this is a STATIC archive of website www.tutorialspoint.com from 11 May 2019, cach3.com does not collect or store any user information, there is no "phishing" involved.
Tutorialspoint

1 Answer
Anvi Jain

This is a C++ Program to show the Duality Transformation of Line and Point. So it can have two cases −

Case-1: A point (a, b) is transformed to the line (y = ax − b).

Case-2: A line D(y = cx + d) is transformed to the point D’(c, −d).

Functions and pseudocodes

Function LineTransformation(double c, double d)

Print C: (d / c)
D: (d * -1)

Function PointTransformation(double x, double y)

Print a = (-1 * y / x)
b = (-1 * y)

Example

#include <iostream>
#include <time.h>
#include <stdlib.h>
using namespace std;
void LineTransformation(double c, double d) {
   cout << "C: " << (d / c) << ", D: " << (d * -1);
}
void PointTransformation(double x, double y) {
   cout << "y=" << (-1 * y / x) << "x +" << (-1 * y);
}
int main(int argc, char **argv) {
   cout << "\n1. Line Transformation\n2. Point Transformation";
   int c;
   cin >> c;
   switch (c) {
      case 1:
         cout << "Enter the coefficients of line y=ax-b:";
         double a, b;
         cin >> a >> b;
         LineTransformation(a, b);
         break;
      case 2:
         cout << "Enter the coordinate of point <a, b>";
         double x, y;
         cin >> x >> y;
         PointTransformation(x, y);
         break;
      default:
         break;
   }
}

Output

1. Line Transformation
2. Point Transformation
1
Enter the coefficients of line y=ax-b:
1
2
C: 2, D: -2

1. Line Transformation
2. Point Transformation
2
Enter the coordinate of point <a, b>
1
2
y=-2x +-2

Advertisements

We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy.