{$n+} uses graph; var gd, gm: integer; const a = 3; b = 9; L: double = 4; scale = 12; type tcurve = procedure(t: double; var x, y: double); (* cubic curves *) procedure decart(t: double; var x, y: double); far; begin x := 3 * a * t / (1 + t * sqr(t)); y := 3 * a * sqr(t) / (1 + t * sqr(t)); end; procedure strophoide(t: double; var x, y: double); far; begin x := a * (sqr(t) - 1) / (sqr(t) + 1); y := a * t * (sqr(t) - 1) / (sqr(t) + 1); end; procedure cissoide(t: double; var x, y: double); far; begin x := a * sqr(t) / (1 + sqr(t)); y := a * t * sqr(t) / (1 + sqr(t)); end; (* cycloides *) procedure cycloide(t: double; var x, y: double); far; begin x := a * (t - L * sin(t)); y := a * (1 - L * cos(t)); end; procedure epi_cycloide(t: double; var x, y: double); far; begin x := (a + b) * cos(t) - L * a * cos((a + b)*t / a); y := (a + b) * sin(t) - L * a * sin((a + b)*t / a); end; procedure hypo_cycloide(t: double; var x, y: double); far; begin x := (b - a) * cos(t) + L * a * cos((b - a)*t / a); y := (b - a) * sin(t) - L * a * sin((b - a)*t / a); end; (* quartic curves *) procedure conhoide(t: double; var x, y: double); far; begin x := a + L * cos(t); y := a * sin(t) / cos(t) + L * sin(t) end; procedure ulitka(t: double; var x, y: double); far; begin x := a * sqr(cos(t)) + l * cos(t); y := a * cos(t) * sin(t) + l * sin(t); end; procedure cardioide(t: double; var x, y: double); far; begin x := a * cos(t) * (1 + cos(t)); y := a * sin(t) * (1 + cos(t)); end; (* other *) procedure hyp_spiral(t: double; var x, y: double); far; begin x := a * cos(t)/t; y := a * sin(t)/t; end; procedure evolventa(t: double; var x, y: double); far; begin x := a * cos(t) + a * t * sin(t); y := a * sin(t) - a * t * cos(t); end; (* ***** heart of program ***** *) procedure set_point(t: double; f: tcurve); var x, y: double; begin f(t, x, y); putpixel( (getmaxx div 2) + trunc(scale * x), (getmaxy div 2) - trunc(scale * y), white ); end; procedure draw_curve(start, finish, step: double; f: tcurve); var t: double; begin setcolor(green); line(0, getmaxy div 2, getmaxx, getmaxy div 2); line(getmaxx div 2, 0, getmaxx div 2, getmaxy); t := start; while t <= finish do begin set_point(t, f); t := t + step; end; end; const step = 0.005; begin gd := detect; initgraph(gd, gm, ''); if graphresult <> grok then begin writeln('graphics error ...'); halt(100) end; { 1 } cleardevice; draw_curve(-10, -1-step, step, decart); draw_curve(-1+step, 10, step, decart); readln; { 2 } cleardevice; draw_curve(-10, 10, step, cissoide); readln; { 3 } cleardevice; draw_curve(-10, 10, step, strophoide); readln; { 4 } cleardevice; draw_curve(-pi/2+step, pi/2-step, step, conhoide); draw_curve(pi/2+step, 3*pi/2-step, step, conhoide); readln; { 5 } cleardevice; draw_curve(0, 2*pi-step, step, ulitka); readln; { 6 } cleardevice; draw_curve(0, 2*pi-step, step, cardioide); readln; { 7 } cleardevice; L := 1; draw_curve(-10, 10, step, cycloide); readln; cleardevice; L := 0.3; draw_curve(-10, 10, step, cycloide); readln; cleardevice; L := 3; draw_curve(-10, 10, step, cycloide); readln; { 8 } cleardevice; L := 1; draw_curve(-10, 10, step, epi_cycloide); readln; cleardevice; L := 0.3; draw_curve(-10, 10, step, epi_cycloide); readln; cleardevice; L := 3; draw_curve(-10, 10, step, epi_cycloide); readln; { 9 } cleardevice; L := 1; draw_curve(-10, 10, step, hypo_cycloide); readln; cleardevice; L := 0.3; draw_curve(-10, 10, step, hypo_cycloide); readln; cleardevice; L := 3; draw_curve(-10, 10, step, hypo_cycloide); readln; { 10 } cleardevice; draw_curve(-10, -step, step, hyp_spiral); draw_curve(step, 10, step, hyp_spiral); readln; { 11 } cleardevice; draw_curve(-10, 10, step, evolventa); readln; closegraph; end.