kicad-developers team mailing list archive
Mailing list archive
Re: Re: Metric and English grids sizes.
--- In kicad-devel@xxxxxxxxxxxxxxx, jean-pierre charras - INPG <jean-pierre.charras@...> wrote:
Unfortunately, grid size cannot be handled in decimils.
In pcbnew grid is handled as double.
This is because for many grids values in mm, using a value rounded in
decimils creates a cummulative error that can be important
(some mm for a 300 mm board)
So grid sizes must be given
- always in inches or decimils but using a floating point value, for non
integer values as needed for metric grids
- or as an integer in decimils or um units and give the used unit (um ou
decimil) as parameter
Maître de conférences
Directeur d'études 2ieme année.
Génie Electrique et Informatique Industrielle 2
Institut Universitaire de Technologie 1 de Grenoble
BP 67, 38402 St Martin d'Heres Cedex
Grenoble Image Parole Signal Automatique (GIPSA - INPG)
Actually, the best internal unit to use in pcbnew would be nanometers (1nm = 0.001um = 0.000001mm), because then both grid size and all coordinates, both metric and imperial, could be expressed with 100% accuracy with integers.
And we don't even need 64bit integers either - a 32bit signed integer would be able to hold coords (and grids) ranging up to +/-2.15 meters or +/-84.5 inches, which I think is enough for kicad :-)
If 4.6 m^2 (49.6 foot^2) of board space isn't enough, use 10nm (centimicrons or decananometers :-) to get a 21.5m/845" coord range (460 m^2 or 273 yard^2), which surely must be enough for everyone ?-)
1 mm = 393.700787401... dmil (ugly and inaccurate)
1 inch = 25.4 mm = 25400 um = 25400000 nm
1 mm = 1000 um = 1000000 nm
1 mil = 0.0254 mm = 25.4 um = 25400 nm
1 dmil = 0.00254 mm = 2.54 um = 2540 nm
The first conversion is the one that requires floats, and it will never ever be 100% accurate.
All the others are simple and 100% accurate integer conversions:
mm2nm(x) = 1000000*x
dmil2nm(x) = 2540*x
So, any metric value, down to 1nm (or 10nm) of precision, and any imperial value with dmil precision can be converted to nm (or 10nm == 1cu == 1danm (*1)) without _any_ loss of accuracy.
(*1) The use of multiple SI prefixes isn't actually allowed, but let's just bend the rules a little :-)
So now we've reach that common point where we have about 7 emails
detailing a feature for which we have no firm volunteers. Funny thing
is, when the volunteer steps up, he will probably have forgotten what
the discussion was all about and end up coding it the way he or she