Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think a comment is necessary to clarify what problem is being avoided by the parallel increment of the integer and the double. And I might name the variable that holds "r-squared" something like r_sq.

dr *= dr;
for (auto dy = std::make_pair<int, double>(-r, -r); dy.first <= r; ++dy.first, ++dy.second) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some C++ style guides frown on applying the increment/decrement operators to floating-point values. However, I don't think the LSST style guide mentions this.

Still, dy.second += 1.0 might help the reader understand the nature of the parallelism a bit more.

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