HP Prime для всех
English
Русский
Название | 3D XYZ Function Plotter |
Описание | Plots 3-dimensional functions of the form f(X,Y), such as f(X,Y):=(-(X^2+Y^2));. |
Автор | Gerardo V. Lozada |
Исходный код отформатирован программными средствами сайта
BEGIN
RETURN e^( - (X^2+Y^2));
END;
f2(X, Y)
BEGIN
RETURN e^(-0.1 * (X^2+Y^2)) * COS(40 * (X^2+Y^2));
END;
f3(X, Y)
BEGIN
RETURN X^2+Y^2;
END;
f4(X, Y)
BEGIN
RETURN 1/X^2+1/Y^2+0.0001;
END;
f(X, Y)
BEGIN
RETURN f1(X, Y);
END;
EXPORT Plot3Dxyz()
BEGIN
LOCAL xres, yres, dtr, x1, x2;
LOCAL xangle, zangle, dx, dy, nx, ny;
LOCAL x, y, z, sx, sy, i, j;
LOCAL sxmin, sxmax, symin, symax, y1, y2;
LOCAL ppx, ppy, px, py;
xres := 319;
yres := 239;
dtr := ATAN(1.0) / 45.0;
INPUT(x1);
INPUT(x2);
INPUT(y1);
INPUT(y2);
INPUT(nx);
INPUT(ny);
INPUT(xangle);
INPUT(zangle);
dx := (x2-x1) / nx;
dy := (y2-y1) / ny;
sxmin := 0;
sxmax := 0;
symin := 0;
symax := 0;
x := x1;
FOR i from 1 TO nx DO
y := y1;
FOR j FROM 1 TO ny DO
z := f(x, y);
sx := x*COS(xangle*dtr) - y*SIN(xangle*dtr);
sy := z*COS(zangle*dtr) - y*SIN(zangle*dtr);
IF sx < sxmin THEN sxmin := sx; END;
IF sx > sxmax THEN sxmax := sx; END;
IF sy < symin THEN symin := sy; END;
IF sy > symax THEN symax := sy; END;
y := y+dy;
END;
x := x+dx;
END;
print(sxmin);
print(sxmax);
print(symin);
print(symax);
wait(0);
RECT();
x := x1;
FOR i from 1 TO nx DO
y := y1;
FOR j FROM 1 TO ny DO
z := f(x, y);
sx := x*COS(xangle*dtr) - y*SIN(xangle*dtr);
sy := z*COS(zangle*dtr) - y*SIN(zangle*dtr);
px := (sx-sxmin) / (sxmax-sxmin) * xres;
py := yres - (sy-symin) / (symax-symin) * yres;
IF (i > 1) AND (j > 1) THEN LINE_P(ppx, ppy, px, py); END;
ppx := px;
ppy := py;
y := y+dy;
END;
x := x+dx;
END;
y := y1;
FOR i from 1 TO ny DO
x := x1;
FOR j FROM 1 TO nx DO
z := f(x, y);
sx := x*COS(xangle*dtr) - y*SIN(xangle*dtr);
sy := z*COS(zangle*dtr) - y*SIN(zangle*dtr);
px := (sx-sxmin) / (sxmax-sxmin) * xres;
py := yres - (sy-symin) / (symax-symin) * yres;
IF (i > 1) AND (j > 1) THEN LINE_P(ppx, ppy, px, py);
ELSE PIXON_P(px, py); END;
ppx := px;
ppy := py;
x := x+dx;
END;
y := y+dy;
END;
FREEZE;
WAIT(0);
END;