Skip to content

Commit

Permalink
Fix SpanSet Creation from large circles
Browse files Browse the repository at this point in the history
Fix an issue where data-types were not large enough to hold values
that may be plausibly used.
  • Loading branch information
natelust authored and timj committed Jul 13, 2023
1 parent 4d318ec commit 423be5b
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/geom/SpanSet.cc
Original file line number Diff line number Diff line change
Expand Up @@ -691,9 +691,13 @@ std::shared_ptr<SpanSet> SpanSet::fromShape(int r, Stencil s, lsst::geom::Point2
tempVec.reserve(2 * r + 1);
switch (s) {
case Stencil::CIRCLE:
for (auto dy = -r; dy <= r; ++dy) {
int dx = static_cast<int>(sqrt(r * r - dy * dy));
tempVec.emplace_back(dy + offset.getY(), -dx + offset.getX(), dx + offset.getX());
{
double dr = static_cast<double>(r);
dr *= dr;
for (auto dy = std::make_pair<int, double>(-r, -r); dy.first <= r; ++dy.first, ++dy.second) {
int dx = static_cast<int>(sqrt(dr-(dy.second*dy.second)));
tempVec.emplace_back(dy.first + offset.getY(), -dx + offset.getX(), dx + offset.getX());
}
}
break;
case Stencil::MANHATTAN:
Expand Down

0 comments on commit 423be5b

Please sign in to comment.