I am trying to replicate the following figure here
and this is what I have so far
\documentclass[12pt,a4paper]{standalone}
\usepackage{tikz,tkz-euclide,pgfplots}
\usetkzobj{all}
\newcommand{\ball}[2]{%
\begin{scope}[shift = {(#1,#2)}
\fill[red] (0,0) circle (0.5);
\clip (0,0) circle (0.5);
\shade[shading=ball,ball color=white,1] (0.15,0.25) circle (0.7);
\end{scope}}
\begin{document}%
\begin{tikzpicture}
\def\height{0.75}
\def\length{3}
\tkzDefPoint(0,0){A} \tkzDefPoint(0.9*\length,-\height){B}
\tkzDefPoint(2*\length,0){C} \tkzDefPoint(1.1*\length, \height){D}
\tkzDrawPolygon(A,B,C,D)
\begin{scope}[shift={(0,2)}]
\tkzDefPoint(0,0){A1} \tkzDefPoint(0.9*\length,-\height){B1}
\tkzDefPoint(2*\length,0){C1} \tkzDefPoint(1.1*\length, \height){D1}
\tkzDrawPolygon(A1,B1,C1,D1)
\end{scope}
\tkzDrawSegments(A,A1 B1,B C1,C D1,D);
% \ball{2}{2}
\end{tikzpicture}
\end{document}
By using the tips I got from this question. I think I almost got it, but the code will not compile when uncommenting the last line. What is the reason for this?
Other means create this image would also appreciated, it is always refreshing to see different approaches to a problem.
scope
options:\begin{scope}[shift = {(#1,#2)}]
. You also have an undefined option for\shade
: instead of\shade[shading=ball,ball color=white,1]
, write\shade[ball color=white]
. I would also suggest\shade[ball color=white] (0.15,0.25) circle (1);
– hpesoj626 Jun 23 '13 at 12:22