And Asymptote
version, ellipse.asy
along with a translation to tikz via svg
size(300);
void Dot(... pair[] p){ // function takes a variable number of arguments
for(int i=0;i<p.length;++i){
fill(shift(p[i])*scale(0.06)*unitcircle,black);
fill(shift(p[i])*scale(0.04)*unitcircle,white);
}
}
real a=2.5, b=2, focus=sqrt(a*a-b*b);
pair c=(0,0), d=(-focus,0);
path el=ellipse(c,a,b);
path tline=rotate(36)*(c--(2a,0));
real tr=intersect(el,tline)[0];
pair r=point(el,tr);
pair tan_dir=dir(el,tr);
path tan_line=scale(b)*(-tan_dir--tan_dir);
pair w=intersectionpoint(d--r,shift(c)*tan_line);
pen linePen=darkblue+1.2pt;
pen elPen=red+1.5pt;
draw(el,elPen); draw(d--r,linePen);
draw(shift(r)*tan_line,linePen);
draw(shift(c)*tan_line,linePen);
Dot(c,d,r,w);
label("$C$",c,NE);label("$D$",d,NW);
label("$R$",r,NE);label("$W$",w,S);
run asy ellipse.asy
to get ellipse.eps
or asy -f pdf ellipse.asy
to get ellipse.pdf
.
Or put it inside the asy
environment in a LaTeX
document (see texdoc asymptote
).
Edit: Some comments added.
A user defined function to draw a list of dots, to be used later as Dot(c,d,r,w);
:
void Dot(... pair[] p){ // function takes a variable number of arguments
for(int i=0;i<p.length;++i){
fill(shift(p[i])*scale(0.06)*unitcircle,black);
fill(shift(p[i])*scale(0.04)*unitcircle,white);
}
}
The function Dot
is defined with ... pair[] p
construction, that means
it is able to accept a variable number of arguments, all of them will be placed
in an array of pairs (2D coordinates) p[]
.
real a=2.5, b=2, focus=sqrt(a*a-b*b);
defines dimensions.
pair c=(0,0), d=(-focus,0);
defines points c
and d
by x,y
coordinates.
path el=ellipse(c,a,b);
defines a curve (ellipse outline) to be used later;
path tline=rotate(36)*(c--(2a,0));
defines a straight line as a rotated by 36 degrees horizontal line c--(2a,0)
real tr=intersect(el,tline)[0];
defines a so-called intersection time, a parameter t
for the path el
, which
corresponds to the point of intersection of tline
with the ellipse outline el
.
pair r=point(el,tr);
define the point of intersection itself.
pair tan_dir=dir(el,tr);
defines a tangent direction at the point r
(at time tr
).
path tan_line=scale(b)*(-tan_dir--tan_dir);
defines a line through the origin parallel to the tangent.
pair w=intersectionpoint(d--r,shift(c)*tan_line);
defines an intersection point of interest, between the line d--r
and a line parallel to the tangent through the origin (point c
).
pen linePen=darkblue+1.2pt;
pen elPen=red+1.5pt;
defined are pens (color and width) to be used for lines and ellipse
draw(el,elPen); draw(d--r,linePen);
draw the ellipse and the line d--r
draw(shift(r)*tan_line,linePen);
draw(shift(c)*tan_line,linePen);
draw two parallel lines through points r
and c
, using defined function Dot
.
Dot(c,d,r,w);
draw fancy dots at all four points c,d,r,w
.
label("$C$",c,NE);label("$D$",d,NW);
label("$R$",r,NE);label("$W$",w,S);
and finally, draw labels, formatted as a (La)TeX
string (e.g. "$C$"
)
at specified position (e.g. ,c
), oriented as specified (e.d. NE
means to the North-West of the point).
Edit2: tikz translation added
Thanks to Harish Kumar
for his answer [here][2], I've just installed inkscape2tikz
from [source][3] and after running asy -f svg ellipse.asy
svg2tikz ellipse.svg > ellipse.tex
here it is a LaTeX
document with tikz
solution, translated from the ellipse.asy
code shown above:
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{tikz}
\begin{document}
\definecolor{cff0000}{RGB}{255,0,0}
\definecolor{c000040}{RGB}{0,0,64}
\definecolor{cffffff}{RGB}{255,255,255}
\begin{tikzpicture}[y=0.80pt,x=0.80pt,yscale=-1, inner sep=0pt, outer sep=0pt]
\begin{scope}[cm={{0.996,0.0,0.0,0.996,(0.0,0.0)}}]
\begin{scope}[cm={{1.0,0.0,0.0,1.0,(207.183,174.51)}}]
\path[draw=cff0000,line join=round,line cap=round,miter limit=10.04,line
width=1.200pt] (75.2812,0.0000) .. controls (75.2812,-33.2613) and
(41.5767,-60.2250) .. (0.0000,-60.2250) .. controls (-41.5767,-60.2250) and
(-75.2812,-33.2613) .. (-75.2812,-0.0000) .. controls (-75.2812,33.2613) and
(-41.5767,60.2250) .. (0.0000,60.2250) .. controls (41.5767,60.2250) and
(75.2812,33.2613) .. (75.2812,0.0000) -- cycle;
\end{scope}
\begin{scope}[cm={{1.0,0.0,0.0,1.0,(207.183,174.51)}}]
\path[draw=c000040,line join=round,line cap=round,miter limit=10.04,line
width=0.960pt] (-45.1687,-0.0000) -- (55.7293,-40.4897);
\end{scope}
\begin{scope}[cm={{1.0,0.0,0.0,1.0,(207.183,174.51)}}]
\path[draw=c000040,line join=round,line cap=round,miter limit=10.04,line
width=0.960pt] (100.9330,-0.6942) -- (10.5257,-80.2853);
\end{scope}
\begin{scope}[cm={{1.0,0.0,0.0,1.0,(207.183,174.51)}}]
\path[draw=c000040,line join=round,line cap=round,miter limit=10.04,line
width=0.960pt] (45.2036,39.7955) -- (-45.2036,-39.7955);
\end{scope}
\begin{scope}[cm={{1.0,0.0,0.0,1.0,(207.183,174.51)}}]
\path[fill=black] (1.8068,0.0000) .. controls (1.8068,-0.9978) and
(0.9978,-1.8068) .. (0.0000,-1.8068) .. controls (-0.9978,-1.8068) and
(-1.8068,-0.9978) .. (-1.8068,-0.0000) .. controls (-1.8068,0.9978) and
(-0.9978,1.8068) .. (0.0000,1.8068) .. controls (0.9978,1.8068) and
(1.8068,0.9978) .. (1.8068,0.0000) -- cycle;
\end{scope}
\begin{scope}[cm={{1.0,0.0,0.0,1.0,(207.183,174.51)}}]
\path[fill=cffffff] (1.2045,0.0000) .. controls (1.2045,-0.6652) and
(0.6652,-1.2045) .. (0.0000,-1.2045) .. controls (-0.6652,-1.2045) and
(-1.2045,-0.6652) .. (-1.2045,-0.0000) .. controls (-1.2045,0.6652) and
(-0.6652,1.2045) .. (0.0000,1.2045) .. controls (0.6652,1.2045) and
(1.2045,0.6652) .. (1.2045,0.0000) -- cycle;
\end{scope}
\begin{scope}[cm={{1.0,0.0,0.0,1.0,(207.183,174.51)}}]
\path[fill=black] (-43.3620,-0.0000) .. controls (-43.3620,-0.9978) and
(-44.1709,-1.8068) .. (-45.1687,-1.8068) .. controls (-46.1666,-1.8068) and
(-46.9755,-0.9978) .. (-46.9755,-0.0000) .. controls (-46.9755,0.9978) and
(-46.1666,1.8068) .. (-45.1687,1.8068) .. controls (-44.1709,1.8068) and
(-43.3620,0.9978) .. (-43.3620,-0.0000) -- cycle;
\end{scope}
\begin{scope}[cm={{1.0,0.0,0.0,1.0,(207.183,174.51)}}]
\path[fill=cffffff] (-43.9642,-0.0000) .. controls (-43.9642,-0.6652) and
(-44.5035,-1.2045) .. (-45.1687,-1.2045) .. controls (-45.8340,-1.2045) and
(-46.3732,-0.6652) .. (-46.3732,-0.0000) .. controls (-46.3732,0.6652) and
(-45.8340,1.2045) .. (-45.1687,1.2045) .. controls (-44.5035,1.2045) and
(-43.9642,0.6652) .. (-43.9642,-0.0000) -- cycle;
\end{scope}
\begin{scope}[cm={{1.0,0.0,0.0,1.0,(207.183,174.51)}}]
\path[fill=black] (57.5361,-40.4897) .. controls (57.5361,-41.4876) and
(56.7272,-42.2965) .. (55.7293,-42.2965) .. controls (54.7315,-42.2965) and
(53.9226,-41.4876) .. (53.9226,-40.4897) .. controls (53.9226,-39.4919) and
(54.7315,-38.6830) .. (55.7293,-38.6830) .. controls (56.7272,-38.6830) and
(57.5361,-39.4919) .. (57.5361,-40.4897) -- cycle;
\end{scope}
\begin{scope}[cm={{1.0,0.0,0.0,1.0,(207.183,174.51)}}]
\path[fill=cffffff] (56.9338,-40.4897) .. controls (56.9338,-41.1550) and
(56.3946,-41.6942) .. (55.7293,-41.6942) .. controls (55.0641,-41.6942) and
(54.5248,-41.1550) .. (54.5248,-40.4897) .. controls (54.5248,-39.8245) and
(55.0641,-39.2852) .. (55.7293,-39.2852) .. controls (56.3946,-39.2852) and
(56.9338,-39.8245) .. (56.9338,-40.4897) -- cycle;
\end{scope}
\begin{scope}[cm={{1.0,0.0,0.0,1.0,(207.183,174.51)}}]
\path[fill=black] (-12.3358,-12.4506) .. controls (-12.3358,-13.4484) and
(-13.1447,-14.2573) .. (-14.1426,-14.2573) .. controls (-15.1404,-14.2573) and
(-15.9493,-13.4484) .. (-15.9493,-12.4506) .. controls (-15.9493,-11.4528) and
(-15.1404,-10.6438) .. (-14.1426,-10.6438) .. controls (-13.1447,-10.6438) and
(-12.3358,-11.4528) .. (-12.3358,-12.4506) -- cycle;
\end{scope}
\begin{scope}[cm={{1.0,0.0,0.0,1.0,(207.183,174.51)}}]
\path[fill=cffffff] (-12.9381,-12.4506) .. controls (-12.9381,-13.1158) and
(-13.4774,-13.6551) .. (-14.1426,-13.6551) .. controls (-14.8078,-13.6551) and
(-15.3471,-13.1158) .. (-15.3471,-12.4506) .. controls (-15.3471,-11.7854) and
(-14.8078,-11.2461) .. (-14.1426,-11.2461) .. controls (-13.4774,-11.2461) and
(-12.9381,-11.7854) .. (-12.9381,-12.4506) -- cycle;
\end{scope}
\begin{scope}[shift={(209.733,171.904)}]
\path (8.9640,-8.3400) .. controls (8.9640,-8.4480) and (8.8800,-8.4480) ..
(8.8560,-8.4480) .. controls (8.8320,-8.4480) and (8.7840,-8.4480) ..
(8.6880,-8.3280) -- (7.8600,-7.3200) .. controls (7.4400,-8.0400) and
(6.7800,-8.4480) .. (5.8800,-8.4480) .. controls (3.2880,-8.4480) and
(0.6000,-5.8200) .. (0.6000,-3.0000) .. controls (0.6000,-0.9960) and
(2.0040,0.2520) .. (3.7560,0.2520) .. controls (4.7160,0.2520) and
(5.5560,-0.1560) .. (6.2520,-0.7440) .. controls (7.2960,-1.6200) and
(7.6080,-2.7840) .. (7.6080,-2.8800) .. controls (7.6080,-2.9880) and
(7.5120,-2.9880) .. (7.4760,-2.9880) .. controls (7.3680,-2.9880) and
(7.3560,-2.9160) .. (7.3320,-2.8680) .. controls (6.7800,-0.9960) and
(5.1600,-0.0960) .. (3.9600,-0.0960) .. controls (2.6880,-0.0960) and
(1.5840,-0.9120) .. (1.5840,-2.6160) .. controls (1.5840,-3.0000) and
(1.7040,-5.0880) .. (3.0600,-6.6600) .. controls (3.7200,-7.4280) and
(4.8480,-8.1000) .. (5.9880,-8.1000) .. controls (7.3080,-8.1000) and
(7.8960,-7.0080) .. (7.8960,-5.7840) .. controls (7.8960,-5.4720) and
(7.8600,-5.2080) .. (7.8600,-5.1600) .. controls (7.8600,-5.0520) and
(7.9800,-5.0520) .. (8.0160,-5.0520) .. controls (8.1480,-5.0520) and
(8.1600,-5.0640) .. (8.2080,-5.2800) -- (8.9640,-8.3400) -- cycle;
\end{scope}
\begin{scope}[shift={(149.391,171.904)}]
\path (1.8840,-0.8880) .. controls (1.7760,-0.4680) and (1.7520,-0.3480) ..
(0.9120,-0.3480) .. controls (0.6840,-0.3480) and (0.5640,-0.3480) ..
(0.5640,-0.1320) .. controls (0.5640,0.0000) and (0.6360,0.0000) ..
(0.8760,0.0000) -- (4.6800,0.0000) .. controls (7.1040,0.0000) and
(9.4680,-2.5080) .. (9.4680,-5.1840) .. controls (9.4680,-6.9120) and
(8.4360,-8.1960) .. (6.7200,-8.1960) -- (2.8680,-8.1960) .. controls
(2.6400,-8.1960) and (2.5320,-8.1960) .. (2.5320,-7.9680) .. controls
(2.5320,-7.8480) and (2.6400,-7.8480) .. (2.8200,-7.8480) .. controls
(3.5520,-7.8480) and (3.5520,-7.7520) .. (3.5520,-7.6200) .. controls
(3.5520,-7.5960) and (3.5520,-7.5240) .. (3.5040,-7.3440) -- (1.8840,-0.8880)
-- cycle(4.4160,-7.3800) .. controls (4.5240,-7.8240) and (4.5720,-7.8480) ..
(5.0400,-7.8480) -- (6.3600,-7.8480) .. controls (7.4880,-7.8480) and
(8.5200,-7.2360) .. (8.5200,-5.5800) .. controls (8.5200,-4.9800) and
(8.2800,-2.8920) .. (7.1160,-1.5720) .. controls (6.7800,-1.1760) and
(5.8680,-0.3480) .. (4.4880,-0.3480) -- (3.1200,-0.3480) .. controls
(2.9520,-0.3480) and (2.9280,-0.3480) .. (2.8560,-0.3600) .. controls
(2.7240,-0.3720) and (2.7120,-0.3960) .. (2.7120,-0.4920) .. controls
(2.7120,-0.5760) and (2.7360,-0.6480) .. (2.7600,-0.7560) -- (4.4160,-7.3800)
-- cycle;
\end{scope}
\begin{scope}[shift={(265.462,131.415)}]
\path (4.4160,-7.3800) .. controls (4.5240,-7.8240) and (4.5720,-7.8480) ..
(5.0400,-7.8480) -- (5.9040,-7.8480) .. controls (6.9360,-7.8480) and
(7.7040,-7.5360) .. (7.7040,-6.6000) .. controls (7.7040,-5.9880) and
(7.3920,-4.2240) .. (4.9800,-4.2240) -- (3.6240,-4.2240) -- (4.4160,-7.3800)
-- cycle(6.0840,-4.0800) .. controls (7.5720,-4.4040) and (8.7360,-5.3640) ..
(8.7360,-6.3960) .. controls (8.7360,-7.3320) and (7.7880,-8.1960) ..
(6.1200,-8.1960) -- (2.8680,-8.1960) .. controls (2.6280,-8.1960) and
(2.5200,-8.1960) .. (2.5200,-7.9680) .. controls (2.5200,-7.8480) and
(2.6040,-7.8480) .. (2.8320,-7.8480) .. controls (3.5520,-7.8480) and
(3.5520,-7.7520) .. (3.5520,-7.6200) .. controls (3.5520,-7.5960) and
(3.5520,-7.5240) .. (3.5040,-7.3440) -- (1.8840,-0.8880) .. controls
(1.7760,-0.4680) and (1.7520,-0.3480) .. (0.9240,-0.3480) .. controls
(0.6480,-0.3480) and (0.5640,-0.3480) .. (0.5640,-0.1200) .. controls
(0.5640,0.0000) and (0.6960,0.0000) .. (0.7320,0.0000) .. controls
(0.9480,0.0000) and (1.2000,-0.0240) .. (1.4280,-0.0240) -- (2.8440,-0.0240)
.. controls (3.0600,-0.0240) and (3.3120,0.0000) .. (3.5280,0.0000) ..
controls (3.6240,0.0000) and (3.7560,0.0000) .. (3.7560,-0.2280) .. controls
(3.7560,-0.3480) and (3.6480,-0.3480) .. (3.4680,-0.3480) .. controls
(2.7360,-0.3480) and (2.7360,-0.4440) .. (2.7360,-0.5640) .. controls
(2.7360,-0.5760) and (2.7360,-0.6600) .. (2.7600,-0.7560) -- (3.5640,-3.9840)
-- (5.0040,-3.9840) .. controls (6.1440,-3.9840) and (6.3600,-3.2640) ..
(6.3600,-2.8680) .. controls (6.3600,-2.6880) and (6.2400,-2.2200) ..
(6.1560,-1.9080) .. controls (6.0240,-1.3560) and (5.9880,-1.2240) ..
(5.9880,-0.9960) .. controls (5.9880,-0.1440) and (6.6840,0.2520) ..
(7.4880,0.2520) .. controls (8.4600,0.2520) and (8.8800,-0.9360) ..
(8.8800,-1.1040) .. controls (8.8800,-1.1880) and (8.8200,-1.2240) ..
(8.7480,-1.2240) .. controls (8.6520,-1.2240) and (8.6280,-1.1520) ..
(8.6040,-1.0560) .. controls (8.3160,-0.2040) and (7.8240,0.0120) ..
(7.5240,0.0120) .. controls (7.2240,0.0120) and (7.0320,-0.1200) ..
(7.0320,-0.6600) .. controls (7.0320,-0.9480) and (7.1760,-2.0400) ..
(7.1880,-2.1000) .. controls (7.2480,-2.5440) and (7.2480,-2.5920) ..
(7.2480,-2.6880) .. controls (7.2480,-3.5640) and (6.5400,-3.9360) ..
(6.0840,-4.0800) -- cycle;
\end{scope}
\begin{scope}[shift={(186.682,173.799)}]
\path (10.8360,-6.8640) .. controls (11.1120,-7.3320) and (11.3760,-7.7760) ..
(12.0960,-7.8480) .. controls (12.2040,-7.8600) and (12.3120,-7.8720) ..
(12.3120,-8.0640) .. controls (12.3120,-8.1960) and (12.2040,-8.1960) ..
(12.1680,-8.1960) .. controls (12.1440,-8.1960) and (12.0600,-8.1720) ..
(11.2680,-8.1720) .. controls (10.9080,-8.1720) and (10.5360,-8.1960) ..
(10.1880,-8.1960) .. controls (10.1160,-8.1960) and (9.9720,-8.1960) ..
(9.9720,-7.9680) .. controls (9.9720,-7.8600) and (10.0680,-7.8480) ..
(10.1400,-7.8480) .. controls (10.3800,-7.8360) and (10.7640,-7.7640) ..
(10.7640,-7.3920) .. controls (10.7640,-7.2360) and (10.7160,-7.1520) ..
(10.5960,-6.9480) -- (7.3200,-1.2120) -- (6.8880,-7.4640) .. controls
(6.8880,-7.6080) and (7.0200,-7.8360) .. (7.6920,-7.8480) .. controls
(7.8480,-7.8480) and (7.9680,-7.8480) .. (7.9680,-8.0760) .. controls
(7.9680,-8.1960) and (7.8480,-8.1960) .. (7.7880,-8.1960) .. controls
(7.3680,-8.1960) and (6.9240,-8.1720) .. (6.4920,-8.1720) -- (5.8680,-8.1720)
.. controls (5.6880,-8.1720) and (5.4720,-8.1960) .. (5.2920,-8.1960) ..
controls (5.2200,-8.1960) and (5.0760,-8.1960) .. (5.0760,-7.9680) .. controls
(5.0760,-7.8480) and (5.1600,-7.8480) .. (5.3640,-7.8480) .. controls
(5.9160,-7.8480) and (5.9160,-7.8360) .. (5.9640,-7.1040) -- (6.0000,-6.6720)
-- (2.8920,-1.2120) -- (2.4480,-7.4040) .. controls (2.4480,-7.5360) and
(2.4480,-7.8360) .. (3.2640,-7.8480) .. controls (3.3960,-7.8480) and
(3.5280,-7.8480) .. (3.5280,-8.0640) .. controls (3.5280,-8.1960) and
(3.4200,-8.1960) .. (3.3480,-8.1960) .. controls (2.9280,-8.1960) and
(2.4840,-8.1720) .. (2.0520,-8.1720) -- (1.4280,-8.1720) .. controls
(1.2480,-8.1720) and (1.0320,-8.1960) .. (0.8520,-8.1960) .. controls
(0.7800,-8.1960) and (0.6360,-8.1960) .. (0.6360,-7.9680) .. controls
(0.6360,-7.8480) and (0.7320,-7.8480) .. (0.9000,-7.8480) .. controls
(1.4640,-7.8480) and (1.4760,-7.7760) .. (1.5000,-7.3920) -- (2.0280,-0.0240)
.. controls (2.0400,0.1800) and (2.0520,0.2520) .. (2.1960,0.2520) .. controls
(2.3160,0.2520) and (2.3400,0.2040) .. (2.4480,0.0240) -- (6.0240,-6.2280) --
(6.4680,-0.0240) .. controls (6.4800,0.1800) and (6.4920,0.2520) ..
(6.6360,0.2520) .. controls (6.7560,0.2520) and (6.7920,0.1920) ..
(6.8880,0.0240) -- (10.8360,-6.8640) -- cycle;
\end{scope}
\end{scope}
\end{tikzpicture}
\end{document}
The graphics looks fine, but the labels vanished somehow.