[latex3-commits] [git/LaTeX3-latex3-latex3] master: l3draw: Point normalisation (9a73280)
Joseph Wright
joseph.wright at morningstar2.co.uk
Thu Feb 8 09:53:26 CET 2018
Repository : https://github.com/latex3/latex3
On branch : master
Link : https://github.com/latex3/latex3/commit/9a73280d5ca37a221e076d29f3f0dcfefb2a44e7
>---------------------------------------------------------------
commit 9a73280d5ca37a221e076d29f3f0dcfefb2a44e7
Author: Joseph Wright <joseph.wright at morningstar2.co.uk>
Date: Thu Feb 8 08:53:26 2018 +0000
l3draw: Point normalisation
>---------------------------------------------------------------
9a73280d5ca37a221e076d29f3f0dcfefb2a44e7
l3trial/l3draw/l3draw-points.dtx | 37 +++++++++++++++++++++++++++++++++++++
l3trial/l3draw/l3draw.dtx | 8 +++++++-
2 files changed, 44 insertions(+), 1 deletion(-)
diff --git a/l3trial/l3draw/l3draw-points.dtx b/l3trial/l3draw/l3draw-points.dtx
index 55e0a64..e2fc458 100644
--- a/l3trial/l3draw/l3draw-points.dtx
+++ b/l3trial/l3draw/l3draw-points.dtx
@@ -186,6 +186,43 @@
% \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}
+% Only a single point expression so the expansion is done here. The
+% outcomes are easy enough
+% \[
+% P_{x} = \frac{x}{x^{2} + y^{2}} \quad
+% P_{y} = \frac{y}{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
+ {
+ \@@_point_normalise:fnn
+ { \fp_eval:n { #1 * #1 + #2 * #2 } }
+ {#1} {#2}
+ }
+\cs_generate_variant:Nn \@@_point_normalise:nn { ff }
+\cs_new:Npn \@@_point_normalise:nnn #1#2#3
+ {
+ { \fp_to_dim:n { #2 / #1 } }
+ { \fp_to_dim:n { #3 / #1 } }
+ }
+\cs_generate_variant:Nn \@@_point_normalise:nnn { f }
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+%
% \subsection{Intersection calculations}
%
% \begin{macro}[EXP]{\draw_point_linejoin:nnnn}
diff --git a/l3trial/l3draw/l3draw.dtx b/l3trial/l3draw/l3draw.dtx
index b071e64..da72b5f 100644
--- a/l3trial/l3draw/l3draw.dtx
+++ b/l3trial/l3draw/l3draw.dtx
@@ -91,7 +91,13 @@
% \end{syntax}
% \end{function}
%
-% \begin{function}[EXP]{\draw_set_xvec:n, \draw_set_yvec:n, \draw_set_zvec:n}
+% \begin{function}[EXP]{\draw_point_nomalise:n}
+% \begin{syntax}
+% \cs{draw_point_nomalise:nn} \marg{point expr}
+% \end{syntax}
+% \end{function}
+%
+% \begin{function}{\draw_set_xvec:n, \draw_set_yvec:n, \draw_set_zvec:n}
% \begin{syntax}
% \cs{draw_set_xvec:n} \marg{point expr}
% \end{syntax}
More information about the latex3-commits
mailing list