3

I asked how to draw a methane with correct dashes and wedges. All was fine till I realized the plane I added should cut through the carbon atom in the middle. lt doesn't. Methane with a plane

The solution I see is to draw the plane and then draw again half of the carbon atom. I've drawn polygons before, but drawing a dome is beyond me. I tried to imitate these questions but failed, partially because they draw the "northern" hemisphere instead of the "western".

Code

\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{positioning,backgrounds,decorations.pathreplacing}
\usepackage{tikz-3dplot,calc}

\colorlet{hyd}{white}
\colorlet{carb}{black!55}
\colorlet{atomshell}{black}
\colorlet{colsigmaMet}{blue!70!cyan}
\colorlet{colsigmaarrowMet}{violet}

\begin{document}
\tdplotsetmaincoords{85}{125}% Determines point of view
\begin{tikzpicture}[tdplot_main_coords,
H atom/.style={circle,fill=hyd,draw=atomshell,thick,inner sep=4.5pt},
C atom/.style={circle,fill=carb,draw=atomshell,thick,inner sep=9pt}]

\def\c{1.5}

\coordinate (c01) at (0,0,0);

\coordinate (c01) at (0,0,0);
\coordinate (h01) at (\c,\c,\c);
\coordinate (h02) at (-\c,-\c,\c);
\coordinate (h03) at (\c,-\c,-\c);
\coordinate (h04) at (-\c,\c,-\c);
\coordinate (cor01) at (\c,-\c,\c);
\coordinate (cor02) at (-\c,\c,\c);
\coordinate (cor03) at (\c,\c,-\c);
\coordinate (cor04) at (-\c,-\c,-\c);

% Cube's edges
\begin{scope}[thick,line join = round]
\draw (h01) -- (cor01) -- (h02) -- (cor02) -- cycle;
\draw (h03) -- (cor04) -- (h04) -- (cor03) -- cycle;
\draw (h03) -- (cor01);
\draw (h04) -- (cor02);
\draw (h01) -- (cor03);
\end{scope}

% Solid bonds (dash and wedge not needed for this projection)
\begin{scope}[very thick]
\draw (c01) -- (h01);
\draw (c01) -- (h02);
\draw (c01) -- (h03);
\draw (c01) -- (h04);
\end{scope}

\begin{scope}[on background layer]
\begin{scope}[thick,line join = round]
\draw (h02) -- (cor04);
\end{scope}
\end{scope}

\begin{scope}[xshift = -9em, yshift = -6em]
\draw [->] (0,0,0) -- (0.9,0,0) node [below right=-0.2em and -0.2em] {$x$};
\draw [->] (0,0,0) -- (0,0.7,0) node [below left= -0.2em and -0.2em] {$y$};
\draw [->] (0,0,0) -- (0,0,0.6) node [below left] {$z$};    
\end{scope}

% Carbon atom
\path (c01) node[C atom]{};

% Shaded plane
\fill[colsigmaMet,opacity=0.65] (h01) -- (h02) -- (cor04) -- (cor03) -- cycle;

\draw[->,colsigmaarrowMet,thick] (c01) -- ($0.6*(1,-1,0)$);

% H atoms
\path
    foreach \X in {1,...,4} {
    (h0\X) node[H atom](H0\X){} };
\node at (h01) [below right=0.15em and 0.3em] {$h_1$};
\node at (h02) [above left=0.3em and 0.3em] {$h_2$};
\node at (h03) [left=0.6em] {$h_3$};
\node at (h04) [right=0.6em] {$h_4$};

\end{tikzpicture}

\end{document}
3

You can draw the plane in two stretches, whereby you leave out the circle that is taken by the atom. To this end, we first switch to the plane of the plane (as you can see, I am not a linguist ;-):

\path (\c,\c,0) coordinate (newX) (\c,-\c,0) coordinate (newY)
 (0,0,\c) coordinate (newZ);
\begin{scope}[x={(newX)},y={(newY)},z={(newZ)},canvas is xz plane at y=0]

and then fill the back stretch:

 \fill[colsigmaMet,opacity=0.65] 
   (-1,-1) |- (0,1) -- (0,8.5pt) arc[start angle=90,end angle=270,radius=8.5pt]
   |-  cycle;

draw the atom:

 \path (c01) node[C atom]{};

and fill the stretch in the front and close the scope:

 \fill[colsigmaMet,opacity=0.65] 
  (1,-1) |- (0,1) -- (0,8.5pt) arc[start angle=90,end angle=-90,radius=8.5pt]
  |-  cycle;
 \end{scope}

Full code: \documentclass{standalone} \usepackage{tikz} \usetikzlibrary{positioning,backgrounds,decorations.pathreplacing} \usepackage{tikz-3dplot}

\colorlet{hyd}{white}
\colorlet{carb}{black!55}
\colorlet{atomshell}{black}
\colorlet{colsigmaMet}{blue!70!cyan}
\colorlet{colsigmaarrowMet}{violet}

\begin{document}
\tdplotsetmaincoords{85}{125}% Determines point of view
\begin{tikzpicture}[tdplot_main_coords,
H atom/.style={circle,fill=hyd,draw=atomshell,thick,inner sep=4.5pt},
C atom/.style={circle,fill=carb,draw=atomshell,thick,inner sep=9pt}]

\def\c{1.5}

\coordinate (c01) at (0,0,0);

\coordinate (c01) at (0,0,0);
\coordinate (h01) at (\c,\c,\c);
\coordinate (h02) at (-\c,-\c,\c);
\coordinate (h03) at (\c,-\c,-\c);
\coordinate (h04) at (-\c,\c,-\c);
\coordinate (cor01) at (\c,-\c,\c);
\coordinate (cor02) at (-\c,\c,\c);
\coordinate (cor03) at (\c,\c,-\c);
\coordinate (cor04) at (-\c,-\c,-\c);

