Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I am trying to place a rectangle on top of an imaginary circle of certain radius, whose center lies in the middle of another rectangle. What I've tried so far is the following

\documentclass{article}

\usepackage{kerkis}
\usepackage{tikz}

\begin{document}
 \begin{tikzpicture}
  % Incident Beam
  \draw[->, thick] (0,0) -- (2,0);
  % Target : Boron + Au --- The center of the imaginary circle is in the center of these rectangles
  \draw[gray!30,fill=gray!30] (6,1) rectangle (6.5,-1);
  \draw[gray!70,fill=gray!70] (6.5,1) rectangle (8.5,-1);
  % Scattering Chamber - The imaginary circle
  %\draw[thick,red,->,dashed] ([shift=(-120:5cm)]7.25,0) arc (0:100:-1cm);
  %\draw[dashed, gray!50] (7.25,0) circle (7cm);
  % Telescopes --- I want to place this rectangle on 170 degrees on top of the imaginary circle
  \draw[black!70, fill=black!70, rotate=30] (2,-2) rectangle (2.5, -2.5); 
 \end{tikzpicture}
\end{document}

My output is

enter image description here

How to place this black rectangle, on a certain angle on top of the dashed circle?

share|improve this question

3 Answers 3

up vote 4 down vote accepted

If the center of the imaginare circle is on (7.25,0) and the radius of the circle is 7cm you can insert a rotated rectangular node at (7.25,0)+(170:7):

\path(7.25,0)+(170:7)
  node[
    fill=black!70,
    minimum width=.5cm,minimum height=1cm,% rectangle
    rotate=80 % 170°-90°=80°
  ]{};

enter image description here

Code:

\documentclass[margin=5mm]{standalone}
\usepackage{tikz}

\begin{document}
\begin{tikzpicture}
  % Incident Beam
  \draw[->, thick] (0,0) -- (2,0);
  % Target : Boron + Au --- The center of the imaginary circle is in the center of these rectangles
  \draw[gray!30,fill=gray!30] (6,1) rectangle (6.5,-1);
  \draw[gray!70,fill=gray!70] (6.5,1) rectangle (8.5,-1);
  % Scattering Chamber - The imaginary circle
  %\draw[thick,red,->,dashed] ([shift=(-120:5cm)]7.25,0) arc (0:100:-1cm);
  \draw[dashed, red] (7.25,0)coordinate(M) circle [radius=7cm];
  % Telescopes --- I want to place this rectangle on 170 degrees on top of the imaginary circle
  \path(7.25,0)+(170:7)
    node[fill=black!70,
    minimum width=.5cm,minimum height=1cm,% rectangle
    rotate=80 % 170°-90°=80°
    ]{};
\end{tikzpicture}
\end{document}
share|improve this answer
    
Thank you very much for your answer! What I want to do is draw a rectangle instead of a square. How is that possible inside a node? –  Thanos Jul 8 at 6:55
    
I used minimum width and minimum height to create a rectangle instead of a square! –  Thanos Jul 8 at 7:31

You can also use nodes,

\documentclass[tikz]{standalone}
\begin{document}
\begin{tikzpicture}
\node[draw,dotted,minimum size=3cm,circle] (a) {};
\node[fill,minimum size=2mm,rotate=55,inner sep=0] at (a.140) {};
\end{tikzpicture}
\end{document}

enter image description here

share|improve this answer

Another idea: use a sloped node for the filled square. This way, you don't have to specify the angle to rotate that square, it will be automatically computed to be aligned with the radius of the circle:

\begin{tikzpicture}
  \tikzset{
    my square/.style={
       fill=orange!70, 
       minimum size=2mm, 
       pos=1, 
       sloped
    }
  }

  \draw [dotted] (0,0) circle(1.5cm);
  \foreach \angle in {0,30,...,360}
    \foreach \distance in {0.9,1.2,1.5}
      \path (0,0) -- (\angle:\distance) 
         node[my square] {};
\end{tikzpicture}

Result

Update

Answering the additional question in the comment, a rectangle can be drawn giving the minimum width and height of the node. It can be useful, however, to leave the width as a parameter with a default value:

\begin{tikzpicture}
  \tikzset{
    my rectangle/.style={
       fill=orange!70, 
       minimum width=#1,   % The width is a parameter
       minimum height=2mm, 
       pos=1, 
       sloped
    },
    my rectangle/.default = 4mm,   % Width when not specified
  }

  \draw [dotted] (0,0) circle(1.5cm);

  % Some rectangles with default width
  \foreach \angle in {0,30,...,330}
     \path (0,0) -- (\angle:1.5) node[my rectangle] {};

  % Other rectangles with given width (and different color)
  \foreach \angle in {0,90,...,330}
     \path (0,0) -- (\angle:1.5) node[my rectangle=7mm, red] {};
\end{tikzpicture}

Result2

share|improve this answer
    
I really like your approach! What if I want to create rectangles and not squares? I tried adding maximum size=20mm but it wasn't valid... –  Thanos Jul 8 at 6:38
    
Instead I used minimum width and minimum height which is valid! –  Thanos Jul 8 at 7:30
    
@Thanos, see my updated answer –  JLDiaz Jul 8 at 8:06

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.