%%
%% This is file `cioptic.mf',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% circ.dtx  (with options: `optic')
%% Copyright 1997-98  Sebastian Tannert / Andreas Tille
%% 
%% This file is part of the CIRC package
%% -------------------------------------
%%   This package is distributed in the hope that it will be useful,
%%   but WITHOUT ANY WARRANTY; without even the implied warranty of
%%   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
%% 
%%   For error reports concerning UNCHANGED versions of this file no
%%   more than one year old, see CIRC.DVI.
%% 
%% IMPORTANT COPYRIGHT NOTICE:
%% 
%% You are NOT ALLOWED to distribute this file alone.
%% 
%% You are allowed to distribute this file under the condition that it
%% is distributed together with all the files listed in circ.txt.
%% 
%% If you receive only some of these files from someone, complain!
%% 
%% You are NOT ALLOWED to change this file.
input csym;

string optionname; optionname="optics";

font_identifier="cioptic";

input defcirc;

hsoa:=.128CIu;

slens_ht#   :=   2CIu#;
slens_lt#   :=   2CIu#;
slens_phi   :=   60;
slens_spc   :=   .55CIu;
define_pixels(slens_lt,slens_ht);

blens_ht#   :=   2CIu#;
blens_lt#   :=   2CIu#;
blens_phi   :=   45;
blens_spc   :=   .88CIu;
define_pixels(blens_lt,blens_ht);

sklens_ht#  :=   2CIu#;
sklens_lt#  :=   2CIu#;
sklens_phi  :=   60;
sklens_spc  :=   .58CIu;
sklens_bt   :=   1CIu;     % Breite Bottom und Top
define_pixels(sklens_lt,sklens_ht);

mir_ht#     :=  2CIu#;
mir_lt#     :=  2CIu#;
mir_wd      :=  .5CIu;    % Schraffurl"ange
define_pixels(mir_ht,mir_lt);

omb_wd# := 3CIu#;
omb_ht# := 2CIu#;
lab_wd# := 4CIu#;
lab_ht# := 2CIu#;
define_pixels(omb_wd,omb_ht,lab_wd,lab_ht);

pol_ht#  :=  2CIu#;
pol_lt#  :=  2CIu#;
pol_spc  := .2CIu;
define_pixels(pol_ht,pol_lt);

pin_ht#  :=  2CIu#;
pin_lt#  :=  2CIu#;
pin_spx  := .16CIu;
pin_spy  := .08CIu;
pin_spz  := .5CIu;
define_pixels(pin_ht,pin_lt);

cam_ht#  := 2CIu#;
cam_lt#  := 3CIu#;
cam_spx  := 2CIu;
cam_spy  := 1CIu;
define_pixels(cam_ht,cam_lt);

scr_ht#  := 4CIu#;
scr_lt#  := 2CIu#;
scr_spx  := 1CIu;
scr_spy  := 1CIu;
define_pixels(scr_ht,scr_lt);

def rectangle(expr width, height, xs, ys) =
  draw (xs,.5height+ys)--(width+xs,.5height+ys)--(width+xs,-.5height+ys)--
       (xs,-.5height+ys)--cycle;
enddef;

def small_lens =
  pickup pensquare scaled normalline;
  numeric pl;
  pl:=.5(slens_lt-slens_spc);
  z0=(.5slens_lt,-.5slens_ht);
  z1=(.5slens_lt,.5slens_ht);
  z2=(.5CIu,0); z3=z2+(hsoa,0);
  z4=(slens_lt-.5CIu,0); z5=z4-(hsoa,0);
  draw z0{dir slens_phi}..z1;
  draw z0{dir (180-slens_phi)}..z1;
  opticalaxis(normalline)(0);
  opticalaxis(normalline)(1CIu);
enddef;

def half_small_lens =
  pickup pensquare scaled normalline;
  numeric pl;
  pl:=.5(slens_lt-slens_spc);
  z0=(.5slens_lt,-.5slens_ht);
  z1=(.5slens_lt,.5slens_ht);
  z4=(slens_lt-.5CIu,0); z5=z4-(hsoa,0);
  draw z0{dir slens_phi}..z1;
  draw z1--z0;
  opticalaxis(normalline)(0);
  opticalaxis(normalline)(1CIu);
enddef;

