151 EDGEPT *Loop, *LoopStart, *Segment;
152 inT16 LastX, LastY, Xmean, Ymean;
153 inT32 NormX, NormY, DeltaX, DeltaY;
162 uinT16 NumBLFeatures, NumCNFeatures;
166 register inT32 pfX, pfY, dX, dY;
190 while (OutLine !=
NULL) {
191 LoopStart = OutLine->
loop;
206 DeltaX = NormX - LastX;
207 DeltaY = NormY - LastY;
208 Length =
MySqrt(DeltaX, DeltaY);
209 n = ((Length << 2) + Length + 32) >> 6;
211 Xsum += ((LastX << 1) + DeltaX) * (int) Length;
212 Ysum += ((LastY << 1) + DeltaY) * (int) Length;
221 while (Loop != LoopStart);
222 OutLine = OutLine->
next;
226 Xmean = (Xsum / (
inT32) LengthSum) >> 1;
227 Ymean = (Ysum / (
inT32) LengthSum) >> 1;
229 Results->
Length = LengthSum;
230 Results->
Xmean = Xmean;
231 Results->
Ymean = Ymean;
250 while (OutLine !=
NULL) {
251 LoopStart = OutLine->
loop;
253 LastX = Loop->
pos.
x - Xmean;
261 NormX = Loop->
pos.
x - Xmean;
263 if (NormY < Results->YBottom)
265 if (NormY > Results->
YTop)
271 DeltaX = NormX - LastX;
272 DeltaY = NormY - LastY;
273 Length =
MySqrt(DeltaX, DeltaY);
274 n = ((Length << 2) + Length + 32) >> 6;
277 dX = (DeltaX << 8) / n;
278 dY = (DeltaY << 8) / n;
279 pfX = (LastX << 8) + (dX >> 1);
280 pfY = (LastY << 8) + (dY >> 1);
281 Ix += ((pfY >> 8) - Ymean) * ((pfY >> 8) - Ymean);
285 Iy += (pfX >> 8) * (pfX >> 8);
289 (
inT16) ((pfY >> 8) - 128),
293 for (i = 1; i < n; i++) {
296 Ix += ((pfY >> 8) - Ymean) * ((pfY >> 8) - Ymean);
297 Iy += (pfX >> 8) * (pfX >> 8);
301 (
inT16) ((pfY >> 8) - 128),
313 while (Loop != LoopStart);
314 OutLine = OutLine->
next;
316 Results->
Width = max_x - min_x;
321 RxInv =
MySqrt2 (NumBLFeatures, Ix, &RxExp);
322 RyInv =
MySqrt2 (NumBLFeatures, Iy, &RyExp);
325 Results->
Rx = (
inT16) (51.2 / (
double) RxInv * pow (2.0, (
double) RxExp));
326 Results->
Ry = (
inT16) (51.2 / (
double) RyInv * pow (2.0, (
double) RyExp));
327 if (Results->
Ry == 0) {
334 Results->
NumBL = NumBLFeatures;
352 int OutLineIndex = -1;
353 while (OutLine !=
NULL) {
354 LoopStart = OutLine->
loop;
356 LastX = (Loop->
pos.
x - Xmean) * RyInv;
357 LastY = (Loop->
pos.
y - Ymean) * RxInv;
358 LastX >>= (
inT8) RyExp;
359 LastY >>= (
inT8) RxExp;
368 NormX = (Loop->
pos.
x - Xmean) * RyInv;
369 NormY = (Loop->
pos.
y - Ymean) * RxInv;
370 NormX >>= (
inT8) RyExp;
371 NormY >>= (
inT8) RxExp;
375 DeltaX = NormX - LastX;
376 DeltaY = NormY - LastY;
377 Length =
MySqrt(DeltaX, DeltaY);
378 n = ((Length << 2) + Length + 32) >> 6;
381 dX = (DeltaX << 8) / n;
382 dY = (DeltaY << 8) / n;
383 pfX = (LastX << 8) + (dX >> 1);
384 pfY = (LastY << 8) + (dY >> 1);
391 if (FeatureOutlineArray) {
392 FeatureOutlineArray[NumCNFeatures] = OutLineIndex;
395 for (i = 1; i < n; i++) {
404 if (FeatureOutlineArray) {
405 FeatureOutlineArray[NumCNFeatures] = OutLineIndex;
416 while (Loop != LoopStart);
417 OutLine = OutLine->
next;
420 Results->
NumCN = NumCNFeatures;
uinT16 MySqrt(inT32 X, inT32 Y)
void UpdateRange(const T1 &x, T2 *lower_bound, T2 *upper_bound)
uinT8 BinaryAnglePlusPi(inT32 Y, inT32 X)
T ClipToRange(const T &x, const T &lower_bound, const T &upper_bound)