/*  Written by W. Taylor, Math Dept, Univ. of Colorado, Boulder,Colo
    80309-0426, ...![ucbvax,allegra]!nbires!boulder!wtaylor  or
    wtaylor@boulder (cs-net).  Last revised 8/22/87                   */

#include <math.h>
#include <stdio.h>
#include "coords.h"

#define PI 3.14159

#define FOCUS 4.0       /* the joint foci are at +/- this number. */
#define BB 1.0         /* a parameter that determines the minor axes
						of the ellipses. */
#define HYPS 10

#define STEP 250           /* Number of divisions of the time interval. Here
                              you can experiment for the best value. Too small
                              and you'll see the corners. Too large and you'll
                              get undesired effects which come from overloading
                              the memory of the printer.  */

/* The curve will be defined parametrically with a parameter  t  which
ranges between two real numbers, which are as follows. Edit these to suit
the case at hand. */

#define START_T 0.0    /* This, and others, must be written as double */
#define STOP_T (2*PI)

/* The next four numbers give the values of the  x  and  y  co-ordinates
at the sides of the window which will be printed. These also can be
changed to suit the case at hand. */

#define LEFT  -7.10 /*  value of  u  at left of window    */
#define RIGHT 7.10
#define BOTTOM -7.10 /*  value of  v  at bottom of window  */
#define TOP 7.10

point f(t,r)
int r; double t;
{
point p;
double b = r*BB;
double c = FOCUS;
double a = sqrt(c*c + b*b);
p.x_coord =  a*cos(t);
p.y_coord =  b*sin(t);
return (p);
}

point h(t,r)
int r; double t;
{
point p;
double u;
double c = FOCUS;
double a = (((double) r)/HYPS)*c;
double b = sqrt(c*c - a*a);
u = 5*(t-PI);
p.x_coord =  a*cosh(u);
p.y_coord =  b*sinh(u);
return (p);
}

main()
{
int r;
point p, f(), h(), g();
char *login, *getlogin();

open_tek();
draw_frame();
for (r=1;r<=6;r+=1)
{
	tek_print_path_param(START_T,STOP_T,STEP,LEFT,RIGHT,BOTTOM,TOP,f,r);
}
for (r=(-HYPS+1);r<HYPS;r+=2)
{
	tek_print_path_param(START_T,STOP_T,STEP,LEFT,RIGHT,BOTTOM,TOP,h,r);
}
alpha_mode();

small_type();
label_x_axis(LEFT,RIGHT);
label_y_axis(TOP,BOTTOM);

large_type();

/*TELL WHERE YOU WANT THE LABEL TO BE*/
p.x_coord = 1.1;  /* inches from left of paper */
p.y_coord = 0.5;  /* inches from bottom of paper */

set_abs_vh(p);
alpha_mode();

/* TEXT */
printf("Confocal ellipses and hyperbolas");

small_type();
p.x_coord += 6.0;
p.y_coord -= 0.15;
set_abs_vh(p);
alpha_mode();
printf("login name: %s",getlogin());
end_tek();
}