def bold_lens =
  pickup pensquare scaled normalline;
  numeric pl;
  pl:=.5(blens_lt-blens_spc);
  z0=(.5blens_lt,-.5blens_ht);
  z1=(.5blens_lt,.5blens_ht);
  draw z0{dir blens_phi}..z1;
  draw z0{dir (180-blens_phi)}..z1;
  opticalaxis(normalline)(0);
  opticalaxis(normalline)(1CIu);
enddef;

def half_bold_lens =
  pickup pensquare scaled normalline;
  numeric pl;
  pl:=.5(blens_lt-blens_spc);
  z0=(.5blens_lt,-.5blens_ht);
  z1=(.5blens_lt,.5blens_ht);
  draw z0{dir blens_phi}..z1;
  draw z1--z0;
  opticalaxis(normalline)(0);
  opticalaxis(normalline)(1CIu);
enddef;

def small_konkav_lens =
  pickup pensquare scaled normalline;
  numeric pl, ql;
  pl:=.5(sklens_lt-sklens_spc);
  ql:=.5(sklens_lt-sklens_bt);
  z0=(ql,-.5sklens_ht);
  z1=(sklens_lt-ql,-.5sklens_ht);
  z2=(ql,.5sklens_ht);
  z3=(sklens_lt-ql,.5sklens_ht);
  z4=(.5CIu,0); z5=z4+(hsoa,0);
  z6=(sklens_lt-.5CIu,0); z7=z6-(hsoa,0);
  draw z0{dir sklens_phi}..z2--z3{dir (180+sklens_phi)}..z1--z0;
  draw z4--z5; draw z6--z7;
  opticalaxis(normalline)(0);
  opticalaxis(normalline)(1CIu);
enddef;

def half_small_konkav_lens =
  pickup pensquare scaled normalline;
  numeric pl, ql;
  pl:=.5(sklens_lt-sklens_spc);
  ql:=.5(sklens_lt+sklens_bt);
  z0=(.5sklens_lt,-.5sklens_ht);
  z1=(ql,-.5sklens_ht);
  z2=(.5sklens_lt,.5sklens_ht);
  z3=(ql,.5sklens_ht);
  draw z0--z2--z3{dir (180+sklens_phi)}..z1--z0;
  opticalaxis(normalline)(0);
  opticalaxis(normalline)(1CIu);
enddef;

def mirror =
  pickup pensquare scaled normalline;
  opticalaxis(normalline)(0);
  opticalaxisdown(normalline)(.5mir_lt,0);
  halfmirror;
  pickup pensquare scaled thinline;
  for i=.125 step .125 until .875:
     draw (i*mir_lt,(.5-i)*mir_ht)--(mir_wd+i*mir_lt,mir_wd+(.5-i)*mir_ht);
  endfor
enddef;

def halfmirror =
  pickup pensquare scaled thickline;
  draw (.5mir_wd,.5(mir_ht-mir_wd))--(mir_lt-.5mir_wd,.5(mir_wd-mir_ht));
enddef;

def halfmirrorline =
  pickup pensquare scaled normalline;
  opticalaxis(normalline)(0);
  opticalaxisdown(normalline)(.5mir_lt,.5mir_ht);
  opticalaxisdown(normalline)(.5mir_lt,0);
enddef;

def polarizer =
  pickup pensquare scaled thinline;
  numeric pl;
  pl:=.5(pol_lt-pol_spc);
  z0=(pl,.5pol_ht);
  z1=z0+(0,-pol_ht);
  z2=z1+(pol_spc,0);
  z3=z0+(pol_spc,0);
  draw z0--z1--z2--z3--cycle;
  % optical axis
  opticalaxis(normalline)(0);
  opticalaxis(normalline)(1CIu);
enddef;

def pinhole =
  pickup pensquare scaled thinline;
  numeric pl;
  pl:=.5(pin_lt-pin_spx);
  fill (.5pin_lt,.5pin_spy)--(pl,.5pin_spz)--(pl,.5pin_ht)--
       (pl+pin_spx,.5pin_ht)--(pl+pin_spx,.5pin_spz)--cycle;
  fill (.5pin_lt,-.5pin_spy)--(pl,-.5pin_spz)--(pl,-.5pin_ht)--
       (pl+pin_spx,-.5pin_ht)--(pl+pin_spx,-.5pin_spz)--cycle;
  % optical axis
  opticalaxis(normalline)(0);
  opticalaxis(normalline)(1CIu);
