#include <stdio.h>

#include <math.h>

#define PI 3.14159365
#define DEG_PER_RAD (180.0/PI)
#define RAD_PER_DEG (PI/180.0)



/******************************************************************************/
// finds the coefficients for the bell parable
// the eq. has the form:
// y= a * sqrt(x + b) + c
// parable_1,parable_2, are the start/end points of the parable
// alpha the starting angle in DEG
// solves 3 equations


void CalcParabola(double x1, double y1, double x2, double y2, double alpha)
{

long double e,k,a,b,c;


e = tan (RAD_PER_DEG * alpha );
k = y2-y1+(2*x1*e);
b = (4*x1*x2*e*e - k*k)/(4*e*k-4*x1*e*e-4*x2*e*e);  
a = (y2-y1)/(sqrt(x2+b)-sqrt(x1+b));        
c = y1 - a*sqrt(x1+b);        


double x=x1;
double y=0;
while(x<x2)
	{

	y=a*sqrt(x+b)+c;
	printf("%6.6f,%6.6f,0\n",x,y);
	x+=0.01;
    }


}




int main(int argc, char ** argv)
{
double x1=0.239756;
double y1=0.971775;

double x2=1.97;
double y2=1.4575;

double alpha=20;

printf("polyline ");
CalcParabola(x1,y1,x2,y2,alpha);


return 0;
}
