Estoy intentando recrear imágenes con imanes de herradura con PSTricks. Me doy cuenta de que hay unpregunta sobre estocon TikZ, pero prefiero PSTricks. Me gustaría dibujar algo como lo siguiente con PSTricks (pst-3dplot):
He mirado el pst-3dplot
paquete para orientarme. Tienen una definición de \pstThreeDBox
para dibujar un cuboide rectangular simple (dt. Quader). Inspirado por eso y omitiendo gran parte de la definición inteligente por casos de diferentes perspectivas de coordenadas (solo siga coorType=0
por ahora), terminé con este código:
% Supposed to draw a threeD Horseshoe
\def\pstThreeDHorseshoe{\pst@object{pstThreeDHorseshoe}}
\def\pstThreeDHorseshoe@i(#1,#2,#3){%
\pst@killglue
\begingroup
\addbefore@par{alternative=false,linestyle=\psk@ThreeDplot@visibleLineStyle}%
\use@keep@par
\gdef\pst@tempX{#1 }%
\gdef\pst@tempY{#2 }%
\gdef\pst@tempZ{#3 }%
\pstThreeDHorseshoe@ii
}% end pstThreeDHorseshoe@i.
\def\pstThreeDHorseshoe@ii(#1,#2,#3)(#4,#5,#6)(#7,#8,#9){%
% Top square :
\pstThreeDSquare(\pst@tempX #1 add,\pst@tempY #2 add,\pst@tempZ #3 add)(#4,#5,#6)(#7,#8,#9)%
% First left square :
\pstThreeDSquare(\pst@tempX #4 add,\pst@tempY #5 add,\pst@tempZ #6 add)(#1 .15 mul,#2 .15 mul,#3 .15 mul)(#7,#8,#9)
% Second left square :
\pstThreeDSquare(\pst@tempX #4 add #1 .85 mul add,\pst@tempY #5 add #2 .85 mul add,\pst@tempZ #6 add #3 .85 mul add)(#1 .15 mul,#2 .15 mul,#3 .15 mul)(#7,#8,#9)
% first front bit :
\pstThreeDSquare(\pst@tempX #7 add,\pst@tempY #8 add,\pst@tempZ #9 add)(#1 .15 mul,#2 .15 mul,#3 .15 mul)(#4,#5,#6)
% second front bit :
\pstThreeDSquare(\pst@tempX #7 add #1 .85 mul add,\pst@tempY #8 add #2 .85 mul add,\pst@tempZ #9 add #3 .85 mul add)(#1 .15 mul,#2 .15 mul,#3 .15 mul)(#4,#5,#6)%
% Inside square one :
\pstThreeDSquare(\pst@tempX #7 .2 mul add #1 .15 mul add,\pst@tempY #8 .2 mul add #2 .15 mul add,\pst@tempZ #9 .2 mul add #3 .15 mul add)(#4,#5,#6)(#7 .8 mul,#8 .8 mul, #9 .8 mul)%
\pstThreeDSquare(\pst@tempX #7 .2 mul add #1 .85 mul add,\pst@tempY #8 .2 mul add #2 .85 mul add,\pst@tempZ #9 .2 mul add #3 .85 mul add)(#4,#5,#6)(#7 .8 mul,#8 .8 mul, #9 .8 mul)%
% Inside square three :
\pstThreeDSquare(\pst@tempX #7 .2 mul add #1 .15 mul add,\pst@tempY #8 .2 mul add #2 .15 mul add,\pst@tempZ #9 .2 mul add #3 .15 mul add)(#4,#5,#6)(#1 .7 mul,#2 .7 mul,#3 .7 mul)
% Back square :
\pstThreeDSquare(\pst@tempX,\pst@tempY,\pst@tempZ)(#4,#5,#6)(#1,#2,#3)
\endgroup
\ignorespaces
}% end pstThreeDHorseshoe@ii.
y correr con
\pstThreeDHorseshoe(0,0,0)(0,0,2)(1.5,0,0)(0,3,0)
Las líneas que no deberían ser visibles deben eliminarse. Para hacerlo existe el parámetro invisibleLineStyle
, pero no está bien documentado, apenas media página.en este libro. Intenté sobrescribir una línea con ese estilo de línea, pero fue en vano.
Aceptaré una respuesta que muestre cómo manejar este parámetro invisibleLineStyle
y me ayude a utilizarlo con la estructura interna de la forma de herradura.
Para una edición: sugiera una forma inteligente de introducir variables para 0,15, 0,2 para que las dimensiones puedan cambiarse más adelante.
Respuesta1
Sólo el imán de herradura:
\documentclass[]{article}
\pagestyle{empty}
\usepackage{pst-solides3d}
\begin{document}
\begin{pspicture}(-2,-3)(7,8)
\psset{viewpoint=20 28 15 rtp2xyz,lightsrc=20 60 60 rtp2xyz,Decran=30,solidmemory}
\psSolid[incolor=red,fillcolor=red,object=parallelepiped,a=2,b=0.75,c=1.5,grid=false,name=H2](0,-0.375,0.75)
\psSolid[incolor=red,fillcolor=red,object=parallelepiped,a=2,b=4,c=0.5,grid=false,name=H1](0,2,0.25)
\psSolid[incolor=red,fillcolor=green,object=parallelepiped,a=2,b=0.75,c=1.5,grid=false,name=H3](0,-0.375,2.25)
\psSolid[incolor=red,fillcolor=green,object=parallelepiped,a=2,b=4,c=0.5,grid=false,name=H4](0,2,2.75)
\end{pspicture}
\end{document}
La imagen del ejemplo completo (Enlace en comentario)