如何用 TikZ 绘制曲柄滑块机构的曲线?

如何用 TikZ 绘制曲柄滑块机构的曲线?

我不知道如何绘制这么复杂的曲线,即使我得到了它的参数方程和隐式方程。

曲线的参数方程

\begin{cases}    
\begin{split}        
x&=r\sin\left(t\right)+\frac{L}{R}\sqrt{R^2-r^2\cos^2\left(t\right)}\\  
y&=\left(1-\frac{L}{R}\right)r\cos\left(t\right)  
\end{split}    
\end{cases}

曲线隐式方程:

\[x^4-2\left(L^2+r^2-\frac{\left(L^2+R^2\right)y^2}{\left(L-R\right)^2}\right)x^2+\left(L^2-r^2-\frac{\left(L^2-R^2\right)y^2}{\left(L-R\right)^2}\right)^2=0\]

O-orange:r=1.5;
orange-red:L=2.5;
orange-blake:R=6;

在此处输入图片描述

答案1

你可以plot直接得到参数方程。比如

\def\r{1.5}
\def\L{2.5}
\def\R{6}
\draw plot[domain=0:360] ({\r*sin(\x)+\L/\R*sqrt(\R*\R-\r*\r*cos(\x)*cos(\x))},{(1-\L/\R)*\r*cos(\x)});

将绘制曲线。

一个完整的例子可能是:

\documentclass[border=2mm]{standalone}
\usepackage    {tikz}
\usetikzlibrary{calc}

\begin{document}
\begin{tikzpicture}[line cap=round,line join=round]
% dimensions
\def\r{1.5}
\def\L{2.5}
\def\R{6}
\def\a{60}                              % orange line angle
\pgfmathsetmacro\b{asin(\r/\R*sin(\a))} % blue line angle
% axes and grid
\draw[gray,step=0.5] (-2.25,-2.25) grid (8.75,2.25);
\draw[step=2]        (-2.25,-2.25) grid (8.75,2.25);
\draw[thick]         (-2.25,0) -- (8.75,0);
\draw[thick]         (0,-2.25) -- (0,2.25);
\foreach\i in {\R-\r,\R+\r}
{%
  \draw[thick] (\i-0.05,-0.05) --++ (0.1,0.1);
  \draw[thick] (\i+0.05,-0.05) --++ (-0.1,0.1);
}
% curve 
\draw[red,dashed] plot[domain=0:360,samples=100] ({\r*sin(\x)+\L/\R*sqrt(\R*\R-\r*\r*cos(\x)*cos(\x))},{(1-\L/\R)*\r*cos(\x)});
% segments
\coordinate (O) at (0,0);
\coordinate (A) at (\a:\r);
\coordinate (C) at ($(A)+(-\b:\R)$);
\coordinate (B) at ($(A)!{\L/\R}!(C)$);
\draw[thick,orange] (O) -- (A);
\draw[thick,blue]   (A) -- (C);
\draw[orange,thick,fill=white] (A) circle (1pt);
\draw[orange,thick,fill=white] (B) circle (1pt);
\draw[thick,fill=white] (C) circle (1pt);
\end{tikzpicture}
\end{document}

在此处输入图片描述

并且,如果改变角度值\a

\documentclass    {beamer}
\usepackage       {tikz}
\usetikzlibrary   {calc}
\setbeamertemplate{navigation symbols}{}

\begin{document}
\begin{frame}
\begin{figure}\centering
\begin{tikzpicture}[line cap=round,line join=round]
% dimensions
\def\r{1.5}
\def\L{2.5}
\def\R{6}
% axes and grid
\draw[gray,step=0.5] (-2.25,-2.25) grid (8.75,2.25);
\draw[step=2]        (-2.25,-2.25) grid (8.75,2.25);
\draw[thick]         (-2.25,0) -- (8.75,0);
\draw[thick]         (0,-2.25) -- (0,2.25);
\foreach\i in {\R-\r,\R+\r}
{%
  \draw[thick] (\i-0.05,-0.05) --++  (0.1,0.1);
  \draw[thick] (\i+0.05,-0.05) --++ (-0.1,0.1);
}
% curve
\draw[red,dashed] plot[domain=0:360,samples=100] ({\r*sin(\x)+\L/\R*sqrt(\R*\R-\r*\r*cos(\x)*cos(\x))},{(1-\L/\R)*\r*cos(\x)});
% segments
\coordinate (O) at (0,0);
\foreach\i in {1,...,36}
{%
  \only<\i>
  {%
    \pgfmathsetmacro\a{10-10*\i}            % orange line angle
    \pgfmathsetmacro\b{asin(\r/\R*sin(\a))} % blue line angle
    \coordinate (A) at (\a:\r);
    \coordinate (C) at ($(A)+(-\b:\R)$);
    \coordinate (B) at ($(A)!{\L/\R}!(C)$);
    \draw[thick,orange] (O) -- (A);
    \draw[thick,blue]   (A) -- (C);
    \draw[orange,thick,fill=white] (A) circle (1pt);
    \draw[orange,thick,fill=white] (B) circle (1pt);
    \draw       [thick,fill=white] (C) circle (1pt);
  }
}
\end{tikzpicture}
\end{figure}
\end{frame}
\end{document}

在此处输入图片描述

相关内容