如何确保在比例变化时交叉点的计算正确?

如何确保在比例变化时交叉点的计算正确?

我需要修改图表的比例,但两条线的交点计算是错误的

\documentclass{article}

\usepackage{tikz}   
\usetikzlibrary{calc,intersections}
\usepackage{esvect}

   
\begin{document}

Faux 

 \begin{tikzpicture}[x={(-1,0)},scale=0.9]
\coordinate (O) at (0,0);
\coordinate (Od) at ($(O)+(0.4,0)$);
\coordinate (Og) at ($(O)-(0.4,0)$);

\draw[dashed] ($(O)-(0,3.5)$) -- ($(O) +(0,1.5)$);
\draw[blue,thick,fill=green!40] (Og) --++(-4,0)coordinate(bout) coordinate[pos=0.8](Of)--++(0,-0.2) --++(3.7,-0.3) --++(0,-1.5)coordinate(Ob)-|(Og);
\draw[blue,thick,fill=green!40] (Od) --++(0.3,0)coordinate(Oa) -- (Ob-|Oa) -| (Od);
\draw[fill] (Od) coordinate(A) circle (0.05) node[above left]{$A$};
\draw[fill] (Og|-Ob) coordinate(B) circle (0.05) node[below right]{$B$};
\draw[latex-,ultra thick] (Of)node[above left]{$\vv{F}$}node[below]{$C$} -- ++(0,1.5);

\draw[thin, red,opacity=0.3,fill] ($(A) +(2,0.6)$) -- (A) --($(A) +(2,-0.6)$);
\draw[name path =aa, dashed,red] (A) --++(-5,-1.5);
\draw[ultra thick, red, -latex] (A) -- ++(3,0.9)node[above]{$\vv{R_A}$};
\draw[thin, red,opacity=0.3,fill] ($(B) +(-2,0.6)$) -- (B) --($(B) +(-2,-0.6)$);
\draw[ultra thick, red, -latex] (B) -- ++(-3,0.9)node[above]{$\vv{R_B}$};
\draw[name path =bb, dashed,red] (B) --++(-5,1.5);

\coordinate [name intersections={of=aa and bb, by=I}];
\draw [dashed, blue] (I)node[below]{$I$} --++(0,3);

\draw[thin,-latex] ($(O)+(0,1)$)coordinate(oo) -- node[above]{$x_{lim}$} (oo-|I);
\draw[-latex] (O) -- (-5,0) node[below]{$\vv{x}$};
\draw[-latex] (O) -- (0,2) node[right]{$\vv{y}$};
\end{tikzpicture}

Correct

 \begin{tikzpicture}[x={(-1,0)}]
\coordinate (O) at (0,0);
\coordinate (Od) at ($(O)+(0.4,0)$);
\coordinate (Og) at ($(O)-(0.4,0)$);


\draw[dashed] ($(O)-(0,3.5)$) -- ($(O) +(0,1.5)$);
\draw[blue,thick,fill=green!40] (Og) --++(-4,0)coordinate(bout) coordinate[pos=0.8](Of)--++(0,-0.2) --++(3.7,-0.3) --++(0,-1.5)coordinate(Ob)-|(Og);
\draw[blue,thick,fill=green!40] (Od) --++(0.3,0)coordinate(Oa) -- (Ob-|Oa) -| (Od);
\draw[fill] (Od) coordinate(A) circle (0.05) node[above left]{$A$};
\draw[fill] (Og|-Ob) coordinate(B) circle (0.05) node[below right]{$B$};
\draw[latex-,ultra thick] (Of)node[above left]{$\vv{F}$}node[below]{$C$} -- ++(0,1.5);

\draw[thin, red,opacity=0.3,fill] ($(A) +(2,0.6)$) -- (A) --($(A) +(2,-0.6)$);
\draw[name path =aa, dashed,red] (A) --++(-5,-1.5);
\draw[ultra thick, red, -latex] (A) -- ++(3,0.9)node[above]{$\vv{R_A}$};
\draw[thin, red,opacity=0.3,fill] ($(B) +(-2,0.6)$) -- (B) --($(B) +(-2,-0.6)$);
\draw[ultra thick, red, -latex] (B) -- ++(-3,0.9)node[above]{$\vv{R_B}$};
\draw[name path =bb, dashed,red] (B) --++(-5,1.5);

\coordinate [name intersections={of=aa and bb, by=I}];
\draw [dashed, blue] (I)node[below]{$I$} --++(0,3);

\draw[thin,-latex] ($(O)+(0,1)$)coordinate(oo) -- node[above]{$x_{lim}$} (oo-|I);
\draw[-latex] (O) -- (-5,0) node[below]{$\vv{x}$};
\draw[-latex] (O) -- (0,2) node[right]{$\vv{y}$};
\end{tikzpicture}
\end{document}

在此处输入图片描述

答案1

由于您用 重新定义单位x={(-1,0)},因此只需用 重新定义单位即可x={(-.9,0)}

