[latex3-commits] [git/LaTeX3-latex3-latex3] master: l3draw: Better name for normalisation (53241b5)
Joseph Wright
joseph.wright at morningstar2.co.uk
Fri Feb 9 12:37:08 CET 2018
Repository : https://github.com/latex3/latex3
On branch : master
Link : https://github.com/latex3/latex3/commit/53241b59429ed35a04c418461597fd99d409beb7
>---------------------------------------------------------------
commit 53241b59429ed35a04c418461597fd99d409beb7
Author: Joseph Wright <joseph.wright at morningstar2.co.uk>
Date: Fri Feb 9 11:37:08 2018 +0000
l3draw: Better name for normalisation
Plus tests and fixes!
>---------------------------------------------------------------
53241b59429ed35a04c418461597fd99d409beb7
l3trial/l3draw/l3draw-points.dtx | 34 ++++++++++++++++----------------
l3trial/l3draw/l3draw.dtx | 4 ++--
l3trial/l3draw/testfiles/m3draw001.lvt | 9 +++++++++
l3trial/l3draw/testfiles/m3draw001.tlg | 18 +++++++++++------
4 files changed, 40 insertions(+), 25 deletions(-)
diff --git a/l3trial/l3draw/l3draw-points.dtx b/l3trial/l3draw/l3draw-points.dtx
index 0952ec9..0ccb391 100644
--- a/l3trial/l3draw/l3draw-points.dtx
+++ b/l3trial/l3draw/l3draw-points.dtx
@@ -185,38 +185,38 @@
% \end{macro}
% \end{macro}
%
-% \begin{macro}[EXP]{\draw_point_normalise:n}
-% \begin{macro}[EXP]{\@@_point_normalise:n, \@@_point_normalise:f}
-% \begin{macro}[EXP]{\@@_point_normalise:nn, \@@_point_normalise:ff}
-% \begin{macro}[EXP]{\@@_point_normalise:nnn, \@@_point_normalise:fnn}
+% \begin{macro}[EXP]{\draw_point_unit_vector:n}
+% \begin{macro}[EXP]{\@@_point_unit_vector:n, \@@_point_unit_vector:f}
+% \begin{macro}[EXP]{\@@_point_unit_vector:nn, \@@_point_unit_vector:ff}
+% \begin{macro}[EXP]{\@@_point_unit_vector:nnn, \@@_point_unit_vector:fnn}
% Only a single point expression so the expansion is done here. The
% outcome is the normalised vector from $(0,0)$ in the direction of
% the point, \emph{i.e.}
% \[
-% P_{x} = \frac{x}{x^{2} + y^{2}} \quad
-% P_{y} = \frac{y}{x^{2} + y^{2}}
+% P_{x} = \frac{x}\sqrt{{x^{2} + y^{2}}} \quad
+% P_{y} = \frac{y}{\sqrt{x^{2} + y^{2}}}
% \]
% with the obvious optimisation of only evaluating the denominator
% once.
% \begin{macrocode}
-\cs_new:Npn \draw_point_normalise:n #1
- { \@@_point_normalise:f {#1} }
-\cs_new:Npn \@@_point_normalise:n #1
- { \@@_point_normalise:ff #1 }
-\cs_generate_variant:Nn \@@_point_normalise:n { f }
-\cs_new:Npn \@@_point_normalise:nn #1#2
+\cs_new:Npn \draw_point_unit_vector:n #1
+ { \@@_point_unit_vector:f {#1} }
+\cs_new:Npn \@@_point_unit_vector:n #1
+ { \@@_point_unit_vector:ff #1 }
+\cs_generate_variant:Nn \@@_point_unit_vector:n { f }
+\cs_new:Npn \@@_point_unit_vector:nn #1#2
{
- \@@_point_normalise:fnn
- { \fp_eval:n { #1 * #1 + #2 * #2 } }
+ \@@_point_unit_vector:fnn
+ { \fp_eval:n { sqrt( (#1) ^ 2 + (#2) ^ 2 ) } }
{#1} {#2}
}
-\cs_generate_variant:Nn \@@_point_normalise:nn { ff }
-\cs_new:Npn \@@_point_normalise:nnn #1#2#3
+\cs_generate_variant:Nn \@@_point_unit_vector:nn { ff }
+\cs_new:Npn \@@_point_unit_vector:nnn #1#2#3
{
{ \fp_to_dim:n { #2 / #1 } }
{ \fp_to_dim:n { #3 / #1 } }
}
-\cs_generate_variant:Nn \@@_point_normalise:nnn { f }
+\cs_generate_variant:Nn \@@_point_unit_vector:nnn { f }
% \end{macrocode}
% \end{macro}
% \end{macro}
diff --git a/l3trial/l3draw/l3draw.dtx b/l3trial/l3draw/l3draw.dtx
index 575627c..7ca9775 100644
--- a/l3trial/l3draw/l3draw.dtx
+++ b/l3trial/l3draw/l3draw.dtx
@@ -91,9 +91,9 @@
% \end{syntax}
% \end{function}
%
-% \begin{function}[EXP]{\draw_point_nomalise:n}
+% \begin{function}[EXP]{\draw_point_unit_vector:n}
% \begin{syntax}
-% \cs{draw_point_nomalise:nn} \marg{point expr}
+% \cs{draw_point_unit_vector:n} \marg{point expr}
% \end{syntax}
% \end{function}
%
diff --git a/l3trial/l3draw/testfiles/m3draw001.lvt b/l3trial/l3draw/testfiles/m3draw001.lvt
index 7ce05f1..dbf5fb8 100644
--- a/l3trial/l3draw/testfiles/m3draw001.lvt
+++ b/l3trial/l3draw/testfiles/m3draw001.lvt
@@ -64,6 +64,15 @@
\draw_point_scale:nn { 0.5 ^ 2 } { { 2cm } { 2cm } }
}
+\TESTEXP { \draw_point_unit_vector:n }
+ {
+ \draw_point_unit_vector:n
+ { \draw_point_vec_coord:nn { 2 } { 1 } }
+ \NEWLINE
+ \draw_point_unit_vector:n
+ { \draw_point_vec_coord:nn { -2 } { 1 } }
+ }
+
\TESTEXP { \draw_point_intersect_lines:nnnn }
{
\draw_point_intersect_lines:nnnn
diff --git a/l3trial/l3draw/testfiles/m3draw001.tlg b/l3trial/l3draw/testfiles/m3draw001.tlg
index 70e8170..85a3364 100644
--- a/l3trial/l3draw/testfiles/m3draw001.tlg
+++ b/l3trial/l3draw/testfiles/m3draw001.tlg
@@ -34,18 +34,24 @@ TEST 5: \draw_point_scale:nn
{14.2263779527559pt}{14.2263779527559pt}
============================================================
============================================================
-TEST 6: \draw_point_intersect_lines:nnnn
+TEST 6: \draw_point_unit_vector:n
+============================================================
+{0.894427190999916pt}{0.447213595499958pt}
+{-0.894427190999916pt}{0.447213595499958pt}
+============================================================
+============================================================
+TEST 7: \draw_point_intersect_lines:nnnn
============================================================
{28.45274353027345pt}{-0.000000000000008234940062507525pt}
{10.51038833340825pt}{10.51038833340825pt}
============================================================
============================================================
-TEST 7: \draw_point_intersect_circles:nnnnn
+TEST 8: \draw_point_intersect_circles:nnnnn
============================================================
{-0.00001237523567pt}{-0.00001237523569pt}
============================================================
============================================================
-TEST 8: \draw_set_ <axis>vec:n
+TEST 9: \draw_set_ <axis>vec:n
============================================================
> {17.49859619140625pt}{17.49859619140625pt}.
<recently read> }
@@ -61,7 +67,7 @@ l. ... }
l. ... }
============================================================
============================================================
-TEST 9: \draw_point_vec_coord:nn
+TEST 10: \draw_point_vec_coord:nn
============================================================
{0pt}{0pt}
{28.45274353027344pt}{28.45274353027344pt}
@@ -69,7 +75,7 @@ TEST 9: \draw_point_vec_coord:nn
{28.45274353027344pt}{28.45274353027344pt}
============================================================
============================================================
-TEST 10: \draw_point_vec_coord:nnn
+TEST 11: \draw_point_vec_coord:nnn
============================================================
{0pt}{0pt}
{-10.95414733886719pt}{-10.95414733886719pt}
@@ -77,7 +83,7 @@ TEST 10: \draw_point_vec_coord:nnn
{-10.95414733886719pt}{17.49859619140625pt}
============================================================
============================================================
-TEST 11: \draw_point_vec_polar:nn
+TEST 12: \draw_point_vec_polar:nn
============================================================
{49.28159740916025pt}{28.45274353027344pt}
{24.64079870458013pt}{28.45274353027344pt}
More information about the latex3-commits
mailing list