[latex3-commits] [git/LaTeX3-latex3-latex3] master: l3draw: Avoid "^2" for squaring (dfb1386)

Joseph Wright joseph.wright at morningstar2.co.uk
Fri Feb 9 22:22:36 CET 2018


Repository : https://github.com/latex3/latex3
On branch  : master
Link       : https://github.com/latex3/latex3/commit/dfb1386eed1511e20744667cc8605862dfd14603

>---------------------------------------------------------------

commit dfb1386eed1511e20744667cc8605862dfd14603
Author: Joseph Wright <joseph.wright at morningstar2.co.uk>
Date:   Fri Feb 9 21:18:34 2018 +0000

    l3draw: Avoid "^2" for squaring
    
    Bruno tells me this is the faster approach.


>---------------------------------------------------------------

dfb1386eed1511e20744667cc8605862dfd14603
 l3trial/l3draw/l3draw-points.dtx |   24 ++++++++++++++++--------
 1 file changed, 16 insertions(+), 8 deletions(-)

diff --git a/l3trial/l3draw/l3draw-points.dtx b/l3trial/l3draw/l3draw-points.dtx
index a9eb993..731279d 100644
--- a/l3trial/l3draw/l3draw-points.dtx
+++ b/l3trial/l3draw/l3draw-points.dtx
@@ -207,7 +207,7 @@
 \cs_new:Npn \@@_point_unit_vector:nn #1#2
   {
     \@@_point_unit_vector:fnn
-      { \fp_eval:n { sqrt( (#1) ^ 2 + (#2) ^ 2 ) } }
+      { \fp_eval:n { sqrt( #1 * #1 + #2 * #2 ) } }
       {#1} {#2}
   }
 \cs_generate_variant:Nn \@@_point_unit_vector:nn { ff }
@@ -398,7 +398,7 @@
 \cs_new:Npn \@@_point_intersect_circles_auxiii:nnnnnnn #1#2#3#4#5#6#7
   {
     \@@_point_intersect_circles_auxiv:fnnnnnnn
-      { \fp_eval:n { sqrt( (#1) ^ 2 + (#2) ^ 2 ) } }
+      { \fp_eval:n { sqrt( #1 * #1 + #2 * #2 ) } }
       {#1} {#2} {#3} {#4} {#5} {#6} {#7}
   }
 \cs_generate_variant:Nn \@@_point_intersect_circles_auxiii:nnnnnnn { ff }
@@ -411,7 +411,7 @@
   {
     \@@_point_intersect_circles_auxv:ffnnnnnnn
       { \fp_eval:n { 1 / #1 } }
-      { \fp_eval:n { (#4) ^ 2 } }
+      { \fp_eval:n { #4 * #4 } }
       {#1} {#2} {#3} {#5} {#6} {#7} {#8}
   }
 \cs_generate_variant:Nn \@@_point_intersect_circles_auxiv:nnnnnnnn { f }
@@ -444,7 +444,7 @@
     \@@_point_intersect_circles_auxvii:fffnnnn
       { \fp_eval:n { #1 * #2 } }
       { \int_if_odd:nTF {#8} { 1 } { -1 } }
-      { \fp_eval:n { sqrt( #3 - (#1) ^ 2 ) * #2 } }
+      { \fp_eval:n { sqrt ( #3 - #1 * #1 ) * #2 } }
       {#4} {#5} {#6} {#7}
   }
 \cs_generate_variant:Nn \@@_point_intersect_circles_auxvi:nnnnnnnn { f }
@@ -512,8 +512,8 @@
 % \begin{macro}[EXP]{\@@_point_interpolate_distance:nnnnn}
 % \begin{macro}[EXP]
 %   {
-%     \@@_point_interpolate_distance_aux:nnnnn,
-%     \@@_point_interpolate_distance_aux:fnnnn,
+%     \@@_point_interpolate_distance_aux:nnnnnnn,
+%     \@@_point_interpolate_distance_aux:nnnnnnn,
 %   }
 % \begin{macro}[EXP]
 %   {
@@ -530,10 +530,18 @@
   }
 \cs_new:Npn \@@_point_interpolate_distance:nnnnn #1#2#3#4#5
   {
+    \@@_point_interpolate_distance_aux:nnnnnnn
+      { \fp_eval:n { #3 - #1 } }
+      { \fp_eval:n { #4 - #2 } }
+      {#1} {#2} {#3} {#4} {#5}
+  }
+\cs_new:Npn \@@_point_interpolate_distance_aux:nnnnnnn #1#2#3#4#5#6#7
+  {
     \@@_point_interpolate_distance_aux:fnnnn
-      { \fp_eval:n { (#5) / sqrt ( ( #3 - #1 ) ^ 2 + ( #4 - #2 ) ^ 2 ) } }
-      {#1} {#2} {#3} {#4}
+      { \fp_eval:n { (#7) / sqrt ( #1 * #1 + #2 * #2 ) } }
+      {#3} {#4} {#5} {#6}
   }
+\cs_generate_variant:Nn \@@_point_interpolate_distance_aux:nnnnnnn { ff }
 \cs_new:Npn \@@_point_interpolate_distance_aux:nnnnn #1#2#3#4#5
   {
     { \fp_to_dim:n { #2 + #1 * #4 } }





More information about the latex3-commits mailing list