14

I use GeoGebra to draw a cube. The code in GeoGebra is

\documentclass[12pt]{article}
\usepackage{pstricks-add}
\pagestyle{empty}
\begin{document}
\psset{xunit=1.0cm,yunit=1.0cm,algebraic=true,dimen=middle,dotstyle=o,dotsize=3pt 0,linewidth=0.8pt,arrowsize=3pt 2,arrowinset=0.25}
\begin{pspicture}(-0.14,5.74)(-0.14,5.77)
\pspolygon[fillcolor=black,fillstyle=solid,opacity=0.1](0,4)(0,0)(1,2)(1,6)
\pspolygon[fillcolor=black,fillstyle=solid,opacity=0.1](1,2)(4,0)(5,6)
\psline[linewidth=1.2pt](0,4)(0,0)
\psline[linewidth=1.2pt](0,0)(4,0)
\psline[linewidth=1.2pt](4,0)(5,2)
\psline[linewidth=1.2pt](5,2)(5,6)
\psline[linewidth=1.2pt](5,6)(1,6)
\psline[linewidth=1.2pt](0,4)(1,6)
\psline[linewidth=1.2pt,linestyle=dashed,dash=1pt 1pt](1,2)(1,6)
\psline[linewidth=1.2pt,linestyle=dashed,dash=1pt 1pt](1,2)(0,0)
\psline[linewidth=1.2pt,linestyle=dashed,dash=1pt 1pt](1,2)(5,2)
\psline[linewidth=1.2pt](4,4)(4,0)
\psline[linewidth=1.2pt](4,4)(0,4)
\psline[linewidth=1.2pt](4,4)(5,6)
\psline(0,4)(0,0)
\psline(0,0)(1,2)
\psline(1,2)(1,6)
\psline(1,6)(0,4)
\psline(1,2)(4,0)
\psline(4,0)(5,6)
\psline(5,6)(1,2)
\psline(1,2)(4.5,3)
\psline(4.5,3)(5,2)
\parametricplot{-2.8632929945846817}{-1.1071487177940902}{0.18*cos(t)+4.5|0.18*sin(t)+3}
\begin{scriptsize}
\psdots[dotstyle=*](0,0)
\rput[bl](-0.04,-0.25){$A$}
\psdots[dotstyle=*](4,0)
\rput[bl](3.96,-0.3){$B$}
\psdots[dotstyle=*](5,2)
\rput[bl](5.03,2.07){$C$}
\psdots[dotstyle=*](1,2)
\rput[bl](0.96,1.6){$D$}
\psdots[dotstyle=*](0,4)
\rput[bl](-0.3,4.22){$A_1$}
\psdots[dotstyle=*](1,6)
\rput[bl](0.95,6.19){$D_1$}
\psdots[dotstyle=*](4,4)
\rput[bl](3.7,4.21){$B_1$}
\psdots[dotstyle=*](5,6)
\rput[bl](5.03,6.07){$C_1$}
\psdots[dotstyle=*](4.5,3)
\rput[bl](4.59,3.02){$E$}
\end{scriptsize}
\end{pspicture}
\end{document}

I want style of the the segments BD, C_1D, AD and D_1D is dashed. I tried

\psset{linestyle=dashed}
\psline(B)(D)
\psline(C_1)(D)
\psline(A)(D)
\psline(D_1)(D)

but the lines are not dashed. How can I get that?

output

  • 1
    Why not use dashed line directly on Geogebra? – Sigur Feb 8 '14 at 14:11
  • You have to discover what are the coordinates of those points and use linestyle=dashed as option. – Sigur Feb 8 '14 at 14:13
  • I used dashed. But, I filled polygons ADD1A1 and BDC1. – minthao_2011 Feb 8 '14 at 14:15
16
\documentclass[pstricks,border=30pt,12pt]{standalone}
\usepackage{pst-eucl}
\psset{opacity=.2}
\begin{document}
\begin{pspicture}(7,7)
    \pstGeonode[PosAngle={-90,-90,0,-90,180}]{A}(5,0){B}(7,1){C}(2,1){D}(0,5){A_1}
    \pstTranslation[PosAngle=120]{A}{A_1}{B,C,D}[B_1,C_1,D_1]
    \pspolygon(A)(B)(C)(C_1)(D_1)(A_1)
    \psline(A_1)(B_1)(C_1)(B)(B_1)
    \pstMiddleAB[PosAngle=20]{B}{C_1}{E}
    \psline(E)(C)
    \pstMarkAngle{D}{E}{C}{}
    \psset{linestyle=dashed}
    \psline(C)(D)(D_1)
    \psline(A)(D)
    \psline(B)(D)(C_1)
    \psline(D)(E)
    \psset{linestyle=none,fillstyle=solid,fillcolor=gray}
    \pspolygon(A)(D)(D_1)(A_1)
    \pspolygon(B)(C_1)(D)
