Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(polar): fix unexpected clipping in polar coordinate #20370

Merged
merged 3 commits into from
Sep 26, 2024
Merged
Show file tree
Hide file tree
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
9 changes: 5 additions & 4 deletions src/coord/polar/Polar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ class Polar implements CoordinateSystem, CoordinateSystemMaster {
const angleExtent = angleAxis.getExtent();

const RADIAN = Math.PI / 180;

const EPSILON = 1e-4;
return {
cx: this.cx,
cy: this.cy,
Expand All @@ -228,12 +228,13 @@ 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
// r == r0 contain nothing
return r !== r0 && (d2 - EPSILON) <= r * r && (d2 + EPSILON) >= r0 * r0;
}
};
}
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.