78 #define MAX(A, B) (((A) < (B)) ? (B) : (A))
79 #define MIN(A, B) (((A) < (B)) ? (A) : (B))
80 #define cot(A) (1./tan(A))
168 if ( lut->
bin == NULL ) {
172 if ( lut->
border == NULL ) {
176 if ( patch == NULL ) {
208 if ( lut->
nBin <= 0 ) {
247 UINT4 maxNBins, maxNBorders;
252 for (
i = 0;
i < maxNBins; ++
i ) {
263 for (
i = 0;
i < maxNBorders; ++
i ) {
352 UINT4 lastBorder = 0;
353 UINT4 currentBin = 0;
358 INT4 directionPlus = -1;
359 INT4 directionPlusZero = -1;
372 REAL8 cosPhiMax, cosPhiMin, phi;
382 cosDelta =
par->cosDelta;
383 cosPhiMax0 =
par->cosPhiMax0;
384 cosPhiMin0 =
par->cosPhiMin0;
385 epsilon =
par->epsilon;
395 rCritic = 2 * cos( lambda ) / ( 1 - sin( lambda ) );
400 rcOldMinus = rCritic;
407 cosPhiMax = cosPhiMax0;
409 if ( cosPhiMax > 0.99999999 ) {
414 phi = acos( cosPhiMax );
428 &rcOldPlus, &directionPlus, &ifailPlus, lut, patch );
432 directionPlusZero = directionPlus;
444 while ( ifailPlus ) {
451 if ( currentBin > maxNBins || lastBorder >= maxNBorders ) {
452 fprintf( stderr,
"currentBin=%d not in range 1 to maxNBins=%d\n"
453 "or lastborder=%d >= maxNBorders=%d [ConstructPLUT.c %d]\n",
454 currentBin, maxNBins, lastBorder, maxNBorders, __LINE__ );
458 cosPhiMax = cosPhiMax + cosDelta;
461 if ( cosPhiMax > 0.99999999 ) {
465 phi = acos( cosPhiMax );
475 rcOldPlus, directionPlus, &ifailPlus, lut, patch );
479 rcOldPlus, &pathology, &directionPlus,
480 &ifailPlus, lut, patch );
485 Fill1Column( currentBin, &lastBorder, lut, patch );
491 nBinPos = currentBin;
500 cosPhiMin = cosPhiMin0;
502 if ( cosPhiMin < -0.99999999 ) {
506 phi = acos( cosPhiMin );
523 directionPlusZero, &rcOldMinus,
524 &pathology, &directionMinus,
525 &ifailMinus, lut, patch );
549 while ( ifailMinus ) {
556 if ( currentBin > maxNBins || lastBorder >= maxNBorders ) {
557 fprintf( stderr,
"currentBin=%d not in range 1 to maxNBins=%d\n"
558 "or lastborder=%d >= maxNBorders=%d [ConstructPLUT.c %d]\n",
559 currentBin, maxNBins, lastBorder, maxNBorders, __LINE__ );
564 cosPhiMin = cosPhiMin - cosDelta;
566 if ( cosPhiMin < -0.99999999 ) {
570 phi = acos( cosPhiMin );
580 rcOldMinus, directionMinus, &ifailMinus, lut, patch );
584 rcOldMinus, &pathology, &directionMinus,
585 &ifailMinus, lut, patch );
590 Fill1Column( currentBin, &lastBorder, lut, patch );
600 lut->
nBin = currentBin + 1;
601 lut->
iniBin = nBinPos - currentBin;
641 if ( patch == NULL ) {
642 fprintf( stderr,
"pointer patch is null [ConstructPLUT.c %d]\n", __LINE__ );
646 fprintf( stderr,
"pointer lut is null [ConstructPLUT.c %d]\n", __LINE__ );
649 if ( ifailP == NULL ) {
650 fprintf( stderr,
"pointer ifailP is null [ConstructPLUT.c %d]\n", __LINE__ );
653 if ( lastBorderP == NULL ) {
654 fprintf( stderr,
"pointer lastBorderP is null [ConstructPLUT.c %d]\n", __LINE__ );
656 lastBorder = *lastBorderP;
671 fprintf( stderr,
"WARNING: Fixing yymin (%d -> 0) [ConstructPLUT.c %d]\n",
675 if ( yymax >= patch->
ySide ) {
676 fprintf( stderr,
"WARNING: Fixing yymax (%d -> %d) [ConstructPLUT.c %d]\n",
677 yymax, patch->
ySide - 1, __LINE__ );
678 yymax = patch->
ySide - 1;
702 xRel = xA + tan(
alpha ) * yA;
736 *lastBorderP = lastBorder;
778 if ( patch == NULL ) {
779 fprintf( stderr,
"pointer patch is null [ConstructPLUT.c %d]\n", __LINE__ );
783 fprintf( stderr,
"pointer lut is null [ConstructPLUT.c %d]\n", __LINE__ );
786 if ( ifailP == NULL ) {
787 fprintf( stderr,
"pointer ifailP is null [ConstructPLUT.c %d]\n", __LINE__ );
790 if ( lastBorderP == NULL ) {
791 fprintf( stderr,
"pointer lastBorderP is null [ConstructPLUT.c %d]\n", __LINE__ );
793 lastBorder = *lastBorderP;
806 fprintf( stderr,
"WARNING: Fixing yymin (%d -> 0) [ConstructPLUT.c %d]\n",
810 if ( yymax >= patch->
ySide ) {
811 fprintf( stderr,
"WARNING: Fixing yymax (%d -> %d) [ConstructPLUT.c %d]\n",
812 yymax, patch->
ySide - 1, __LINE__ );
813 yymax = patch->
ySide - 1;
832 lut->
bin[currentBin + 1].
leftB1 = lastBorder;
836 lut->
bin[currentBin + 1].
rightB2 = lastBorder;
840 xRel = xA + tan(
alpha ) * yA;
851 lut->
bin[currentBin + 1].
rightB2 = lastBorder;
861 lut->
bin[currentBin + 1].
leftB1 = lastBorder;
874 *lastBorderP = lastBorder;
914 if ( patch == NULL ) {
915 fprintf( stderr,
"pointer patch is null [ConstructPLUT.c %d]\n", __LINE__ );
919 fprintf( stderr,
"pointer lut is null [ConstructPLUT.c %d]\n", __LINE__ );
922 if ( ifailP == NULL ) {
923 fprintf( stderr,
"pointer ifailP is null [ConstructPLUT.c %d]\n", __LINE__ );
926 if ( lastBorderP == NULL ) {
927 fprintf( stderr,
"pointer lastBorderP is null [ConstructPLUT.c %d]\n", __LINE__ );
929 lastBorder = *lastBorderP;
942 fprintf( stderr,
"WARNING: Fixing yymin (%d -> 0) [ConstructPLUT.c %d]\n",
946 if ( yymax >= patch->
ySide ) {
947 fprintf( stderr,
"WARNING: Fixing yymax (%d -> %d) [ConstructPLUT.c %d]\n",
948 yymax, patch->
ySide - 1, __LINE__ );
949 yymax = patch->
ySide - 1;
959 if ( direction == 1 ) {
963 REAL8 xcOld, ycOld, xRel, slope;
965 xcOld = rcOld * cos(
alpha );
966 ycOld = rcOld * sin(
alpha );
971 lut->
bin[currentBin].
leftB1 = lastBorder;
972 lut->
bin[currentBin + 1].
rightB1 = lastBorder;
985 xRel = xA + tan(
alpha ) * ( yA - ycOld );
994 if ( xRel < xcOld ) {
995 lut->
bin[currentBin].
leftB1 = lastBorder;
996 lut->
bin[currentBin + 1].
rightB1 = lastBorder;
1006 lut->
bin[currentBin + 1].
leftB2 = lastBorder;
1031 lut->
bin[currentBin + 1].
leftB1 = lastBorder;
1034 lut->
bin[currentBin].
leftB2 = lastBorder;
1035 lut->
bin[currentBin + 1].
rightB2 = lastBorder;
1039 xRel = xA + tan(
alpha ) * yA;
1049 lut->
bin[currentBin].
leftB2 = lastBorder;
1050 lut->
bin[currentBin + 1].
rightB2 = lastBorder;
1060 lut->
bin[currentBin + 1].
leftB1 = lastBorder;
1075 *lastBorderP = lastBorder;
1119 if ( epsP == NULL ) {
1120 fprintf( stderr,
"pointer epsP is null [ConstructPLUT.c %d]\n", __LINE__ );
1123 if ( lineCaseP == NULL ) {
1124 fprintf( stderr,
"pointer lineCaseP is null [ConstructPLUT.c %d]\n", __LINE__ );
1129 e1 = ang1 -
LAL_PI * 0.5;
1130 e21 = ang2 -
LAL_PI * 0.5;
1133 if ( fabs( e1 ) < epsilon ) {
1139 if ( fabs( e21 ) < epsilon ) {
1145 if ( fabs( e22 ) < epsilon ) {
1164 static void FindExactLine(
REAL8 alpha,
REAL8 delta,
1172 if ( fabs( 1. - sin( lambda ) < 1.0e-6 ) {
1173 fprintf( stderr,
"warning: possible division by 0 [ConstructPLUT.c %d]\n", __LINE__ );
1175 rA = 2.* cos( lambda ) / ( 1. - sin( lambda ) );
1176 *xA = rA * cos( alpha );
1177 *yA = rA * sin( alpha );
1196 rA = 2.* cos( lambda ) / ( 1. - sin( lambda ) );
1197 *xA = rA * cos(
alpha );
1198 *yA = rA * sin(
alpha );
1218 INT4 yymin, yymax, noIn;
1227 if ( ( patch->
xMin <= xA ) && ( patch->
xMax >= xA ) ) {
1230 yymax = patch->
ySide - 1;
1236 if ( ( patch->
yMin <= yA ) && ( patch->
yMax >= yA ) ) {
1239 kkk = yA / patch->
deltaY - 0.5;
1240 kkk += patch->
ySide * 0.5;
1241 yymin = ceil( kkk );
1244 kkk = yA / patch->
deltaY - 0.5;
1245 kkk += patch->
ySide * 0.5;
1246 yymax = floor( kkk );
1253 REAL8 myy1, y2, slope;
1255 myy1 = slope * ( xA - patch->
xMin ) + yA;
1256 y2 = slope * ( xA - patch->
xMax ) + yA;
1258 if ( ( ( myy1 >= patch->
yMin ) || ( y2 >= patch->
yMin ) )
1259 && ( ( myy1 <= patch->
yMax ) || ( y2 <= patch->yMax ) ) ) {
1260 REAL8 yupper, ylower;
1262 yupper =
MAX( myy1, y2 );
1263 ylower =
MIN( myy1, y2 );
1264 yupper =
MIN( yupper, patch->
yMax );
1265 ylower =
MAX( ylower, patch->
yMin );
1267 kkk = ylower / patch->
deltaY - 0.5;
1268 kkk += patch->
ySide * 0.5;
1269 yymin = ceil( kkk );
1271 kkk = yupper / patch->
deltaY - 0.5;
1272 kkk += patch->
ySide * 0.5;
1273 yymax = floor( kkk );
1299 column[yymin] = patch->
xSide;
1300 column[yymax] = patch->
xSide;
1310 kkk = xA / patch->
deltaX - 0.5;
1311 kkk += patch->
xSide * 0.5;
1312 xpixel = ceil( kkk );
1317 if ( xpixel > patch->
xSide ) {
1318 xpixel = patch->
xSide;
1321 for ( jj = yymin; jj <= yymax; ++jj ) {
1322 column[jj] = xpixel;
1330 tanalpha = tan(
alpha );
1332 for ( jj = yymin; jj <= yymax; ++jj ) {
1334 xofy = xA + tanalpha * ( yA - patch->
yCoor[jj] );
1335 kkk = xofy / patch->
deltaX - 0.5;
1336 kkk += patch->
xSide * 0.5;
1337 xpixel = ceil( kkk );
1342 if ( xpixel > patch->
xSide ) {
1343 xpixel = patch->
xSide;
1346 column[jj] = xpixel;
1390 lastBorder = *lastBorderP;
1392 rho1 = cos( ang1 ) / ( 1. - sin( ang1 ) );
1393 rho2 = cos( ang2 ) / ( 1. - sin( ang2 ) );
1395 xc = rc * cos(
alpha );
1396 yc = rc * sin(
alpha );
1397 radius = fabs( rho1 -
rho2 );
1401 if ( ( yc + radius < patch->yMin ) || ( yc - radius > patch->
yMax ) ||
1402 ( xc + radius < patch->xMin ) || ( xc - radius > patch->
xMax ) ||
1403 ( sqrt( patch->
xMax * patch->
xMax + patch->
yMax * patch->
yMax ) + radius < fabs( rc ) ) ) {
1416 direction = ( ( fabs( rc ) < radius ) ? ( 1 ) : ( -1 ) );
1420 if ( direction == -1 ) {
1424 if ( xc >= patch->
xMin ) {
1435 fprintf( stderr,
"WARNING: Fixing yymin (%d -> 0) [ConstructPLUT.c %d]\n",
1439 if ( yymax >= patch->
ySide ) {
1440 fprintf( stderr,
"WARNING: Fixing yymax (%d -> %d) [ConstructPLUT.c %d]\n",
1441 yymax, patch->
ySide - 1, __LINE__ );
1442 yymax = patch->
ySide - 1;
1458 if ( xc <= patch->xMax ) {
1469 fprintf( stderr,
"WARNING: Fixing yymin (%d -> 0) [ConstructPLUT.c %d]\n",
1473 if ( yymax >= patch->
ySide ) {
1474 fprintf( stderr,
"WARNING: Fixing yymax (%d -> %d) [ConstructPLUT.c %d]\n",
1475 yymax, patch->
ySide - 1, __LINE__ );
1476 yymax = patch->
ySide - 1;
1492 if ( pieces == 0 ) {
1506 if ( xc >= patch->
xMin ) {
1517 fprintf( stderr,
"WARNING: Fixing yymin (%d -> 0) [ConstructPLUT.c %d]\n",
1521 if ( yymax >= patch->
ySide ) {
1522 fprintf( stderr,
"WARNING: Fixing yymax (%d -> %d) [ConstructPLUT.c %d]\n",
1523 yymax, patch->
ySide - 1, __LINE__ );
1524 yymax = patch->
ySide - 1;
1541 if ( xc <= patch->xMax ) {
1552 fprintf( stderr,
"WARNING: Fixing yymin (%d -> 0) [ConstructPLUT.c %d]\n",
1556 if ( yymax >= patch->
ySide ) {
1557 fprintf( stderr,
"WARNING: Fixing yymax (%d -> %d) [ConstructPLUT.c %d]\n",
1558 yymax, patch->
ySide - 1, __LINE__ );
1559 yymax = patch->
ySide - 1;
1576 if ( pieces == 0 ) {
1584 *lastBorderP = lastBorder;
1585 *directionP = direction;
1615 INT4 *pathologyP,
INT4 *directionP,
1629 pathology = *pathologyP;
1630 lastBorder = *lastBorderP;
1632 rho1 = cos( ang1 ) / ( 1. - sin( ang1 ) );
1633 rho2 = cos( ang2 ) / ( 1. - sin( ang2 ) );
1635 xc = rc * cos(
alpha );
1636 yc = rc * sin(
alpha );
1637 radius = fabs( rho1 -
rho2 );
1641 if ( ( yc + radius < patch->yMin ) || ( yc - radius > patch->
yMax ) ||
1642 ( xc + radius < patch->xMin ) || ( xc - radius > patch->
xMax ) ||
1643 ( sqrt( patch->
xMax * patch->
xMax + patch->
yMax * patch->
yMax ) + radius < fabs( rc ) ) ) {
1656 direction = ( ( fabs( rc ) < radius ) ? ( 1 ) : ( -1 ) );
1660 if ( direction == -1 ) {
1662 if ( directionPlus == -1 ) {
1669 if ( xc >= patch->
xMin ) {
1680 fprintf( stderr,
"WARNING: Fixing yymin (%d -> 0) [ConstructPLUT.c %d]\n",
1684 if ( yymax >= patch->
ySide ) {
1685 fprintf( stderr,
"WARNING: Fixing yymax (%d -> %d) [ConstructPLUT.c %d]\n",
1686 yymax, patch->
ySide - 1, __LINE__ );
1687 yymax = patch->
ySide - 1;
1702 lut->
bin[currentBin + 1].
leftB1 = lastBorder;
1707 if ( xc <= patch->xMax ) {
1718 fprintf( stderr,
"WARNING: Fixing yymin (%d -> 0) [ConstructPLUT.c %d]\n",
1722 if ( yymax >= patch->
ySide ) {
1723 fprintf( stderr,
"WARNING: Fixing yymax (%d -> %d) [ConstructPLUT.c %d]\n",
1724 yymax, patch->
ySide - 1, __LINE__ );
1725 yymax = patch->
ySide - 1;
1740 lut->
bin[currentBin + 1].
rightB2 = lastBorder;
1745 if ( pieces == 0 ) {
1759 if ( xc >= patch->
xMin ) {
1770 fprintf( stderr,
"WARNING: Fixing yymin (%d -> 0) [ConstructPLUT.c %d]\n",
1774 if ( yymax >= patch->
ySide ) {
1775 fprintf( stderr,
"WARNING: Fixing yymax (%d -> %d) [ConstructPLUT.c %d]\n",
1776 yymax, patch->
ySide - 1, __LINE__ );
1777 yymax = patch->
ySide - 1;
1789 lut->
bin[currentBin + 1].
rightB1 = lastBorder;
1794 if ( xc <= patch->xMax ) {
1805 fprintf( stderr,
"WARNING: Fixing yymin (%d -> 0) [ConstructPLUT.c %d]\n",
1809 if ( yymax >= patch->
ySide ) {
1810 fprintf( stderr,
"WARNING: Fixing yymax (%d -> %d) [ConstructPLUT.c %d]\n",
1811 yymax, patch->
ySide - 1, __LINE__ );
1812 yymax = patch->
ySide - 1;
1824 lut->
bin[currentBin + 1].
leftB2 = lastBorder;
1829 if ( pieces == 0 ) {
1839 *lastBorderP = lastBorder;
1840 *pathologyP = pathology;
1841 *directionP = direction;
1885 lastBorder = *lastBorderP;
1886 pathology = *pathologyP;
1887 direction = *directionP;
1889 rho1 = cos( ang1 ) / ( 1. - sin( ang1 ) );
1890 rho2 = cos( ang2 ) / ( 1. - sin( ang2 ) );
1892 xc = rc * cos(
alpha );
1893 yc = rc * sin(
alpha );
1894 radius = fabs( rho1 -
rho2 );
1898 if ( ( yc + radius < patch->yMin ) || ( yc - radius > patch->
yMax ) ||
1899 ( xc + radius < patch->xMin ) || ( xc - radius > patch->
xMax ) ||
1900 ( sqrt( patch->
xMax * patch->
xMax + patch->
yMax * patch->
yMax ) + radius < fabs( rc ) ) ) {
1910 if ( direction == -1 ) {
1915 if ( xc >= patch->
xMin ) {
1926 fprintf( stderr,
"WARNING: Fixing yymin (%d -> 0) [ConstructPLUT.c %d]\n",
1930 if ( yymax >= patch->
ySide ) {
1931 fprintf( stderr,
"WARNING: Fixing yymax (%d -> %d) [ConstructPLUT.c %d]\n",
1932 yymax, patch->
ySide - 1, __LINE__ );
1933 yymax = patch->
ySide - 1;
1944 lut->
bin[currentBin + 1].
leftB1 = lastBorder;
1949 if ( xc <= patch->xMax ) {
1960 fprintf( stderr,
"WARNING: Fixing yymin (%d -> 0) [ConstructPLUT.c %d]\n",
1964 if ( yymax >= patch->
ySide ) {
1965 fprintf( stderr,
"WARNING: Fixing yymax (%d -> %d) [ConstructPLUT.c %d]\n",
1966 yymax, patch->
ySide - 1, __LINE__ );
1967 yymax = patch->
ySide - 1;
1977 lut->
bin[currentBin].
leftB2 = lastBorder;
1978 lut->
bin[currentBin + 1].
rightB2 = lastBorder;
1983 if ( pieces == 0 ) {
1998 if ( ( rcOld - rCritic ) * ( rc - rCritic ) < 0 ) {
2005 if ( xc >= patch->
xMin ) {
2016 fprintf( stderr,
"WARNING: Fixing yymin (%d -> 0) [ConstructPLUT.c %d]\n",
2020 if ( yymax >= patch->
ySide ) {
2021 fprintf( stderr,
"WARNING: Fixing yymax (%d -> %d) [ConstructPLUT.c %d]\n",
2022 yymax, patch->
ySide - 1, __LINE__ );
2023 yymax = patch->
ySide - 1;
2034 lut->
bin[currentBin].
leftB1 = lastBorder;
2035 lut->
bin[currentBin + 1].
rightB1 = lastBorder;
2038 lut->
bin[currentBin + 1].
leftB1 = lastBorder;
2044 if ( xc <= patch->xMax ) {
2055 fprintf( stderr,
"WARNING: Fixing yymin (%d -> 0) [ConstructPLUT.c %d]\n",
2059 if ( yymax >= patch->
ySide ) {
2060 fprintf( stderr,
"WARNING: Fixing yymax (%d -> %d) [ConstructPLUT.c %d]\n",
2061 yymax, patch->
ySide - 1, __LINE__ );
2062 yymax = patch->
ySide - 1;
2074 lut->
bin[currentBin + 1].
leftB2 = lastBorder;
2076 lut->
bin[currentBin].
leftB1 = lastBorder;
2077 lut->
bin[currentBin + 1].
rightB2 = lastBorder;
2083 if ( pieces == 0 ) {
2092 *lastBorderP = lastBorder;
2093 *pathologyP = pathology;
2094 *directionP = direction;
2134 INT4 noIn, noIn1, noIn2;
2136 REAL8 yupper, kkpos;
2146 if ( xc < patch->xMin ) {
2154 ylower =
MAX( patch->
yMin, yc - radius );
2155 yupper =
MIN( patch->
yMax, yc + radius );
2159 kkk = yupper / patch->
deltaY - 0.5;
2160 kkk += 0.5 * patch->
ySide;
2161 yymax = floor( kkk );
2163 kkk = ylower / patch->
deltaY - 0.5;
2164 kkk += 0.5 * patch->
ySide;
2165 yymin = ceil( kkk );
2176 if ( ( yymax < 0 ) || ( yymin > patch->
ySide - 1 ) ) {
2184 if ( yc < patch->yMax ) {
2190 kkpos = ( radius - ( yupper - yc ) ) * ( radius + ( yupper - yc ) );
2191 kkpos = fabs( kkpos );
2193 x1 = xc - sqrt( kkpos );
2196 if ( ( x1 >= patch->
xMin ) && ( x1 <= patch->xMax ) ) {
2199 if ( x1 > patch->
xMax ) {
2200 kkpos = ( radius - ( patch->
xMax - xc ) ) * ( radius + ( patch->
xMax - xc ) );
2201 kkpos = fabs( kkpos );
2202 myy1 = yc + sqrt( kkpos );
2205 if ( myy1 >= patch->
yMin ) {
2209 kkk = myy1 / patch->
deltaY - 0.5;
2210 kkk += 0.5 * patch->
ySide;
2211 yymax = floor( kkk );
2212 distance2 = ( xc - patch->
xMax ) * ( xc - patch->
xMax ) + ( yc - patch->
yCoor[yymax] ) * ( yc - patch->
yCoor[yymax] );
2214 if ( distance2 < radius * radius ) {
2226 if ( yc > patch->
yMin ) {
2230 kkpos = ( radius - ( yc - ylower ) ) * ( radius + ( yc - ylower ) );
2231 kkpos = fabs( kkpos );
2232 x1 = xc - sqrt( kkpos );
2235 if ( ( x1 >= patch->
xMin ) && ( x1 <= patch->xMax ) ) {
2238 if ( x1 > patch->
xMax ) {
2239 kkpos = ( radius - ( patch->
xMax - xc ) ) * ( radius + ( patch->
xMax - xc ) );
2240 kkpos = fabs( kkpos );
2241 myy1 = yc - sqrt( kkpos );
2245 if ( myy1 <= patch->yMax ) {
2249 kkk = myy1 / patch->
deltaY - 0.5;
2250 kkk += 0.5 * patch->
ySide;
2251 yymin = ceil( kkk );
2252 distance2 = ( xc - patch->
xMax ) * ( xc - patch->
xMax ) + ( yc - patch->
yCoor[yymin] ) * ( yc - patch->
yCoor[yymin] );
2253 if ( distance2 < radius * radius ) {
2266 if ( noIn1 && ( !noIn2 ) ) {
2270 kkpos = ( radius - ( yc - ylower ) ) * ( radius + ( yc - ylower ) );
2271 kkpos = fabs( kkpos );
2272 x1 = xc - sqrt( kkpos );
2275 if ( x1 < patch->xMin ) {
2277 kkpos = ( radius - ( patch->
xMin - xc ) ) * ( radius + ( patch->
xMin - xc ) );
2278 kkpos = fabs( kkpos );
2279 myy1 = yc + sqrt( kkpos );
2282 kkk = myy1 / patch->
deltaY - 0.5;
2283 kkk += 0.5 * patch->
ySide;
2284 yymin = ceil( kkk );
2290 if ( ( ! noIn1 ) && noIn2 ) {
2295 kkpos = ( radius - ( yupper - yc ) ) * ( radius + ( yupper - yc ) );
2296 kkpos = fabs( kkpos );
2297 x1 = xc - sqrt( kkpos );
2300 if ( x1 < patch->xMin ) {
2302 kkpos = ( radius - ( patch->
xMin - xc ) ) * ( radius + ( patch->
xMin - xc ) );
2303 kkpos = fabs( kkpos );
2304 myy1 = yc - sqrt( kkpos );
2307 kkk = myy1 / patch->
deltaY - 0.5;
2308 kkk += 0.5 * patch->
ySide;
2309 yymax = floor( kkk );
2315 if ( noIn1 && noIn2 ) {
2346 INT4 noIn, noIn1, noIn2;
2349 REAL8 yupper, kkpos;
2357 if ( xc > patch->
xMax ) {
2364 ylower =
MAX( patch->
yMin, yc - radius );
2365 yupper =
MIN( patch->
yMax, yc + radius );
2369 kkk = yupper / patch->
deltaY - 0.5;
2370 kkk += 0.5 * patch->
ySide;
2371 yymax = floor( kkk );
2374 kkk = ( ylower / patch->
deltaY - 0.5 );
2375 kkk += 0.5 * patch->
ySide;
2376 yymin = ceil( kkk );
2378 if ( ( yymax < 0 ) || ( yymin > patch->
ySide - 1 ) ) {
2387 if ( yc < patch->yMax ) {
2392 kkpos = ( radius - ( yupper - yc ) ) * ( radius + ( yupper - yc ) );
2393 kkpos = fabs( kkpos );
2394 x1 = xc + sqrt( kkpos );
2398 if ( ( x1 >= patch->
xMin ) && ( x1 <= patch->xMax ) ) {
2401 if ( x1 < patch->xMin ) {
2402 kkpos = ( radius - ( patch->
xMin - xc ) ) * ( radius + ( patch->
xMin - xc ) );
2403 kkpos = fabs( kkpos );
2404 myy1 = yc + sqrt( kkpos );
2407 if ( myy1 >= patch->
yMin ) {
2411 kkk = myy1 / patch->
deltaY - 0.5;
2412 kkk += 0.5 * patch->
ySide;
2413 yymax = floor( kkk );
2423 if ( yc > patch->
yMin ) {
2426 kkpos = ( radius - ( yc - ylower ) ) * ( radius + ( yc - ylower ) );
2427 kkpos = fabs( kkpos );
2428 x1 = xc + sqrt( kkpos );
2431 if ( ( x1 >= patch->
xMin ) && ( x1 <= patch->xMax ) ) {
2434 if ( x1 < patch->xMin ) {
2435 kkpos = ( radius - ( patch->
xMin - xc ) ) * ( radius + ( patch->
xMin - xc ) );
2436 kkpos = fabs( kkpos );
2437 myy1 = yc - sqrt( kkpos );
2440 if ( myy1 <= patch->yMax ) {
2444 kkk = myy1 / patch->
deltaY - 0.5;
2445 kkk += 0.5 * patch->
ySide;
2446 yymin = ceil( kkk );
2456 if ( noIn1 && ( !noIn2 ) ) {
2460 kkpos = ( radius - ( yc - ylower ) ) * ( radius + ( yc - ylower ) );
2461 kkpos = fabs( kkpos );
2462 x1 = xc + sqrt( kkpos );
2465 if ( x1 > patch->
xMax ) {
2467 kkpos = ( radius - ( patch->
xMax - xc ) ) * ( radius + ( patch->
xMax - xc ) );
2468 kkpos = fabs( kkpos );
2469 myy1 = yc + sqrt( kkpos );
2474 kkk = myy1 / patch->
deltaY - 0.5;
2475 kkk += 0.5 * patch->
ySide;
2476 yymin = ceil( kkk );
2482 if ( ( ! noIn1 ) && noIn2 ) {
2487 kkpos = ( radius - ( yupper - yc ) ) * ( radius + ( yupper - yc ) );
2488 kkpos = fabs( kkpos );
2489 x1 = xc + sqrt( kkpos );
2491 if ( x1 > patch->
xMax ) {
2493 kkpos = ( radius - ( patch->
xMax - xc ) ) * ( radius + ( patch->
xMax - xc ) );
2494 kkpos = fabs( kkpos );
2495 myy1 = yc - sqrt( kkpos );
2500 kkk = myy1 / patch->
deltaY - 0.5;
2501 kkk += 0.5 * patch->
ySide;
2502 yymax = floor( kkk );
2509 if ( noIn1 && noIn2 ) {
2552 for ( jj = yymin; jj <= yymax; ++jj ) {
2557 kkpos = ( radius - ( yc - patch->
yCoor[jj] ) ) * ( radius + ( yc - patch->
yCoor[jj] ) );
2558 kkpos = fabs( kkpos );
2559 realx = xc - sqrt( kkpos );
2564 kkk = realx / patch->
deltaX - 0.5;
2565 kkk += 0.5 * patch->
xSide;
2566 myindex = ceil( kkk );
2567 if ( myindex < 0 ) {
2570 if ( myindex > patch->
xSide ) {
2571 myindex = patch->
xSide;
2574 column[jj] = myindex;
2592 for ( jj = yymin; jj <= yymax; ++jj ) {
2597 kkpos = ( radius - ( yc - patch->
yCoor[jj] ) ) * ( radius + ( yc - patch->
yCoor[jj] ) );
2598 kkpos = fabs( kkpos );
2599 realx = xc + sqrt( kkpos );
2604 kkk = realx / patch->
deltaX - 0.5;
2605 kkk += 0.5 * patch->
xSide;
2606 myindex = ceil( kkk );
2607 if ( myindex < 0 ) {
2610 if ( myindex > patch->
xSide - 1 ) {
2611 myindex = patch->
xSide;
2613 column[jj] = myindex;
2643 INT4 lb1, rb1, lb2, rb2;
2647 lastBorder = *lastBorderP;
2670 FillCaseN1( lb1, rb1, currentBin, lut, patch );
2674 if ( lb1 && !( rb1 ) && !( lb2 ) ) {
2679 if ( lb1 && !( rb1 ) && lb2 ) {
2680 FillCaseN3( lb1, lb2, currentBin, &lastBorder, lut, patch );
2681 *lastBorderP = lastBorder;
2685 if ( !( lb1 ) && rb1 && !( rb2 ) ) {
2690 if ( !( lb1 ) && rb1 && rb2 ) {
2695 if ( !( lb1 ) && !( rb1 ) && lb2 && rb2 ) {
2696 FillCaseN6( lb2, rb2, currentBin, lut, patch );
2700 if ( !( lb1 ) && !( rb1 ) && lb2 && !( rb2 ) ) {
2705 if ( !( lb1 ) && !( rb1 ) && !( lb2 ) && rb2 ) {
2710 if ( !( currentBin ) && !( lb1 ) && !( rb1 ) && !( lb2 ) && !( rb2 ) ) {
2726 INT4 lb1UpY, lb1LoY;
2727 INT4 rb1UpY, rb1LoY;
2733 if ( ( lb1UpY == patch->
ySide - 1 ) && ( lb1LoY == 0 ) ) {
2743 if ( lb1LoY > yCl ) {
2745 if ( rb1LoY > yCr ) {
2753 if ( lb1UpY < yCl ) {
2755 if ( rb1UpY < yCr ) {
2771 INT4 lb1UpY, lb1LoY;
2778 if ( lb1LoY > yCl ) {
2784 if ( lb1UpY < yCl ) {
2798 INT4 lb1UpY, lb1LoY;
2799 INT4 lb2UpY, lb2LoY;
2803 lastBorder = *lastBorderP;
2810 if ( lb1LoY > yCl ) {
2818 if ( lb1UpY < yCl ) {
2831 for (
k = lb2LoY;
k <= lb2UpY; ++
k ) {
2834 *lastBorderP = lastBorder;
2845 INT4 rb1UpY, rb1LoY;
2852 if ( rb1UpY < yCr ) {
2858 if ( rb1LoY > yCr ) {
2876 INT4 rb1UpY, rb1LoY;
2877 INT4 rb2UpY, rb2LoY;
2886 if ( rb1UpY < yCr ) {
2892 if ( rb1LoY > yCr ) {
2911 INT4 lb2UpY, lb2LoY;
2912 INT4 rb2UpY, rb2LoY;
2918 if ( ( lb2UpY == patch->
ySide - 1 ) && ( lb2LoY == 0 ) ) {
2927 if ( lb2UpY >= yCl ) {
2929 if ( rb2UpY >= yCr ) {
2936 if ( lb2LoY <= yCl ) {
2938 if ( rb2LoY <= yCr ) {
2954 INT4 lb2UpY, lb2LoY;
2961 if ( lb2UpY >= yCl ) {
2966 if ( lb2LoY <= yCl ) {
2980 INT4 rb2UpY, rb2LoY;
2990 if ( rb2UpY >= yCr ) {
2994 if ( rb2LoY <= yCr ) {
3033 INT4 lb1, rb1, lb2, rb2;
3055 if ( rb1 && !( rb2 ) && !( lb1 ) ) {
3060 if ( !( rb1 ) && lb2 && !( rb2 ) && !( lb1 ) ) {
3065 if ( !( rb1 ) && !( lb2 ) && rb2 ) {
3070 if ( !( rb1 ) && !( lb2 ) && !( rb2 ) && lb1 ) {
3081 if ( !( rb1 ) && lb2 && !( rb2 ) && lb1 ) {
3086 if ( !( rb2 ) && lb1 && rb1 ) {
3087 FillCaseA3( lb1, rb1, currentBin, lut, patch );
3091 if ( !( rb1 ) && lb2 && rb2 ) {
3092 FillCaseA3( lb2, rb2, currentBin, lut, patch );
3096 if ( !( currentBin ) && !( lb1 ) && !( rb1 ) && !( lb2 ) && !( rb2 ) ) {
3110 INT4 rb1UpY, rb1LoY;
3111 INT4 rb2UpY, rb2LoY;
3124 if ( yCr1 < rb1UpY ) {
3141 INT4 lb1UpY, lb1LoY;
3142 INT4 lb2UpY, lb2LoY;
3155 if ( yCl1 < lb1UpY ) {
3174 INT4 rb1UpY, rb1LoY;
3175 INT4 lb1UpY, lb1LoY;
3187 if ( ( lb1UpY == patch->
ySide - 1 ) && ( lb1LoY == 0 ) ) {
3192 if ( lb1UpY >= yCl1 ) {
3197 if ( lb1LoY <= yCl1 ) {
3203 if ( rb1LoY > yCr1 ) {
3208 if ( rb1UpY < yCr1 ) {
static void FollowLineCase(INT4, UINT4 *, REAL8, REAL8, REAL8, REAL8, INT4, INT4 *, HOUGHptfLUT *, HOUGHPatchGrid *)
static void InitialLineCase(UINT4 *, REAL8, REAL8, REAL8, INT4 *, HOUGHptfLUT *, HOUGHPatchGrid *)
static void FillCaseN7(INT4, INT4, HOUGHptfLUT *, HOUGHPatchGrid *)
static void FillCaseA2(INT4, INT4, INT4, HOUGHptfLUT *)
static void CheckLeftCircle(REAL8, REAL8, REAL8, INT4 *, INT4 *, INT4 *, HOUGHPatchGrid *)
static void Fill1ColumnAnor(INT4, HOUGHptfLUT *, HOUGHPatchGrid *)
static void Fill1Column(INT4, UINT4 *, HOUGHptfLUT *, HOUGHPatchGrid *)
static void FillCaseN4(INT4, INT4, HOUGHptfLUT *, HOUGHPatchGrid *)
static void FillCaseN6(INT4, INT4, INT4, HOUGHptfLUT *, HOUGHPatchGrid *)
static void FollowCircleCase(INT4, UINT4 *, REAL8, REAL8, REAL8, REAL8, REAL8, INT4 *, INT4 *, INT4 *, HOUGHptfLUT *, HOUGHPatchGrid *)
static void PLUTInitialize(HOUGHptfLUT *)
static void FillCaseN2(INT4, INT4, HOUGHptfLUT *, HOUGHPatchGrid *)
static void SecondCircleCase(INT4, UINT4 *, REAL8, REAL8, REAL8, INT4, REAL8 *, INT4 *, INT4 *, INT4 *, HOUGHptfLUT *, HOUGHPatchGrid *)
static void DrawLine(REAL8, REAL8, REAL8, INT4, INT4, COORType *, HOUGHPatchGrid *)
static void FillCaseN5(INT4, INT4, INT4, HOUGHptfLUT *)
static void DrawRightCircle(REAL8, REAL8, REAL8, INT4, INT4, COORType *, HOUGHPatchGrid *)
static void CheckLineCase(REAL8, REAL8, REAL8, REAL8 *, INT4 *)
static void FillCaseN3(INT4, INT4, INT4, INT4 *, HOUGHptfLUT *, HOUGHPatchGrid *)
static void FillCaseN1(INT4, INT4, INT4, HOUGHptfLUT *, HOUGHPatchGrid *)
static void FillCaseN8(INT4, INT4, HOUGHptfLUT *, HOUGHPatchGrid *)
static void InitialCircleCase(UINT4 *, REAL8, REAL8, REAL8, REAL8 *, INT4 *, INT4 *, HOUGHptfLUT *, HOUGHPatchGrid *)
static void DrawLeftCircle(REAL8, REAL8, REAL8, INT4, INT4, COORType *, HOUGHPatchGrid *)
static void SecondLineCase(INT4, UINT4 *, REAL8, REAL8, REAL8, INT4 *, HOUGHptfLUT *, HOUGHPatchGrid *)
static void FindLine(REAL8, REAL8, REAL8, REAL8 *, REAL8 *)
static void FillCaseA1(INT4, INT4, INT4, HOUGHptfLUT *)
static void CheckLineIntersection(REAL8, REAL8, REAL8, INT4 *, INT4 *, INT4 *, HOUGHPatchGrid *)
static void FillCaseA3(INT4, INT4, INT4, HOUGHptfLUT *, HOUGHPatchGrid *)
static void FillPLUT(HOUGHParamPLUT *, HOUGHptfLUT *, HOUGHPatchGrid *)
static void CheckRightCircle(REAL8, REAL8, REAL8, INT4 *, INT4 *, INT4 *, HOUGHPatchGrid *)
static double double delta
#define ABORT(statusptr, code, mesg)
#define INITSTATUS(statusptr)
#define RETURN(statusptr)
void LALHOUGHConstructPLUT(LALStatus *status, HOUGHptfLUT *lut, HOUGHPatchGrid *patch, HOUGHParamPLUT *par)
INT2 COORType
To be changed to {INT2 COORType} if the number of pixels in the x-direction exceeds 255.
INT2 rightB2
Border index to be used (stop-border ‘ ’)
INT2 leftB1
Border index to be used (start-border ‘ ’)
INT2 piece1min
If piece1min piece1max no corrections should be added.
INT2 piece2max
Interval limits of the (second piece) correction to the first column.
INT2 rightB1
Border index to be used (stop-border ‘ ’)
INT2 piece1max
Interval limits of the (first piece) correction to the first column.
INT2 leftB2
Border index to be used (start-border ‘ ’)
INT2 piece2min
If piece2min piece2max no corrections should be added.
COORType * xPixel
x pixel index to be marked
INT4 yLower
lower y pixel affected by this border and yUpper<yLower or yUpper<0 are possible
INT4 yCenter
y pixel value of the center of the circle
INT4 yUpper
upper y pixel affected by this border
Parameters needed to construct the partial look up table.
This structure stores patch-frequency grid information.
UINT2 ySide
Real number of pixels in the y-direction (in the projected plane).
REAL8 deltaY
Longitudinal space resolution, y-direction.
REAL8 yMin
Patch limit, as center of the first pixel.
UINT2 xSide
Real number of pixels in the x direction (in the projected plane); it should be less than or equal to...
REAL8 yMax
Patch limit, as center of the last pixel.
REAL8 deltaX
Longitudinal space resolution, x-direction.
REAL8 xMin
Patch limit, as the coordinate of the center of the first pixel.
REAL8 xMax
Patch limit, as the coordinate of the center of the last pixel.
REAL8 * yCoor
Coordinates of the pixel centers.
REAL8 deltaF
Frequency resolution: df=1/TCOH
This structure stores the patch-time-frequency look up table.
INT4 offset
Frequency bin corresponding to center of patch measured with respect to f0Bin (zero in modulated case...
REAL8 deltaF
Frequency resolution df=1/TCOH, where 1/TCOH is the coherent integration time used in teh demodulatio...
UINT2 maxNBins
Maximum number of bins affecting the patch (for memory allocation purposes)
INT4 nBin
Exact number of bins affecting the patch.
HOUGHBorder * border
The annulus borders.
INT4 iniBin
First bin affecting the patch with respect to f0.
HOUGHBin2Border * bin
Bin to border correspondence.
UINT2 maxNBorders
Maximum number of borders affecting the patch (for memory allocation purposes)
INT8 f0Bin
Frequency bin for which it has been constructed.
INT8 nFreqValid
Number of frequencies where the lut is valid.