Dependencies: DMSupport DMemWin
embedded/MATH1.cpp@0:08606a13a816, 2016-06-02 (annotated)
- Committer:
- destinyXfate
- Date:
- Thu Jun 02 05:04:57 2016 +0000
- Revision:
- 0:08606a13a816
;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
destinyXfate | 0:08606a13a816 | 1 | #include "MATH1.h" |
destinyXfate | 0:08606a13a816 | 2 | #define pi 3.14159265359 |
destinyXfate | 0:08606a13a816 | 3 | double mean(double *d, int len) |
destinyXfate | 0:08606a13a816 | 4 | { |
destinyXfate | 0:08606a13a816 | 5 | double mean = 0.0; |
destinyXfate | 0:08606a13a816 | 6 | double sum = 0.0; |
destinyXfate | 0:08606a13a816 | 7 | |
destinyXfate | 0:08606a13a816 | 8 | for(int i = 0 ; i<len ; i++) { |
destinyXfate | 0:08606a13a816 | 9 | sum += d[i]; |
destinyXfate | 0:08606a13a816 | 10 | } |
destinyXfate | 0:08606a13a816 | 11 | |
destinyXfate | 0:08606a13a816 | 12 | mean = sum / len ; |
destinyXfate | 0:08606a13a816 | 13 | return mean; |
destinyXfate | 0:08606a13a816 | 14 | } |
destinyXfate | 0:08606a13a816 | 15 | |
destinyXfate | 0:08606a13a816 | 16 | double MAXof3(double one, double two, double three) |
destinyXfate | 0:08606a13a816 | 17 | { |
destinyXfate | 0:08606a13a816 | 18 | double MAXMAX = one; |
destinyXfate | 0:08606a13a816 | 19 | double yoyoyo[2]= {two, three}; |
destinyXfate | 0:08606a13a816 | 20 | for(int i = 0; i<2 ; i++) { |
destinyXfate | 0:08606a13a816 | 21 | if(yoyoyo[i]>MAXMAX) { |
destinyXfate | 0:08606a13a816 | 22 | MAXMAX = yoyoyo[i]; |
destinyXfate | 0:08606a13a816 | 23 | } |
destinyXfate | 0:08606a13a816 | 24 | } |
destinyXfate | 0:08606a13a816 | 25 | return MAXMAX; |
destinyXfate | 0:08606a13a816 | 26 | } |
destinyXfate | 0:08606a13a816 | 27 | |
destinyXfate | 0:08606a13a816 | 28 | ///square/// |
destinyXfate | 0:08606a13a816 | 29 | double MATH::sqr(double value) |
destinyXfate | 0:08606a13a816 | 30 | { |
destinyXfate | 0:08606a13a816 | 31 | double sqrvalue = value * value; |
destinyXfate | 0:08606a13a816 | 32 | return sqrvalue; |
destinyXfate | 0:08606a13a816 | 33 | } |
destinyXfate | 0:08606a13a816 | 34 | |
destinyXfate | 0:08606a13a816 | 35 | |
destinyXfate | 0:08606a13a816 | 36 | ///line voltage RMS/// |
destinyXfate | 0:08606a13a816 | 37 | double MATH::LVRMS(double* d1, double* d2, uint16_t len) |
destinyXfate | 0:08606a13a816 | 38 | { |
destinyXfate | 0:08606a13a816 | 39 | double sum = 0.0; |
destinyXfate | 0:08606a13a816 | 40 | for (int i = 0; i < len; i++) { |
destinyXfate | 0:08606a13a816 | 41 | sum += sqr((d1[i]-d2[i])); |
destinyXfate | 0:08606a13a816 | 42 | } |
destinyXfate | 0:08606a13a816 | 43 | double RMS = sqrt(sum/len); |
destinyXfate | 0:08606a13a816 | 44 | return RMS; |
destinyXfate | 0:08606a13a816 | 45 | } |
destinyXfate | 0:08606a13a816 | 46 | |
destinyXfate | 0:08606a13a816 | 47 | ///RMS/// |
destinyXfate | 0:08606a13a816 | 48 | double MATH::RMS(double* d, uint16_t len) |
destinyXfate | 0:08606a13a816 | 49 | { |
destinyXfate | 0:08606a13a816 | 50 | double sum = 0.0; |
destinyXfate | 0:08606a13a816 | 51 | for (int i = 0; i < len; i++) { |
destinyXfate | 0:08606a13a816 | 52 | sum += d[i]*d[i]; |
destinyXfate | 0:08606a13a816 | 53 | } |
destinyXfate | 0:08606a13a816 | 54 | double rms = sqrt(sum/len)*1.0; |
destinyXfate | 0:08606a13a816 | 55 | return rms; |
destinyXfate | 0:08606a13a816 | 56 | } |
destinyXfate | 0:08606a13a816 | 57 | |
destinyXfate | 0:08606a13a816 | 58 | |
destinyXfate | 0:08606a13a816 | 59 | ///unbalance rate/// |
destinyXfate | 0:08606a13a816 | 60 | double MATH::UR(double d1, double d2, double d3) |
destinyXfate | 0:08606a13a816 | 61 | { |
destinyXfate | 0:08606a13a816 | 62 | double abc_avg = (d1+d2+d3) / 3.0; |
destinyXfate | 0:08606a13a816 | 63 | double x[3] = {fabs(d1 - abc_avg), fabs(d2 - abc_avg), fabs(d3 - abc_avg)}; |
destinyXfate | 0:08606a13a816 | 64 | double dmax = 0.0; |
destinyXfate | 0:08606a13a816 | 65 | for(int i=0 ; i<3 ; i++) { |
destinyXfate | 0:08606a13a816 | 66 | if(x[i]>dmax) { |
destinyXfate | 0:08606a13a816 | 67 | dmax=x[i]; |
destinyXfate | 0:08606a13a816 | 68 | } |
destinyXfate | 0:08606a13a816 | 69 | } |
destinyXfate | 0:08606a13a816 | 70 | double URv = dmax / abc_avg * 100.0; |
destinyXfate | 0:08606a13a816 | 71 | return URv; |
destinyXfate | 0:08606a13a816 | 72 | } |
destinyXfate | 0:08606a13a816 | 73 | |
destinyXfate | 0:08606a13a816 | 74 | |
destinyXfate | 0:08606a13a816 | 75 | ///angle(rad)/// |
destinyXfate | 0:08606a13a816 | 76 | double MATH::angle(double d1, double d2) |
destinyXfate | 0:08606a13a816 | 77 | { |
destinyXfate | 0:08606a13a816 | 78 | |
destinyXfate | 0:08606a13a816 | 79 | double sqrt_2 = sqrt(2.0); |
destinyXfate | 0:08606a13a816 | 80 | if (d1 > 0.0 ) { |
destinyXfate | 0:08606a13a816 | 81 | if(d2 > 0.0) { |
destinyXfate | 0:08606a13a816 | 82 | double rad = fabs(atan(d2 / d1)); |
destinyXfate | 0:08606a13a816 | 83 | return (0.0 + rad); |
destinyXfate | 0:08606a13a816 | 84 | } else { |
destinyXfate | 0:08606a13a816 | 85 | double rad = fabs(atan(d2 / d1)); |
destinyXfate | 0:08606a13a816 | 86 | return (0.0 - rad); |
destinyXfate | 0:08606a13a816 | 87 | } |
destinyXfate | 0:08606a13a816 | 88 | } else { |
destinyXfate | 0:08606a13a816 | 89 | if(d2 > 0.0) { |
destinyXfate | 0:08606a13a816 | 90 | double rad = fabs(atan(d2 / d1)); |
destinyXfate | 0:08606a13a816 | 91 | return (pi - rad); |
destinyXfate | 0:08606a13a816 | 92 | } else { |
destinyXfate | 0:08606a13a816 | 93 | double rad = fabs(atan(d2 / d1)); |
destinyXfate | 0:08606a13a816 | 94 | return (pi + rad); |
destinyXfate | 0:08606a13a816 | 95 | } |
destinyXfate | 0:08606a13a816 | 96 | } |
destinyXfate | 0:08606a13a816 | 97 | } |
destinyXfate | 0:08606a13a816 | 98 | |
destinyXfate | 0:08606a13a816 | 99 | ///Unbalance Factor/// |
destinyXfate | 0:08606a13a816 | 100 | double MATH::UF(double rms_a, double rms_b, double rms_c, double angle_a, double angle_b, double angle_c) |
destinyXfate | 0:08606a13a816 | 101 | { |
destinyXfate | 0:08606a13a816 | 102 | double a = 120.0 * pi / 180 ; /// degree -> rad |
destinyXfate | 0:08606a13a816 | 103 | double ang_v1_1 = angle_b + a*2.0 ; |
destinyXfate | 0:08606a13a816 | 104 | double ang_v1_2 = angle_c + a; |
destinyXfate | 0:08606a13a816 | 105 | double ang_v2_1 = angle_b + a; |
destinyXfate | 0:08606a13a816 | 106 | double ang_v2_2 = angle_c + a*2.0; |
destinyXfate | 0:08606a13a816 | 107 | |
destinyXfate | 0:08606a13a816 | 108 | double v1 = sqrt(sqr((rms_a * cos(angle_a)) + (rms_b * cos(ang_v1_1)) + (rms_c * cos(ang_v1_2))) |
destinyXfate | 0:08606a13a816 | 109 | + sqr((rms_a * sin(angle_a)) + (rms_b * sin(ang_v1_1)) + (rms_c * sin(ang_v1_2)))); |
destinyXfate | 0:08606a13a816 | 110 | double v2 = sqrt(sqr((rms_a * cos(angle_a)) + (rms_b * cos(ang_v2_1)) + (rms_c * cos(ang_v2_2))) |
destinyXfate | 0:08606a13a816 | 111 | + sqr((rms_a * sin(angle_a)) + (rms_b * sin(ang_v2_1)) + (rms_c * sin(ang_v2_2)))); |
destinyXfate | 0:08606a13a816 | 112 | |
destinyXfate | 0:08606a13a816 | 113 | return (v2/v1)*100.0 ; |
destinyXfate | 0:08606a13a816 | 114 | } |
destinyXfate | 0:08606a13a816 | 115 | |
destinyXfate | 0:08606a13a816 | 116 | ///DFT/// |
destinyXfate | 0:08606a13a816 | 117 | double MATH::doDFT(double *input, double *output, int N) |
destinyXfate | 0:08606a13a816 | 118 | { |
destinyXfate | 0:08606a13a816 | 119 | for (int i=0 ; i<N ; i++) { |
destinyXfate | 0:08606a13a816 | 120 | double re = 0; |
destinyXfate | 0:08606a13a816 | 121 | double im = 0; |
destinyXfate | 0:08606a13a816 | 122 | for(int j=0 ; j<N ; j++) { |
destinyXfate | 0:08606a13a816 | 123 | re += input[j]*cos(2*pi*i*j/N); |
destinyXfate | 0:08606a13a816 | 124 | im += input[j]*(-sin(2*pi*i*j/N)); |
destinyXfate | 0:08606a13a816 | 125 | } |
destinyXfate | 0:08606a13a816 | 126 | output[i] = sqrt(sqr(re) + sqr(im))/N; |
destinyXfate | 0:08606a13a816 | 127 | } |
destinyXfate | 0:08606a13a816 | 128 | return *output; |
destinyXfate | 0:08606a13a816 | 129 | |
destinyXfate | 0:08606a13a816 | 130 | } |
destinyXfate | 0:08606a13a816 | 131 | |
destinyXfate | 0:08606a13a816 | 132 | |
destinyXfate | 0:08606a13a816 | 133 | void MATH::integal(double *in, double *out, int len, int sps) |
destinyXfate | 0:08606a13a816 | 134 | { |
destinyXfate | 0:08606a13a816 | 135 | |
destinyXfate | 0:08606a13a816 | 136 | double t = 1.0 /sps ; |
destinyXfate | 0:08606a13a816 | 137 | double mean; |
destinyXfate | 0:08606a13a816 | 138 | double sum = 0.0; |
destinyXfate | 0:08606a13a816 | 139 | out[0] = 0 ; |
destinyXfate | 0:08606a13a816 | 140 | double v = 0; |
destinyXfate | 0:08606a13a816 | 141 | |
destinyXfate | 0:08606a13a816 | 142 | for(int i = 1 ; i < len ; i++) { |
destinyXfate | 0:08606a13a816 | 143 | v += ((in[i - 1] + in[i]) * t / 2.0); /// m/s --> *1000 mm/s --> *1000 *1000 um/s |
destinyXfate | 0:08606a13a816 | 144 | out[i] = v; |
destinyXfate | 0:08606a13a816 | 145 | } |
destinyXfate | 0:08606a13a816 | 146 | |
destinyXfate | 0:08606a13a816 | 147 | mean = mean(out, len); |
destinyXfate | 0:08606a13a816 | 148 | |
destinyXfate | 0:08606a13a816 | 149 | for(int i = 0 ; i<len ; i++) { |
destinyXfate | 0:08606a13a816 | 150 | out[i] = ( out[i] - mean ) * 1000; |
destinyXfate | 0:08606a13a816 | 151 | } |
destinyXfate | 0:08606a13a816 | 152 | |
destinyXfate | 0:08606a13a816 | 153 | |
destinyXfate | 0:08606a13a816 | 154 | } |
destinyXfate | 0:08606a13a816 | 155 | |
destinyXfate | 0:08606a13a816 | 156 | void MATH::detrend(double *y, int len, int sps) |
destinyXfate | 0:08606a13a816 | 157 | { |
destinyXfate | 0:08606a13a816 | 158 | int i; |
destinyXfate | 0:08606a13a816 | 159 | double t = 1.0 /sps ; |
destinyXfate | 0:08606a13a816 | 160 | |
destinyXfate | 0:08606a13a816 | 161 | double sum_k1 = 0.0, sum_k2 = 0.0, xbar = 0.0, ybar = 0.0; |
destinyXfate | 0:08606a13a816 | 162 | |
destinyXfate | 0:08606a13a816 | 163 | double *x, *d1, *d2; |
destinyXfate | 0:08606a13a816 | 164 | x = (double*) malloc(sizeof(double) * len); |
destinyXfate | 0:08606a13a816 | 165 | d1 = (double*) malloc(sizeof(double) * len); |
destinyXfate | 0:08606a13a816 | 166 | d2 = (double*) malloc(sizeof(double) * len); |
destinyXfate | 0:08606a13a816 | 167 | |
destinyXfate | 0:08606a13a816 | 168 | for(i=0 ; i<len ; i++) { |
destinyXfate | 0:08606a13a816 | 169 | x[i] = (i+1)*t; |
destinyXfate | 0:08606a13a816 | 170 | } |
destinyXfate | 0:08606a13a816 | 171 | |
destinyXfate | 0:08606a13a816 | 172 | xbar = mean(x, len); |
destinyXfate | 0:08606a13a816 | 173 | ybar = mean(y, len); |
destinyXfate | 0:08606a13a816 | 174 | |
destinyXfate | 0:08606a13a816 | 175 | for(i=0 ; i<len ; i++) { |
destinyXfate | 0:08606a13a816 | 176 | d1[i] = x[i]-xbar; |
destinyXfate | 0:08606a13a816 | 177 | d2[i] = y[i]-ybar; |
destinyXfate | 0:08606a13a816 | 178 | sum_k1 += d1[i]*d2[i]; |
destinyXfate | 0:08606a13a816 | 179 | sum_k2 += d1[i]*d1[i]; |
destinyXfate | 0:08606a13a816 | 180 | } |
destinyXfate | 0:08606a13a816 | 181 | |
destinyXfate | 0:08606a13a816 | 182 | double A,B; |
destinyXfate | 0:08606a13a816 | 183 | A = sum_k1/sum_k2; |
destinyXfate | 0:08606a13a816 | 184 | B = ybar-A*xbar; |
destinyXfate | 0:08606a13a816 | 185 | |
destinyXfate | 0:08606a13a816 | 186 | double * trend; |
destinyXfate | 0:08606a13a816 | 187 | trend = (double*) malloc(sizeof(double) * len); |
destinyXfate | 0:08606a13a816 | 188 | |
destinyXfate | 0:08606a13a816 | 189 | for(i=0 ; i<len ; i++) { |
destinyXfate | 0:08606a13a816 | 190 | trend[i]=A*x[i] + B; |
destinyXfate | 0:08606a13a816 | 191 | y[i]=y[i]-trend[i]; |
destinyXfate | 0:08606a13a816 | 192 | } |
destinyXfate | 0:08606a13a816 | 193 | |
destinyXfate | 0:08606a13a816 | 194 | } |
destinyXfate | 0:08606a13a816 | 195 | |
destinyXfate | 0:08606a13a816 | 196 | |
destinyXfate | 0:08606a13a816 | 197 | double MATH::Peak2Peak(double *in, int len) |
destinyXfate | 0:08606a13a816 | 198 | { |
destinyXfate | 0:08606a13a816 | 199 | int i; |
destinyXfate | 0:08606a13a816 | 200 | double outpp; |
destinyXfate | 0:08606a13a816 | 201 | |
destinyXfate | 0:08606a13a816 | 202 | double MAX = in[0]; |
destinyXfate | 0:08606a13a816 | 203 | for(i = 1 ; i < len ; i++) { |
destinyXfate | 0:08606a13a816 | 204 | MAX = (in[i] > MAX ? in[i]:MAX ) ; |
destinyXfate | 0:08606a13a816 | 205 | } |
destinyXfate | 0:08606a13a816 | 206 | |
destinyXfate | 0:08606a13a816 | 207 | double min = in[0]; |
destinyXfate | 0:08606a13a816 | 208 | for(i = 1 ; i < len ; i++) { |
destinyXfate | 0:08606a13a816 | 209 | min = (in[i] < min ? in[i]:min ) ; |
destinyXfate | 0:08606a13a816 | 210 | } |
destinyXfate | 0:08606a13a816 | 211 | |
destinyXfate | 0:08606a13a816 | 212 | outpp = MAX - min; |
destinyXfate | 0:08606a13a816 | 213 | |
destinyXfate | 0:08606a13a816 | 214 | return outpp; |
destinyXfate | 0:08606a13a816 | 215 | } |
destinyXfate | 0:08606a13a816 | 216 | |
destinyXfate | 0:08606a13a816 | 217 | |
destinyXfate | 0:08606a13a816 | 218 | double MATH::PeakValue(double *x , double *y, double *z, int len) |
destinyXfate | 0:08606a13a816 | 219 | { |
destinyXfate | 0:08606a13a816 | 220 | double xmax = fabs(x[0]), ymax = fabs(y[0]), zmax = fabs(z[0]); |
destinyXfate | 0:08606a13a816 | 221 | for(int i =1; i<len ; i++) { |
destinyXfate | 0:08606a13a816 | 222 | if(fabs(x[i]) > xmax) { |
destinyXfate | 0:08606a13a816 | 223 | xmax = fabs(x[i]); |
destinyXfate | 0:08606a13a816 | 224 | } |
destinyXfate | 0:08606a13a816 | 225 | if(fabs(y[i]) > ymax) { |
destinyXfate | 0:08606a13a816 | 226 | ymax = fabs(y[i]); |
destinyXfate | 0:08606a13a816 | 227 | } |
destinyXfate | 0:08606a13a816 | 228 | if(fabs(z[i]) > zmax) { |
destinyXfate | 0:08606a13a816 | 229 | zmax = fabs(z[i]); |
destinyXfate | 0:08606a13a816 | 230 | } |
destinyXfate | 0:08606a13a816 | 231 | } |
destinyXfate | 0:08606a13a816 | 232 | double MAX = ymax; |
destinyXfate | 0:08606a13a816 | 233 | double xzmax[2]= {xmax, zmax}; |
destinyXfate | 0:08606a13a816 | 234 | for(int i=0 ; i<2 ; i++) { |
destinyXfate | 0:08606a13a816 | 235 | if(xzmax[i] > MAX) { |
destinyXfate | 0:08606a13a816 | 236 | MAX = xzmax[i]; |
destinyXfate | 0:08606a13a816 | 237 | } |
destinyXfate | 0:08606a13a816 | 238 | } |
destinyXfate | 0:08606a13a816 | 239 | |
destinyXfate | 0:08606a13a816 | 240 | return MAX ; |
destinyXfate | 0:08606a13a816 | 241 | } |
destinyXfate | 0:08606a13a816 | 242 | |
destinyXfate | 0:08606a13a816 | 243 | |
destinyXfate | 0:08606a13a816 | 244 | double MATH::UBValue(double *maxi, double *x , double *y, double *z, int len) |
destinyXfate | 0:08606a13a816 | 245 | { |
destinyXfate | 0:08606a13a816 | 246 | double xmin = fabs(x[0]) , ymin = fabs(y[0]) , zmin = fabs(z[0]); |
destinyXfate | 0:08606a13a816 | 247 | for(int i = 1 ; i<len ; i++) { |
destinyXfate | 0:08606a13a816 | 248 | if(fabs(x[i]) < xmin) { |
destinyXfate | 0:08606a13a816 | 249 | xmin = fabs(x[i]); |
destinyXfate | 0:08606a13a816 | 250 | } |
destinyXfate | 0:08606a13a816 | 251 | if(fabs(y[i]) < ymin) { |
destinyXfate | 0:08606a13a816 | 252 | ymin = fabs(y[i]); |
destinyXfate | 0:08606a13a816 | 253 | } |
destinyXfate | 0:08606a13a816 | 254 | if(fabs(z[i]) < zmin) { |
destinyXfate | 0:08606a13a816 | 255 | zmin = fabs(z[i]); |
destinyXfate | 0:08606a13a816 | 256 | } |
destinyXfate | 0:08606a13a816 | 257 | } |
destinyXfate | 0:08606a13a816 | 258 | double MIN = zmin; |
destinyXfate | 0:08606a13a816 | 259 | double yxmin[2]= {ymin, xmin}; |
destinyXfate | 0:08606a13a816 | 260 | for(int i=0 ; i<2 ; i++) { |
destinyXfate | 0:08606a13a816 | 261 | if(yxmin[i] < MIN) { |
destinyXfate | 0:08606a13a816 | 262 | MIN = yxmin[i]; |
destinyXfate | 0:08606a13a816 | 263 | } |
destinyXfate | 0:08606a13a816 | 264 | } |
destinyXfate | 0:08606a13a816 | 265 | |
destinyXfate | 0:08606a13a816 | 266 | double UB = *maxi + 0.5 *( *maxi - MIN ) / ( len - 1 ); |
destinyXfate | 0:08606a13a816 | 267 | return UB; |
destinyXfate | 0:08606a13a816 | 268 | } |
destinyXfate | 0:08606a13a816 | 269 | |
destinyXfate | 0:08606a13a816 | 270 | |
destinyXfate | 0:08606a13a816 | 271 | double MATH::THD(double *ass_1, double *ass_2, double *ass_3, int pu) |
destinyXfate | 0:08606a13a816 | 272 | { |
destinyXfate | 0:08606a13a816 | 273 | double WTF, WTFa, WTFb, WTFc; |
destinyXfate | 0:08606a13a816 | 274 | double you_1, you_2, you_3, fu_1, fu_2, fu_3; |
destinyXfate | 0:08606a13a816 | 275 | |
destinyXfate | 0:08606a13a816 | 276 | switch(pu) { |
destinyXfate | 0:08606a13a816 | 277 | case 10000 : |
destinyXfate | 0:08606a13a816 | 278 | you_1 = (sqr(ass_1[120]) + sqr(ass_1[180]) + sqr(ass_1[240]) + sqr(ass_1[300]) + sqr(ass_1[360]) + sqr(ass_1[420]) + sqr(ass_1[480]) + sqr(ass_1[540]) + sqr(ass_1[600]) + sqr(ass_1[660])); |
destinyXfate | 0:08606a13a816 | 279 | fu_1 = sqrt(you_1); |
destinyXfate | 0:08606a13a816 | 280 | WTFa = (fu_1 / ass_1[60])*100; |
destinyXfate | 0:08606a13a816 | 281 | |
destinyXfate | 0:08606a13a816 | 282 | you_2 = (sqr(ass_2[120]) + sqr(ass_2[180]) + sqr(ass_2[240]) + sqr(ass_2[300]) + sqr(ass_2[360]) + sqr(ass_2[420]) + sqr(ass_2[480]) + sqr(ass_2[540]) + sqr(ass_2[600]) + sqr(ass_2[660])); |
destinyXfate | 0:08606a13a816 | 283 | fu_2 = sqrt(you_2); |
destinyXfate | 0:08606a13a816 | 284 | WTFb = (fu_2 / ass_2[60])*100; |
destinyXfate | 0:08606a13a816 | 285 | |
destinyXfate | 0:08606a13a816 | 286 | you_3 = (sqr(ass_3[120]) + sqr(ass_3[180]) + sqr(ass_3[240]) + sqr(ass_3[300]) + sqr(ass_3[360]) + sqr(ass_3[420]) + sqr(ass_3[480]) + sqr(ass_3[540]) + sqr(ass_3[600]) + sqr(ass_3[660])); |
destinyXfate | 0:08606a13a816 | 287 | fu_3 = sqrt(you_3); |
destinyXfate | 0:08606a13a816 | 288 | WTFc = (fu_3 / ass_3[60])*100; |
destinyXfate | 0:08606a13a816 | 289 | |
destinyXfate | 0:08606a13a816 | 290 | WTF = MAXof3(WTFa, WTFb, WTFc); |
destinyXfate | 0:08606a13a816 | 291 | break; |
destinyXfate | 0:08606a13a816 | 292 | case 8192 : |
destinyXfate | 0:08606a13a816 | 293 | |
destinyXfate | 0:08606a13a816 | 294 | double opps_2, opps_3, opps_4, opps_5, opps_6, opps_7, opps_8, opps_9, opps_10, opps_11; |
destinyXfate | 0:08606a13a816 | 295 | |
destinyXfate | 0:08606a13a816 | 296 | opps_2 = (ass_1[49] > ass_1[50] ? ass_1[49] :ass_1[50]); |
destinyXfate | 0:08606a13a816 | 297 | opps_4 = (ass_1[98] > ass_1[99] ? ass_1[98] :ass_1[99]); |
destinyXfate | 0:08606a13a816 | 298 | opps_6 = (ass_1[147] > ass_1[148] ? ass_1[147] :ass_1[148]); |
destinyXfate | 0:08606a13a816 | 299 | opps_7 = (ass_1[172] > ass_1[173] ? ass_1[172] :ass_1[173]); |
destinyXfate | 0:08606a13a816 | 300 | opps_9 = (ass_1[221] > ass_1[222] ? ass_1[221] :ass_1[222]); |
destinyXfate | 0:08606a13a816 | 301 | opps_11 = (ass_1[270] > ass_1[271] ? ass_1[270] :ass_1[271]); |
destinyXfate | 0:08606a13a816 | 302 | opps_3 = MAXof3(ass_1[73], ass_1[74], ass_1[75]); |
destinyXfate | 0:08606a13a816 | 303 | opps_5 = MAXof3(ass_1[122], ass_1[123], ass_1[124]); |
destinyXfate | 0:08606a13a816 | 304 | opps_8 = MAXof3(ass_1[196], ass_1[197], ass_1[198]); |
destinyXfate | 0:08606a13a816 | 305 | opps_10 = MAXof3(ass_1[245], ass_1[246], ass_1[247]); |
destinyXfate | 0:08606a13a816 | 306 | |
destinyXfate | 0:08606a13a816 | 307 | you_1 = (sqr(opps_2) + sqr(opps_3) + sqr(opps_4) + sqr(opps_5) + sqr(opps_6) + sqr(opps_7) + sqr(opps_8) + sqr(opps_9) + sqr(opps_10) + sqr(opps_11)); |
destinyXfate | 0:08606a13a816 | 308 | fu_1 = sqrt(you_1); |
destinyXfate | 0:08606a13a816 | 309 | WTFa = (fu_1 / ass_1[24])*100; |
destinyXfate | 0:08606a13a816 | 310 | |
destinyXfate | 0:08606a13a816 | 311 | opps_2 = (ass_2[49] > ass_2[50] ? ass_2[49] :ass_2[50]); |
destinyXfate | 0:08606a13a816 | 312 | opps_4 = (ass_2[98] > ass_2[99] ? ass_2[98] :ass_2[99]); |
destinyXfate | 0:08606a13a816 | 313 | opps_6 = (ass_2[147] > ass_2[148] ? ass_2[147] :ass_2[148]); |
destinyXfate | 0:08606a13a816 | 314 | opps_7 = (ass_2[172] > ass_2[173] ? ass_2[172] :ass_2[173]); |
destinyXfate | 0:08606a13a816 | 315 | opps_9 = (ass_2[221] > ass_2[222] ? ass_2[221] :ass_2[222]); |
destinyXfate | 0:08606a13a816 | 316 | opps_11 = (ass_2[270] > ass_2[271] ? ass_2[270] :ass_2[271]); |
destinyXfate | 0:08606a13a816 | 317 | opps_3 = MAXof3(ass_2[73], ass_2[74], ass_2[75]); |
destinyXfate | 0:08606a13a816 | 318 | opps_5 = MAXof3(ass_2[122], ass_2[123], ass_2[124]); |
destinyXfate | 0:08606a13a816 | 319 | opps_8 = MAXof3(ass_2[196], ass_2[197], ass_2[198]); |
destinyXfate | 0:08606a13a816 | 320 | opps_10 = MAXof3(ass_2[245], ass_2[246], ass_2[247]); |
destinyXfate | 0:08606a13a816 | 321 | |
destinyXfate | 0:08606a13a816 | 322 | you_2 = (sqr(opps_2) + sqr(opps_3) + sqr(opps_4) + sqr(opps_5) + sqr(opps_6) + sqr(opps_7) + sqr(opps_8) + sqr(opps_9) + sqr(opps_10) + sqr(opps_11)); |
destinyXfate | 0:08606a13a816 | 323 | fu_2 = sqrt(you_2); |
destinyXfate | 0:08606a13a816 | 324 | WTFb = (fu_2 / ass_2[24])*100; |
destinyXfate | 0:08606a13a816 | 325 | |
destinyXfate | 0:08606a13a816 | 326 | opps_2 = (ass_3[49] > ass_3[50] ? ass_3[49] :ass_3[50]); |
destinyXfate | 0:08606a13a816 | 327 | opps_4 = (ass_3[98] > ass_3[99] ? ass_3[98] :ass_3[99]); |
destinyXfate | 0:08606a13a816 | 328 | opps_6 = (ass_3[147] > ass_3[148] ? ass_3[147] :ass_3[148]); |
destinyXfate | 0:08606a13a816 | 329 | opps_7 = (ass_3[172] > ass_3[173] ? ass_3[172] :ass_3[173]); |
destinyXfate | 0:08606a13a816 | 330 | opps_9 = (ass_3[221] > ass_3[222] ? ass_3[221] :ass_3[222]); |
destinyXfate | 0:08606a13a816 | 331 | opps_11 = (ass_3[270] > ass_3[271] ? ass_3[270] :ass_3[271]); |
destinyXfate | 0:08606a13a816 | 332 | opps_3 = MAXof3(ass_3[73], ass_3[74], ass_3[75]); |
destinyXfate | 0:08606a13a816 | 333 | opps_5 = MAXof3(ass_3[122], ass_3[123], ass_3[124]); |
destinyXfate | 0:08606a13a816 | 334 | opps_8 = MAXof3(ass_3[196], ass_3[197], ass_3[198]); |
destinyXfate | 0:08606a13a816 | 335 | opps_10 = MAXof3(ass_3[245], ass_3[246], ass_3[247]); |
destinyXfate | 0:08606a13a816 | 336 | |
destinyXfate | 0:08606a13a816 | 337 | you_3 = (sqr(opps_2) + sqr(opps_3) + sqr(opps_4) + sqr(opps_5) + sqr(opps_6) + sqr(opps_7) + sqr(opps_8) + sqr(opps_9) + sqr(opps_10) + sqr(opps_11)); |
destinyXfate | 0:08606a13a816 | 338 | fu_3 = sqrt(you_3); |
destinyXfate | 0:08606a13a816 | 339 | WTFc = (fu_3 / ass_3[24])*100; |
destinyXfate | 0:08606a13a816 | 340 | |
destinyXfate | 0:08606a13a816 | 341 | WTF = MAXof3(WTFa, WTFb, WTFc); |
destinyXfate | 0:08606a13a816 | 342 | break; |
destinyXfate | 0:08606a13a816 | 343 | } |
destinyXfate | 0:08606a13a816 | 344 | |
destinyXfate | 0:08606a13a816 | 345 | return WTF; |
destinyXfate | 0:08606a13a816 | 346 | } |
destinyXfate | 0:08606a13a816 | 347 | |
destinyXfate | 0:08606a13a816 | 348 | |
destinyXfate | 0:08606a13a816 | 349 | double MATH::HD(double *ck_1, double *ck_2, double *ck_3, int pu) |
destinyXfate | 0:08606a13a816 | 350 | { |
destinyXfate | 0:08606a13a816 | 351 | double blow, blow1, blow2, blow3; |
destinyXfate | 0:08606a13a816 | 352 | double su_3, su_5, su_7, su_9, su_11; |
destinyXfate | 0:08606a13a816 | 353 | |
destinyXfate | 0:08606a13a816 | 354 | switch(pu) { |
destinyXfate | 0:08606a13a816 | 355 | |
destinyXfate | 0:08606a13a816 | 356 | case 10000: |
destinyXfate | 0:08606a13a816 | 357 | |
destinyXfate | 0:08606a13a816 | 358 | su_3 = (ck_1[180] / ck_1[60])*100; |
destinyXfate | 0:08606a13a816 | 359 | su_5 = (ck_1[300] / ck_1[60])*100; |
destinyXfate | 0:08606a13a816 | 360 | su_7 = (ck_1[420] / ck_1[60])*100; |
destinyXfate | 0:08606a13a816 | 361 | su_9 = (ck_1[540] / ck_1[60])*100; |
destinyXfate | 0:08606a13a816 | 362 | su_11 = (ck_1[660] / ck_1[60])*100; |
destinyXfate | 0:08606a13a816 | 363 | |
destinyXfate | 0:08606a13a816 | 364 | blow1 = su_3; |
destinyXfate | 0:08606a13a816 | 365 | double job[4]= {su_5, su_7, su_9, su_11}; |
destinyXfate | 0:08606a13a816 | 366 | for(int i = 0 ; i<4 ; i++) { |
destinyXfate | 0:08606a13a816 | 367 | if(job[i] > blow1) { |
destinyXfate | 0:08606a13a816 | 368 | blow1 = job[i]; |
destinyXfate | 0:08606a13a816 | 369 | } |
destinyXfate | 0:08606a13a816 | 370 | } |
destinyXfate | 0:08606a13a816 | 371 | |
destinyXfate | 0:08606a13a816 | 372 | su_3 = (ck_2[180] / ck_2[60])*100; |
destinyXfate | 0:08606a13a816 | 373 | su_5 = (ck_2[300] / ck_2[60])*100; |
destinyXfate | 0:08606a13a816 | 374 | su_7 = (ck_2[420] / ck_2[60])*100; |
destinyXfate | 0:08606a13a816 | 375 | su_9 = (ck_2[540] / ck_2[60])*100; |
destinyXfate | 0:08606a13a816 | 376 | su_11 = (ck_2[660] / ck_2[60])*100; |
destinyXfate | 0:08606a13a816 | 377 | |
destinyXfate | 0:08606a13a816 | 378 | blow2 = su_3; |
destinyXfate | 0:08606a13a816 | 379 | double job2[4]= {su_5, su_7, su_9, su_11}; |
destinyXfate | 0:08606a13a816 | 380 | for(int i = 0 ; i<4 ; i++) { |
destinyXfate | 0:08606a13a816 | 381 | if(job2[i] > blow2) { |
destinyXfate | 0:08606a13a816 | 382 | blow2 = job2[i]; |
destinyXfate | 0:08606a13a816 | 383 | } |
destinyXfate | 0:08606a13a816 | 384 | } |
destinyXfate | 0:08606a13a816 | 385 | |
destinyXfate | 0:08606a13a816 | 386 | su_3 = (ck_3[180] / ck_3[60])*100; |
destinyXfate | 0:08606a13a816 | 387 | su_5 = (ck_3[300] / ck_3[60])*100; |
destinyXfate | 0:08606a13a816 | 388 | su_7 = (ck_3[420] / ck_3[60])*100; |
destinyXfate | 0:08606a13a816 | 389 | su_9 = (ck_3[540] / ck_3[60])*100; |
destinyXfate | 0:08606a13a816 | 390 | su_11 = (ck_3[660] / ck_3[60])*100; |
destinyXfate | 0:08606a13a816 | 391 | |
destinyXfate | 0:08606a13a816 | 392 | blow3 = su_3; |
destinyXfate | 0:08606a13a816 | 393 | double job3[4]= {su_5, su_7, su_9, su_11}; |
destinyXfate | 0:08606a13a816 | 394 | for(int i = 0 ; i<4 ; i++) { |
destinyXfate | 0:08606a13a816 | 395 | if(job3[i] > blow3) { |
destinyXfate | 0:08606a13a816 | 396 | blow3 = job3[i]; |
destinyXfate | 0:08606a13a816 | 397 | } |
destinyXfate | 0:08606a13a816 | 398 | } |
destinyXfate | 0:08606a13a816 | 399 | |
destinyXfate | 0:08606a13a816 | 400 | blow = MAXof3(blow1, blow2, blow3); |
destinyXfate | 0:08606a13a816 | 401 | |
destinyXfate | 0:08606a13a816 | 402 | break; |
destinyXfate | 0:08606a13a816 | 403 | |
destinyXfate | 0:08606a13a816 | 404 | case 8192 : |
destinyXfate | 0:08606a13a816 | 405 | |
destinyXfate | 0:08606a13a816 | 406 | double opps_3, opps_5, opps_7, opps_9, opps_11; |
destinyXfate | 0:08606a13a816 | 407 | opps_3 = MAXof3(ck_1[73], ck_1[74], ck_1[75]); |
destinyXfate | 0:08606a13a816 | 408 | opps_5 = MAXof3(ck_1[122], ck_1[123], ck_1[124]); |
destinyXfate | 0:08606a13a816 | 409 | opps_7 = (ck_1[172] > ck_1[173] ? ck_1[172] :ck_1[173]); |
destinyXfate | 0:08606a13a816 | 410 | opps_9 = (ck_1[221] > ck_1[222] ? ck_1[221] :ck_1[222]); |
destinyXfate | 0:08606a13a816 | 411 | opps_11 = (ck_1[270] > ck_1[271] ? ck_1[270] :ck_1[271]); |
destinyXfate | 0:08606a13a816 | 412 | |
destinyXfate | 0:08606a13a816 | 413 | |
destinyXfate | 0:08606a13a816 | 414 | su_3 = (opps_3 / ck_1[24])*100; |
destinyXfate | 0:08606a13a816 | 415 | su_5 = (opps_5 / ck_1[24])*100; |
destinyXfate | 0:08606a13a816 | 416 | su_7 = (opps_7 / ck_1[24])*100; |
destinyXfate | 0:08606a13a816 | 417 | su_9 = (opps_9 / ck_1[24])*100; |
destinyXfate | 0:08606a13a816 | 418 | su_11 = (opps_11 / ck_1[24])*100; |
destinyXfate | 0:08606a13a816 | 419 | |
destinyXfate | 0:08606a13a816 | 420 | blow1 = su_3; |
destinyXfate | 0:08606a13a816 | 421 | double job4[4]= {su_5, su_7, su_9, su_11}; |
destinyXfate | 0:08606a13a816 | 422 | for(int i = 0 ; i<4 ; i++) { |
destinyXfate | 0:08606a13a816 | 423 | if(job4[i] > blow1) { |
destinyXfate | 0:08606a13a816 | 424 | blow1 = job4[i]; |
destinyXfate | 0:08606a13a816 | 425 | } |
destinyXfate | 0:08606a13a816 | 426 | } |
destinyXfate | 0:08606a13a816 | 427 | |
destinyXfate | 0:08606a13a816 | 428 | |
destinyXfate | 0:08606a13a816 | 429 | opps_3 = MAXof3(ck_2[73], ck_2[74], ck_2[75]); |
destinyXfate | 0:08606a13a816 | 430 | opps_5 = MAXof3(ck_2[122], ck_2[123], ck_2[124]); |
destinyXfate | 0:08606a13a816 | 431 | opps_7 = (ck_2[172] > ck_2[173] ? ck_2[172] :ck_2[173]); |
destinyXfate | 0:08606a13a816 | 432 | opps_9 = (ck_2[221] > ck_2[222] ? ck_2[221] :ck_2[222]); |
destinyXfate | 0:08606a13a816 | 433 | opps_11 = (ck_2[270] > ck_2[271] ? ck_2[270] :ck_2[271]); |
destinyXfate | 0:08606a13a816 | 434 | |
destinyXfate | 0:08606a13a816 | 435 | su_3 = (opps_3 / ck_2[24])*100; |
destinyXfate | 0:08606a13a816 | 436 | su_5 = (opps_5 / ck_2[24])*100; |
destinyXfate | 0:08606a13a816 | 437 | su_7 = (opps_7 / ck_2[24])*100; |
destinyXfate | 0:08606a13a816 | 438 | su_9 = (opps_9 / ck_2[24])*100; |
destinyXfate | 0:08606a13a816 | 439 | su_11 = (opps_11 / ck_2[24])*100; |
destinyXfate | 0:08606a13a816 | 440 | |
destinyXfate | 0:08606a13a816 | 441 | blow2 = su_3; |
destinyXfate | 0:08606a13a816 | 442 | double job5[4]= {su_5, su_7, su_9, su_11}; |
destinyXfate | 0:08606a13a816 | 443 | |
destinyXfate | 0:08606a13a816 | 444 | for(int i = 0 ; i<4 ; i++) { |
destinyXfate | 0:08606a13a816 | 445 | if(job5[i] > blow2) { |
destinyXfate | 0:08606a13a816 | 446 | blow2 = job5[i]; |
destinyXfate | 0:08606a13a816 | 447 | } |
destinyXfate | 0:08606a13a816 | 448 | } |
destinyXfate | 0:08606a13a816 | 449 | |
destinyXfate | 0:08606a13a816 | 450 | |
destinyXfate | 0:08606a13a816 | 451 | opps_3 = MAXof3(ck_3[73], ck_3[74], ck_3[75]); |
destinyXfate | 0:08606a13a816 | 452 | opps_5 = MAXof3(ck_3[122], ck_3[123], ck_3[124]); |
destinyXfate | 0:08606a13a816 | 453 | opps_7 = (ck_3[172] > ck_3[173] ? ck_3[172] :ck_3[173]); |
destinyXfate | 0:08606a13a816 | 454 | opps_9 = (ck_3[221] > ck_3[222] ? ck_3[221] :ck_3[222]); |
destinyXfate | 0:08606a13a816 | 455 | opps_11 = (ck_3[270] > ck_3[271] ? ck_3[270] :ck_3[271]); |
destinyXfate | 0:08606a13a816 | 456 | |
destinyXfate | 0:08606a13a816 | 457 | su_3 = (opps_3 / ck_3[24])*100; |
destinyXfate | 0:08606a13a816 | 458 | su_5 = (opps_5 / ck_3[24])*100; |
destinyXfate | 0:08606a13a816 | 459 | su_7 = (opps_7 / ck_3[24])*100; |
destinyXfate | 0:08606a13a816 | 460 | su_9 = (opps_9 / ck_3[24])*100; |
destinyXfate | 0:08606a13a816 | 461 | su_11 = (opps_11 / ck_3[24])*100; |
destinyXfate | 0:08606a13a816 | 462 | |
destinyXfate | 0:08606a13a816 | 463 | blow3 = su_3; |
destinyXfate | 0:08606a13a816 | 464 | double job6[4]= {su_5, su_7, su_9, su_11}; |
destinyXfate | 0:08606a13a816 | 465 | |
destinyXfate | 0:08606a13a816 | 466 | for(int i = 0 ; i<4 ; i++) { |
destinyXfate | 0:08606a13a816 | 467 | if(job6[i] > blow3) { |
destinyXfate | 0:08606a13a816 | 468 | blow3 = job6[i]; |
destinyXfate | 0:08606a13a816 | 469 | } |
destinyXfate | 0:08606a13a816 | 470 | } |
destinyXfate | 0:08606a13a816 | 471 | |
destinyXfate | 0:08606a13a816 | 472 | blow = MAXof3(blow1, blow2, blow3); |
destinyXfate | 0:08606a13a816 | 473 | |
destinyXfate | 0:08606a13a816 | 474 | break; |
destinyXfate | 0:08606a13a816 | 475 | } |
destinyXfate | 0:08606a13a816 | 476 | |
destinyXfate | 0:08606a13a816 | 477 | return blow; |
destinyXfate | 0:08606a13a816 | 478 | |
destinyXfate | 0:08606a13a816 | 479 | } |