Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enabling FPU breaks drawing with arrows #678

Open
PhelypeOleinik opened this issue May 20, 2019 · 6 comments
Open

Enabling FPU breaks drawing with arrows #678

PhelypeOleinik opened this issue May 20, 2019 · 6 comments

Comments

@PhelypeOleinik
Copy link
Member

PhelypeOleinik commented May 20, 2019

The following code:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{fpu}
\begin{document}
\begin{tikzpicture}[/pgf/fpu=true,/pgf/fpu/output format=fixed]
  \draw (0,0) -- (1,1); % works
  \draw [->] (0,0) -- (1,1); % doesn't
\end{tikzpicture}
\end{document}

breaks with:

! Package PGF Math Error: Sorry, an internal routine of the floating point unit
 got an ill-formatted floating point number `-28.45274000000000'. The unreadabl
e part was near '-28.45274000000000'..

See the PGF Math package documentation for explanation.
Type  H <return>  for immediate help.
 ...                                              
                                                  
l.9   \draw [->] (0,0) -- (1,1);
                                 % doesn't
?

with the current (3.1.3) version of PGF--TikZ.

The command works fine without the [->]. PGF--TikZ version 3.1.1 works fine.

@hmenke
Copy link
Member

hmenke commented May 20, 2019

Bisected to 65b8261

@hmenke
Copy link
Member

hmenke commented May 20, 2019

What we have here is a much deeper problem, namely that drawing with FPU enabled will not work. Try this example with any version of PGF:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{fpu}
\begin{document}
\begin{tikzpicture}[/pgf/fpu=true]
  \draw (0,0) -- (1,1);
\end{tikzpicture}
\end{document}

I'm tending to mark this as wont-fix because even if we fix this tiny regression, the rest will still remain unusable.

@hmenke hmenke added the pgfmath label May 20, 2019
@u-fischer
Copy link
Contributor

u-fischer commented May 20, 2019

Imho it indicates a real problem of the fpu library with output format fixed:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{fpu}
\begin{document}
\pgfkeys{/pgf/fpu,/pgf/fpu/output format=fixed}
\pgfmathcos{1}
xxx
\end{document}

@u-fischer
Copy link
Contributor

u-fischer commented May 20, 2019

It seems to work if one use \pgfmathparse instead of the math command:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{fpu}
\makeatletter
\def\pgfpointnormalised#1{%
  \pgf@process{#1}%
  \pgfmathparse{atan2(\the\pgf@y,\the\pgf@x)}%
  \let\pgf@tmp=\pgfmathresult%
  \pgfmathparse{cos(\pgf@tmp)}%
  \pgf@x=\pgfmathresult pt\relax%
  \pgfmathparse{sin(\pgf@tmp)}%
  \pgf@y=\pgfmathresult pt\relax%
  }
\begin{document}
\begin{tikzpicture}[/pgf/fpu=true,/pgf/fpu/output format=fixed]
  \draw (0,0) -- (1,1); % works
  \draw [->] (0,0) -- (1,1); % doesn't
\end{tikzpicture}
\end{document}

@hmenke hmenke added the fpu label May 20, 2019
@hmenke
Copy link
Member

hmenke commented May 21, 2019

I have a patch, but that will break other things.

diff --git a/tex/generic/pgf/math/pgfmathfunctions.code.tex b/tex/generic/pgf/math/pgfmathfunctions.code.tex
index d1c3c434..3f6e5784 100644
--- a/tex/generic/pgf/math/pgfmathfunctions.code.tex
+++ b/tex/generic/pgf/math/pgfmathfunctions.code.tex
@@ -71,7 +71,11 @@
         \def#1{#2}%
         \def\pgfmath@@head{\def#2}%
     \or
-        \def#1##1{\pgfmathparse{##1}\expandafter#2\expandafter{\pgfmathresult}}%
+        \def#1##1{%
+            \pgfmathparse{##1}%
+            \pgfmathfloatparsenumber{\pgfmathresult}%
+            \expandafter#2\expandafter{\pgfmathresult}%
+        }%
         \def\pgfmath@@head{\def#2####1}%
     \else%
         \pgfmath@toks={}%
@@ -91,7 +95,8 @@
             \pgfmath@addto@toks{\pgfmathparse}%
             \expandafter\expandafter\expandafter\pgfmath@addto@toks%
                 \expandafter\expandafter\expandafter{\expandafter\expandafter\expandafter%
-                    {\expandafter\pgfmath@char@hash\pgfmathcounter}}%
+                    {\expandafter\pgfmath@char@hash\pgfmathcounter}%
+                    \pgfmathfloatparsenumber{\pgfmathresult}}%
             \pgfmath@addto@toks{\let}%
             \expandafter\pgfmath@addto@toks\expandafter{%
                 \csname pgfmath@argument@\pgfmathcounter\endcsname=\pgfmathresult}%

@ilayn
Copy link
Member

ilayn commented Dec 24, 2019

I enjoy the manual's warning about this instead of changing the behavior

Use fpu=false to deactivate the FPU. This will restore any change. Please note that this is not
necessary if the FPU is used inside of a TeX group – it will be deactivated afterwards anyway.
It does not hurt to call fpu=true or fpu=false multiple times.

I think a better warning about fpu not being a drop-in replacement math engine for the regular usage (which would have been the default if it was so) is a better way instead of enabling at the top of the tikzpicture and trying to mend things as they break.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

4 participants