Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
6 changes: 3 additions & 3 deletions src/coord/polar/Polar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -228,12 +228,12 @@ class Polar implements CoordinateSystem, CoordinateSystemMaster {
// Start angle and end angle don't matter
const dx = x - this.cx;
const dy = y - this.cy;
// minus a tiny value 1e-4 to avoid being clipped unexpectedly
const d2 = dx * dx + dy * dy - 1e-4;
const d2 = dx * dx + dy * dy;
const r = this.r;
const r0 = this.r0;

return d2 <= r * r && d2 >= r0 * r0;
// minus a tiny value 1e-4 in double side to avoid being clipped unexpectedly
return (d2 - 1e-4) <= r * r && (d2 + 1e-4) >= r0 * r0;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Please consider the scenario where r is equal to r0, in which case the data within the polar coordinates should consistently be clipped. Therefore, I recommend adding r !== r0 && as a safeguard. Additionally, to minimize redundancy, we may define a constant const epsilon = 1e-4;.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

OK got this. I will do this tody

}
};
}
Expand Down
39 changes: 39 additions & 0 deletions test/clip.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.