如何将节点横坐标作为参数传递给宏?

如何将节点横坐标作为参数传递给宏?

如何制作以下宏

    %\pstInterFF{\m(N-A.x,N-B.x)}{\fp(x)}{4}{tc}% failed

    %\pstInterFF{\psGetNodeCenter{A}\psGetNodeCenter{B}\m(A.x,B.x)}{\fp(x)}{4}{tc}% failed

    %\pstInterFF{\N(A)(B)}{\fp(x)}{4}{tc}   % failed

    %\pstInterFF{\psGetNodeCenter{A}\psGetNodeCenter{B}\n(A)(B)}{\fp(x)}{4}{tc}% failed

    %\pstInterFF{\psGetNodeCenter{A}\psGetNodeCenter{B}((\f(B.x)-\f(A.x))/(B.x-A.x))}{\fp(x)}{4}{tc}% failed

    %\pstInterFF{(\f(N-B.x)-\f(N-A.x))/(N-B.x-N-A.x)}{\fp(x)}{4}{tc}% failed

工作?

最小工作示例

\documentclass[pstricks,border=12pt]{standalone}
\usepackage{pst-eucl,pstricks-add}

\def\f(#1){((#1)*(#1-5)*(#1-6)/4+1.5*(#1)-5)}

\def\m(#1,#2){((\f(#2)-\f(#1))/(#2-#1))}
\def\N(#1)(#2){((\f(N-#2.x)-\f(N-#1.x))/(N-#2.x-N-#1.x))}
\def\n(#1)(#2){((\f(#2.x)-\f(#1.x))/(#2.x-#1.x))}

\def\fp(#1){Derive(1,\f(#1))}% f'(x) 

\begin{document}

\begin{pspicture}[algebraic,saveNodeCoors](-1,-1)(8,8)
    \psaxes[labels=none,ticks=none]{->}(0,0)(-.5,-.5)(7.5,7.5)[$x$,0][$y$,90]
    \pstGeonode(*1 {\f(x)}){A}(*6.5 {\f(x)}){B}
    \psplot[linecolor=blue]{N-A.x}{N-B.x}{\f(x)}
    \bgroup
    \psset{PointSymbol=none,PointName=none}

    %\pstInterFF{\m(N-A.x,N-B.x)}{\fp(x)}{4}{tc}% failed

    %\pstInterFF{\psGetNodeCenter{A}\psGetNodeCenter{B}\m(A.x,B.x)}{\fp(x)}{4}{tc}% failed

    %\pstInterFF{\N(A)(B)}{\fp(x)}{4}{tc}   % failed

    %\pstInterFF{\psGetNodeCenter{A}\psGetNodeCenter{B}\n(A)(B)}{\fp(x)}{4}{tc}% failed

    %\pstInterFF{\psGetNodeCenter{A}\psGetNodeCenter{B}((\f(B.x)-\f(A.x))/(B.x-A.x))}{\fp(x)}{4}{tc}% failed

    %\pstInterFF{(\f(N-B.x)-\f(N-A.x))/(N-B.x-N-A.x)}{\fp(x)}{4}{tc}% failed

    \pstInterFF{(\f(6.5)-\f(1))/(6.5-1)}{\fp(x)}{4}{tc}% succeeded

    \egroup
    \pstGeonode(*N-tc.x {\f(x)}){C}
    \pcline[nodesep=-1,linecolor=green](A)(B)
    \psxline[linecolor=red](C){.1(A)-.1(B)}{.1(B)-.1(A)}
    \psset{linecolor=gray,linestyle=dashed}
    \psCoordinates(A)\psCoordinates(B)\psCoordinates(C)
\end{pspicture}

\end{document}

答案1

保存节点坐标名称中的破折号和点会导致 和AlgParser被误解。节点名称N-A.x变为N A x exp sub。因此,您必须重新定义N-A.x和 ,N-B.x然后才能在代数表达式中使用它们:

\documentclass[pstricks,border=12pt]{standalone}
\usepackage{pst-eucl,pstricks-add}

\def\f(#1){((#1)*(#1-5)*(#1-6)/4+1.5*(#1)-5)}

\def\m(#1,#2){((\f(#2)-\f(#1))/(#2-#1))}
\def\N(#1)(#2){((\f(N-#2.x)-\f(N-#1.x))/(N-#2.x-N-#1.x))}
\def\n(#1)(#2){((\f(#2.x)-\f(#1.x))/(#2.x-#1.x))}

\def\fp(#1){Derive(1,\f(#1))}% f'(x) 

\begin{document}

\begin{pspicture}[algebraic,saveNodeCoors](-1,-1)(8,8)
    \psaxes[labels=none,ticks=none]{->}(0,0)(-.5,-.5)(7.5,7.5)[$x$,0][$y$,90]
    \pstGeonode(*1 {\f(x)}){A}(*6.5 {\f(x)}){B}
    \psplot[linecolor=blue]{N-A.x}{N-B.x}{\f(x)}
    \bgroup
    \psset{PointSymbol=none,PointName=none}

    \makeatletter
      \pst@Verb{ /NAx N-A.x def /NBx N-B.x def }
    \makeatother
    \pstInterFF{\m(NAx,NBx)}{\fp(x)}{4}{tc}

    \egroup
    \pstGeonode(*N-tc.x {\f(x)}){C}
    \pcline[nodesep=-1,linecolor=green](A)(B)
    \psxline[linecolor=red](C){.1(A)-.1(B)}{.1(B)-.1(A)}
    \psset{linecolor=gray,linestyle=dashed}
    \psCoordinates(A)\psCoordinates(B)\psCoordinates(C)
\end{pspicture}

\end{document}

在此处输入图片描述

对于您的其他表达与\psGetNodeCenter您遇到的类似问题。

答案2

随着电流http://texnik.dante.de/tex/generic/pst-node/pst-node.tex

\documentclass[pstricks,border=12pt]{standalone}
\usepackage{pst-eucl,pstricks-add}

\def\f#1{(#1*(#1-5)*(#1-6)/4+1.5*#1-5)}
\def\m(#1,#2){(\f{#2}-\f{#1})/(#2-#1)}
\def\fp#1{Derive(1,\f{#1})}% f'(x) 

\def\L#1{\uput[-90](#1|0,0){$#1\mathstrut$}\uput[180](0,0|#1){$f(#1)$}\psCoordinates[linestyle=dashed,linecolor=gray](#1)}

\begin{document}

\begin{pspicture}[algebraic,saveNodeCoors,NodeCoorPrefix=N,
   PointSymbol=none,PointName=none](-1,-1)(8,8)
\psaxes[labels=none,ticks=none]{->}(0,0)(-.5,-.5)(7.5,7.5)[$x$,0][$y$,90]
\pnodes(*1 {\f{x}}){a}(*6.5 {\f{x}}){b}
\psplot[linecolor=blue]{Nax}{Nbx}{\f{x}}
\pstInterFF{\m(Nax,Nbx)}{\fp{x}}{4}{temp}
\pstGeonode(*Ntempx {\f{x}}){c}
\pcline[nodesep=-1,linecolor=green](a)(b)
\psxline[linecolor=red](c){.1(a)-.1(b)}{.1(b)-.1(a)}
\psset{linecolor=gray,linestyle=dashed}
\L{a}\L{b}\L{c}
\end{pspicture}

\end{document}

一个新的可选参数,其含义如下:

> 1.33  2014-03-25 - added optional argument NodeCoorPrefix for savedCoors 
>                    By default it is empty: names are N-<Name>.x|y
>                    if it is set:           names are <NodeCoorPrefix><Name>x|y

相关内容