|
View:
New views
3 Messages
—
Rating Filter:
Alert me
|
|
|
Circles are not very circularYesterday I downloaded a picture of a 360 degree protractor from the
examples gallery. http://www.texample.net/tikz/examples/degree-wheel/ The outline of the protractor is a circle of radius 2.0cm, and tick-marks at degree intervals run from 1.8 cm to 2.0 cm *** However *** Some of the tick marks do not reach the circle. You can see this by magnifying the edge in Adobe Viewer. The stroke-width is large, so the gap indicates a significant error. (By the way, I can't see a gap in the PStricks version) The tick marks are OK at 0, 90, 180, 270 degrees, and at their worst at 45, 135, 225, 315 degrees. I presume that the Circle is implemented as a four-curve cubic Bezier, and suspect that the length of the control vector is too big. The normal value given in most software is 4/3 of (sqrt(2) * the radius. See for example: http://www.tinaja.com/glib/bezcirc.pdf This value forces the Bezier to be exact at eight points (0, 45, 90, ... , 315 degrees ), with small errors (always too large) in between. If this accuracy is unacceptable, you could always use more cubic-bezier-segments; you could get eight segments from a look-up table of 5 values and `four rules' arithmetic, so you don't need to rely on a TeX-based arithmetic engine for Trigonometry or square Roots. I have modified the code (see below), replacing the circle command with a low-level Bezier version, and the gaps have indeed disappeared. But I left the ordinary circle for the `shading' so you can see the difference. I would appreciate comments---and if necessary action---by someone on the programming team. Bye for now, Ken. % #################### code follows ################## % A simple compass % Author: Dario Orescanin % modified: Ken Starks % to reduce errors (Magnify at 45, 135, 225, 315 degrees, near edge of protractor) \documentclass{minimal} \usepackage{tikz} \usepackage{verbatim} \begin{comment} :Title: Degree wheel :Tags: Foreach A degree wheel inspired by `an example`_ on the `PSTricks website`_. .. _an example: http://tug.org/PSTricks/main.cgi?file=examples#compass .. _pstricks website: http://tug.org/PSTricks/main.cgi :Author: Dario Orescanin \end{comment} \begin{document} \begin{centering} % Define a few constants for easy configuration \def\radius{2cm} \def\onedegrad{1.8cm} \def\fivedegrad{1.75cm} \def\tendegrad{1.7cm} \def\labelrad{1.6cm} \begin{tikzpicture}[scale=4] % adding a subtle gray tone to add a bit of "personality" \shade[shading=radial, inner color=white, outer color=gray!15] (0,0) circle (\radius); % START OF REPLACEMENT (I've left the shading in an ordinary circle, so you can % see the difference. % \draw (0,0) circle (\radius); \def\cveclen{0.55228475*\radius} % (4.0 * (sqrt(2)-1)/3.0) * \radius % for more about accuracy, see: % http://www.tinaja.com/glib/bezcirc.pdf \pgfpathmoveto{\pgfpoint{\radius}{0cm}}; \pgfpathcurveto {\pgfpoint{\radius}{\cveclen}}{\pgfpoint{\cveclen}{\radius}}{\pgfpoint{0cm}{\radius}}; \pgfpathcurveto {\pgfpoint{-\cveclen}{\radius}}{\pgfpoint{-\radius}{\cveclen}}{\pgfpoint{-\radius}{0cm}}; \pgfpathcurveto {\pgfpoint{-\radius}{-\cveclen}}{\pgfpoint{-\cveclen}{-\radius}}{\pgfpoint{0cm}{-\radius}}; \pgfpathcurveto {\pgfpoint{\cveclen}{-\radius}}{\pgfpoint{\radius}{-\cveclen}}{\pgfpoint{\radius}{0cm}}; \pgfclosepath; \pgfusepath{stroke}; \draw[fill=black] (0,0) circle (.02mm); \node[draw, circle, inner sep=.2mm] (a) at (0,0) {}; % helper lines \foreach \x in {0, 45, ..., 360} \draw[very thin, gray!40] (a) -- (\x:\radius); % main lines \foreach \x in {0,...,359} \draw (\x:\onedegrad) -- (\x:\radius); % labels and longer lines at every 10 degrees \foreach \x in {0,10,...,350} { \node[scale=1.4, rotate=\x*-1] at (360-\x+90:\labelrad) {\x}; \draw (\x:\tendegrad) -- (\x:\radius); }; % lines at every 5 degrees \foreach \x in {0,5,...,355} \draw (\x:\fivedegrad) -- (\x:\radius); \end{tikzpicture} \end{centering} \end{document} ------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ _______________________________________________ pgf-users mailing list pgf-users@... https://lists.sourceforge.net/lists/listinfo/pgf-users |
|
|
Re: Circles are not very circularHi,
Your suggestion of 0.55228475 is what I understand to give the *maximum* error for cubic bezier approximation of circular arcs. The minimum error (again as I understand it - I am not a maths or a CAD person) is actually provided by 0.55191496. However, having just looked at \pgfpathellipse I see that the "magic number" used is actually 0.555, which is neither of these two. I don't why this number was chosen, but there may have been a good reason. I suggest submitting this either as a bug or a feature request. In the mean time replacing 0.555 in \pgfpathellipse with numbers of your choice may provide preferable results (and will effect all paths such as circle and ellipse in TikZ). \pgfpathellipse is defined in \pgfcorepathconstruct.code.tex Regards Mark ------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ _______________________________________________ pgf-users mailing list pgf-users@... https://lists.sourceforge.net/lists/listinfo/pgf-users |
|
|
Re: Circles are not very circularDear Ken, dear Mark,
the number 0.555 used in pgf is actually a bit embarrassing... I choose the value 0.555 about a zillions ago (this was already in pgf when pgf.sty was still a single file (!) ). It was found by trial and error and looked "good enough" and no one ever complained. Naturally, I should have looked up the right number. The value 0.5522847 gives much better results, indeed. Mark, 0.55191496. does not seem to give as good results as 0.5522847. Also, in the calculation from the link Ken send I think it is proved that 4/3(sqrt(2)-1) should be optimal. Where does 0.55191496 come from? Anyway, I fixed this in the CVS, which now uses 0.5522... Many thanks for pointing this out. While we are at it, do you have a good formula (implementable in TeX...) for computing the lengths of the support vectors for arcs? For instance, what is the correct length of the support vectors for an arc of 80 degrees? or 30.234 degrees? Currently, some more trial and error numbers are used and the results are, well, not-so-good... Best regards, Till Am 09.10.2008 um 20:06 schrieb Mark Wibrow: > Hi, > > Your suggestion of 0.55228475 is what I understand to give the > *maximum* error for cubic bezier approximation of circular arcs. The > minimum error (again as I understand it - I am not a maths or a CAD > person) is actually provided by 0.55191496. > > However, having just looked at \pgfpathellipse I see that the "magic > number" used is actually 0.555, which is neither of these two. I don't > why this number was chosen, but there may have been a good reason. > > I suggest submitting this either as a bug or a feature request. > > In the mean time replacing 0.555 in \pgfpathellipse with numbers of > your choice may provide preferable results (and will effect all paths > such as circle and ellipse in TikZ). \pgfpathellipse is defined in > \pgfcorepathconstruct.code.tex > > Regards > > Mark > > ------------------------------------------------------------------------- > This SF.Net email is sponsored by the Moblin Your Move Developer's > challenge > Build the coolest Linux based applications with Moblin SDK & win > great prizes > Grand prize is a trip for two to an Open Source event anywhere in > the world > http://moblin-contest.org/redirect.php?banner_id=100&url=/ > _______________________________________________ > pgf-users mailing list > pgf-users@... > https://lists.sourceforge.net/lists/listinfo/pgf-users > -- Prof. Dr. Till Tantau www.tcs.uni-luebeck.de/mitarbeiter/tantau ------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ _______________________________________________ pgf-users mailing list pgf-users@... https://lists.sourceforge.net/lists/listinfo/pgf-users |
| Free embeddable forum powered by Nabble | Forum Help |