[pstricks] [pst-eucl] add some useful macros with examples, do you like them?

廖雄飞 liaofei1128 at 163.com
Fri Sep 27 16:02:38 CEST 2019


After a lot of tests, I found that it is need to fix \pstAbsNode and \pstOrdNode to divide the \psxunit and \psyunit.
So I update the patch as following:
--------------------------------------------
*** a/pst-eucl.tex2019-09-27 21:57:39.592734200 +0800
--- b/pst-eucl.tex2019-09-27 21:57:16.004449300 +0800
***************
*** 1730,1735 ****
--- 1730,1841 ----
    \ignorespaces
  }
  %
+ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+ %% Here are some functions to operate the Coordinate
+ %% of a given node.
+ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+ %
+ %% \pstAbsNode - return the abscissa value of a node, which can be transformed to a new abscissa by pstricks raw code.
+ %% #1 -> [input] the input node
+ \def\pstAbsNode#1{%
+   tx at EcldDict begin /N@#1 GetNode pop \pst at number\psxunit div end
+ }%
+ %
+ % \pstOrdNode - return the ordinate value of a node, which can be transformed to a new ordinate by pstricks raw code.
+ %% #1 -> [input] the input node
+ \def\pstOrdNode#1{%
+   tx at EcldDict begin /N@#1 GetNode exch pop \pst at number\psyunit div end
+ }%
+ %
+ % \pstMoveNode - move a node by abscissa and ordinate and get the target node.
+ %% #1 -> options
+ %% #2 -> abscissa increment
+ %% #3 -> ordinate increment
+ %% #4 -> orignal node name
+ %% #5 -> target node name
+ \def\pstMoveNode{\@ifnextchar[\Pst at MoveNode{\Pst at MoveNode[]}}
+ \def\Pst at MoveNode[#1]{%
+   \begingroup
+     \psset{#1}%
+     \Pst at MoveNode@i}
+ \def\Pst at MoveNode@i(#1,#2)#3#4{%
+   \pnode(! \pstAbsNode{#3} #1 add \pstOrdNode{#3} #2 add){#4}%
+   \Pst at geonodelabel{#4}%
+   \endgroup%
+ }%
+ %
+ % \pstLineAbsNode - create a new node on the line AB whose abscissa was the given value.
+ %% #1 -> options
+ %% #2 -> [input] the line point A
+ %% #3 -> [input] the line point B
+ %% #4 -> [input] the abscissa value
+ %% #5 -> [output] the target node name
+ \def\pstLineAbsNode{\@ifnextchar[\Pst at LineAbsNode{\Pst at LineAbsNode[]}}
+ \def\Pst at LineAbsNode[#1]{%
+   \begingroup
+     \psset{#1}%
+     \Pst at LineAbsNode@i}
+ \def\Pst at LineAbsNode@i#1#2#3#4{%
+   \pnode(! #3 0){@LINEABSAUXA#1#2}\pnode(! #3 1){@LINEABSAUXB#1#2}%
+   \pstInterLL{#1}{#2}{@LINEABSAUXA#1#2}{@LINEABSAUXB#1#2}{#4}%
+   \Pst at geonodelabel{#4}%
+   \endgroup%
+ }%
+ %
+ % \pstLineOrdNode - create a new node on the line AB whose ordinate was the given value.
+ %% #1 -> options
+ %% #2 -> [input] the line point A
+ %% #3 -> [input] the line point B
+ %% #4 -> [input] the ordinate value
+ %% #5 -> [output] the target node name
+ \def\pstLineOrdNode{\@ifnextchar[\Pst at LineOrdNode{\Pst at LineOrdNode[]}}
+ \def\Pst at LineOrdNode[#1]{%
+   \begingroup
+     \psset{#1}%
+     \Pst at LineOrdNode@i}
+ \def\Pst at LineOrdNode@i#1#2#3#4{%
+   \pnode(! 0 #3){@LINEORDAUXA#1#2}\pnode(! 1 #3){@LINEORDAUXB#1#2}%
+   \pstInterLL{#1}{#2}{@LINEORDAUXA#1#2}{@LINEORDAUXB#1#2}{#4}%
+   \Pst at geonodelabel{#4}%
+   \endgroup%
+ }%
+ %
+ % \pstCircleAbsNode - create the new nodes on the Circle O whose abscissa was the given value.
+ %% #1 -> options
+ %% #2 -> [input] the circle center O
+ %% #3 -> [input] the circle point A or empty with Radius parameter
+ %% #4 -> [input] the abscissa value
+ %% #5 -> [output] the target node name
+ %% #6 -> [output] the target node name
+ \def\pstCircleAbsNode{\@ifnextchar[\Pst at CircleAbsNode{\Pst at CircleAbsNode[]}}
+ \def\Pst at CircleAbsNode[#1]{%
+   \begingroup
+     \psset{#1}%
+     \Pst at CircleAbsNode@i}
+ \def\Pst at CircleAbsNode@i#1#2#3#4#5{%
+   \pnode(! #3 0){@LINEABSAUXA#1#2}\pnode(! #3 1){@LINEABSAUXB#1#2}%
+   \pstInterLC{@LINEABSAUXA#1#2}{@LINEABSAUXB#1#2}{#1}{#2}{#4}{#5}%
+   \endgroup%
+ }%
+ %
+ % \pstCircleOrdNode - create a new node on the line AB whose ordinate was the given value.
+ %% #1 -> options
+ %% #2 -> [input] the line point A
+ %% #3 -> [input] the line point B
+ %% #4 -> [input] the ordinate value
+ %% #5 -> [output] the target node name
+ %% #6 -> [output] the target node name
+ \def\pstCircleOrdNode{\@ifnextchar[\Pst at CircleOrdNode{\Pst at CircleOrdNode[]}}
+ \def\Pst at CircleOrdNode[#1]{%
+   \begingroup
+     \psset{#1}%
+     \Pst at CircleOrdNode@i}
+ \def\Pst at CircleOrdNode@i#1#2#3#4#5{%
+   \pnode(! 0 #3){@LINEORDAUXA#1#2}\pnode(! 1 #3){@LINEORDAUXB#1#2}%
+   \pstInterLC{@LINEORDAUXA#1#2}{@LINEORDAUXB#1#2}{#1}{#2}{#4}{#5}%
+   \endgroup%
+ }%
+ %
  \catcode`\@=\PstAtCode\relax
  %
  \endinput


| |
廖雄飞
|
|
liaofei1128 at 163.com
|
签名由网易邮箱大师定制
On 9/27/2019 09:15,廖雄飞<liaofei1128 at 163.com> wrote:
I have some update to use the special coordinate such that we can use \pstAbsNode and \pstOrdNode as abscissa and ordinate parameter, for example

\pstCircleAbsNode[Radius=\pstDistVal{2},PosAngleA=-60,PosAngleB=60,PointSymbol=*]{O}{}{\pstAbsNode{O}}{C}{D}

-------------------
diff -p a/pst-eucl.tex b/pst-eucl.tex
*** a/pst-eucl.tex     2019-09-27 08:58:30.600000000 +0800
--- b/pst-eucl.tex     2019-09-27 08:55:45.400000000 +0800
***************
*** 1730,1735 ****
--- 1730,1841 ----
   \ignorespaces
 }
 %
+ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+ %% Here are some functions to operate the Coordinate
+ %% of a given node.
+ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+ %
+ %% \pstAbsNode - return the abscissa value of a node, which can be transformed to a new abscissa by pstricks raw code.
+ %% #1 -> [input] the input node
+ \def\pstAbsNode#1{%
+   tx at EcldDict begin /N@#1 GetNode pop end
+ }%
+ %
+ % \pstOrdNode - return the ordinate value of a node, which can be transformed to a new ordinate by pstricks raw code.
+ %% #1 -> [input] the input node
+ \def\pstOrdNode#1{%
+   tx at EcldDict begin /N@#1 GetNode exch pop end
+ }%
+ %
+ % \pstMoveNode - move a node by abscissa and ordinate and get the target node.
+ %% #1 -> options
+ %% #2 -> abscissa increment
+ %% #3 -> ordinate increment
+ %% #4 -> orignal node name
+ %% #5 -> target node name
+ \def\pstMoveNode{\@ifnextchar[\Pst at MoveNode{\Pst at MoveNode[]}}
+ \def\Pst at MoveNode[#1]{%
+   \begingroup
+     \psset{#1}%
+     \Pst at MoveNode@i}
+ \def\Pst at MoveNode@i(#1,#2)#3#4{%
+   \pnode(! \pstAbsNode{#3} #1 add \pstOrdNode{#3} #2 add){#4}%
+   \Pst at geonodelabel{#4}%
+   \endgroup%
+ }%
+ %
+ % \pstLineAbsNode - create a new node on the line AB whose abscissa was the given value.
+ %% #1 -> options
+ %% #2 -> [input] the line point A
+ %% #3 -> [input] the line point B
+ %% #4 -> [input] the abscissa value
+ %% #5 -> [output] the target node name
+ \def\pstLineAbsNode{\@ifnextchar[\Pst at LineAbsNode{\Pst at LineAbsNode[]}}
+ \def\Pst at LineAbsNode[#1]{%
+   \begingroup
+     \psset{#1}%
+     \Pst at LineAbsNode@i}
+ \def\Pst at LineAbsNode@i#1#2#3#4{%
+   \pnode(! #3 0){@LINEABSAUXA#1#2}\pnode(! #3 1){@LINEABSAUXB#1#2}%
+   \pstInterLL{#1}{#2}{@LINEABSAUXA#1#2}{@LINEABSAUXB#1#2}{#4}%
+   \Pst at geonodelabel{#4}%
+   \endgroup%
+ }%
+ %
+ % \pstLineOrdNode - create a new node on the line AB whose ordinate was the given value.
+ %% #1 -> options
+ %% #2 -> [input] the line point A
+ %% #3 -> [input] the line point B
+ %% #4 -> [input] the ordinate value
+ %% #5 -> [output] the target node name
+ \def\pstLineOrdNode{\@ifnextchar[\Pst at LineOrdNode{\Pst at LineOrdNode[]}}
+ \def\Pst at LineOrdNode[#1]{%
+   \begingroup
+     \psset{#1}%
+     \Pst at LineOrdNode@i}
+ \def\Pst at LineOrdNode@i#1#2#3#4{%
+   \pnode(! 0 #3){@LINEORDAUXA#1#2}\pnode(! 1 #3){@LINEORDAUXB#1#2}%
+   \pstInterLL{#1}{#2}{@LINEORDAUXA#1#2}{@LINEORDAUXB#1#2}{#4}%
+   \Pst at geonodelabel{#4}%
+   \endgroup%
+ }%
+ %
+ % \pstCircleAbsNode - create the new nodes on the Circle O whose abscissa was the given value.
+ %% #1 -> options
+ %% #2 -> [input] the circle center O
+ %% #3 -> [input] the circle point A or empty with Radius parameter
+ %% #4 -> [input] the abscissa value
+ %% #5 -> [output] the target node name
+ %% #6 -> [output] the target node name
+ \def\pstCircleAbsNode{\@ifnextchar[\Pst at CircleAbsNode{\Pst at CircleAbsNode[]}}
+ \def\Pst at CircleAbsNode[#1]{%
+   \begingroup
+     \psset{#1}%
+     \Pst at CircleAbsNode@i}
+ \def\Pst at CircleAbsNode@i#1#2#3#4#5{%
+   \pnode(! #3 0){@LINEABSAUXA#1#2}\pnode(! #3 1){@LINEABSAUXB#1#2}%
+   \pstInterLC{@LINEABSAUXA#1#2}{@LINEABSAUXB#1#2}{#1}{#2}{#4}{#5}%
+   \endgroup%
+ }%
+ %
+ % \pstCircleOrdNode - create a new node on the line AB whose ordinate was the given value.
+ %% #1 -> options
+ %% #2 -> [input] the line point A
+ %% #3 -> [input] the line point B
+ %% #4 -> [input] the ordinate value
+ %% #5 -> [output] the target node name
+ %% #6 -> [output] the target node name
+ \def\pstCircleOrdNode{\@ifnextchar[\Pst at CircleOrdNode{\Pst at CircleOrdNode[]}}
+ \def\Pst at CircleOrdNode[#1]{%
+   \begingroup
+     \psset{#1}%
+     \Pst at CircleOrdNode@i}
+ \def\Pst at CircleOrdNode@i#1#2#3#4#5{%
+   \pnode(! 0 #3){@LINEORDAUXA#1#2}\pnode(! 1 #3){@LINEORDAUXB#1#2}%
+   \pstInterLC{@LINEORDAUXA#1#2}{@LINEORDAUXB#1#2}{#1}{#2}{#4}{#5}%
+   \endgroup%
+ }%
+ %
 \catcode`\@=\PstAtCode\relax
 %
 \endinput


|
廖雄飞
北京龙腾融智科技有限公司
18510165638
邮箱:liaofei1128 at 163.com
北京市海淀区农大南路33号中电华晶商务酒店六楼
|

签名由 网易邮箱大师 定制

On 09/27/2019 00:22, 廖雄飞 wrote:
Hi, 
    This time I add the following seven macros, they are:


\pstAbsNode - return the abscissa value of a node, which can be transformed to a new abscissa by pstricks raw code.
\pstOrdNode - return the ordinate value of a node, which can be transformed to a new ordinate by pstricks raw code.
\pstMoveNode - move a node by abscissa and ordinate and get the target node.
\pstLineAbsNode - create a new node on the line AB whose abscissa was the given value.
\pstLineOrdNode - create a new node on the line AB whose ordinate was the given value.
\pstCircleAbsNode - create the new nodes on the Circle O whose abscissa was the given value.
\pstCircleOrdNode - create a new node on the line AB whose ordinate was the given value.


Note that \pstCircleAbsNode is not like \pstCurvAbsNode, it will get the two nodes with the given abscissa x.


-------------------------------------------
Here is the changes:
-------------------------------------------
diff --git a/Tools/pst-eucl/tex/pst-eucl.tex b/Tools/pst-eucl/tex/pst-eucl.tex
index df8d75a..67f0bdd 100755
--- a/Tools/pst-eucl/tex/pst-eucl.tex
+++ b/Tools/pst-eucl/tex/pst-eucl.tex
@@ -1730,6 +1730,112 @@
   \ignorespaces
 }
 %
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%% Here are some functions to operate the Coordinate
+%% of a given node.
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%
+%% \pstAbsNode - return the abscissa value of a node, which can be transformed to a new abscissa by pstricks raw code.
+%% #1 -> [input] the input node
+\def\pstAbsNode#1{%
+  tx at EcldDict begin /N@#1 GetNode pop end
+}%
+%
+% \pstOrdNode - return the ordinate value of a node, which can be transformed to a new ordinate by pstricks raw code.
+%% #1 -> [input] the input node
+\def\pstOrdNode#1{%
+  tx at EcldDict begin /N@#1 GetNode exch pop end
+}%
+%
+% \pstMoveNode - move a node by abscissa and ordinate and get the target node.
+%% #1 -> options
+%% #2 -> abscissa increment
+%% #3 -> ordinate increment
+%% #4 -> orignal node name
+%% #5 -> target node name
+\def\pstMoveNode{\@ifnextchar[\Pst at MoveNode{\Pst at MoveNode[]}}
+\def\Pst at MoveNode[#1]{%
+  \begingroup
+    \psset{#1}%
+    \Pst at MoveNode@i}
+\def\Pst at MoveNode@i(#1,#2)#3#4{%
+  \pnode(! \pstAbsNode{#3} #1 add \pstOrdNode{#3} #2 add){#4}%
+  \Pst at geonodelabel{#4}%
+  \endgroup%
+}%
+%
+% \pstLineAbsNode - create a new node on the line AB whose abscissa was the given value.
+%% #1 -> options
+%% #2 -> [input] the line point A
+%% #3 -> [input] the line point B
+%% #4 -> [input] the abscissa value
+%% #5 -> [output] the target node name
+\def\pstLineAbsNode{\@ifnextchar[\Pst at LineAbsNode{\Pst at LineAbsNode[]}}
+\def\Pst at LineAbsNode[#1]{%
+  \begingroup
+    \psset{#1}%
+    \Pst at LineAbsNode@i}
+\def\Pst at LineAbsNode@i#1#2#3#4{%
+  \pnode(#3,0){@LINEABSAUXA}\pnode(#3,1){@LINEABSAUXB}%
+  \pstInterLL{#1}{#2}{@LINEABSAUXA}{@LINEABSAUXB}{#4}%
+  \Pst at geonodelabel{#4}%
+  \endgroup%
+}%
+%
+% \pstLineOrdNode - create a new node on the line AB whose ordinate was the given value.
+%% #1 -> options
+%% #2 -> [input] the line point A
+%% #3 -> [input] the line point B
+%% #4 -> [input] the ordinate value
+%% #5 -> [output] the target node name
+\def\pstLineOrdNode{\@ifnextchar[\Pst at LineOrdNode{\Pst at LineOrdNode[]}}
+\def\Pst at LineOrdNode[#1]{%
+  \begingroup
+    \psset{#1}%
+    \Pst at LineOrdNode@i}
+\def\Pst at LineOrdNode@i#1#2#3#4{%
+  \pnode(0,#3){@LINEORDAUXA}\pnode(1,#3){@LINEORDAUXB}%
+  \pstInterLL{#1}{#2}{@LINEORDAUXA}{@LINEORDAUXB}{#4}%
+  \Pst at geonodelabel{#4}%
+  \endgroup%
+}%
+%
+% \pstCircleAbsNode - create the new nodes on the Circle O whose abscissa was the given value.
+%% #1 -> options
+%% #2 -> [input] the circle center O
+%% #3 -> [input] the circle point A or empty with Radius parameter
+%% #4 -> [input] the abscissa value
+%% #5 -> [output] the target node name
+%% #6 -> [output] the target node name
+\def\pstCircleAbsNode{\@ifnextchar[\Pst at CircleAbsNode{\Pst at CircleAbsNode[]}}
+\def\Pst at CircleAbsNode[#1]{%
+  \begingroup
+    \psset{#1}%
+    \Pst at CircleAbsNode@i}
+\def\Pst at CircleAbsNode@i#1#2#3#4#5{%
+  \pnode(#3,0){@LINEABSAUXA}\pnode(#3,1){@LINEABSAUXB}%
+  \pstInterLC{@LINEABSAUXA}{@LINEABSAUXB}{#1}{#2}{#4}{#5}%
+  \endgroup%
+}%
+%
+% \pstCircleOrdNode - create a new node on the line AB whose ordinate was the given value.
+%% #1 -> options
+%% #2 -> [input] the line point A
+%% #3 -> [input] the line point B
+%% #4 -> [input] the ordinate value
+%% #5 -> [output] the target node name
+%% #6 -> [output] the target node name
+\def\pstCircleOrdNode{\@ifnextchar[\Pst at CircleOrdNode{\Pst at CircleOrdNode[]}}
+\def\Pst at CircleOrdNode[#1]{%
+  \begingroup
+    \psset{#1}%
+    \Pst at CircleOrdNode@i}
+\def\Pst at CircleOrdNode@i#1#2#3#4#5{%
+  \pnode(0,#3){@LINEORDAUXA}\pnode(1,#3){@LINEORDAUXB}%
+  \pstInterLC{@LINEORDAUXA}{@LINEORDAUXB}{#1}{#2}{#4}{#5}%
+  \endgroup%
+}%
+%
 \catcode`\@=\PstAtCode\relax
 %
 \endinput


-----------------------------------------------
Here is the examples:
-----------------------------------------------
\documentclass[b5paper]{book}


\usepackage{picture}
\usepackage{graphicx}
\usepackage{caption}
\usepackage{pstricks}
\usepackage{auto-pst-pdf}
\usepackage{pst-eucl}
\usepackage{pst-plot}


\psset{unit=0.8cm}
\psset{linewidth=0.6pt}
\psset{dotscale=0.5}
\psset{CodeFig=false}
\psset{PointSymbol=*}


\begin{document}


\begin{pspicture}[showgrid=true](0,0)(5,5)
\def\ra{3.0}\def\rb{4.0}
\pstGeonode[PosAngle=-90](0.0,0.0){A}
\pstGeonode[PosAngle=90](! \pstAbsNode{A} 1 add \pstOrdNode{A} 2 add){B}
\pstLineAB[linecolor=blue]{A}{B}
\pstGeonode[PosAngle=90](! \pstAbsNode{A} 2 add \pstOrdNode{A} 3 add){C}
\pstLineAB[linecolor=magenta]{A}{C}
\pstMoveNode[PosAngle=-90,PointName=D_1](3,2){A}{D}
\pstLineAB[linecolor=red]{A}{D}
\pstMoveNode[PosAngle=-90,PointName=E_2](\pscalculate{sqrt(\ra*\ra+\rb*\rb)},\pscalculate{\ra*\rb/(\ra+\rb)}){A}{E}
\pstLineAB[linecolor=cyan]{A}{E}
\end{pspicture}


\begin{pspicture}[showgrid=true](-1,-1)(5,5)
\pstGeonode[PosAngle=0](0,1.5){A}
\pstGeonode[PosAngle=-90](1.0,2.0){B}
\pstLineAB[linecolor=red,nodesep=-0.5]{A}{B}
\pstLineAbsNode[PosAngle=90,PointName=C_1,PointSymbol=*]{A}{B}{2.5}{C}
\pstLineOrdNode[PosAngle=90,PointName=D_1,PointSymbol=*]{A}{B}{3.5}{D}
\pstLineAB[linecolor=blue,nodesep=-0.5]{C}{D}
\end{pspicture}


\begin{pspicture}[showgrid=true](-3,-3)(3,3)
\pstGeonode[PosAngle=-90](0,0){O}
\pstGeonode[PosAngle=0](2.5,0){A}
\pstCircleOA[linecolor=red]{O}{A}
\pstCircleAbsNode[PosAngleA=-60,PosAngleB=60,PointSymbol=*]{O}{A}{1.0}{C}{D}
\pstCircleOrdNode[PosAngleA=120,PosAngleB=60,PointSymbol=*]{O}{A}{1.0}{E}{F}
\pstLineAB[linecolor=blue,nodesep=-0.5]{C}{D}
\pstLineAB[linecolor=cyan,nodesep=-0.5]{E}{F}
\end{pspicture}


\end{document}


| |
廖雄飞
|
|
liaofei1128 at 163.com
|
签名由网易邮箱大师定制
On 8/20/2019 03:08,Herbert Voss<Herbert.Voss at fu-berlin.de> wrote:
Am 19.08.19 um 13:13 schrieb 廖雄飞:

    I add a parameter 'MarkAngleType' to mark angle with double or
triple arcs as we can do in `eukleides', can you approve this change?

I added it to pst-eucl.tex and uploaded the new version to CTAN.

Herbert
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://tug.org/pipermail/pstricks/attachments/20190927/81ceb724/attachment-0001.html>


More information about the PSTricks mailing list