Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include<math.h>
- struct point {
- double x;
- double y;
- };
- main()
- {
- int speed = 20;
- double defender_position_x = 0;
- double defender_position_y = 60;
- struct point target_position[15];
- struct point defender_position[15];
- //defender_position
- FILE *myFile;
- myFile = fopen("Point.txt", "r");
- int i;
- for (i = 0; i < 15; i++)
- {
- fscanf(myFile, "%lf %lf", &target_position[i].x , &target_position[i].y );
- }
- for (i = 0; i < 15; i++)
- {
- printf("Number is: %lf %lf\n\n", target_position[i].x, target_position[i].y);
- }
- for (int t=0; t<12; t++){
- double distance = sqrt((((target_position[t].x - defender_position_x)*(target_position[t].x - defender_position_x)) + (target_position[t].y - defender_position_y)*target_position[t].y - defender_position_y));
- double sin = ((target_position[t].y) - (defender_position_y)) / distance;
- double cos = ((target_position[t].x) - (defender_position_x)) / distance;
- printf("distance: %lf" , distance);
- }
- }
Add Comment
Please, Sign In to add comment