多线程 1
载入中...
搜索中...
未找到
测试.cpp
浏览该文件的文档.
1//
2// 测试.cpp
3// 多线程
4//
5// Created by 赵明明 on 2023/6/16.
6//
7
8#include "测试.hpp"
9#include "cude_30.hpp"
10
12
13 // 准备数据
14 D3P* d3p = new D3P();
15 //d3p->img=new 矩阵(300,300,(float)0);
16 d3p->img = img;
17 //float data[]={20,0,70,28,10,20};
18 //float data[]={172.59416,208.23482,192.20932,195.64584,193.60979,193.60979,173.83084,206.82564};
19 //float data[]={167.77657,209.48589,183.75443,197.52885,192.20932,195.64584,172.59416,208.23482};
20 //float data[]={159.98738,210.35248,169.0131,198.87709,183.75443,197.52885,167.77657,209.48589};
21 //float data[]={128.40584,208.23482,108.79068,195.64584,117.24558,197.52885,133.22343,209.48589};
22 //float data[]={150.5,89.53356,128.40584,92.76518,127.16916,94.17436};
23 /*
24 float data_0[]={172.59416,208.23482,192.20932,195.64584,193.60979,193.60979,173.83084,206.82564};
25 float vns_0[]={-0.353101804477644,0.9240814883102055,0.14625991901178756,-0.6527987287973793,0.7076287060184845,0.2703978876642792,-0.7065841769241161,0.7076281757079974,-0.0,-0.38219478530246154,0.9240814808981521,-0.0};
26 */
27 for(int i=0;i<1032;i++){
28
29 d3p->points_plane= new 矩阵(L[i],2,(data_vt[i]),1);
30 d3p->points_plane->取整();
31 //cout<<*d3p->points_plane;
32 d3p->vns_plane=new 矩阵(L[i],3,vns[i],1);
33 //cout<<*(d3p->vns_plane);
34 //绘制
35 DrawPlane dp=DrawPlane(d3p);
36 dp.draw_plane_index(i);
37 //cout<<*(d3p->img);
38
39 }
40 cout<<"test_DrawPlane\n";
41}
42void test_FillPology(void){
43 float data[]={20,0,70,28,10,20};
44 矩阵* 多边形顶点=new 矩阵(3,2,data,1);
45 FillPology fp=FillPology(多边形顶点);
46 cout<<"*多边形顶点"<<endl;
47 cout<<*多边形顶点;
48
49 fp.fill_test();
50 //矩阵* sp=fp.get_select_pos(0);
51 矩阵* 左右=fp.get_scan();
52 cout<<"扫描出左右边界:";
53 cout<<*左右;
54 矩阵* sp=fp.get_select_pos_from_scan(左右);
55 cout<<"得到多边形内部的点";
56 cout<<*sp;
57
58 矩阵* img = new 矩阵(50,70,(float)0);
59 float color=5;
60 fp.fill_color(img, &color);
61 cout<<"img\n";
62 cout<<*img;
63}
64
65void test_线(void){
66
67 cout<<"求两个点所在直线:"<<endl;
68 矩阵 两个点=*(new 矩阵(2,2,(float)0));
69 两个点[0]=-3;
70 两个点[1]=-1;
71 两个点[2]=1;
72 两个点[3]=1;
73 cout<<两个点<<endl;
74 线 line = *(new 线(0,0));
75 line.斜率和截距(&两个点);
76 cout<<line;
77
78
79 cout<<"直线交点";
80 线 线1=线(0.2,0.5);
81 线 线2=线(-0.2,0);
82 矩阵 交点=线1.求交点(线1, 线2);
83 cout<<交点<<endl;
84
85
86 cout<<"线段交点";
87 矩阵 两个点1=*(new 矩阵(2,2,(float)0));
88 两个点1[0]=0;
89 两个点1[1]=10;
90 两个点1[2]=300;
91 两个点1[3]=10;
92 cout<<"线段1:";
93 cout<<两个点1;
94 矩阵 两个点2=*(new 矩阵(2,2,(float)0));
95 两个点2[0]=20;
96 两个点2[1]=0;
97 两个点2[2]=10;
98 两个点2[3]=20;
99 cout<<"线段2:";
100 cout<<两个点2;
101
102 float 被替换的序号=0;
103 //矩阵* 交点1=new 矩阵(1,2,0);
104 矩阵* 交点1=线1.线段交点(两个点1, 两个点2,&被替换的序号);
105 cout<<"两线段的交点:";
106 cout<<*(交点1);
107 cout<<"线段1的第几个点可用交点代替:";
108 cout<<被替换的序号<<endl;
109
110 矩阵 两个点3=*(new 矩阵(2,2,(float)0));
111 两个点3[0]=20;
112 两个点3[1]=0;
113 两个点3[2]=70;
114 两个点3[3]=28;
115 cout<<"线段3:";
116 cout<<两个点3;
117 float 被替换的序号2=0;
118 矩阵* 交点2=线1.线段交点(两个点1, 两个点3,&被替换的序号2);
119 cout<<"两线段的交点:";
120 cout<<*(交点2);
121 cout<<"线段1的第几个点可用交点代替:";
122 cout<<被替换的序号2<<endl;
123
124 矩阵* 两个交点=交点1->r_(交点1,交点2);
125 cout<<*(两个交点);
126
127
128}
129void test_单位化(void){
130 //float data[]={142.0685,203.69131,134.71452,204.39499,150.5,211.46643};
131 float data[]={0,0,1,0.5,0.7,0,2,10,20,20};
132 矩阵* 阵=new 矩阵(3,3,data,1);
133 cout<<"单位化"<<endl;
134 矩阵* 单位=阵->单位化();
135 cout<<*单位;
136
137 cout<<"点积";
138 cout<<*((*单位)["0,:"]->点积(*((*单位)["0,:"])));
139 cout<<*((*单位)["0,:"]->点积(*((*单位)["1,:"])));
140 cout<<*((*单位)["0,:"]->点积(*((*单位)["2,:"])));
141
142}
143void test_和(void){
144 float data_116[]={142.0685,203.69131,134.71452,204.39499,150.5,211.46643};
145 矩阵* 多边形顶点=new 矩阵(3,2,data_116,1);
146 矩阵* 和= 多边形顶点->();
147 cout<<*多边形顶点;
148 cout<<"多边形顶点->和:"<<endl;
149 cout<<*和;
150
151 和= 多边形顶点->(0);
152 cout<<"多边形顶点->和:"<<endl;
153 cout<<*和;
154
155 和= 多边形顶点->(1);
156 cout<<"多边形顶点->和:"<<endl;
157 cout<<*和;
158
159}
160void test_minmax(void){
161 float data[]={20,0,70,28,10,20};
162 矩阵* 多边形顶点=new 矩阵(3,2,data,1);
163 矩阵* minmax=多边形顶点->minmax();
164 cout<<"多边形顶点->minmax();"<<endl;
165 cout<<*(minmax);
166 minmax=多边形顶点->minmax(0);
167 cout<<"多边形顶点->minmax(0);"<<endl;
168 cout<<*(minmax);
169 minmax=多边形顶点->minmax(1);
170 cout<<"多边形顶点->minmax(1);"<<endl;
171 cout<<*(minmax);
172
173 minmax=多边形顶点->minmax(2);
174 cout<<"多边形顶点->minmax(2);"<<endl;
175 // 由于minmax是空指针,所以类内的宽度和高度都是随机的,所以在按照宽度和高度输出时,就会报错。
176 cout<<*(minmax);
177
178
179
180
181}
182void test_add_sub(void){
183 矩阵 m = *(new 矩阵(5,0));
184 m.operator[](1)=2;
185 m[2]=3;
186 矩阵 两个点=*(new 矩阵(5,5,(float)0));
187 矩阵 两个点1=*(new 矩阵(5,5,(float)2));
188 两个点[0]=-1;
189 两个点[1]=-1;
190 两个点[2]=-1;
191 两个点[-1]=-3;
192 cout<<两个点<<endl;
193 两个点1[-1]=-3;
194 cout<<两个点1<<endl;
195 cout<<"两个矩阵相加"<<endl;
196 矩阵 果=两个点+两个点1;
197 cout<<果<<endl;
198
199 矩阵 果加1=两个点+3.5;
200 cout<<果加1<<endl;
201
202 cout<<"两个矩阵相减"<<endl;
203 矩阵 果减 = 两个点-两个点1;
204 cout<<果减<<endl;
205 矩阵 果减1=两个点-3.5;
206 cout<<果减1<<endl;
207
208 cout<<"两个矩阵相乘"<<endl;
209 矩阵 果乘 = 两个点*两个点1;
210 cout<<果乘<<endl;
211 矩阵 果乘1=两个点*3.5;
212 cout<<果乘1<<endl;
213
214 cout<<"两个矩阵相除"<<endl;
215 矩阵 果除 = 两个点/两个点1;
216 cout<<果除<<endl;
217 矩阵 果除1=两个点/3.5;
218 cout<<果除1<<endl;
219
220
221}
222void test_子矩阵(void){
223 矩阵 m = *(new 矩阵(5,0));
224 m.operator[](1)=2;
225 m[2]=3;
226 矩阵 两个点=*(new 矩阵(50,50,(float)0));
227 两个点[0]=-1;
228 两个点[1]=-1;
229 两个点[2]=-1;
230 两个点[-1]=-3;
231 cout<<两个点<<endl;
232
233 // 测试输出行或者列
234 cout<<"第0,1行"<<endl;
235 cout<<*(两个点["0:2,:"])<<endl;
236 cout<<*(两个点.(0,2))<<endl;
237
238 cout<<"第47,48,49行"<<endl;
239
240 cout<<*(两个点["47:50,:"])<<endl;
241
242
243
244 cout<<"第0,1列"<<endl;
245 cout<<*(两个点[":,0:2"])<<endl;
246 cout<<*(两个点.(0,2))<<endl;
247
248 cout<<"第47,48,49列"<<endl;
249 cout<<*(两个点[":,47:50"])<<endl;
250
251
252 cout<<"输出1,49,48,2,0行"<<endl;
253 cout<<*(两个点.行们(5,1,49,48,2,0));
254 cout<<"输出1,49,48,2,0列"<<endl;
255 cout<<*(两个点.列们(5,1,49,48,2,0));
256
257 cout<<"输出1,49,48,2,0行的第1,49,48,2,0列"<<endl;
258 cout<<*((两个点.行们(5,1,49,48,2,0))->列们(5,1,49,48,2,0));
259
260
261 cout<<"转置"<<endl;
262 cout<<*(两个点.转置())<<endl;
263}
264void test_c_(void){
265 矩阵* 矩阵1=new 矩阵(3,1,(float)0);
266 矩阵* 矩阵2=new 矩阵(3,1,(float)2);
267 矩阵* 矩阵3=矩阵1->c_(矩阵1,矩阵2);
268 cout<<(*矩阵1)<<endl;
269 cout<<(*矩阵2)<<endl;
270 cout<<(*矩阵3)<<endl;
271}
272void test_r_(void){
273 矩阵* 矩阵1=new 矩阵(3,1,(float)0);
274 矩阵* 矩阵2=new 矩阵(3,1,(float)2);
275 矩阵* 矩阵3=矩阵1->r_(矩阵1,矩阵2);
276 cout<<(*矩阵1)<<endl;
277 cout<<(*矩阵2)<<endl;
278 cout<<(*矩阵3)<<endl;
279
280 矩阵* 矩阵4=new 矩阵(4,2,(float)0);
281 矩阵* 矩阵5=new 矩阵(3,1,(float)2);
282 矩阵* 矩阵6=矩阵4->r_(矩阵4,矩阵5);
283 cout<<(*矩阵4)<<endl;
284 cout<<(*矩阵5)<<endl;
285 cout<<(*矩阵6)<<endl;
286
287}
288void test_矩阵(void){
289
290 矩阵 m = *(new 矩阵(5,0));
291 m.operator[](1)=2;
292 m[2]=3;
293 矩阵 两个点=*(new 矩阵(2,2,(float)0));
294 两个点[0]=0;
295 两个点[1]=1;
296 两个点[2]=2;
297 两个点[-1]=3;
298 cout<<两个点.(1,1)<<endl;
299
300 // 测试按照行列输出数据 通过
301 cout<<*(两个点["1,1"])<<endl;
302
303 // 测试输出行或者列
304 cout<<"第0行,第1行"<<endl;
305 cout<<*(两个点["0,:"])<<endl;
306 cout<<*(两个点["1,:"])<<endl;
307
308 cout<<"第0列,第1列"<<endl;
309 cout<<*(两个点[":,0"])<<endl;
310 cout<<*(两个点[":,1"])<<endl;
311
312
313 //测试重载输出 通过
314
315 cout<<"输出矩阵:两个点"<<endl;
316 cout<<两个点<<endl;
317
318 cout<<"第0行-第1行:"<<endl;
319 矩阵 果减=*(两个点["0,:"])-*(两个点["1,:"]);
320 cout<<果减<<endl;
321
322 cout<<"第0列-第1列:"<<endl;
323 矩阵 果减1=*(两个点[":,0"])-*(两个点[":,1"]);
324 cout<<果减1<<endl;
325
326}
void test_子矩阵(void)
Definition 测试.cpp:222
void test_DrawPlane(矩阵 *img)
Definition 测试.cpp:11
void test_add_sub(void)
Definition 测试.cpp:182
void test_和(void)
Definition 测试.cpp:143
void test_c_(void)
Definition 测试.cpp:264
void test_矩阵(void)
Definition 测试.cpp:288
void test_FillPology(void)
Definition 测试.cpp:42
void test_单位化(void)
Definition 测试.cpp:129
void test_线(void)
Definition 测试.cpp:65
void test_minmax(void)
Definition 测试.cpp:160
void test_r_(void)
Definition 测试.cpp:272
int draw_plane_index(int plane_index=0)
Definition DrawPlane.hpp:28
void fill_test()
测试FillPology是否建立成功,并可调用
矩阵 * get_select_pos_from_scan(矩阵 *左右扫描点)
使用光栅扫描法得到的左右点,计算多边形内点的坐标
矩阵 * fill_color(矩阵 *img, float *color)
利用光删扫描法得到的左右点,对多边形内部填充颜色
矩阵 * get_scan(void)
尝试光删扫描法,看会不会比矩阵求取法更快一些
基本的矩阵计算类,用于完成各种矩阵初始化、最大最小、取值、加减乘除、精度设置等矩阵计算
Definition 矩阵.hpp:25
矩阵 * c_(矩阵 *矩阵1, 矩阵 *矩阵2)
Definition 矩阵.hpp:296
矩阵 * 行们(int count,...)
Definition 矩阵.hpp:501
void 取整(void)
对矩阵内的数据取整
Definition 矩阵.hpp:117
矩阵 * 列们(int count,...)
Definition 矩阵.hpp:519
矩阵 * 列(int i)
Definition 矩阵.hpp:489
矩阵 * 转置(void)
Definition 矩阵.hpp:458
矩阵 * r_(矩阵 *矩阵1, 矩阵 *矩阵2)
按行合并
Definition 矩阵.hpp:314
矩阵 * minmax(void)
求矩阵中所有元素的最大值,最小值
Definition 矩阵.hpp:196
矩阵 * 和(void)
求矩阵内个元素的和
Definition 矩阵.hpp:162
矩阵 * 行(int i)
Definition 矩阵.hpp:476
float & 取(int i, int j)
Definition 矩阵.hpp:643
矩阵 * 单位化(void)
对矩阵的每一行,进行单位化
Definition 矩阵.hpp:141
Definition 线.hpp:15
矩阵 * 线段交点(矩阵 &线1的两个点, 矩阵 &线2的两个点, float *被替换的序号)
Definition 线.hpp:88
矩阵 求交点(线 线1, 线 线2)
Definition 线.hpp:36
线 & 斜率和截距(矩阵 *两个点)
Definition 线.hpp:23
float data_116[]
Definition cube.hpp:243
float * data_vt[]
Definition cube.hpp:2075
int L[]
Definition cube.hpp:2077
float * vns[]
Definition cube.hpp:2076
矩阵 * img
Definition main.cpp:22
矩阵 * img
Definition DrawPlane.hpp:19
矩阵 * vns_plane
Definition DrawPlane.hpp:17
矩阵 * points_plane
Definition DrawPlane.hpp:16