\end{pspicture}
\end{document}

enter image description here

Miscellaneous

If everything behind the surface should be dashed then the angle mark should be too.

\documentclass[pstricks,border=30pt,12pt]{standalone}
\usepackage{pst-eucl}
\psset{opacity=.2}
\begin{document}
\begin{pspicture}(7,7)
    \pstGeonode[PosAngle={-90,-90,0,-90,180}]{A}(5,0){B}(7,1){C}(2,1){D}(0,5){A_1}
    \pstTranslation[PosAngle=120]{A}{A_1}{B,C,D}[B_1,C_1,D_1]
    \pspolygon(A)(B)(C)(C_1)(D_1)(A_1)
    \psline(A_1)(B_1)(C_1)(B)(B_1)
    \pstMiddleAB[PosAngle=20]{B}{C_1}{E}
    \psline(E)(C)
    \psset{linestyle=dashed}
    \psline(C)(D)(D_1)
    \psline(A)(D)
    \psline(B)(D)(C_1)
    \psline(D)(E)
    \pstMarkAngle{D}{E}{C}{}
    \psset{linestyle=none,fillstyle=solid,fillcolor=gray}
    \pspolygon(A)(D)(D_1)(A_1)
    \pspolygon(B)(C_1)(D)
\end{pspicture}
\end{document}

enter image description here

  • @ Code Mocker. BD, C1D are dashed. Now I want to draw CA1 and A1D are also dashed. – minthao_2011 Feb 8 '14 at 14:43
  • ED shouldn't be dashed. – Svend Tveskæg Feb 8 '14 at 14:55
  • 1
    @SvendTveskæg: It should be dashed because it is behind the front surfaces. – kiss my armpit Feb 8 '14 at 14:59
12
\documentclass{article}% Herbert 20110907
\usepackage{pst-3dplot}

\begin{document}
\begin{pspicture}(-3,-3)(3.5,2.5)
\psset{coorType=3,hiddenLine=false}
%\pstThreeDCoor[xMin=-0,xMax=5,yMin=0,yMax=4,zMin=0,zMax=4]   
\pstThreeDBox[linestyle=solid](0,0,0)(3,0,0)(0,3,0)(0,0,3)
\pstThreeDTriangle[fillcolor=black!20,fillstyle=solid,opacity=0.5](3,0,0)(0,3,0)(3,3,3)
\pstThreeDSquare[fillcolor=black!20,fillstyle=solid,opacity=0.5](0,0,0)(0,0,3)(3,0,0)
\pstThreeDTriangle[fillcolor=red!60,fillstyle=solid,opacity=0.5](3,0,0)(3,3,0)(1.5,3,1.5)
%\pstThreeDLine[linecolor=red](3,0,0)(3,3,0)(1.5,3,1.5)(3,0,0)
\pstThreeDDot(1.5,3,1.5)
\pstThreeDPut[pOrigin=tr](0,0,0){$A$}
\pstThreeDPut[pOrigin=tr](0,3,0){$B$}
\pstThreeDPut[pOrigin=tl](3,3,0){$C$}
\pstThreeDPut[pOrigin=tl](3,0,0){$D$}
\pstThreeDPut[pOrigin=br](0,0,3){$A_1$}
\pstThreeDPut[pOrigin=br](0,3,3){$B_1$}
\pstThreeDPut[pOrigin=bl](3,3,3){$C_1$}
\pstThreeDPut[pOrigin=bl](3,0,3){$D_1$}
\pstThreeDPut[pOrigin=lb](1.5,3,1.5){$E$}
\pstThreeDCircle[linecolor=red,beginAngle=45,endAngle=145](1.5,3,1.5)(-0.2,-0.4,0.2)(0,-0.2,-0.2)
\end{pspicture}

\end{document}

enter image description here

  • @ Herbert The segments AD, BD, CD, C_1D, DD_1 are dashed. Now I want to CA1 and A1D are also dashed. – minthao_2011 Feb 8 '14 at 14:50
12

Just another way of doing things...

\documentclass[tikz,border=0.125cm]{standalone}
\begin{document}
\begin{tikzpicture}[x=(0:2cm), y=(90:2cm*sqrt 2), z=(210:2cm/sqrt 3)]
\foreach \s in {0,1}
  \foreach \l [count=\i from 3, 
    evaluate={\t=-\i*90+45; \n=(\s==0) ? "" : "1";}] in {A,B,C,D}
       \coordinate (\l\n) at (cos \t, \s, sin \t);
