![PSTricks: pst-3dplot で馬蹄形磁石を描く](https://rvso.com/image/400364/PSTricks%3A%20pst-3dplot%20%E3%81%A7%E9%A6%AC%E8%B9%84%E5%BD%A2%E7%A3%81%E7%9F%B3%E3%82%92%E6%8F%8F%E3%81%8F.png)
私はPSTricksを使って馬蹄形磁石で画像を再現しようとしています。これについての質問TikZ で描画したいのですが、PSTricks の方が好きです。PSTricks (pst-3dplot) で次のようなものを描画したいと思います。
ガイダンスを得るためにパッケージを見ました。そこには、単純な直方体 (dt. Quader) を描くためのpst-3dplot
の定義があります。それに触発され、異なる座標の視点による巧妙な定義の多くを省略して (とりあえず で進めます)、最終的に次のコードになりました。\pstThreeDBox
coorType=0
% 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.
そして走る
\pstThreeDHorseshoe(0,0,0)(0,0,2)(1.5,0,0)(0,3,0)
表示されるべきでない行は削除する必要があります。これを行うにはパラメータがありますinvisibleLineStyle
が、十分に文書化されておらず、半ページしかありません。この本ではその線スタイルで線を上書きしようとしましたが、効果はありませんでした。
invisibleLineStyle
このパラメータをどのように処理するかを示し、馬蹄形の内部構造でそれを使用するのに役立つ回答を受け入れます。
編集用: 後で寸法を変更できるように、0.15、0.2 の変数を導入する賢い方法を提案してください。
答え1
馬蹄形磁石のみ:
\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}
完全な例の画像(コメント内のリンク)