선과 점의 이중성 변환을 보여주는 C++ 프로그램입니다. 따라서 두 가지 경우가 있을 수 있습니다. -
사례-1: 점(a, b)을 직선(y =ax − b)으로 변환합니다.
사례 2: 선 D(y =cx + d)는 점 D'(c, -d)로 변환됩니다.
함수 및 의사코드
함수 LineTransformation(더블 c, 더블 d)
Print C: (d / c) D: (d * -1)
함수 PointTransformation(더블 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의 좌표를 입력합니다.