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.

the following code draws three diamonds with their ends fixed at (0,0). Can someone pls suggest a better way to do the same thing, such as drawing one diamond and rotate them as copied? Thanks!

\documentclass[10pt,a4paper]{article}
\usepackage{tikz}
\begin{document}
\begin{figure}
\begin{picture}(215,20)(0,0)
\begin{tikzpicture}

\pgftransformshift{\pgfpoint{90}{0}}; 
\filldraw[scale=1,color=black](0,0) circle(7cm); % plate
\filldraw[scale=1,white] (0,0)--++(120:2.966)--++(60:2.966)--++(300:2.966)--++(240:2.966) ;
\filldraw[scale=1,white] (0,0)--++(180:2.966)--++(240:2.966)--++(0:2.966)--++(60:2.966) ;
\filldraw[scale=1,white] (0,0)--++(0:2.966)--++(300:2.966)--++(180:2.966)--++(120:2.966) ;

\end{tikzpicture}  
\end{picture}  
\end{figure} 
\end{document}
share|improve this question
1  
You could use the rotate option. –  Caramdir Jan 31 '11 at 19:14
    
Hi thanks, but the rotate option does not rotate "as copied". SO I am confused how to use it to serve my purpose. –  gamahuri Jan 31 '11 at 19:20

6 Answers 6

as mentioned use the rotate option. You can't really copy TikZ stuff. It is simpler to store the coordinates in a macro:

\documentclass[10pt,a4paper]{article}
\usepackage{tikz}
\newcommand*\mydiamond{--++(120:2.966)--++(60:2.966)--++(300:2.966)--++(240:2.966)}

\begin{document}

\begin{figure}
\begin{tikzpicture}
\pgftransformshift{\pgfpoint{90}{0}}; 
\filldraw[scale=1,color=black](0,0) circle(7cm); % plate
\filldraw[scale=1,white] (0,0) \mydiamond ;
\filldraw[scale=1,white,rotate=120] (0,0) \mydiamond ;
\filldraw[scale=1,white,rotate=240] (0,0) \mydiamond ;
\end{tikzpicture}
\end{figure}

\end{document}

The first coordinate (0,0) is not part of the macro to allow its reuse somewhere else. BTW: The picture environment is not required

share|improve this answer

If you are simply trying to reduce keystrokes and avoid manual angle calculation, the easiest way is probably to use a foreach loop:

\documentclass[10pt,a4paper]{article}
\usepackage{tikz}
\begin{document}
\begin{figure}
\begin{picture}(215,20)(0,0)
\begin{tikzpicture}

\pgftransformshift{\pgfpoint{90}{0}}; 
\filldraw[scale=1,color=black](0,0) circle(7cm); % plate

\foreach \angle in {0,120,240}
  \filldraw[scale=1,white,rotate=\angle] (0,0)--++(120:2.966)--++(60:2.966)--++(300:2.966)--++(240:2.966) ;

\end{tikzpicture}  
\end{picture}  
\end{figure} 
\end{document}
share|improve this answer
    
I really want to reduce keystrokes! Thanks! –  gamahuri Jan 31 '11 at 19:59

It's possible to remove some useless things. I remove the picture environment and \pgftransformshift and scale =1. The color black is by default.

\documentclass[10pt,a4paper]{article}
\usepackage{tikz,fullpage}
\begin{document}

\begin{figure}[h]
\begin{tikzpicture}
\filldraw (0,0) circle(7cm);
\foreach \angle in {0,120,240}
  \filldraw[color=white,rotate=\angle] (0,0)--++(120:3)--++(60:3)--++(300:3)--++(240:3);
\end{tikzpicture}  
\end{figure}
\end{document} 
share|improve this answer
\documentclass[10pt,a4paper]{article}
\usepackage{tikz}
\begin{document}
\begin{figure}
\begin{picture}(215,20)(0,0)
\begin{tikzpicture}
%%%0
\pgftransformshift{\pgfpoint{100}{0}}; 
\filldraw[scale=0.2,color=black](0,0) circle(7cm); 
\path[coordinate, scale=0.2] (-4.15,-2.5)  coordinate(A)++( 60:8.5cm) coordinate(B)++(-60:8.5cm) coordinate(C);
\draw[fill=white] (A) -- (B) -- (C) -- cycle;
%%%%1
\pgftransformshift{\pgfpoint{90}{0}}; 
\filldraw[scale=0.2,color=black](0,0) circle(7cm); 
\foreach \angle in {0,120,240}
  \filldraw[scale=0.2,white,rotate=\angle] (0,0)--++(120:2.966)--++(60:2.966)--++(300:2.966)--++(240:2.966) ;
