![\psGetDistance 有什么作用?](https://linux22.com/image/463728/%5CpsGetDistance%20%E6%9C%89%E4%BB%80%E4%B9%88%E4%BD%9C%E7%94%A8%EF%BC%9F.png)
朋友们,
我想知道\psGetDistance
这是否与欧氏距离有关,或者它与什么有关?下面是我解释的一个最小工作示例:
\documentclass{article}
\usepackage{pstricks-add}
\usepackage{fp}
\def\distance(#1,#2)(#3,#4){
\FPset\hjsxi{#1}
\FPset\hjsxii{#3}
\FPset\hjsyi{#2}
\FPset\hjsyii{#4}
\FPsub\hjsxa\hjsxii\hjsxi
\FPmul\hjsxa\hjsxa\hjsxa
\FPsub\hjsya\hjsyii\hjsyi
\FPmul\hjsya\hjsya\hjsya
\FPadd\hjsz\hjsxa\hjsya
\FPeval\hjsz{root(2,\hjsz)}
\FPeval\hjsz{round(\hjsz,2)}
\FPeval\hjsz{clip(\hjsz)}
\hjsz}
\setlength{\parindent}{0pt}
\begin{document}
Note that:\\
\verb+(1) \psGetDistance(-2,1)( 3, 1)\DVal \DVal+ = \psGetDistance(-2,1)(3,1)\DVal \DVal\\
\verb+(2) \psGetDistance(-2,1)(-3,-1)\DVal \DVal+ = \psGetDistance(-2,1)(-3,-1)\DVal \DVal\\
\verb+(3) \psGetDistance(-2,0)( 3,-1)\DVal \DVal+ = \psGetDistance(-2,0)( 3,-1)\DVal \DVal\\\\
However rounded distance is\\
\verb+(4) \distance(-2,1)( 3, 1)+ = \distance(-2,1)(3,1)\\
\verb+(5) \distance(-2,1)(-3,-1)+ = \distance(-2,1)(-3,-1)\\
\verb+(6) \distance(-2,0)( 3,-1)+ = \distance(-2,0)(3,-1)\\
\end{document}
这是输出:
结果 (1)-(3) 与 pstricks-add 的文档相对应。但是没有给出解释细节。结果 (4)-(6) 是欧几里得距离。
亲切的问候
汉斯
答案1
具有最新的PSTricks-add
:
\documentclass{article}
\usepackage{pstricks-add}
\parindent=0pt
\begin{document}
Note that:
\verb+(1) \psGetDistance(-2,1)( 3, 1)\DVal \DVal+ = \psGetDistance(-2,1)(3,1)\CVal \CVal\\
\verb+(2) \psGetDistance(-2,1)(-3,-1)\DVal \DVal+ = \psGetDistance[3](-2,1)(-3,-1)\CVal
\CVal\\
\verb+(3) \psGetDistance(-2,0)( 3,-1)\DVal \DVal+ = \psGetDistance[5](-2,0)( 3,-1)\CVal
\CVal
\end{document}