fork download
  1. #include <stdio.h>
  2. #include <math.h>
  3.  
  4. #define PI 3.14159265
  5.  
  6. void rotatePoint(float *x, float *y, float angle) {
  7. // Convert angle from degrees to radians
  8. float rad = angle * (PI / 180.0);
  9.  
  10. // Rotation matrix
  11. float x_new = *x * cos(rad) - *y * sin(rad);
  12. float y_new = *x * sin(rad) + *y * cos(rad);
  13.  
  14. *x = x_new;
  15. *y = y_new;
  16. }
  17.  
  18. int main() {
  19. float x, y, angle;
  20.  
  21. // Input original point coordinates
  22. printf("Enter the x coordinate of the point: ");
  23. scanf("%f", &x);
  24. printf("Enter the y coordinate of the point: ");
  25. scanf("%f", &y);
  26.  
  27. // Input rotation angle
  28. printf("Enter the rotation angle (in degrees): ");
  29. scanf("%f", &angle);
  30.  
  31. // Rotate the point
  32. rotatePoint(&x, &y, angle);
  33.  
  34. // Display the new coordinates
  35. printf("New coordinates after rotation: (%.2f, %.2f)\n", x, y);
  36.  
  37. return 0;
  38. }
Success #stdin #stdout 0s 5284KB
stdin
Standard input is empty
stdout
Enter the x coordinate of the point: Enter the y coordinate of the point: Enter the rotation angle (in degrees): New coordinates after rotation: (0.00, 0.00)