1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

pythonでプロットしてみる#3

Last updated at Posted at 2022-02-28

前回はptsファイルを二次元でプロットしてみた
勉強ついでに三次元でのプロットもやってみようと思う!

20220228.pts
35.9528 397.0 188
39.2651 397.0 188
39.3750 521.0 188
40.6219 389.0 188
40.4791 516.0 188
47.4060 393.0 188
49.5154 394.0 188
48.1366 807.0 188
50.2460 420.0 188
51.4984 398.0 188
51.8555 407.0 188
52.3553 404.0 188
51.8390 786.0 188
53.6847 758.0 188
54.4373 752.0 188
55.0415 746.0 188
55.6677 738.0 188
56.4203 732.0 188
56.9037 726.0 188
57.6398 717.0 188
58.2605 712.0 188
58.8702 706.0 188
59.4965 700.0 188
60.1062 694.0 188
60.7324 689.0 188
61.4685 684.0 188
62.0892 679.0 188
62.5781 674.0 188
63.1989 668.0 188
64.0613 664.0 188
64.5612 658.0 188
65.1709 654.0 188
65.9180 649.0 188
66.5277 645.0 188
67.1375 641.0 188
67.7637 637.0 188
68.3734 633.0 188
68.9996 631.0 188
69.6094 627.0 188
70.3564 623.0 188
70.9662 620.0 188
71.4661 616.0 188
72.2021 613.0 188
72.7020 610.0 188
73.4326 607.0 188
74.1852 605.0 188
74.5422 602.0 188
75.2948 600.0 188
75.9045 597.0 188
76.5308 595.0 188
77.1405 591.0 188
77.7448 590.0 188
78.3710 588.0 188
78.8544 586.0 188
79.7333 584.0 188
80.3430 582.0 188
80.9528 579.0 188
81.4526 577.0 188
82.1832 577.0 188
82.6831 575.0 188
83.2928 573.0 188
83.9026 572.0 188
84.5288 571.0 188
85.3857 569.0 188
85.8856 568.0 188
86.4954 568.0 188
87.1051 567.0 188
87.6050 564.0 188
88.3411 564.0 188
88.9673 563.0 188
89.6979 562.0 188
90.3076 561.0 188
90.8075 561.0 188
91.2964 561.0 188
92.1698 560.0 188
92.6532 560.0 188
93.1366 559.0 188
94.0155 559.0 188
94.4989 557.0 188
95.1196 559.0 188
95.7294 558.0 188
96.4819 558.0 188
96.9653 557.0 188
97.7014 557.0 188
98.2013 557.0 188
98.9374 558.0 188
99.5416 558.0 188
100.0415 558.0 188
100.7776 558.0 188
101.2775 567.0 188
101.7609 570.0 188
102.8705 503.0 188
103.9966 433.0 188
105.1062 384.0 188
105.8423 363.0 188
106.7157 359.0 188
106.8256 360.0 188
107.9517 361.0 188
108.3087 361.0 188
109.1711 362.0 188
109.7919 363.0 188
109.9017 364.0 188
110.7642 365.0 188
111.2640 366.0 188
111.7474 367.0 188
112.8735 368.0 188
113.3569 368.0 188
113.9667 370.0 188
114.3402 372.0 188
115.2026 373.0 188
115.3125 374.0 188
116.0596 375.0 188
116.5430 376.0 188
117.1692 379.0 188
118.2788 380.0 188
118.5150 382.0 188
119.3719 384.0 188
119.9817 385.0 188
120.2344 386.0 188
120.8386 388.0 188
121.4484 391.0 188
122.3108 393.0 188
122.6678 395.0 188
123.1677 396.0 188
124.0302 399.0 188
124.5135 400.0 188
125.2496 402.0 188
125.4968 406.0 188
126.3593 407.0 188
126.7163 410.0 188
127.5732 413.0 188
127.9358 416.0 188
128.4357 419.0 188
129.1718 420.0 188
129.9023 424.0 188
130.5121 426.0 188
130.8856 430.0 188
131.6217 432.0 188
132.3578 436.0 188
132.8412 439.0 188
133.1982 442.0 188
134.0771 445.0 188
134.5605 449.0 188
134.9176 454.0 188
135.6537 457.0 188
136.1536 461.0 188
136.8896 464.0 188
137.2467 469.0 188
137.9828 473.0 188
138.7134 477.0 188
139.0924 482.0 188
139.9493 485.0 188
140.3119 491.0 188
140.9216 496.0 188
141.5259 501.0 188
141.9049 507.0 188
142.7618 512.0 188
143.2452 517.0 188
143.7341 523.0 188
144.4812 529.0 188
144.8438 535.0 188
145.7007 541.0 188
146.0577 547.0 188
146.7938 554.0 188
147.2937 562.0 188
147.9034 568.0 188
148.5132 575.0 188
149.1229 583.0 188
149.6228 591.0 188
150.1062 599.0 188
150.8423 608.0 188
151.3257 616.0 188
151.9354 625.0 188
152.5616 635.0 188
153.0450 645.0 188
153.6548 655.0 188
154.2645 665.0 188
154.8853 677.0 188
155.4950 688.0 188
155.9839 700.0 188
156.6046 713.0 188
157.2144 725.0 188
157.6978 740.0 188
159.7797 1557.0 188
160.3894 1574.0 188
161.0156 1589.0 188
161.4990 1626.0 188
162.7295 1682.0 188
163.3392 1710.0 188
163.9490 1741.0 188
164.5752 1770.0 188
165.1849 1803.0 188
166.1682 2694.0 188
167.1515 1672.0 188
167.6404 1663.0 188
168.7500 2163.0 188
169.3542 2211.0 188
169.8541 2268.0 188
170.5902 2321.0 188
171.0736 2623.0 188
171.6998 2630.0 188
172.3096 2641.0 188
172.9358 2623.0 188
173.5455 2616.0 188
174.1553 2618.0 188
174.7760 2733.0 188
175.3857 2868.0 188
175.8746 3035.0 188
176.4954 3010.0 188
177.1051 2988.0 188
177.7148 3008.0 188
178.3411 3006.0 188
182.2797 2022.0 188
188.9044 2561.0 188
189.5306 2566.0 188
191.3708 2558.0 188
192.3541 4697.0 188
192.9639 4684.0 188
193.5736 4693.0 188
194.1833 4727.0 188
200.8575 744.0 188
201.3409 743.0 188
201.9507 737.0 188
202.5604 737.0 188
203.1866 740.0 188
203.7964 738.0 188
205.4059 489.0 188
206.1530 482.0 188
206.6364 476.0 188
207.3724 470.0 188
208.1085 466.0 188
208.8556 462.0 188
209.4653 456.0 188
210.0751 451.0 188
210.5750 448.0 188
211.0583 446.0 188
211.7944 458.0 188
212.5305 450.0 188
213.2776 443.0 188
214.1400 419.0 188
214.4971 406.0 188
215.4968 400.0 188
215.9802 396.0 188
216.9635 372.0 188
217.8259 358.0 188
218.4521 344.0 188
219.1827 339.0 188
219.9188 330.0 188
221.0284 322.0 188
221.5283 313.0 188
221.7645 304.0 188
222.6215 293.0 188
223.6047 287.0 188
224.9835 280.0 188
225.3406 274.0 188
226.4502 268.0 188
226.4337 263.0 188
227.1863 260.0 188
227.6697 256.0 188
228.4058 252.0 188
229.1364 248.0 188
230.2625 246.0 188
230.6250 243.0 188
232.9816 240.0 188
233.5913 237.0 188
232.8387 235.0 188
234.8273 233.0 188
233.9374 230.0 188
234.2944 228.0 188
236.6675 226.0 188
236.6510 223.0 188
237.8870 221.0 188
238.4967 218.0 188
239.1229 217.0 188
239.2328 215.0 188
240.3424 213.0 188
240.9686 212.0 188
241.0730 211.0 188
242.1826 210.0 188
242.8088 209.0 188
242.5452 208.0 188
244.0283 207.0 188
244.6545 206.0 188
245.2643 205.0 188
245.8740 204.0 188
246.4948 203.0 188
247.1045 202.0 188
247.7142 201.0 188
247.9669 201.0 188
248.9502 199.0 188
249.5599 199.0 188
249.9335 199.0 188
250.7959 198.0 188
251.4056 197.0 188
252.0264 197.0 188
252.6361 197.0 188
253.2458 196.0 188
254.1248 196.0 188
254.4818 196.0 188
255.0916 196.0 188
255.7178 196.0 188
256.3275 195.0 188
256.9373 195.0 188
257.5580 195.0 188
258.1677 195.0 188
258.7939 195.0 188
259.4037 195.0 188
260.0134 195.0 188
260.6232 195.0 188
261.2494 195.0 188
261.2329 196.0 188
262.4634 196.0 188
263.0731 196.0 188
263.6993 197.0 188
264.3091 198.0 188
264.1718 198.0 188
265.5286 199.0 188
265.9021 200.0 188
266.7645 201.0 188
267.3743 202.0 188
267.9840 203.0 188
268.6047 204.0 188
269.2145 206.0 188
269.8242 207.0 188
269.5605 209.0 188
271.0602 210.0 188
271.6699 212.0 188
272.2797 215.0 188
272.8894 217.0 188
273.5156 220.0 188
274.1199 223.0 188
273.6090 227.0 188
274.5923 231.0 188
278.3881 1307.0 188
278.9978 1299.0 188
279.6075 1270.0 188
280.2173 1265.0 188
280.9479 1259.0 188
281.5576 1260.0 188
282.1674 1254.0 188
282.7771 1252.0 188
283.3868 1247.0 188
283.9966 1248.0 188
284.6063 1251.0 188
285.2325 1253.0 188
293.7964 1278.0 188
298.7018 1246.0 188
303.6072 1128.0 188
304.8431 1278.0 188
314.9011 1015.0 188
315.5109 1003.0 188
316.1371 987.0 188
317.3566 963.0 188
318.0927 949.0 188
318.7134 940.0 188
319.3231 930.0 188
319.9329 917.0 188
320.6689 909.0 188
321.2952 898.0 188
321.9049 888.0 188
322.5146 875.0 188
323.1244 866.0 188
323.8715 857.0 188
324.3549 851.0 188
324.9646 841.0 188
325.7007 832.0 188
326.2006 824.0 188
326.8103 814.0 188
327.5464 810.0 188
328.0298 801.0 188
328.7769 799.0 188
329.3866 787.0 188
329.9963 780.0 188
330.7324 774.0 188
331.2323 767.0 188
331.9684 761.0 188
332.5781 757.0 188
333.1824 711.0 188
333.9185 739.0 188
334.4183 741.0 188
335.0281 737.0 188
335.7642 731.0 188
336.3739 725.0 188
336.8573 718.0 188
337.6044 718.0 188
338.0933 710.0 188
338.8239 707.0 188
339.5599 701.0 188
339.9335 701.0 188
340.6696 695.0 188
341.4056 693.0 188
344.2456 385.0 188
344.9982 377.0 188
345.7343 373.0 188
346.0913 371.0 188
346.9482 370.0 188
347.7008 374.0 188
347.9370 374.0 188
348.5468 373.0 188
354.4684 267.0 188