%%%2
\pgftransformshift{\pgfpoint{90}{0}}; 
\filldraw[scale=0.2,color=black](0,0) circle(7cm);
\foreach \angle in {0,120,240}
\filldraw[scale=0.2,white,rotate=\angle] (0,0)--++(120:1.121)--++(60:1.121)--++(180:1.121)--++(120:1.121)--++(60:1.121)--++(0:1.121)--++(120:1.121)--++(60:1.121)--++(300:1.121)--++(240:1.121)--++(0:1.121)--++(300:1.121)--++(240:1.121)--++(180:1.121)--++(300:1.121)--++(240:1.121) ;
%%%3
\pgftransformshift{\pgfpoint{90}{0}}; 
\filldraw[scale=0.2,color=black](0,0) circle(7cm);
\foreach \angle in {0,120,240}
  \filldraw[scale=0.2,white,rotate=\angle] (0,0)--++(120:00.4)--++(60:0.4)--++(180:0.4)--++(120:0.4)--++(60:0.4)--++(0:0.4)--++(120:0.4)--++(60:0.4)--++(180:0.4)--++(120:0.4)--++(240:0.4)--++(180:0.4)--++(120:0.4)--++(60:0.4)--++(180:0.4)--++(120:0.4)--++(60:0.4)--++(0:0.4)--++(120:0.4)--++(60:0.4)--++(0:0.4)--++(300:0.4)--++(60:0.4)--++(0:0.4)--++(120:00.4)--++(60:0.4)--++(180:0.4)--++(120:0.4)--++(60:0.4)--++(0:0.4)--++(120:0.4)--++(60:0.4)--++(300:00.4)--++(240:00.4)--++(0:00.4)--++(300:00.4)--++(240:00.4)--++(180:00.4)--++(300:00.4)--++(240:00.4)--++(0:00.4)--++(300:00.4)--++(60:00.4)--++(0:00.4)--++(300:00.4)--++(240:00.4)--++(0:00.4)--++(300:00.4)--++(240:00.4)--++(180:00.4)--++(300:00.4)--++(240:00.4)--++(180:00.4)--++(120:00.4)--++(240:00.4)--++(180:00.4)--++(300:0.4)--++(240:0.4)--++(0:0.4)--++(300:0.4)--++(240:0.4)--++(180:0.4)--++(300:0.4)--++(240:0.4) ;
\end{tikzpicture}  
\end{picture}  
\end{figure} 
\end{document}

enter image description here

share|improve this answer
    
There must be a better way to do that using recursion... –  Yossi Farjoun Feb 1 '11 at 13:08
    
I would really like to know that for sure.. –  gamahuri Feb 1 '11 at 13:31
\documentclass{minimal}
\usepackage{tikz}
\usetikzlibrary{shapes.geometric}

\begin{document}
  \begin{tikzpicture}
    \fill (0:0) circle (7cm);
    \foreach \r in {90,210,330}
      \node[fill=white,shape=diamond,aspect=1.725,scale=9,rotate=\r] (a) at (\r:2.85) {};
  \end{tikzpicture}  
\end{document}
share|improve this answer
    
yes you can do that but it's not very easy to explain why : aspect =1.725, scale =9 and 2.85. You need to make some extra calculations . –  Alain Matthes Jan 31 '11 at 20:56
    
If I'd have the time, I'd built in a scaling mechanism. So I only provided a simple frame and admitted of improvement. Some arithmatics should do the trick. –  Thorsten Donig Feb 1 '11 at 9:16
    
Thanks guys, every bit of suggestion was helpful! Anyway, I am sharing (as answer) what I intended to do. –  gamahuri Feb 1 '11 at 10:04

I give a scalable solution. I hope it is ok!!

Here is the code:

\documentclass[10pt,a4paper]{article}

\usepackage{tikz}
\usetikzlibrary{calc}

\begin{document}
\centering

\begin{tikzpicture}
\def\radius{7}
\pgfmathsetmacro{\RATIO}{2.966/7}
\pgfmathsetmacro{\edge}{\radius*\RATIO}


\filldraw(0,0) circle(\radius cm); % plate

\foreach \angle in {0,120,240}{
\filldraw[white,rotate=\angle] (0,0)--++(60:\edge)--++(120:\edge)--++(-120:\edge)--cycle;
}
\end{tikzpicture}


\end{document}
share|improve this answer
    
Some other solutions are scalable ! –  Alain Matthes Jan 31 '11 at 21:25

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.