\path (B) -- (C1) coordinate [midway] (E);
\fill [gray!25] (A) -- (D) -- (D1) -- (A1) -- cycle (D) -- (B) -- (C1) -- cycle;
\foreach \p in {A,...,E,A1,B1,C1,D1} \fill (\p) circle [radius=2pt];
\foreach \p/\a in {A/below left,B/below,C/right,D/above left,E/right} \node [\a] at (\p) {$\p$};
\foreach \p/\a in {A/left,B/above left,C/above,D/above left} \node [\a] at (\p1) {$\p_1$};
\draw [dashed] (A) -- (D) -- (D1) (D) -- (C) (D) -- (C1) (D) -- (B) (D) -- (E);
\draw (A) -- (A1) -- (B1) -- (B)  -- (A) (B) -- (C)  -- (C1) -- (D1) -- (A1) (B) -- (C1) -- (B1) (E) -- (C);
\clip (D) -- (E) -- (C);
\draw [dashed] (E) circle [radius=10pt];
\end{tikzpicture}
\end{document}

enter image description here

11

Here is a possible solution.

\documentclass{article}

\usepackage{pst-eucl}

\begin{document}

\psset{
  linewidth = 0.8pt,
  linejoin = 2,
  dotstyle = *,
  dotsize = 3pt 0
}
\begin{pspicture}(-0.4,-0.4)(5.47,6.45)
\pnodes(0,0){A}(0,4){A1}(4,0){B}(4,4){B1}(5,2){C}(5,6){C1}(1,2){D}(1,6){D1}(4.5,3){E}
{\psset{
  linestyle = none,
  fillstyle = solid,
  fillcolor = black!15
}
\pspolygon(A)(A1)(D1)(D)
\pspolygon(D)(C1)(B)}
{\psset{
   linewidth = 1.2pt
 }
\pspolygon(A)(A1)(B1)(B)
\pspolygon(A1)(D1)(C1)(B1)
\pspolygon(B)(B1)(C1)(C)
{\psset{
   linestyle = dashed,
   dash = 2pt 2pt
 }
\psline(A)(D)(B)
\psline(D1)(D)(C1)
\psline(C)(D)(E)
\pstMarkAngle[
  MarkAngleRadius = 0.2
]{D}{E}{C}{}}}
\psline(E)(C)
\psline(B)(C1)
\psdots(A)(A1)(B)(B1)(C)(C1)(D)(D1)(E)
\uput[300](A){$A$}
\uput[120](A1){$A_1$}
\uput[300](B){$B$}
\uput[120](B1){$B_1$}
\uput[30](C){$C$}
\uput[45](C1){$C_1$}
\uput[280](D){$D$}
\uput[70](D1){$D_1$}
\uput[30](E){$E$}
\end{pspicture}

\end{document}

output2

10

1) With Fuite =30 et coeff =.5

\documentclass[10pt]{article}
\usepackage{tikz}
\usetikzlibrary{calc} 

\newcommand\pgfmathsinandcos[3]{% 
  \pgfmathsetmacro#1{sin(#3)}% 
  \pgfmathsetmacro#2{cos(#3)}% 
}
\tikzset{point/.style = {fill=gray,circle,inner sep=2pt}}

\begin{document}

\pgfmathsetmacro\angFuite{30}
\pgfmathsetmacro\coeffReduc{0.5}
\pgfmathsetmacro\clen{2}

\begin{tikzpicture}[scale=4,thick]
\pgfmathsinandcos\sint\cost{\angFuite} %  

\begin{scope}
  \draw    (0,0) coordinate (A)  -- (\clen,0)     coordinate (B) 
                                 -- (\clen,\clen) coordinate (B1) 
                                 -- (0,\clen)     coordinate (A1) 
                                 -- (A);
\end{scope}

\begin{scope}[cm={1,0,\coeffReduc*\cost,\coeffReduc*\sint,(0,0)}]
  \draw          (B) -- (\clen,\clen) coordinate (C);
  \draw[dashed]  (A) -- (0,\clen)     coordinate (D) 
                     -- (C) ;
\end{scope}

\begin{scope}[cm={1,0,0,1,(2*\coeffReduc*\cost,2*\coeffReduc*\sint)}]
  \draw[dashed] (D)       -- (0,\clen)     coordinate (D1);
  \draw         (\clen,0) -- (\clen,\clen) coordinate (C1) 
                          -- (D1) -- (A1);
\end{scope}


   \draw (B1) -- (C1) -- coordinate (E)(B);
   \draw[dashed] (B) -- (D) -- (E);
   \draw[dashed] (D) -- (E);
   \draw (C) -- (E);
   \fill[gray!10,fill opacity=0.5] (A) -- (D) --(D1) -- (A1) -- cycle;
   \fill[gray!10,fill opacity=0.5] (B) -- (D) --(C1) --  cycle;
   %label
   \foreach \pt in {A,...,E}  \node[point] at (\pt) {};
   \foreach \pt in {A,...,D}  \node[point,label={above=6pt:$\pt_1$}] at (\pt1) {};
   \foreach \pt in {A,...,D} \node[below=6pt] at (\pt) {\pt};
    \node[point,label={right=6pt:$E$}] at (E) {};
    \draw[opacity=.5,gray,dashed] ($(D)!0.8!(E)$) edge[out=-50,in=-140] ($(C)!0.8!(E)$);
 \end{tikzpicture}
