3

So, I am new to TeX, and I needed to plot something along these lines:

Hand-drawn scheme of the 3d coordinate plane.

and what I tried to do was:

\documentclass[tikz,border=3mm]{standalone}
\usetikzlibrary{perspective}
\begin{document}
\begin{tikzpicture}[3d view={140}{20},>=stealth,
    line join=round,semithick,dot/.style={circle,fill,inner sep=1pt},
    declare function={xmax=9;ymax=10;zmax=8;}]

 \draw[->] (tpp cs:x=0,y=0,z=0) coordinate (O)
  -- (tpp cs:x=xmax,y=0,z=0) coordinate[label=left:$x$] (X);

 \draw[->] (O) -- (tpp cs:x=0,y=ymax,z=0) coordinate[label=above:$y$] (Y);

 \draw[->] (O) -- (tpp cs:x=0,y=0,z=zmax) coordinate[label=above right:$z$] (Z);

 \path (tpp cs:x=2,y=-sqrt(3),z=3) coordinate[dot,label=above:$A$](A)

 (tpp cs:x=6,y=-sqrt(3),z=3) coordinate[dot,label=left:$B$](B)

 (tpp cs:x=8,y=0,z=0) coordinate[dot,label=left:$C$](C)

 (tpp cs:x=6,y=-sqrt(3),z=-3) coordinate[dot,label=below:$D$](D)

 (tpp cs:x=2,y=sqrt(3),z=-3) coordinate[dot,label=right:$E$](E)

 (tpp cs:x=0,y=4*sqrt(3),z=4) coordinate[dot,label=right:$F$](F)

 (tpp cs:x=2,y=3*sqrt(3),z=7) coordinate[dot,label=right:$G$](G)

 (tpp cs:x=6,y=3*sqrt(3),z=7) coordinate[dot,label=below:$H$](H)

 (tpp cs:x=8,y=4*sqrt(3),z=4) coordinate[dot,label=right:$I$](I)

 (tpp cs:x=6,y=5*sqrt(3),z=1) coordinate[dot,label=below:$J$](J)

 (tpp cs:x=2,y=5*sqrt(3),z=1) coordinate[dot,label=right:$K$](K);


 \draw (A) edge (B) -- (B) edge (C) -- (C) edge (D) -- (D) edge[dashed] (E) 

 -- (E) edge[dashed] (O) -- (A) edge (G) -- (B) edge (H) -- (C) edge (I) -- (D) edge (J) -- (E) edge[dashed] (K) -- (O) edge[dashed] (F) -- (G) edge (F) -- (F) edge (K) -- (K) edge (J) -- (J) edge (I) -- (I) edge (H) -- (H) edge (G) --;

\end{tikzpicture}
\end{document}

However, something is wrong (I really don't have any clue whatsoever what it is), as this error message appears:

https://pastebin.com/GcD4rKLx

(pastebin, as the error was too big)

So I would like to ask if any of you can help me... I would like something along the lines of the handdrawn plane (that was what I was trying) and the r line, which I have no idea how to do. I would like for it to be dashed through the solid, and fulled out of the solid.

Anyways, thanks in advance for the help and sorry for the not native english! Best wishes!

1
  • Wrap sqrt(...) with braces, i.e., {sqrt(...)}.
    – ZhiyuanLck
    Jul 19, 2020 at 18:00

1 Answer 1

1

So, after (a LOT) of trial and error, I managed to do what I wanted, in, perhaps, not the nicest way, but it works, so... That's enough for me.

I will leave this here if anyone is interested:

\documentclass[tikz,border=3mm]{standalone}
\usetikzlibrary{perspective}
\begin{document}
\begin{tikzpicture}[3d view={155}{16},>=stealth,
    line join=round,line width=2pt,dot/.style={circle,fill,inner sep=2pt},
    declare function={xmax=12;ymax=12;zmax=8;kmax=1.73205;}]

 \path (tpp cs:x=0,y=0,z=0) coordinate[dot](O)

 (tpp cs:x=2,y=-1.73205,z=3) coordinate[dot](A)

 (tpp cs:x=6,y=-1.73205,z=3) coordinate[dot](B)

 (tpp cs:x=8,y=0,z=0) coordinate[dot](C)

 (tpp cs:x=6,y=1.73205,z=-3) coordinate[dot](D)

 (tpp cs:x=2,y=1.73205,z=-3) coordinate[dot](E)

 (tpp cs:x=0,y=6.9282,z=4) coordinate[dot](F)

 (tpp cs:x=2,y=5.19615,z=7) coordinate[dot](G)

 (tpp cs:x=6,y= 5.19615,z=7) coordinate[dot](H)

 (tpp cs:x=8,y=6.9282,z=4) coordinate[dot](I)

 (tpp cs:x=6,y=8.660254,z=1) coordinate[dot](J)

 (tpp cs:x=2,y=8.660254,z=1) coordinate[dot](K)

 (tpp cs:x=0,y=4.5755,z=0) coordinate(M)

 (tpp cs:x=0,y=0,z=5.372) coordinate(N)


 (tpp cs:x=4,y=-3.58*kmax,z=-3.58) coordinate(S)

 (tpp cs:x=4,y=6.9282,z=4) coordinate(P)

 (tpp cs:x=4,y=10*kmax,z=10) coordinate(Q)

 (tpp cs:x=4,y=-6*kmax,z=-6) coordinate(R);

 
 \draw (S) edge[dashed] (P);
 \draw (P) edge (Q);
 \draw (S) edge (R);


 \draw (O) edge[dashed] (C);
 \draw (C) edge (tpp cs:x=xmax,y=0,z=0) coordinate (X);


 \draw (O) edge[dashed] (M);
 \draw (M) edge (tpp cs:x=0,y=ymax,z=0) coordinate (Y);


 \draw (O) edge[dashed] (N);
 \draw (N) edge (tpp cs:x=0,y=0,z=zmax) coordinate (Z);




 \draw (E) edge[dashed] (O);
 \draw (F) edge[dashed] (O);
 \draw (A) edge[dashed] (O);
 \draw (A) edge[dashed] (G);
 \draw (A) edge[dashed] (B);


 \draw (J) edge (I);
 \draw (H) edge (I);
 \draw (G) edge (H);
 \draw (C) edge (I);

 \draw (E) edge (K);
 \draw (J) edge (K);
 \draw (F) edge (K);

 \draw (B) edge (C);
 \draw (D) edge (C);
 \draw (D) edge (E);
 \draw (D) edge (J);
 \draw (B) edge (H);
 \draw (G) edge (F);

\end{tikzpicture}
\end{document}

And here is the final result:

Final Product

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.