यह रेखा और बिंदु के द्वैत परिवर्तन को दिखाने के लिए एक C++ प्रोग्राम है। तो इसके दो मामले हो सकते हैं -
मामला-1: एक बिंदु (a, b) को रेखा (y =ax - b) में बदल दिया जाता है।
केस-2: एक रेखा D(y =cx + d) बिंदु D'(c, −d) में बदल जाती है।
कार्य और छद्म कोड
फंक्शन लाइनट्रांसफॉर्मेशन(डबल सी, डबल डी)
Print C: (d / c) D: (d * -1)
फ़ंक्शन पॉइंट ट्रांसफ़ॉर्मेशन (डबल x, डबल y)
Print a = (-1 * y / x) b = (-1 * y)
उदाहरण
#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;
}
} आउटपुट
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