diff options
Diffstat (limited to 'tex/context/base/thrd-trg.tex')
| -rw-r--r-- | tex/context/base/thrd-trg.tex | 54 | 
1 files changed, 30 insertions, 24 deletions
| diff --git a/tex/context/base/thrd-trg.tex b/tex/context/base/thrd-trg.tex index 3fce672d5..dda81a8af 100644 --- a/tex/context/base/thrd-trg.tex +++ b/tex/context/base/thrd-trg.tex @@ -6,6 +6,12 @@  \unprotect +% compare: \number 0.5 \number -0.5 \number 1.5 \number -1.5 +% +% so we need: + +\def\realnumber#1{\withoutpt\the\dimexpr#1\s!pt\relax} % brrr +  \chardef     \@iv         =     4  \chardef     \@xc         =    90 % was \nin@ty  \chardef     \@clxx       =   180 @@ -51,22 +57,22 @@  %D calculations.  \def\calculatesin#1% -  {{\expandafter\ifx\csname sin \number#1\endcsname\relax +  {{\expandafter\ifx\csname sin \realnumber{#1}\endcsname\relax        \!!dimena#1\onepoint        \tg@@sin -      \expandafter\xdef\csname sin \number#1\endcsname{\withoutpt\the\!!dimena}% +      \expandafter\xdef\csname sin \realnumber{#1}\endcsname{\withoutpt\the\!!dimena}%      \fi}}  \def\calculatecos#1% -  {{\expandafter\ifx\csname cos \number#1\endcsname\relax +  {{\expandafter\ifx\csname cos \realnumber{#1}\endcsname\relax        \!!dimena\@xc\onepoint        \advance\!!dimena-#1\onepoint        \tg@@sin -      \expandafter\xdef\csname cos \number#1\endcsname{\withoutpt\the\!!dimena}% +      \expandafter\xdef\csname cos \realnumber{#1}\endcsname{\withoutpt\the\!!dimena}%      \fi}}  \def\calculatetan#1% -  {{\expandafter\ifx\csname tan \number#1\endcsname\relax +  {{\expandafter\ifx\csname tan \realnumber{#1}\endcsname\relax        \calculatesin{#1}%        \calculatecos{#1}%        \!!dimena\calculatedcos{#1}\onepoint @@ -74,40 +80,40 @@        \!!dimenb\calculatedsin{#1}\onepoint        \!!dimenb\@xvi@k\!!dimenb        \divide\!!dimenb\!!dimena -      \expandafter\xdef\csname tan \number#1\endcsname{\withoutpt\the\!!dimenb}% +      \expandafter\xdef\csname tan \realnumber{#1}\endcsname{\withoutpt\the\!!dimenb}%     \fi}}  %D The results are accessed with: -\def\calculatedsin#1{\csname sin \number#1\endcsname} -\def\calculatedcos#1{\csname cos \number#1\endcsname} -\def\calculatedtan#1{\csname tan \number#1\endcsname} +\def\calculatedsin#1{\csname sin \realnumber{#1}\endcsname} +\def\calculatedcos#1{\csname cos \realnumber{#1}\endcsname} +\def\calculatedtan#1{\csname tan \realnumber{#1}\endcsname}  %D A more save implementation would be: -\def\calculatedsin#1{\executeifdefined{sin \number#1}\!!zerocount} -\def\calculatedcos#1{\executeifdefined{cos \number#1}\!!plusone} -\def\calculatedtan#1{\executeifdefined{tan \number#1}\!!zerocount} +\def\calculatedsin#1{\executeifdefined{sin \realnumber{#1}}\!!zerocount} +\def\calculatedcos#1{\executeifdefined{cos \realnumber{#1}}\!!plusone  } +\def\calculatedtan#1{\executeifdefined{tan \realnumber{#1}}\!!zerocount}  %D A few values are predefined, although, on todays systems there  %D is no real reason for that. I've added the 270 ones and changed  %D the -90 tan. Also, I prefer text (\type {\!!..} instead of  %D counters \type {\..}. -\expandafter\let\csname sin   0\endcsname\!!zerocount -\expandafter\let\csname cos   0\endcsname\!!plusone -\expandafter\let\csname sin  90\endcsname\!!plusone -\expandafter\let\csname cos  90\endcsname\!!zerocount -\expandafter\let\csname sin 180\endcsname\!!zerocount -\expandafter\let\csname cos 180\endcsname\!!minusone -\expandafter\let\csname sin 270\endcsname\!!minusone -\expandafter\let\csname cos 270\endcsname\!!zerocount +\expandafter\let\csname sin \realnumber{  0}\endcsname\!!zerocount +\expandafter\let\csname cos \realnumber{  0}\endcsname\!!plusone +\expandafter\let\csname sin \realnumber{ 90}\endcsname\!!plusone +\expandafter\let\csname cos \realnumber{ 90}\endcsname\!!zerocount +\expandafter\let\csname sin \realnumber{180}\endcsname\!!zerocount +\expandafter\let\csname cos \realnumber{180}\endcsname\!!minusone +\expandafter\let\csname sin \realnumber{270}\endcsname\!!minusone +\expandafter\let\csname cos \realnumber{270}\endcsname\!!zerocount -\expandafter\let\csname sin -90\endcsname\!!minusone -\expandafter\let\csname cos -90\endcsname\!!zerocount +\expandafter\let\csname sin \realnumber{-90}\endcsname\!!minusone +\expandafter\let\csname cos \realnumber{-90}\endcsname\!!zerocount -\expandafter\def\csname tan  90\endcsname{\writestatus\m!systems{infinite tan +90}} -\expandafter\def\csname tan -90\endcsname{\writestatus\m!systems{infinite tan -90}} +\expandafter\def\csname tan \realnumber{ 90}\endcsname{\writestatus\m!systems{infinite tan +90}} +\expandafter\def\csname tan \realnumber{-90}\endcsname{\writestatus\m!systems{infinite tan -90}}  %D Usage: \type {\calculatesin{10}} and \type {\calculatedsin{10}} | 
