unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, math, ExtCtrls;
type
TForm1 =
class(TForm)
Button1: TButton;
Image1: TImage;
Button2: TButton;
memo1: TMemo;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private-Deklarationen }
function my_fakultaet(n:integer):real;
function my_pow(x:real;n:integer):real;
function my_exp(x:real):real;
function my_ln (x:real):real;
function my_rpow(x,y:real):real;
function my_root(x:real;n:integer):real;
function my_pi:real;
function my_sin_rad(x:real):real;
function my_sin_grad(x:real):real;
public
{ Public-Deklarationen }
end;
var
Form1: TForm1;
steps:integer=10;
implementation
{$R *.dfm}
function Tform1.my_fakultaet(n:integer):real;
Var i:Integer; s:real;
Begin
s:=1;
for i:=1
to n
do s:=s*i;
result:=s;
End;
function Tform1.my_pow(x:real;n:integer):real;
Var i:integer; s,ds:real;
Begin
s:=1;
if n>0
then for i:=1
to n
do s:=s*x;
result:=s;
End;
function Tform1.my_exp(x:real):real;
Var i:integer; s,ds,fak:real;
Begin
s:=1; fak:=1;
for i:=1
to steps
do
begin
fak:=fak*i;
ds:=my_pow(x,i)/fak;
s:=s+ds;
end;
my_exp:=s;
End;
function Tform1.my_ln (x:real):real;
Var i,n:integer; s,ds:real;
Begin
s:=0;
for i:=1
to steps
do
begin
n:=2*i-1;
ds:=(x-1)/(x+1);
ds:=my_pow(ds,n)*1/n;
s:=s+ds;
end;
my_ln:=s*2;
End;
function Tform1.my_rpow(x,y:real):real;
Var i:integer; s,ds:real;
Begin
my_rpow:=my_exp(my_ln(x)*y);
End;
function Tform1.my_root(x:real;n:integer):real;
Var i:integer;
Begin
my_root:=my_exp(my_ln(x)/n);
End;
function Tform1.my_pi :real;
Var i:integer; s,ds:real;
Begin
s:=1;
for i:=1
to steps
do
begin
ds:=power(-1,i)/((2*i+1)* power(3,i));
s:=s+ds;
end;
my_pi:=6/sqrt(3)*s;
End;
function Tform1.my_sin_rad(x:real):real;
Var i,j:integer; s,ds:real;
Begin
s:=x;
for i:=1
to steps
do
begin
j:=2*i+1;
ds:=power(-1,i)*power(x,j)/my_fakultaet(j);
s:=s+ds;
end;
my_sin_rad:=s;
End;
function Tform1.my_sin_grad(x:real):real;
Var i:integer;
Begin
my_sin_grad:=my_sin_rad(x*my_pi/180);
End;
procedure TForm1.Button1Click(Sender: TObject);
Var grad,
rad,s,ds:real;
x,xm,y,
i,
h,
xoffset,
yoffset,
ix,
iy,
endwert
:integer;
kopfstand :boolean;
deltay,
ydiffz,
ymin,
ymax,
omega,
sy,
t
:double;
begin
grad:=
rad*(180/pi);
image1.picture:=nil;
x:=0;
y:=image1.Height
div 2;
xm:=image1.width;
image1.Canvas.moveto(x,y);
image1.canvas.lineto(xm,y);
begin
kopfstand:=true;
omega:=2;
h:=image1.Height;
ymin:=-1.1;
ymax:=1.1;
ydiffz:=ymax-ymin;
deltay:=ydiffz/h;
xoffset:=10;
yoffset:=h
div 2;
with image1.Canvas
do
begin
moveto(x,0);
lineto(x,h);
moveto(x,y);
lineto(image1.width,y);
pen.color:=clblack;
end;
Endwert:=trunc(2*pi/0.02/omega);
for i:=0
to endwert
do
begin
t:=i*0.02;
sy:=sin(omega*t);
x:=i;
y:=trunc(sy/deltay);
ix:=trunc(x+xoffset);
with image1.canvas
do
begin
if kopfstand
then
begin
y:=h-y;
iy:=trunc(y-yoffset)
end
else iy:=trunc(y+yoffset);
if i=0
then
moveto(ix,iy)
else
lineto(ix,iy);
end;
end;
end;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
image1.Picture:=nil;
end;
end.