% Cube's edges
\begin{scope}[thick,line join = round]
\draw (h01) -- (cor01) -- (h02) -- (cor02) -- cycle;
\draw (h03) -- (cor04) -- (h04) -- (cor03) -- cycle;
\draw (h03) -- (cor01);
\draw (h04) -- (cor02);
\draw (h01) -- (cor03);
\end{scope}

% Solid bonds (dash and wedge not needed for this projection)
\begin{scope}[very thick]
\draw (c01) -- (h01);
\draw (c01) -- (h02);
\draw (c01) -- (h03);
\draw (c01) -- (h04);
\end{scope}

\begin{scope}[on background layer]
\begin{scope}[thick,line join = round]
\draw (h02) -- (cor04);
\end{scope}
\end{scope}

\begin{scope}[xshift = -9em, yshift = -6em]
\draw [->] (0,0,0) -- (0.9,0,0) node [below right=-0.2em and -0.2em] {$x$};
\draw [->] (0,0,0) -- (0,0.7,0) node [below left= -0.2em and -0.2em] {$y$};
\draw [->] (0,0,0) -- (0,0,0.6) node [below left] {$z$};    
\end{scope}

\path (\c,\c,0) coordinate (newX) (\c,-\c,0) coordinate (newY)
 (0,0,\c) coordinate (newZ);
\begin{scope}[x={(newX)},y={(newY)},z={(newZ)},canvas is xz plane at y=0]
 \fill[colsigmaMet,opacity=0.65] 
   (-1,-1) |- (0,1) -- (0,8.5pt) arc[start angle=90,end angle=270,radius=8.5pt]
   |-  cycle;
 \path (c01) node[C atom]{};
 \fill[colsigmaMet,opacity=0.65] 
  (1,-1) |- (0,1) -- (0,8.5pt) arc[start angle=90,end angle=-90,radius=8.5pt]
  |-  cycle;
\end{scope}
% Carbon atom

% Shaded plane
%\fill[colsigmaMet,opacity=0.65] (h01) -- (h02) -- (cor04) -- (cor03) -- cycle;

%\end{scope}
\draw[->,colsigmaarrowMet,thick] (c01) -- ($0.6*(1,-1,0)$);

% H atoms
\path
    foreach \X in {1,...,4} {
    (h0\X) node[H atom](H0\X){} };
\node at (h01) [below right=0.15em and 0.3em] {$h_1$};
\node at (h02) [above left=0.3em and 0.3em] {$h_2$};
\node at (h03) [left=0.6em] {$h_3$};
\node at (h04) [right=0.6em] {$h_4$};

\end{tikzpicture}

\end{document}

enter image description here

P.S. I agree that I failed to answer the question in the title. Here is how one can draw half-spheres. The calculations are explained e.g. here (even though I have used a somewhat different way of deriving the result), and there are dedicated packages for that. The bottom-line is that you have to work out the angles of the visible part. (If you are interested in a more package-independent way, see e.g. here.) The result is

\documentclass[tikz,border=3mm]{standalone}
\usepackage{tikz-3dplot}
\begin{document}
\begin{tikzpicture}
\tdplotsetmaincoords{70}{110}
\begin{scope}[tdplot_main_coords,declare function={R=4;alpha=30;}]
 \draw[tdplot_screen_coords,dashed] circle[radius=R];
 \pgfmathsetmacro\angVis{atan(sin(alpha-\tdplotmainphi)*tan(\tdplotmaintheta))} 
 \clip plot[domain=\angVis:\angVis+180,variable=\t] 
    (xyz spherical cs:radius=R,longitude=alpha,latitude=\t)
    coordinate(aux) [tdplot_screen_coords]
    let \p1=($(aux)-(0,0)$),\n1={atan2(\y1,\x1)} in
    arc[start angle=\n1,end angle=\n1+180,radius=R];
 \shade[tdplot_screen_coords,ball color=blue] circle[radius=R];     
\end{scope} 
%
\tdplotsetmaincoords{85}{125}
\begin{scope}[xshift=9cm,tdplot_main_coords,declare function={R=3;alpha=20;}]
 \draw[tdplot_screen_coords,dashed] circle[radius=R];
 \pgfmathsetmacro\angVis{atan(sin(alpha-\tdplotmainphi)*tan(\tdplotmaintheta))} 
 \clip plot[domain=\angVis:\angVis+180,variable=\t] 
    (xyz spherical cs:radius=R,longitude=alpha,latitude=\t)
    coordinate(aux) [tdplot_screen_coords]
    let \p1=($(aux)-(0,0)$),\n1={atan2(\y1,\x1)} in
    arc[start angle=\n1,end angle=\n1+180,radius=R];
 \shade[tdplot_screen_coords,ball color=red] circle[radius=R];  
\end{scope} 
\end{tikzpicture}
\end{document}

enter image description here

It is straightforward to add the case when you see the half sphere from the inside.

| improve this answer | |
  • I like this idea, even if it does ruin the question title :P Where does the canvas is xz plane at y=0 key come from? I can't find it in PGF's manual. – methaneman May 6 at 18:38
  • 1
    @methaneman It is in the 3d library, which gets loaded by tikz-3dplot. You can find it on p. 565 of pgfmanual v3.1.5. – user194703 May 6 at 19:33
  • @methaneman I tried to undo the ruination of the title and added something on half spheres. – user194703 May 7 at 19:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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