
\usepackage{pict2e}
\usepackage{pstricks-add}
\usepackage{pst-node,pst-plot}
\psset{plotpoints=9,unit=3}
どういうわけか、さまざまな人のアドバイスに従って、上記のコード行を自分の行の上に置きました\begin{document}
。3 つのパッケージの内容の違いや最後のコマンドが何をするのかはわかりませんが、特定の場所に線や点、円、テキストを含む必要な簡単な図を描くことができました。
ここで、楕円を描きたいと思います。長軸と短軸の端点を指定できます。これらは奇妙な角度ではなく、水平と垂直です。また、曲線上に対称パターンで 4 つの点を指定することもできます。
それは可能ですか?
答え1
を使用するとpstricks
、非常に簡単に次のようになります。
\documentclass[a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\pagestyle{empty}
\usepackage[pdf, svgnames]{pstricks}%
\usepackage{pstricks-add}
\begin{document}
\begin{pspicture}
\psaxes{->}(0,0)(-6,-5)(7,5)
\psclip{
\psellipse[linewidth = 1.5pt, linecolor = Purple](1,-1)(4,3)}
\psset{linestyle = dashed, linewidth = 0.6pt}
\psline(1,-5)(1,7)\psline(-6,-1)(7,-1)
\endpsclip
\psEllipseTangents(1,-1)(4,3)(-2,3)
\psline{*-*}(-2,3)(EllipseT1)
\psline{*-*}(-2,3)(EllipseT2)
\end{pspicture}
\end{document}
説明:\psellipse
最初の引数には中心の座標があります。2 番目の引数には、水平半軸と垂直半軸を指定します。他の軸を持つ楕円を作成するには、中心を中心に回転する必要があります。
マクロではpsEllipseTangent
、与えられた点から楕円への接線を描くことができます。この点の座標は 3 番目の引数として渡されます。楕円との接点は、 および という名前のノードEllipseT1
ですEllipseT2
。
答え2
同様のソリューションですが、ロードされるパッケージは少なくなります。
\documentclass{article}
\usepackage{pstricks-add}
\begin{document}
\begin{pspicture}(-4.2,-2.2)(4.85,5.7)
\psaxes{->}(0,0)(-4.2,-2.2)(4.5,5.3)[$x$,0][$y$,90]
\psdot(2,4)
\psellipse(0,0)(3,1.5)
\psEllipseTangents(0,0)(3,1.5)(2,4)
\psset{nodesep = -1cm, linecolor = blue}
\pcline(2,4)(EllipseT1)
\pcline(2,4)(EllipseT2)
\psdots(EllipseT1)(EllipseT2)
\uput[135](EllipseT1){$T_{1}$}
\uput[45](EllipseT2){$T_{2}$}
\end{pspicture}
\end{document}
答え3
とtikz
\documentclass[svgnames,tikz,border=10pt]{standalone}
\begin{document}
\begin{tikzpicture}
\draw[very thick, -stealth] (-6,0) -- (6,0);
\foreach \x in {-5,-4,-3,-2,-1,1,2,3,4,5}{
\draw (\x,0.2) -- (\x,-0.2) node[below] {\x};
}
\draw[very thick, -stealth] (0,-6) -- (0,6);
\foreach \y in {-5,-4,-3,-2,-1,1,2,3,4,5}{
\draw (0.2,\y) -- (-0.2,\y) node[left] {\y};
}
\draw[very thick,Purple] (-1,3) arc [start angle=0,end angle=360,x radius = 2cm, y radius=1cm]node[circle,fill,pos=0.3,sloped,inner sep=2pt] (a){} node [circle,fill,pos=0.9,sloped,inner sep=2pt] (b) {};
\draw[shorten <= -1cm, shorten >= -7cm] (a.west) -- (a.east);
\draw[shorten <= -1cm, shorten >= -5cm] (b.west) -- (b.east);
\end{tikzpicture}
\end{document}
答え4
Asymptote
楕円の接線点を求めるための基礎として、より単純な単位円のケースを利用するソリューション。この手順では、2getTangentPoints
つの入力パラメータを使用して 2 つの接線点を計算します。transform tr
これは、原点の単位円を に変換するために使用されます。ellipse
また、pair T
点の座標も計算されます。
%
% ell.tex :
%
\documentclass[10pt,a4paper]{article}
\usepackage{lmodern}
\usepackage{subcaption}
\usepackage[inline]{asymptote}
\begin{asydef}
import graph;
import fontsize;
defaultpen(fontsize(9pt));
pair O=(0,0);
pen linepen=deepblue+0.8bp;
pen tanpen=orange+0.8bp;
pen graypen=gray+0.6bp;
pair[] getTangentPoints(transform tr, pair T){
assert(!inside(tr*Circle(O,1),T)
,"*** The point is not outside of the ellipse ***");
pair[] p=new pair[2];
pair tmp1, tmp2;
transform tphi;
tmp1=tr^(-1)*T;
tphi=rotate(-degrees(dir(tmp1)));
tmp2=tphi*tmp1;
p[0]=(1/tmp2.x,sqrt(1-1/tmp2.x^2));
p[1]=(p[0].x,-p[0].y);
return tr*tphi^(-1)*p;
}
\end{asydef}
\usepackage[left=2cm,right=2cm,top=2cm,bottom=2cm]{geometry}
%
\begin{document}
%
\begin{figure}
\captionsetup[subfigure]{justification=centering}
\centering
\begin{subfigure}{0.45\textwidth}
\begin{asy}
size(70mm);
real a=2, b=0.618a;
pair T0=(1.5,-2);
transform tr=shift(1.3,-0.5)*rotate(20)*scale(a,b);
guide Ellipse=tr*Circle(O,1);
pair[] T=getTangentPoints(tr,T0);
xaxis(RightTicks(OmitTick(0),Step=1,step=0.5));
yaxis( LeftTicks(OmitTick(0),Step=1,step=0.5));
draw(Ellipse,linepen);
draw(tr*(N--S),graypen);draw(tr*(E--W),graypen);
draw(T0--(T[0]+dir(T[0]-T0)),tanpen);
draw(T0--(T[1]+dir(T[1]-T0)),tanpen);
dot(T0--T[0]--tr*O--T[1],UnFill);
label("$T_0$",T0,T0-tr*O);
label("$T_1$",T[0],T[0]-tr*O);
label("$T_2$",T[1],T[1]-tr*O);
\end{asy}
%
\caption{}
\label{fig:1a}
\end{subfigure}
%
\begin{subfigure}{0.45\textwidth}
\begin{asy}
size(70mm);
real a=3, b=0.2a;
pair T0=(4,0.9);
transform tr=shift(0.3,-1.5)*rotate(-35)*scale(a,b);
guide Ellipse=tr*Circle(O,1);
pair[] T=getTangentPoints(tr,T0);
xaxis(RightTicks(OmitTick(0),Step=1,step=0.5));
yaxis( LeftTicks(OmitTick(0),Step=1,step=0.5));
draw(Ellipse,linepen);
draw(tr*(N--S),graypen);draw(tr*(E--W),graypen);
draw(T0--(T[0]+dir(T[0]-T0)),tanpen);
draw(T0--(T[1]+dir(T[1]-T0)),tanpen);
dot(T0--T[0]--tr*O--T[1],UnFill);
label("$T_0$",T0,T0-tr*O);
label("$T_1$",T[0],T[0]-tr*O);
label("$T_2$",T[1],T[1]-tr*O);
\end{asy}
%
\caption{}
\label{fig:1b}
\end{subfigure}
\caption{}
\label{fig:1}
\end{figure}
%
\end{document}
%
% Process:
%
% pdflatex ell.tex
% asy ell-*.asy
% pdflatex ell.tex