\end{document}

enter image description here

2) with fuite = 15 and coeff = .7

enter image description here

9

Another tikz solution:

\documentclass[tikz,border=10pt]{standalone}
\usetikzlibrary{backgrounds,calc}
\tikzset{point/.style = {fill=black,circle,inner sep=0.7pt}}
\begin{document}
  \begin{tikzpicture}[font=\tiny]
    \coordinate (a) at (0,0);
    \coordinate (b) at (2,0);
    \coordinate (c) at (2,2);
    \coordinate (d) at (0,2);
    %
    \coordinate (a1) at (0.65,0.45);
    \coordinate (b1) at (2.65,0.45);
    \coordinate (c1) at (2.65,2.45);
    \coordinate (d1) at (0.65,2.45);

    \foreach \x in {a,b,c,d,a1,b1,c1,d1}{
    \node[point] at (\x) {};
    } 
    \foreach \x/\y in {c/B_1,d/A_1,c1/C_1,d1/D_1}{
    \node[] at ($(\x)+(0,0.2)$) {$\y$};
    }  
    \foreach \x/\y in {a/A,b/B,b1/C,a1/D}{
    \node[] at ($(\x)+(0,-0.2)$) {$\y$};
    }  


    \draw (a) -- (b) -- (c) -- (d) --cycle;
    \draw (d1) -- (c1) -- (b1) edge[densely dashed] (a1) ;
    \draw[densely dashed] (a) -- (a1) -- (d1) edge[solid] (d);
    \draw (b) -- (b1)  (c) -- (c1) ;
    \draw[densely dashed] (b) -- (a1) -- (c1) edge[solid]node[point,outer sep=0pt] (c1b){}  (b);
    \draw[densely dashed] (a1) -- coordinate[pos=0.95] (arc1) (c1b); 
    \draw (c1b) -- coordinate[pos=0.1] (arc2)(b1);
    \draw (arc1) edge[in=210,out=290] (arc2);
    \node[] at ($(c1b)+(0.15,0)$) {$E$};
    \begin{scope}[on background layer]
    \path[fill=gray!20] (a) -- (a1) -- (d1) -- (d) -- cycle;
    \path[fill=gray!20] (a1) -- (c1) -- (b) -- cycle;
    \end{scope}

  \end{tikzpicture}
\end{document}

enter image description here

  • How about label E? – minthao_2011 Feb 8 '14 at 15:54
  • @minthao_2011 Sorry I forgot :). Added now. – user11232 Feb 8 '14 at 15:57
  • @minthao_2011 Thank you, you are welcome. – user11232 Feb 8 '14 at 16:16
7

A tikz solution, providing a different approach.

enter image description here

Code

\documentclass[border=10pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{positioning,calc}

\begin{document}
\begin{tikzpicture}[scale=1,inner sep=0pt, outer sep=0pt]
\coordinate[label=right:$A$] (A) at (-1.2,-1.8);
\coordinate[label=right:$B$] (B) at (2.8,-1.8);
\coordinate[label=right:$C$] (C) at (4,0);
\coordinate[label=right:$D$] (D) at (0,0);
\coordinate[label=$A_1$]    (A1) at (-1.2,1.2);
\coordinate[label=$B_1$]    (B1) at (2.8,1.2);
\coordinate[label=$C_1$]    (C1) at (4,3);
\coordinate[label=$D_1$]    (D1) at (0,3);

\draw [thick] (B) --(A);
\draw [thick] (D1)--(A1)--(B1)--(C1);
\draw [thick] (A1)--(A) (B1)--(B);
\draw [thick] (B) --(C)--(C1)--(D1);
\draw [thick] (C1)--(B);
\draw [dashed]  (C)--(D) --(A)  (D)--(D1);
\filldraw [gray,opacity=0.5,thick] (A1)--(D1)--(D)--(A);
\filldraw [gray,opacity=0.5,thick, dashed] (B)--(C1)--(D)--cycle;
\draw [dotted]   ($(B)!0.5!(C1)$) node[](E){$E$}--(D)  ($(B)!0.5!(C1)$)--(4,0);
\draw [thick,dashed]($(E)!0.2!(D)$) to[bend right=30] ($(E)!0.5!(C)$);   % arc
\end{tikzpicture}
\end{document}

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.