summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/latex/l3kernel/l3coffins.dtx
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2019-08-14 20:53:00 +0000
committerKarl Berry <karl@freefriends.org>2019-08-14 20:53:00 +0000
commit5630d54170b9d8a8aabf2ad7e84c92840b86160d (patch)
treec673565b6e75f784e64eceff6bfcf5775b905ef0 /Master/texmf-dist/source/latex/l3kernel/l3coffins.dtx
parentbce9fed0de3adbb0f82fc4ac9171b618921fb14d (diff)
l3kernel (14aug19)
git-svn-id: svn://tug.org/texlive/trunk@51881 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/source/latex/l3kernel/l3coffins.dtx')
-rw-r--r--Master/texmf-dist/source/latex/l3kernel/l3coffins.dtx172
1 files changed, 71 insertions, 101 deletions
diff --git a/Master/texmf-dist/source/latex/l3kernel/l3coffins.dtx b/Master/texmf-dist/source/latex/l3kernel/l3coffins.dtx
index 963d61b7ae7..aca74650f23 100644
--- a/Master/texmf-dist/source/latex/l3kernel/l3coffins.dtx
+++ b/Master/texmf-dist/source/latex/l3kernel/l3coffins.dtx
@@ -43,7 +43,7 @@
% }^^A
% }
%
-% \date{Released 2019-07-25}
+% \date{Released 2019-08-14}
%
% \maketitle
%
@@ -464,12 +464,12 @@
% \end{macrocode}
% \end{variable}
%
-% \begin{variable}{\l_@@_slope_x_fp}
-% \begin{variable}{\l_@@_slope_y_fp}
+% \begin{variable}{\l_@@_slope_A_fp}
+% \begin{variable}{\l_@@_slope_B_fp}
% Used for calculations of intersections.
% \begin{macrocode}
-\fp_new:N \l_@@_slope_x_fp
-\fp_new:N \l_@@_slope_y_fp
+\fp_new:N \l_@@_slope_A_fp
+\fp_new:N \l_@@_slope_B_fp
% \end{macrocode}
% \end{variable}
% \end{variable}
@@ -1123,7 +1123,7 @@
%
% \begin{macro}{\@@_calculate_intersection:Nnn}
% \begin{macro}{\@@_calculate_intersection:nnnnnnnn}
-% \begin{macro}{\@@_calculate_intersection_aux:nnnnnN}
+% \begin{macro}{\@@_calculate_intersection:nnnnnn}
% The lead off in finding intersections is to recover the two poles
% and then hand off to the auxiliary for the actual calculation. There
% may of course not be an intersection, for which an error trap is
@@ -1159,7 +1159,7 @@
\cs_new_protected:Npn \@@_calculate_intersection:nnnnnnnn
#1#2#3#4#5#6#7#8
{
- \dim_compare:nNnTF {#3} = { \c_zero_dim }
+ \dim_compare:nNnTF {#3} = \c_zero_dim
% \end{macrocode}
% The case where the first pole is vertical. So the $x$-component
% of the interaction is at $a$. There is then a test on the
@@ -1173,17 +1173,23 @@
% The second pole may still be horizontal, in which case the
% $y$-component of the intersection is $b'$. If not,
% \[
-% y = \frac{d'}{c'} \left ( x - a' \right ) + b'
+% y = \frac{d'}{c'} \left ( a - a' \right ) + b'
% \]
-% with the $x$-component already known to be |#1|. This calculation
-% is done as a generalised auxiliary.
+% with the $x$-component already known to be |#1|.
% \begin{macrocode}
{
- \dim_compare:nNnTF {#8} = \c_zero_dim
- { \dim_set:Nn \l_@@_y_dim {#6} }
+ \dim_set:Nn \l_@@_y_dim
{
- \@@_calculate_intersection_aux:nnnnnN
- {#1} {#5} {#6} {#7} {#8} \l_@@_y_dim
+ \dim_compare:nNnTF {#8} = \c_zero_dim
+ {#6}
+ {
+ \fp_to_dim:n
+ {
+ ( \dim_to_fp:n {#8} / \dim_to_fp:n {#7} )
+ * ( \dim_to_fp:n {#1} - \dim_to_fp:n {#5} )
+ + \dim_to_fp:n {#6}
+ }
+ }
}
}
}
@@ -1199,117 +1205,81 @@
\dim_compare:nNnTF {#8} = { \c_zero_dim }
{ \bool_set_true:N \l_@@_error_bool }
{
- \dim_compare:nNnTF {#7} = \c_zero_dim
- { \dim_set:Nn \l_@@_x_dim {#5} }
% \end{macrocode}
-% The formula for the case where the second pole is neither horizontal
-% nor vertical is
+% Now we deal with the case where the second pole may be vertical, or
+% if not we have
% \[
-% x = \frac{c'}{d'} \left ( y - b' \right ) + a'
+% x = \frac{c'}{d'} \left ( b - b' \right ) + a'
% \]
% which is again handled by the same auxiliary.
% \begin{macrocode}
+ \dim_set:Nn \l_@@_x_dim
{
- \@@_calculate_intersection_aux:nnnnnN
- {#2} {#6} {#5} {#8} {#7} \l_@@_x_dim
+ \dim_compare:nNnTF {#7} = \c_zero_dim
+ {#5}
+ {
+ \fp_to_dim:n
+ {
+ ( \dim_to_fp:n {#7} / \dim_to_fp:n {#8} )
+ * ( \dim_to_fp:n {#4} - \dim_to_fp:n {#6} )
+ + \dim_to_fp:n {#5}
+ }
+ }
}
}
}
% \end{macrocode}
-% The first pole is neither horizontal nor vertical. This still leaves
-% the second pole, which may be a special case. For those possibilities,
-% the calculations are the same as above with the first and second poles
-% interchanged.
+% The first pole is neither horizontal nor vertical. To avoid even
+% more complexity, we now work out both slopes and pass to an auxiliary.
% \begin{macrocode}
{
- \dim_compare:nNnTF {#7} = \c_zero_dim
+ \use:x
{
- \dim_set:Nn \l_@@_x_dim {#5}
- \@@_calculate_intersection_aux:nnnnnN
- {#5} {#1} {#2} {#3} {#4} \l_@@_y_dim
- }
- {
- \dim_compare:nNnTF {#8} = \c_zero_dim
- {
- \dim_set:Nn \l_@@_y_dim {#6}
- \@@_calculate_intersection_aux:nnnnnN
- {#6} {#2} {#1} {#4} {#3} \l_@@_x_dim
- }
-% \end{macrocode}
-% If none of the special cases apply then there is still a need to
-% check that there is a unique intersection between the two pole. This
-% is the case if they have different slopes.
-% \begin{macrocode}
- {
- \fp_set:Nn \l_@@_slope_x_fp
- { \dim_to_fp:n {#4} / \dim_to_fp:n {#3} }
- \fp_set:Nn \l_@@_slope_y_fp
- { \dim_to_fp:n {#8} / \dim_to_fp:n {#7} }
- \fp_compare:nNnTF
- \l_@@_slope_x_fp = \l_@@_slope_y_fp
- { \bool_set_true:N \l_@@_error_bool }
-% \end{macrocode}
-% All of the tests pass, so there is the full complexity of the
-% calculation:
-% \[
-% x = \frac { a ( d / c ) - a' ( d' / c' ) - b + b' }
-% { ( d / c ) - ( d' / c' ) }
-% \]
-% and noting that the two ratios are already worked out from the test
-% just performed. There is quite a bit of shuffling from dimensions to
-% floating points in order to do the work. The $y$-values is then
-% worked out using the standard auxiliary starting from the
-% $x$-position.
-% \begin{macrocode}
- {
- \dim_set:Nn \l_@@_x_dim
- {
- \fp_to_dim:n
- {
- (
- \dim_to_fp:n {#1} *
- \l_@@_slope_x_fp
- - ( \dim_to_fp:n {#5} *
- \l_@@_slope_y_fp )
- - \dim_to_fp:n {#2}
- + \dim_to_fp:n {#6}
- )
- /
- (
- \l_@@_slope_x_fp -
- \l_@@_slope_y_fp
- )
- }
- }
- \@@_calculate_intersection_aux:nnnnnN
- { \l_@@_x_dim }
- {#5} {#6} {#8} {#7} \l_@@_y_dim
- }
- }
+ \@@_calculate_intersection:nnnnnn
+ { \dim_to_fp:n {#4} / \dim_to_fp:n {#3} }
+ { \dim_to_fp:n {#8} / \dim_to_fp:n {#7} }
}
+ {#1} {#2} {#5} {#6}
}
}
}
% \end{macrocode}
-% The formula for finding the intersection point is in most cases the
-% same. The formula here is
+% Assuming the two poles are not parallel, then the intersection point is
+% found in two steps. First we find the $x$-value with
% \[
-% \#6 = \#4 \cdot \left( \frac { \#1 - \#2 } { \#5 } \right)\#3
+% x = \frac { sa - s'a' - b + b' }{ s - s' }
+% \]
+% and then finding the $y$-value with
+% \[
+% y = s ( x - a ) + b
% \]
-% Thus |#4| and |#5| should be the directions of the pole while
-% |#2| and |#3| are co-ordinates.
% \begin{macrocode}
-\cs_new_protected:Npn \@@_calculate_intersection_aux:nnnnnN
- #1#2#3#4#5#6
+\cs_set_protected:Npn \@@_calculate_intersection:nnnnnn #1#2#3#4#5#6
{
- \dim_set:Nn #6
+ \fp_compare:nNnTF {#1} = {#2}
+ { \bool_set_true:N \l_@@_error_bool }
{
- \fp_to_dim:n
+ \dim_set:Nn \l_@@_x_dim
+ {
+ \fp_to_dim:n
+ {
+ (
+ #1 * \dim_to_fp:n {#3}
+ - #2 * \dim_to_fp:n {#5}
+ - \dim_to_fp:n {#4}
+ + \dim_to_fp:n {#6}
+ )
+ /
+ ( #1 - #2 )
+ }
+ }
+ \dim_set:Nn \l_@@_y_dim
{
- \dim_to_fp:n {#4} *
- ( \dim_to_fp:n {#1} - \dim_to_fp:n {#2} ) /
- \dim_to_fp:n {#5}
- + \dim_to_fp:n {#3}
+ \fp_to_dim:n
+ {
+ #1 * ( \l_@@_x_dim - \dim_to_fp:n {#3} )
+ + \dim_to_fp:n {#4}
+ }
}
}
}