« Return to Thread: Circles are not very circular

Circles are not very circular

by Ken Starks :: Rate this Message:

Reply to Author | View in Thread

Yesterday 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

 « Return to Thread: Circles are not very circular