[latex3-commits] [git/LaTeX3-latex3-latex3] master: l3draw: Interpolation in arcs (2ca0479)
Joseph Wright
joseph.wright at morningstar2.co.uk
Fri Feb 9 22:27:23 CET 2018
Repository : https://github.com/latex3/latex3
On branch : master
Link : https://github.com/latex3/latex3/commit/2ca04796c907d5bc3739dfa0f8cb79f7271cf4f8
>---------------------------------------------------------------
commit 2ca04796c907d5bc3739dfa0f8cb79f7271cf4f8
Author: Joseph Wright <joseph.wright at morningstar2.co.uk>
Date: Fri Feb 9 21:25:19 2018 +0000
l3draw: Interpolation in arcs
Here there is a difference from pgf: we only get the point.
In pgf, a shortcut is used to save the tangent vector in this code.
As we are not using global variables for data return, that doesn't work here.
>---------------------------------------------------------------
2ca04796c907d5bc3739dfa0f8cb79f7271cf4f8
l3trial/l3draw/l3draw-points.dtx | 80 ++++++++++++++++++++++++++++++++
l3trial/l3draw/l3draw.dtx | 7 +++
l3trial/l3draw/testfiles/m3draw001.lvt | 11 +++++
l3trial/l3draw/testfiles/m3draw001.tlg | 13 ++++--
4 files changed, 107 insertions(+), 4 deletions(-)
diff --git a/l3trial/l3draw/l3draw-points.dtx b/l3trial/l3draw/l3draw-points.dtx
index 731279d..e25fec6 100644
--- a/l3trial/l3draw/l3draw-points.dtx
+++ b/l3trial/l3draw/l3draw-points.dtx
@@ -554,6 +554,86 @@
% \end{macro}
% \end{macro}
%
+% \begin{macro}[EXP]{\draw_point_interpolate_arc:nnnnnn}
+% \begin{macro}[EXP]{\@@_point_interpolate_arc_auxi:nnnnnnnn}
+% \begin{macro}[EXP]{\@@_point_interpolate_arc_auxii:nnnnnnnn}
+% \begin{macro}[EXP]
+% {
+% \@@_point_interpolate_arc_auxiii:nnnnnnnn,
+% \@@_point_interpolate_arc_auxiii:fnnnnnnn
+% }
+% \begin{macro}[EXP]
+% {
+% \@@_point_interpolate_arc_auxiv:nnnnnnn,
+% \@@_point_interpolate_arc_auxiv:fnnnnnn
+% }
+% \begin{macro}[EXP]
+% {
+% \@@_point_interpolate_arc_auxv:nnnnnnn,
+% \@@_point_interpolate_arc_auxv:fnnnnnn
+% }
+% \begin{macrocode}
+\cs_new:Npn \draw_point_interpolate_arc:nnnnnn #1#2#3#4#5#6
+ {
+ \@@_point_expand:nnN {#2} {#3}
+ \@@_point_interpolate_arc_auxi:nnnnnnnn
+ {#1} {#4} {#5} {#6}
+ }
+\cs_new:Npn \@@_point_interpolate_arc_auxi:nnnnnnnn #1#2#3#4#5#6#7#8
+ {
+ \@@_point_expand:nnN {#6} { { } { } }
+ \@@_point_interpolate_arc_auxii:nnnnnnnn
+ {#5} { {#1} {#2} {#3} {#4} } {#7} {#8}
+ }
+\cs_new:Npn \@@_point_interpolate_arc_auxii:nnnnnnnn #1#2#3#4#5#6#7#8
+ {
+ \@@_point_interpolate_arc_auxiii:fnnnnnnnn
+ { \fp_eval:n {#5} } {#7} {#8} #6 {#1} {#2}
+ }
+% \end{macrocode}
+% At this stage, the three co-ordinate pairs are fully expanded but somewhat
+% re-ordered:
+% \begin{enumerate}[label = \#\arabic*, font = \ttfamily]
+% \item $p$
+% \item $\theta_{1}$
+% \item $\theta_{2}$
+% \item $x_{c}$
+% \item $y_{c}$
+% \item $x_{a1}$
+% \item $y_{a1}$
+% \item $x_{a2}$
+% \item $y_{a2}$
+% \end{enumerate}
+% We are now in a position to find the target angle, and from that
+% the sine and cosine required.
+% \begin{macrocode}
+\cs_new:Npn \@@_point_interpolate_arc_auxiii:nnnnnnnnn #1#2#3#4#5#6#7#8#9
+ {
+ \@@_point_interpolate_arc_auxiv:fnnnnnn
+ { \fp_eval:n { #1 * (#3) + ( 1 - #1 ) * (#2) } }
+ {#4} {#5} {#6} {#7} {#8} {#9}
+ }
+\cs_generate_variant:Nn \@@_point_interpolate_arc_auxiii:nnnnnnnnn { f }
+\cs_new:Npn \@@_point_interpolate_arc_auxiv:nnnnnnn #1#2#3#4#5#6#7
+ {
+ \@@_point_interpolate_arc_auxv:ffnnnnnn
+ { \fp_eval:n { cosd (#1) } }
+ { \fp_eval:n { sind (#1) } }
+ {#2} {#3} {#4} {#5} {#6} {#7}
+ }
+\cs_generate_variant:Nn \@@_point_interpolate_arc_auxiv:nnnnnnn { f }
+\cs_new:Npn \@@_point_interpolate_arc_auxv:nnnnnnnn #1#2#3#4#5#6#7#8
+ {
+ { \fp_to_dim:n { #3 + #1 * #5 + #2 * #7 } }
+ { \fp_to_dim:n { #4 + #1 * #6 + #2 * #8 } }
+ }
+\cs_generate_variant:Nn \@@_point_interpolate_arc_auxv:nnnnnnnn { ff }
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+%
% \subsection{Vector support}
%
% As well as co-ordinates relative to the drawing
diff --git a/l3trial/l3draw/l3draw.dtx b/l3trial/l3draw/l3draw.dtx
index 1d0942a..dc55a35 100644
--- a/l3trial/l3draw/l3draw.dtx
+++ b/l3trial/l3draw/l3draw.dtx
@@ -142,6 +142,13 @@
% \end{syntax}
% \end{function}
%
+% \begin{function}[EXP]{\draw_point_interpolate_arc:nnn}
+% \begin{syntax}
+% \cs{draw_point_interpolate_line:nnn} \marg{part}
+% \marg{center} \marg{minor axis} \marg{major axis} \marg{angle1} \marg{angle2}
+% \end{syntax}
+% \end{function}
+%
% \end{documentation}
%
% \begin{implementation}
diff --git a/l3trial/l3draw/testfiles/m3draw001.lvt b/l3trial/l3draw/testfiles/m3draw001.lvt
index 5d978fe..f214972 100644
--- a/l3trial/l3draw/testfiles/m3draw001.lvt
+++ b/l3trial/l3draw/testfiles/m3draw001.lvt
@@ -119,6 +119,17 @@
{ \draw_point_vec_coord:nn { 0 } { 1 } }
}
+\TESTEXP { \draw_point_interpolate_arc:nnnnnn }
+ {
+ \draw_point_interpolate_arc:nnnnnn
+ { 0.25 }
+ { { 1cm } { 1cm } }
+ { { 1cm } { 0cm } }
+ { { 0cm } { 1cm } }
+ { 30 }
+ { 40 }
+ }
+
\TEST { \draw_set_<axis>vec:n }
{
\exp_args:Nx \tl_show:n { \draw_point_vec_coord:nnn { 1 } { 1 } { 1 } }
diff --git a/l3trial/l3draw/testfiles/m3draw001.tlg b/l3trial/l3draw/testfiles/m3draw001.tlg
index 5f0d700..af3bd98 100644
--- a/l3trial/l3draw/testfiles/m3draw001.tlg
+++ b/l3trial/l3draw/testfiles/m3draw001.tlg
@@ -62,7 +62,12 @@ TEST 10: \draw_point_interpolate_distance:nnn
{56.90548706054688pt}{86.41889076260014pt}
============================================================
============================================================
-TEST 11: \draw_set_ <axis>vec:n
+TEST 11: \draw_point_interpolate_arc:nnnnnn
+============================================================
+{52.44956684602254pt}{43.74041050993108pt}
+============================================================
+============================================================
+TEST 12: \draw_set_ <axis>vec:n
============================================================
> {17.49859619140625pt}{17.49859619140625pt}.
<recently read> }
@@ -78,7 +83,7 @@ l. ... }
l. ... }
============================================================
============================================================
-TEST 12: \draw_point_vec_coord:nn
+TEST 13: \draw_point_vec_coord:nn
============================================================
{0pt}{0pt}
{28.45274353027344pt}{28.45274353027344pt}
@@ -86,7 +91,7 @@ TEST 12: \draw_point_vec_coord:nn
{28.45274353027344pt}{28.45274353027344pt}
============================================================
============================================================
-TEST 13: \draw_point_vec_coord:nnn
+TEST 14: \draw_point_vec_coord:nnn
============================================================
{0pt}{0pt}
{-10.95414733886719pt}{-10.95414733886719pt}
@@ -94,7 +99,7 @@ TEST 13: \draw_point_vec_coord:nnn
{-10.95414733886719pt}{17.49859619140625pt}
============================================================
============================================================
-TEST 14: \draw_point_vec_polar:nn
+TEST 15: \draw_point_vec_polar:nn
============================================================
{49.28159740916025pt}{28.45274353027344pt}
{24.64079870458013pt}{28.45274353027344pt}
More information about the latex3-commits
mailing list