Consider the following code, with which Herbert Voß helped me over at {TeX} SX:
Code: Select all
\documentclass{article}
\usepackage{pst-solides3d}
\usepackage{expl3}
%% Parameters
% Windings
\def\lWind{20}
\def\rWind{10}
% Radii
\def\rHelix{1.11}
\def\rWire{0.015}
% Floating point calculations
\ExplSyntaxOn
\cs_new_eq:NN
\calc
\fp_eval:n
\ExplSyntaxOff
% Constants
\def\factor{80} % \factor > \lWind,\rWind
\def\nLeft{\calc{2*\lWind/\factor} }
\def\nRight{\calc{2*\rWind/\factor} }
%% Colours
\colorlet{wireColor}{red!60}
\colorlet{coreColor}{cyan!50}
%% Wire
\newpsobject{wire}{psSolid}{%
object=courbe,
% Choose max(\nRight,\nLeft) -- the fewer windings, the larger
% the constant multiplied by max(\nRight,\nLeft)
ngrid=970 \nLeft mul cvi 15,
r=\rWire,
fillcolor=wireColor,
incolor=wireColor
}
\pagestyle{empty}
\begin{document}
\begin{figure}[htbp]
\centering
\begin{pspicture}(-5,-5)(5,5)
\psset{%
algebraic,
viewpoint=20 5 10 rtp2xyz,
lightsrc=20 60 60 rtp2xyz,
Decran=30,
solidmemory,
action=none,
grid=false
}
%%--------- Core ----------
\psSolid[object=anneau,h=1.0,R=4,r=2.5,ngrid=4,RotZ=90,RotY=45,RotX=90,
fillcolor=coreColor,name=core]
%%--------- Wire ----------
% Left
\defFunction{heliceA}(t){\rHelix*cos(\factor*t)}{\rHelix*sin(\factor*t)}%
{t/\nLeft}
\wire[function=heliceA,range=0 Pi \nLeft mul,name=wireA](0,-2.25,-1.5)
% Right
\defFunction{heliceB}(t){\rHelix*cos(\factor*t)}{-\rHelix*sin(\factor*t)}%
{t/\nRight}
\wire[function=heliceB,range=0 Pi \nRight mul,name=wireB](0,2.25,-1.5)
%%------- Assembly --------
\psSolid[object=fusion,base=core wireA wireB,action=draw**]
\end{pspicture}
\end{figure}
\end{document}
\nLeft
and \nRight
if I want PSTricks to do them without activating the L3 fp syntax? I have triedCode: Select all
\def\nLeft{2 \lWind mul \factWind div }
\def\nRight{2 \rWind mul \factWind div }
Thank you in advance!