'***************************************************** '* REDUCTION OF CONICALS * '* of equation: ax^2+2bxy+cy^2+2dx+2ey+f=0 * '* ------------------------------------------------- * '* The program, knowing the coefficients a, b, c, d, * '* e and f of the cartesian equation, finds the * '* caracteristics of the reduction elements: * '* type of conical (hyperbola,parabola,ellipse or * '* circle) and center position, focus position(s), * '* axes and excentricity. * '* ------------------------------------------------- * '* Ref.: "Mathematiques en Turbo-Pascal By M. Ducamp * '* and A. Reverchon (vol 2), Eyrolles, Paris, 1988" * '* [BIBLI 05]. * '* ------------------------------------------------- * '* SAMPLE RUN: * '* * '* REDUCTION OF CONICALS * '* * '* a = 1 * '* 2b = 2 * '* c = 1 * '* 2d = -13 * '* 2e = -11 * '* f = 32 * '* * '* Type: Parabola * '* * '* Center: x=0.999999 y=5.000000 * '* Symmetry direction: x=1 y=-1 * '* Focus: x=1.124999 y=4.875000 * '* Parameter: 0.35355339 * '* * '* Basic version by J-P Moreau. * '* (www.jpmoreau.fr) * '***************************************************** defdbl a-h,o-z defint i-n ' input variables: ' a,b,c,d,e,f: DOUBLE; (coefficients of cartesian equation) ' output variables: ' ityp: type of conical (integer) ' 1: ellipse ' 2: hyperbola ' 3: parabola ' 4: circle ' 5: line ' 6: two lines ' 7: one point ' 8: no conical at all. ' ex: excentricity (or parameter for a parabola), ' xc,yc: coordinates of center, ' xla,xlb: axis half-length for an ellipse (la, radius for a circle), ' xf1,yf1,xf2,yf2: focus coordinates (only one focus for a parabola), ' xs1,ys1,xs2,ys2: summit coordinates for an hyperbola, ' xv1,yv1,xv2,yv2: vector directions of symmetry axes ' (only one direction for a parabola). ' other internal variables: ' delta,u,xl,xm,x2,y2: DOUBLE; ' i,j,ityp: INTEGER; 'begin main program cls print print " REDUCTION OF CONICALS" print input " a = ", a input " 2b = ", b input " c = ", c input " 2d = ", d input " 2e = ", e input " f = ", f print b=b/2: d=d/2: e=e/2 delta=a*c-b*b if delta=0 then gosub 1000 'call Parabola else xc=(b*e-d*c)/delta yc=(b*d-a*e)/delta f = f + a*xc*xc+2*b*xc*yc+c*yc*yc+2*d*xc+2*e*yc if f=0 then if delta>0 then ityp=7 'one point else ityp=6 'two lines goto 100 end if end if u=sqr((a-c)*(a-c)+4*b*b) xl=(a+c-u)/2: xm=(a+c+u)/2 if a=c and b=0 then if f*a>=0 then ityp=8 'no conical goto 100 else ityp=4 'circle xla=sqr(-f/a) ex=1# goto 100 end if end if if a0 then typ=8 'no conical return end if xla=sqr(-f/xl): xlb=sqr(-f/xm) if xl<0 then u=xla: xla=xlb: xlb=u u=x2: x2=-y2: y2=u u=xv1: xv1=-yv1: yv1=u end if xv2=-yv1: yv2=xv1 u=sqr(xla*xla-xlb*xlb) xf1=xc+x2*u: yf1=yc+y2*u xf2=xc-x2*u: yf2=yc-y2*u ex=u/xla return 'end of file conical.bas