diff options
Diffstat (limited to 'graphics/pgf/contrib/tzplot/tzplot.sty')
-rw-r--r-- | graphics/pgf/contrib/tzplot/tzplot.sty | 800 |
1 files changed, 682 insertions, 118 deletions
diff --git a/graphics/pgf/contrib/tzplot/tzplot.sty b/graphics/pgf/contrib/tzplot/tzplot.sty index 7b574bdc25..2016b6bbd0 100644 --- a/graphics/pgf/contrib/tzplot/tzplot.sty +++ b/graphics/pgf/contrib/tzplot/tzplot.sty @@ -11,7 +11,7 @@ %% http://www.latex-project.org/lppl.txt. %% %% ------------------------------------------------- -\ProvidesPackage{tzplot}[2022/02/28 v2.0 Plot Graphs with TikZ Abbreviations] +\ProvidesPackage{tzplot}[2022/09/28 v2.1 Plot Graphs with TikZ Abbreviations] % expl3,xparse: LPPL % tikz: LPPL and/or GNU GPL @@ -154,6 +154,26 @@ fpu, % for computation for \tzpicangle \let\tzslopeatepsilonR\tzslopeepsilonR +%% normal epsilon + +\def\tz@default@normal@epsilonL{.01} +\def\tz@default@normal@epsilonR{.01} +\def\tz@initial@normal@epsilonL{\tz@default@normal@epsilonL} +\def\tz@initial@normal@epsilonR{\tz@default@normal@epsilonL} +\NewDocumentCommand\settznormalepsilon{mg} +{% + \renewcommand\tz@initial@normal@epsilonL{#1} + \IfNoValueTF {#2} + {\renewcommand\tz@initial@normal@epsilonR{#1}} + {\renewcommand\tz@initial@normal@epsilonR{#2}} +} +\newcommand\tznormalepsilonL{\tz@initial@normal@epsilonL} +\newcommand\tznormalepsilonR{\tz@initial@normal@epsilonR} + +\let\tznormalatepsilonL\tznormalepsilonL +\let\tznormalatepsilonR\tznormalepsilonR + + %%%%% layers: defaults %% tzpath layer %% default: main @@ -209,6 +229,16 @@ fpu, % for computation for \tzpicangle \let\tzslopeatlayer\tzslopelayer \let\settzslopeatlayer\settzslopelayer +%% normal layer +\def\tz@default@normal@layer{behind} % fixed +\def\tz@initial@normal@layer{\tz@default@normal@layer} % changeable +\NewDocumentCommand\settznormallayer{m} + {\renewcommand\tz@initial@normal@layer{#1}} +\newcommand\tznormallayer{\tz@initial@normal@layer} + +\let\tznormalatlayer\tznormallayer +\let\settznormalatlayer\settznormallayer + %% angle layer \def\tz@default@angle@layer{behind} % fixed \def\tz@initial@angle@layer{\tz@default@angle@layer} % changeable @@ -445,6 +475,21 @@ fpu, % for computation for \tzpicangle \edef#3{\pgfmathresult}% } +%%%%% (ADDED 2022/04/23) +%%%%% \tzpointlength +\NewDocumentCommand\tzdistance{ r() r() m g g } +{ + \tikz@scan@one@point\pgfutil@firstofone($(#2)-(#1)$)\relax% + \pgfmathparse{veclen(\the\pgf@x,\the\pgf@y)/28.45274}% convert pt to cm + \edef#3{\pgfmathresult}% + \IfValueT { #4 } { \pgfmathparse{\the\pgf@x/28.45274}\edef#4{\pgfmathresult} } + \IfValueT { #5 } { \pgfmathparse{\the\pgf@y/28.45274}\edef#5{\pgfmathresult} } +} + +%%% NOT working correctly +% { \pgfmathparse{round(veclen(\the\pgf@x,\the\pgf@y)/28.45274}*1000)/1000 }% rounded + + %%% --- end of \tzgetxyval %%%%%% \tzgetxyval (experimental) @@ -483,8 +528,6 @@ fpu, % for computation for \tzpicangle - - %%%%% Dots %%% Node Dots %%% (basic: using minimum size) @@ -4630,7 +4673,7 @@ fpu, % for computation for \tzpicangle %% final action cases: \bool_if:NTF \g_tzplot_BEGIN_cmd_bool { %% if AtBegin_true - % define (tzCPSS) by path (WITH \l_tzplot_TEMP_opt_tl ) + % define (tzCSPS) by path (WITH \l_tzplot_TEMP_opt_tl ) \exp_last_unbraced:Nf \path \l_tzplot_TEMP_opt_tl @@ -4639,6 +4682,7 @@ fpu, % for computation for \tzpicangle ; \path (current~subpath~start) coordinate (tzCSPS) ; % all together (important) + \tl_clear:N \l_tmpa_tl % (2022/08/31 ndh) \tl_put_right:No \l_tmpa_tl { \g_tzplot_BEGIN_cmd_tl } \tl_put_right:Nn \l_tmpa_tl { (tzCSPS) -- } \tl_put_right:No \l_tmpa_tl { \l_tzplot_plot_coordinates_tl } % important @@ -4865,7 +4909,7 @@ fpu, % for computation for \tzpicangle %% final action cases: \bool_if:NTF \g_tzplotcurve_BEGIN_cmd_bool { %% if AtBegin_true - % define (tzCPSS) by path (WITH \l_tzplotcurve_TEMP_opt_tl ) + % define (tzCSPS) by path (WITH \l_tzplotcurve_TEMP_opt_tl ) \exp_last_unbraced:Nf \path \l_tzplotcurve_TEMP_opt_tl @@ -4874,6 +4918,7 @@ fpu, % for computation for \tzpicangle ; \path (current~subpath~start) coordinate (tzCSPS) ; % all together (important) + \tl_clear:N \l_tmpa_tl % (2022/08/31 ndh) \tl_put_right:No \l_tmpa_tl { \g_tzplotcurve_BEGIN_cmd_tl } \tl_put_right:Nn \l_tmpa_tl { (tzCSPS) -- } \tl_put_right:No \l_tmpa_tl { \l_tzplotcurve_plot_coordinates_tl } % important @@ -6575,22 +6620,83 @@ fpu, % for computation for \tzpicangle %%% \tzaxes -\NewDocumentCommand\tzaxes{ s O{} D<>{0,0} r() d() +G{} O{} +G{} O{} } +\NewDocumentCommand\tzaxes{ s O{} D<>{0,0} D""{axes} } { - \IfNoValueTF { #5 } + \tl_clear:N \l_tzaxes_opt_tl + \tl_clear:N \l_tzaxes_x_cmd_tl + \tl_clear:N \l_tzaxes_y_cmd_tl + \tl_clear:N \l_tzaxes_path_cmd_tl + \tl_clear:N \l_tzaxes_name_path_tl + \tl_clear:N \l_tzaxes_shift_coor_tl + + \IfBooleanTF { #1 } + { \bool_set_true:N \l_tmpa_bool } + { \bool_set_false:N \l_tmpa_bool } + + \tl_set:Nn \l_tzaxes_opt_tl { [ -> , #2 ] } + + \tl_set:Nn \l_tzaxes_name_path_tl { #4 } + \tl_set:Nn \l_tzaxes_shift_coor_tl { #3 } + + \tzaxes_check_token:n +} + +\cs_new:Npn \tzaxes_check_token:n #1 +{ + \str_if_eq:nnT { #1 } { ( } + { \tzaxes_final_actions ( } +} + +\NewDocumentCommand\tzaxes_final_actions{ r() d() +G{} O{} +G{} O{} } +{ + \IfNoValueTF { #2 } { - \draw [ -> , #2 ] - ( 0,0 |- #3 ) -- ( #4 |- #3 ) node [ right , #7 ] { #6 } ; - \draw [ -> , #2 ] - ( #3 |- 0,0 ) -- ( #3 |- #4 ) node [ above , #9 ] { #8 } ; + \tl_set:Nx \l_tzaxes_x_cmd_tl + { + ( 0,0 |- {\l_tzaxes_shift_coor_tl} ) -- ( #1 |- {\l_tzaxes_shift_coor_tl} ) + node [ right , \exp_not:n { #4 } ] { \exp_not:n { #3 } } + } + \tl_set:Nx \l_tzaxes_y_cmd_tl + { + ( {\l_tzaxes_shift_coor_tl} |- 0,0 ) -- ( {\l_tzaxes_shift_coor_tl} |- #1 ) + node [ above , \exp_not:n { #6 } ] { \exp_not:n { #5 } } + } + \tl_set:Nx \l_tzaxes_path_cmd_tl + { + ( 0,0 |- {\l_tzaxes_shift_coor_tl} ) -- ( #1 |- {\l_tzaxes_shift_coor_tl} ) + ( {\l_tzaxes_shift_coor_tl} |- 0,0 ) + -- ( {\l_tzaxes_shift_coor_tl} |- \exp_not:n { #1 } ) + } } { - \draw [ -> , #2 ] - ( #4 |- #3 ) -- ( #5 |- #3 ) node [ right , #7 ] { #6 } ; - \draw [ -> , #2 ] - ( #3 |- #4 ) -- ( #3 |- #5 ) node [ above , #9 ] { #8 } ; + \tl_set:Nx \l_tzaxes_x_cmd_tl + { + ( #1 |- {\l_tzaxes_shift_coor_tl} ) -- ( #2 |- {\l_tzaxes_shift_coor_tl} ) + node [ right , \exp_not:n { #4 } ] { \exp_not:n { #3 } } + } + \tl_set:Nx \l_tzaxes_y_cmd_tl + { + ( {\l_tzaxes_shift_coor_tl} |- #1 ) -- ( {\l_tzaxes_shift_coor_tl} |- #2 ) + node [ above , \exp_not:n { #6 } ] { \exp_not:n { #5 } } + } + \tl_set:Nx \l_tzaxes_path_cmd_tl + { + ( #1 |- {\l_tzaxes_shift_coor_tl} ) -- ( #2 |- {\l_tzaxes_shift_coor_tl} ) + ( {\l_tzaxes_shift_coor_tl} |- #1 ) -- ( {\l_tzaxes_shift_coor_tl} |- #2 ) + } } - \IfBooleanT { #1 } + + \tl_put_left:No \l_tzaxes_x_cmd_tl { \l_tzaxes_opt_tl } + \tl_put_left:No \l_tzaxes_y_cmd_tl { \l_tzaxes_opt_tl } + \tl_put_left:No \l_tzaxes_path_cmd_tl + { [ name~path = \l_tzaxes_name_path_tl ] } + + % final actions + \exp_last_unbraced:Nf \draw \l_tzaxes_x_cmd_tl ; + \exp_last_unbraced:Nf \draw \l_tzaxes_y_cmd_tl ; + \exp_last_unbraced:Nf \path \l_tzaxes_path_cmd_tl ; + + \bool_if:NT \l_tmpa_bool { \coordinate (bbxOpposite) at (current~bounding~box.north~east) ; \coordinate (bbxOrigin) at (current~bounding~box.south~west) ; @@ -6598,72 +6704,190 @@ fpu, % for computation for \tzpicangle } } +%%% -- end of \tzaxes + %%% \tzaxesL -- simpler version of \tzaxes -\NewDocumentCommand\tzaxesL{ t' O{} d<> r() r() +G{} O{} +G{} O{} } +\bool_new:N \l_tzaxesL_shift_coor_bool + +\NewDocumentCommand\tzaxesL{ t' O{} d<> D""{axesL}} { + \tl_clear:N \l_tzaxesL_opt_tl + \tl_clear:N \l_tzaxesL_x_cmd_tl + \tl_clear:N \l_tzaxesL_y_cmd_tl + \tl_clear:N \l_tzaxesL_path_cmd_tl + \tl_clear:N \l_tzaxesL_name_path_tl + \tl_clear:N \l_tzaxesL_shift_coor_tl + \IfBooleanTF { #1 } + { \bool_set_true:N \l_tmpa_bool } + { \bool_set_false:N \l_tmpa_bool } + + \tl_set:Nn \l_tzaxesL_opt_tl { [ #2 ] } + + \tl_set:Nn \l_tzaxesL_name_path_tl { #4 } + + \IfValueTF { #3 } { - \draw [ #2 ] - \IfValueTF { #3 } + \tl_set:Nn \l_tzaxesL_shift_coor_tl { #3 } + \bool_set_true:N \l_tzaxesL_shift_coor_bool + } + { + \tl_clear:N \l_tzaxesL_shift_coor_tl + \bool_set_false:N \l_tzaxesL_shift_coor_bool + } + + \tzaxesL_check_token:n +} + +\cs_new:Npn \tzaxesL_check_token:n #1 +{ + \str_if_eq:nnT { #1 } { ( } + { \tzaxesL_final_actions ( } +} + +\NewDocumentCommand\tzaxesL_final_actions{ r() r() +G{} O{} +G{} O{} } +{ + \bool_if:NTF \l_tmpa_bool + { %% swap version + % x-axis + \bool_if:NTF \l_tzaxesL_shift_coor_bool + { + \tl_set:Nx \l_tzaxesL_x_cmd_tl + { + ( [ shift = { (\l_tzaxesL_shift_coor_tl) } ] #2 ) + -- ( [ shift = { (\l_tzaxesL_shift_coor_tl) } ] #1 |- #2 ) + node [ left , \exp_not:n { #4 } ] { \exp_not:n { #3 } } + } + } + { + \tl_set:Nn \l_tzaxesL_x_cmd_tl { - ( [shift={(#3)}]#5 ) -- ( [shift={(#3)}]#4 |- #5 ) + ( #2 ) -- ( #1 |- #2 ) + node [ left , #4 ] { #3 } } + } + % y-axis + \bool_if:NTF \l_tzaxesL_shift_coor_bool + { + \tl_set:Nx \l_tzaxesL_y_cmd_tl { - ( #5 ) -- ( #4 |- #5 ) + ( [ shift = { (\l_tzaxesL_shift_coor_tl) } ] #2 ) + -- ( [ shift = { (\l_tzaxesL_shift_coor_tl) } ] #2 |- #1 ) + node [ below , \exp_not:n { #6 } ] { \exp_not:n { #5 } } } - node [ left , #7 ] { #6 } ; - \draw [ #2 ] - \IfValueTF { #3 } + } + { + \tl_set:Nn \l_tzaxesL_y_cmd_tl + { + ( #2 ) -- ( #2 |- #1 ) + node [ below , #6] { #5 } + } + } + % for path only + \bool_if:NTF \l_tzaxesL_shift_coor_bool + { + \tl_set:Nx \l_tzaxesL_path_cmd_tl { - ( [shift={(#3)}]#5 ) -- ( [shift={(#3)}]#5 |- #4 ) + ( [ shift = { (\l_tzaxesL_shift_coor_tl) } ] #2 ) + -- ( [ shift = { (\l_tzaxesL_shift_coor_tl) } ] #1 |- #2 ) + ( [ shift = { (\l_tzaxesL_shift_coor_tl) } ] #2 ) + -- ( [ shift = { (\l_tzaxesL_shift_coor_tl) } ] #2 |- #1 ) } + } + { + \tl_set:Nn \l_tzaxesL_path_cmd_tl { - ( #5 ) -- ( #5 |- #4 ) + ( #2 ) -- ( #1 |- #2 ) + ( #2 ) -- ( #2 |- #1 ) } - node [ below , #9 ] { #8 } ; + } } - { - \draw [ #2 ] - \IfValueTF { #3 } + { %% standard version + % x-axis + \bool_if:NTF \l_tzaxesL_shift_coor_bool + { + \tl_set:Nx \l_tzaxesL_x_cmd_tl { - ( [shift={(#3)}]#4 ) -- ( [shift={(#3)}]#5 |- #4 ) + ( [ shift = { (\l_tzaxesL_shift_coor_tl) } ] #1 ) + -- ( [shift = {(\l_tzaxesL_shift_coor_tl) } ] #2 |- #1 ) + node [ right , \exp_not:n { #4 } ] { \exp_not:n { #3 } } } + } + { + \tl_set:Nn \l_tzaxesL_x_cmd_tl + { + ( #1 ) -- ( #2 |- #1 ) + node [ right , #4 ] { #3 } + } + } + % y-axis + \bool_if:NTF \l_tzaxesL_shift_coor_bool + { + \tl_set:Nx \l_tzaxesL_y_cmd_tl { - ( #4 ) -- ( #5 |- #4 ) + ( [ shift = { (\l_tzaxesL_shift_coor_tl) } ] #1 ) + -- ( [ shift = { (\l_tzaxesL_shift_coor_tl) } ] #1 |- #2 ) + node [ above , \exp_not:n { #6 } ] { \exp_not:n { #5 } } } - node [ right , #7 ] { #6 } ; - \draw [ #2 ] - \IfValueTF { #3 } + } + { + \tl_set:Nn \l_tzaxesL_y_cmd_tl + { + ( #1 ) -- ( #1 |- #2 ) + node [ above , #6 ] { #5 } + } + } + % path only + \bool_if:NTF \l_tzaxesL_shift_coor_bool + { + \tl_set:Nx \l_tzaxesL_path_cmd_tl { - ( [shift={(#3)}]#4 ) -- ( [shift={(#3)}]#4 |- #5 ) + ( [ shift = { (\l_tzaxesL_shift_coor_tl) } ] #1 ) + -- ( [ shift = { (\l_tzaxesL_shift_coor_tl) } ] #2 |- #1 ) + ( [ shift = { (\l_tzaxesL_shift_coor_tl) } ] #1 ) + -- ( [ shift = { (\l_tzaxesL_shift_coor_tl) } ] #1 |- #2 ) } + } + { + \tl_set:Nn \l_tzaxesL_path_cmd_tl { - ( #4 ) -- ( #4 |- #5 ) + ( #1 ) -- ( #2 |- #1 ) + ( #1 ) -- ( #1 |- #2 ) } - node [ above , #9 ] { #8 } ; + } } + % combining options and command tokens + \tl_put_left:No \l_tzaxesL_x_cmd_tl { \l_tzaxesL_opt_tl } + \tl_put_left:No \l_tzaxesL_y_cmd_tl { \l_tzaxesL_opt_tl } + \tl_put_left:No \l_tzaxesL_path_cmd_tl + { [ name~path = \l_tzaxesL_name_path_tl ] } + % final actions + \exp_last_unbraced:Nf \draw \l_tzaxesL_x_cmd_tl ; + \exp_last_unbraced:Nf \draw \l_tzaxesL_y_cmd_tl ; + \exp_last_unbraced:Nf \path \l_tzaxesL_path_cmd_tl ; } %%% -- end of \tzaxesL + %%% \tzaxisx -\NewDocumentCommand\tzaxisx{ s O{} D<>{0} m m G{} O{} } +\NewDocumentCommand\tzaxisx{ s O{} D<>{0} D""{axisx} m m G{} O{} } { - \draw [ -> , #2 ] - ( #4 , #3 ) -- ( #5 , #3 ) node [ right , #7 ] { #6 } ; + \draw [ -> , name~path = #4 , #2 ] + ( #5 , #3 ) -- ( #6 , #3 ) node [ right , #8 ] { #7 } ; } %%% \tzaxisy -\NewDocumentCommand\tzaxisy{ s O{} D<>{0} m m G{} O{} } +\NewDocumentCommand\tzaxisy{ s O{} D<>{0} D""{axisy} m m G{} O{} } { - \draw [ -> , #2 ] - ( #3 , #4 ) -- ( #3 , #5 ) node [ above , #7 ] { #6 } ; + \draw [ -> , name~path = #4 , #2 ] + ( #3 , #5 ) -- ( #3 , #6 ) node [ above , #8 ] { #7 } ; } @@ -7392,8 +7616,6 @@ fpu, % for computation for \tzpicangle - - %%% \tznodeframe \NewDocumentCommand\tznodeframe @@ -7554,7 +7776,8 @@ fpu, % for computation for \tzpicangle } } - \tzsecantat_sub_fn:n +% \tzsecantat_sub_fn:n + \tzsecantat_final_actions } \NewDocumentCommand\tzsecantat_domain_process{ m m } @@ -7563,10 +7786,10 @@ fpu, % for computation for \tzpicangle \def\tzsecantatToVal{#2} } -\cs_new:Npn \tzsecantat_sub_fn:n -{ - \tzsecantat_final_actions -} +%\cs_new:Npn \tzsecantat_sub_fn:n +%{ +% \tzsecantat_final_actions +%} \NewDocumentCommand\tzsecantat_final_actions { +G{} O{} D<>{} } { @@ -7652,7 +7875,8 @@ fpu, % for computation for \tzpicangle } } - \tzsecant_sub_fn:n +% \tzsecant_sub_fn:n + \tzsecant_final_actions } \NewDocumentCommand\tzsecant_domain_process{ m m } @@ -7661,10 +7885,10 @@ fpu, % for computation for \tzpicangle \def\tzsecantToVal{#2} } -\cs_new:Npn \tzsecant_sub_fn:n -{ - \tzsecant_final_actions -} +%\cs_new:Npn \tzsecant_sub_fn:n +%{ +% \tzsecant_final_actions +%} \NewDocumentCommand\tzsecant_final_actions { +G{} O{} D<>{} } { @@ -7719,31 +7943,31 @@ fpu, % for computation for \tzpicangle %%% \tzslopeat (main) \NewDocumentCommand\tzslopeat - { O{} m m + { t' O{} m m >{ \SplitArgument { 1 } { , } } d() - m O{0} +G{} O{} D<>{} + m O{0} % +G{} O{} D<>{} } { % to resolve discrepancy (due to bounding box), when repeated \bool_if:nTF { - \str_if_eq_p:ee { \TANCurve } { #2 } && - \str_if_eq_p:ee { \TANWhere } { #3 } + \str_if_eq_p:ee { \TANCurve } { #3 } && + \str_if_eq_p:ee { \TANWhere } { #4 } } { \bool_set_true:N \l_tzslopeat_bbox_bool } { \bool_set_false:N \l_tzslopeat_bbox_bool } % for local change of epsilon_1, epsilon_2 - \IfValueT { #4 } + \IfValueT { #5 } { - \tzslopeat_epsilon_process #4 + \tzslopeat_epsilon_process #5 \renewcommand\tzslopeepsilonL{\tzslopeatEpsilonOne} \renewcommand\tzslopeepsilonR{\tzslopeatEpsilonTwo} } % getting ready - \coordinate (LXcoor) at ($(#3,0)-(\tzslopeepsilonL,0)$) ; - \coordinate (RXcoor) at ($(#3,0)+(\tzslopeepsilonR,0)$) ; + \coordinate (LXcoor) at ($(#4,0)-(\tzslopeepsilonL,0)$) ; + \coordinate (RXcoor) at ($(#4,0)+(\tzslopeepsilonR,0)$) ; \bool_if:NTF \l_tzslopeat_bbox_bool { @@ -7759,14 +7983,14 @@ fpu, % for computation for \tzpicangle } % find vertical X points - \path [ name~path = C-vline ] (#3,0 |- bbxBottom) -- (#3,0 |- bbxTop) ; - \path [ name~intersections = { of = #2 ~ and ~ C-vline , name = TANp } ] ; + \path [ name~path = C-vline ] (#4,0 |- bbxBottom) -- (#4,0 |- bbxTop) ; + \path [ name~intersections = { of = #3 ~ and ~ C-vline , name = TANp } ] ; \path [ name~path = L-vline ] (LXcoor |- bbxBottom) -- (LXcoor |- bbxTop) ; - \path [ name~intersections = { of = #2 ~ and ~ L-vline , name = LXcut } ] ; + \path [ name~intersections = { of = #3 ~ and ~ L-vline , name = LXcut } ] ; \path [ name~path = R-vline ] (RXcoor |- bbxBottom) -- (RXcoor |- bbxTop) ; - \path [ name~intersections = { of = #2 ~ and ~ R-vline , name = RXcut } ] ; + \path [ name~intersections = { of = #3 ~ and ~ R-vline , name = RXcut } ] ; % move to tangent point \coordinate (tzXproj) @@ -7777,32 +8001,42 @@ fpu, % for computation for \tzpicangle at ($(RXcut-1)+(TANp-1)-(tzXproj)$); % move % determine final extended points - \tl_set:Nx \l_label_pos_tl + \tl_set:Nx \l_tmpa_tl { - (RRpoint) -- (TANp-1) -- - ([turn]#6 \c_colon_str #5/2 ) coordinate (final-LL) + \IfBooleanTF { #1 } + { + (RRpoint) -- (TANp-1) -- + ([turn]-180 \c_colon_str #6/2 ) coordinate (final-LL) + } + { + (RRpoint) -- (TANp-1) -- + ([turn]#7 \c_colon_str #6/2 ) coordinate (final-LL) + } } \tl_set:Nx \l_tmpb_tl { - (LLpoint) -- (TANp-1) -- - ([turn]#6 \c_colon_str #5/2 ) coordinate (final-RR) + \IfBooleanTF { #1 } + { + (LLpoint) -- (TANp-1) -- + ([turn]-180 \c_colon_str #6/2 ) coordinate (final-RR) + } + { + (LLpoint) -- (TANp-1) -- + ([turn]#7 \c_colon_str #6/2 ) coordinate (final-RR) + } } - \exp_last_unbraced:Nf \path \l_label_pos_tl ; + \exp_last_unbraced:Nf \path \l_tmpa_tl ; \exp_last_unbraced:Nf \path \l_tmpb_tl ; \tl_set:Nn \l_tzslopeat_cmd_tl { - [ #1 ] (final-LL) -- (final-RR) + [ #2 ] (final-LL) -- (final-RR) } - \gdef\TANCurve{#2}\gdef\TANWhere{#3} - - \begin{pgfonlayer}{\tzslopelayer} - \exp_last_unbraced:Nf \draw \l_tzslopeat_cmd_tl node [ #8 ] { #7 } #9 ; - \end{pgfonlayer} - % to resolve TikZ issue: unknown path name with layer group - \exp_last_unbraced:Nf \path \l_tzslopeat_cmd_tl ; + \gdef\TANCurve{#3}\gdef\TANWhere{#4} + + \tzslopeat_final_actions } \NewDocumentCommand\tzslopeat_epsilon_process{ m m } @@ -7811,6 +8045,17 @@ fpu, % for computation for \tzpicangle \def\tzslopeatEpsilonTwo{#2} } +\NewDocumentCommand\tzslopeat_final_actions{ +G{} O{} D<>{} } +{ + % final action + \begin{pgfonlayer}{\tzslopelayer} + \exp_last_unbraced:Nf \draw \l_tzslopeat_cmd_tl node [ #2 ] { #1 } #3 ; + \end{pgfonlayer} + % to resolve TikZ issue: unknown path name with layer group + \exp_last_unbraced:Nf \path \l_tzslopeat_cmd_tl ; + +} + %%% --- end of \tzslopeat @@ -7820,31 +8065,31 @@ fpu, % for computation for \tzpicangle %%% \tzslope (main) \NewDocumentCommand\tzslope - { O{} m r() + { t' O{} m r() >{ \SplitArgument { 1 } { , } } d() - m O{0} +G{} O{} D<>{} + m O{0} % +G{} O{} D<>{} } { % to resolve discrepancy (due to bounding box), when repeated \bool_if:nTF { - \str_if_eq_p:ee { \TANCurve } { #2 } && - \str_if_eq_p:ee { \TANWhere } { #3 } + \str_if_eq_p:ee { \TANCurve } { #3 } && + \str_if_eq_p:ee { \TANWhere } { #4 } } { \bool_set_true:N \l_tzslope_bbox_bool } { \bool_set_false:N \l_tzslope_bbox_bool } % for local change of epsilon_1, epsilon_2 - \IfValueT { #4 } + \IfValueT { #5 } { - \tzslope_epsilon_process #4 + \tzslope_epsilon_process #5 \renewcommand\tzslopeepsilonL{\tzslopeEpsilonOne} \renewcommand\tzslopeepsilonR{\tzslopeEpsilonTwo} } % getting ready - \coordinate (LXcoor) at ($(#3)-(\tzslopeepsilonL,0)$) ; - \coordinate (RXcoor) at ($(#3)+(\tzslopeepsilonR,0)$) ; + \coordinate (LXcoor) at ($(#4)-(\tzslopeepsilonL,0)$) ; + \coordinate (RXcoor) at ($(#4)+(\tzslopeepsilonR,0)$) ; \bool_if:NTF \l_tzslope_bbox_bool { @@ -7860,14 +8105,14 @@ fpu, % for computation for \tzpicangle } % find vertical X points - \path [ name~path = C-vline ] (#3,0 |- bbxBottom) -- (#3,0 |- bbxTop) ; - \path [ name~intersections = { of = #2 ~ and ~ C-vline , name = TANp } ] ; + \path [ name~path = C-vline ] (#4 |- bbxBottom) -- (#4 |- bbxTop) ; + \path [ name~intersections = { of = #3 ~ and ~ C-vline , name = TANp } ] ; \path [ name~path = L-vline ] (LXcoor |- bbxBottom) -- (LXcoor |- bbxTop) ; - \path [ name~intersections = { of = #2 ~ and ~ L-vline , name = LXcut } ] ; + \path [ name~intersections = { of = #3 ~ and ~ L-vline , name = LXcut } ] ; \path [ name~path = R-vline ] (RXcoor |- bbxBottom) -- (RXcoor |- bbxTop) ; - \path [ name~intersections = { of = #2 ~ and ~ R-vline , name = RXcut } ] ; + \path [ name~intersections = { of = #3 ~ and ~ R-vline , name = RXcut } ] ; % move to tangent point \coordinate (tzXproj) @@ -7878,32 +8123,42 @@ fpu, % for computation for \tzpicangle at ($(RXcut-1)+(TANp-1)-(tzXproj)$); % move % determine final extended points - \tl_set:Nx \l_label_pos_tl + \tl_set:Nx \l_tmpa_tl { - (RRpoint) -- (TANp-1) -- - ([turn]#6 \c_colon_str #5/2 ) coordinate (final-LL) + \IfBooleanTF { #1 } + { + (RRpoint) -- (TANp-1) -- + ([turn]-180 \c_colon_str #6/2 ) coordinate (final-LL) + } + { + (RRpoint) -- (TANp-1) -- + ([turn]#7 \c_colon_str #6/2 ) coordinate (final-LL) + } } \tl_set:Nx \l_tmpb_tl { - (LLpoint) -- (TANp-1) -- - ([turn]#6 \c_colon_str #5/2 ) coordinate (final-RR) + \IfBooleanTF { #1 } + { + (LLpoint) -- (TANp-1) -- + ([turn]-180 \c_colon_str #6/2 ) coordinate (final-RR) + } + { + (LLpoint) -- (TANp-1) -- + ([turn]#7 \c_colon_str #6/2 ) coordinate (final-RR) + } } - \exp_last_unbraced:Nf \path \l_label_pos_tl ; + \exp_last_unbraced:Nf \path \l_tmpa_tl ; \exp_last_unbraced:Nf \path \l_tmpb_tl ; \tl_set:Nn \l_tzslope_cmd_tl { - [ #1 ] (final-LL) -- (final-RR) + [ #2 ] (final-LL) -- (final-RR) } - \gdef\TANCurve{#2}\gdef\TANWhere{#3} + \gdef\TANCurve{#3}\gdef\TANWhere{#4} - \begin{pgfonlayer}{\tzslopelayer} - \exp_last_unbraced:Nf \draw \l_tzslope_cmd_tl node [ #8 ] { #7 } #9 ; - \end{pgfonlayer} - % to resolve TikZ issue: unknown path name with layer group - \exp_last_unbraced:Nf \path \l_tzslope_cmd_tl ; + \tzslope_final_actions } \NewDocumentCommand\tzslope_epsilon_process{ m m } @@ -7912,10 +8167,318 @@ fpu, % for computation for \tzpicangle \def\tzslopeEpsilonTwo{#2} } +\NewDocumentCommand\tzslope_final_actions{ +G{} O{} D<>{} } +{ + % final action + \begin{pgfonlayer}{\tzslopelayer} + \exp_last_unbraced:Nf \draw \l_tzslope_cmd_tl node [ #2 ] { #1 } #3 ; + \end{pgfonlayer} + % to resolve TikZ issue: unknown path name with layer group + \exp_last_unbraced:Nf \path \l_tzslope_cmd_tl ; +} + %%% --- end of \tzslope +%%%%% Normal lines +%% No <shift coor> +%% No <shift coor> +%% No <shift coor> + +%%% \tznormalat +%% -- normal line at x + +\bool_new:N \l_tznormalat_bbox_bool + +%%% \tznormalat (main) +\NewDocumentCommand\tznormalat + { s t' O{} m m + >{ \SplitArgument { 1 } { , } } d() + m O{90} % +G{} O{} D<>{} + } +{ + % to resolve discrepancy (due to bounding box), when repeated + \bool_if:nTF + { + \str_if_eq_p:ee { \TANCurve } { #4 } && + \str_if_eq_p:ee { \TANWhere } { #5 } + } + { \bool_set_true:N \l_tznormalat_bbox_bool } + { \bool_set_false:N \l_tznormalat_bbox_bool } + + % for local change of epsilon_1, epsilon_2 + \IfValueT { #6 } + { + \tznormalat_epsilon_process #6 + \renewcommand\tznormalepsilonL{\tznormalatEpsilonOne} + \renewcommand\tznormalepsilonR{\tznormalatEpsilonTwo} + } + + % getting ready + \coordinate (LXcoor) at ($(#5,0)-(\tznormalepsilonL,0)$) ; + \coordinate (RXcoor) at ($(#5,0)+(\tznormalepsilonR,0)$) ; + + \bool_if:NTF \l_tznormalat_bbox_bool + { + \IfNodeDefined{bbxBottom}{} + { + \coordinate (bbxTop) at (current~bounding~box.north) ; + \coordinate (bbxBottom) at (current~bounding~box.south) ; + } + } + { + \coordinate (bbxTop) at (current~bounding~box.north) ; + \coordinate (bbxBottom) at (current~bounding~box.south) ; + } + + % find vertical X points + \path [ name~path = C-vline ] (#5,0 |- bbxBottom) -- (#5,0 |- bbxTop) ; + \path [ name~intersections = { of = #4 ~ and ~ C-vline , name = TANp } ] ; + + \path [ name~path = L-vline ] (LXcoor |- bbxBottom) -- (LXcoor |- bbxTop) ; + \path [ name~intersections = { of = #4 ~ and ~ L-vline , name = LXcut } ] ; + + \path [ name~path = R-vline ] (RXcoor |- bbxBottom) -- (RXcoor |- bbxTop) ; + \path [ name~intersections = { of = #4 ~ and ~ R-vline , name = RXcut } ] ; + + % move to tangent point + \coordinate (tzXproj) + at ($(LXcut-1)!(TANp-1)!(RXcut-1)$); % projection + \coordinate (LLpoint) + at ($(LXcut-1)+(TANp-1)-(tzXproj)$); % move + \coordinate (RRpoint) + at ($(RXcut-1)+(TANp-1)-(tzXproj)$); % move + + % determine final extended points + % from (final-LL) + \tl_set:Nx \l_tmpa_tl + { + \IfBooleanTF { #1 } + { + \IfBooleanTF { #2 } + { + (RRpoint) -- (TANp-1) -- + ([turn]-90 \c_colon_str #7/2 ) coordinate (final-LL) + } + { + (RRpoint) -- (TANp-1) -- + ([turn]#8 \c_colon_str #7/2 ) coordinate (final-LL) + } + } + { + (TANp-1) coordinate (final-LL) + } + } + % to (final-RR) + \tl_set:Nx \l_tmpb_tl + { + \IfBooleanTF { #1 } + { % starred : slope + \IfBooleanTF { #2 } + { % opposite direction (swap) + (LLpoint) -- (TANp-1) -- + ([turn]-90 \c_colon_str #7/2 ) coordinate (final-RR) + } + { + (LLpoint) -- (TANp-1) -- + ([turn]#8 \c_colon_str #7/2 ) coordinate (final-RR) + } + } + { % standard : normal + { + \IfBooleanTF { #2 } + { % opposite direction (swap) + (LLpoint) -- (TANp-1) -- + ([turn]-90 \c_colon_str #7/2 ) coordinate (final-RR) + } + { % standard normal + (LLpoint) -- (TANp-1) -- + ([turn]#8 \c_colon_str #7/2 ) coordinate (final-RR) + } + } + } + } + + \exp_last_unbraced:Nf \path \l_tmpa_tl ; + \exp_last_unbraced:Nf \path \l_tmpb_tl ; + + \tl_set:Nn \l_tznormalat_cmd_tl + { + [ #3 ] (final-LL) -- (final-RR) + } + + \gdef\TANCurve{#4}\gdef\TANWhere{#5} + + \tznormalat_final_actions +} + +\NewDocumentCommand\tznormalat_epsilon_process{ m m } +{ + \def\tznormalatEpsilonOne{#1} + \def\tznormalatEpsilonTwo{#2} +} + +\NewDocumentCommand\tznormalat_final_actions{ +G{} O{} D<>{} } +{ + % final action + \begin{pgfonlayer}{\tznormallayer} + \exp_last_unbraced:Nf \draw \l_tznormalat_cmd_tl node [ #2 ] { #1 } #3 ; + \end{pgfonlayer} + % to resolve TikZ issue: unknown path name with layer group + \exp_last_unbraced:Nf \path \l_tznormalat_cmd_tl ; +} + +%%% --- end of \tznormalat + + +%%% \tznormal (On) -- normal line at (x,y) + +\bool_new:N \l_tznormal_bbox_bool + +%%% \tznormal (main) +\NewDocumentCommand\tznormal + { s t' O{} m r() + >{ \SplitArgument { 1 } { , } } d() + m O{90} % +G{} O{} D<>{} + } +{ + % to resolve discrepancy (due to bounding box), when repeated + \bool_if:nTF + { + \str_if_eq_p:ee { \TANCurve } { #4 } && + \str_if_eq_p:ee { \TANWhere } { #5 } + } + { \bool_set_true:N \l_tznormal_bbox_bool } + { \bool_set_false:N \l_tznormal_bbox_bool } + + % for local change of epsilon_1, epsilon_2 + \IfValueT { #6 } + { + \tznormal_epsilon_process #6 + \renewcommand\tznormalepsilonL{\tznormalEpsilonOne} + \renewcommand\tznormalepsilonR{\tznormalEpsilonTwo} + } + + % getting ready + \coordinate (LXcoor) at ($(#5)-(\tznormalepsilonL,0)$) ; + \coordinate (RXcoor) at ($(#5)+(\tznormalepsilonR,0)$) ; + + \bool_if:NTF \l_tznormal_bbox_bool + { + \IfNodeDefined{bbxBottom}{} + { + \coordinate (bbxTop) at (current~bounding~box.north) ; + \coordinate (bbxBottom) at (current~bounding~box.south) ; + } + } + { + \coordinate (bbxTop) at (current~bounding~box.north) ; + \coordinate (bbxBottom) at (current~bounding~box.south) ; + } + + % find vertical X points + \path [ name~path = C-vline ] (#5 |- bbxBottom) -- (#5 |- bbxTop) ; + \path [ name~intersections = { of = #4 ~ and ~ C-vline , name = TANp } ] ; + + \path [ name~path = L-vline ] (LXcoor |- bbxBottom) -- (LXcoor |- bbxTop) ; + \path [ name~intersections = { of = #4 ~ and ~ L-vline , name = LXcut } ] ; + + \path [ name~path = R-vline ] (RXcoor |- bbxBottom) -- (RXcoor |- bbxTop) ; + \path [ name~intersections = { of = #4 ~ and ~ R-vline , name = RXcut } ] ; + + % move to tangent point + \coordinate (tzXproj) + at ($(LXcut-1)!(TANp-1)!(RXcut-1)$); % projection + \coordinate (LLpoint) + at ($(LXcut-1)+(TANp-1)-(tzXproj)$); % move + \coordinate (RRpoint) + at ($(RXcut-1)+(TANp-1)-(tzXproj)$); % move + + % determine final extended points + % from (final-LL) + \tl_set:Nx \l_tmpa_tl + { + \IfBooleanTF { #1 } + { + \IfBooleanTF { #2 } + { + (RRpoint) -- (TANp-1) -- + ([turn]-90 \c_colon_str #7/2 ) coordinate (final-LL) + } + { + (RRpoint) -- (TANp-1) -- + ([turn]#8 \c_colon_str #7/2 ) coordinate (final-LL) + } + } + { + (TANp-1) coordinate (final-LL) + } + } + % to (final-RR) + \tl_set:Nx \l_tmpb_tl + { + \IfBooleanTF { #1 } + { % starred : slope + \IfBooleanTF { #2 } + { % opposite direction (swap) + (LLpoint) -- (TANp-1) -- + ([turn]-90 \c_colon_str #7/2 ) coordinate (final-RR) + } + { + (LLpoint) -- (TANp-1) -- + ([turn]#8 \c_colon_str #7/2 ) coordinate (final-RR) + } + } + { % standard : normal + { + \IfBooleanTF { #2 } + { % opposite direction (swap) + (LLpoint) -- (TANp-1) -- + ([turn]-90 \c_colon_str #7/2 ) coordinate (final-RR) + } + { % standard normal + (LLpoint) -- (TANp-1) -- + ([turn]#8 \c_colon_str #7/2 ) coordinate (final-RR) + } + } + } + } + + \exp_last_unbraced:Nf \path \l_tmpa_tl ; + \exp_last_unbraced:Nf \path \l_tmpb_tl ; + + \tl_set:Nn \l_tznormal_cmd_tl + { + [ #3 ] (final-LL) -- (final-RR) + } + + \gdef\TANCurve{#4}\gdef\TANWhere{#5} + + \tznormal_final_actions +} + +\NewDocumentCommand\tznormal_epsilon_process{ m m } +{ + \def\tznormalEpsilonOne{#1} + \def\tznormalEpsilonTwo{#2} +} + +\NewDocumentCommand\tznormal_final_actions{ +G{} O{} D<>{} } +{ + % final action + \begin{pgfonlayer}{\tznormallayer} + \exp_last_unbraced:Nf \draw \l_tznormal_cmd_tl node [ #2 ] { #1 } #3 ; + \end{pgfonlayer} + % to resolve TikZ issue: unknown path name with layer group + \exp_last_unbraced:Nf \path \l_tznormal_cmd_tl ; +} + +%%% --- end of \tznormal + + + + %%%%% Tangent lines %%% \tztangentat -- tangent to a path at x @@ -8041,7 +8604,8 @@ fpu, % for computation for \tzpicangle \gdef\TANCurve{#5}\gdef\TANWhere{#6} - \tztangentat_sub_fn:n +% \tztangentat_sub_fn:n + \tztangentat_final_actions } \NewDocumentCommand\tztangentat_epsilon_process{ m m } @@ -8056,10 +8620,10 @@ fpu, % for computation for \tzpicangle \def\tztangentatToVal{#2} } -\cs_new:Npn \tztangentat_sub_fn:n -{ - \tztangentat_final_actions -} +%\cs_new:Npn \tztangentat_sub_fn:n +%{ +% \tztangentat_final_actions +%} \NewDocumentCommand\tztangentat_final_actions { +G{} O{} D<>{} } { @@ -8192,7 +8756,8 @@ fpu, % for computation for \tzpicangle \gdef\TANCurve{#5}\gdef\TANWhere{#6} - \tztangent_sub_fn:n +% \tztangent_sub_fn:n + \tztangent_final_actions } \NewDocumentCommand\tztangent_epsilon_process{ m m } @@ -8207,10 +8772,10 @@ fpu, % for computation for \tzpicangle \def\tztangentToVal{#2} } -\cs_new:Npn \tztangent_sub_fn:n -{ - \tztangent_final_actions -} +%\cs_new:Npn \tztangent_sub_fn:n +%{ +% \tztangent_final_actions +%} \NewDocumentCommand\tztangent_final_actions { +G{} O{} D<>{} } { @@ -8515,4 +9080,3 @@ fpu, % for computation for \tzpicangle \endinput - |