enddef;

def screenleft (expr gray) =
  pickup pensquare scaled normalline;
  path a, b;
  numeric pl;
  pl:=.5(scr_lt-scr_spx);
  z0=(pl,.5scr_ht);
  z1=(pl+scr_spx,scr_spy);
  z2=(pl+scr_spx,-.5scr_ht);
  z3=(pl,-scr_spy);
  draw z0--z1--z2--z3--cycle;
  a:=z0--z1;
  b:=z2--z3;
  vshade(b, a, gray, unitsquare);
enddef;

def screenright (expr gray) =
  pickup pensquare scaled normalline;
  path a, b;
  numeric pl;
  pl:=.5(scr_lt-scr_spx);
  z0=(pl,-.5scr_ht);
  z1=(pl,scr_spy);
  z2=(pl+scr_spx,.5scr_ht);
  z3=(pl+scr_spx,-scr_spy);
  draw z0--z1--z2--z3--cycle;
  a:=z1--z2;
  b:=z3--z0;
  vshade(b, a, gray, unitsquare);
enddef;

def opticalaxis(expr linethickness)(expr offset) =
  pickup pensquare scaled linethickness;
  draw (offset,0)--(offset+hsoa,0);
  draw (offset+3hsoa,0)--(offset+5hsoa,0);
  draw (offset+7hsoa,0)--(offset+1CIu,0);
enddef;

def halfopticalaxis(expr linethickness)(expr offset) =
  pickup pensquare scaled linethickness;
  draw (offset,0)--(offset+hsoa,0);
  draw (offset+3hsoa,0)--(offset+.5CIu,0);
enddef;

def opticalaxisdown(expr linethickness)(expr xoffset, yoffset) =
  pickup pensquare scaled linethickness;
  draw (xoffset,yoffset)--(xoffset,yoffset-hsoa);
  draw (xoffset,yoffset-3hsoa)--(xoffset,yoffset-5hsoa);
  draw (xoffset,yoffset-7hsoa)--(xoffset,yoffset-1CIu);
enddef;

def halfopticalaxisdown(expr linethickness)(expr xoffset, yoffset) =
  pickup pensquare scaled linethickness;
  draw (xoffset,yoffset)--(xoffset,yoffset-hsoa);
  draw (xoffset,yoffset-3hsoa)--(xoffset,yoffset-.5CIu);
enddef;

def camera =
  pickup pensquare scaled thickline;
  numeric pl;
  pl:=cam_lt-cam_spx;
  draw (pl,.25cam_spy)--(0,.5cam_spy)--(0,-.5cam_spy)--(pl,-.25cam_spy);
  draw (pl,.5cam_ht)--(pl,-.5cam_ht)--(cam_lt,-.5cam_ht)--(cam_lt,.5cam_ht)--cycle;
enddef;

