% mathematical symbols by Anthony Phan.
% file: mathineq.mf (inequalities)
% last modification: May 16, 2005.
% Only known charcodes will be generated.

% Inequality signs and related things (relations).
% Some pictures overlap the bottom. It is necessary
% for correct centering of the whole box.
% Spreads for cross bars have been checked.
% Curly slants are strange: it is half way to two
% extreme solutions...

def horizontal_rules_list=math_axis,
  -body_depth,-desc_depth,x_height,cap_height,asc_height,body_height
enddef;

use_rule1;
make_sim_picture;

if (main_name_string="less") or (main_name_string="greater"):

  beginpicture(first,
    12u#+2appr#,v_center(spread4#+rth#));
  pickup tiny.nib;
  y2r=0.5[y1,y3]=good.y math_axis; y1-y3=spread4;
  rt x1=w-Appr; lft x2r=Appr; x1=x1r=x3=x3r;
  adjust_slanted_bar(2r,1,2a,1a)(0.5(rth-tiny),-1);
  adjust_slanted_bar(2r,3,2b,3b)(0.5(rth-tiny),1);
  z1r=whatever[z2r,z1a]; z3r=whatever[z2r,z3b];
  z1r-z1=z1-z1l; z3r-z3=z3-z3l;
  z2l-z1l=whatever*(z2r-z1r);
  z2l-z3l=whatever*(z2r-z3r);
  filldraw stroke z3e--z2e--z1e;
  a:=2vround 0.5(spread1/abs cosd angle(z2r-z3r));
  endpicture;

  beginpicture(second,
    12u#+2appr#,v_center(spread4#+rth#));
  pickup tiny.nib;
  y2r=0.5[y1,y3]=good.y math_axis; y1-y3=spread4;
  lft x1=Appr; rt x2r=w-Appr; x1=x1r=x3=x3r;
  adjust_slanted_bar(2r,1,2a,1a)(0.5(rth-tiny),1);
  adjust_slanted_bar(2r,3,2b,3b)(0.5(rth-tiny),-1);
  z1r=whatever[z2r,z1a]; z3r=whatever[z2r,z3b];
  z1r-z1=z1-z1l; z3r-z3=z3-z3l;
  z2l-z1l=whatever*(z2r-z1r);
  z2l-z3l=whatever*(z2r-z3r);
  filldraw stroke z3e--z2e--z1e;
  endpicture;

else:
  
  beginpicture(first,
    12u#+2appr#,v_center(spread4#+rth#));
  pickup tiny.nib; pos2(rth,90); pos4(rth,90);
  lft x2=Appr; rt x1r=rt x3l=w-Appr; x4=0.50[x2,x1r];
  y2=y4=math_axis; y3l-y2r=y2l-y1r=0.5spread4; y1r=y1l; y3r=y3l;
  x1r-x1l=diag_width(rth-tiny,z4r-z1r);
  x3l-x3r=diag_width(rth-tiny,z4l-z3l);
  filldraw stroke z2e{right}...z1e{z1r-z4r};
  filldraw stroke z2e{right}...z3e{z3l-z4l};
  a:=spread1;
  endpicture;

  beginpicture(second,
    12u#+2appr#,v_center(spread4#+rth#));
  pickup tiny.nib; pos2(rth,-90); pos4(rth,-90);
  rt x2=w-Appr; lft x1l=lft x3r=Appr; x4=0.50[x2,x1l];
  y2=y4=math_axis; y3r-y2l=y2r-y1l=0.5spread4; y1r=y1l; y3r=y3l;
  x1l-x1r=-diag_width(rth-tiny,z4l-z1l);
  x3r-x3l=-diag_width(rth-tiny,z4r-z3r);
  filldraw stroke z2e{left}...z1e{z1l-z4l};
  filldraw stroke z2e{left}...z3e{z3r-z4r};
  endpicture;
fi

if (main_name_string="greater") or (main_name_string="successor"):
  tmp_picture:=first_picture; first_picture:=second_picture;
  second_picture:=tmp_picture;
fi

%
% Let's go
%

beginchar(main_name_with(),
    12u#+2appr#,v_center(spread4#+rth#));
  main_name_string&" sign";
  currentpicture:=first_picture;
endchar;

beginchar(main_name_with(_not),
    12u#+2appr#,asc_height#,asc_depth#);
  "not " & main_name_string&" sign";
  currentpicture:=first_picture;
  pickup tiny.nib;
  pos1(rth,0); pos2(rth,0); top y1l=h; bot y2l=-d;
  lft x1l=lft x2l=hround 0.5(w-rth);
  filldraw stroke z1e..z2e; penlabels(1,2);
endchar;

beginchar(main_name_with(_slant),
    12u#+2appr#,v_center(spread4#+spread1#+rth#));
  main_name_string&"-slant sign";
  currentpicture:=first_picture shifted(0,0.5a);
  save b;
  pickup tiny.nib;
  if (main_name_string="less") or (main_name_string="greater"):
    y0=good.y math_axis; lft x1=Appr; rt x2=w-Appr;
    b=(rth-tiny)/cosd angle(x2-x1,0.5spread4);
    penpos1(b,90); penpos2(b,90);
    if (main_name_string="less"):  y1=y0-0.5a; y1-y2=0.5spread4;
    else: y2=y0-0.5a; y1-y2=-0.5spread4; fi
    filldraw stroke z1e..z2e; penlabels(1,2);
  elseif main_name_string="predecessor":
    pos2(rth,-90); pos3(rth,-90);
    lft x2=Appr; y2=y3=math_axis-0.5spread1;
    rt x1l=rt x1=w-Appr; y1=y2r-0.5spread4;
    x3=0.50[x2,x1l];
    y1l=y1r=y2r-vround(0.5spread4
      *(0.5[1,1/abs cosd angle(z3l-z1)]));
    x1l-x1r=diag_width(rth-tiny,z3l-z1l);
    filldraw stroke z1e{z3l-z1l}...z2e{left};
    penlabels(1,2,3);
  else:
    pos2(rth,-90); pos3(rth,-90);
    rt x2=w-Appr; y2=y3=math_axis-0.5spread1;
    lft x1l=lft x1=Appr; y1=y2r-0.5spread4;
    x3=0.50[x2,x1l];
    y1l=y1r=y2r-vround(0.5spread4
      *(0.5[1,1/abs cosd angle(z3l-z1)]));
    x1l-x1r=-diag_width(rth-tiny,z3l-z1l);
    filldraw stroke z1e{z3l-z1l}...z2e{right};
    penlabels(1,2,3);
  fi
  tmp_picture:=currentpicture;
endchar;

beginchar(main_name_with(_not_slant),
    12u#+2appr#,asc_height#,asc_depth#);
  "not "&main_name_string&"-slant sign";
  currentpicture:=tmp_picture;
  pickup tiny.nib;
  pos1(rth,0); pos2(rth,0); top y1l=h; bot y2l=-d;
  lft x1l=lft x2l=hround 0.5(w-rth);
  filldraw stroke z1e..z2e; penlabels(1,2);
endchar;

beginchar(main_name_with(_eq),
    12u#+2appr#,v_center(spread4#+spread0#+rth#));
  main_name_string&"-bar sign";
  currentpicture:=first_picture shifted(0,0.5spread0);
  pickup tiny.nib;
  pos1(rth,90); pos2(rth,90); rt x2=w-Appr; lft x1=Appr;
  y1=y2=math_axis-0.5(spread4+spread0);
  filldraw stroke z1e..z2e; penlabels(1,2);
  tmp_picture:=currentpicture;
endchar;

beginchar(main_name_with(_not_eq),
    12u#+2appr#,asc_height#,asc_depth#);
  "not "&main_name_string&"-bar sign";
  currentpicture:=tmp_picture;
  pickup tiny.nib;
  pos1(rth,0); pos2(rth,0); top y1l=h; bot y2l=-d;
  lft x1l=lft x2l=hround 0.5(w-rth);
  filldraw stroke z1e..z2e; penlabels(1,2);
endchar;

beginchar(main_name_with(_eq_not),
    12u#+2appr#,v_center(spread4#+spread0#+rth#));
  main_name_string&"-not bar sign";
  currentpicture:=tmp_picture;
  pickup tiny.nib;
  y0=math_axis-0.5(spread4+spread0);
  x0=0.5w;
  v_adjust(1r,2l,y0,1.5spread1-0.5rth);
  lft x2l-Appr=w-Appr-rt x1r=hround 3.5u;
  adjust_slanted_bar(2l,1r,2r,1l)(rth-tiny,-1);
  filldraw stroke z1e..z2e; penlabels(0,1,2);
endchar;

beginchar(main_name_with(_eq_varnot),
    12u#+2appr#,v_center(spread4#+spread0#+rth#));
  main_name_string&"-varnot bar sign";
  currentpicture:=tmp_picture;
  pickup tiny.nib;
  y0=math_axis-0.5(spread4+spread0);
  x0=0.5w;
  v_adjust(1l,2l,y0,1.5spread1-0.5rth);
  pos1(rth,0); pos2(rth,0);
  lft x1l=lft x2l=hround 0.5(w-rth);
  filldraw stroke z1e..z2e; penlabels(0,1,2);
endchar;

beginchar(main_name_with(_eqq),
    12u#+2appr#,v_center(spread4#+spread1#+spread0#+rth#));
  main_name_string&" equal sign";
  currentpicture:=first_picture shifted(0,0.5(spread1+spread0));
  pickup tiny.nib;
  pos1(rth,90); pos2(rth,90); pos3(rth,90); pos4(rth,90);
  rt x2=rt x4=w-Appr; lft x1=lft x3=Appr;
  y1=y2=math_axis-0.5(spread4-spread1+spread0);
  y3=y4=y1-spread1;
  filldraw stroke z1e..z2e; filldraw stroke z3e..z4e;
  penlabels(1,2,3,4);
  tmp_picture:=currentpicture;
endchar;

beginchar(main_name_with(_not_eqq),
    12u#+2appr#,v_center(max(asc_height#+asc_depth#,
	spread4#+spread1#+spread0#+rth#)));
  "not "&main_name_string&" equal sign";
  currentpicture:=tmp_picture;
  pickup tiny.nib;
  pos1(rth,0); pos2(rth,0);
  v_adjust(1l,2l,math_axis,max(h+d,spread4+spread0+2spread1));
  lft x1l=lft x2l=hround 0.5(w-rth);
  filldraw stroke z1e..z2e; penlabels(1,2);
endchar;

beginchar(main_name_with(_eqq_not),
    12u#+2appr#,v_center(spread4#+spread1#+spread0#+rth#));
  main_name_string&" but not equal sign";
  currentpicture:=tmp_picture;
  pickup tiny.nib;
  y0=math_axis-0.5(spread4+spread0);
  x0=0.5w;
  v_adjust(1r,2l,y0,2.5spread1-0.5rth);
  lft x2l-Appr=w-Appr-rt x1r=hround 2.75u;
  adjust_slanted_bar(2l,1r,2r,1l)(rth-tiny,-1);
  filldraw stroke z1e..z2e; penlabels(0,1,2);
endchar;

beginchar(main_name_with(_eqq_varnot),
    12u#+2appr#,v_center(spread4#+spread1#+spread0#+rth#)); 
  "variant "&main_name_string&" but not equal sign";
  currentpicture:=tmp_picture;
  pickup tiny.nib;
  y0=math_axis-0.5(spread4+spread0);
  x0=0.5w;
  v_adjust(1l,2l,y0,2.5spread1-0.5rth);
  pos1(rth,0); pos2(rth,0);
  lft x1l=lft x2l=hround 0.5(w-rth);
  filldraw stroke z1e..z2e; penlabels(1,2);
endchar;

beginchar(main_name_with(_upperslant),
    12u#+2appr#,v_center(spread4#+spread1#+rth#));
  main_name_string &"with upper slant sign";
  currentpicture:=first_picture shifted(0,-0.5a);
  save b;
  pickup tiny.nib;
  if (main_name_string="less") or (main_name_string="greater"):
    y0=good.y math_axis; lft x1=Appr; rt x2=w-Appr;
    b=(rth-tiny)/cosd angle(x2-x1,0.5spread4);
    penpos1(b,90); penpos2(b,90);
    if (main_name_string="less"):  y1=y0+0.5a; y1-y2=-0.5spread4;
    else: y2=y0+0.5a; y1-y2=0.5spread4; fi
    filldraw stroke z1e..z2e; penlabels(1,2);
  elseif main_name_string="predecessor":
    pos2(rth,90); pos3(rth,90);
    lft x2=Appr; y2=y3=math_axis+0.5spread1;
    rt x1l=rt x1=w-Appr; y1=y2r+0.5spread4;
    x3=0.50[x2,x1l];
    y1l=y1r=y2r+vround(0.5spread4
      *(0.5[1,1/abs cosd angle(z3l-z1)]));
    x1l-x1r=diag_width(rth-tiny,z3l-z1l);
    filldraw stroke z1e{z3l-z1l}...z2e{left};
    penlabels(1,2,3);
  else:
    pos2(rth,90); pos3(rth,90);
    rt x2=w-Appr; y2=y3=math_axis+0.5spread1;
    lft x1l=lft x1=Appr; y1=y2r+0.5spread4;
    x3=0.50[x2,x1l];
    y1l=y1r=y2r+vround(0.5spread4
      *(0.5[1,1/abs cosd angle(z3l-z1)]));
    x1l-x1r=-diag_width(rth-tiny,z3l-z1l);
    filldraw stroke z1e{z3l-z1l}...z2e{right};
    penlabels(1,2,3);
  fi
  tmp_picture:=currentpicture;
endchar;

beginchar(main_name_with(_not_upperslant),
    12u#+2appr#,asc_height#,asc_depth#);
  "not " & main_name_string&" upper slant sign";
  currentpicture:=tmp_picture;
  pickup tiny.nib;
  pos1(rth,0); pos2(rth,0); top y1l=h; bot y2l=-d;
  lft x1l=lft x2l=hround 0.5(w-rth);
  filldraw stroke z1e..z2e; penlabels(1,2);
endchar;

beginchar(main_name_with(_opposite),
    12u#+2appr#,v_center(1.5spread4#+spread1#+rth#));
  main_name_string&" and opposite sign";
  currentpicture:=(first_picture
    shifted(0,vround(0.5a+0.25spread4)))
  +(second_picture
    shifted(0,-vround(0.5a+0.25spread4)));
endchar;

beginchar(main_name_with(_eq_opposite),12u#+2appr#,
    v_center(2spread4#+2spread0#+rth#));
  main_name_string&" bar opposite sign";
  currentpicture:=(first_picture
    shifted(0,vround(spread0+0.5spread4)))
  +(second_picture
    shifted(0,-vround(spread0+0.5spread4)));
  pickup tiny.nib; pos1(rth,90); pos2(rth,90);
  lft x1=Appr; rt x2=w-Appr; y1=y2=math_axis;
  filldraw stroke z1e..z2e; penlabels(1,2);
endchar;

beginchar(main_name_with(_eqq_opposite),12u#+2appr#,
    v_center(2spread4#+2spread0#+spread1#+rth#));
  main_name_string&" equal opposite sign";
  pickup tiny.nib;
  pos1(rth,90); pos2(rth,90); pos3(rth,90); pos4(rth,90);
  lft x1=lft x3=Appr; rt x2=rt x4=w-Appr;
  y1-y3=y2-y4=spread1; 0.5[y1,y3]=0.5[y2,y4]=math_axis;
  currentpicture:=(first_picture
    shifted(0,vround(spread0+0.5spread1+0.5spread4)))
  +(second_picture
    shifted(0,-vround(spread0+0.5spread1+0.5spread4)));
  filldraw stroke z1e..z2e; filldraw stroke z3e..z4e;
  penlabels(1,2,3,4);
endchar;

beginchar(main_name_with(_sim),12u#+2appr#,
    v_center(spread4#+spread1#+spread0#+rth#));
  main_name_string&" similarity sign";
  numeric b,c; b=vround(0.5spread1+0.5spread0);
  c=b-vround(0.5(spread4+spread1)+spread0);
  currentpicture:=(first_picture shifted(0,b))
  +(sim_picture shifted(0,c));
  tmp_picture:=currentpicture;
endchar;

beginchar(main_name_with(_not_sim),
    12u#+2appr#,v_center(max(asc_height#+asc_depth#,
	spread4#+spread1#+spread0#+rth#)));
  "not "&main_name_string&" similarity sign";
  currentpicture:=tmp_picture;
  pickup tiny.nib;
  pos1(rth,0); pos2(rth,0);
  v_adjust(1l,2l,math_axis,max(h+d,spread4+spread0+2spread1));
  lft x1l=lft x2l=hround 0.5(w-rth);
  filldraw stroke z1e..z2e; penlabels(1,2);
endchar;

beginchar(main_name_with(_sim_not),
    12u#+2appr#,v_center(spread4#+spread1#+spread0#+rth#));
  main_name_string&" but not similarity sign";
  currentpicture:=tmp_picture;
  pickup tiny.nib;
  y0=math_axis-0.5(spread4+spread0);
  x0=0.5w;
  v_adjust(1r,2l,y0,2spread1);
  lft x2l-Appr=w-Appr-rt x1r=hround 2.75u;
  adjust_slanted_bar(2l,1r,2r,1l)(rth-tiny,-1);
  filldraw stroke z1e..z2e; penlabels(0,1,2);
endchar;

beginchar(main_name_with(_approx),
    12u#+2appr#,v_center(spread4#+2spread1#+spread0#+2rth#));
  main_name_string&" approximative sign";
  numeric b,c; b=vround(spread1+0.5spread0+0.5rth);
  c=b-vround(0.5(spread4+spread1)+spread0);
  currentpicture:=(first_picture shifted(0,b))
  +(sim_picture shifted(0,c))
  +(sim_picture shifted(0,c-spread1-rth));
  tmp_picture:=currentpicture;
endchar;

beginchar(main_name_with(_not_approx),
    12u#+2appr#,v_center(max(asc_height#+asc_depth#,
	spread4#+2spread1#+spread0#+2rth#)));
  main_name_string&" but not approximative sign";
  currentpicture:=tmp_picture;
  pickup tiny.nib;
  pos1(rth,0); pos2(rth,0);
  v_adjust(1l,2l,math_axis,max(h+d,spread4+spread0+3spread1));
  lft x1l=lft x2l=hround 0.5(w-rth);
  filldraw stroke z1e..z2e; penlabels(1,2);
endchar;

beginchar(main_name_with(_approx_not),
    12u#+2appr#,v_center(spread4#+2spread1#+spread0#+2rth#));
  main_name_string&" but not approximative sign";
  currentpicture:=tmp_picture;
  pickup tiny.nib;
  y0=math_axis-0.5(spread4+spread0);
  x0=0.5w;
  v_adjust(1r,2l,y0,3spread1);
  lft x2l-Appr=w-Appr-rt x1r=hround 2.5u;
  adjust_slanted_bar(2l,1r,2r,1l)(rth-tiny,-1);
  filldraw stroke z1e..z2e; penlabels(0,1,2);
endchar;

beginchar(main_name_with(_dot),
    12u#+2appr#,v_center(spread4#+rth#));
  main_name_string&" with dot sign";
  currentpicture:=first_picture; pickup tiny.nib;
  adjust_dot1((
      if (main_name_string="less") or (main_name_string="predecessor"):
	w-Appr-u-0.5dtsz else: Appr+u+0.5dtsz fi,
      good.y math_axis),dtsz,false,true);
  dot(1,1');
endchar;





