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

pie() / arc() rendering bug for specific combination of radii #119

Closed
danburzo opened this issue Mar 7, 2018 · 5 comments
Closed

pie() / arc() rendering bug for specific combination of radii #119

danburzo opened this issue Mar 7, 2018 · 5 comments

Comments

@danburzo
Copy link

danburzo commented Mar 7, 2018

While toying with the parameters for pie and arc, I have found a glitch for this configuration:

{
  "innerRadius": 23,
  "outerRadius": 128,
  "cornerRadius": 14,
  "padAngle": 0.06,
  "values": [6, 6]
}

Which outputs this shape:

screen shot 2018-03-07 at 17 59 40

Not sure if it warrants further investigation, but I wanted to let you know.

Seems to be a kind of floating point error, since it happens only on specific combinations of values and radii.

Other combinations can cause different glitches:

{
  "innerRadius": 20,
  "outerRadius": 115,
  "cornerRadius": 13,
  "padAngle": 0.06,
  "values": [ 6, 6 ]
}

Outputs the shape below:

screen shot 2018-03-07 at 18 30 19

@danburzo danburzo changed the title pie() / arc() rendering bug for specific combination of inner/outer/corner/pad radius Mar 7, 2018
@danburzo danburzo changed the title arc() rendering bug for specific combination of inner/outer/corner/pad radius Mar 7, 2018
@mbostock
Copy link
Member

mbostock commented Mar 7, 2018

@mbostock
Copy link
Member

mbostock commented Mar 7, 2018

Just noticed you already linked to an Observable notebook to reproduce this issue. Well played, sir.

@danburzo
Copy link
Author

danburzo commented Mar 7, 2018

I wouldn't dare show up without an Observable notebook to reproduce this issue! :)

Would you say that it's benign that the pie() generator produces π as the angle for most identical value pairs, but "almost π" for [6, 6]? (I still have to read more carefully through the code to have any useful points to make).

@mbostock
Copy link
Member

mbostock commented Mar 7, 2018

It’s not exactly π because the padAngle is non-zero.

@danburzo
Copy link
Author

danburzo commented Mar 7, 2018

Looking through the code for the pie() generator, it seems that in the case of N identical values, the padAngle gets eliminated and the angle span for each slice is (2 * π / N), which for N = 2 gives us π — in most cases, except that for [6, 6] and particular padAngle values it results in not-quite-π.

(Not sure if it's relevant but it seems counter-intuitive for the padAngle to evaporate in these specific cases? Edit: I realized later that padAngle is included within each slice's angle span)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants