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.
\documentclass{minimal}
\usepackage{tikz,tikz-3dplot}

\begin{document}
  \tdplotsetmaincoords{70}{115}

  \begin{tikzpicture}[scale=4,tdplot_main_coords]


    \coordinate (O) at (1,1,1);
    \tdplotsetcoord{P}{1.414213}{54.68636}{45}

    \draw[fill=gray!50,fill opacity=0.5] (O) -- ($(O) + (Py)$) -- ($(O) + (Pyz)$) -- ($(O) + (Pz)$) -- cycle;
    \draw[fill=blue,fill opacity=0.5] (O) -- ($(O) + (Px)$) -- ($(O) + (Pxy)$) -- ($(O) + (Py)$) -- cycle;
   \draw[fill=green,fill opacity=0.5] (O) -- ($(O) + (Px)$) -- ($(O) + (Pxz)$) -- ($(O) + (Pz)$) -- cycle;
   \draw[fill=yellow,fill opacity=0.5] ($(O) + (Pz)$) -- ($(O) + (Pyz)$) -- ($(O) + (P)$) -- ($(O) + (Pxz)$) -- cycle;
    \draw[fill=red,fill opacity=0.5] ($(O) + (Px)$) -- ($(O) + (Pxy)$) -- ($(O) + (P)$) -- ($(O) + (Pxz)$) -- cycle;
    \draw[fill=pink,fill opacity=0.5] ($(O) + (Py)$) -- ($(O) + (Pxy)$) -- ($(O) + (P)$) -- ($(O) + (Pyz)$) -- cycle;

 \tdplotsetmaincoords{10}{10}%%%%%%%%%%%%this is not changing the rotation since the begin tikzpicture has alread used it once

 \coordinate (M) at (3,2,1);
    \tdplotsetcoord{P}{1.414213}{54.68636}{45}

    \draw[fill=gray!50,fill opacity=0.5] (M) -- ($(M) + (Py)$) -- ($(M) + (Pyz)$) -- ($(M) + (Pz)$) -- cycle;
    \draw[fill=blue,fill opacity=0.5] (M) -- ($(M) + (Px)$) -- ($(M) + (Pxy)$) -- ($(M) + (Py)$) -- cycle;
   \draw[fill=green,fill opacity=0.5] (M) -- ($(M) + (Px)$) -- ($(M) + (Pxz)$) -- ($(M) + (Pz)$) -- cycle;
   \draw[fill=yellow,fill opacity=0.5] ($(M) + (Pz)$) -- ($(M) + (Pyz)$) -- ($(M) + (P)$) -- ($(M) + (Pxz)$) -- cycle;
    \draw[fill=red,fill opacity=0.5] ($(M) + (Px)$) -- ($(M) + (Pxy)$) -- ($(M) + (P)$) -- ($(M) + (Pxz)$) -- cycle;
    \draw[fill=pink,fill opacity=0.5] ($(M) + (Py)$) -- ($(M) + (Pxy)$) -- ($(M) + (P)$) -- ($(M) + (Pyz)$) -- cycle;
\end{document}

I want both cubes to have different orientations as well as be in the same figure? How can I do this?

share|improve this question
add comment

1 Answer

Remarks

You can use scope to have several coordinate systems in one drawing.

Implementation

\documentclass[tikz]{standalone}
\usepackage{tikz,tikz-3dplot}
\begin{document}
\begin{tikzpicture}[scale=4]
    \tdplotsetmaincoords{70}{115}
    \begin{scope}[tdplot_main_coords]
        \coordinate (O) at (0,0,0);
        \tdplotsetcoord{P}{1.414213}{54.68636}{45}
        \draw[fill=gray!50,fill opacity=0.5] (O) -- ($(O) + (Py)$) -- ($(O) + (Pyz)$) -- ($(O) + (Pz)$) -- cycle;
        \draw[fill=blue,fill opacity=0.5] (O) -- ($(O) + (Px)$) -- ($(O) + (Pxy)$) -- ($(O) + (Py)$) -- cycle;
        \draw[fill=green,fill opacity=0.5] (O) -- ($(O) + (Px)$) -- ($(O) + (Pxz)$) -- ($(O) + (Pz)$) -- cycle;
        \draw[fill=yellow,fill opacity=0.5] ($(O) + (Pz)$) -- ($(O) + (Pyz)$) -- ($(O) + (P)$) -- ($(O) + (Pxz)$) -- cycle;
        \draw[fill=red,fill opacity=0.5] ($(O) + (Px)$) -- ($(O) + (Pxy)$) -- ($(O) + (P)$) -- ($(O) + (Pxz)$) -- cycle;
        \draw[fill=pink,fill opacity=0.5] ($(O) + (Py)$) -- ($(O) + (Pxy)$) -- ($(O) + (P)$) -- ($(O) + (Pyz)$) -- cycle;
    \end{scope}

    \tdplotsetmaincoords{10}{10}
    \begin{scope}[tdplot_main_coords,xshift=1cm]
        \coordinate (M) at (0,0,0);
        \tdplotsetcoord{P}{1.414213}{54.68636}{45}
        \draw[fill=gray!50,fill opacity=0.5] (M) -- ($(M) + (Py)$) -- ($(M) + (Pyz)$) -- ($(M) + (Pz)$) -- cycle;
        \draw[fill=blue,fill opacity=0.5] (M) -- ($(M) + (Px)$) -- ($(M) + (Pxy)$) -- ($(M) + (Py)$) -- cycle;
        \draw[fill=green,fill opacity=0.5] (M) -- ($(M) + (Px)$) -- ($(M) + (Pxz)$) -- ($(M) + (Pz)$) -- cycle;
        \draw[fill=yellow,fill opacity=0.5] ($(M) + (Pz)$) -- ($(M) + (Pyz)$) -- ($(M) + (P)$) -- ($(M) + (Pxz)$) -- cycle;
        \draw[fill=red,fill opacity=0.5] ($(M) + (Px)$) -- ($(M) + (Pxy)$) -- ($(M) + (P)$) -- ($(M) + (Pxz)$) -- cycle;
        \draw[fill=pink,fill opacity=0.5] ($(M) + (Py)$) -- ($(M) + (Pxy)$) -- ($(M) + (P)$) -- ($(M) + (Pyz)$) -- cycle;
    \end{scope}
\end{tikzpicture}
\end{document}

Output

enter image description here

share|improve this answer
add comment

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.