JPITTXY2C43TV7GPYP6MWZJBMRPA6FDB2YVLTTJ2CTW6TZJXMR3AC
NFGGK4RXMB4KTXY25Q3R6LKU7D3AU4D2BPKLIM4RIQBDMBQ3VOWAC
PHJ2TT2CQ2IRXOB5KAV2664KKTPYFPFUIBEGAOQBGB4SAZ7PKNHAC
SGBBXP6UM37WUCHR3GEKLZURBQRTFE6C4NSF7EY6PXRNR2WYWXTQC
SVY2PTCLXR3KNPQAWXVXTTGCC5DR334HOAKHYO3VDDRWM2BWMALAC
ACZYEIX7WMPIIODKCATBCUE626AJ4ZGGBOMVC6BGXM27EQU2RECAC
6UEYAQ27626W64EMNMW33D24RJEZNJPEPEOKNMU524SIL5VSTHOAC
UFMQQPYCBI6Z576P7PH4ZAPC7L7P3D4H66NJMFQKP6WRAPIK2NOQC
// Advance a ray in quadrant 0.
// note that slope must be nonnegative!
// returns 0 if the advance was in x, 1 if it was in y, 2 if it was
// the diagonal
static int _find_next_intercept(double* accx, double* accy, const double slope)
{
// handle perpendiculars
if (double_is_zero(slope))
{
*accx += 1.0;
return 0;
}
if (slope > 100.0)
{
*accy += 1.0;
return 1;
}
const double xtarget = static_cast<int>(*accx) + 1;
const double ytarget = static_cast<int>(*accy) + 1;
const double xdistance = xtarget - *accx;
const double ydistance = ytarget - *accy;
double distdiff = xdistance * slope - ydistance;
// exact corner
if (double_is_zero(distdiff))
{
// move somewhat away from the corner
if (slope > 1.0)
{
*accx = xtarget + EPSILON_VALUE * 2;
*accy = ytarget + EPSILON_VALUE * 2 * slope;
}
else
{
*accx = xtarget + EPSILON_VALUE * 2 / slope;
*accy = ytarget + EPSILON_VALUE * 2;
}
return 2;
}
// move to the boundary
double traveldist;
int rc = -1;
if (distdiff > 0.0)
{
traveldist = ydistance / slope;
rc = 1;
}
else
{
traveldist = xdistance;
rc = 0;
}
// and a little into the next cell, taking care
// not to go too far
if (distdiff < 0.0)
distdiff = -distdiff;
traveldist += std::min(EPSILON_VALUE * 10.0, 0.5 * distdiff / slope);
*accx += traveldist;
*accy += traveldist * slope;
return rc;
}
// Advance a ray in quadrant 0.
// note that slope must be nonnegative!
// returns 0 if the advance was in x, 1 if it was in y, 2 if it was
// the diagonal
int ray_def::_find_next_intercept()
{
// handle perpendiculars
if (double_is_zero(slope))
{
accx += 1.0;
return 0;
}
if (slope > 100.0)
{
accy += 1.0;
return 1;
}
const double xtarget = static_cast<int>(accx) + 1;
const double ytarget = static_cast<int>(accy) + 1;
const double xdistance = xtarget - accx;
const double ydistance = ytarget - accy;
double distdiff = xdistance * slope - ydistance;
// exact corner
if (double_is_zero(distdiff))
{
// move somewhat away from the corner
if (slope > 1.0)
{
accx = xtarget + EPSILON_VALUE * 2;
accy = ytarget + EPSILON_VALUE * 2 * slope;
}
else
{
accx = xtarget + EPSILON_VALUE * 2 / slope;
accy = ytarget + EPSILON_VALUE * 2;
}
return 2;
}
// move to the boundary
double traveldist;
int rc = -1;
if (distdiff > 0.0)
{
traveldist = ydistance / slope;
rc = 1;
}
else
{
traveldist = xdistance;
rc = 0;
}
// and a little into the next cell, taking care
// not to go too far
if (distdiff < 0.0)
distdiff = -distdiff;
traveldist += std::min(EPSILON_VALUE * 10.0, 0.5 * distdiff / slope);
accx += traveldist;
accy += traveldist * slope;
return rc;
}
_find_next_intercept(&ax, &ay, slope);
curx = static_cast<int>(ax);
cury = static_cast<int>(ay);
if (curx*curx + cury*cury > radius2)
copy._find_next_intercept();
c = copy.pos();
if (c.abs() > radius2)