在此 MWE 中,有@Jake 的答案的帮助如何制作椭圆的切线以及与其平行的线?
但是我没能成功利用我tangent=0.35
后来得到的这个点将其与 F1 和 F2 连接起来。换句话说:省略线上的蓝点和黑点应该相同,但是我怎样才能在不猜测我画切线的点的角度的情况下获得精确的点呢?
\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{calc,decorations.markings,intersections}
\usepackage{pgfplots}
\pgfplotsset{compat=1.15}
\begin{document}
\begin{tikzpicture}[
dot/.style={draw,fill,circle,inner sep=1pt},
tangent/.style={
decoration={
markings,% switch on markings
mark=
at position #1
with
{
\coordinate (tangent point-\pgfkeysvalueof{/pgf/decoration/mark info/sequence number}) at (0pt,0pt);
\coordinate (tangent unit vector-\pgfkeysvalueof{/pgf/decoration/mark info/sequence number}) at (1,0pt);
\coordinate (tangent orthogonal unit vector-\pgfkeysvalueof{/pgf/decoration/mark info/sequence number}) at (0pt,1);
}
},
postaction=decorate
},
use tangent/.style={
shift=(tangent point-#1),
x=(tangent unit vector-#1),
y=(tangent orthogonal unit vector-#1)
},
use tangent/.default=1
]
\def\a{4} % major half axis
\def\b{2} % minor half axis
\draw[thick, tangent=0.35] (0,0) ellipse ({\a} and {\b});
\fill (tangent point-1) circle [radius=2pt];
\draw [use tangent] (2,0) -- (-2,0);
\def\angle{125} % angle for point on ellipse
%Labelling the foci
\node[dot,label={below:$F_1$}] (F1) at ({-sqrt(\a*\a-\b*\b)},0) {};
\node[dot,label={below:$F_2$}] (F2) at ({+sqrt(\a*\a-\b*\b)},0) {};
%Point on ellipsis
\node[dot,label={\angle:$P$},blue] (P) at (\angle:{\a} and {\b}) {};
\draw (F1) -- (P) (P) -- (F2);
\end{tikzpicture}
\end{document}
答案1
tkz-euclide
借助宏的帮助bisector out
,这非常简单。这可以在简单的 Ti 中实现钾Z 与calc
库有关,但这里只是一条简单的线来获取切线。
\documentclass[tikz,border=3.14mm]{standalone}
\usepackage{tkz-euclide}
\usetikzlibrary{calc}
\begin{document}
\begin{tikzpicture}[dot/.style={draw,fill,circle,inner sep=1pt},]
\def\a{4} % major half axis
\def\b{2} % minor half axis
\draw[thick] (0,0) ellipse ({\a} and {\b});
\node[dot,label={below:$F_1$}] (F1) at ({-sqrt(\a*\a-\b*\b)},0) {};
\node[dot,label={below:$F_2$}] (F2) at ({+sqrt(\a*\a-\b*\b)},0) {};
\def\angle{125} % angle for point on ellipse
\node[dot,label={\angle:$P$},blue] (P) at (\angle:{\a} and {\b}) {};
\draw (F1) -- (P) -- (F2);
\tkzDefLine[bisector out](F1,P,F2) \tkzGetPoint{K}
\draw ($(K)!-2!(P)$)--($(P)!-2.5!(K)$);
\end{tikzpicture}
\end{document}
我通常更喜欢在可能的情况下将所有内容都编码进去tkz-euclide
,但我认为您会保留原始代码。
答案2
当你在等待 TikZ 骑兵时,这是我早些时候做的元帖子以供比较。
Metapost 有一个很有用的概念,即沿路径的(分数)点。对于椭圆形,从“3 点”开始有 8 个点。
point t of E
给出该点的一对坐标direction t of E
给出一对表示该点切线的数值
为了画出一条漂亮的线条,我曾经angle
找到旋转direction
并将其应用到已知线条上......
\documentclass[border=5mm]{standalone}
\usepackage{luamplib}
\begin{document}
\mplibtextextlabel{enable}
\begin{mplibcode}
vardef focus(expr e, n) =
numeric a,b;
a = arclength (point 0 of e .. center e);
b = arclength (point 2 of e .. center e);
((a+-+b)/a)[center e, point if n=1: 4 else: 0 fi of e]
enddef;
beginfig(1);
path E; E = fullcircle xscaled 233 yscaled 144 rotated 8;
numeric t; t = 2.7182818;
z0 = point t of E;
z1 = focus(E,1);
z2 = focus(E,2);
path tangent;
tangent = (left--right) scaled 42
rotated angle direction t of E
shifted point t of E;
drawoptions(withcolor 3/4);
draw point 0 of E -- point 4 of E withcolor .7 white;
draw point 2 of E -- point 6 of E withcolor .7 white;
drawoptions(withcolor 3/4 red);
draw tangent;
draw z1 -- z0 -- z2;
drawoptions(withcolor 5/8 blue);
draw E;
drawoptions();
dotlabel.lrt(btex $F_1$ etex, z1);
dotlabel.lrt(btex $F_2$ etex, z2);
dotlabel.ulft(btex $P$ etex, z0);
endfig;
\end{mplibcode}
\end{document}
提供的focus
例程会进行算术运算,根据给定的椭圆路径找到焦点。这包含在 中,luamplib
因此可以使用 进行编译lualatex
。
答案3
几何方法利用了这样一个事实:椭圆上某一点的法线是从该点到两个焦点的角度的内部平分线。TikZ 的方法是这里使用用户定义的命令bisectorpoint
。
在 Asymptote 中,角平分线方向是内置命令。
pair dir(path p, path q)
returns unit(dir(p)+dir(q)).
尤其,
pair Mn=M+dir(M--F1,M--F2);
pair Mt=rotate(90,M)*Mn;
Mn
给出椭圆法线上的点和Mt
M处切线上的点。
unitsize(1cm);
real a=3, b=2;
real c=sqrt(a^2-b^2);
pair F1=(-c,0), F2=(c,0);
real t=130;
pair M=(a*Cos(t),b*Sin(t)); // a point on the ellipse
// M--Mn is the internal bisector of MF1 and MF2
pair Mn=M+dir(M--F1,M--F2);
pair Mt=rotate(90,M)*Mn;
dot(F1^^F2,gray);
draw((a+1,0)--(-a-1,0)^^(0,b+.5)--(0,-b-.5),gray);
draw(F1--M--F2,gray);
draw(ellipse((0,0),a,b));
draw(interp(M,Mt,-2)--interp(M,Mt,1.5),red);
draw(interp(M,Mn,-1)--interp(M,Mn,1.5),blue);
label("$F_1$",F1,S);
label("$F_2$",F2,S);
label("$M$",M+.4*dir(165));
答案4
使用tzplot
:
\documentclass[border=1mm]{standalone}
\usepackage{tzplot}
\begin{document}
\begin{tikzpicture}[scale=1.4]
\def\a{4} % major half axis
\def\b{2} % minor half axis
\tzbbox(-4,-2)(4,2.2)
\settzdotsize{4pt}
\tzellipse[thick]"AA"(0,0)({\a} and {\b})
\tzvXpointat*{AA}{-2.5}(P){$P$}
\tztangent{AA}(P)[-4:-1]
\tzcoors*({-sqrt(\a*\a-\b*\b)},0)(F1){$F_1$}[b]({+sqrt(\a*\a-\b*\b)},0)(F2){$F_2$}[b];
\tzlines(F1)(P)(F2);
\end{tikzpicture}
\end{document}