SmtC: Show me the Code
Ole Peter Smith
Instituto de Matemática e Estatística
Universidade Federal de Goiás
http://www.olesmith.com.br

PyTikZ3D
Quando Pedro me fala sobre Paulo
Sei mais do Pedro do que do Paulo
Sigmund Freud
< TikZ | Parallelipiped | Tetrahedron >
Paralelipipid
Python Code:
Python Listing: ../TikZ_Examples/Parallelepiped.py.
import os,sys


sys.path.append('/usr/local/Python')

from TikZ import *
from Vector import *

from Matrix import *
from Mesh import *

O=Vector([0,0,0])
P1=Vector([1,0,0])
P2=Vector([2,0,0])
P3=Vector([1,2,0])

ts=[-0.5,1.5]



CS=Vector([-0.25,-0.25,0])

P0=Vector([1,1,1])
u=Vector([1,0,0])
v=Vector([0.25,1,0])
w=Vector([0.25,0.25,-1])

ps1=[
    P0,
    P0+3*u,
    P0+3*u+3*v,
    P0+3*v,
]

ps2=[]
for p in ps1:
    ps2.append(p+w)

ps=ps1+ps2

box=[
    [0,1,5,4],
    [3,2,6,7],
]

plane1=[1,4,7,2]
plane2=[0,5,6,3]
parallels2=[
    [0,3],[5,6],
]
parallels1=[
    [1,2],[4,7]
]

M1=Vector([0,0,0])
for i in range(   len(box[0])   ):
    M1=M1+ps[   box[0][i]   ]
M1=0.25*M1

M2=Vector([0,0,0])
for i in range(   len(box[1])   ):
    M2=M2+ps[   box[1][i]   ]
M2=0.25*M2


mytikz=TikZ()

#Styles
ucs_style="gray"

color_1="blue"
color_2="cyan"
color_meridional="orange"

style_connections=""
style_vector="-latex"
style_meridional=color_meridional+","+style_vector

style_diagonals=style_connections+",dashed"
style_1=color_1+",opacity=0.5"
style_2=color_2+",opacity=0.5"

tikz=[]
tikz+=mytikz.TikZ_UCS(
    u,v,w,CS,
    ucs_style,
    titles=["u","v","w"]
)


tikz=tikz+mytikz.TikZ_Points(
    ps,
    titles=["A","B","C","D","E","F","G","H"],
    node_style=["below","below","right","left","left","right","above","above"]
)


tikz+=mytikz.TikZ_Connections_Draw(
    ps,box,
    style_connections,
    comment="Box"
)
tikz+=mytikz.TikZ_Connections_Draw(
    ps,
    [[0,3],[1,2],[4,7],[5,6]],
    style_connections
)
tikz+=mytikz.TikZ_Connections_Draw(
    ps,
    [[2,7],[3,6]],
    style_diagonals
)
tikz+=mytikz.TikZ_Connections_Draw(
    ps,
    [[0,5],[1,4]],
    style_diagonals
)

pdf=mytikz.TikZ_LaTeX_Save_Run(
    mytikz.TikZ_LaTeX_Picture(tikz),
    "Parallelipiped.pdf"
)
$\LaTeX$ Generated::
LaTeX Listing: ../TikZ_Examples/Images/Parallelepiped.tex. PDF   ZIP*  
\documentclass{standalone}
%%%%! Preamble from: /root/ufg/PreAmble.tikz.tex

\usepackage{xcolor}
\usepackage{graphicx}
\usepackage{ifthen}
\usepackage{xifthen}

\usepackage{amssymb,amsmath,amsthm}

\usepackage{pgfplots}


\usepackage{pgf,pgffor}


