Bugfix for Drawing Polytop Arcs (and more?)

I have recently submitted an updated version of tikz-3dplot to the CTAN, and the latest version should be available on the CTAN distribution site soon.

Some time ago, a problem was brought to my attention regarding the polytope arc command. I finally cracked open the code and spent some time checking it out. It turned out to due how my numerical comparisons and conditional statements were written.

To compare a numerical value to another, I use the \pgfmathparse command as follows:

\pgfmathparse{\tdplotstartphi < \tdplotresphi}

The result of this will be a value written to \pgfmathresult that is 0 if false, or 1 if true.

Next, I perform conditional execution of subsequent commands using the \ifthenelse command from the ifthenpackage:

%code block for true condition
%code block for false condition

This is probably not the most elegant way to do things, but it works. Or at least it did when I wrote this package.

When the recent bug was brought to my attention, I drilled down into the execution of the tikz-3dplot package until I discovered that these conditional execution statements were not properly firing. They were always executing the false condition. It turned out that the \equal comparison between \pgfmathresult and 1.0 was no longer valid. Through trial and error, I found that it will now work if I use the following:

%code block for true condition
%code block for false condition

Note the subtle change of comparison, where I am now comparing /pgfmathresult to 1, rather than 1.0. My best guess is that the nature of the value returned by \pgfmathresult and how it is compared using \equal has been subtly changed, and so the comparison was no longer valid.

I’m not well versed on how LaTeX and PGF handles the storage and comparison of values, and I’ve always had the impression that there is no real data type structure to speak of, but my guess is that this is where the problem arises. I picture it to be the same as comparing two string literals that originated from numbers, and the conversion from number to string are different for each value, resulting in a different string.

So, long story short, lots of head scratching, and a subtle change repaired the issue. Enjoy!


~ by Jeff Hein on 2012/01/11.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: