pstricks、psSolid 和 listplotIIID

pstricks、psSolid 和 listplotIIID

在 listplotIIID 中,有没有办法将“100 分”后的线条颜色改为灰色,将“500 分”后的线条颜色改回黑色等等?

\documentclass[border=0pt,10pt,dvipsnames]{standalone}
\usepackage{amsmath}
\usepackage{pstricks}
\usepackage{dashrule}
\usepackage{pst-plot}%, pst-math}
\usepackage{pst-func}
\usepackage{pst-ode}
\usepackage{pst-3dplot}
\usepackage{pst-solides3d}
\usepackage[off]{auto-pst-pdf}
\usepackage[nomessages]{fp}
\psset{algebraic,unit=2}
\usepackage[active,tightpage]{preview}
\PreviewBorder=12pt
\PreviewEnvironment{pspicture}




\makeatletter
\def\listplotIIID{\def\pst@par{}\pst@object{listplotIIID}}
\def\listplotIIID@i#1{%
\@nameuse{beginplot@\psplotstyle}%
\addto@pscode{%
   /viewpointXYZ {\pst@solides@viewpoint} def
   /Decran \pst@solides@Decran\space def % distance de l'ecran
    viewpointXYZ /ZpointVue ED /YpointVue ED /XpointVue ED
  /THETA {YpointVue XpointVue atan} bind def
  /PHI   {ZpointVue XpointVue dup mul YpointVue dup mul add sqrt atan} bind def
  /Dobs  {XpointVue dup mul YpointVue dup mul add ZpointVue dup mul add sqrt} bind def
  XpointVue YpointVue ZpointVue /viewpoint defpoint3d
    /XYZ [#1] def
  /@tabXYZ [
    0 3 XYZ length 3 sub {/i exch def
     XYZ i get
     XYZ i 1 add get
     XYZ i 2 add get
     3dto2d
     \pst@number\psunit mul exch
     \pst@number\psunit mul exch
    }  for
    ] bind def
 [ @tabXYZ aload pop
    }%
\@nameuse{endplot@\psplotstyle}}%
\makeatother


\def\r(#1){0.25*sqrt((9-#1*#1)*(#1*#1+1))}
\def\rs(#1){-(1/4)*#1*(#1^2-4)/sqrt(-(#1^2-9)*(#1^2+1))}
\def\rss(#1){-(1/4)*(#1^6-12*#1^4-27*#1^2+36)/((#1^2-9)*(#1^2+1)*sqrt(-(#1^2-9)*(#1^2+1))) }


\begin{document}
\begin{pspicture}(-2.1,-1.1)(2.5,1.2)
\psset[pst-solides3d]{viewpoint=20 5 20,Decran=20,lightsrc=viewpoint}
\defFunction[algebraic]{rot}(t,v){\r(t)*sin(v)} {t} {\r(t)*cos(v)}
\psSolid[object=surfaceparametree,base=-3 3 0 6.28,
inhue=0.01 0.11, hue=0.1 0,
function=rot,linewidth=0.5pt,grid=false,opacity=0.8,ngrid=200 70,
intersectiontype=0,       
%% Intersections with planes [a b c d] = ax + by + cz + d = 0
intersectionplan={[0 1 0 0] [0 1 0 -2.828] [0 0 1 0]},
intersectioncolor=(red) (red)  (blue),
intersectionlinewidth=1 1]

\axesIIID(1,3,1)(2,3.5,2)

\pstODEsolve[algebraic,algebraicOutputFormat]{test}{\r(x[2])*sin(x[0])
| x[2] | \r(x[2])*cos(x[0])}{0}{14}{2000}{1.57 1 2.8284 0}{ x[1] |
 -2*\rs(x[2])*x[1]*x[3]/(\r(x[2]))| x[3] |
 -\rss(x[2])*\rs(x[2])*x[3]*x[3]/(\rs(x[2])*\rs(x[2])+1)
+\rs(x[2])*\r(x[2])*x[1]*x[1]/(\rs(x[2])*\rs(x[2])+1)}

\listplotIIID[linecolor=black,linewidth=1pt]{test}

\pstODEsolve[algebraic,algebraicOutputFormat]{test}{\r(x[2])*sin(x[0]) |
 x[2] | \r(x[2])*cos(x[0])}{0}{2}{500}{1.57 -1 2.8284 0}{ x[1] |
 -2*\rs(x[2])*x[1]*x[3]/(\r(x[2]))| x[3] |
 -\rss(x[2])*\rs(x[2])*x[3]*x[3]/(\rs(x[2])*\rs(x[2])+1)
+\rs(x[2])*\r(x[2])*x[1]*x[1]/(\rs(x[2])*\rs(x[2])+1)}
\listplotIIID[linecolor=black,linewidth=1pt]{test}
\psSolid[object=point,args=0.75 2.828 0]
\end{pspicture}
\end{document}

答案1

以下解决方案定义了一个键valuerange=<start>-<stop>,它将成为下一次更新的一部分pst-solides3d

\documentclass[border=0pt,10pt,dvipsnames,pstricks]{standalone}
\usepackage{amsmath}
\usepackage{dashrule}
\usepackage{pst-plot}%, pst-math}
\usepackage{pst-func}
\usepackage{pst-ode}
\usepackage{pst-3dplot}

\usepackage{pst-solides3d}
\usepackage[nomessages]{fp}
\psset{algebraic,unit=2}

\makeatletter
\define@key[psset]{}{valuerange}[1-]{\expandafter\pst@getrange#1\@nil}
\def\pst@getrange#1-#2\@nil{%
  \ifx\relax#1\relax \def\pst@startvalue{1 }\else\def\pst@startvalue{#1 }\fi%
  \ifx\relax#2\relax \def\pst@endvalue{1e32 }\else\def\pst@endvalue{#2 }\fi%
}
\psset{valuerange=1-}

\def\listplotIIID{\def\pst@par{}\pst@object{listplotIIID}}
\def\listplotIIID@i#1{%
\@nameuse{beginplot@\psplotstyle}%
\addto@pscode{%
   /viewpointXYZ {\pst@solides@viewpoint} def
   /Decran \pst@solides@Decran\space def % distance de l'ecran
    viewpointXYZ /ZpointVue ED /YpointVue ED /XpointVue ED
  /THETA {YpointVue XpointVue atan} bind def
  /PHI   {ZpointVue XpointVue dup mul YpointVue dup mul add sqrt atan} bind def
  /Dobs  {XpointVue dup mul YpointVue dup mul add ZpointVue dup mul add sqrt} bind def
  XpointVue YpointVue ZpointVue /viewpoint defpoint3d
    /XYZ [#1] def
  /@tabXYZ [
    0 3 XYZ length 3 sub {
     /i exch def
     XYZ i get
     XYZ i 1 add get
     XYZ i 2 add get
     i 3 div dup /ii ED  
       \pst@startvalue ge {
         ii \pst@endvalue le { 
         3dto2d
         \pst@number\psunit mul exch
         \pst@number\psunit mul exch
       } { pop pop pop } ifelse
     }{ pop pop pop } ifelse
    }  for
    ] bind def
 [ @tabXYZ aload pop
    }%
\@nameuse{endplot@\psplotstyle}}%
\makeatother

\def\r(#1){0.25*sqrt((9-#1*#1)*(#1*#1+1))}
\def\rs(#1){-(1/4)*#1*(#1^2-4)/sqrt(-(#1^2-9)*(#1^2+1))}
\def\rss(#1){-(1/4)*(#1^6-12*#1^4-27*#1^2+36)/((#1^2-9)*(#1^2+1)*sqrt(-(#1^2-9)*(#1^2+1))) }


\begin{document}
\begin{pspicture}(-2.1,-1.1)(2.5,1.2)
\psset[pst-solides3d]{viewpoint=20 5 20,Decran=20,lightsrc=viewpoint}
\defFunction[algebraic]{rot}(t,v){\r(t)*sin(v)} {t} {\r(t)*cos(v)}
%\psSolid[object=surfaceparametree,base=-3 3 0 6.28,inhue=0.01 0.11, hue=0.1 0,
%   function=rot,linewidth=0.5pt,grid=false,opacity=0.8,ngrid=200 70,
%   intersectiontype=0,       
%   %% Intersections with planes [a b c d] = ax + by + cz + d = 0
%   intersectionplan={[0 1 0 0] [0 1 0 -2.828] [0 0 1 0]},
%   intersectioncolor=(red) (red)  (blue),
%   intersectionlinewidth=1 1]

\axesIIID(1,3,1)(2,3.5,2)

\pstODEsolve[algebraic,algebraicOutputFormat,%saveData
  ]{test}{\r(x[2])*sin(x[0])
| x[2] | \r(x[2])*cos(x[0])}{0}{14}{2000}{1.57 1 2.8284 0}{ x[1] |
 -2*\rs(x[2])*x[1]*x[3]/(\r(x[2]))| x[3] |
 -\rss(x[2])*\rs(x[2])*x[3]*x[3]/(\rs(x[2])*\rs(x[2])+1)
+\rs(x[2])*\r(x[2])*x[1]*x[1]/(\rs(x[2])*\rs(x[2])+1)}

\listplotIIID[linewidth=1pt,linecolor=red,valuerange={-50}]{test}
\listplotIIID[linewidth=1pt,linecolor=green,valuerange={50-100}]{test}
\listplotIIID[linewidth=1pt,linecolor=blue,valuerange={100-}]{test}

\pstODEsolve[algebraic,algebraicOutputFormat]{test}{
  \r(x[2])*sin(x[0]) |
  x[2]               | 
  \r(x[2])*cos(x[0])}{0}{2}{500}{1.57 -1 2.8284 0}{ x[1] |
 -2*\rs(x[2])*x[1]*x[3]/(\r(x[2]))| x[3] |
 -\rss(x[2])*\rs(x[2])*x[3]*x[3]/(\rs(x[2])*\rs(x[2])+1)
    +\rs(x[2])*\r(x[2])*x[1]*x[1]/(\rs(x[2])*\rs(x[2])+1)}

\listplotIIID[linewidth=1pt,linecolor=cyan,valuerange={-50}]{test}
\listplotIIID[linewidth=1pt,linecolor=magenta,valuerange={50-100}]{test}
\listplotIIID[linewidth=1pt,linecolor=gray,valuerange={100-}]{test}

%\psSolid[object=point,args=0.75 2.828 0]

\end{pspicture}

\end{document}

在此处输入图片描述

相关内容