|
| 1 | +#include <stdio.h> |
| 2 | +#include <stdlib.h> |
| 3 | +#include <math.h> |
| 4 | +#include <string.h> |
| 5 | + |
| 6 | +#define MaxN 2001 |
| 7 | +#define resolution 1024 |
| 8 | +#define DEBUG 1 |
| 9 | + |
| 10 | + |
| 11 | +long A[MaxN*MaxN]; |
| 12 | +long P1[MaxN*MaxN], P2[MaxN*MaxN]; |
| 13 | +long Test[MaxN]; |
| 14 | + |
| 15 | +FILE* SaSOHO; |
| 16 | +FILE* Presek1; |
| 17 | +FILE* Presek2; |
| 18 | +FILE* TestingOutput; |
| 19 | +FILE* DebugText; |
| 20 | +FILE* Presek1Ispis; |
| 21 | +FILE* Presek2Ispis; |
| 22 | + |
| 23 | +int main(){ |
| 24 | + |
| 25 | + Presek1 = fopen("Trenutak1.txt", "r"); |
| 26 | + Presek2 = fopen("Trenutak2.txt", "r"); |
| 27 | + Presek1Ispis = fopen("Presek1Ispis.txt", "w"); |
| 28 | + Presek2Ispis = fopen("Presek2Ispis.txt", "w"); |
| 29 | + SaSOHO = fopen("SaSOHO.txt", "r"); |
| 30 | + TestingOutput = fopen("TestingOutput_Beta06.txt", "w"); /**Od najvece dimenzije do najmanje 3-0 {0.05, 0.5, 0.6, 1}*/ |
| 31 | + DebugText = fopen("Debug.txt", "w"); |
| 32 | + double foo, xi, yi, Testx, Testy, x,y, MinX, MinY, MaxX, MaxY, binstep, binstepP1; |
| 33 | + long i,j; |
| 34 | + char input[256]; |
| 35 | + |
| 36 | + MaxX = 17; MaxY = 17; |
| 37 | + MinX = -17; MinY = -17; /** [stepeni] Vrednost celog vidnog polja sa Suncem u Centru, Sekanin rad za velicinu piksela(Uzeo sam kameru C3)*/ |
| 38 | + memset(Test, sizeof(Test), 0); |
| 39 | + memset(A, sizeof(A), 0); |
| 40 | + binstep = (MaxX-MinX)/resolution; /**Kamera C3 ima 1024*1024 piksela*/ |
| 41 | + |
| 42 | + if(DEBUG) printf("%lf\n", binstep); |
| 43 | + |
| 44 | + /*for(i=0; i<10; i++){ |
| 45 | + /*fgets(input, sizeof input, Testing); |
| 46 | + sscanf(input, "%lf %lf", &Testx, &Testy); |
| 47 | + scanf("%lf%lf", &Testx, &Testy); |
| 48 | + printf("%lf\t%ld\t%lf\t%ld\n", fabs(Testx)/binstep, lround(fabs(Testx)/binstep), fabs(Testy)/binstep, lround(fabs(Testy)/binstep)); |
| 49 | + printf("1: %ld\n", lround(fabs(Testx)/binstep) + lround(fabs(Testy)/binstep)*10); |
| 50 | + Test[lround(fabs(Testx)/binstep) + lround(fabs(Testy)/binstep)*10]++; |
| 51 | + } |
| 52 | +
|
| 53 | + for(i=0; i<10; i++) |
| 54 | + for(j=0; j<10; j++){ |
| 55 | + if(j==9) printf("%ld\n", Test[i+j*10]); |
| 56 | + else printf("%ld ", Test[i+j*10]); |
| 57 | + }*/ |
| 58 | + |
| 59 | + while(!feof(SaSOHO)){ |
| 60 | + fgets(input, sizeof input, SaSOHO); |
| 61 | + sscanf(input, "%lf %lf", &x, &y); |
| 62 | + // if(DEBUG) printf("Ok: %ld %ld %ld\n", A[lround(fabs(x)/binstep) + lround((fabs(y)/binstep))*2000], lround(fabs(x)/binstep) + lround((fabs(y)/binstep))*2000, i); |
| 63 | + if(x<0) xi = MaxX - fabs(x); |
| 64 | + else |
| 65 | + if(x>0) xi = MaxX+x; |
| 66 | + else xi = x; |
| 67 | + if(y<0) yi = MaxY+fabs(y); |
| 68 | + else |
| 69 | + if(y>0) yi = MaxY - y; |
| 70 | + else yi = y; |
| 71 | + A[lround(xi/binstep) + lround(yi/binstep)*resolution]++; |
| 72 | + // if(DEBUG) printf("Ok: %ld %ld %ld\n", A[lround(fabs(x)/binstep) + lround((fabs(y)/binstep))*2000], lround(fabs(x)/binstep) + lround((fabs(y)/binstep))*2000, i); |
| 73 | + } |
| 74 | + |
| 75 | + |
| 76 | + for(i=0; i<resolution*resolution; i++){ |
| 77 | + if(i%resolution==0) fprintf(TestingOutput, "%ld\n", A[i]); |
| 78 | + else fprintf(TestingOutput, "%ld\t", A[i]); |
| 79 | + } |
| 80 | + |
| 81 | + /** Presek 1 */ |
| 82 | + |
| 83 | + memset(input, sizeof input, 0); |
| 84 | + memset(P1, sizeof P1, 0); |
| 85 | + double MaxXP1, MinXP1, MaxYP1, MinYP1; |
| 86 | + double binstepP1X, binstepP1Y; |
| 87 | + |
| 88 | + MaxXP1 = -100; MaxYP1 = -100; |
| 89 | + MinXP1 = 100; MinYP1 = 100; |
| 90 | + |
| 91 | + while(!feof(Presek1)){ |
| 92 | + fgets(input, sizeof input, Presek1); |
| 93 | + sscanf(input, "%lf %lf %lf", &foo, &x, &y); |
| 94 | + if(MaxXP1<fabs(x)) MaxXP1 = fabs(x); |
| 95 | + if(MaxYP1<fabs(y)) MaxYP1 = fabs(y); |
| 96 | + if(MinXP1>fabs(x)) MinXP1 = fabs(x); |
| 97 | + if(MinYP1>fabs(y)) MinYP1 = fabs(y); |
| 98 | + } |
| 99 | + |
| 100 | + binstepP1X = (fabs(MaxXP1)-fabs(MinXP1))/resolution; |
| 101 | + binstepP1Y = (fabs(MaxYP1)-fabs(MinYP1))/resolution; |
| 102 | + if(DEBUG) printf("%.10lf %lf %lf %lf %lf %lf %lf %lf\n", binstepP1X, fabs(MaxXP1)-fabs(MinXP1), (fabs(MaxYP1) - fabs(MinYP1))/binstepP1X, (fabs(MaxXP1)-fabs(MinXP1))/binstepP1Y, MaxXP1, MaxYP1, MinXP1, MinYP1); |
| 103 | + rewind(Presek1); |
| 104 | + |
| 105 | + |
| 106 | + i=0; |
| 107 | + while(!feof(Presek1)){ |
| 108 | + fgets(input, sizeof input, Presek1); |
| 109 | + sscanf(input, "%lf %lf %lf", &foo, &x, &y); |
| 110 | + P1[lround((fabs(x)-fabs(MinXP1))/binstepP1X) + lround((fabs(y)-fabs(MinYP1))/binstepP1Y)*resolution]++; |
| 111 | + } |
| 112 | + |
| 113 | + for(i=0; i<resolution*resolution; i++) |
| 114 | + if(i%resolution==0) fprintf(Presek1Ispis, "%ld\n", P1[i]); |
| 115 | + else fprintf(Presek1Ispis, "%ld\t", P1[i]); |
| 116 | + |
| 117 | + /** Presek 2*/ |
| 118 | + |
| 119 | + memset(input, sizeof input, 0); |
| 120 | + memset(P2, sizeof P2, 0); |
| 121 | + double MaxXP2, MinXP2, MaxYP2, MinYP2; |
| 122 | + double binstepP2X, binstepP2Y; |
| 123 | + |
| 124 | + MaxXP2 = -100; MaxYP2 = -100; |
| 125 | + MinXP2 = 100; MinYP2 = 100; |
| 126 | + |
| 127 | + while(!feof(Presek2)){ |
| 128 | + fgets(input, sizeof input, Presek2); |
| 129 | + sscanf(input, "%lf %lf %lf", &foo, &x, &y); |
| 130 | + if(MaxXP2<fabs(x)) MaxXP2 = fabs(x); |
| 131 | + if(MaxYP2<fabs(y)) MaxYP2 = fabs(y); |
| 132 | + if(MinXP2>fabs(x)) MinXP2 = fabs(x); |
| 133 | + if(MinYP2>fabs(y)) MinYP2 = fabs(y); |
| 134 | + } |
| 135 | + |
| 136 | + if(DEBUG) printf("%lf %lf %lf %lf\n", MaxXP2, MinXP2, MaxYP2, MinYP2); |
| 137 | + |
| 138 | + binstepP2X = (fabs(MaxXP2)-fabs(MinXP2))/resolution; |
| 139 | + binstepP2Y = (fabs(MaxYP2)-fabs(MinYP2))/resolution; |
| 140 | + if(DEBUG) printf("%.10lf %lf %lf %lf %lf %lf %lf %lf\n", binstepP2X, fabs(MaxXP2)-fabs(MinXP2), (fabs(MaxYP2) - fabs(MinYP2))/binstepP2X, (fabs(MaxXP2)-fabs(MinXP2))/binstepP2Y, MaxXP2, MaxYP2, MinXP2, MinYP2); |
| 141 | + |
| 142 | + rewind(Presek2); |
| 143 | + |
| 144 | + while(!feof(Presek2)){ |
| 145 | + fgets(input, sizeof input, Presek2); |
| 146 | + sscanf(input, "%lf %lf %lf", &foo, &x, &y); |
| 147 | + P2[lround((fabs(x)-fabs(MinXP2))/binstepP2X) + lround((fabs(y)-fabs(MinYP2))/binstepP2Y)*resolution]++; |
| 148 | + } |
| 149 | + |
| 150 | + for(i=0; i<resolution*resolution; i++) |
| 151 | + if(i%resolution==0) fprintf(Presek2Ispis, "%ld\n", P2[i]); |
| 152 | + else fprintf(Presek2Ispis, "%ld\t", P2[i]); |
| 153 | + |
| 154 | + fclose(SaSOHO); |
| 155 | + fclose(Presek1Ispis); |
| 156 | + fclose(Presek1); |
| 157 | + fclose(Presek2); |
| 158 | + fclose(DebugText); |
| 159 | + fclose(TestingOutput); |
| 160 | + return 0; |
| 161 | +} |
0 commit comments