"SmalCIuns";
twochars(0)(small_lens)(.5slens_ht#,slens_lt#,.5slens_ht#);

"HalfSmalCIuns";
fourchars(2)(half_small_lens)((slens_lt,0))(.5slens_ht#,slens_lt#,.5slens_ht#);

"BoldLens";
twochars(6)(bold_lens)(.5blens_ht#,blens_lt#,.5blens_ht#);

"HalfBoldLens";
fourchars(8)(half_bold_lens)((blens_lt,0))(.5blens_ht#,blens_lt#,.5blens_ht#);

"SmallKonkavLens";
twochars(12)(small_konkav_lens)(.5sklens_ht#,sklens_lt#,.5sklens_ht#);

"HalfSmallKonkavLens";
fourchars(14)(half_small_konkav_lens)((sklens_lt,0))(.5sklens_ht#,sklens_lt#,.5sklens_ht#);

"Mirror";
eightchars(85)(mirror)(.5mir_lt#,.5mir_ht#,.5mir_ht#,.5mir_lt#);

"BeamSplitter";
eightchars(36)(halfmirror;halfmirrorline)(.5mir_lt#,.5mir_ht#,.5mir_ht#,.5mir_lt#);

"Polarizer";
twochars(44)(polarizer)(.5pol_ht#,pol_lt#,.5pol_ht#);

"Pinhole";
twochars(46)(pinhole)(.5pin_ht#,pin_lt#,.5pin_ht#);

"Camera";
fourchars(66)(camera)((cam_lt,0))(.5cam_ht#,cam_lt#,.5cam_ht#);

"ScreenLeft";
twochars(72)(screenleft(2);opticalaxis(normalline)(0))(.5scr_ht#,scr_lt#,.5scr_ht#);

"ScreenRight";
twochars(74)(screenright(2);opticalaxis(normalline)(1CIu))(.5scr_ht#,scr_lt#,.5scr_ht#);

"ScreenLeftBehind";
twochars(76)(screenleft(2);halfopticalaxis(normalline)(1.5CIu))(.5scr_ht#,scr_lt#,.5scr_ht#);

"ScreenRightBehind";
twochars(78)(screenright(2);halfopticalaxis(normalline)(0))(.5scr_ht#,scr_lt#,.5scr_ht#);

"VScreenLeft";
twochars(80)(screenleft(4);opticalaxis(normalline)(0);halfopticalaxis(normalline)(1.5CIu))(.5scr_ht#,scr_lt#,.5scr_ht#);

"VScreenRight";
twochars(82)(screenright(4);opticalaxis(normalline)(1CIu);halfopticalaxis(normalline)(0))(.5scr_ht#,scr_lt#,.5scr_ht#);

"horizontal dashed half line to the right";
beginchar(128,.5CIu#,0pt,0pt);
   halfopticalaxis(normalline)(0);
endchar;

"horizontal dashed long line to the right";
beginchar(129,1CIu#,0pt,0pt);
   opticalaxis(normalline)(0);
endchar;

"horizontal dashed half line to the left";
beginchar(130,.5CIu#,0pt,0pt);
   halfopticalaxis(normalline)(-.5CIu);
endchar;

"horizontal dashed half line up";
beginchar(131,0pt,.5CIu#,0pt);
   halfopticalaxisdown(normalline)(0,.5CIu);
endchar;

"horizontal dashed long line up";
beginchar(132,0pt,1CIu#,0pt);
   opticalaxisdown(normalline)(0,1CIu);
endchar;

"horizontal dashed half line down";
beginchar(133,0pt,0pt,.5CIu#);
   halfopticalaxisdown(normalline)(0,0);
endchar;

"bold horizontal dashed half line to the right";
beginchar(136,.5CIu#,0pt,0pt);
   halfopticalaxis(2normalline)(0);
endchar;

"bold horizontal dashed long line to the right";
beginchar(137,1CIu#,0pt,0pt);
   opticalaxis(2normalline)(0);
endchar;

"bold horizontal dashed half line to the left";
beginchar(138,.5CIu#,0pt,0pt);
   halfopticalaxis(2normalline)(-.5CIu);
endchar;

"bold horizontal dashed half line up";
beginchar(139,0pt,.5CIu#,0pt);
   halfopticalaxisdown(2normalline)(0,.5CIu);
endchar;

"bold horizontal dashed long line up";
beginchar(140,0pt,1CIu#,0pt);
   opticalaxisdown(2normalline)(0,1CIu);
endchar;

"bold horizontal dashed half line down";
beginchar(141,0pt,0pt,.5CIu#);
   halfopticalaxisdown(2normalline)(0,0);
endchar;

if unknown cmbase: input cmbase fi

tracingstats:=1;
picture r[];

def put_text(expr ts,xstart,ystart,rot,justification) =
  begingroup
    text_width:=0;text_height:=0;
    for ind:=0 step 1 until length(ts)-1:
      dec_num:=ASCII substring (ind,ind+1) of ts;
      if unknown r[dec_num]: dec_num:=32; fi
      if dec_num=32:
        text_width:=text_width+wd[65];
        text_height:=max(text_height,ht[65]+dp[65]);
      elseif dec_num>=0:
        text_width:=text_width+wd[dec_num];
        text_height:=max(text_height,ht[dec_num]+dp[dec_num]);
      fi
    endfor
    if rot=90:
      if justification=1: ynext:=ystart;
      elseif justification=2: ynext:=round(ystart-text_width/2);
      else: ynext:=round(ystart-text_width);
      fi
      xnext:=xstart+text_height/2;
    else:
      if justification=1: xnext:=xstart;
      elseif justification=2: xnext:=round(xstart-text_width/2);
      else: xnext:=round(xstart-text_width);
      fi
      ynext:=ystart-text_height/2;
    fi
    for ind:=0 step 1 until length(ts)-1:
      dec_num:=ASCII substring (ind,ind+1) of ts;
      if unknown r[dec_num]: dec_num:=32; fi
      if dec_num=32:
        xnext:=xnext+wd[65]*cosd rot;
        ynext:=ynext+wd[65]*sind rot;
      elseif dec_num>=0:
        currentpicture:=currentpicture+r[dec_num] shifted(xnext,ynext)
          rotatedaround ((xnext,ynext),rot);
        xnext:=xnext+wd[dec_num]*cosd rot;
        ynext:=ynext+wd[dec_num]*sind rot;
      fi
    endfor
  endgroup
enddef;

def endchar =
  r[charcode]:=currentpicture;
  wd[charcode]:=w;ht[charcode]:=h;dp[charcode]:=d;
  endgroup;
enddef;
let endchar_ = endchar;
let generate = relax;
let roman = relax;
input cmss10.mf
if ligs>1: font_coding_scheme:="TeX text";
else: font_coding_scheme:=
  if ligs=0: "TeX typewriter text"
  else: "TeX text without f-ligatures" fi;
fi
font_setup;
input romanu.mf %Roman uppercase.
input romanl.mf %Roman lowerrcase.

def endchar =
  % Next line should probably be removed if CM base is used
  %Include the next two lines if you want to
  %rotate the picture 90 deg.(Portrait to Landscape)
  %currentpicture:=currentpicture rotated 90 shifted (h,0);
  %tmp:=charht; charht:=charwd; charwd:=tmp;
  scantokens extra_endchar;
  if proofing>0: makebox(proofrule); fi
  chardx:=w;
  shipit;
  if displaying>0: makebox(screenrule); showit; fi
  endgroup
enddef;
let endchar_ = saveendchar;
let generate = input;
let roman = roman;
def t_ = transformed currenttransform enddef;

"Laser Box horizontal";
beginchar(160,lab_wd#,.5lab_ht#,.5lab_ht#);
  pickup pensquare scaled thickline;
  rectangle(lab_wd,lab_ht,0,0);
  pickup pencircle scaled normalline;
  put_text("Laser",.5lab_wd,0,0,2);
endchar;

"Laser Box vertical";
beginchar(161,.5lab_ht#,lab_wd#,.5lab_ht#);
  pickup pensquare scaled thickline;
  rectangle(lab_ht,lab_wd,-.5lab_ht,.5lab_wd);
  pickup pencircle scaled normalline;
  put_text("Laser",0,.5lab_wd,90,2);
endchar;

"Photometer Box horizontal";
beginchar(162,omb_wd#,.5omb_ht#,.5omb_ht#);
  pickup pensquare scaled thickline;
  rectangle(omb_wd,omb_ht,0,0);
  pickup pencircle scaled normalline;
  put_text("PM",.5omb_wd,0,0,2);
endchar;

"Photometer Box vertical";
beginchar(163,.5omb_ht#,omb_wd#,.5omb_ht#);
  pickup pensquare scaled thickline;
  rectangle(omb_ht,omb_wd,-.5omb_ht,.5omb_wd);
  pickup pencircle scaled normalline;
  put_text("PM",0,.5omb_wd,90,2);
endchar;

"Optical Modulator Box horizontal";
beginchar(164,omb_wd#,.5omb_ht#,.5omb_ht#);
  pickup pensquare scaled thickline;
  rectangle(omb_wd,omb_ht,0,0);
  pickup pensquare scaled normalline;
  put_text("OM",.5omb_wd,0,0,2);
endchar;

"Optical Modulator Box vertical";
beginchar(165,omb_ht#,.5omb_wd#,.5omb_wd#);
  pickup pensquare scaled thickline;
  rectangle(omb_ht,omb_wd,0,0); %-.5omb_ht,.5omb_wd);
  pickup pensquare scaled normalline;
  put_text("OM",.5omb_ht,0,90,2);
endchar;

end;
%% 
%%
%% End of file `cioptic.mf'.
