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 want to join the vertices labeled as (1), b, abc, and ac but could not succeed. I'd highly appreciate if you point me out what I'm doing wrong and what is the solution. Thanks

enter image description here

\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{calc}
\begin{document}
\begin{tikzpicture}[scale = 4, fill opacity = 1.0, thick,
                        line cap = round, line join = round]
    %% Define coordinate labels.
    % t(op) and b(ottom) layers
    \path \foreach \layer/\direction in {b/{0, 0, 0}, t/{0, 1, 0}} {
        (\direction)
        \foreach \point/\label in {{0, 0, 0}/ll, {1, 0, 0}/lr, {1, 0, -1}/ur, {0, 0, -1}/ul} {
            +(\point) coordinate (\layer\label)
        }
        ($(\layer ll)!0.5!(\layer ur)$) coordinate (\layer md)
    };



    % Put text next to the labels as requested.
    % Funilly enough we need to set fill opacity to 1.
    \draw \foreach \text/\label/\anchor in {%
        $\left(1\right)$/bll/east,
        $b$/bul/east,
        $c$/tll/east,
        $bc$/tul/east,
        $a$/blr/west,
        $ab$/bur/west,
        $ac$/tlr/west,
        $abc$/tur/west} {
        (\label) node[anchor=\anchor, fill opacity = 1] {\text}
    };
    % Draw  cube.
    \fill (0, 0, -1) circle (0.5pt);
    \foreach \direction in {(0, 0, 1), (0, 1, 0), (1, 0, 0)} {
        \draw[dashed, black] (bul) -- + \direction;
    }


    \fill[red!60,   opacity=0.5]  (tll) -- (tul)  -- (bur) -- (blr);
    \fill[blue!60, opacity=0.5]  (bll)   -- (bul)   -- (tur) -- (tlr);




    \draw (bll) -- (blr) -- (tlr) -- (tll) -- cycle;
    \draw (blr) -- (bur) -- (tur) -- (tlr) -- cycle;
    \draw (tll) -- (tlr) -- (tur) -- (tul) -- cycle;

    \foreach \point in {bll, blr, bur, tll, tlr, tul, tur} {
        \fill[fill opacity=1] (\point) circle (0.75pt);
    }


\node[below] at (1.0, -0.2, 0.0) {$AC$};

\end{tikzpicture}
\end{document}
share|improve this question
    
With your current coordinate system, it's as simple as a straight line from (1) to abc. –  T. Verron Dec 6 '12 at 15:39
2  
The four points are exactly on a line (try to replace \fill by \filldraw. –  Caramdir Dec 6 '12 at 15:39

1 Answer 1

up vote 10 down vote accepted

Simply change the z-direction so that the points are no longer apparently collinear.

\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{calc}

\begin{document}
\begin{tikzpicture}[scale = 4, thick,
    % change the z-direction
    z={(-0.3,-0.6)}]

    %% Define coordinate labels.
    % t(op) and b(ottom) layers
    \path \foreach \layer/\direction in {b/{0, 0, 0}, t/{0, 1, 0}} {
        (\direction)
        \foreach \point/\label in {{0, 0, 0}/ll, {1, 0, 0}/lr, {1, 0, -1}/ur, {0, 0, -1}/ul} {
            +(\point) coordinate (\layer\label)
        }
        ($(\layer ll)!0.5!(\layer ur)$) coordinate (\layer md)
    };

    % Put text next to the labels as requested.
    \draw \foreach \text/\label/\anchor in {%
        $\left(1\right)$/bll/east,
        $b$/bul/east,
        $c$/tll/east,
        $bc$/tul/east,
        $a$/blr/west,
        $ab$/bur/west,
        $ac$/tlr/west,
        $abc$/tur/west} {
        (\label) node[anchor=\anchor] {\text}
    };
    % Draw  cube.
    \fill (0, 0, -1) circle (0.5pt);
    \foreach \direction in {(0, 0, 1), (0, 1, 0), (1, 0, 0)} {
        \draw[dashed, black] (bul) -- + \direction;
    }

    % add some midpoints for correct drawing of transparent planes
    \coordinate (m1) at ($(bll)!0.5!(tlr)$);
    \coordinate (m2) at ($(bul)!0.5!(tur)$);

    \fill[blue!60, opacity=0.5]  (bll)   -- (bul)   -- (m2) -- (m1) -- cycle;
    \fill[red!60,   opacity=0.5]  (tll) -- (tul)  -- (bur) -- (blr) -- cycle;
    \fill[blue!60, opacity=0.5]  (m1) -- (m2) -- (tur) -- (tlr) -- cycle;
    \draw[very thin, black!60] (m1) -- (m2);

    \draw (bll) -- (blr) -- (tlr) -- (tll) -- cycle;
    \draw (blr) -- (bur) -- (tur) -- (tlr) -- cycle;
    \draw (tll) -- (tlr) -- (tur) -- (tul) -- cycle;

    \foreach \point in {bll, blr, bur, tll, tlr, tul, tur} {
        \fill[fill opacity=1] (\point) circle (0.75pt);
    }
\end{tikzpicture}
\end{document}

result

share|improve this answer
    
Thanks a lot @Caramdir for your effort and spending time to resolve my issue with this overlay diagram. Thanks again. –  MYaseen208 Dec 6 '12 at 16:05

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.