正如@rpapa自己纠正的那样,为了达到同样的效果,需要对 y 做同样的事情[x={(-.9,0)},y={(0,.9)}]

\begin{tikzpicture}[x={(-.9,0)},y={(0,.9)}]

截屏

\documentclass{article}

\usepackage{tikz}   
\usetikzlibrary{calc,intersections}
\usepackage{esvect}

   
\begin{document}

Faux 

 \begin{tikzpicture}[x={(-.9,0)},y={(0,.9)}]
\coordinate (O) at (0,0);
\coordinate (Od) at ($(O)+(0.4,0)$);
\coordinate (Og) at ($(O)-(0.4,0)$);

\draw[dashed] ($(O)-(0,3.5)$) -- ($(O) +(0,1.5)$);
\draw[blue,thick,fill=green!40] (Og) --++(-4,0)coordinate(bout) coordinate[pos=0.8](Of)--++(0,-0.2) --++(3.7,-0.3) --++(0,-1.5)coordinate(Ob)-|(Og);
\draw[blue,thick,fill=green!40] (Od) --++(0.3,0)coordinate(Oa) -- (Ob-|Oa) -| (Od);
\draw[fill] (Od) coordinate(A) circle (0.05) node[above left]{$A$};
\draw[fill] (Og|-Ob) coordinate(B) circle (0.05) node[below right]{$B$};
\draw[latex-,ultra thick] (Of)node[above left]{$\vv{F}$}node[below]{$C$} -- ++(0,1.5);

\draw[thin, red,opacity=0.3,fill] ($(A) +(2,0.6)$) -- (A) --($(A) +(2,-0.6)$);
\draw[name path =aa, dashed,red] (A) --++(-5,-1.5);
\draw[ultra thick, red, -latex] (A) -- ++(3,0.9)node[above]{$\vv{R_A}$};
\draw[thin, red,opacity=0.3,fill] ($(B) +(-2,0.6)$) -- (B) --($(B) +(-2,-0.6)$);
\draw[ultra thick, red, -latex] (B) -- ++(-3,0.9)node[above]{$\vv{R_B}$};
\draw[name path =bb, dashed,red] (B) --++(-5,1.5);

\coordinate [name intersections={of=aa and bb, by=I}];
\draw [dashed, blue] (I)node[below]{$I$} --++(0,3);

\draw[thin,-latex] ($(O)+(0,1)$)coordinate(oo) -- node[above]{$x_{lim}$} (oo-|I);
\draw[-latex] (O) -- (-5,0) node[below]{$\vv{x}$};
\draw[-latex] (O) -- (0,2) node[right]{$\vv{y}$};
\end{tikzpicture}

Correct

 \begin{tikzpicture}[x={(-1,0)}]
\coordinate (O) at (0,0);
\coordinate (Od) at ($(O)+(0.4,0)$);
\coordinate (Og) at ($(O)-(0.4,0)$);


\draw[dashed] ($(O)-(0,3.5)$) -- ($(O) +(0,1.5)$);
\draw[blue,thick,fill=green!40] (Og) --++(-4,0)coordinate(bout) coordinate[pos=0.8](Of)--++(0,-0.2) --++(3.7,-0.3) --++(0,-1.5)coordinate(Ob)-|(Og);
\draw[blue,thick,fill=green!40] (Od) --++(0.3,0)coordinate(Oa) -- (Ob-|Oa) -| (Od);
\draw[fill] (Od) coordinate(A) circle (0.05) node[above left]{$A$};
\draw[fill] (Og|-Ob) coordinate(B) circle (0.05) node[below right]{$B$};
\draw[latex-,ultra thick] (Of)node[above left]{$\vv{F}$}node[below]{$C$} -- ++(0,1.5);

\draw[thin, red,opacity=0.3,fill] ($(A) +(2,0.6)$) -- (A) --($(A) +(2,-0.6)$);
\draw[name path =aa, dashed,red] (A) --++(-5,-1.5);
\draw[ultra thick, red, -latex] (A) -- ++(3,0.9)node[above]{$\vv{R_A}$};
\draw[thin, red,opacity=0.3,fill] ($(B) +(-2,0.6)$) -- (B) --($(B) +(-2,-0.6)$);
\draw[ultra thick, red, -latex] (B) -- ++(-3,0.9)node[above]{$\vv{R_B}$};
\draw[name path =bb, dashed,red] (B) --++(-5,1.5);

\coordinate [name intersections={of=aa and bb, by=I}];
\draw [dashed, blue] (I)node[below]{$I$} --++(0,3);

\draw[thin,-latex] ($(O)+(0,1)$)coordinate(oo) -- node[above]{$x_{lim}$} (oo-|I);
\draw[-latex] (O) -- (-5,0) node[below]{$\vv{x}$};
\draw[-latex] (O) -- (0,2) node[right]{$\vv{y}$};
\end{tikzpicture}
\end{document}

相关内容