unit
Unit15;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls, Math;
type
TForm1 =
class
(TForm)
PaintBox1: TPaintBox;
procedure
PaintBox1Paint(Sender: TObject);
procedure
FormCreate(Sender: TObject);
private
public
end
;
function
xs(x:
double
):
integer
;
function
ys(y:
double
):
integer
;
var
Form1: TForm1;
a,b,px,py,qx,qy,ming,maxg,x,y:
double
;
implementation
{$R *.dfm}
function
f(x:
double
):
double
;
begin
result:=
abs
(cos(
2
*x)-sin(
2
*x));
end
;
procedure
TForm1
.
FormCreate(Sender: TObject);
begin
a:=-
12
; b:=
15
;
end
;
procedure
TForm1
.
PaintBox1Paint(Sender: TObject);
var
i,j:
integer
;
begin
ming:=
0.1
; maxg:=
0.1
;
for
i:=
0
to
round(
abs
(a)+
abs
(b))
do
begin
x:=a+i;
y:=f(x);
if
maxg<y
then
maxg:=y;
if
ming>y
then
ming:=y;
end
;
px:=(PaintBox1
.
Width-PaintBox1
.
left)/(b-a); qx:=left-px*a;
py:=(PaintBox1
.
top-PaintBox1
.
Height)/(maxg-ming); qy:=PaintBox1
.
top-py*maxg;
for
j:=PaintBox1
.
Left
to
PaintBox1
.
Width
do
PaintBox1
.
Canvas
.
Pixels[xs(j),ys(f(j))]:=clred;
end
;
function
xs(x:
double
):
integer
;
begin
result:=round(px*x+qx);
end
;
function
ys(y:
double
):
integer
;
begin
result:=round(py*y+qy);
end
;
end
.