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

Precision relative to viewbox or max demical point #141

Open
pborunda opened this issue Feb 27, 2017 · 2 comments · May be fixed by #262
Open

Precision relative to viewbox or max demical point #141

pborunda opened this issue Feb 27, 2017 · 2 comments · May be fixed by #262

Comments

@pborunda
Copy link
Contributor

Ok I re-thought the problem with precision. @Ede123 I think your right about the zero being arbitrary related to #136. This is not an attempt to waste your time and sound like I'm repeat myself. Not sure if the scour project is interested in going in this direction. But thought I'd share anyway.

I think the reason that rounding near zero worked well for me was not that 0 is special. Its that the precision operation doesn't account for the dimensions of the svg image viewbox.

If I have a viewbox 100px width 100px height, normally I'm not too concerned with precision like 0.00001. Actually it seems the smallest number i work with is intervals of 0.01. So 100/0.01 = 10000 units. Which looks like 6 significant digits.

Similarly if i have a viewbox 30px by 30px, using the same 10000 units, my smallest signficant interval would be 0.003.

So how does a number like 0.00005 slip by scour, but not 1.00005?

The suggestion is to implement some limiting option like --max-decimal-point, or --precision-relative-to-viewbox, or even implicity limit the max to 10,000/100,000 units the max width/height.

@Ede123
Copy link
Member

Ede123 commented Feb 27, 2017

So how does a number like 0.00005 slip by scour, but not 1.00005?

That's the very reason for using significant digits... If you have a value of 1.00005 dropping the digits is an error of less than 0.005%. If you have a value of 0.00005 and change it to zero the error is infinity.

Now I agree there are situations where this is acceptable as it could be a simple rounding issue. However it's very hard to determine when this would be acceptable. Using the viewBox of the image would work in some cases but completely ignores that objects might be scaled.
Right now I have no good idea how this could be solved in an universal way without breaking some images. The correct approach would probably be to determine the bounding box size of a give object and adjust precision relative to that, but you probably can imagine that this is not an easy task...

@pborunda
Copy link
Contributor Author

Your rounding errors are correct when the number is rounded relative to itself. But relative to the 100px by 100px width/height, dropping the .00005 is an error of 0.00005% for both 1.00005 and 0.00005.

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

Successfully merging a pull request may close this issue.

2 participants