summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/metapost/featpost/example/trigonometry.mp
blob: fb7299ddaaa7c7e3da13426832f689d2f8e24fa4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
% trigonometry.mp
% L. Nobre G.
% 2002

% %input mp-tool;

verbatimtex 
\documentclass{article} 
\usepackage{palatino} 
\usepackage{concmath} 
\usepackage{ccfonts} 
\begin{document} 
etex

def PickColor =
  ( uniformdeviate(1) , uniformdeviate(1), 0 )
enddef;

beginfig(1);
  picture sin, cos, tan, ctg, sec, csc;
  color sincol, coscol, tancol, ctgcol, seccol, csccol;
  pair sinl, cosl, tanl, ctgl, secl, cscl;
  path sinp, cosp, tanp, ctgp, secp;
  numeric Ang, U, len, labelscale;
  path diag, fram, quar;
  pair urc, ulc, lrc, tgc, sic, coc, btg;
  pen basepen, thikpen, thinpen;
  Ang = 21;              % Ang < 45
  U = 1.8in;
  labelscale = 2;
  basepen = pencircle scaled 1.2pt;
  thikpen = pencircle scaled 3.4pt;
  thinpen = pencircle scaled 1.2pt;
  sincol = PickColor;
  coscol = PickColor;
  tancol = PickColor;
  ctgcol = PickColor;
  seccol = PickColor;
  csccol = PickColor;
  len = U * cosd( Ang ) / sind( Ang );
  urc = ( len, U );
  ulc = ( 0, U );
  lrc = ( len, 0 );
  tgc = ( U, U * sind( Ang ) / cosd( Ang ) );
  sic = ( U * cosd( Ang ), U * sind( Ang ) );
  coc = ( U * cosd( Ang ), 0 );
  btg = ( U, 0 );
  diag = origin--urc;
  fram = origin--lrc--urc--ulc--cycle;
  quar = halfcircle cutafter ( origin--up );
  quar := quar scaled 2U;
  draw fram withpen basepen;
  draw quar withpen basepen;
  sinl = 0.5[coc,sic];
  sinp = coc--sic;
  cosl = 0.5[origin,coc];
  cosp = origin--coc;
  tanl = 0.5[btg,tgc];
  tanp = btg--tgc;
  ctgl = 0.5[ulc,urc];
  ctgp = ulc--urc;
  secl = 0.5[origin,sic];
  secp = origin--tgc;
  cscl = 0.5[origin,urc];
  draw diag withcolor csccol withpen thikpen;
  draw secp withcolor seccol withpen thinpen;
  draw ctgp withcolor ctgcol withpen thinpen;
  draw tanp withcolor tancol withpen thinpen;
  draw cosp withcolor coscol withpen thinpen;
  draw sinp withcolor sincol withpen thinpen;
  sin = thelabel.lft( btex sin etex scaled labelscale, sinl );
  cos = thelabel.top( btex cos etex scaled labelscale, cosl );
  tan = thelabel.rt( btex tan etex scaled labelscale, tanl );
  ctg = thelabel.bot( btex cotan etex scaled labelscale, ctgl );
  sec = thelabel.top( btex sec etex scaled labelscale, origin );
  csc = thelabel.top( btex cosec etex scaled labelscale, origin );
  draw sin withcolor sincol;
  draw cos withcolor coscol;
  draw tan withcolor tancol;
  draw ctg withcolor ctgcol;
  draw sec rotated Ang shifted secl withcolor seccol;
  draw csc rotated Ang shifted cscl withcolor csccol;
endfig;

verbatimtex 
\end{document} 
etex

end.