diff options
Diffstat (limited to 'Master/texmf-dist/tex/latex/tkz-fct/tkz-fct.sty')
-rw-r--r-- | Master/texmf-dist/tex/latex/tkz-fct/tkz-fct.sty | 714 |
1 files changed, 714 insertions, 0 deletions
diff --git a/Master/texmf-dist/tex/latex/tkz-fct/tkz-fct.sty b/Master/texmf-dist/tex/latex/tkz-fct/tkz-fct.sty new file mode 100644 index 00000000000..86aa260a027 --- /dev/null +++ b/Master/texmf-dist/tex/latex/tkz-fct/tkz-fct.sty @@ -0,0 +1,714 @@ +% Copyright 2011 by Alain Matthes +% +% This file may be distributed and/or modified +% +% 1. under the LaTeX Project Public License and/or +% 2. under the GNU Public License. +% + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + % % + % tkz-fct.sty encodage : utf8 % + % % + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + % % + % Créé par Alain Matthes le 16-01-2011 % + % % + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% Objet : fonctions numériques en 2D with gnuplot + +% constants from tkz-base +% \tkz@init@xstep +% \tkz@init@ystep +%<---------------------------------------------------------------------------> +\NeedsTeXFormat{LaTeX2e} +\ProvidesPackage{tkz-fct}[2011/06/01 1.16 c function ] +\newcount\tkz@tkzf@fct +\edef\tkzTWOPTCode{\the\catcode`\:} +\tkz@tkzf@fct=0 % +\def\tkzfctloaded{} +%<---------------------------------------------------------------------------> +% Initialisation +%<---------------------------------------------------------------------------> +\RequirePackage{tkz-base} +% % Code from Christian Tellechea 2009 % modified by AM +% modified \FP@pow from fp.sty +\def\FP@pow#1#2#3{% + \FP@beginmessage{POW}% + {\def\FP@beginmessage##1{}% + \def\FP@endmessage##1{}% + \FPifzero{#2}% + \expandafter\@firstoftwo + \else + \expandafter\@secondoftwo + \fi + {\FP@pow@zero{#3}}% + {\FPifint{#3}% + \expandafter\@firstoftwo + \else + \expandafter\@secondoftwo + \fi +{\FPifneg{#2}% + \FPneg\FP@tmpd{#2}% + \FPln\FP@tmpd\FP@tmpd + \FPmul\FP@tmpd\FP@tmpd{#3}% + \FPexp\FP@tmpd\FP@tmpd + \FPtrunc\FP@tmp{#3}0% + \ifodd\FP@tmp + \FPneg\FP@tmp\FP@tmpd + \else + \let\FP@tmp\FP@tmpd + \fi +\else + \FPln\FP@tmpd{#2}% + \FPmul\FP@tmpd\FP@tmpd{#3}% + \FPexp\FP@tmp\FP@tmpd +\fi +}% +{\FPln\FP@tmpd{#2}% + \FPmul\FP@tmpd\FP@tmpd{#3}% + \FPexp\FP@tmp\FP@tmpd}% +}% +\global\let\FP@tmp\FP@tmp}% +\FP@endmessage{}% +\let#1\FP@tmp} +%<---------------------------------------------------------------------------> +% Styles +%<---------------------------------------------------------------------------> +\def\tkzfctset#1{\pgfkeys{/tkztan/.cd,#1}} + +\tkzfctset{tan style/.style={->,>=latex}} %<---------------------------------------------------------------------------> +% tkzFct +%<---------------------------------------------------------------------------> +\newif\iftkz@draw +\newif\iftkz@fp +\def\tkz@dmin{-5}\def\tkz@dmax{5} +\pgfkeys{% +/tkzfct/.cd, +domain/.code args={#1:#2} {\FPeval\tkz@min{(#1)} + \FPeval\tkz@max{(#2)}}, +samples/.code = {\edef\tkz@fct@samples{#1}}, +id/.code = {\edef\tkz@fct@id{#1}}, +fp/.is if = tkz@fp, +fp/.default = false, +/tkzfct/.unknown/.code = {\let\searchname=\pgfkeyscurrentname + \pgfkeysalso{\searchname/.try=#1, + /tikz/\searchname/.retry=#1}}} + +\def\tkzFct{\pgfutil@ifnextchar[{\tkzActivOff\tkz@fct}{\tkz@fct[]}} +\def\tkz@fct[#1]#2{% +\pgfkeys{/tkzfct/.cd, +domain = \@xa:\@xb, +samples = 200, +fp = true, +id = tkzfct} +\pgfqkeys{/tkzfct}{#1}% +\iftkz@init@NO% + \FPdiv{\tkz@x@delta}{\tkz@init@xorigine}{\tkz@init@xstep}% + \FPdiv{\tkz@y@delta}{\tkz@init@yorigine}{\tkz@init@ystep}% +\else + \FPset{\tkz@x@delta}{0}% + \FPset{\tkz@y@delta}{0}% +\fi% +% stockage +\advance\tkz@tkzf@fct by 1 % +\FPdiv\tkz@ba{\tkz@min}{\tkz@init@xstep}% +\FPdiv\tkz@bb{\tkz@max}{\tkz@init@xstep}% +\def\x{(x*\tkz@init@xstep)}% +\expandafter\edef\csname tkzFctgnu\@alph\tkz@tkzf@fct \endcsname{#2}% +\expandafter\edef\csname tkzFctgnuLast\endcsname{#2} +\begin{scope}[samples = \tkz@fct@samples,#1] + \clip (\tkz@xa,\tkz@ya) rectangle (\tkz@xb,\tkz@yb); + \draw[xshift = -\tkz@x@delta cm,yshift = -\tkz@y@delta cm,/tkzfct/.cd]% + plot[id=\tkz@fct@id,domain= \tkz@ba:\tkz@bb]% + function{(#2)/\tkz@init@ystep};% +\end{scope} + \let\tkz@tmp@xstep\tkz@init@xstep + \def\tkz@init@xstep{1} +\iftkz@fp% + \ReplaceSubStrings{\tkz@tempa}{#2}{log}{ln} + \ReplaceSubStrings{\tkz@tempb}{\tkz@tempa}{**}{^} + \ReplaceSubStrings{\tkz@tempa}{\tkz@tempb}{\x}{x} + \ReplaceSubStrings{\tkz@tempb}{\tkz@tempa}{asin}{arcsin} + \ReplaceSubStrings{\tkz@tempa}{\tkz@tempb}{acos}{arccos} + \ReplaceSubStrings{\tkz@tempb}{\tkz@tempa}{atan}{arctan} + \expandafter\edef\csname tkzFct\@alph\tkz@tkzf@fct\endcsname{\tkz@tempb}% + \expandafter\edef\csname tkzFctLast\endcsname{\tkz@tempb}% + \fi + \let\tkz@init@xstep\tkz@tmp@xstep + \catcode`\:=\tkzTWOPTCode\relax +}% +%<---------------------------------------------------------------------------> +% point d'une courbe (new method) +%<---------------------------------------------------------------------------> +\pgfkeys{% +/tkzfctpt/.cd, +draw/.is if = tkz@draw, +draw/.default = true, +with/.code = \global\def\tkz@fct@used{#1}, +ref/.code = \global\def\tkz@fct@ref{#1}} + +\def\tkzDefPointByFct{\pgfutil@ifnextchar[{\tkz@fctpoint}{\tkz@fctpoint[]}} +\def\tkz@fctpoint[#1](#2){% +\pgfkeys{/tkzfctpt/.cd, + draw = false, + with = {}, + ref = {}} +\pgfqkeys{/tkzfctpt}{#1} + + \FPeval\x{(#2)}% + \ifx\tkzutil@empty\tkz@fct@used + \FPeval\tkz@fx{\tkzFctLast} + \else + \edef\tkz@fct{\csname tkzFct\tkz@fct@used\endcsname} + \FPeval\tkz@fx{\tkz@fct} + \fi + \tkzDefPoint(\x,\tkz@fx){tkzPointResult}% + \iftkz@draw + \tkzDrawPoint(tkzPointResult) + \fi +\ifx\tkzutil@empty\tkz@fct@ref +\else + \tkzGetPoint{\tkz@fct@ref} +\fi +}% +%<---------------------------------------------------------------------------> +% tangente \tkzDrawTangentLine +%<---------------------------------------------------------------------------> +\pgfkeys{% +/tkztan/.cd, +draw/.is if = tkz@draw, +draw/.default = true, +with/.code = \global\def\tkz@fct@used{#1}, +kr/.code = {\edef\tkz@tan@kr{#1}}, +kl/.code = {\edef\tkz@tan@kl{#1}}, +/tkztan/.unknown/.code = {\let\searchname=\pgfkeyscurrentname + \pgfkeysalso{\searchname/.try=#1, + /tikz/\searchname/.retry=#1}} +}% +%<---------------------------------------------------------------------------> +\def\tkzDrawTangentLine{\pgfutil@ifnextchar[{\tkz@DrawTangentLine}{% + \tkz@DrawTangentLine[]}} +\def\tkz@DrawTangentLine[#1](#2){% +\begingroup +\pgfkeys{/tkztan/.cd, + draw = false, + with = {}, + kr = 1, + kl = 1} +\pgfqkeys{/tkztan}{#1} +\FPeval\x{(#2)}% +\ifx\tkzutil@empty\tkz@fct@used + \FPeval\tkz@img{\tkzFctLast} + \let\tkz@fct\tkzFctLast +\else + \edef\tkz@fct{\csname tkzFct\tkz@fct@used\endcsname} + \FPeval\tkz@img{\tkz@fct} + \fi +\let\tkz@old@img\tkz@img +\let\tkz@old@x\x +\tkzDefPoint(\tkz@old@x,\tkz@old@img){tkzPointResult} +\FPdiv{\tkz@krx}{\tkz@tan@kr}{\tkz@init@xstep} +\FPdiv{\tkz@kry}{\tkz@tan@kr}{\tkz@init@ystep} +\FPdiv{\tkz@klx}{\tkz@tan@kl}{\tkz@init@xstep} +\FPdiv{\tkz@kly}{\tkz@tan@kl}{\tkz@init@ystep} + % demi tgt--> droite +\FPifzero{\tkz@tan@kr}% +\else +\FPadd{\x}{\tkz@old@x}{0.000001}% +\FPeval\tkz@img{\tkz@fct}% +\FPadd{\tkz@deltay}{\tkz@old@img}{-\tkz@img}% +\FPmul{\tkz@slope}{\tkz@deltay}{1000000}% +\protected@edef\tkz@temp{% +\noexpand\draw[/tkztan/tan style,/tkztan/.cd,#1]}\tkz@temp% + (tkzPointResult)--++(\tkz@krx,-\tkz@kry*\tkz@slope); +\fi +% demi tgt --> gauche +\FPifzero{\tkz@tan@kl}% + \else +\FPadd{\x}{\tkz@old@x}{-0.000001} +\FPeval\tkz@img{\tkz@fct}% +\FPadd{\tkz@deltay}{\tkz@old@img}{-\tkz@img} +\FPmul{\tkz@slope}{\tkz@deltay}{-1000000} +\protected@edef\tkz@temp{% +\noexpand\draw[/tkztan/tan style,/tkztan/.cd,#1]}\tkz@temp% + (tkzPointResult)--++(-\tkz@klx,\tkz@kly*\tkz@slope); + \fi + \iftkz@draw + \tkzDrawPoint(tkzPointResult) + \fi +\endgroup +} +%<---------------------------------------------------------------------------> +% tkzArea +%<---------------------------------------------------------------------------> +\pgfkeys{% +/tkzarea/.cd, +domain/.code args={#1:#2} {\FPeval\tkz@min{(#1)} + \FPeval\tkz@max{(#2)}}, +opacity/.code = {\edef\tkz@fct@opacity{#1}}, +id/.code = {\edef\tkz@fct@id{#1}}, +color/.code = {\edef\tkz@fct@color{#1}}, +samples/.code = {\edef\tkz@fct@samples{#1}}, +/tkzarea/.unknown/.code = {\let\searchname=\pgfkeyscurrentname + \pgfkeysalso{\searchname/.try=#1, + /tikz/\searchname/.retry=#1}}} +\def\tkzArea{\pgfutil@ifnextchar[{\catcode`\:=12 \tkz@aire}{\tkz@aire[]}} +\def\tkz@aire[#1]{% +\begingroup +\pgfkeys{% +/tkzarea/.cd, +domain = -5:5, +color = \tkz@otherlinecolor, +samples = 200, +id = tkzfonct, +opacity = .5} +\pgfqkeys{/tkzarea}{#1} +\iftkz@init@NO + \FPdiv{\tkz@x@delta}{\tkz@init@xorigine}{\tkz@init@xstep}% + \FPdiv{\tkz@y@delta}{\tkz@init@yorigine}{\tkz@init@ystep}% +\else + \FPset{\tkz@x@delta}{0} + \FPset{\tkz@y@delta}{0}% +\fi% +\def\x{(x*\tkz@init@xstep)} +\FPdiv\tkz@ba{\tkz@min}{\tkz@init@xstep}% +\FPdiv\tkz@bb{\tkz@max}{\tkz@init@xstep}% +\begin{scope}[] + \path[ fill, + xshift = -\tkz@x@delta cm, + yshift = -\tkz@y@delta cm, + color = \tkz@fct@color,% + fill opacity = \tkz@fct@opacity,#1, + domain = \tkz@ba:\tkz@bb, + samples = \tkz@fct@samples]% + (\tkz@ba,0)--plot [id = \tkz@fct@id]% + function{(\tkzFctgnuLast)/\tkz@init@ystep}--(\tkz@bb,0); + \end{scope} +\endgroup +} +\let\tkzDrawArea\tkzArea +%<---------------------------------------------------------------------------> +% tkzAreafg +%<---------------------------------------------------------------------------> +\pgfkeys{/tkzareafg/.cd, +domain/.code args={#1:#2} {\FPeval\tkz@min{(#1)} + \FPeval\tkz@max{(#2)}}, +between/.code args={#1 and #2}{\def\tkz@below{#1} + \def\tkz@above{#2}}, +opacity/.code = {\edef\tkz@fct@opacity{#1}}, +id/.code = {\edef\tkz@fct@id{#1}}, +color/.code = {\edef\tkz@fct@color{#1}}, +samples/.code = {\edef\tkz@fct@samples{#1}}, +/tkzareafg/.unknown/.code = {\let\searchname=\pgfkeyscurrentname + \pgfkeysalso{\searchname/.try=#1, + /tikz/\searchname/.retry=#1}}} +\def\tkzAreafg{\pgfutil@ifnextchar[{\tkz@airefg}{\tkz@airefg[]}} +\def\tkz@airefg[#1]{% +\begingroup +\pgfkeys{/tkzareafg/.cd, +domain = -5:5, +between = a and b, +color = lightgray, +samples = 200, +id = tkzfonct, +opacity = .5 +} +\pgfqkeys{/tkzareafg}{#1} +\def\tkz@fctsup{\csname tkzFctgnu\tkz@below\endcsname} +\def\tkz@fctinf{\csname tkzFctgnu\tkz@above\endcsname} +\iftkz@init@NO% + \FPdiv{\tkz@x@delta}{\tkz@init@xorigine}{\tkz@init@xstep}% + \FPdiv{\tkz@y@delta}{\tkz@init@yorigine}{\tkz@init@xstep}% +\else + \FPset{\tkz@x@delta}{0} + \FPset{\tkz@y@delta}{0}% +\fi% +% essai du test sur xstep +\def\x{(x*\tkz@init@xstep)} +\FPdiv\tkz@ba{\tkz@min}{\tkz@init@xstep} +\FPdiv\tkz@bb{\tkz@max}{\tkz@init@xstep} +\begin{scope}[domain = \tkz@ba:\tkz@bb, + samples = \tkz@fct@samples, + id = \tkz@fct@id] + \clip (\tkz@ba,\tkz@ya)--plot function{(\tkz@fctsup)/\tkz@init@ystep}% + --(\tkz@bb,\tkz@ya);% + \clip (\tkz@ba,\tkz@yb)--plot function{(\tkz@fctinf)/\tkz@init@ystep}% + --(\tkz@bb,\tkz@yb); + \fill [color = \tkz@fct@color, + fill opacity = \tkz@fct@opacity, + /tkzareafg/.cd, + #1]% + (\tkz@ba,\tkz@ya) rectangle (\tkz@bb,\tkz@yb); +\end{scope} +\endgroup +} +\let\tkzDrawAreafg\tkzAreafg +\def\tkz@pamin{-5}\def\tkz@pamax{5} +%<---------------------------------------------------------------------------> +% tkzFctPar +%<---------------------------------------------------------------------------> +\def\tkzFctPar{\pgfutil@ifnextchar[{\catcode`\:=12 \tkz@fctp}{\tkz@fctp[]}} +\def\tkz@fctp[#1]#2#3{% +\begingroup +\pgfkeys{% +/tkzfct/.cd, +domain = \tkz@pamin:\tkz@pamax, +samples = 200, +fp = true, +id = tkzfct} +\pgfqkeys{/tkzfct}{#1} + \iftkz@init@NO% + \FPdiv{\tkz@x@delta}{\tkz@init@xorigine}{\tkz@init@xstep}% + \FPdiv{\tkz@y@delta}{\tkz@init@yorigine}{\tkz@init@ystep}% + \else + \FPset{\tkz@x@delta}{0} + \FPset{\tkz@y@delta}{0}% + \fi% + \begin{scope}[samples = \tkz@fct@samples] + \tkzActivOff + \clip (\tkz@xa,\tkz@ya) rectangle (\tkz@xb,\tkz@yb); + \draw [xshift = -\tkz@x@delta cm,% + yshift = -\tkz@y@delta cm, + /tkzfct/.cd, #1]% + plot [parametric,domain = \tkz@min:\tkz@max,% + id = tkzparfct]% + function {(#2)/\tkz@init@xstep,(#3)/\tkz@init@ystep}; + \tkzActivOn + \end{scope} +\endgroup +} +%<---------------------------------------------------------------------------> +% tkzFctPolar +%<---------------------------------------------------------------------------> +\def\tkz@pomin{0}\def\tkz@pomax{2*pi} +\def\tkzFctPolar{\pgfutil@ifnextchar[{% + \catcode`\:=12 \tkz@FctPolar}{\tkz@FctPolar[]}} +\def\tkz@FctPolar[#1]#2{% +\begingroup +\pgfkeys{% +/tkzfct/.cd, +domain = \tkz@pomin:\tkz@pomax, +fp = true, +samples = 200, +id = tkzfctpolar} +\pgfqkeys{/tkzfct}{#1} + \iftkz@init@NO% + \FPdiv{\tkz@x@delta}{\tkz@init@xorigine}{\tkz@init@xstep}% + \FPdiv{\tkz@y@delta}{\tkz@init@yorigine}{\tkz@init@ystep}% + \else + \FPset{\tkz@x@delta}{0} + \FPset{\tkz@y@delta}{0}% + \fi% + + \begin{scope} + \tkzActivOff + \draw [xshift = -\tkz@x@delta cm,% + yshift = -\tkz@y@delta cm, + /tkzfct/.cd, #1]% + plot [raw gnuplot,id = tkzpolarfct]% + function { set polar;set samples \tkz@fct@samples ; set trange [\tkz@min:\tkz@max]; plot (#2)/\tkz@init@xstep}; + \tkzActivOn + \end{scope} +\endgroup +} +%<---------------------------------------------------------------------------> +% tkzDrawRiemannSum +%<---------------------------------------------------------------------------> +\pgfkeys{/tkzriemann/.cd, +interval/.code args={#1:#2} {\FPeval\tkz@min{(#1)} + \FPeval\tkz@max{(#2)}}, +number/.code = {\edef\tkz@fct@nb{#1}}, +opacity/.code = {\edef\tkz@fct@opacity{#1}}, +color/.code = {\edef\tkz@fct@color{#1}}, +/tkzriemann/.unknown/.code = {\let\searchname=\pgfkeyscurrentname + \pgfkeysalso{\searchname/.try=#1, + /tikz/\searchname/.retry=#1}}} \def\tkzDrawRiemannSum{\pgfutil@ifnextchar[{% + \catcode`\:=12 \tkz@DrawRiemannSum}{\tkz@DrawRiemannSum[]}} +\def\tkz@DrawRiemannSum[#1]{% +\begingroup +\pgfkeys{% +/tkzriemann/.cd, +interval = 1:2, +number = 10, +opacity = 0.5, +line width = 1pt} +\pgfqkeys{/tkzriemann}{#1} + \iftkz@init@NO% + \FPdiv{\tkz@x@delta}{\tkz@init@xorigine}{\tkz@init@xstep}% + \FPdiv{\tkz@y@delta}{\tkz@init@yorigine}{\tkz@init@ystep}% + \else + \FPset{\tkz@x@delta}{0} + \FPset{\tkz@y@delta}{0}% + \fi% +\FPadd\tkz@intwd{\tkz@max}{-\tkz@min} +\FPdiv\tkz@delta{\tkz@intwd}{\tkz@fct@nb} +\FPadd\tkz@fct@nb{\tkz@fct@nb}{-1} + \begin{scope} +\foreach \i in {0,1,...,\tkz@fct@nb}{% + \FPeval\x{(\tkz@min+i*\tkz@delta)} + \FPeval\tkz@fx{\tkzFcta} + \FPadd\tkz@next{\x}{\tkz@delta} + \draw[color=\tkz@fct@color,opacity=\tkz@fct@opacity,/tkzriemann/.cd,#1] (\x ,0 ) rectangle (\tkz@next , \tkz@fx/\tkz@init@ystep ); + } + \end{scope} +\endgroup +} +%<---------------------------------------------------------------------------> +% tkzDrawRiemannSumInf +%<---------------------------------------------------------------------------> +\pgfkeys{/tkzriemann/.cd, +interval/.code args={#1:#2} {\FPeval\tkz@min{(#1)} + \FPeval\tkz@max{(#2)}}, +number/.code = {\edef\tkz@fct@nb{#1}}, +opacity/.code = {\edef\tkz@fct@opacity{#1}}, +color/.code = {\edef\tkz@fct@color{#1}}, +/tkzriemann/.unknown/.code = {\let\searchname=\pgfkeyscurrentname + \pgfkeysalso{\searchname/.try=#1, + /tikz/\searchname/.retry=#1}}} \def\tkzDrawRiemannSumInf{\pgfutil@ifnextchar[{% + \catcode`\:=12 \tkz@DrawRiemannSumInf}{\tkz@DrawRiemannSumInf[]}} +\def\tkz@DrawRiemannSumInf[#1]{% +\begingroup +\pgfkeys{% +/tkzriemann/.cd, +interval = 1:2, +number = 10, +opacity = 0.5, +line width = 1pt} +\pgfqkeys{/tkzriemann}{#1} + \iftkz@init@NO% + \FPdiv{\tkz@x@delta}{\tkz@init@xorigine}{\tkz@init@xstep}% + \FPdiv{\tkz@y@delta}{\tkz@init@yorigine}{\tkz@init@ystep}% + \else + \FPset{\tkz@x@delta}{0} + \FPset{\tkz@y@delta}{0}% + \fi% +\FPadd\tkz@intwd{\tkz@max}{-\tkz@min} +\FPdiv\tkz@delta{\tkz@intwd}{\tkz@fct@nb} +\FPadd\tkz@fct@nb{\tkz@fct@nb}{-1} + +\begin{scope} +\foreach \i in {0,1,...,\tkz@fct@nb}{% + \FPeval\x{(\tkz@min+i*\tkz@delta)} + \FPeval\tkz@fx{\tkzFcta} + \let\tkz@firstimg\tkz@fx + \let\tkz@firstx\x + \FPadd\tkz@next{\x}{\tkz@delta} + \let\tkzFctTmp\tkzFcta + \FPset\x{\tkz@next} + \FPeval\tkz@fxnext{\tkzFcta} +\ifdim \tkz@fx pt < \tkz@fxnext pt\relax + \draw[opacity=\tkz@fct@opacity,/tkzriemann/.cd,#1] (\tkz@firstx ,0 ) rectangle (\tkz@next , \tkz@firstimg/\tkz@init@ystep ); +\else +\draw[opacity=\tkz@fct@opacity,/tkzriemann/.cd,#1] (\tkz@firstx ,0 ) rectangle (\tkz@next , \tkz@fxnext/\tkz@init@ystep ); + \fi + } + \end{scope} +\endgroup +} +%<---------------------------------------------------------------------------> +% tkzDrawRiemannSumSup +%<---------------------------------------------------------------------------> + +\def\tkzDrawRiemannSumSup{\pgfutil@ifnextchar[{% + \catcode`\:=12 \tkz@DrawRiemannSumSup}{\tkz@DrawRiemannSumSup[]}} +\def\tkz@DrawRiemannSumSup[#1]{% +\begingroup +\pgfkeys{% +/tkzriemann/.cd, +interval = 1:2, +number = 10, +opacity = 0.5, +line width = 1pt} +\pgfqkeys{/tkzriemann}{#1} + \iftkz@init@NO% + \FPdiv{\tkz@x@delta}{\tkz@init@xorigine}{\tkz@init@xstep}% + \FPdiv{\tkz@y@delta}{\tkz@init@yorigine}{\tkz@init@ystep}% + \else + \FPset{\tkz@x@delta}{0} + \FPset{\tkz@y@delta}{0}% + \fi% +\FPadd\tkz@intwd{\tkz@max}{-\tkz@min} +\FPdiv\tkz@delta{\tkz@intwd}{\tkz@fct@nb} +\FPadd\tkz@fct@nb{\tkz@fct@nb}{-1} + +\begin{scope} +\foreach \i in {0,1,...,\tkz@fct@nb}{% + \FPeval\x{(\tkz@min+i*\tkz@delta)} + \FPeval\tkz@fx{\tkzFcta} + \let\tkz@firstimg\tkz@fx + \let\tkz@firstx\x + \FPadd\tkz@next{\x}{\tkz@delta} + \let\tkzFctTmp\tkzFcta + \FPset\x{\tkz@next} + \FPeval\tkz@fxnext{\tkzFcta} +\ifdim \tkz@fx pt > \tkz@fxnext pt\relax + \draw[opacity=\tkz@fct@opacity,/tkzriemann/.cd,#1] (\tkz@firstx ,0 ) rectangle (\tkz@next , \tkz@firstimg/\tkz@init@ystep ); +\else +\draw[opacity=\tkz@fct@opacity,/tkzriemann/.cd,#1] (\tkz@firstx ,0 ) rectangle (\tkz@next , \tkz@fxnext/\tkz@init@ystep ); + \fi + } + \end{scope} +\endgroup +} +%<---------------------------------------------------------------------------> +% tkzDrawRiemannSumMid +%<---------------------------------------------------------------------------> + +\def\tkzDrawRiemannSumMid{\pgfutil@ifnextchar[{% + \catcode`\:=12 \tkz@DrawRiemannSumMid}{\tkz@DrawRiemannSumMid[]}} +\def\tkz@DrawRiemannSumMid[#1]{% +\begingroup +\pgfkeys{% +/tkzriemann/.cd, +interval = 1:2, +number = 10, +opacity = 0.5, +line width = 1pt} +\pgfqkeys{/tkzriemann}{#1} + \iftkz@init@NO% + \FPdiv{\tkz@x@delta}{\tkz@init@xorigine}{\tkz@init@xstep}% + \FPdiv{\tkz@y@delta}{\tkz@init@yorigine}{\tkz@init@ystep}% + \else + \FPset{\tkz@x@delta}{0} + \FPset{\tkz@y@delta}{0}% + \fi% +\FPadd\tkz@intwd{\tkz@max}{-\tkz@min} +\FPdiv\tkz@delta{\tkz@intwd}{\tkz@fct@nb} +\FPadd\tkz@fct@nb{\tkz@fct@nb}{-1} + +\begin{scope} +\foreach \i in {0,1,...,\tkz@fct@nb}{% + \FPeval\x{(\tkz@min+i*\tkz@delta)} + \FPeval\tkz@fx{\tkzFcta} + \let\tkz@firstimg\tkz@fx + \let\tkz@firstx\x + \FPadd\tkz@next{\x}{\tkz@delta} + \FPset\x{\tkz@next} + \FPeval\tkz@fxnext{\tkzFcta} + \FPeval\tkz@midimg{(\tkz@firstimg+\tkz@fxnext)/2} + + \draw[opacity=\tkz@fct@opacity,/tkzriemann/.cd,#1] (\tkz@firstx ,0 ) rectangle (\tkz@next , \tkz@midimg/\tkz@init@ystep ); + } + \end{scope} +\endgroup +} + +%<--------------------------------------------------------------------------–> +% tkzXH F rien T et [ ou ] +%<--------------------------------------------------------------------------–> +\def\tkz@ComT{v} % need + +\pgfkeys{ + tkzxh/.cd, + posgrad/.code = {\def\tkz@tkzXh@posgrad{#1}}, + left/.code = {\def\tkz@tkzXh@left{#1}}, + right/.code = {\def\tkz@tkzXh@right{#1}}, + color/.code = {\def\tkz@tkzXh@color{#1}}, + } +\def\tkzXH{\pgfutil@ifnextchar[{\tkz@xh}{\tkz@xh[]}} +\def\tkz@xh[#1]#2{% +\pgfkeys{/tkzxh/.cd, + posgrad = {below=6 pt}, + color = \tkz@mainlinecolor, + left = {}, + right = {} +} + \pgfqkeys{/tkzxh}{#1} +\begingroup +\foreach \xA/\RA/\sA/\xB/\RB/\sB in {#2}{% + \tkzDefPoint(\xA,0){deb}\tkzDefPoint(\xB,0){fin} + \begin{scope}[decoration={border,angle=-45, + amplitude=0.3cm,segment length=2mm,raise=0.1cm}] + \draw[decorate,\tkz@tkzXh@color,thick] (deb) -- (fin); + \node at (deb) {\Large\textbf{\sA}}; + \node at (fin) {\Large\textbf{\sB}}; +\ifx\RA\tkz@ComT + \protected@edef\tkz@temp{% + \noexpand\node[\tkz@tkzXh@posgrad]}\tkz@temp at (deb){% + \tkz@showgrad{\xA}$\numprint{\tkz@result}$};\fi + +\ifx\RB\tkz@ComT + \protected@edef\tkz@temp{\noexpand\node[\tkz@tkzXh@posgrad]}\tkz@temp% + at (fin){% + \tkz@showgrad{\xB}$\numprint{\tkz@result}$};\fi + +\protected@edef\tkz@temp{% + \noexpand\node[\tkz@tkzXh@posgrad]}\tkz@temp at (\tkz@xa,0) {\tkz@tkzXh@left};% +\protected@edef\tkz@temp{\noexpand\node[\tkz@tkzXh@posgrad]}\tkz@temp% + at (\tkz@xb,0) {\tkz@tkzXh@right}; +\end{scope} +}% +\endgroup +}% +%<---------------------------------------------------------------------------> +% tangente obsolete +%<---------------------------------------------------------------------------> +\def\tkzTan{\pgfutil@ifnextchar[{\tkz@Tan}{\tkz@Tan[]}} + +\def\tkz@Tan[#1]#2(#3)#{ +\pgfkeys{/tkztan/.cd, +draw = false, +with={}, +kr = 1, +kl = 1} +\pgfqkeys{/tkztan}{#1} + \global\edef\tkz@opttan{#1} + \FPeval\x{(#3)}% + \FPeval\tkz@img{#2} + \let\tkz@yy #2% + \let\tkz@xx\x% + \let\tkz@old@img\tkz@img + \tkz@@Tan +} +\def\tkz@@Tan#1{% +\FPdiv{\tkz@old@x}{\x}{1} +\let\tkz@nexpty\tkz@img +\tkz@ptStar[](\tkz@old@x,\tkz@nexpty){#1} +\FPdiv{\tkz@krx}{\tkz@tan@kr}{\tkz@tmp@xstep} +\FPdiv{\tkz@kry}{\tkz@tan@kr}{\tkz@init@ystep} +\FPdiv{\tkz@klx}{\tkz@tan@kl}{\tkz@tmp@xstep} +\FPdiv{\tkz@kly}{\tkz@tan@kl}{\tkz@init@ystep} + % demi tgt--> droite +\FPifzero{\tkz@tan@kr}% +\else +\FPadd{\x}{\tkz@xx}{0.000001}% +\FPeval\tkz@img{\tkz@yy}% +\FPadd{\tkz@deltay}{\tkz@old@img}{-\tkz@img}% +\FPmul{\tkz@slope}{\tkz@deltay}{1000000}% +\protected@edef\tkz@temp{ + \noexpand\draw[tan style,/tkztan/.cd,\tkz@opttan,-]}\tkz@temp% + (#1)--++(\tkz@krx,-\tkz@kry*\tkz@slope); +\fi +% demi tgt --> gauche +\FPifzero{\tkz@tan@kl}% + \else +\FPadd{\x}{\tkz@xx}{-0.000001} +\FPeval\tkz@img{\tkz@yy}% +\FPadd{\tkz@deltay}{\tkz@old@img}{-\tkz@img} +\FPmul{\tkz@slope}{\tkz@deltay}{-1000000} + \protected@edef\tkz@temp{ + \noexpand +\draw[tan style,/tkztan/.cd,\tkz@opttan,-]}\tkz@temp% + (#1)--++(-\tkz@klx,\tkz@kly*\tkz@slope); + \fi +} +%<---------------------------------------------------------------------------> +% point d'une courbe obsolete +%<---------------------------------------------------------------------------> +\def\tkzFctPt{\pgfutil@ifnextchar[{\tkz@fctpt}{\tkz@fctpt[]}} +\def\tkz@fctpt[#1]#2(#3)#{% + \global\edef\tkz@optptfct{#1} + \FPeval\x{(#3)}% + \FPeval\tkz@y{#2} + \tkz@defpoint +} +\def\tkz@defpoint#1{ + \tkzDefPoint(\x,\tkz@y){#1} +\protected@edef\tkz@temp{ + \noexpand \tkzDrawPoint[\tkz@optptfct](#1)}\tkz@temp + \let\tkz@init@xstep\tkz@tmp@xstep +} +%<-------------------------- the end ---------------------------------------> +\endinput + +
\ No newline at end of file |