\newcommand{\Vector}[1]{\underline{\mathbf{#1}}}%\Vector{a}
\newcommand{\Matrix}[1]{\underline{\underline{{\mathbf{#1}}}}}

\usepackage{tikz}
\usepackage{tkz-euclide}
%%!
%%! For older versions of package tkz-euclide
%%! you may need uncomment the following line:
%   \usetkzobj{all}
%%!

\usetikzlibrary
    {
      shapes.geometric,
      arrows,
      calc,
      intersections,
      arrows.meta,
      decorations.markings,
      positioning,
      math,
      angles,
      quotes,
      patterns,3d,
      backgrounds,
      fillbetween
    }

\makeatletter
\newcommand{\gettikzxy}[3]{%
  \tikz@scan@one@point\pgfutil@firstofone#1\relax
  \edef#2{\the\pgf@x}%
  \edef#3{\the\pgf@y}%
  \tikzmath{\#2=#2/28.4527;};
  \tikzmath{\#3=#3/28.4527;};
}
\makeatother
\pgfplotsset{compat=1.14}



%%%%! Preamble end: /root/ufg/PreAmble.tikz.tex


\begin{document}

   \begin{tikzpicture}[]
      %%! UCS
      %%! UCS
      \filldraw[blue] (-0.500000,-0.500000,0.000000) circle(1pt);
      \draw[-latex,very thin,blue] (-0.500000,-0.500000,0.000000) -- (0.500000,-0.500000,0.000000);
      \node[] at (0.600000,-0.500000,0.000000) {};
      \draw[-latex,very thin,blue] (-0.500000,-0.500000,0.000000) -- (-0.250000,0.500000,0.000000);
      \node[] at (-0.225000,0.600000,0.000000) {};
      \draw[-latex,very thin,blue] (-0.500000,-0.500000,0.000000) -- (-0.250000,-0.250000,-1.000000);
      \node[] at (-0.225000,-0.225000,-1.100000) {};
      \node[blue] at (0.600000,-0.500000,0.000000) {\tiny{$u$}};
      \node[blue] at (-0.225000,0.600000,0.000000) {\tiny{$v$}};
      \node[blue] at (-0.225000,-0.225000,-1.100000) {\tiny{$w$}};
      
      %%! Mesh
      \filldraw[] (1.000000,1.000000,1.000000) circle(1pt);
      \filldraw[] (1.000000,1.000000,1.000000) circle(1pt);
      \node[above,font={\tiny}] at (0.950000,0.950000,1.000000) { $A$ };
      \filldraw[] (2.000000,1.000000,1.000000) circle(1pt);
      \filldraw[] (2.000000,1.000000,1.000000) circle(1pt);
      \node[above,font={\tiny}] at (1.950000,0.950000,1.000000) { $B$ };
      \filldraw[] (2.250000,2.000000,1.000000) circle(1pt);
      \filldraw[] (2.250000,2.000000,1.000000) circle(1pt);
      \node[above,font={\tiny}] at (2.200000,1.950000,1.000000) { $C$ };
      \filldraw[] (1.250000,2.000000,1.000000) circle(1pt);
      \filldraw[] (1.250000,2.000000,1.000000) circle(1pt);
      \node[above,font={\tiny}] at (1.200000,1.950000,1.000000) { $D$ };
      \filldraw[] (1.250000,1.250000,0.000000) circle(1pt);
      \filldraw[] (1.250000,1.250000,0.000000) circle(1pt);
      \node[above,font={\tiny}] at (1.200000,1.200000,0.000000) { $E$ };
      \filldraw[] (2.250000,1.250000,0.000000) circle(1pt);
      \filldraw[] (2.250000,1.250000,0.000000) circle(1pt);
      \node[above,font={\tiny}] at (2.200000,1.200000,0.000000) { $F$ };
      \filldraw[] (2.500000,2.250000,0.000000) circle(1pt);
      \filldraw[] (2.500000,2.250000,0.000000) circle(1pt);
      \node[above,font={\tiny}] at (2.450000,2.200000,0.000000) { $G$ };
      \filldraw[] (1.500000,2.250000,0.000000) circle(1pt);
      \filldraw[] (1.500000,2.250000,0.000000) circle(1pt);
      \node[above,font={\tiny}] at (1.450000,2.200000,0.000000) { $H$ };
      
      
      %%! Box
      \draw[ultra thin](1.000000,1.000000,1.000000) -- (2.000000,1.000000,1.000000) -- (2.250000,1.250000,0.000000) -- (1.250000,1.250000,0.000000) -- cycle;
      \draw[ultra thin](1.250000,2.000000,1.000000) -- (2.250000,2.000000,1.000000) -- (2.500000,2.250000,0.000000) -- (1.500000,2.250000,0.000000) -- cycle;
      
      %%! Diagonals 1
      \draw[ultra thin,dashed](2.250000,2.000000,1.000000) -- (1.500000,2.250000,0.000000) -- cycle;
      \draw[ultra thin,dashed](1.250000,2.000000,1.000000) -- (2.500000,2.250000,0.000000) -- cycle;
      
      %%! Diagonals 2
      \draw[ultra thin,dashed](1.000000,1.000000,1.000000) -- (2.250000,1.250000,0.000000) -- cycle;
      \draw[ultra thin,dashed](2.000000,1.000000,1.000000) -- (1.250000,1.250000,0.000000) -- cycle;
      \draw[orange,-latex] (1.375000,0.125000,0.500000) -- (2.125000,3.125000,0.500000);
      \filldraw[orange] (1.625000,1.125000,0.500000) circle(1pt);
      \filldraw[orange] (1.875000,2.125000,0.500000) circle(1pt);
      \fill[blue,opacity=0.5](2.000000,1.000000,1.000000) -- (1.250000,1.250000,0.000000) -- (1.500000,2.250000,0.000000) -- (2.250000,2.000000,1.000000) -- cycle;
      \fill[cyan,opacity=0.5](1.000000,1.000000,1.000000) -- (2.250000,1.250000,0.000000) -- (2.500000,2.250000,0.000000) -- (1.250000,2.000000,1.000000) -- cycle;
      \draw[blue,opacity=0.5,-latex] (1.750000,0.000000,1.000000) -- (2.500000,3.000000,1.000000);
      \draw[blue,opacity=0.5,-latex] (1.000000,0.250000,0.000000) -- (1.750000,3.250000,0.000000);
      \draw[cyan,opacity=0.5,-latex] (0.750000,0.000000,1.000000) -- (1.500000,3.000000,1.000000);
      \draw[cyan,opacity=0.5,-latex] (2.000000,0.250000,0.000000) -- (2.750000,3.250000,0.000000);
   \end{tikzpicture}


\end{document}
< TikZ | Parallelipiped | Tetrahedron >
Messages:
0 secs.