Форум программистов, компьютерный форум, киберфорум
Delphi: Графика, звук, видео
Войти
Регистрация
Восстановить пароль
Карта форума Темы раздела Блоги Сообщество Поиск Заказать работу  
 
Рейтинг 4.91/11: Рейтинг темы: голосов - 11, средняя оценка - 4.91
2 / 2 / 0
Регистрация: 13.05.2009
Сообщений: 37
1

построитель графиков ф-ции

03.12.2010, 18:42. Показов 2204. Ответов 1
Метки нет (Все метки)

Author24 — интернет-сервис помощи студентам
есть ошибки:
1. y= x^2+1/x2 строит бред ,причем не знаю как "выколить " 0
2.y=exp(b*x*ln(a),чтобы и было не целое числ надо описать,как real ?
3.y=a*sin(bx +c)+в строит привильно,я думаю
4.астроид,где x=b*cos^3t;y=b*sin^3t


Delphi
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
unit Unit1;
 
interface
 
uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, Menus, StdCtrls, ExtCtrls;
 
type
  TForm1 = class(TForm)
    PaintBox1: TPaintBox;
    Edit1: TEdit;
    Edit2: TEdit;
    Edit3: TEdit;
    Edit4: TEdit;
    Label2: TLabel;
    Label3: TLabel;
    Label4: TLabel;
    ComboBox1: TComboBox;
    ComboBox2: TComboBox;
    ColorDialog1: TColorDialog;
    Button1: TButton;
    Button2: TButton;
    Button3: TButton;
    procedure Button2Click(Sender: TObject);
    procedure PaintBox1Paint(Sender: TObject);
    procedure Button1Click(Sender: TObject);
    procedure Button3Click(Sender: TObject);
 
     procedure ComboBox2Change(Sender: TObject);
                             
  private
    { Private declarations }
  public
    { Public declarations }
  end;
 
var
  Form1: TForm1;
  i,a,b,c,d:integer; x,y,t:real;
 
implementation
 
{$R *.dfm}
 
procedure TForm1.Button2Click(Sender: TObject);
begin
Repaint;
end;
 
procedure TForm1.PaintBox1Paint(Sender: TObject);
begin
with form1.PaintBox1.Canvas do begin
brush.color:=clwhite;
rectangle(0,0,500,500);
pen.width:=2;
pen.color:=clgreen;
moveto(250,0);lineto(250,500);
moveto(0,250);lineto(500,250);
moveto(240,20);lineto(250,0);lineto(260,20);
moveto(480,240);lineto(500,250);lineto(480,260);
 x:=10; y:=480;
for i:=-9 to 9 do begin
TextOut(round(x),255,IntToStr(i));
x:=x+25; end;
for i:=-9 to 9 do begin
TextOut(235,round(y),IntToStr(i));
y:=y-25; end;
TextOut (485,255,'X');
TextOut (235,5,'Y');
pen.width:=1;
for i:=1 to 500 do begin
if i mod 25=0 then begin moveto(i,0);lineto(i,500);end;end;
for i:=1 to 500 do begin
if i mod 25=0 then begin moveto(0,i);lineto(500,i);end;end;
end;
 
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
a:=strtoint(edit1.Text);b:=strtoint(edit2.Text);c:=strtoint(edit3.Text);d:=strtoint(edit4.Text);
case form1.ComboBox1.ItemIndex of
 
0:with form1.PaintBox1.Canvas do begin
x:=10 ;
y:=((x*x)+1/(x*x))*(-1);
moveto(round(x*25)+250,round(y*25)+250);
for i:=0 to 500 do begin x:=-10;
 y:=(x*x+1/(x*x));end;
lineto(round(x*25)+250,round(y*25)+250);
 y:=(x*x+1/(x*x)); textout(round(x*25),400,'x*x+1/(x*x)');
end;
 
 
 
 
 
1:with form1.PaintBox1.Canvas do begin
x:=10 ;
y:=(exp(b*x*ln(a))*(-1));
moveto(round(x*25)+250,round(y*25)+250);
for i:=0 to 500 do begin x:=-10;
 y:=(exp(b*x*ln(a)));end;
lineto(round(x*25)+250,round(y*25)+250);
 y:=(exp(b*x*ln(a))); textout(round(x*25),400,'exp(b*x*ln(a)');
end;
 
2:with form1.PaintBox1.Canvas do begin
x:=-10;
y:=(a*sin(b*x+c)+d);
moveto(round(x*25)+250,round(y*25)+250);
for i:=-10000 to 10000 do begin
y:=((a*sin(b*x+c)+d));
lineto(round(x*25+250),round(y*25+250));x:=x+0.01;end;     x:=10;
y:=((a*sin(b*x+c)+d)); textout(round(x*25),200,'a*sin(b*x+c)+d');
                        end;
3:with form1.PaintBox1.Canvas do begin
t:=-10;
x:=(b-a)*cos(t)+a*cos(((b-a)*t)/a);y:=((b-a)*sin(t)-a*sin(((b-a)*t)/a))*(-1);
moveto(round(x*25)+250,round(y*25)+250);
for i:=-10000 to 10000 do begin
x:=(b-a)*cos(t)+a*cos(((b-a)*t)/a);y:=((b-a)*sin(t)-a*sin(((b-a)*t)/a))*(-1);
lineto(round(x*25+250),round(y*25+250));t:=t+0.01;end;
x:=(b-a)*cos(t)+a*cos(((b-a)*t)/a);y:=((b-a)*sin(t)-a*sin(((b-a)*t)/a))*(-1); textout(round(x*25),200,'astroid')
end;       end;
end;
procedure TForm1.Button3Click(Sender: TObject);
begin
if form1.ColorDialog1.Execute then form1.PaintBox1.Canvas.Pen.Color:=colordialog1.Color;
end;
 
 
procedure TForm1.ComboBox2Change(Sender: TObject);
begin
case form1.ComboBox2.ItemIndex of
0:form1.PaintBox1.Canvas.Pen.Width:=1;
1:form1.PaintBox1.Canvas.Pen.Width:=2;
2:form1.PaintBox1.Canvas.Pen.Width:=3;
3:form1.PaintBox1.Canvas.Pen.Width:=4;
4:form1.PaintBox1.Canvas.Pen.Width:=5;
end;
end;
 
 
 
end.
Добавлено через 3 часа 30 минут
Цитата Сообщение от nik20 Посмотреть сообщение
есть ошибки:
1. y= x^2+1/x2 строит бред ,причем не знаю как "выколить " 0
2.y=exp(b*x*ln(a),чтобы и было не целое числ надо описать,как real ?
3.y=a*sin(bx +c)+в строит привильно,я думаю
4.астроид,где x=b*cos^3t;y=b*sin^3t


Delphi
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
unit Unit1;
 
interface
 
uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, Menus, StdCtrls, ExtCtrls;
 
type
  TForm1 = class(TForm)
    PaintBox1: TPaintBox;
    Edit1: TEdit;
    Edit2: TEdit;
    Edit3: TEdit;
    Edit4: TEdit;
    Label2: TLabel;
    Label3: TLabel;
    Label4: TLabel;
    ComboBox1: TComboBox;
    ComboBox2: TComboBox;
    ColorDialog1: TColorDialog;
    Button1: TButton;
    Button2: TButton;
    Button3: TButton;
    procedure Button2Click(Sender: TObject);
    procedure PaintBox1Paint(Sender: TObject);
    procedure Button1Click(Sender: TObject);
    procedure Button3Click(Sender: TObject);
 
     procedure ComboBox2Change(Sender: TObject);
                             
  private
    { Private declarations }
  public
    { Public declarations }
  end;
 
var
  Form1: TForm1;
  i,a,b,c,d:integer; x,y,t:real;
 
implementation
 
{$R *.dfm}
 
procedure TForm1.Button2Click(Sender: TObject);
begin
Repaint;
end;
 
procedure TForm1.PaintBox1Paint(Sender: TObject);
begin
with form1.PaintBox1.Canvas do begin
brush.color:=clwhite;
rectangle(0,0,500,500);
pen.width:=2;
pen.color:=clgreen;
moveto(250,0);lineto(250,500);
moveto(0,250);lineto(500,250);
moveto(240,20);lineto(250,0);lineto(260,20);
moveto(480,240);lineto(500,250);lineto(480,260);
 x:=10; y:=480;
for i:=-9 to 9 do begin
TextOut(round(x),255,IntToStr(i));
x:=x+25; end;
for i:=-9 to 9 do begin
TextOut(235,round(y),IntToStr(i));
y:=y-25; end;
TextOut (485,255,'X');
TextOut (235,5,'Y');
pen.width:=1;
for i:=1 to 500 do begin
if i mod 25=0 then begin moveto(i,0);lineto(i,500);end;end;
for i:=1 to 500 do begin
if i mod 25=0 then begin moveto(0,i);lineto(500,i);end;end;
end;
 
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
a:=strtoint(edit1.Text);b:=strtoint(edit2.Text);c:=strtoint(edit3.Text);d:=strtoint(edit4.Text);
case form1.ComboBox1.ItemIndex of
 
0:with form1.PaintBox1.Canvas do begin
x:=10 ;
y:=((x*x)+1/(x*x))*(-1);
moveto(round(x*25)+250,round(y*25)+250);
for i:=0 to 500 do begin x:=-10;
 y:=(x*x+1/(x*x));end;
lineto(round(x*25)+250,round(y*25)+250);
 y:=(x*x+1/(x*x)); textout(round(x*25),400,'x*x+1/(x*x)');
end;
 
 
 
 
 
1:with form1.PaintBox1.Canvas do begin
x:=10 ;
y:=(exp(b*x*ln(a))*(-1));
moveto(round(x*25)+250,round(y*25)+250);
for i:=0 to 500 do begin x:=-10;
 y:=(exp(b*x*ln(a)));end;
lineto(round(x*25)+250,round(y*25)+250);
 y:=(exp(b*x*ln(a))); textout(round(x*25),400,'exp(b*x*ln(a)');
end;
 
2:with form1.PaintBox1.Canvas do begin
x:=-10;
y:=(a*sin(b*x+c)+d);
moveto(round(x*25)+250,round(y*25)+250);
for i:=-10000 to 10000 do begin
y:=((a*sin(b*x+c)+d));
lineto(round(x*25+250),round(y*25+250));x:=x+0.01;end;     x:=10;
y:=((a*sin(b*x+c)+d)); textout(round(x*25),200,'a*sin(b*x+c)+d');
                        end;
3:with form1.PaintBox1.Canvas do begin
t:=-10;
x:=(b-a)*cos(t)+a*cos(((b-a)*t)/a);y:=((b-a)*sin(t)-a*sin(((b-a)*t)/a))*(-1);
moveto(round(x*25)+250,round(y*25)+250);
for i:=-10000 to 10000 do begin
x:=(b-a)*cos(t)+a*cos(((b-a)*t)/a);y:=((b-a)*sin(t)-a*sin(((b-a)*t)/a))*(-1);
lineto(round(x*25+250),round(y*25+250));t:=t+0.01;end;
x:=(b-a)*cos(t)+a*cos(((b-a)*t)/a);y:=((b-a)*sin(t)-a*sin(((b-a)*t)/a))*(-1); textout(round(x*25),200,'astroid')
end;       end;
end;
procedure TForm1.Button3Click(Sender: TObject);
begin
if form1.ColorDialog1.Execute then form1.PaintBox1.Canvas.Pen.Color:=colordialog1.Color;
end;
 
 
procedure TForm1.ComboBox2Change(Sender: TObject);
begin
case form1.ComboBox2.ItemIndex of
0:form1.PaintBox1.Canvas.Pen.Width:=1;
1:form1.PaintBox1.Canvas.Pen.Width:=2;
2:form1.PaintBox1.Canvas.Pen.Width:=3;
3:form1.PaintBox1.Canvas.Pen.Width:=4;
4:form1.PaintBox1.Canvas.Pen.Width:=5;
end;
end;
 
 
 
end.



астроида и синусоида получились,а вот 1 и 2.нет

Добавлено через 18 часов 54 минуты
так попытался построить гиперболу,но ничегоне получилось

Delphi
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
0:with form1.PaintBox1.Canvas do begin
x:=-10;y:=(1/exp(x*ln(a)))*(-1); moveto(round(x*25)+325,round(y*25)+250);
for i:=0 to 1000 do begin
 x:=x+0.01;if x<>0 then begin y:=(1/exp(x*ln(a)))*(-1);end;
lineto(round(x*25)+325,round(y*25)+200);
end; x:=0.01;y:=(1/exp(x+ln(a)))*(-1);moveto(round(x*25)+325,round(y*25)+200);
for i:=0 to 1000 do begin
 x:=x+0.01;if x<>0 then begin y:=(1/exp(x*ln(a)))*(-1);end;
lineto(round(x*25)+325,round(y*25)+200);
end;  x:=10;y:=(1/exp(-x*ln(a))); moveto(round(x*25)+175,round(y*25)+300);
for i:=0 to 1000 do begin
 x:=x-0.01;if x<>0 then begin y:=(1/exp(-x*ln(a)));end;
lineto(round(x*25)+175,round(y*25)+300);
end; x:=-0.01;y:=(1/exp(abs(x)*ln(a)));moveto(round(x*25)+175,round(y*25)+300);
for i:=0 to 1000 do begin
 x:=x-0.01;if x<>0 then begin y:=(1/exp(abs(x)*ln(a)));end;
lineto(round(x*25)+175,round(y*25)+300);
end;
x:=10;y:=(1/exp(x*ln(a)))*(-1); textout(round(x*25),400,'1/exp(x+ln(a))');
end;
Добавлено через 2 часа 48 минут
мне кто-то подскажет?
0
Programming
Эксперт
94731 / 64177 / 26122
Регистрация: 12.04.2006
Сообщений: 116,782
03.12.2010, 18:42
Ответы с готовыми решениями:

Построитель графиков с масштабированием
Собственно помогите мне пожалуйста написать построитель графиков с маштабированием. Типа если...

Простой построитель графиков Java [Swing]
Написал графический редактор, стоящий и изменяющий сплайны в режиме реального времени на основе...

Построитель графиков. Распознать введенную в textBox функцию
Программа должна чертить график функции, заданной пользователем. Например sin(2*x)+ln(x)....

Передача ф-ции как параметра другой ф-ции
struct pupil{ char surname; int school; int answer; int num; } tmp, a; ...

1
2 / 2 / 0
Регистрация: 13.05.2009
Сообщений: 37
04.12.2010, 15:10  [ТС] 2
вот задача
Вложения
Тип файла: rar postroitel.rar (177.9 Кб, 96 просмотров)
0
04.12.2010, 15:10
IT_Exp
Эксперт
87844 / 49110 / 22898
Регистрация: 17.06.2006
Сообщений: 92,604
04.12.2010, 15:10
Помогаю со студенческими работами здесь

Узнать в ф-ции имя вызвавшей ф-ции
Это возможно? Т.е. есть некая ф-ция debug(msg), передавать имя вызвавшей ее процедуры в параметрах...

Построитель отчета
Как заполнить макет из построителя??? Области заголовок и подвал почему то вывелись. Правда без...

построитель отчетов
есть 2 колонки сумма и количество. как-нить можно добавить еще одну колонку, результат которой...

Построитель выражений
День добрый. Бьюсь тут с построителем над одной задачкой и ни как не получается получить желаемый...


Искать еще темы с ответами

Или воспользуйтесь поиском по форуму:
2
Ответ Создать тему
КиберФорум - форум программистов, компьютерный форум, программирование
Powered by vBulletin
Copyright ©2000 - 2024, CyberForum.ru