This is a C Program to show the duality transformation of line and point. The transformation corresponds from line to point and point to line.
Here is source code of the C Program to Show the Duality Transformation of Line and Point. The C program is successfully compiled and run on a Linux system. The program output is also shown below.
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
void performLineTransformation(double a, double b) {
printf("X: %lf, Y: %lf", (b / a), (b * -1));
}
void performPointTransformation(double x, double y) {
printf("y=%lfx + %lf", (-1 * y / x), (-1 * y));
}
int main(int argc, char **argv) {
printf("Perform what transformation.\n1. Line Transformation\n2. Point Transformation");
int option;
scanf("%d", &option);
switch (option) {
case 1:
printf("Enter the coefficients of line <y=ax-b>");
double a, b;
scanf("%lf", &a);
scanf("%lf", &b);
performLineTransformation(a, b);
break;
case 2:
printf("Enter the coordinate of point <x, y>");
double x, y;
scanf("%lf", &x);
scanf("%lf", &y);
performPointTransformation(x, y);
break;
default:
break;
}
return 0;
}
Output:
$ gcc DualityTransform.c $ ./a.out Perform what transformation. 1. Line Transformation 2. Point Transformation 1 Enter the coefficients of line <y=ax-b>: 1 2 3 X: 2.000000, Y: -2.000000
Sanfoundry Global Education & Learning Series – 1000 C Programs.
advertisement
advertisement
Here’s the list of Best Books in C Programming, Data Structures and Algorithms.
If you find any mistake above, kindly email to [email protected]Related Posts:
- Apply for Computer Science Internship
- Check Computer Science Books
- Practice Computer Science MCQs
- Practice BCA MCQs
- Apply for C Internship