Graphics, Figures & TablesFilling Part of a Drawing

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
MichaelB
Posts: 1
Joined: Tue Oct 15, 2013 5:21 pm

Filling Part of a Drawing

Post by MichaelB »

Hi ,

I want to fill one of two of this draw but I didn't find how to use \arcsin in calculations.

Code: Select all

\documentclass[11pt]{article}
\usepackage{tikz}
\usetikzlibrary{calc}

\begin{document}
  \begin{tikzpicture}
%    \foreach \r in {0.8,1.6,...,8.4} \fill [color=gray!20](\arcsin(0.4)/\r):\right)--(\arcsin(0.4/(\r+0.4)):\r+0.4)-- (0;0)arc (\arcsin(0.4/(\r+0.4)):\arcsin(0.8/(\r+0.4)):\r)--(\arcsin(0.8/(\r)))--cycle;
%    I need to use odd and even but first my pb is with :
%    \pgfmathparse{\arcsin(0.4/8.4)}\let\n\pgfmathresult 
%    I guess that \arcsin doesn't work ...I don't know why
    \draw (0,0) circle (0.1) ;
    \draw (0,0) circle (0.4) ;
    \foreach \y in {0.8,1.2,...,8.4}
      \draw (0,0) circle (\y);
    \clip  (0,0) circle (8.4) ;
    \foreach \x in {0.4,0.8,...,8.4}
      \draw (-10,\x)--(10,\x);
    \foreach \x in {0.4,0.8,...,8.4}
      \draw (-10,-\x)--(10,-\x);
    \draw (-10,-0.1)--(10,-0.1);
    \draw (-10,0.1)--(10,0.1);
  \end{tikzpicture}
\end{document}
Last edited by localghost on Tue Oct 15, 2013 8:26 pm, edited 1 time in total.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

cgnieder
Site Moderator
Posts: 2000
Joined: Sat Apr 16, 2011 7:27 pm

Filling Part of a Drawing

Post by cgnieder »

Hi Micheal,

Welcome to the LaTeX community. I think you're on the right track. The pgf function is asin and not \arcsin. This is described in part VI section 63.2 of the pgfmanual.

I tried to modify you MWE but it didn't work out: (\d) will not be a valid coordinate.

Code: Select all

\documentclass[11pt]{article}
\usepackage{tikz}
\usetikzlibrary{calc}

\begin{document}
  \begin{tikzpicture}
    \foreach \r in {0.8,1.6,...,8.4}
      \pgfmathparse{(asin(0.4)/\r)}
      \let\a\pgfmathresult\show\a
      \pgfmathparse{asin(0.4/(\r+0.4))}
      \let\b\pgfmathresult\show\b
      \pgfmathparse{asin(0.8/(\r+0.4))}
      \let\c\pgfmathresult\show\c
      \pgfmathparse{asin(0.8/(\r))}
      \let\d\pgfmathresult\show\d
      \fill [color=gray!20]
        (\a:\r) -- (\b:\r+0.4) -- (0,0) arc (\b:\c:\r) -- (\d) --cycle;
    \draw (0,0) circle (0.1) ;
    \draw (0,0) circle (0.4) ;
    \foreach \y in {0.8,1.2,...,8.4}
      \draw (0,0) circle (\y);
    \clip  (0,0) circle (8.4) ;
    \foreach \x in {0.4,0.8,...,8.4}
      \draw (-10,\x)--(10,\x);
    \foreach \x in {0.4,0.8,...,8.4}
      \draw (-10,-\x)--(10,-\x);
    \draw (-10,-0.1)--(10,-0.1);
    \draw (-10,0.1)--(10,0.1);
  \end{tikzpicture}
\end{document}
Regards
site moderator & package author
Post Reply