summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/latex/l3experimental/l3draw/l3draw-points.dtx
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/source/latex/l3experimental/l3draw/l3draw-points.dtx')
-rw-r--r--Master/texmf-dist/source/latex/l3experimental/l3draw/l3draw-points.dtx31
1 files changed, 22 insertions, 9 deletions
diff --git a/Master/texmf-dist/source/latex/l3experimental/l3draw/l3draw-points.dtx b/Master/texmf-dist/source/latex/l3experimental/l3draw/l3draw-points.dtx
index 510b6534bd0..a171b598e76 100644
--- a/Master/texmf-dist/source/latex/l3experimental/l3draw/l3draw-points.dtx
+++ b/Master/texmf-dist/source/latex/l3experimental/l3draw/l3draw-points.dtx
@@ -44,7 +44,7 @@
% }^^A
% }
%
-% \date{Released 2019-07-01}
+% \date{Released 2019-08-25}
%
% \maketitle
%
@@ -199,9 +199,9 @@
% save on any expression evaluation there and force expansion.
% \begin{macrocode}
\cs_new:Npn \draw_point_polar:nn #1#2
- { \draw_point_polar:nnn {#1} {#2} {#2} }
+ { \draw_point_polar:nnn {#1} {#1} {#2} }
\cs_new:Npn \draw_point_polar:nnn #1#2#3
- { \@@_draw_polar:fnn { \fp_eval:n {#1} } {#2} {#3} }
+ { \@@_draw_polar:fnn { \fp_eval:n {#3} } {#1} {#2} }
\cs_new:Npn \@@_draw_polar:nnn #1#2#3
{ \@@_point_to_dim:n { cosd(#1) * (#2) , sind(#1) * (#3) } }
\cs_generate_variant:Nn \@@_draw_polar:nnn { f }
@@ -216,24 +216,37 @@
%
% \begin{macro}[EXP]{\draw_point_unit_vector:n}
% \begin{macro}[EXP]{\@@_point_unit_vector:nn}
-% Only a single point expression so the expansion is done here. The
-% outcome is the normalised vector from $(0,0)$ in the direction of
+% \begin{macro}[EXP]{\@@_point_unit_vector:nnn}
+% The outcome is the normalised vector from $(0,0)$ in the direction of
% the point, \emph{i.e.}
% \[
% P_{x} = \frac{x}{\sqrt{x^{2} + y^{2}}} \quad
% P_{y} = \frac{y}{\sqrt{x^{2} + y^{2}}}
% \]
+% except where the length is zero, in which case a vertical vector is
+% returned.
% \begin{macrocode}
\cs_new:Npn \draw_point_unit_vector:n #1
{ \@@_point_process:nn { \@@_point_unit_vector:nn } {#1} }
\cs_new:Npn \@@_point_unit_vector:nn #1#2
{
- \@@_point_to_dim:n
- { ( #1 , #2 ) / (sqrt(#1 * #1 + #2 * #2)) }
+ \exp_args:Nf \@@_point_unit_vector:nnn
+ { \fp_eval:n { (sqrt(#1 * #1 + #2 * #2)) } }
+ {#1} {#2}
+ }
+\cs_new:Npn \@@_point_unit_vector:nnn #1#2#3
+ {
+ \fp_compare:nNnTF {#1} = \c_zero_fp
+ { 0pt, 1pt }
+ {
+ \@@_point_to_dim:n
+ { ( #2 , #3 ) / #1 }
+ }
}
% \end{macrocode}
% \end{macro}
% \end{macro}
+% \end{macro}
%
% \subsection{Intersection calculations}
%
@@ -856,9 +869,9 @@
% Much the same as the core polar approach.
% \begin{macrocode}
\cs_new:Npn \draw_point_vec_polar:nn #1#2
- { \draw_point_vec_polar:nnn {#1} {#2} {#2} }
+ { \draw_point_vec_polar:nnn {#1} {#1} {#2} }
\cs_new:Npn \draw_point_vec_polar:nnn #1#2#3
- { \@@_draw_vec_polar:fnn { \fp_eval:n {#1} } {#2} {#3} }
+ { \@@_draw_vec_polar:fnn { \fp_eval:n {#3} } {#1} {#2} }
\cs_new:Npn \@@_draw_vec_polar:nnn #1#2#3
{
\@@_point_to_dim:n