ptsファイルの中身はこんな感じ
このファイルをmain.pyと同じディレクトリにおく

main.py
f = open("./20220228.pts",'r')
data = f.read()
datas_list = data.split('\n')
datas_float = []
for data_list in datas_list:
    datas_float.append(data_list.split(' '))
x_list = []
y_list = []
z_list = []
for i in range (len(datas_float)-1):
    for ii in range(3):
        if(ii % 3 == 1):
            x_list.append(float(datas_float[i][0]))
        elif(ii % 3 == 2):
            y_list.append(float(datas_float[i][1]))
        else:
            z_list.append(float(datas_float[i][2]))
main.py
import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
fig = plt.figure(figsize = (8, 8))
ax = fig.add_subplot(111, projection='3d')
ax.set_title("pts 3D", size = 20)
ax.set_xlabel("x", size = 14, color = "r")
ax.set_ylabel("y", size = 14, color = "r")
ax.set_zlabel("z", size = 14, color = "r")
ax.set_xlim(0,max(x_list))
ax.set_ylim(0,max(y_list))
ax.set_zlim(0,max(z_list))
for i in range(len(z_list)):
    ax.scatter(x_list[i], y_list[i], z_list[i], s = 40, c = "blue")
plt.show()
fig.savefig('3d.jpg')

実際の点群情報

messageImage_1646011436918.jpg

pythonで3dプロットした結果

3d.jpg

結果

これもまた前回の二次元にプロットした時と同様で
3dプロットしたものが点群情報とは異なっていることが分かる

課題

ptsファイルの構成を色々調べる必要がある

1
0
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?