質問編集履歴
3
詳しく更新
test
CHANGED
File without changes
|
test
CHANGED
@@ -20,7 +20,7 @@
|
|
20
20
|
|
21
21
|
|
22
22
|
|
23
|
-
class
|
23
|
+
class Point{
|
24
24
|
|
25
25
|
public:
|
26
26
|
|
@@ -30,7 +30,7 @@
|
|
30
30
|
|
31
31
|
double vertical_angle; //xy平面と点のなす角度(以下、垂直角)
|
32
32
|
|
33
|
-
|
33
|
+
Point();
|
34
34
|
|
35
35
|
};
|
36
36
|
|
@@ -174,6 +174,10 @@
|
|
174
174
|
|
175
175
|
|
176
176
|
|
177
|
+
|
178
|
+
|
179
|
+
|
180
|
+
|
177
181
|
###1.水平角ソート後
|
178
182
|
|
179
183
|
a_point[ hori ][ vertical ].hori_angle =
|
@@ -296,6 +300,34 @@
|
|
296
300
|
|
297
301
|
|
298
302
|
|
303
|
+
###現状
|
304
|
+
|
305
|
+
垂直角のソートのみ取り入れているので,以下のような結果が得られています.
|
306
|
+
|
307
|
+
|
308
|
+
|
309
|
+
a_point[ hori ][ vertical ].hori_angle =
|
310
|
+
|
311
|
+
[-180,0,-30,-180,0,-30,-180],
|
312
|
+
|
313
|
+
[-30,0,180,-180,-180,0,-30,0],
|
314
|
+
|
315
|
+
[-180,0,-30,(0,180,-180),0],
|
316
|
+
|
317
|
+
[180,180,-30,(180,180),-180,-30]
|
318
|
+
|
319
|
+
|
320
|
+
|
321
|
+
a_point[hori][vertical].vertical_angle =
|
322
|
+
|
323
|
+
[-10,-10,0,10,10,15,30],
|
324
|
+
|
325
|
+
[-10,0,10,15,20,25,30],
|
326
|
+
|
327
|
+
[0,15,20,25,25,25,30],
|
328
|
+
|
329
|
+
[-10,0,10,15,20,20,30];
|
330
|
+
|
299
331
|
|
300
332
|
|
301
333
|
### 補足情報
|
2
詳しく変更
test
CHANGED
File without changes
|
test
CHANGED
@@ -16,6 +16,46 @@
|
|
16
16
|
|
17
17
|
```C++
|
18
18
|
|
19
|
+
/*Point.h*/
|
20
|
+
|
21
|
+
|
22
|
+
|
23
|
+
class point{
|
24
|
+
|
25
|
+
public:
|
26
|
+
|
27
|
+
double x,y,z; //点のx,y,z座標値
|
28
|
+
|
29
|
+
double hori_angle; //xy平面上でのx軸と点の角度(以下、水平角)
|
30
|
+
|
31
|
+
double vertical_angle; //xy平面と点のなす角度(以下、垂直角)
|
32
|
+
|
33
|
+
point();
|
34
|
+
|
35
|
+
};
|
36
|
+
|
37
|
+
```
|
38
|
+
|
39
|
+
```C++
|
40
|
+
|
41
|
+
/*Point.cpp*/
|
42
|
+
|
43
|
+
|
44
|
+
|
45
|
+
#include "Point.h"
|
46
|
+
|
47
|
+
Point::Point(){
|
48
|
+
|
49
|
+
}
|
50
|
+
|
51
|
+
```
|
52
|
+
|
53
|
+
```C++
|
54
|
+
|
55
|
+
/*main.cpp*/
|
56
|
+
|
57
|
+
|
58
|
+
|
19
59
|
using namespace pcl;
|
20
60
|
|
21
61
|
PointCloud<pcl::PointXYZI>::Ptr input(new pal::PointCloud<pcl::PointXYZI>);//入力点群
|
@@ -28,22 +68,6 @@
|
|
28
68
|
|
29
69
|
|
30
70
|
|
31
|
-
class point{
|
32
|
-
|
33
|
-
public:
|
34
|
-
|
35
|
-
double x,y,z; //点のx,y,z座標値
|
36
|
-
|
37
|
-
double hori_angle; //xy平面上でのx軸と点の角度(以下、水平角)
|
38
|
-
|
39
|
-
double vertical_angle; //xy平面と点のなす角度(以下、垂直角)
|
40
|
-
|
41
|
-
point();
|
42
|
-
|
43
|
-
};
|
44
|
-
|
45
|
-
|
46
|
-
|
47
71
|
Void main(void){
|
48
72
|
|
49
73
|
for(int i = 0; i < hori; i++){
|
@@ -64,7 +88,7 @@
|
|
64
88
|
|
65
89
|
a_point[j][i].hori_angle = atan2(a_point[j][i].y,a_point[j][i].x);
|
66
90
|
|
67
|
-
a_point[j][
|
91
|
+
a_point[j][i].vertical_angle = /*計算式*/;
|
68
92
|
|
69
93
|
//↑↑↑それぞれ[rad]から[deg]に変換,水平角は-180[deg]~180[deg]が,垂直角は-10[deg]~30[deg]が得られる
|
70
94
|
|
@@ -204,37 +228,37 @@
|
|
204
228
|
|
205
229
|
temp1 = a_point[j][i].x;
|
206
230
|
|
207
|
-
temp2 = a_point[j][
|
231
|
+
temp2 = a_point[j][i].y;
|
208
|
-
|
232
|
+
|
209
|
-
temp3 = a_point[j][
|
233
|
+
temp3 = a_point[j][i].z;
|
210
|
-
|
234
|
+
|
211
|
-
temp4 = a_point[j][
|
235
|
+
temp4 = a_point[j][i].hori_angle;
|
212
|
-
|
236
|
+
|
213
|
-
temp5 = a_point[j][
|
237
|
+
temp5 = a_point[j][i].vertical_angle;
|
214
238
|
|
215
239
|
|
216
240
|
|
217
241
|
a_point[j][i].x = a_point[k][i].x;
|
218
242
|
|
219
|
-
a_point[j][
|
243
|
+
a_point[j][i].y = a_point[k][I].y;
|
220
|
-
|
244
|
+
|
221
|
-
a_point[j][
|
245
|
+
a_point[j][i].z = a_point[k][I].z;
|
222
|
-
|
246
|
+
|
223
|
-
a_point[j][
|
247
|
+
a_point[j][i].hori_angle = a_point[k][i].hori_angle;
|
224
|
-
|
248
|
+
|
225
|
-
a_point[j][
|
249
|
+
a_point[j][i].vertical_angle = a_point[k][i].vertical_angle;
|
226
250
|
|
227
251
|
|
228
252
|
|
229
253
|
a_point[k][i].x = temp1;
|
230
254
|
|
231
|
-
a_point[k][
|
255
|
+
a_point[k][i].y = temp2;
|
232
|
-
|
256
|
+
|
233
|
-
a_point[k][
|
257
|
+
a_point[k][i].z = temp3;
|
234
|
-
|
258
|
+
|
235
|
-
a_point[k][
|
259
|
+
a_point[k][i].hori_angle = temp4;
|
236
|
-
|
260
|
+
|
237
|
-
a_point[k][
|
261
|
+
a_point[k][i].vertical_angle = temp5;
|
238
262
|
|
239
263
|
}
|
240
264
|
|
1
詳しく編集し直しました
test
CHANGED
File without changes
|
test
CHANGED
@@ -1,135 +1,285 @@
|
|
1
|
-
###
|
2
|
-
|
3
|
-
C++で作成しています。
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
1
|
+
### 実現したいこと
|
2
|
+
|
3
|
+
C++で作成しています。
|
4
|
+
|
5
|
+
PCD形式の点群データを配列に格納し,class内のデータ(二次元配列)でソートしたいです。(伝え方が難しい)
|
6
|
+
|
7
|
+
垂直角のソートは出来ているのですが,水平角のソート方法がわかりません.
|
8
|
+
|
9
|
+
解決策がありましたら教えていただきたいです.
|
10
|
+
|
11
|
+
|
12
|
+
|
13
|
+
### 該当のソースコード
|
14
|
+
|
15
|
+
|
16
|
+
|
17
|
+
```C++
|
18
|
+
|
19
|
+
using namespace pcl;
|
20
|
+
|
21
|
+
PointCloud<pcl::PointXYZI>::Ptr input(new pal::PointCloud<pcl::PointXYZI>);//入力点群
|
22
|
+
|
23
|
+
|
24
|
+
|
25
|
+
int hori = 7; //水平方向データ数
|
26
|
+
|
27
|
+
int vertical = 4; //垂直方向データ数
|
28
|
+
|
29
|
+
|
30
|
+
|
31
|
+
class point{
|
32
|
+
|
33
|
+
public:
|
34
|
+
|
35
|
+
double x,y,z; //点のx,y,z座標値
|
36
|
+
|
37
|
+
double hori_angle; //xy平面上でのx軸と点の角度(以下、水平角)
|
38
|
+
|
39
|
+
double vertical_angle; //xy平面と点のなす角度(以下、垂直角)
|
40
|
+
|
41
|
+
point();
|
42
|
+
|
43
|
+
};
|
44
|
+
|
45
|
+
|
46
|
+
|
47
|
+
Void main(void){
|
48
|
+
|
49
|
+
for(int i = 0; i < hori; i++){
|
50
|
+
|
51
|
+
for(int j = 0; j < vertical; j++){
|
52
|
+
|
53
|
+
/*点群データを配列に格納*/
|
54
|
+
|
55
|
+
a_point[j][i].x = input->points[i*4+j].x;
|
56
|
+
|
57
|
+
a_point[j][i].y = input->points[i*4+j].y;
|
58
|
+
|
59
|
+
a_point[j][i].z = input->points[i*4+j].z;
|
60
|
+
|
61
|
+
|
62
|
+
|
63
|
+
/*垂直角・水平角を求める*/
|
64
|
+
|
65
|
+
a_point[j][i].hori_angle = atan2(a_point[j][i].y,a_point[j][i].x);
|
66
|
+
|
67
|
+
a_point[j][I].vertical_angle = /*計算式*/;
|
68
|
+
|
69
|
+
//↑↑↑それぞれ[rad]から[deg]に変換,水平角は-180[deg]~180[deg]が,垂直角は-10[deg]~30[deg]が得られる
|
70
|
+
|
71
|
+
}
|
72
|
+
|
73
|
+
}
|
74
|
+
|
75
|
+
/*並べ替える*/
|
76
|
+
|
77
|
+
Sort();
|
78
|
+
|
79
|
+
}
|
80
|
+
|
81
|
+
|
82
|
+
|
83
|
+
Void Sort(void){
|
84
|
+
|
85
|
+
|
86
|
+
|
87
|
+
/*水平角を-180[deg]から 昇順に並べた後 ,同じ水平角内で垂直角を-10[deg]から昇順に並べたい.
|
88
|
+
|
89
|
+
理想形は以下のようになる.(このような表し方が正しいのかは多目に見て欲しいです)
|
90
|
+
|
91
|
+
|
92
|
+
|
93
|
+
a_point[hori][vertical].hori_angle
|
94
|
+
|
95
|
+
= [-180,-180,-180,-180,-180,-180,-180],
|
96
|
+
|
97
|
+
[-30 ,-30 ,-30 ,-30 ,-30 ,-30 ,-30 ],
|
98
|
+
|
99
|
+
[0 ,0 ,0 ,0 ,0 ,0 ,0 ],
|
100
|
+
|
101
|
+
[180 ,180 ,180 ,180 ,180 ,180 ,180 ];
|
102
|
+
|
103
|
+
|
104
|
+
|
105
|
+
a_point[hori][vertical].vertical_angle
|
106
|
+
|
107
|
+
= [-10,0,10,15,20,25,30],
|
108
|
+
|
109
|
+
[-10,0,10,15,20,25,30],
|
110
|
+
|
111
|
+
[-10,0,10,15,20,25,30],
|
112
|
+
|
113
|
+
[-10,0,10,15,20,25,30];
|
114
|
+
|
115
|
+
|
116
|
+
|
117
|
+
*/
|
118
|
+
|
119
|
+
}
|
120
|
+
|
121
|
+
```
|
122
|
+
|
123
|
+
|
124
|
+
|
125
|
+
###入力(ソート前)データ
|
126
|
+
|
127
|
+
|
128
|
+
|
129
|
+
a_point[ hori ][ vertical ].hori_angle =
|
130
|
+
|
131
|
+
[-180,-180,0 ,-30 ,-30 ,0 ,-180],
|
132
|
+
|
133
|
+
[-30 ,0 ,0 ,-30 ,-180,180 ,0 ],
|
134
|
+
|
135
|
+
[0 ,0 ,-180,180 ,-180,-30 ,180 ],
|
136
|
+
|
137
|
+
[-180,-30 ,180 ,180 ,-30 ,180 ,180 ];
|
138
|
+
|
139
|
+
|
140
|
+
|
141
|
+
a_point[ hori ][ vertical ].vertical_angle =
|
142
|
+
|
143
|
+
[-10 ,10 ,-10 ,0 ,15 ,10 ,30 ],
|
144
|
+
|
145
|
+
[-10 ,30 ,20 ,25 ,15 ,10 ,0 ],
|
146
|
+
|
147
|
+
[15 ,25 ,0 ,25 ,25 ,20 ,30 ],
|
148
|
+
|
149
|
+
[20 ,10 ,-10 ,20 ,30 ,0 ,15 ];
|
150
|
+
|
151
|
+
|
152
|
+
|
153
|
+
###1.水平角ソート後
|
154
|
+
|
155
|
+
a_point[ hori ][ vertical ].hori_angle =
|
156
|
+
|
157
|
+
[-180,-180,-180,-180,-180,-180,-180],
|
158
|
+
|
159
|
+
[-30 ,-30 ,-30 ,-30 ,-30 ,-30 ,-30 ],
|
160
|
+
|
161
|
+
[0 ,0 ,0 ,0 ,0 ,0 ,0 ],
|
162
|
+
|
163
|
+
[180 ,180 ,180 ,180 ,180 ,180 ,180 ];
|
164
|
+
|
165
|
+
|
166
|
+
|
167
|
+
|
168
|
+
|
169
|
+
↓↓↓こんな感じなのかな?と予想↓↓↓
|
170
|
+
|
171
|
+
a_point[ hori ][ vertical ].vertical_angle =
|
172
|
+
|
173
|
+
[(-10 ,20 ),10 ,0 ,(15 ,25 ),30 ],
|
174
|
+
|
175
|
+
[-10 ,10 ,0 ,(25 ,15 ),30 ,20 ],
|
176
|
+
|
177
|
+
[15 ,(30 ,25 ),(-10,20 ),10 ,0 ],
|
178
|
+
|
179
|
+
[-10 ,(25 ,20 ),(10 ,0 ),(30 ,15 )];
|
180
|
+
|
181
|
+
|
182
|
+
|
183
|
+
()内は順不同.あくまで予想です.
|
184
|
+
|
185
|
+
|
186
|
+
|
187
|
+
###2.垂直角ソート後
|
188
|
+
|
189
|
+
```C++
|
190
|
+
|
191
|
+
/*垂直角ソートプログラム(Sort関数内に存在)*/
|
192
|
+
|
193
|
+
|
194
|
+
|
195
|
+
double temp1, temp2, temp3, temp4, temp5;
|
196
|
+
|
197
|
+
|
198
|
+
|
199
|
+
for(int i = 0; i < hori; i++){
|
200
|
+
|
201
|
+
for(int j = 0; j < vertical; j++){
|
202
|
+
|
203
|
+
for(int k = j+1; k < vertival; k++){
|
204
|
+
|
205
|
+
temp1 = a_point[j][i].x;
|
206
|
+
|
207
|
+
temp2 = a_point[j][I].y;
|
208
|
+
|
209
|
+
temp3 = a_point[j][I].z;
|
210
|
+
|
211
|
+
temp4 = a_point[j][I].hori_angle;
|
212
|
+
|
213
|
+
temp5 = a_point[j][I].vertical_angle;
|
214
|
+
|
215
|
+
|
216
|
+
|
217
|
+
a_point[j][i].x = a_point[k][i].x;
|
218
|
+
|
219
|
+
a_point[j][I].y = a_point[k][I].y;
|
220
|
+
|
221
|
+
a_point[j][I].z = a_point[k][I].z;
|
222
|
+
|
223
|
+
a_point[j][I].hori_angle = a_point[k][I].hori_angle;
|
224
|
+
|
225
|
+
a_point[j][I].vertical_angle = a_point[k][I].vertical_angle;
|
226
|
+
|
227
|
+
|
228
|
+
|
229
|
+
a_point[k][i].x = temp1;
|
230
|
+
|
231
|
+
a_point[k][I].y = temp2;
|
232
|
+
|
233
|
+
a_point[k][I].z = temp3;
|
234
|
+
|
235
|
+
a_point[k][I].hori_angle = temp4;
|
236
|
+
|
237
|
+
a_point[k][I].vertical_angle = temp5;
|
238
|
+
|
239
|
+
}
|
240
|
+
|
241
|
+
}
|
242
|
+
|
243
|
+
}
|
244
|
+
|
245
|
+
|
246
|
+
|
247
|
+
```
|
20
248
|
|
21
249
|
<結果>
|
22
250
|
|
23
|
-
[
|
24
|
-
|
25
|
-
[1,1,1,1,1,1,1]
|
26
|
-
|
27
|
-
[
|
28
|
-
|
29
|
-
[
|
30
|
-
|
31
|
-
[
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
[0,0,0,
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
[
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
```C++
|
62
|
-
|
63
|
-
class point{
|
64
|
-
|
65
|
-
public:
|
66
|
-
|
67
|
-
int angle;
|
68
|
-
|
69
|
-
point();
|
70
|
-
|
71
|
-
};
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
Void main(void){
|
76
|
-
|
77
|
-
for(int i=0;i<7;i++){
|
78
|
-
|
79
|
-
for(int j=0;j<4;j++){
|
80
|
-
|
81
|
-
point[j][i].angle = /*上記<入力>の配列*/;
|
82
|
-
|
83
|
-
}
|
84
|
-
|
85
|
-
}
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
Sort();
|
90
|
-
|
91
|
-
}
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
Void Sort(void){
|
96
|
-
|
97
|
-
int temp;
|
98
|
-
|
99
|
-
//昇順ソート
|
100
|
-
|
101
|
-
for(int i=0;i<7;i++){
|
102
|
-
|
103
|
-
for(int j=0;j<4;j++){
|
104
|
-
|
105
|
-
for(int k=i+1;i<7;i++){
|
106
|
-
|
107
|
-
if(point[j][k].angle<point[j][I].angle){
|
108
|
-
|
109
|
-
temp = point[j][i].angle;
|
110
|
-
|
111
|
-
point[j][I].angle = point[k][I].angle;
|
112
|
-
|
113
|
-
point[k][I].angle = temp
|
114
|
-
|
115
|
-
}
|
116
|
-
|
117
|
-
}
|
118
|
-
|
119
|
-
}
|
120
|
-
|
121
|
-
}
|
122
|
-
|
123
|
-
}
|
124
|
-
|
125
|
-
```
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
### 補足情報(FW/ツールのバージョンなど)
|
132
|
-
|
133
|
-
本当はもっと長いソースコードです。必要かなと判断した部分のみ記載したので辻褄が合わない部分もあるかもしれません。
|
134
|
-
|
135
|
-
上記<結果>が得られれば嬉しいです。よろしくお願いいたします。
|
251
|
+
a_point[ hori ][ vertical ].hori_angle =
|
252
|
+
|
253
|
+
[-180,-180,-180,-180,-180,-180,-180],
|
254
|
+
|
255
|
+
[-30 ,-30 ,-30 ,-30 ,-30 ,-30 ,-30 ],
|
256
|
+
|
257
|
+
[0 ,0 ,0 ,0 ,0 ,0 ,0 ],
|
258
|
+
|
259
|
+
[180 ,180 ,180 ,180 ,180 ,180 ,180 ];
|
260
|
+
|
261
|
+
|
262
|
+
|
263
|
+
a_point[hori][vertical].vertical_angle =
|
264
|
+
|
265
|
+
[-10,0,10,15,20,25,30],
|
266
|
+
|
267
|
+
[-10,0,10,15,20,25,30],
|
268
|
+
|
269
|
+
[-10,0,10,15,20,25,30],
|
270
|
+
|
271
|
+
[-10,0,10,15,20,25,30];
|
272
|
+
|
273
|
+
|
274
|
+
|
275
|
+
|
276
|
+
|
277
|
+
### 補足情報
|
278
|
+
|
279
|
+
a_point[][]はpoint classのことを表しています.
|
280
|
+
|
281
|
+
垂直角のソートは出来ているのですが,水平角のソート方法がわかりません.
|
282
|
+
|
283
|
+
|
284
|
+
|
285
|
+
更に詳しく編集し直しました.
|