
\usepackage{pict2e}
\usepackage{pstricks-add}
\usepackage{pst-node,pst-plot}
\psset{plotpoints=9,unit=3}
어떻게 든 다양한 사람들의 조언에 따라 위의 코드 줄을 내 줄 위에 놓았습니다 \begin{document}
. 세 패키지의 내용과 마지막 명령의 차이점이 무엇인지 잘 모르겠지만 가능했습니다. 선, 점, 원, 특정 위치의 텍스트를 포함하는 간단한 다이어그램을 그리는 데 필요했습니다.
이제 타원을 그리고 싶습니다. 주요 축과 보조 축의 끝점을 지정할 수 있는데, 그 끝점은 이상한 각도가 아닌 수평 및 수직이며 곡선의 대칭 패턴으로 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
첫 번째 인수의 중심 좌표가 있습니다. 두 번째 인수는 수평 및 수직 반축을 제공합니다. 다른 축과 함께 타원을 만들려면 중심을 중심으로 회전해야 합니다.
매크로 의 경우 psEllipseTangent
, 주어진 지점에서 타원에 대한 접선을 그릴 수 있습니다. 이 점의 좌표를 세 번째 인수로 갖습니다. 타원과의 접촉점은 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
타원에 대한 접선 점을 얻기 위해 단위원의 간단한 사례를 기반으로 활용하는 솔루션입니다 . 이 절차에서는 getTangentPoints
두 개의 입력 매개변수인 transform tr
, 원점의 단위원을 로 변환하는 데 사용되는 ellipse
, 및 pair T
점의 a - 좌표를 사용하여 두 개의 접선점을 계산합니다.
%
% 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