沿旋转的椭圆按设定的间隔创建切线

沿旋转的椭圆按设定的间隔创建切线

我正在尝试以较小的间隔绘制旋转椭圆的切线,但我不确定最好的方法是什么。我可以从 Wolfram Alpha 获取斜率,但我不想对线条进行硬编码。

我的代码:

\documentclass [10pt] {article}
\usepackage{pgfplots}
\usetikzlibrary{intersections, calc}
\usepackage{tikz}
\begin{document}
\begin{center}
\begin{tikzpicture}[scale=0.75]
    \draw[step=1cm,gray,very thin,dashed] (-2.9,-2.9) grid (2.9,2.9);
    \draw[rotate around={45:(0,0)}][thick] (0,0) ellipse (2.449cm and 1.414cm);
    \draw[thick,black,<->](0,-2.9)--(0,2.9);
    \draw[thick,black,<->](-2.9,0)--(2.9,0);
\end{tikzpicture}
\end{center}
\end{document}

所以现在它只是一个普通的椭圆:

倾斜椭圆

但我想要类似这样的东西:

带切线的倾斜椭圆

尽管椭圆上有更多线条,但点也更多。我该怎么做呢?

答案1

像这样吗?

浓烈的

这使用了一种新的装饰,tangy作为postaction主路径绘制之后的装饰:

\documentclass[border=10pt,tikz]{standalone}
\usetikzlibrary{decorations}
\pgfdeclaredecoration{tangy}{initial}{
  \state{initial}[width=10pt]
  {
    \pgfpathmoveto{\pgfpoint{25pt}{0}}
    \pgfpathlineto{\pgfpoint{-25pt}{0}}
    \pgfpathmoveto{\pgfpoint{+10pt}{0}}
  }
  \state{final}
  {
    \pgfpathmoveto{\pgfpointdecoratedpathlast}
  }
}
\begin{document}
\begin{tikzpicture}[scale=0.75]
    \draw [step=1cm,gray, very thin, dashed] (-2.9,-2.9) grid (2.9,2.9);
    \draw [rotate around={45:(0,0)}, thick, postaction={decorate, draw=red, thin, decoration={tangy}}] (0,0) ellipse (2.449cm and 1.414cm);
    \draw [thick, black, <->] (0,-2.9)--(0,2.9);
    \draw [thick, black, <->] (-2.9,0)--(2.9,0);
\end{tikzpicture}

这利用了这样一个事实:当声明装饰时,TikZ 会变换坐标系,使得 x 轴与当前路径相切。

答案2

元帖子,该direction t of p语法对于绘制切线很有用。我希望 TikZ 粉丝可以向您展示 TikZ 的等效语法。

在此处输入图片描述

prologues := 3;
outputtemplate := "%j%c.eps";

beginfig(1);

u = 1cm;
path xx, yy, ee;
xx = (left -- right) scaled 3u;
yy = xx rotated 90;

drawdblarrow xx;
drawdblarrow yy;

ee = fullcircle xscaled 4.828u yscaled 2.828u rotated 45;

for t = 0 step 1/4 until 8:
  draw (left--right) scaled 1.5 u 
                     rotated angle direction t of ee 
                     shifted point t of ee 
                     withcolor .67 blue;
endfor

draw ee withcolor .67 red;

endfig;
end.

您还需要知道路径fullcircle(以及椭圆)有 8 个点。

相关内容