diff options
author | Karl Berry <karl@freefriends.org> | 2012-09-03 22:56:48 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2012-09-03 22:56:48 +0000 |
commit | 49ee169240901a3f97d82ab2e35e37cf237b3961 (patch) | |
tree | 75a8e3f59aebd5cac9c9132f0bdbd606052cde67 /Master/texmf-dist/tex/latex/hobby | |
parent | 8028e80de243e75b6cd0bdc9aec5dbed7c6be192 (diff) |
new tikz package hobby (3sep12)
git-svn-id: svn://tug.org/texlive/trunk@27584 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/hobby')
-rw-r--r-- | Master/texmf-dist/tex/latex/hobby/hobby.code.tex | 640 | ||||
-rw-r--r-- | Master/texmf-dist/tex/latex/hobby/pgflibraryhobby.code.tex | 62 | ||||
-rw-r--r-- | Master/texmf-dist/tex/latex/hobby/pml3array.sty | 286 | ||||
-rw-r--r-- | Master/texmf-dist/tex/latex/hobby/tikzlibraryhobby.code.tex | 289 |
4 files changed, 1277 insertions, 0 deletions
diff --git a/Master/texmf-dist/tex/latex/hobby/hobby.code.tex b/Master/texmf-dist/tex/latex/hobby/hobby.code.tex new file mode 100644 index 00000000000..70555c1973c --- /dev/null +++ b/Master/texmf-dist/tex/latex/hobby/hobby.code.tex @@ -0,0 +1,640 @@ +%% +%% This is file `hobby.code.tex', +%% generated with the docstrip utility. +%% +%% The original source files were: +%% +%% hobby.dtx (with options: `hobby') +%% ---------------------------------------------------------------- +%% hobby --- a TikZ/PGF library for drawing smooth(ish) curves using +%% Hobby's algorithm (implemented in LaTeX3) +%% E-mail: stacey@math.ntnu.no +%% Released under the LaTeX Project Public License v1.3c or later +%% See http://www.latex-project.org/lppl.txt +%% ---------------------------------------------------------------- +%% +\RequirePackage{expl3} +\RequirePackage{xparse} +\RequirePackage{pml3array} +\ExplSyntaxOn +\cs_generate_variant:Nn \fp_set:Nn {Nx} +\fp_new:N \g_hobby_parama_fp +\fp_new:N \g_hobby_paramb_fp +\fp_new:N \g_hobby_paramc_fp + +\fp_gset:Nn \g_hobby_parama_fp {2^.5} + +\fp_gset:Nn \g_hobby_paramb_fp {1/16} + +\fp_gset:Nn \g_hobby_paramc_fp {(3-5^.5)/2} +\bool_new:N \l_hobby_closed_bool +\bool_new:N \l_hobby_disjoint_bool +\array_new:N \l_hobby_points_array +\array_new:N \l_hobby_points_x_array +\array_new:N \l_hobby_points_y_array +\array_new:N \l_hobby_angles_array +\array_new:N \l_hobby_distances_array +\array_new:N \l_hobby_tension_out_array +\array_new:N \l_hobby_tension_in_array +\array_new:N \l_hobby_matrix_a_array +\array_new:N \l_hobby_matrix_b_array +\array_new:N \l_hobby_matrix_c_array +\array_new:N \l_hobby_matrix_d_array +\array_new:N \l_hobby_vector_u_array +\array_new:N \l_hobby_excess_angle_array +\array_new:N \l_hobby_psi_array +\array_new:N \l_hobby_theta_array +\array_new:N \l_hobby_phi_array +\array_new:N \l_hobby_sigma_array +\array_new:N \l_hobby_rho_array +\array_new:N \l_hobby_controla_array +\array_new:N \l_hobby_controlb_array +\fp_new:N \l_hobby_matrix_v_fp +\fp_new:N \l_hobby_tempa_fp +\fp_new:N \l_hobby_tempb_fp +\fp_new:N \l_hobby_tempc_fp +\fp_new:N \l_hobby_tempd_fp +\fp_new:N \l_hobby_temps_fp +\fp_new:N \l_hobby_in_curl_fp +\fp_set:Nn \l_hobby_in_curl_fp {1} +\fp_new:N \l_hobby_out_curl_fp +\fp_set:Nn \l_hobby_out_curl_fp {1} +\fp_new:N \l_hobby_in_angle_fp +\fp_set_eq:NN \l_hobby_in_angle_fp \c_undefined_fp +\fp_new:N \l_hobby_out_angle_fp +\fp_set_eq:NN \l_hobby_out_angle_fp \c_undefined_fp +\int_new:N \l_hobby_npoints_int +\keys_define:nn {hobby / read in all} { + x .fp_set:N = \l_hobby_tempa_fp, + y .fp_set:N = \l_hobby_tempb_fp, + tension~out .fp_set:N = \l_hobby_tempc_fp, + tension~in .fp_set:N = \l_hobby_tempd_fp, + excess~angle .fp_set:N = \l_hobby_temps_fp, + tension .meta:n = { tension~out=#1, tension~in=#1 }, + tension~out .default:n = 1, + tension~in .default:n = 1, + excess~angle .default:n = 0, + in~angle .fp_set:N = \l_hobby_in_angle_fp, + out~angle .fp_set:N = \l_hobby_out_angle_fp, + in~curl .fp_set:N = \l_hobby_in_curl_fp, + out~curl .fp_set:N = \l_hobby_out_curl_fp, + closed .bool_set:N = \l_hobby_closed_bool, + closed .default:n = true, + disjoint .bool_set:N = \l_hobby_disjoint_bool, + disjoint .default:n = true, +} +\keys_define:nn { hobby / read in params} { + in~angle .fp_set:N = \l_hobby_in_angle_fp, + out~angle .fp_set:N = \l_hobby_out_angle_fp, + in~curl .fp_set:N = \l_hobby_in_curl_fp, + out~curl .fp_set:N = \l_hobby_out_curl_fp, + closed .bool_set:N = \l_hobby_closed_bool, + closed .default:n = true, + disjoint .bool_set:N = \l_hobby_disjoint_bool, + disjoint .default:n = true, +} +\cs_set:Nn \hobby_distangle:n { + \fp_set:Nn \l_hobby_tempa_fp { + (\array_get:Nn \l_hobby_points_x_array {#1 + 1}) + - (\array_get:Nn \l_hobby_points_x_array {#1})} + + \fp_set:Nn \l_hobby_tempb_fp { + (\array_get:Nn \l_hobby_points_y_array {#1 + 1}) + - (\array_get:Nn \l_hobby_points_y_array {#1})} + + \fp_atantwo:NNN \l_hobby_tempc_fp \l_hobby_tempb_fp \l_hobby_tempa_fp + \fp_veclen:NVV \l_hobby_tempd_fp \l_hobby_tempa_fp \l_hobby_tempb_fp + + \array_push:Nx \l_hobby_angles_array {\fp_to_tl:N \l_hobby_tempc_fp} + \array_push:Nx \l_hobby_distances_array {\fp_to_tl:N \l_hobby_tempd_fp} + } +\cs_new:Nn \fp_atantwo:NNN { + \pgfmathparse{rad(atan2(\fp_use:N #3,\fp_use:N #2))} + \exp_args:NNo \fp_set:Nn #1 {\pgfmathresult} +} +\cs_new:Nn \fp_veclen:Nnn { + \fp_set:Nn #1 {((#2)^2 + (#3)^2)^.5} +} +\cs_generate_variant:Nn \fp_veclen:Nnn {NVV} +\cs_new:Nn \hobby_ctrllen:Nnn { + \fp_set:Nn #1 {(2 - \g_hobby_parama_fp + * ( sin(#2) - \g_hobby_paramb_fp * sin(#3) ) + * ( sin(#3) - \g_hobby_paramb_fp * sin(#2) ) + * ( cos(#2) - cos(#3) ) ) + / ( 1 + (1 - \g_hobby_paramc_fp) * cos(#3) + \g_hobby_paramc_fp * cos(#2))} +} +\cs_generate_variant:Nn \hobby_ctrllen:Nnn {NVV} +\cs_new_protected:Npn \hobby_append_point_copy:n #1 + { + \hobby_append_point_copy_aux:Nn \l_hobby_points_array {#1} + \hobby_append_point_copy_aux:Nn \l_hobby_points_x_array {#1} + \hobby_append_point_copy_aux:Nn \l_hobby_points_y_array {#1} + \hobby_append_point_copy_aux:Nn \l_hobby_tension_in_array {#1} + \hobby_append_point_copy_aux:Nn \l_hobby_tension_out_array {#1} + \hobby_append_point_copy_aux:Nn \l_hobby_excess_angle_array {#1} + } +\cs_new_protected:Npn \hobby_append_point_copy_aux:Nn #1#2 + { \array_push:Nx #1 { \array_get:Nn #1 {#2} } } +\cs_new:Nn \hobby_genpath: +{ +\bool_if:NT \l_hobby_closed_bool { + \fp_compare:nTF {(\array_get:Nn \l_hobby_points_x_array {0}) + = + (\array_top:N \l_hobby_points_x_array)} + { + \fp_compare:nF { + \array_get:Nn \l_hobby_points_y_array {0} + = + \array_top:N \l_hobby_points_y_array + } + { + \hobby_append_point_copy:n {0} + } + } + { + \hobby_append_point_copy:n {0} + } + \hobby_append_point_copy:n {1} +} +\int_set:Nn \l_hobby_npoints_int {\array_length:N \l_hobby_points_y_array} + +\prg_stepwise_function:nnnN {0} {1} {\l_hobby_npoints_int - 1} \hobby_distangle:n + \prg_stepwise_inline:nnnn {1} {1} {\l_hobby_npoints_int - 1} { + \fp_set:Nx \l_hobby_tempa_fp { + \array_get:Nn \l_hobby_angles_array {##1} + - \array_get:Nn \l_hobby_angles_array {##1 - 1}} + \fp_compare:nTF {\l_hobby_tempa_fp > \c_pi_fp } + { + \fp_sub:Nn \l_hobby_tempa_fp {2 * \c_pi_fp} + } + {} + \fp_compare:nTF {\l_hobby_tempa_fp < -\c_pi_fp } + { + \fp_add:Nn \l_hobby_tempa_fp {2 * \c_pi_fp} + } + {} +\array_get:NnNTF \l_hobby_excess_angle_array {##1} \l_tmpa_tl { + \fp_add:Nn \l_hobby_tempa_fp {2 * \c_pi_fp * \l_tmpa_tl} + }{} + \array_put:Nnx \l_hobby_psi_array {##1}{\fp_to_tl:N \l_hobby_tempa_fp} + } + \prg_stepwise_inline:nnnn {1} {1} {\l_hobby_npoints_int - 1} { + \array_put:Nnx \l_hobby_matrix_a_array {##1} {\fp_to_tl:n { + \array_get:Nn \l_hobby_tension_in_array {##1}^2 + * \array_get:Nn \l_hobby_distances_array {##1} + * \array_get:Nn \l_hobby_tension_in_array {##1 + 1} + }} +} + \prg_stepwise_inline:nnnn {1} {1} {\l_hobby_npoints_int - 1} { + + \array_put:Nnx \l_hobby_matrix_b_array {##1} {\fp_to_tl:n +{(3 * (\array_get:Nn \l_hobby_tension_in_array {##1 + 1}) - 1) * + (\array_get:Nn \l_hobby_tension_out_array {##1})^2 * +(\array_get:Nn \l_hobby_tension_out_array {##1 - 1}) +* ( \array_get:Nn \l_hobby_distances_array {##1 - 1}) ++ +(3 * (\array_get:Nn \l_hobby_tension_out_array {##1 - 1}) - 1) +* (\array_get:Nn \l_hobby_tension_in_array {##1})^2 +* (\array_get:Nn \l_hobby_tension_in_array {##1 + 1}) +* (\array_get:Nn \l_hobby_distances_array {##1})} +} +} + \prg_stepwise_inline:nnnn {1} {1} {\l_hobby_npoints_int - 2} { + + \array_put:Nnx \l_hobby_matrix_c_array {##1} {\fp_to_tl:n +{(\array_get:Nn \l_hobby_tension_in_array {##1})^2 +* (\array_get:Nn \l_hobby_tension_in_array {##1 - 1}) +* (\array_get:Nn \l_hobby_distances_array {##1 - 1}) +}} + +} + \prg_stepwise_inline:nnnn {1} {1} {\l_hobby_npoints_int - 2} { + + \array_put:Nnx \l_hobby_matrix_d_array {##1} {\fp_to_tl:n +{ +- (\array_get:Nn \l_hobby_psi_array {##1 + 1}) +* (\array_get:Nn \l_hobby_tension_out_array {##1})^2 +* (\array_get:Nn \l_hobby_tension_out_array {##1 - 1}) +* (\array_get:Nn \l_hobby_distances_array {##1 - 1}) +- (3 * (\array_get:Nn \l_hobby_tension_out_array {##1 - 1}) - 1) +* (\array_get:Nn \l_hobby_psi_array {##1}) +* (\array_get:Nn \l_hobby_tension_in_array {##1})^2 +* (\array_get:Nn \l_hobby_tension_in_array {##1 + 1}) +* (\array_get:Nn \l_hobby_distances_array {##1}) +} +} +} +\bool_if:NTF \l_hobby_closed_bool { +\array_put:Nnx \l_hobby_matrix_c_array {0} {\fp_to_tl:n { +- (\array_get:Nn \l_hobby_distances_array {\l_hobby_npoints_int - 2}) +* (\array_get:Nn \l_hobby_tension_out_array {\l_hobby_npoints_int - 2}) +* (\array_get:Nn \l_hobby_tension_out_array {\l_hobby_npoints_int - 1})^2 +}} + +\array_put:Nnn \l_hobby_matrix_b_array {0} {1} +\array_put:Nnn \l_hobby_matrix_d_array {0} {0} + +\array_put:Nnx \l_hobby_matrix_b_array {\l_hobby_npoints_int - 1} {\fp_to_tl:n { +(\array_get:Nn \l_hobby_matrix_b_array {\l_hobby_npoints_int - 1}) ++ 1 +}} + + \array_put:Nnx \l_hobby_matrix_d_array {\l_hobby_npoints_int - 1} {\fp_to_tl:n { +- (\array_get:Nn \l_hobby_psi_array {1}) +* (\array_get:Nn \l_hobby_tension_out_array {\l_hobby_npoints_int -1})^2 +* (\array_get:Nn \l_hobby_tension_out_array {\l_hobby_npoints_int -2}) +* (\array_get:Nn \l_hobby_distances_array {\l_hobby_npoints_int - 2}) +- (3 * (\array_get:Nn \l_hobby_tension_out_array {\l_hobby_npoints_int - 2}) - 1) +* (\array_get:Nn \l_hobby_psi_array {\l_hobby_npoints_int - 1}) +* (\array_get:Nn \l_hobby_tension_in_array {\l_hobby_npoints_int - 1})^2 +* (\array_get:Nn \l_hobby_tension_in_array {\l_hobby_npoints_int}) +* (\array_get:Nn \l_hobby_distances_array {\l_hobby_npoints_int -1}) +} +} + \array_put:Nnn \l_hobby_vector_u_array {0} {1} +\array_put:Nnn \l_hobby_vector_u_array {\l_hobby_npoints_int - 1} {1} + \prg_stepwise_inline:nnnn {1} {1} {\l_hobby_npoints_int - 2} { + \array_put:Nnn \l_hobby_vector_u_array {##1} {0} + } +\fp_set:Nn \l_hobby_matrix_v_fp { +(\array_get:Nn \l_hobby_tension_out_array {\l_hobby_npoints_int -1})^2 +* (\array_get:Nn \l_hobby_tension_out_array {\l_hobby_npoints_int -2}) +* (\array_get:Nn \l_hobby_distances_array {\l_hobby_npoints_int -2}) +} +} +{ +\fp_if_undefined:NTF \l_hobby_out_angle_fp +{ + \array_put:Nnx \l_hobby_matrix_b_array {0} {\fp_to_tl:n { + (\array_get:Nn \l_hobby_tension_in_array {1})^3 +* \l_hobby_in_curl_fp ++ +(3 * (\array_get:Nn \l_hobby_tension_in_array {1}) - 1) +* (\array_get:Nn \l_hobby_tension_out_array {0})^3 +}} + + \array_put:Nnx \l_hobby_matrix_c_array {0} {\fp_to_tl:n { + (\array_get:Nn \l_hobby_tension_out_array {0})^3 ++ +(3 * (\array_get:Nn \l_hobby_tension_out_array {0}) - 1) +* (\array_get:Nn \l_hobby_tension_in_array {1})^3 +* \l_hobby_in_curl_fp +}} + + \array_put:Nnx \l_hobby_matrix_d_array {0} {\fp_to_tl:n { +-( (\array_get:Nn \l_hobby_tension_out_array {0})^3 ++ +(3 * (\array_get:Nn \l_hobby_tension_out_array {0}) - 1) +* (\array_get:Nn \l_hobby_tension_in_array {1})^3 +* \l_hobby_in_curl_fp) +* (\array_get:Nn \l_hobby_psi_array {1}) +}} + +} +{ + \array_put:Nnn \l_hobby_matrix_b_array {0} {1} + \array_put:Nnn \l_hobby_matrix_c_array {0} {0} + \fp_set:Nn \l_hobby_tempa_fp { \l_hobby_out_angle_fp + - \array_get:Nn \l_hobby_angles_array {0} } + \fp_compare:nT {\l_hobby_tempa_fp > \c_pi_fp } + { + \fp_sub:Nn \l_hobby_tempa_fp {2 * \c_pi_fp} + } + \fp_compare:nT {\l_hobby_tempa_fp < -\c_pi_fp } + { + \fp_add:Nn \l_hobby_tempa_fp {2 * \c_pi_fp} + } + \array_put:Nnx \l_hobby_matrix_d_array {0} {\fp_to_tl:N \l_hobby_tempa_fp} +} +\fp_if_undefined:NTF \l_hobby_in_angle_fp +{ + + \array_put:Nnx \l_hobby_matrix_b_array {\l_hobby_npoints_int - 1} {\fp_to_tl:n { +\array_get:Nn \l_hobby_matrix_b_array {\l_hobby_npoints_int - 1} +- (\array_get:Nn \l_hobby_tension_out_array {\l_hobby_npoints_int - 1})^2 +* (\array_get:Nn \l_hobby_tension_out_array {\l_hobby_npoints_int - 2}) +* (\array_get:Nn \l_hobby_distances_array {\l_hobby_npoints_int - 2}) +* +((3 * (\array_get:Nn \l_hobby_tension_in_array {\l_hobby_npoints_int} ) - 1) +* (\array_get:Nn \l_hobby_tension_out_array {\l_hobby_npoints_int - 1})^3 \l_tmpa_tl +* \l_hobby_out_curl_fp ++ +(\array_get:Nn \l_hobby_tension_in_array {\l_hobby_npoints_int })^3) +/ +((3 * (\array_get:Nn \l_hobby_tension_out_array {\l_hobby_npoints_int -2}) - 1) +* (\array_get:Nn \l_hobby_tension_in_array {\l_hobby_npoints_int})^3 ++ +( \array_get:Nn \l_hobby_tension_out_array {\l_hobby_npoints_int - 1})^3 +* \l_hobby_out_curl_fp) +}} + + \array_put:Nnx \l_hobby_matrix_d_array {\l_hobby_npoints_int - 1} {\fp_to_tl:n { +- (3 * (\array_get:Nn \l_hobby_tension_out_array {\l_hobby_npoints_int - 2}) - 1) +* (\array_get:Nn \l_hobby_psi_array {\l_hobby_npoints_int - 1}) +* (\array_get:Nn \l_hobby_tension_in_array {\l_hobby_npoints_int - 1})^2 +* (\array_get:Nn \l_hobby_tension_in_array {\l_hobby_npoints_int}) +* (\array_get:Nn \l_hobby_distances_array {\l_hobby_npoints_int - 1}) +}} + +} +{ + \fp_set:Nn \l_hobby_tempa_fp { - \l_hobby_in_angle_fp + \c_pi_fp ++ (\array_get:Nn \l_hobby_angles_array {\l_hobby_npoints_int - 1})} + \fp_compare:nT {\l_hobby_tempa_fp > \c_pi_fp } + { + \fp_sub:Nn \l_hobby_tempa_fp {2 * \c_pi_fp} + } + \fp_compare:nT {\l_hobby_tempa_fp < -\c_pi_fp } + { + \fp_add:Nn \l_hobby_tempa_fp {2 * \c_pi_fp} + } + + \array_put:Nnx \l_hobby_phi_array {\l_hobby_npoints_int} + {\fp_to_tl:N \l_hobby_tempa_fp} + + \array_put:Nnx \l_hobby_matrix_d_array {\l_hobby_npoints_int - 1} {\fp_to_tl:n { + \l_hobby_tempa_fp + * (\array_get:Nn \l_hobby_tension_out_array {\l_hobby_npoints_int - 1})^2 +* (\array_get:Nn \l_hobby_tension_out_array {\l_hobby_npoints_int - 2}) +* (\array_get:Nn \l_hobby_distances_array {\l_hobby_npoints_int - 2}) +- +(3 * ( \array_get:Nn \l_hobby_tension_out_array {\l_hobby_npoints_int - 2}) - 1) +* (\array_get:Nn \l_hobby_psi_array {\l_hobby_npoints_int - 1}) +* (\array_get:Nn \l_hobby_tension_in_array {\l_hobby_npoints_int - 1})^2 +* (\array_get:Nn \l_hobby_tension_in_array {\l_hobby_npoints_int}) +* (\array_get:Nn \l_hobby_distances_array {\l_hobby_npoints_int - 1}) }} +} +} +\prg_stepwise_inline:nnnn {1} {1} {\l_hobby_npoints_int - 1} { + + \array_put:Nnx \l_hobby_matrix_b_array {##1} {\fp_to_tl:n { + (\array_get:Nn \l_hobby_matrix_b_array {##1 - 1}) +* (\array_get:Nn \l_hobby_matrix_b_array {##1}) +- +(\array_get:Nn \l_hobby_matrix_c_array {##1 - 1}) +* (\array_get:Nn \l_hobby_matrix_a_array {##1}) +}} + \int_compare:nT {##1 < \l_hobby_npoints_int - 1} { + + \array_put:Nnx \l_hobby_matrix_c_array {##1} {\fp_to_tl:n { +(\array_get:Nn \l_hobby_matrix_b_array {##1 - 1}) + * (\array_get:Nn \l_hobby_matrix_c_array {##1}) +}} + } + + \array_put:Nnx \l_hobby_matrix_d_array {##1} {\fp_to_tl:n { +(\array_get:Nn \l_hobby_matrix_b_array {##1 - 1}) + * (\array_get:Nn \l_hobby_matrix_d_array {##1}) +- + (\array_get:Nn \l_hobby_matrix_d_array {##1 - 1}) + * (\array_get:Nn \l_hobby_matrix_a_array {##1}) +}} + \bool_if:NT \l_hobby_closed_bool { + \array_put:Nnx \l_hobby_vector_u_array {##1} {\fp_to_tl:n { +(\array_get:Nn \l_hobby_matrix_b_array {##1 - 1}) +* (\array_get:Nn \l_hobby_vector_u_array {##1}) +- +(\array_get:Nn \l_hobby_vector_u_array {##1 - 1}) +* (\array_get:Nn \l_hobby_matrix_a_array {##1}) +}} +} +} + \array_put:Nnx \l_hobby_theta_array {\l_hobby_npoints_int - 1} {\fp_to_tl:n { +(\array_get:Nn \l_hobby_matrix_d_array {\l_hobby_npoints_int - 1}) +/ (\array_get:Nn \l_hobby_matrix_b_array {\l_hobby_npoints_int - 1}) +}} +\bool_if:NT \l_hobby_closed_bool { + \array_put:Nnx \l_hobby_vector_u_array {\l_hobby_npoints_int - 1} {\fp_to_tl:n { + (\array_get:Nn \l_hobby_vector_u_array {\l_hobby_npoints_int - 1}) +/ (\array_get:Nn \l_hobby_matrix_b_array {\l_hobby_npoints_int - 1}) +}} +} +\prg_stepwise_inline:nnnn {\l_hobby_npoints_int - 2} {-1} {0} { + + \array_put:Nnx \l_hobby_theta_array {##1} {\fp_to_tl:n { +( (\array_get:Nn \l_hobby_matrix_d_array {##1}) + - (\array_get:Nn \l_hobby_theta_array {##1 + 1}) + * (\array_get:Nn \l_hobby_matrix_c_array {##1}) +) / (\array_get:Nn \l_hobby_matrix_b_array {##1}) +}} +} +\bool_if:NT \l_hobby_closed_bool { +\prg_stepwise_inline:nnnn {\l_hobby_npoints_int - 2} {-1} {0} { + \array_put:Nnx \l_hobby_vector_u_array {##1} {\fp_to_tl:n +{ + ((\array_get:Nn \l_hobby_vector_u_array {##1}) + - (\array_get:Nn \l_hobby_vector_u_array {##1 + 1}) + * (\array_get:Nn \l_hobby_matrix_c_array {##1}) + ) / (\array_get:Nn \l_hobby_matrix_b_array {##1}) +}} +} + +\fp_set:Nn \l_hobby_tempb_fp { +((\array_get:Nn \l_hobby_theta_array {1}) +* \l_hobby_matrix_v_fp +- (\array_get:Nn \l_hobby_theta_array {\l_hobby_npoints_int - 1}) +) / ( +(\array_get:Nn \l_hobby_vector_u_array {1}) +* \l_hobby_matrix_v_fp +- (\array_get:Nn \l_hobby_vector_u_array {\l_hobby_npoints_int - 1}) ++ 1 +)} + +\prg_stepwise_inline:nnnn {0} {1} {\l_hobby_npoints_int - 1} { + + \array_put:Nnx \l_hobby_theta_array {##1} {\fp_to_tl:n { + (\array_get:Nn \l_hobby_theta_array {##1}) + - (\array_get:Nn \l_hobby_vector_u_array {##1}) + * \l_hobby_tempb_fp +}} +} +} +\prg_stepwise_inline:nnnn {1} {1} {\l_hobby_npoints_int - 1} { + + \array_put:Nnx \l_hobby_phi_array {##1} {\fp_to_tl:n { + - (\array_get:Nn \l_hobby_psi_array {##1}) + - (\array_get:Nn \l_hobby_theta_array {##1}) + }} + } +\bool_if:NTF \l_hobby_closed_bool { + \int_decr:N \l_hobby_npoints_int +}{ +\fp_if_undefined:NT \l_hobby_in_angle_fp +{ + \array_put:Nnx \l_hobby_phi_array {\l_hobby_npoints_int} {\fp_to_tl:n { +((3 * (\array_get:Nn \l_hobby_tension_in_array {\l_hobby_npoints_int}) - 1) +* (\array_get:Nn \l_hobby_tension_out_array {\l_hobby_npoints_int - 1})^3 +* \l_hobby_out_curl_fp ++ +(\array_get:Nn \l_hobby_tension_in_array {\l_hobby_npoints_int })^3) +/ +((3 * (\array_get:Nn \l_hobby_tension_out_array {\l_hobby_npoints_int -2}) - 1) +* (\array_get:Nn \l_hobby_tension_in_array {\l_hobby_npoints_int})^3 \l_tmpa_tl ++ +(\array_get:Nn \l_hobby_tension_out_array {\l_hobby_npoints_int - 1})^3 +* \l_hobby_out_curl_fp) +* +(\array_get:Nn \l_hobby_theta_array {\l_hobby_npoints_int -1}) +}} +} +} +\prg_stepwise_inline:nnnn {0} {1} {\l_hobby_npoints_int - 1} { + + \fp_set:Nn \l_hobby_tempa_fp {\array_get:Nn \l_hobby_theta_array {##1}} + + \fp_set:Nn \l_hobby_tempb_fp {\array_get:Nn \l_hobby_phi_array {##1 + 1}} + + \hobby_ctrllen:NVV \l_hobby_temps_fp \l_hobby_tempa_fp \l_hobby_tempb_fp + + \array_put:Nnx \l_hobby_sigma_array {##1 + 1} {\fp_to_tl:N \l_hobby_temps_fp} + + \hobby_ctrllen:NVV \l_hobby_temps_fp \l_hobby_tempb_fp \l_hobby_tempa_fp + + \array_put:Nnx \l_hobby_rho_array {##1} {\fp_to_tl:N \l_hobby_temps_fp} + + } +\prg_stepwise_inline:nnnn {0} {1} {\l_hobby_npoints_int - 1} { + +\array_put:Nnx \l_hobby_controla_array {##1 + 1} {x = \fp_eval:n { +(\array_get:Nn \l_hobby_points_x_array {##1}) ++ + (\array_get:Nn \l_hobby_distances_array {##1}) * + (\array_get:Nn \l_hobby_rho_array {##1}) * +cos ( (\array_get:Nn \l_hobby_angles_array {##1}) ++ + (\array_get:Nn \l_hobby_theta_array {##1})) +/3 +}, y = \fp_eval:n { +( \array_get:Nn \l_hobby_points_y_array {##1}) + + (\array_get:Nn \l_hobby_distances_array {##1}) * + (\array_get:Nn \l_hobby_rho_array {##1}) * +sin ( (\array_get:Nn \l_hobby_angles_array {##1}) ++ + (\array_get:Nn \l_hobby_theta_array {##1})) +/3 +} +} +} + +\prg_stepwise_inline:nnnn {1} {1} {\l_hobby_npoints_int} { + \array_put:Nnx \l_hobby_controlb_array {##1} { + x = \fp_eval:n {\array_get:Nn \l_hobby_points_x_array {##1} +- (\array_get:Nn \l_hobby_distances_array {##1 - 1}) +* (\array_get:Nn \l_hobby_sigma_array {##1}) +* cos((\array_get:Nn \l_hobby_angles_array {##1 - 1}) +- (\array_get:Nn \l_hobby_phi_array {##1}))/3 +}, y = \fp_eval:n { + (\array_get:Nn \l_hobby_points_y_array {##1}) +- (\array_get:Nn \l_hobby_distances_array {##1 - 1}) +* (\array_get:Nn \l_hobby_sigma_array {##1}) +* sin((\array_get:Nn \l_hobby_angles_array {##1 - 1}) +- (\array_get:Nn \l_hobby_phi_array {##1}))/3 +} } + } +} +\NewDocumentCommand \hobbyinit {m m m} { +\hobby_set_cmds:nnn#1#2#3 +\array_clear:N \l_hobby_points_array +\array_clear:N \l_hobby_points_x_array +\array_clear:N \l_hobby_points_y_array +\array_clear:N \l_hobby_angles_array +\array_clear:N \l_hobby_distances_array +\array_clear:N \l_hobby_tension_out_array +\array_clear:N \l_hobby_tension_in_array +\array_clear:N \l_hobby_excess_angle_array +\array_clear:N \l_hobby_matrix_a_array +\array_clear:N \l_hobby_matrix_b_array +\array_clear:N \l_hobby_matrix_c_array +\array_clear:N \l_hobby_matrix_d_array +\array_clear:N \l_hobby_vector_u_array +\array_clear:N \l_hobby_psi_array +\array_clear:N \l_hobby_theta_array +\array_clear:N \l_hobby_phi_array +\array_clear:N \l_hobby_sigma_array +\array_clear:N \l_hobby_rho_array +\array_clear:N \l_hobby_controla_array +\array_clear:N \l_hobby_controlb_array +\bool_set_false:N \l_hobby_closed_bool +\bool_set_false:N \l_hobby_disjoint_bool + + \int_set:Nn \l_hobby_npoints_int {-1} + \fp_set_eq:NN \l_hobby_in_angle_fp \c_undefined_fp + \fp_set_eq:NN \l_hobby_out_angle_fp \c_undefined_fp + \fp_set_eq:NN \l_hobby_in_curl_fp \c_one_fp + \fp_set_eq:NN \l_hobby_out_curl_fp \c_one_fp +} +\NewDocumentCommand \hobbyaddpoint { m } { + \keys_set:nn { hobby/read in all } + { + tension~out, + tension~in, + excess~angle, + #1 + } + \array_push:Nx \l_hobby_tension_out_array {\fp_to_tl:N \l_hobby_tempc_fp} + \array_push:Nx \l_hobby_tension_in_array {\fp_to_tl:N \l_hobby_tempd_fp} + \array_push:Nx \l_hobby_excess_angle_array {\fp_to_tl:N \l_hobby_temps_fp} + \array_push:Nx \l_hobby_points_array { + x = \fp_use:N \l_hobby_tempa_fp, + y = \fp_use:N \l_hobby_tempb_fp } + \array_push:Nx \l_hobby_points_x_array {\fp_to_tl:N \l_hobby_tempa_fp} + \array_push:Nx \l_hobby_points_y_array {\fp_to_tl:N \l_hobby_tempb_fp} +} +\NewDocumentCommand \hobbysetparams { m } { + \keys_set:nn { hobby / read in params } + { + #1 + } +} +\cs_new:Nn \hobby_set_cmds:nnn { + \cs_set_eq:NN \hobby_moveto:n #1 + \cs_set_eq:NN \hobby_curveto:nnn #2 + \cs_set_eq:NN \hobby_close:n #3 +} +\tl_new:N \l_tmpc_tl +\NewDocumentCommand \hobbygenpath { } { + \hobby_genpath: + \bool_if:NT \l_hobby_disjoint_bool { + \array_get:NnN \l_hobby_points_array {0} \l_tmpa_tl + \exp_args:No \hobby_moveto:n {\l_tmpa_tl} + } + \prg_stepwise_inline:nnnn {1} {1} {\l_hobby_npoints_int} { + \array_get:NnN \l_hobby_controla_array {##1} \l_tmpa_tl + \array_get:NnN \l_hobby_controlb_array {##1} \l_tmpb_tl + \array_get:NnN \l_hobby_points_array {##1} \l_tmpc_tl + \exp_args:Nooo \hobby_curveto:nnn {\l_tmpa_tl} {\l_tmpb_tl} {\l_tmpc_tl} +} + \bool_if:NT \l_hobby_closed_bool { + \array_get:NnN \l_hobby_points_array {0} \l_tmpa_tl + \exp_args:No \hobby_close:n {\l_tmpa_tl} + } +} +\ExplSyntaxOff +%% +%% Copyright (C) 2012 by Andrew Stacey <stacey@math.ntnu.no> +%% +%% This file may be distributed and/or modified under the conditions +%% of the LaTeX Project Public License, either version 1.3 of this +%% license or (at your option) any later version. +%% The latest version of this license is in: +%% +%% http://www.latex-project.org/lppl.txt +%% +%% and version 1.3 or later is part of all distributions of LaTeX +%% version 2005/12/01 or later. +%% +%% This work is "maintained" (as per LPPL maintenance status) by +%% Andrew Stacey. +%% +%% This work consists of the files hobby.dtx +%% hobby_doc.tex +%% and the derived files hobby.code.tex +%% pgflibraryhobby.code.tex +%% tikzlibraryhobby.code.tex +%% hobby.ins +%% hobby.pdf +%% hobby_doc.pdf +%% README.txt +%% +%% +%% End of file `hobby.code.tex'. diff --git a/Master/texmf-dist/tex/latex/hobby/pgflibraryhobby.code.tex b/Master/texmf-dist/tex/latex/hobby/pgflibraryhobby.code.tex new file mode 100644 index 00000000000..3e4e609dae9 --- /dev/null +++ b/Master/texmf-dist/tex/latex/hobby/pgflibraryhobby.code.tex @@ -0,0 +1,62 @@ +%% +%% This is file `pgflibraryhobby.code.tex', +%% generated with the docstrip utility. +%% +%% The original source files were: +%% +%% hobby.dtx (with options: `pgflibrary') +%% ---------------------------------------------------------------- +%% hobby --- a TikZ/PGF library for drawing smooth(ish) curves using +%% Hobby's algorithm (implemented in LaTeX3) +%% E-mail: stacey@math.ntnu.no +%% Released under the LaTeX Project Public License v1.3c or later +%% See http://www.latex-project.org/lppl.txt +%% ---------------------------------------------------------------- +%% +\input{hobby.code.tex} +\pgfkeys{ + /pgf/hobby/.is family, + /pgf/hobby/.cd, + x/.code={\pgf@x=#1cm}, + y/.code={\pgf@y=#1cm}, +} +\def\hobby@curveto#1#2#3{% + \pgfpathcurveto{\hobby@topgf{#1}}{\hobby@topgf{#2}}{\hobby@topgf{#3}}% +} +\def\hobby@moveto#1{% + \pgfpathmoveto{\hobby@topgf{#1}}% +} +\def\hobby@topgf#1{% + \pgfqkeys{/pgf/hobby}{#1}% +} +\def\hobby@close#1{% + \pgfpathclose +} +%% +%% Copyright (C) 2012 by Andrew Stacey <stacey@math.ntnu.no> +%% +%% This file may be distributed and/or modified under the conditions +%% of the LaTeX Project Public License, either version 1.3 of this +%% license or (at your option) any later version. +%% The latest version of this license is in: +%% +%% http://www.latex-project.org/lppl.txt +%% +%% and version 1.3 or later is part of all distributions of LaTeX +%% version 2005/12/01 or later. +%% +%% This work is "maintained" (as per LPPL maintenance status) by +%% Andrew Stacey. +%% +%% This work consists of the files hobby.dtx +%% hobby_doc.tex +%% and the derived files hobby.code.tex +%% pgflibraryhobby.code.tex +%% tikzlibraryhobby.code.tex +%% hobby.ins +%% hobby.pdf +%% hobby_doc.pdf +%% README.txt +%% +%% +%% End of file `pgflibraryhobby.code.tex'. diff --git a/Master/texmf-dist/tex/latex/hobby/pml3array.sty b/Master/texmf-dist/tex/latex/hobby/pml3array.sty new file mode 100644 index 00000000000..e704e4c41ab --- /dev/null +++ b/Master/texmf-dist/tex/latex/hobby/pml3array.sty @@ -0,0 +1,286 @@ +%% +%% This is file `pml3array.sty', +%% generated with the docstrip utility. +%% +%% The original source files were: +%% +%% hobby.dtx (with options: `array') +%% ---------------------------------------------------------------- +%% hobby --- a TikZ/PGF library for drawing smooth(ish) curves using +%% Hobby's algorithm (implemented in LaTeX3) +%% E-mail: stacey@math.ntnu.no +%% Released under the LaTeX Project Public License v1.3c or later +%% See http://www.latex-project.org/lppl.txt +%% ---------------------------------------------------------------- +%% +\RequirePackage{expl3} +\ExplSyntaxOn +\tl_new:N \l_array_tmp_tl +\tl_new:N \l_array_show_tl +\int_new:N \l_array_base_int +\int_new:N \l_array_top_int +\int_new:N \l_array_tmp_int +\int_new:N \g_array_base_int +\int_set:Nn \g_array_base_int {0} +\cs_new:Npn \array_adjust_ends:Nn #1#2 { + \prop_get:NnNTF #1 {base} \l_tmpa_tl + { + \int_compare:nNnTF {\l_tmpa_tl} > {#2} + { + \prop_put:Nnx #1 {base} {\int_eval:n {#2}} + } + {} + } + { + \prop_put:Nnx #1 {base} {\int_eval:n {#2}} + } + \prop_get:NnNTF #1 {top} \l_tmpa_tl + { + \int_compare:nNnTF {\l_tmpa_tl} < {#2} + { + \prop_put:Nnx #1 {top} {\int_eval:n {#2}} + } + {} + } + { + \prop_put:Nnx #1 {top} {\int_eval:n {#2}} + } +} +\cs_new:Npn \array_put:Nnn #1#2#3 { + \exp_args:NNx \prop_put:Nnn #1 {\int_eval:n {#2}} {#3} + \array_adjust_ends:Nn #1{#2} +} +\cs_generate_variant:Nn \array_put:Nnn {Nnx} +\cs_new:Npn \array_get:NnN #1#2#3 { + \exp_args:NNx \prop_get:NnN #1 {\int_eval:n {#2}} #3 +} +\cs_new:Npn \array_get:Nn #1#2 { + \exp_args:NNf \prop_get:Nn #1 { \int_eval:n {#2} } +} +\cs_new:Npn \array_get:NnNTF #1#2#3#4#5 { + \exp_args:NNx \prop_get:NnNTF #1 {\int_eval:n {#2}} #3 {#4}{#5} +} +\cs_new_eq:NN \array_if_empty:NTF \prop_if_empty:NTF +\cs_new_eq:NN \array_new:N \prop_new:N +\cs_new_eq:NN \array_clear:N \prop_clear:N +\cs_new:Npn \array_map_function:NN #1#2 +{ + \array_if_empty:NTF #1 {} { + \prop_get:NnNTF #1 {base} \l_array_tmp_tl { + \int_set:Nn \l_array_base_int {\l_array_tmp_tl} + }{ + \int_set:Nn \l_array_base_int {0} + } + \prop_get:NnNTF #1 {top} \l_array_tmp_tl { + \int_set:Nn \l_array_top_int {\l_array_tmp_tl} + }{ + \int_set:Nn \l_array_top_int {0} + } + \prg_stepwise_inline:nnnn {\l_array_base_int} {1} {\l_array_top_int} { + \array_get:NnN #1 {##1} \l_array_tmp_tl + \exp_args:Nno #2 {##1} \l_array_tmp_tl +} +} {} +} +\cs_generate_variant:Nn \array_map_function:NN { Nc } +\cs_generate_variant:Nn \array_map_function:NN { c , cc } +\cs_new:Npn \array_reverse_map_function:NN #1#2 +{ + \array_if_empty:NTF #1 {} { + \prop_get:NnNTF #1 {base} \l_array_tmp_tl { + \int_set:Nn \l_array_base_int {\l_array_tmp_tl} + }{ + \int_set:Nn \l_array_base_int {0} + } + \prop_get:NnNTF #1 {top} \l_array_tmp_tl { + \int_set:Nn \l_array_top_int {\l_array_tmp_tl} + }{ + \int_set:Nn \l_array_top_int {0} + } + \prg_stepwise_inline:nnnn {\l_array_top_int} {-1} {\l_array_base_int} { + \array_get:NnN #1 {##1} \l_array_tmp_tl + \exp_args:Nno #2 {##1} \l_array_tmp_tl +} +} {} +} +\cs_generate_variant:Nn \array_reverse_map_function:NN { Nc } +\cs_generate_variant:Nn \array_reverse_map_function:NN { c , cc } +\cs_new_protected:Npn \array_map_inline:Nn #1#2 + { + \int_gincr:N \g_prg_map_int + \cs_gset:cpn { array_map_inline_ \int_use:N \g_prg_map_int :nn } + ##1##2 {#2} + \exp_args:NNc \array_map_function:NN #1 + { array_map_inline_ \int_use:N \g_prg_map_int :nn } + \prg_break_point:n { \int_gdecr:N \g_prg_map_int } + } +\cs_generate_variant:Nn \array_map_inline:Nn { c } +\cs_new_protected:Npn \array_reverse_map_inline:Nn #1#2 + { + \int_gincr:N \g_prg_map_int + \cs_gset:cpn { array_map_inline_ \int_use:N \g_prg_map_int :nn } + ##1##2 {#2} + \exp_args:NNc \array_reverse_map_function:NN #1 + { array_map_inline_ \int_use:N \g_prg_map_int :nn } + \prg_break_point:n { \int_gdecr:N \g_prg_map_int } + } +\cs_generate_variant:Nn \array_reverse_map_inline:Nn { c } +\msg_new:nnn { array } { show } + { + The~array~\token_to_str:N #1~ + \array_if_empty:NTF #1 + { is~empty } + { contains~the~items~(without~outer~braces): } + } +\cs_new_protected:Npn \array_show:N #1 + { + \tl_clear:N \l_array_show_tl + \array_map_function:NN #1 \array_show_aux:nn + \__msg_show_variable:Nnx + #1 + { array } + { \l_array_show_tl } + } + +\cs_new_protected:Npn \array_show_aux:nn #1#2 +{ + \tl_if_eq:NNTF {#2} {\q_no_value} {} + { + \tl_put_right:No \l_array_show_tl {\__msg_show_item:nn {#1}{#2}} + } +} +\cs_generate_variant:Nn \array_show:N { c } +\cs_new_protected:Npn \array_push:Nn #1#2 +{ + \prop_get:NnNTF #1 {top} \l_array_tmp_tl + { + \int_set:Nn \l_array_tmp_int {\l_array_tmp_tl} + \int_incr:N \l_array_tmp_int + \array_put:Nnn #1 {\l_array_tmp_int} {#2} + } + { + \array_put:Nnn #1 {\g_array_base_int} {#2} + } +} +\cs_generate_variant:Nn \array_push:Nn {Nx} +\cs_new_protected:Npn \array_unshift:Nn #1#2 +{ + \prop_get:NnNTF #1 {base} \l_array_tmp_tl + { + \int_set:Nn \l_array_tmp_int {\l_array_tmp_tl} + \int_decr:N \l_array_tmp_int + \array_put:Nnn #1 {\l_array_tmp_int} {#2} + } + { + \array_put:Nnn #1 {\g_array_base_int} {#2} + } +} +\cs_generate_variant:Nn \array_unshift:Nn {Nx} +\cs_new_protected:Npn \array_pop:NN #1#2 +{ + \prop_get:NnN #1 {top} \l_array_tmp_tl + \array_get:NnN #1 {\l_array_tmp_tl} #2 + \array_del:Nn #1 {\l_array_tmp_tl} +} +\cs_new_protected:Npn \array_shift:NN #1#2 +{ + \prop_get:NnN #1 {base} \l_array_tmp_tl + \array_get:NnN #1 {\l_array_tmp_tl} #2 + \array_del:Nn #1 {\l_array_tmp_tl} +} +\cs_new_protected:Npn \array_top:NN #1#2 +{ + \prop_get:NnN #1 {top} \l_array_tmp_tl + \array_get:NnN #1 {\l_array_tmp_tl} #2 +} +\cs_new_protected:Npn \array_base:NN #1#2 +{ + \prop_get:NnN #1 {base} \l_array_tmp_tl + \array_get:NnN #1 {\l_array_tmp_tl} #2 +} +\cs_new:Npn \array_top:N #1 +{ + \array_get:Nn #1 {\prop_get:Nn #1 {top}} +} +\cs_new:Npn \array_base:N #1 +{ + \array_get:Nn #1 {\prop_get:Nn #1 {base}} +} +\cs_new_protected:Npn \array_del:Nn #1#2 +{ + \exp_args:NNx \prop_del:Nn #1 {\int_eval:n {#2}} + \int_set:Nn \l_array_tmp_int {0} + \array_map_inline:Nn #1 { + \tl_if_eq:NNTF {##2} {\q_no_value} {} + { + \int_incr:N \l_array_tmp_int + } + } + \int_compare:nNnTF {\l_array_tmp_int} = {0} + { + \prop_clear:N #1 + } + { + \prop_get:NnN #1 {top} \l_array_tmp_tl + \int_compare:nNnTF {#2} = {\l_array_tmp_tl} { + \prop_get:NnN #1 {base} \l_array_tmp_tl + \int_set:Nn \l_array_tmp_int {\l_array_tmp_tl} + \array_map_inline:Nn #1 { + \tl_if_eq:NNTF {##2} {\q_no_value} {} + { + \int_compare:nNnTF {\l_array_tmp_int} < {##1} { + \int_set:Nn \l_array_tmp_int {##1} + }{} + } + } + \prop_put:Nnx #1 {top} {\int_use:N \l_array_tmp_int} + }{} + \prop_get:NnN #1 {base} \l_array_tmp_tl + \int_compare:nNnTF {#2} = {\l_array_tmp_tl} { +p \prop_get:NnN #1 {top} \l_array_tmp_tl + \int_set:Nn \l_array_tmp_int {\l_array_tmp_tl} + \array_map_inline:Nn #1 { + \tl_if_eq:NNTF {##2} {\q_no_value} {} + { + \int_compare:nNnTF {\l_array_tmp_int} > {##1} { + \int_set:Nn \l_array_tmp_int {##1} + }{} + } + } + \prop_put:Nnx #1 {base} {\int_use:N \l_array_tmp_int} + }{} + } +} +\cs_new_protected:Npn \array_length:N #1 +{ + \int_eval:n {\prop_get:Nn #1 {top} - \prop_get:Nn #1 {base}} +} +\ExplSyntaxOff +%% +%% Copyright (C) 2012 by Andrew Stacey <stacey@math.ntnu.no> +%% +%% This file may be distributed and/or modified under the conditions +%% of the LaTeX Project Public License, either version 1.3 of this +%% license or (at your option) any later version. +%% The latest version of this license is in: +%% +%% http://www.latex-project.org/lppl.txt +%% +%% and version 1.3 or later is part of all distributions of LaTeX +%% version 2005/12/01 or later. +%% +%% This work is "maintained" (as per LPPL maintenance status) by +%% Andrew Stacey. +%% +%% This work consists of the files hobby.dtx +%% hobby_doc.tex +%% and the derived files hobby.code.tex +%% pgflibraryhobby.code.tex +%% tikzlibraryhobby.code.tex +%% hobby.ins +%% hobby.pdf +%% hobby_doc.pdf +%% README.txt +%% +%% +%% End of file `pml3array.sty'. diff --git a/Master/texmf-dist/tex/latex/hobby/tikzlibraryhobby.code.tex b/Master/texmf-dist/tex/latex/hobby/tikzlibraryhobby.code.tex new file mode 100644 index 00000000000..9214dfd6dd3 --- /dev/null +++ b/Master/texmf-dist/tex/latex/hobby/tikzlibraryhobby.code.tex @@ -0,0 +1,289 @@ +%% +%% This is file `tikzlibraryhobby.code.tex', +%% generated with the docstrip utility. +%% +%% The original source files were: +%% +%% hobby.dtx (with options: `tikzlibrary') +%% ---------------------------------------------------------------- +%% hobby --- a TikZ/PGF library for drawing smooth(ish) curves using +%% Hobby's algorithm (implemented in LaTeX3) +%% E-mail: stacey@math.ntnu.no +%% Released under the LaTeX Project Public License v1.3c or later +%% See http://www.latex-project.org/lppl.txt +%% ---------------------------------------------------------------- +%% +\usepgflibrary{hobby} +\let\hobby@opts=\pgfutil@empty +\tikzset{ + curve through/.style={ + to path={ + \pgfextra{ + \expandafter\curvethrough\expandafter[\hobby@opts]{% + (\tikztostart) .. #1 .. (\tikztotarget)% + } + } + } + }, + tension in/.code = {}, + tension out/.code = {}, + tension/.code = {}, + excess angle/.code = {}, + closed/.code = {% + \expandafter\def\expandafter\hobby@opts\expandafter{\hobby@opts% + closed=#1,disjoint=#1}% + }, + closed/.default = true, + in angle/.code = {% + \pgfmathparse{#1*pi/180}% + \edef\@temp{ in angle=\pgfmathresult,}% + \expandafter\expandafter\expandafter% + \def% + \expandafter\expandafter\expandafter% + \hobby@opts% + \expandafter\expandafter\expandafter% + {\expandafter\hobby@opts\@temp}% + }, + out angle/.code = {% + \pgfmathparse{#1*pi/180}% + \edef\@temp{ out angle=\pgfmathresult,}% + \expandafter\expandafter\expandafter% + \def% + \expandafter\expandafter\expandafter% + \hobby@opts% + \expandafter\expandafter\expandafter% + {\expandafter\hobby@opts\@temp}% + }, + in curl/.code = {% + \expandafter\def\expandafter\hobby@opts\expandafter{\hobby@opts in curl=#1,}% + }, + out curl/.code = {% + \expandafter\def\expandafter\hobby@opts\expandafter{\hobby@opts out curl=#1,}% + }, + use Hobby shortcut/.code={% + \let\tikz@curveto@auto=\hobby@curveto@auto + } +} +\newcommand\curvethrough[2][]{% + \hobbyinit\hobby@moveto\hobby@curveto\hobby@close + \hobbysetparams{#1}% + \hobby@processpts{#2}% +} +\newcommand\hobby@processpts[1]{% + \pgfutil@in@{..}{#1}% + \ifpgfutil@in@% + \hobby@getonepoint #1 \relax + \let\hobby@next=\hobby@processpts + \else + \def\hobby@pt{#1}% + \def\hobby@rest{}% + \let\hobby@next=\hobbygenpath + \fi + \let\tikz@scan@point@options=\pgfutil@empty + \expandafter\tikz@scan@one@point\expandafter\pgfutil@firstofone\hobby@pt\relax + \pgfmathsetmacro\hobby@x{\the\pgf@x/1cm}% + \pgfmathsetmacro\hobby@y{\the\pgf@y/1cm}% + \expandafter\hobbyaddpoint\expandafter{\tikz@scan@point@options,% + x = \hobby@x, y = \hobby@y}% + \expandafter\hobby@next\expandafter{\hobby@rest}% +} +\def\hobby@getonepoint#1..#2\relax{% + \def\hobby@pt{#1}% + \def\hobby@rest{#2}% +} +\def\hobby@curveto@auto{% + \hobbyinit\pgfutil@gobble\hobby@curveto\hobby@close + \pgfmathsetmacro\hobby@x{\the\tikz@lastx/1cm}% + \pgfmathsetmacro\hobby@y{\the\tikz@lasty/1cm}% + \pgfutil@ifundefined{tikz@scan@point@options}{% + \hobbyaddpoint{x = \hobby@x, y = \hobby@y}% + }{% + \expandafter\hobbyaddpoint\expandafter{\tikz@scan@point@options,% + x = \hobby@x, y = \hobby@y}% + }% + \let\tikz@scan@point@options=\pgfutil@empty + \tikz@scan@one@point\hobby@addfromtikz} +\def\hobby@addfromtikz#1{% + #1% + \tikz@make@last@position{#1}% + \pgfmathsetmacro\hobby@x{\the\pgf@x/1cm}% + \pgfmathsetmacro\hobby@y{\the\pgf@y/1cm}% + \expandafter\hobbyaddpoint\expandafter{\tikz@scan@point@options,% + x = \hobby@x, y = \hobby@y}% + \hobby@donext} +\def\hobby@donext{% + \pgfutil@ifnextchar.% + {\hobby@curveto@check}% + {\hobby@finish@auto}}% +\def\hobby@curveto@check..{% + \pgfutil@ifnextchar c% + {\hobby@maybefinish@auto}% + {\hobby@curveto@continue}}% +\def\hobby@maybefinish@auto c{% + \pgfutil@ifnextchar o% + {\hobby@finish@auto .. c}% + {\hobby@closeandfinish@auto}} +\def\hobby@closeandfinish@auto ycle{% + \hobbysetparams{closed=true,disjoint=true}% + \hobby@finish@auto% +} +\def\hobby@curveto@continue{% + \let\tikz@scan@point@options=\pgfutil@empty + \tikz@scan@one@point\hobby@addfromtikz} +\def\hobby@finish@auto{% + \hobbygenpath + \tikz@scan@next@command% +} +\tikzset{ + quick curve through/.style={% + to path={% + \pgfextra{% + \tikz@scan@one@point\pgfutil@firstofone(\tikztostart)% + \edef\hobby@qpoints{\noexpand\pgfqpoint{\the\pgf@x}{\the\pgf@y}}% + \def\hobby@qpointa{}% + \def\hobby@quick@path{}% + \def\hobby@angle{}% + \tikz@scan@one@point\hobby@quickfirst #1 (\tikztotarget)\relax + } + \hobby@quick@path + } + } +} +\pgfmathsetmacro\hobby@sf{10cm} +\def\hobby@quickfirst#1{% + #1% + \edef\hobby@qpointa{\noexpand\pgfqpoint{\the\pgf@x}{\the\pgf@y}}% + \pgfutil@ifnextchar\relax{% + \edef\hobby@quick@path{ -- (\the\pgf@x,\the\pgf@y)}% + }{% + \tikz@scan@one@point\hobby@quick}} +\def\hobby@quick#1{% + #1% + \pgf@xb=\pgf@x + \pgf@yb=\pgf@y + \hobby@qpointa + \pgf@xa=\pgf@x + \pgf@ya=\pgf@y + \advance\pgf@xb by -\pgf@xa + \advance\pgf@yb by -\pgf@ya + \pgfmathsetmacro\hobby@done{sqrt((\pgf@xb/\hobby@sf)^2 + (\pgf@yb/\hobby@sf)^2)}% + \pgfmathsetmacro\hobby@omegaone{rad(atan2(\pgf@xb,\pgf@yb))}% + \hobby@qpoints + \advance\pgf@xa by -\pgf@x + \advance\pgf@ya by -\pgf@y + \pgfmathsetmacro\hobby@dzero{sqrt((\pgf@xa/\hobby@sf)^2 + (\pgf@ya/\hobby@sf)^2)}% + \pgfmathsetmacro\hobby@omegazero{rad(atan2(\pgf@xa,\pgf@ya))}% + \pgfmathsetmacro\hobby@psi{\hobby@omegaone - \hobby@omegazero}% + \pgfmathsetmacro\hobby@psi{\hobby@psi > pi ? \hobby@psi - 2*pi : \hobby@psi}% + \pgfmathsetmacro\hobby@psi{\hobby@psi < -pi ? \hobby@psi + 2*pi : \hobby@psi}% + \ifx\hobby@angle\pgfutil@empty + \pgfmathsetmacro\hobby@thetaone{-\hobby@psi * \hobby@done% +/(\hobby@done + \hobby@dzero)}% + \pgfmathsetmacro\hobby@thetazero{-\hobby@psi - \hobby@thetaone}% + \let\hobby@phione=\hobby@thetazero + \let\hobby@phitwo=\hobby@thetaone + \else + \let\hobby@thetazero=\hobby@angle + \pgfmathsetmacro\hobby@thetaone{% + -(2 * \hobby@psi + \hobby@thetazero) * \hobby@done% + / (2 * \hobby@done + \hobby@dzero)}% + \pgfmathsetmacro\hobby@phione{-\hobby@psi - \hobby@thetaone}% + \let\hobby@phitwo=\hobby@thetaone + \fi + \let\hobby@angle=\hobby@thetaone + \pgfmathsetmacro\hobby@alpha{% + sqrt(2) * (sin(\hobby@thetazero r) - 1/16 * sin(\hobby@phione r))% +* (sin(\hobby@phione r) - 1/16 * sin(\hobby@thetazero r))% + * (cos(\hobby@thetazero r) - cos(\hobby@phione r))}% + \pgfmathsetmacro\hobby@rho{% + (2 + \hobby@alpha)/(1 + (1 - (3 - sqrt(5))/2)% + * cos(\hobby@thetazero r) + (3 - sqrt(5))/2 * cos(\hobby@phione r))}% + \pgfmathsetmacro\hobby@sigma{% + (2 - \hobby@alpha)/(1 + (1 - (3 - sqrt(5))/2)% + * cos(\hobby@phione r) + (3 - sqrt(5))/2 * cos(\hobby@thetazero r))}% + \hobby@qpoints + \pgf@xa=\pgf@x + \pgf@ya=\pgf@y + \pgfmathsetlength\pgf@xa{% + \pgf@xa + \hobby@dzero * \hobby@rho% + * cos((\hobby@thetazero + \hobby@omegazero) r)/3*\hobby@sf}% + \pgfmathsetlength\pgf@ya{% + \pgf@ya + \hobby@dzero * \hobby@rho% + * sin((\hobby@thetazero + \hobby@omegazero) r)/3*\hobby@sf}% + \hobby@qpointa + \pgf@xb=\pgf@x + \pgf@yb=\pgf@y + \pgfmathsetlength\pgf@xb{% + \pgf@xb - \hobby@dzero * \hobby@sigma% + * cos((-\hobby@phione + \hobby@omegazero) r)/3*\hobby@sf}% + \pgfmathsetlength\pgf@yb{% + \pgf@yb - \hobby@dzero * \hobby@sigma% + * sin((-\hobby@phione + \hobby@omegazero) r)/3*\hobby@sf}% + \hobby@qpointa + \edef\hobby@quick@path{\hobby@quick@path .. controls% + (\the\pgf@xa,\the\pgf@ya) and (\the\pgf@xb,\the\pgf@yb) .. (\the\pgf@x,\the\pgf@y) }% + \let\hobby@qpoints=\hobby@qpointa + #1 + \edef\hobby@qpointa{\noexpand\pgfqpoint{\the\pgf@x}{\the\pgf@y}}% + \pgfutil@ifnextchar\relax{% + \pgfmathsetmacro\hobby@alpha{% + sqrt(2) * (sin(\hobby@thetaone r) - 1/16 * sin(\hobby@phitwo r))% + * (sin(\hobby@phitwo r) - 1/16 * sin(\hobby@thetaone r))% + * (cos(\hobby@thetaone r) - cos(\hobby@phitwo r))}% + \pgfmathsetmacro\hobby@rho{% + (2 + \hobby@alpha)/(1 + (1 - (3 - sqrt(5))/2)% + * cos(\hobby@thetaone r) + (3 - sqrt(5))/2 * cos(\hobby@phitwo r))}% + \pgfmathsetmacro\hobby@sigma{% + (2 - \hobby@alpha)/(1 + (1 - (3 - sqrt(5))/2)% + * cos(\hobby@phitwo r) + (3 - sqrt(5))/2 * cos(\hobby@thetaone r))}% + \hobby@qpoints + \pgf@xa=\pgf@x + \pgf@ya=\pgf@y + \pgfmathsetlength\pgf@xa{% + \pgf@xa + \hobby@done * \hobby@rho% + * cos((\hobby@thetaone + \hobby@omegaone) r)/3*\hobby@sf}% + \pgfmathsetlength\pgf@ya{% + \pgf@ya + \hobby@done * \hobby@rho% + * sin((\hobby@thetaone + \hobby@omegaone) r)/3*\hobby@sf}% + \hobby@qpointa + \pgf@xb=\pgf@x + \pgf@yb=\pgf@y + \pgfmathsetlength\pgf@xb{% + \pgf@xb - \hobby@done * \hobby@sigma% + * cos((-\hobby@phitwo + \hobby@omegaone) r)/3*\hobby@sf}% + \pgfmathsetlength\pgf@yb{% + \pgf@yb - \hobby@done * \hobby@sigma% + * sin((-\hobby@phitwo + \hobby@omegaone) r)/3*\hobby@sf}% + \hobby@qpointa + \edef\hobby@quick@path{\hobby@quick@path .. controls% + (\the\pgf@xa,\the\pgf@ya) and (\the\pgf@xb,\the\pgf@yb) .. (\the\pgf@x,\the\pgf@y) }% +}{% +\tikz@scan@one@point\hobby@quick}} +%% +%% Copyright (C) 2012 by Andrew Stacey <stacey@math.ntnu.no> +%% +%% This file may be distributed and/or modified under the conditions +%% of the LaTeX Project Public License, either version 1.3 of this +%% license or (at your option) any later version. +%% The latest version of this license is in: +%% +%% http://www.latex-project.org/lppl.txt +%% +%% and version 1.3 or later is part of all distributions of LaTeX +%% version 2005/12/01 or later. +%% +%% This work is "maintained" (as per LPPL maintenance status) by +%% Andrew Stacey. +%% +%% This work consists of the files hobby.dtx +%% hobby_doc.tex +%% and the derived files hobby.code.tex +%% pgflibraryhobby.code.tex +%% tikzlibraryhobby.code.tex +%% hobby.ins +%% hobby.pdf +%% hobby_doc.pdf +%% README.txt +%% +%% +%% End of file `tikzlibraryhobby.code.tex'. |