[Tikz] Précision des calculs

Tout ce qui concerne le langage TeX/LaTeX et ses variantes. Ce langage est utilisable sur le forum via les balises tex.
[participation réservée aux utilisateurs inscrits]
Règles du forum
Merci de soigner la rédaction de vos messages et de consulter ce sujet avant de poster. Pensez également à utiliser la fonction recherche du forum.
zariski63
Utilisateur éprouvé
Utilisateur éprouvé
Messages : 525
Inscription : jeudi 14 octobre 2010, 09:20
Statut actuel : Enseignant
Localisation : Clermont-Ferrand

[Tikz] Précision des calculs

Message non lu par zariski63 »

Bonjour !
Quelqu'un pourrait-il me dire pourquoi j'ai une différence de valeurs (certes à la troisième décimale environ) entre les abscisses que donne tikz (en pt) et celles que je calcule en sachant que 1cm = 72,27/2,54 ?
Merci.

Code : Tout sélectionner

\documentclass{standalone}

\usepackage{lmodern}
\usepackage{fourier}
\usepackage[french]{babel}
\usepackage{enumitem}
   \frenchsetup{StandardLists=true}
\usepackage{xcolor}
  \definecolor{vertfonce}{rgb}{0,0.44,0}
  \definecolor{mauve}{rgb}{0.58,0,0.82}
\usepackage{tikz}
   \usetikzlibrary{intersections}
   \usetikzlibrary{calc}
   \usetikzlibrary{positioning}


\begin{document}

\begin{tikzpicture}%[scale=2,transform shape]
% Le repère
\draw[line width=0.05pt,fill=yellow!50!white,fill opacity=0.3] (0,0)rectangle(4,4);
\draw[line width=0.08pt,step=.2,lightgray] (0,0)grid(4,4);
\draw[line width=0.08pt,gray](0,0)grid(4,4);
% Les axes
\draw[-stealth](0,0)--(4,0)node[anchor=north east,font=\footnotesize]{$x$};
\draw[-stealth](0,0)--(0,4)node[anchor=north east,font=\footnotesize]{$y$};
% Les graduations
%\node[below left,font=\footnotesize] at (0,0){$O$};
\foreach \x in {1,2,...,3} \draw (\x,-0.1)--(\x,0) node[below,font=\footnotesize]{$\x$};
\foreach \y in {1,2,...,3} \draw (-0.1,\y)--(0,\y) node[left,font=\footnotesize]{$\y$};
% Tracés
\draw[name path =A, draw=red,line width=0.5pt]
    plot[samples=100,smooth,domain=0.25:4] (\x,{1/\x});
\draw[name path =B, draw=blue,line width=0.5pt]
    plot[samples=100,smooth,domain=1:4] (\x,{4/\x});
\draw[name path =C, draw=vertfonce,line width=0.5pt]
    plot[samples=100,smooth,domain=0:4] (\x,{(2*\x+3)/(\x+1)});
\draw[name path =D, draw=mauve,line width=0.5pt]
    plot[samples=100,smooth,domain=0:4] (\x,{(2*\x+3)/(2*\x+1)});
%
%\draw (0,2.8) node[fill=white,above]{$f(x)=\dfrac{1}{x}$};
%\draw (0,2.2) node[fill=white,above]{$g(x)=\dfrac{4}{x}$};
%\draw (0,2.2) node[fill=white,above]{$h(x)=\dfrac{2x+3}{x+1}$};
%\draw (0,2.2) node[fill=white,above]{$j(x)=\dfrac{2x+3}{2x+1}$};
%
\draw[name intersections = {of = A and C, by ={I}}];
\fill[fill=red](I) circle (1pt) node[line width=0.5pt,anchor=south east] {\footnotesize I};
%
\draw[name intersections = {of = A and D, by ={J}}];
\fill[fill=red](J) circle (1pt) node[line width=0.5pt,anchor=north east] {\footnotesize J};
%
\draw[name intersections = {of = B and D, by ={K}}];
\fill[fill=red](K) circle (1pt) node[line width=0.5pt,anchor=south] {\footnotesize K};
%
\draw[name intersections = {of = B and C, by ={L}}];
\fill[fill=red](L) circle (1pt) node[line width=0.5pt,anchor=south west] {\footnotesize L};
%Abscisses rendu par tikz
\draw (5.8,-0.5) node[font=\footnotesize]{Abscisse en pt rendu par tikz};
%
\draw[red,densely dotted,line width=0.4pt] let \p1=(I) in (\x1,\y1)--(\x1,0) node[red,below=0.3,font=\footnotesize]{\x1};
%
\draw[blue,densely dotted,line width=0.4pt] let \p1=(J) in (\x1,\y1)--(\x1,0) node[blue,below=0.6,font=\footnotesize]{\x1};
%
\draw[vertfonce,densely dotted,line width=0.4pt] let \p1=(K) in (\x1,\y1)--(\x1,0) node[vertfonce,below=0.3,font=\footnotesize]{\x1};
%
\draw[mauve,densely dotted,line width=0.4pt] let \p1=(L) in (\x1,\y1)--(\x1,0) node[mauve,below=0.3,font=\footnotesize]{\x1};
%Abscisses exactes
\draw (5,2.5) node[font=\footnotesize]{Abscisses en cm};
%
\draw (5,2) node[red,font=\footnotesize]{\pgfmathparse{(-2+sqrt(12))/4}\pgfmathresult \, cm ; };
\draw (5,1.5) node[blue,font=\footnotesize]{0.5 \, cm ; };
%
\draw (5,1) node[vertfonce,font=\footnotesize]{\pgfmathparse{(5+sqrt(57))/4}\pgfmathresult  \, cm ; };
\draw (5,0.5) node[mauve,font=\footnotesize]{\pgfmathparse{(1+sqrt(33))/4}\pgfmathresult  \, cm ; };
%Abscisses en pt US
\draw (7,2.5) node[font=\footnotesize]{Abscisses en pt};
%
\draw (7,2) node[red,font=\footnotesize]
              {\pgfmathparse{(-2+sqrt(12))/4*28.452755905}\pgfmathresult \, pt ; };
\draw (7,1.5) node[blue,font=\footnotesize]
              {\pgfmathparse{0.5*28.452755905}\pgfmathresult \, pt; };
%
\draw (7,1) node[vertfonce,font=\footnotesize]
              {\pgfmathparse{(5+sqrt(57))/4*28.452755905}\pgfmathresult  \, pt; };
\draw (7,0.5) node[mauve,font=\footnotesize]
              {\pgfmathparse{(1+sqrt(33))/4*28.452755905}\pgfmathresult  \, pt ; };
\end{tikzpicture}

\end{document}
rebouxo
Modérateur honoraire
Modérateur honoraire
Messages : 6962
Inscription : mercredi 15 février 2006, 13:18
Localisation : le havre
Contact :

Re: Tikz

Message non lu par rebouxo »

Ah en croire Alain Matthes dans la doc de l'extension tkz-eucl, les calculs avec pgf sont d'une précision peu fiable. Il préfère utiliser l'extension FP, plus précise.

Olivier
A line is a point that went for a walk. Paul Klee.
Par solidarité, pas de MP.
Répondre
  • Sujets similaires
    Réponses
    Vues
    Dernier message