Mathematica, 142 bytes
Graphics[{Circle[],Line/@{{{c=Cos@t,0},{c,s=Sin@t},{0,s}},{{0,0},{1/c,0},{0,1/s},{0,0},{c,s}}},},PlotRange->{r={-2,2},r}]~Animate~{t,0.01,2Pi}
I'm plotting for angles between 0.01
and 2π
which conveniently skips any angles where one of the lines would become actually infinite. You can make a GIF from it by replacing Animate
with Table
, adding a step width of 0.1
say and then using Export
on the result:
![enter image description here](../../I/static/images/b6b2317de981b3e32a912fbeb86f0e818b642ab5dacbdb62ebb8e5dfee11f123.gif)
So I got a bit bored and thought I'd give the full-blown thing a go (with all lines and colours). I omitted the labels, because they are really annoying to position and just clutter everything up.
Animate[
c = Cos@t;
s = Sin@t;
h = Sign@c;
v = Sign@s;
i = .1 h;
j = .1 v;
Graphics[{
Thick,
Circle[],
Line /@ {{{c, -s}, {0, 0}, {c, s}}, {{-i, 0}, {-i, j}, {0,
j}}, {{-i + c, 0}, {-i + c, j}, {c, j}}, {{c - .1 s,
s + .1 c}, {1.1 c - .1 s, 1.1 s + .1 c}, 1.1 {c, s}}},
Circle[{0, 0}, 0.1, {t, Round[t, Pi]}],
Blue,
Line /@ {{{0, 0}, {c, 0}}, {{0, s}, {c, s}}},
Red,
Line /@ {{{0, 0}, {0, s}}, {{c, 0}, {c, s}}},
Darker@Green,
Line[{{c, 0}, {h, 0}}],
Cyan,
Line[{{0, s}, {0, v}}],
Lighter@Lighter@Magenta,
Line[{{h, 0}, {1/c, 0}}],
Darker@Darker@Green,
Line[{{0, v}, {0, 1/s}}],
Orange,
Line[{{0, 1/s}, {c, s}}],
Lighter@Brown,
Line[{{1/c, 0}, {c, s}}],
Gray,
Line[{{c, 0}, {c, -s}}],
Lighter@Gray,
Line[{{c, s}, {h, 0}}],
Lighter@Pink,
Line /@ {{{-.45 h, 0}, {-.55 h, 0}}, {{-.45 h, 1/s}, {-.55 h,
1/s}}},
Arrowheads[{-.05, .05}],
Arrow[{{-.5 h, 0}, {-.5 h, 1/s}}],
Darker@Cyan,
Line /@ {{{0, -.45 v}, {0, -.55 v}}, {{1/c, -.45 v}, {1/
c, -.55 v}}},
Arrow[{{0, -.5 v}, {1/c, -.5 v}}],
Dashed,
Black,
Line[{{c, s}, 1.3 {c, s}}],
Lighter@Pink,
Line /@ {{{0, 0}, {-.5 h, 0}}, {{0, 1/s}, {-.5 h, 1/s}}},
Darker@Cyan,
Line /@ {{{0, 0}, {0, -.5 v}}, {{1/c, 0}, {1/c, -.5 v}}}
}, PlotRange -> {r = {-2, 2}, r}],
{t, 0.01, 2 Pi}
];
Enjoy!
![enter image description here](../../I/static/images/98e356d18a9c462088f9cd033a2efc743e0ea5e6e01150d841ed47306b505319.gif)
And because this is still a code-golf question I golfed this down as well, to see how short I could get it. Currently, 719 bytes:
Graphics[{Thick,Arrowheads@{-.05,.05},(z=Circle)[],(n=Line)/@{{p={c=Cos@t,s=Sin@t},o={0,0},{c,-s}},{-{i=.1(h=Sign@c),0},{-i,j=.1(v=Sign@s)},{0,j}},{{-i+c,0},{-i+c,j},{c,j}},{p+(q={-.1s,.1c}),1.1p+q,1.1p}},z[o,0.1,{t,Round[t,Pi]}],{e=Dashed,n[{p,1.3p}]},Blue,n/@{{o,a={c,0}},{b={0,s},p}},Red,n/@{{o,b},{a,p}},g=(d=Darker)@Green,n@{a,{h,0}},y=Cyan,n@{b,{0,v}},(l=Lighter)@l@Magenta,n@{{h,0},f={1/c,0}},d@g,n@{{0,v},u={0,1/s}},Orange,n@{u,p},l@Brown,n@{f,p},r=Gray,n@{a,{c,-s}},l@r,n@{p,{h,0}},l@Pink,n/@{q={{-.45h,0},{-.55h,0}},{u,u}+q},Arrow@{q={-.5h,0},u+q},{e,n/@{{o,q},{u,u+q}}},d@y,n/@{q={{0,-.45v},{0,-.55v}},{f,f}+q},Arrow@{q={0,-.5v},f+q},{e,n/@{{o,q},{f,f+q}}}},PlotRange->{r={-2,2},r}]~Animate~{t,0.01,2Pi,0.05}
Dead link, perhaps? – sergiol – 2017-11-11T12:06:41.930
@sergiol I've updated it now :) – Beta Decay – 2017-11-11T15:04:32.483
1An image or gif of what your code produces would be very helpful. – Calvin's Hobbies – 2014-08-19T15:56:36.700
@Calvin'sHobbies Added – Beta Decay – 2014-08-19T16:00:09.897
1I count ASCII 232 characters there, though with tokenisation it probably is 185 bytes. Watch out for that byte counter on BBC Basic for Windows. I usually post as an ASCII count. Your code is probabably golfable down below 185 ASCII characters with VDU's though. – Level River St – 2014-08-19T16:19:44.457
1And when the tangent or cotangent are infinite, what should be drawn? Also, what does "output" mean? Can a program write a gif or video file, or should it output in real time on a canvas? – Peter Taylor – 2014-08-19T16:21:40.720
@PeterTaylor When tan and cot are infinite, you could draw it to a very long length. Regarding the format of the output, it can be anything. – Beta Decay – 2014-08-19T16:26:51.263