如何使用 PSTrick 或 TikZ 绘制这个立方体?

如何使用 PSTrick 或 TikZ 绘制这个立方体?

我使用 GeoGebra 绘制立方体。GeoGebra 中的代码是

\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}

BD我想要、C_1D和段的样式ADD_1D虚线。我试过了

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

但线条不是虚线。我该如何得到它?

output

答案1

\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

各种各样的

如果表面后面的所有内容都应该被虚化,那么角度标记也应该是虚化。

\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

答案2

\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

答案3

只是做事的另一种方式......

\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

答案4

1) Fuite =30 且 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)fuite = 15,coeff = .7

enter image description here

相关内容