  function [tpLeft,tpRight] = TanPoints(p,q,r)
% p is a column 2-vector that identifies an observer point.
% q is a column 2-vector that defines the center of a radius r disk.
% tpLeft is a column 2-vector that specifies the location of the 
%     tangent point of a ray from p to the left edge of the disk.
% tpRight is a column 2-vector that specifies the location of the 
%     tangent point of a ray from p to the right edge of the disk.

  v = q-p;
  d = norm(v);
  v = v/d;
  theta = asin(r/d);
  c = cos(theta);
  s = sin(theta);
  uL = [c s ; -s c]'*v;
  uR = [c s ; -s c]*v;
  const = sqrt(d^2 - r^2);
  tpLeft = p + const*uL;
  tpRight =p + const*uR;