56 |
void atR(void *_data, double pos[2], double *out) |
void atR(void *_data, double pos[2], double *out) |
57 |
{ |
{ |
58 |
float *data = (float*)_data; |
float *data = (float*)_data; |
59 |
|
double temp[2][2]; |
60 |
int a = floor(pos[0] * 150); |
int a = floor(pos[0] * 150); |
61 |
int b = floor(pos[1] * 150); |
int b = floor(pos[1] * 150); |
62 |
*out = *(data + a + b * 1020); |
for (int i = 0; i < 4; i++) { |
63 |
|
for (int j = 0; j < 2; j++) { |
64 |
|
temp[i][j] = *(data + (i + a) + (j + b) * 1020); |
65 |
|
} |
66 |
|
} |
67 |
|
double temp2[2]; |
68 |
|
double t = pos[0]*150 - floor(pos[0]*150); |
69 |
|
for (int i = 0; i < 2; i++) { |
70 |
|
temp2[i] = (temp[0][i] * (1 - t) + temp[1][i] * t); |
71 |
|
} |
72 |
|
t = pos[1]*150 - floor(pos[1]*150); |
73 |
|
*out = (temp2[0] * (1 - t) + temp2[1] * t); |
74 |
} |
} |
75 |
|
|
76 |
void at(void* _data, double pos[2], double out[2]) |
void at(void* _data, double pos[2], double out[2]) |
87 |
tempy[i][j] = *(data + (j + b - 1) * 700 + (i + a - 1) * 2 + 1); |
tempy[i][j] = *(data + (j + b - 1) * 700 + (i + a - 1) * 2 + 1); |
88 |
} |
} |
89 |
} |
} |
90 |
double t = pos[0] - floor(pos[0]); |
double t = pos[0]*150 - floor(pos[0]*150); |
91 |
double tempxx[4]; |
double tempxx[4]; |
92 |
double tempyx[4]; |
double tempyx[4]; |
93 |
for(int i = 0; i < 4; i++) { |
for(int i = 0; i < 4; i++) { |
100 |
(2 * tempy[0][i] - 5 * tempy[1][i] + 4 * tempy[2][i] - tempy[3][i]) * t * t + |
(2 * tempy[0][i] - 5 * tempy[1][i] + 4 * tempy[2][i] - tempy[3][i]) * t * t + |
101 |
(-tempy[0][i] + 3 * tempy[1][i] - 3 * tempy[2][i] + tempy[3][i]) * t * t * t); |
(-tempy[0][i] + 3 * tempy[1][i] - 3 * tempy[2][i] + tempy[3][i]) * t * t * t); |
102 |
} |
} |
103 |
t = pos[1] - floor(pos[1]); |
t = pos[1]*150 - floor(pos[1]*150); |
104 |
out[0] = 0.5 * (2 * tempxx[0] + |
out[0] = 0.5 * (2 * tempxx[0] + |
105 |
(-tempxx[0] + tempxx[2]) * t + |
(-tempxx[0] + tempxx[2]) * t + |
106 |
(2 * tempxx[0] - 5 * tempxx[1] + 4 * tempxx[2] - tempxx[3]) * t * t + |
(2 * tempxx[0] - 5 * tempxx[1] + 4 * tempxx[2] - tempxx[3]) * t * t + |