我曾经\psbezier
画过一个带有内推边缘的三角形:
\begin{pspicture}(0,-1)(3,1)
\psdot(0,0) \uput[180](0,0){$a$}
\psdot(3,1) \uput[45](3,1){$c$}
\psdot(3,-1) \uput[-45](3,-1){$b$}
\psbezier(3,1)(2,0.4)(1,0.1)(0,0)
\psbezier[ArrowInside=-*,ArrowInsidePos=0.66](0,0)(1,-0.1)(2,-0.4)(3,-1)
\psbezier[ArrowInside=-*,ArrowInsidePos=0.33](3,-1)(2.6,-0.5)(2.6,0.5)(3,1)
\end{pspicture}
现在,我找不到一种聪明的方法(不使用反复试验猜测坐标)来连接通过直线指定的贝塞尔曲线上的(未命名的)项目ArrowInside
符号ArrowInsidePos
。
或者,我只需将直线与这两条贝塞尔曲线的交点连接起来就足够了。但是再说一遍:即使在浏览了 Timothy Van Zandt 编写的综合用户指南后,我也想不出使用 PStricks 实现此目的的明智方法。
有什么建议可以解决该问题吗?
答案1
贝塞尔曲线被指定为其 x 和 y 坐标的三阶多项式。以下是如何使用\psparnode
(from pst-node
) 在曲线上放置任意距离的节点:
我使用了 PostScript 红皮书第 565 页中的公式(http://www.adobe.com/products/postscript/pdfs/PLRM.pdf:
\documentclass[margin=12pt, pstricks]{standalone}
\usepackage{pst-node}
\makeatletter
\def\psbeziernode(#1)(#2)(#3)(#4)#5#6{%
\begingroup
\pst@getcoor{#1}\pst@tempa
\pst@getcoor{#2}\pst@tempb
\pst@getcoor{#3}\pst@tempc
\pst@getcoor{#4}\pst@tempd
\psparnode{#5}{%
\pst@tempa /y0 ED /x0 ED
\pst@tempb /y1 ED /x1 ED
\pst@tempc /y2 ED /x2 ED
\pst@tempd /y3 ED /x3 ED
/cx { x1 x0 sub 3 mul } def
/bx { x2 x1 sub 3 mul cx sub } def
/ax { x3 x0 sub bx sub cx sub } def
/cy { y1 y0 sub 3 mul } def
/by { y2 y1 sub 3 mul cy sub } def
/ay { y3 y0 sub by sub cy sub } def
ax t mul bx add t mul cx add t mul x0 add
ay t mul by add t mul cy add t mul y0 add \tx@UserCoor}{#6}%
\endgroup
}%
\makeatother
\begin{document}
\begin{pspicture}(0,-1)(3,1)
\psdot(0,0) \uput[180](0,0){$a$}
\psdot(3,1) \uput[45](3,1){$c$}
\psdot(3,-1) \uput[-45](3,-1){$b$}
\psbezier(3,1)(2,0.4)(1,0.1)(0,0)
\psbezier(0,0)(1,-0.1)(2,-0.4)(3,-1)
\psbeziernode(0,0)(1,-0.1)(2,-0.4)(3,-1){0.66}{N1}
\psbezier(3,-1)(2.6,-0.5)(2.6,0.5)(3,1)
\psbeziernode(3,-1)(2.6,-0.5)(2.6,0.5)(3,1){0.33}{N2}
\psline[linecolor=red](N1)(N2)\psdot(N1)\psdot(N2)
\end{pspicture}
\end{document}
结果是:
请注意,对于相同的值,\psbeziernode
和的位置并不完全重合。ArrowInsidePos
将原始节点与和ArrowInside
进行比较时,可以看出箭头略有偏移。ArrowInsidePos=0
ArrowInsidePos=1
答案2
基于 TikZ 的版本:
\documentclass[tikz,border=10pt]{standalone}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}[marker/.style={circle,fill,draw,inner sep=1pt,pos=#1}]
\foreach \place/\angle/\name in {{(0,0)}/180/a,{(3,1)}/45/c,{(3,-1)}/-45/b}
{
\filldraw[black] \place circle (1.5pt)
node[label={\angle:$\name$},inner sep=0pt](\name){};
}
\draw (a) edge[bend left=15]
node[marker=0.75](a-b){}% marking the path a-b: select the position [0,1]
(b) ;
\draw (c) edge[bend right=15]
node[marker=0.7](c-b){}% marking the path c-b: select the position [0,1]
(b) ;
\draw (c) edge[bend left=15](a);
\draw[red](a-b)--(c-b); % interconnecting the two markers
\end{tikzpicture}
\end{document}
结果: