share
Dependencies: RotationMat_ SDFileSystem mbed
Diff: main.cpp
- Revision:
- 0:cbd607fc4caa
- Child:
- 1:28cfbd0cc92e
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Wed Feb 03 11:39:23 2016 +0000 @@ -0,0 +1,506 @@ + +#include "mbed.h" +#include "SDFileSystem.h" +#include "Adafruit_DotStar.h" +#include "LedData.h" + +#include "Vector3D.h" +#include "RotationMat.h" +#include <math.h> + +SDFileSystem sd(p11, p12, p13, p14, "sd"); // the pinout on the mbed Cool Components workshop board +Serial pc(USBTX, USBRX); // tx, rx +FILE *fp; + +LocalFileSystem local("local"); // Create the local filesystem under the name "local" + +//const int byte_num = 114;//3*19 *2上下 // CSVから一度に読み込むバイト数 // 改行2バイト分読み込みをどこかで考える(アスキーコード 13と10) + +//int rState = 3; // シリアル値によって変化 +bool ontime = false; +unsigned char compareT_b[3]; +unsigned long compareT = 0;//比較する数値 +//unsigned long diff_time = 0;//時間調整用 +//unsigned long start_time = 0;//時間調整用 +Timer timer; + +float v_leds[6][9][22][3]= +{{{{94.8345, 103.159, 81.2937},{84.1609, 112.037, 81.2937},{72.6612, 119.815, 81.2937},{60.4483, 126.417, 81.2937},{47.642, 131.779, 81.2937},{34.368, 135.846, 81.2937},{20.7567, 138.58, 81.2937},{6.94161, 139.954, 81.2937},{-6.94162, 139.954, 81.2937}, +{-20.7567, 138.58, 81.2937},{-34.368, 135.846, 81.2937},{-47.642, 131.779, 81.2937},{-60.4483, 126.417, 81.2937},{-72.6612, 119.815, 81.2937},{-84.1609, 112.037, 81.2937},{-94.8345, 103.159, 81.2937},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0}}, +{{-110.95, 100.308, 62.2297},{-101.171, 110.163, 62.2297},{-90.5197, 119.07, 62.2297},{-79.0889, 126.95, 62.2297},{-66.9766, 133.737, 62.2297},{-54.2872, 139.371, 62.2297},{-41.1301, 143.805, 62.2297},{-27.6185, 146.999, 62.2297},{-13.869, 148.927, 62.2297}, +{0, 149.571, 62.2297},{13.869, 148.927, 62.2297},{27.6185, 146.999, 62.2297},{41.1301, 143.805, 62.2297},{54.2872, 139.371, 62.2297},{66.9766, 133.737, 62.2297},{79.0889, 126.95, 62.2297},{90.5197, 119.07, 62.2297},{101.171, 110.163, 62.2297},{110.95, 100.308, 62.2297}, +{0,0,0},{0,0,0},{0,0,0}}, +{{116.848, 104.014, 42.0925},{107.165, 113.965, 42.0925},{96.6378, 123.018, 42.0925},{85.3497, 131.102, 42.0925},{73.3891, 138.153, 42.0925},{60.8505, 144.116, 42.0925},{47.8326, 148.944, 42.0925},{34.4378, 152.598, 42.0925},{20.7718, 155.051, 42.0925},{6.94216, 156.282, 42.0925}, +{-6.94217, 156.282, 42.0925},{-20.7718, 155.051, 42.0925},{-34.4378, 152.598, 42.0925},{-47.8326, 148.944, 42.0925},{-60.8505, 144.116, 42.0925},{-73.3891, 138.153, 42.0925},{-85.3497, 131.102, 42.0925},{-96.6378, 123.018, 42.0925},{-107.165, 113.965, 42.0925},{-116.848, 104.014, 42.0925},{0,0,0},{0,0,0}}, +{{-126.603, 98.8175, 21.2293},{-117.595, 109.383, 21.2293},{-107.708, 119.131, 21.2293},{-97.0158, 127.989, 21.2293},{-85.5985, 135.89, 21.2293},{-73.5415, 142.776, 21.2293},{-60.9347, 148.594, 21.2293},{-47.8725, 153.302, 21.2293},{-34.4526, 156.864, 21.2293},{-20.7751, 159.254, 21.2293},{-6.94232, 160.453, 21.2293}, +{6.94234, 160.453, 21.2293},{20.7751, 159.254, 21.2293},{34.4526, 156.864, 21.2293},{47.8726, 153.302, 21.2293},{60.9347, 148.594, 21.2293},{73.5415, 142.776, 21.2293},{85.5986, 135.89, 21.2293},{97.0158, 127.989, 21.2293},{107.708, 119.131, 21.2293},{117.595, 109.383, 21.2293},{126.603, 98.8175, 21.2293}}, +{{126.92, 100.675, 0},{117.833, 111.173, 0},{107.88, 120.854, 0},{97.1356, 129.648, 0},{85.6772, 137.49, 0},{73.5894, 144.321, 0},{60.961, 150.092, 0},{47.8849, 154.761, 0},{34.457, 158.293, 0},{20.7759, 160.662, 0},{6.94232, 161.851, 0},{-6.94231, 161.851, 0},{-20.776, 160.662, 0},{-34.457, 158.293, 0}, +{-47.8849, 154.761, 0},{-60.9611, 150.092, 0},{-73.5894, 144.321, 0},{-85.6772, 137.49, 0},{-97.1356, 129.648, 0},{-107.88, 120.854, 0},{-117.833, 111.173, 0},{-126.92, 100.675, 0}}, +{{-126.603, 98.8175, -21.2293},{-117.595, 109.383, -21.2293},{-107.708, 119.131, -21.2293},{-97.0158, 127.989, -21.2293},{-85.5985, 135.89, -21.2293},{-73.5415, 142.776, -21.2293},{-60.9347, 148.594, -21.2293},{-47.8725, 153.302, -21.2293},{-34.4526, 156.864, -21.2293},{-20.7751, 159.254, -21.2293}, +{-6.94232, 160.453, -21.2293},{6.94234, 160.453, -21.2293},{20.7751, 159.254, -21.2293},{34.4526, 156.864, -21.2293},{47.8726, 153.302, -21.2293},{60.9347, 148.594, -21.2293},{73.5415, 142.776, -21.2293},{85.5986, 135.89, -21.2293},{97.0158, 127.989, -21.2293},{107.708, 119.131, -21.2293},{117.595, 109.383, -21.2293}, +{126.603, 98.8175, -21.2293}}, +{{116.848, 104.014, -42.0925},{107.165, 113.965, -42.0925},{96.6378, 123.018, -42.0925},{85.3497, 131.102, -42.0925},{73.3891, 138.153, -42.0925},{60.8505, 144.116, -42.0925},{47.8326, 148.944, -42.0925},{34.4378, 152.598, -42.0925},{20.7718, 155.051, -42.0925},{6.94216, 156.282, -42.0925},{-6.94217, 156.282, -42.0925}, +{-20.7718, 155.051, -42.0925},{-34.4378, 152.598, -42.0925},{-47.8326, 148.944, -42.0925},{-60.8505, 144.116, -42.0925},{-73.3891, 138.153, -42.0925},{-85.3497, 131.102, -42.0925},{-96.6378, 123.018, -42.0925},{-107.165, 113.965, -42.0925},{-116.848, 104.014, -42.0925},{0,0,0},{0,0,0}}, +{{-110.95, 100.308, -62.2297},{-101.171, 110.163, -62.2297},{-90.5197, 119.07, -62.2297},{-79.0889, 126.95, -62.2297},{-66.9766, 133.737, -62.2297},{-54.2872, 139.371, -62.2297},{-41.1301, 143.805, -62.2297},{-27.6185, 146.999, -62.2297},{-13.869, 148.927, -62.2297},{0, 149.571, -62.2297},{13.869, 148.927, -62.2297}, +{27.6185, 146.999, -62.2297},{41.1301, 143.805, -62.2297},{54.2872, 139.371, -62.2297},{66.9766, 133.737, -62.2297},{79.0889, 126.95, -62.2297},{90.5197, 119.07, -62.2297},{101.171, 110.163, -62.2297},{110.95, 100.308, -62.2297},{0,0,0},{0,0,0},{0,0,0}}, +{{94.8345, 103.159, -81.2937},{84.1609, 112.037, -81.2937},{72.6612, 119.815, -81.2937},{60.4483, 126.417, -81.2937},{47.642, 131.779, -81.2937},{34.368, 135.846, -81.2937},{20.7567, 138.58, -81.2937},{6.94161, 139.954, -81.2937},{-6.94162, 139.954, -81.2937},{-20.7567, 138.58, -81.2937},{-34.368, 135.846, -81.2937}, +{-47.642, 131.779, -81.2937},{-60.4483, 126.417, -81.2937},{-72.6612, 119.815, -81.2937},{-84.1609, 112.037, -81.2937},{-94.8345, 103.159, -81.2937},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0}} +},{{{81.2937, 94.8345, 103.159},{81.2937, 84.1609, 112.037},{81.2937, 72.6612, 119.815},{81.2937, 60.4483, 126.417},{81.2937, 47.642, 131.779},{81.2937, 34.368, 135.846},{81.2937, 20.7567, 138.58},{81.2937, 6.94162, 139.954},{81.2937, -6.94162, 139.954},{81.2937, -20.7567, 138.58},{81.2937, -34.368, 135.846}, +{81.2937, -47.642, 131.779},{81.2937, -60.4483, 126.417},{81.2937, -72.6612, 119.815},{81.2937, -84.1609, 112.037},{81.2937, -94.8345, 103.159},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0}}, +{{62.2297, -110.95, 100.308},{62.2297, -101.171, 110.163},{62.2297, -90.5197, 119.07},{62.2297, -79.0889, 126.95},{62.2298, -66.9766, 133.737},{62.2298, -54.2872, 139.371},{62.2297, -41.1301, 143.805},{62.2297, -27.6185, 146.999},{62.2297, -13.869, 148.927},{62.2297, 2.72015e-06, 149.571},{62.2297, 13.869, 148.927}, +{62.2297, 27.6185, 146.999},{62.2297, 41.1301, 143.805},{62.2297, 54.2872, 139.371},{62.2297, 66.9766, 133.737},{62.2297, 79.0889, 126.95},{62.2297, 90.5197, 119.07},{62.2297, 101.171, 110.163},{62.2297, 110.95, 100.308},{0,0,0},{0,0,0},{0,0,0}}, +{{42.0925, 116.848, 104.014},{42.0925, 107.165, 113.965},{42.0925, 96.6378, 123.018},{42.0925, 85.3496, 131.102},{42.0925, 73.3891, 138.153},{42.0925, 60.8505, 144.116},{42.0925, 47.8326, 148.944},{42.0925, 34.4378, 152.598},{42.0925, 20.7718, 155.051},{42.0925, 6.94216, 156.282},{42.0925, -6.94217, 156.282}, +{42.0925, -20.7718, 155.051},{42.0925, -34.4378, 152.598},{42.0925, -47.8326, 148.944},{42.0925, -60.8505, 144.116},{42.0925, -73.3891, 138.153},{42.0925, -85.3496, 131.102},{42.0925, -96.6378, 123.018},{42.0925, -107.165, 113.965},{42.0925, -116.848, 104.014},{0,0,0},{0,0,0}}, +{{21.2293, -126.603, 98.8175},{21.2293, -117.595, 109.383},{21.2293, -107.708, 119.131},{21.2293, -97.0158, 127.989},{21.2293, -85.5985, 135.89},{21.2293, -73.5415, 142.776},{21.2293, -60.9347, 148.594},{21.2293, -47.8725, 153.302},{21.2293, -34.4526, 156.864},{21.2293, -20.7751, 159.254},{21.2293, -6.94232, 160.453}, +{21.2293, 6.94234, 160.453},{21.2293, 20.7751, 159.254},{21.2293, 34.4526, 156.864},{21.2293, 47.8726, 153.302},{21.2293, 60.9347, 148.594},{21.2293, 73.5415, 142.776},{21.2293, 85.5985, 135.89},{21.2293, 97.0158, 127.989},{21.2293, 107.708, 119.131},{21.2293, 117.595, 109.383},{21.2293, 126.603, 98.8175}}, +{{-1.1472e-06, 126.92, 100.675},{-2.91114e-07, 117.833, 111.173},{5.67114e-07, 107.88, 120.854},{1.42118e-06, 97.1356, 129.648},{2.2648e-06, 85.6772, 137.49},{3.09178e-06, 73.5894, 144.321},{3.89606e-06, 60.961, 150.092},{4.67171e-06, 47.8849, 154.761},{5.41305e-06, 34.457, 158.293},{6.11463e-06, 20.7759, 160.662}, +{6.77128e-06, 6.94232, 161.851},{7.3782e-06, -6.94231, 161.851},{7.93092e-06, -20.776, 160.662},{8.42537e-06, -34.457, 158.293},{8.85794e-06, -47.8849, 154.761},{9.22544e-06, -60.9611, 150.092},{9.52517e-06, -73.5894, 144.321},{9.75493e-06, -85.6772, 137.49},{9.91304e-06, -97.1356, 129.648},{9.99832e-06, -107.88, 120.854},{1.00102e-05, -117.833, 111.173},{9.94847e-06, -126.92, 100.675}}, +{{-21.2293, -126.603, 98.8175},{-21.2293, -117.595, 109.383},{-21.2293, -107.708, 119.131},{-21.2293, -97.0158, 127.989},{-21.2293, -85.5985, 135.89},{-21.2293, -73.5415, 142.776},{-21.2293, -60.9347, 148.594},{-21.2293, -47.8725, 153.302},{-21.2293, -34.4526, 156.864},{-21.2293, -20.7751, 159.254},{-21.2293, -6.94232, 160.453},{-21.2293, 6.94234, 160.453},{-21.2293, 20.7751, 159.254}, +{-21.2293, 34.4526, 156.864},{-21.2293, 47.8726, 153.302},{-21.2293, 60.9347, 148.594},{-21.2293, 73.5415, 142.776},{-21.2293, 85.5985, 135.89},{-21.2293, 97.0158, 127.989},{-21.2293, 107.708, 119.131},{-21.2293, 117.595, 109.383},{-21.2293, 126.603, 98.8175}}, +{{-42.0925, 116.848, 104.014},{-42.0925, 107.165, 113.965},{-42.0925, 96.6378, 123.018},{-42.0925, 85.3496, 131.102},{-42.0925, 73.3891, 138.153},{-42.0925, 60.8505, 144.116},{-42.0925, 47.8326, 148.944},{-42.0925, 34.4378, 152.598},{-42.0925, 20.7718, 155.051}, +{-42.0925, 6.94216, 156.282},{-42.0925, -6.94217, 156.282},{-42.0925, -20.7718, 155.051},{-42.0925, -34.4378, 152.598},{-42.0925, -47.8326, 148.944},{-42.0925, -60.8505, 144.116},{-42.0925, -73.3891, 138.153},{-42.0925, -85.3496, 131.102},{-42.0925, -96.6378, 123.018},{-42.0925, -107.165, 113.965},{-42.0925, -116.848, 104.014},{0,0,0},{0,0,0}}, +{{-62.2297, -110.95, 100.308},{-62.2297, -101.171, 110.163},{-62.2297, -90.5197, 119.07},{-62.2297, -79.0889, 126.95},{-62.2297, -66.9766, 133.737},{-62.2297, -54.2872, 139.371},{-62.2297, -41.1301, 143.805},{-62.2297, -27.6185, 146.999},{-62.2297, -13.869, 148.927},{-62.2297, -2.72015e-06, 149.571},{-62.2297, 13.869, 148.927}, +{-62.2297, 27.6185, 146.999},{-62.2297, 41.1301, 143.805},{-62.2297, 54.2872, 139.371},{-62.2297, 66.9766, 133.737},{-62.2297, 79.0889, 126.95},{-62.2297, 90.5197, 119.07},{-62.2297, 101.171, 110.163},{-62.2297, 110.95, 100.308},{0,0,0},{0,0,0},{0,0,0}}, +{{-81.2937, 94.8345, 103.159},{-81.2936, 84.1609, 112.037},{-81.2936, 72.6612, 119.815},{-81.2936, 60.4483, 126.417},{-81.2936, 47.642, 131.779},{-81.2936, 34.368, 135.846},{-81.2936, 20.7567, 138.58},{-81.2936, 6.94161, 139.954},{-81.2936, -6.94162, 139.954}, +{-81.2936, -20.7567, 138.58},{-81.2936, -34.368, 135.846},{-81.2936, -47.642, 131.779},{-81.2936, -60.4483, 126.417},{-81.2936, -72.6612, 119.815},{-81.2936, -84.1609, 112.037},{-81.2936, -94.8345, 103.159},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0}} +},{{{-81.2937, 94.8345, -103.159},{-81.2936, 84.1609, -112.037},{-81.2936, 72.6612, -119.815},{-81.2936, 60.4483, -126.417},{-81.2936, 47.642, -131.779},{-81.2936, 34.368, -135.846},{-81.2936, 20.7567, -138.58},{-81.2936, 6.94161, -139.954},{-81.2936, -6.94162, -139.954}, +{-81.2936, -20.7567, -138.58},{-81.2936, -34.368, -135.846},{-81.2936, -47.642, -131.779},{-81.2936, -60.4483, -126.417},{-81.2936, -72.6612, -119.815},{-81.2936, -84.1609, -112.037},{-81.2936, -94.8345, -103.159},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0}}, +{{-62.2297, -110.95, -100.308},{-62.2297, -101.171, -110.163},{-62.2297, -90.5197, -119.07},{-62.2297, -79.0889, -126.95},{-62.2297, -66.9766, -133.737},{-62.2297, -54.2872, -139.371},{-62.2297, -41.1301, -143.805},{-62.2297, -27.6185, -146.999},{-62.2297, -13.869, -148.927}, +{-62.2297, -2.72015e-06, -149.571},{-62.2297, 13.869, -148.927},{-62.2297, 27.6185, -146.999},{-62.2297, 41.1301, -143.805},{-62.2297, 54.2872, -139.371},{-62.2297, 66.9766, -133.737},{-62.2297, 79.0889, -126.95},{-62.2297, 90.5197, -119.07},{-62.2297, 101.171, -110.163},{-62.2297, 110.95, -100.308},{0,0,0},{0,0,0},{0,0,0}}, +{{-42.0925, 116.848, -104.014},{-42.0925, 107.165, -113.965},{-42.0925, 96.6378, -123.018},{-42.0925, 85.3496, -131.102},{-42.0925, 73.3891, -138.153},{-42.0925, 60.8505, -144.116},{-42.0925, 47.8326, -148.944},{-42.0925, 34.4378, -152.598},{-42.0925, 20.7718, -155.051},{-42.0925, 6.94216, -156.282},{-42.0925, -6.94217, -156.282}, +{-42.0925, -20.7718, -155.051},{-42.0925, -34.4378, -152.598},{-42.0925, -47.8326, -148.944},{-42.0925, -60.8505, -144.116},{-42.0925, -73.3891, -138.153},{-42.0925, -85.3496, -131.102},{-42.0925, -96.6378, -123.018},{-42.0925, -107.165, -113.965},{-42.0925, -116.848, -104.014},{0,0,0},{0,0,0}}, +{{-21.2293, -126.603, -98.8175},{-21.2293, -117.595, -109.383},{-21.2293, -107.708, -119.131},{-21.2293, -97.0158, -127.989},{-21.2293, -85.5985, -135.89},{-21.2293, -73.5415, -142.776},{-21.2293, -60.9347, -148.594},{-21.2293, -47.8725, -153.302},{-21.2293, -34.4526, -156.864},{-21.2293, -20.7751, -159.254}, +{-21.2293, -6.94232, -160.453},{-21.2293, 6.94234, -160.453},{-21.2293, 20.7751, -159.254},{-21.2293, 34.4526, -156.864},{-21.2293, 47.8726, -153.302},{-21.2293, 60.9347, -148.594},{-21.2293, 73.5415, -142.776},{-21.2293, 85.5985, -135.89},{-21.2293, 97.0158, -127.989},{-21.2293, 107.708, -119.131},{-21.2293, 117.595, -109.383},{-21.2293, 126.603, -98.8175}}, +{{-1.1472e-06, 126.92, -100.675},{-2.91114e-07, 117.833, -111.173},{5.67114e-07, 107.88, -120.854},{1.42118e-06, 97.1356, -129.648},{2.2648e-06, 85.6772, -137.49},{3.09178e-06, 73.5894, -144.321},{3.89606e-06, 60.961, -150.092},{4.67171e-06, 47.8849, -154.761},{5.41305e-06, 34.457, -158.293},{6.11463e-06, 20.7759, -160.662},{6.77128e-06, 6.94232, -161.851}, +{7.3782e-06, -6.94231, -161.851},{7.93092e-06, -20.776, -160.662},{8.42537e-06, -34.457, -158.293},{8.85794e-06, -47.8849, -154.761},{9.22544e-06, -60.9611, -150.092},{9.52517e-06, -73.5894, -144.321},{9.75493e-06, -85.6772, -137.49},{9.91304e-06, -97.1356, -129.648},{9.99832e-06, -107.88, -120.854},{1.00102e-05, -117.833, -111.173},{9.94847e-06, -126.92, -100.675}}, +{{21.2293, -126.603, -98.8175},{21.2293, -117.595, -109.383},{21.2293, -107.708, -119.131},{21.2293, -97.0158, -127.989},{21.2293, -85.5985, -135.89},{21.2293, -73.5415, -142.776},{21.2293, -60.9347, -148.594},{21.2293, -47.8725, -153.302},{21.2293, -34.4526, -156.864},{21.2293, -20.7751, -159.254},{21.2293, -6.94232, -160.453},{21.2293, 6.94234, -160.453}, +{21.2293, 20.7751, -159.254},{21.2293, 34.4526, -156.864},{21.2293, 47.8726, -153.302},{21.2293, 60.9347, -148.594},{21.2293, 73.5415, -142.776},{21.2293, 85.5985, -135.89},{21.2293, 97.0158, -127.989},{21.2293, 107.708, -119.131},{21.2293, 117.595, -109.383},{21.2293, 126.603, -98.8175}}, +{{42.0925, 116.848, -104.014},{42.0925, 107.165, -113.965},{42.0925, 96.6378, -123.018},{42.0925, 85.3496, -131.102},{42.0925, 73.3891, -138.153},{42.0925, 60.8505, -144.116},{42.0925, 47.8326, -148.944},{42.0925, 34.4378, -152.598},{42.0925, 20.7718, -155.051},{42.0925, 6.94216, -156.282}, +{42.0925, -6.94217, -156.282},{42.0925, -20.7718, -155.051},{42.0925, -34.4378, -152.598},{42.0925, -47.8326, -148.944},{42.0925, -60.8505, -144.116},{42.0925, -73.3891, -138.153},{42.0925, -85.3496, -131.102},{42.0925, -96.6378, -123.018},{42.0925, -107.165, -113.965},{42.0925, -116.848, -104.014},{0,0,0},{0,0,0}}, +{{62.2297, -110.95, -100.308},{62.2297, -101.171, -110.163},{62.2297, -90.5197, -119.07},{62.2297, -79.0889, -126.95},{62.2298, -66.9766, -133.737},{62.2298, -54.2872, -139.371},{62.2297, -41.1301, -143.805},{62.2297, -27.6185, -146.999},{62.2297, -13.869, -148.927},{62.2297, 2.72015e-06, -149.571},{62.2297, 13.869, -148.927}, +{62.2297, 27.6185, -146.999},{62.2297, 41.1301, -143.805},{62.2297, 54.2872, -139.371},{62.2297, 66.9766, -133.737},{62.2297, 79.0889, -126.95},{62.2297, 90.5197, -119.07},{62.2297, 101.171, -110.163},{62.2297, 110.95, -100.308},{0,0,0},{0,0,0},{0,0,0}}, +{{81.2937, 94.8345, -103.159},{81.2937, 84.1609, -112.037},{81.2937, 72.6612, -119.815},{81.2937, 60.4483, -126.417},{81.2937, 47.642, -131.779},{81.2937, 34.368, -135.846},{81.2937, 20.7567, -138.58},{81.2937, 6.94162, -139.954},{81.2937, -6.94162, -139.954}, +{81.2937, -20.7567, -138.58},{81.2937, -34.368, -135.846},{81.2937, -47.642, -131.779},{81.2937, -60.4483, -126.417},{81.2937, -72.6612, -119.815},{81.2937, -84.1609, -112.037},{81.2937, -94.8345, -103.159},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0}} +}, +{{{-103.159, 81.2936, -94.8345},{-112.037, 81.2936, -84.1609},{-119.815, 81.2936, -72.6612},{-126.417, 81.2936, -60.4483},{-131.779, 81.2936, -47.642},{-135.846, 81.2936, -34.368},{-138.58, 81.2936, -20.7567},{-139.954, 81.2936, -6.94161},{-139.954, 81.2936, 6.94162}, +{-138.58, 81.2936, 20.7567},{-135.846, 81.2936, 34.368},{-131.779, 81.2936, 47.642},{-126.417, 81.2936, 60.4483},{-119.815, 81.2936, 72.6613},{-112.037, 81.2936, 84.1609},{-103.159, 81.2937, 94.8345},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0}}, +{{-100.308, 62.2297, 110.95},{-110.163, 62.2297, 101.171},{-119.07, 62.2297, 90.5197},{-126.95, 62.2297, 79.0889},{-133.737, 62.2297, 66.9766},{-139.371, 62.2297, 54.2873},{-143.805, 62.2297, 41.1301},{-146.999, 62.2297, 27.6185},{-148.927, 62.2297, 13.869}, +{-149.571, 62.2297, 3.8178e-06},{-148.927, 62.2297, -13.869},{-146.999, 62.2297, -27.6185},{-143.805, 62.2297, -41.1301},{-139.371, 62.2297, -54.2872},{-133.737, 62.2297, -66.9766},{-126.95, 62.2297, -79.0889},{-119.07, 62.2297, -90.5197},{-110.163, 62.2297, -101.171}, +{-100.308, 62.2297, -110.95},{0,0,0},{0,0,0},{0,0,0}}, +{{-104.014, 42.0925, -116.848},{-113.965, 42.0925, -107.165},{-123.018, 42.0925, -96.6378},{-131.102, 42.0925, -85.3496},{-138.153, 42.0925, -73.3891},{-144.116, 42.0925, -60.8505},{-148.944, 42.0925, -47.8326},{-152.598, 42.0925, -34.4378},{-155.051, 42.0925, -20.7718}, +{-156.282, 42.0925, -6.94216},{-156.282, 42.0925, 6.94217},{-155.051, 42.0925, 20.7718},{-152.598, 42.0925, 34.4378},{-148.944, 42.0925, 47.8326},{-144.116, 42.0925, 60.8505},{-138.153, 42.0925, 73.3891},{-131.102, 42.0925, 85.3497},{-123.018, 42.0925, 96.6378}, +{-113.965, 42.0925, 107.165},{-104.014, 42.0925, 116.848},{0,0,0},{0,0,0}}, +{{-98.8175, 21.2293, 126.603},{-109.383, 21.2293, 117.595},{-119.131, 21.2293, 107.708},{-127.989, 21.2293, 97.0158},{-135.89, 21.2293, 85.5985},{-142.776, 21.2293, 73.5415},{-148.594, 21.2293, 60.9347},{-153.302, 21.2293, 47.8725},{-156.864, 21.2293, 34.4526}, +{-159.254, 21.2293, 20.7751},{-160.453, 21.2293, 6.94233},{-160.453, 21.2293, -6.94233},{-159.254, 21.2293, -20.7751},{-156.864, 21.2293, -34.4526},{-153.302, 21.2293, -47.8726},{-148.594, 21.2293, -60.9347},{-142.776, 21.2293, -73.5415},{-135.89, 21.2293, -85.5985}, +{-127.989, 21.2293, -97.0158},{-119.131, 21.2293, -107.708},{-109.383, 21.2293, -117.595},{-98.8175, 21.2293, -126.603}}, +{{-100.675, -5.54783e-06, -126.92},{-111.173, -5.15064e-06, -117.833},{-120.854, -4.7156e-06, -107.88},{-129.648, -4.24593e-06, -97.1356},{-137.49, -3.74507e-06, -85.6772},{-144.321, -3.21669e-06, -73.5894},{-150.092, -2.66469e-06, -60.961},{-154.761, -2.09311e-06, -47.8849}, +{-158.293, -1.50616e-06, -34.457},{-160.662, -9.08145e-07, -20.7759},{-161.851, -3.03458e-07, -6.94231},{-161.851, 3.03459e-07, 6.94232},{-160.662, 9.08147e-07, 20.776},{-158.293, 1.50616e-06, 34.457},{-154.761, 2.09312e-06, 47.8849},{-150.092, 2.66469e-06, 60.9611}, +{-144.321, 3.2167e-06, 73.5894},{-137.49, 3.74507e-06, 85.6772},{-129.648, 4.24593e-06, 97.1356},{-120.854, 4.7156e-06, 107.88},{-111.173, 5.15064e-06, 117.833},{-100.675, 5.54784e-06, 126.92}}, +{{-98.8175, -21.2293, 126.603},{-109.383, -21.2293, 117.595},{-119.131, -21.2293, 107.708},{-127.989, -21.2293, 97.0158},{-135.89, -21.2293, 85.5985},{-142.776, -21.2293, 73.5415},{-148.594, -21.2293, 60.9347},{-153.302, -21.2293, 47.8725},{-156.864, -21.2293, 34.4526}, +{-159.254, -21.2293, 20.7751},{-160.453, -21.2293, 6.94233},{-160.453, -21.2293, -6.94233},{-159.254, -21.2293, -20.7751},{-156.864, -21.2293, -34.4526},{-153.302, -21.2293, -47.8726},{-148.594, -21.2293, -60.9347},{-142.776, -21.2293, -73.5415},{-135.89, -21.2293, -85.5985}, +{-127.989, -21.2293, -97.0158},{-119.131, -21.2293, -107.708},{-109.383, -21.2293, -117.595},{-98.8175, -21.2293, -126.603}}, +{{-104.014, -42.0925, -116.848},{-113.965, -42.0925, -107.165},{-123.018, -42.0925, -96.6378},{-131.102, -42.0925, -85.3496},{-138.153, -42.0925, -73.3891},{-144.116, -42.0925, -60.8505},{-148.944, -42.0925, -47.8326},{-152.598, -42.0925, -34.4378},{-155.051, -42.0925, -20.7718}, +{-156.282, -42.0925, -6.94215},{-156.282, -42.0925, 6.94218},{-155.051, -42.0925, 20.7718},{-152.598, -42.0925, 34.4378},{-148.944, -42.0925, 47.8326},{-144.116, -42.0925, 60.8505},{-138.153, -42.0925, 73.3891},{-131.102, -42.0925, 85.3497},{-123.018, -42.0925, 96.6378}, +{-113.965, -42.0925, 107.165},{-104.014, -42.0925, 116.848},{0,0,0},{0,0,0}}, +{{-100.308, -62.2297, 110.95},{-110.163, -62.2297, 101.171},{-119.07, -62.2297, 90.5197},{-126.95, -62.2297, 79.0889},{-133.737, -62.2297, 66.9766},{-139.371, -62.2297, 54.2873},{-143.805, -62.2297, 41.1301},{-146.999, -62.2297, 27.6186},{-148.927, -62.2297, 13.869}, +{-149.571, -62.2297, 9.2581e-06},{-148.927, -62.2297, -13.869},{-146.999, -62.2297, -27.6185},{-143.805, -62.2297, -41.1301},{-139.371, -62.2297, -54.2872},{-133.737, -62.2297, -66.9766},{-126.95, -62.2297, -79.0889},{-119.07, -62.2297, -90.5197},{-110.163, -62.2297, -101.171}, +{-100.308, -62.2297, -110.95},{0,0,0},{0,0,0},{0,0,0}}, +{{-103.159, -81.2937, -94.8345},{-112.037, -81.2936, -84.1609},{-119.815, -81.2936, -72.6612},{-126.417, -81.2936, -60.4483},{-131.779, -81.2936, -47.642},{-135.846, -81.2936, -34.368},{-138.58, -81.2936, -20.7567},{-139.954, -81.2936, -6.9416},{-139.954, -81.2936, 6.94163}, +{-138.58, -81.2936, 20.7567},{-135.846, -81.2936, 34.368},{-131.779, -81.2936, 47.642},{-126.417, -81.2936, 60.4483},{-119.815, -81.2936, 72.6613},{-112.037, -81.2936, 84.1609},{-103.159, -81.2936, 94.8345},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0}} +},{{{103.159, 81.2937, 94.8345},{112.037, 81.2936, 84.1609},{119.815, 81.2936, 72.6612},{126.417, 81.2936, 60.4483},{131.779, 81.2936, 47.642},{135.846, 81.2936, 34.368},{138.58, 81.2936, 20.7567},{139.954, 81.2936, 6.94162},{139.954, 81.2936, -6.94162},{138.58, 81.2936, -20.7567}, +{135.846, 81.2936, -34.368},{131.779, 81.2936, -47.642},{126.417, 81.2936, -60.4483},{119.815, 81.2936, -72.6612},{112.037, 81.2936, -84.1609},{103.159, 81.2936, -94.8345},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0}}, +{{100.308, 62.2297, -110.95},{110.163, 62.2297, -101.171},{119.07, 62.2297, -90.5197},{126.95, 62.2297, -79.0889},{133.737, 62.2297, -66.9766},{139.371, 62.2297, -54.2872},{143.805, 62.2297, -41.1301},{146.999, 62.2297, -27.6185},{148.927, 62.2297, -13.869},{149.571, 62.2297, 3.8178e-06}, +{148.927, 62.2297, 13.869},{146.999, 62.2297, 27.6185},{143.805, 62.2297, 41.1301},{139.371, 62.2297, 54.2872},{133.737, 62.2297, 66.9766},{126.95, 62.2297, 79.0889},{119.07, 62.2297, 90.5197},{110.163, 62.2297, 101.171},{100.308, 62.2297, 110.95},{0,0,0},{0,0,0},{0,0,0}}, +{{104.014, 42.0925, 116.848},{113.965, 42.0925, 107.165},{123.018, 42.0925, 96.6378},{131.102, 42.0925, 85.3497},{138.153, 42.0925, 73.3891},{144.116, 42.0925, 60.8505},{148.944, 42.0925, 47.8326},{152.598, 42.0925, 34.4378},{155.051, 42.0925, 20.7718},{156.282, 42.0925, 6.94217}, +{156.282, 42.0925, -6.94216},{155.051, 42.0925, -20.7718},{152.598, 42.0925, -34.4378},{148.944, 42.0925, -47.8326},{144.116, 42.0925, -60.8505},{138.153, 42.0925, -73.3891},{131.102, 42.0925, -85.3496},{123.018, 42.0925, -96.6378},{113.965, 42.0925, -107.165}, +{104.014, 42.0925, -116.848},{0,0,0},{0,0,0}}, +{{98.8175, 21.2293, -126.603},{109.383, 21.2293, -117.595},{119.131, 21.2293, -107.708},{127.989, 21.2293, -97.0158},{135.89, 21.2293, -85.5985},{142.776, 21.2293, -73.5415},{148.594, 21.2293, -60.9347},{153.302, 21.2293, -47.8725},{156.864, 21.2293, -34.4526}, +{159.254, 21.2293, -20.7751},{160.453, 21.2293, -6.94232},{160.453, 21.2293, 6.94234},{159.254, 21.2293, 20.7751},{156.864, 21.2293, 34.4526},{153.302, 21.2293, 47.8726},{148.594, 21.2293, 60.9347},{142.776, 21.2293, 73.5415},{135.89, 21.2293, 85.5986}, +{127.989, 21.2293, 97.0159},{119.131, 21.2293, 107.708},{109.383, 21.2293, 117.595},{98.8175, 21.2293, 126.603}}, +{{100.675, 5.54784e-06, 126.92},{111.173, 5.15064e-06, 117.833},{120.854, 4.7156e-06, 107.88},{129.648, 4.24593e-06, 97.1356},{137.49, 3.74507e-06, 85.6772},{144.321, 3.21669e-06, 73.5894},{150.092, 2.66469e-06, 60.9611},{154.761, 2.09311e-06, 47.8849}, +{158.293, 1.50616e-06, 34.457},{160.662, 9.08146e-07, 20.776},{161.851, 3.03459e-07, 6.94233},{161.851, -3.03458e-07, -6.94231},{160.662, -9.08146e-07, -20.776},{158.293, -1.50616e-06, -34.457},{154.761, -2.09312e-06, -47.8849},{150.092, -2.66469e-06, -60.9611}, +{144.321, -3.21669e-06, -73.5894},{137.49, -3.74507e-06, -85.6772},{129.648, -4.24593e-06, -97.1356},{120.854, -4.7156e-06, -107.88},{111.173, -5.15064e-06, -117.833},{100.675, -5.54784e-06, -126.92}}, +{{98.8175, -21.2293, -126.603},{109.383, -21.2293, -117.595},{119.131, -21.2293, -107.708},{127.989, -21.2293, -97.0158},{135.89, -21.2293, -85.5985},{142.776, -21.2293, -73.5415},{148.594, -21.2293, -60.9347},{153.302, -21.2293, -47.8725},{156.864, -21.2293, -34.4526}, +{159.254, -21.2293, -20.7751},{160.453, -21.2293, -6.94231},{160.453, -21.2293, 6.94235},{159.254, -21.2293, 20.7751},{156.864, -21.2293, 34.4526},{153.302, -21.2293, 47.8726},{148.594, -21.2293, 60.9347},{142.776, -21.2293, 73.5415},{135.89, -21.2293, 85.5986}, +{127.989, -21.2293, 97.0159},{119.131, -21.2293, 107.708},{109.383, -21.2293, 117.595},{98.8175, -21.2293, 126.603}}, +{{104.014, -42.0925, 116.848},{113.965, -42.0925, 107.165},{123.018, -42.0925, 96.6378},{131.102, -42.0925, 85.3497},{138.153, -42.0925, 73.3891},{144.116, -42.0925, 60.8505},{148.944, -42.0925, 47.8326},{152.598, -42.0925, 34.4378},{155.051, -42.0925, 20.7718}, +{156.282, -42.0925, 6.94217},{156.282, -42.0925, -6.94216},{155.051, -42.0925, -20.7718},{152.598, -42.0925, -34.4378},{148.944, -42.0925, -47.8326},{144.116, -42.0925, -60.8505},{138.153, -42.0925, -73.3891},{131.102, -42.0925, -85.3496},{123.018, -42.0925, -96.6378}, +{113.965, -42.0925, -107.165},{104.014, -42.0925, -116.848},{0,0,0},{0,0,0}}, +{{100.308, -62.2297, -110.95},{110.163, -62.2297, -101.171},{119.07, -62.2297, -90.5197},{126.95, -62.2297, -79.0889},{133.737, -62.2297, -66.9766},{139.371, -62.2297, -54.2872},{143.805, -62.2297, -41.1301},{146.999, -62.2297, -27.6185},{148.927, -62.2297, -13.869}, +{149.571, -62.2297, 9.2581e-06},{148.927, -62.2297, 13.869},{146.999, -62.2297, 27.6186},{143.805, -62.2297, 41.1301},{139.371, -62.2297, 54.2873},{133.737, -62.2297, 66.9766},{126.95, -62.2297, 79.0889},{119.07, -62.2297, 90.5197},{110.163, -62.2297, 101.171}, +{100.308, -62.2297, 110.95},{0,0,0},{0,0,0},{0,0,0}}, +{{103.159, -81.2936, 94.8345},{112.037, -81.2936, 84.1609},{119.815, -81.2936, 72.6612},{126.417, -81.2936, 60.4483},{131.779, -81.2936, 47.642},{135.846, -81.2936, 34.368},{138.58, -81.2936, 20.7567},{139.954, -81.2936, 6.94162},{139.954, -81.2936, -6.94161}, +{138.58, -81.2936, -20.7567},{135.846, -81.2936, -34.368},{131.779, -81.2936, -47.642},{126.417, -81.2936, -60.4483},{119.815, -81.2936, -72.6612},{112.037, -81.2936, -84.1609},{103.159, -81.2937, -94.8345},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0}} +},{{{94.8345, -103.159, -81.2937},{84.1609, -112.037, -81.2937},{72.6612, -119.815, -81.2937},{60.4483, -126.417, -81.2937},{47.642, -131.779, -81.2937},{34.368, -135.846, -81.2937},{20.7567, -138.58, -81.2937},{6.94161, -139.954, -81.2937}, +{-6.94162, -139.954, -81.2937},{-20.7567, -138.58, -81.2937},{-34.368, -135.846, -81.2937},{-47.642, -131.779, -81.2937},{-60.4483, -126.417, -81.2937},{-72.6612, -119.815, -81.2937},{-84.1609, -112.037, -81.2937},{-94.8345, -103.159, -81.2937}, +{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0}}, +{{-110.95, -100.308, -62.2297},{-101.171, -110.163, -62.2298},{-90.5197, -119.07, -62.2298},{-79.0889, -126.95, -62.2298},{-66.9766, -133.737, -62.2298},{-54.2872, -139.371, -62.2298},{-41.1301, -143.805, -62.2298},{-27.6185, -146.999, -62.2298}, +{-13.869, -148.927, -62.2298},{0, -149.571, -62.2298},{13.869, -148.927, -62.2298},{27.6185, -146.999, -62.2298},{41.1301, -143.805, -62.2298},{54.2872, -139.371, -62.2298},{66.9766, -133.737, -62.2298},{79.0889, -126.95, -62.2298}, +{90.5197, -119.07, -62.2298},{101.171, -110.163, -62.2298},{110.95, -100.308, -62.2297},{0,0,0},{0,0,0},{0,0,0}}, +{{116.848, -104.014, -42.0925},{107.165, -113.965, -42.0925},{96.6378, -123.018, -42.0925},{85.3497, -131.102, -42.0925},{73.3891, -138.153, -42.0925},{60.8505, -144.116, -42.0925},{47.8326, -148.944, -42.0925},{34.4378, -152.598, -42.0925}, +{20.7718, -155.051, -42.0925},{6.94216, -156.282, -42.0925},{-6.94217, -156.282, -42.0925},{-20.7718, -155.051, -42.0925},{-34.4378, -152.598, -42.0925},{-47.8326, -148.944, -42.0925},{-60.8505, -144.116, -42.0925},{-73.3891, -138.153, -42.0925}, +{-85.3497, -131.102, -42.0925},{-96.6378, -123.018, -42.0925},{-107.165, -113.965, -42.0925},{-116.848, -104.014, -42.0925},{0,0,0},{0,0,0}}, +{{-126.603, -98.8175, -21.2293},{-117.595, -109.383, -21.2293},{-107.708, -119.131, -21.2293},{-97.0158, -127.989, -21.2293},{-85.5985, -135.89, -21.2293},{-73.5415, -142.776, -21.2294},{-60.9347, -148.594, -21.2294},{-47.8725, -153.302, -21.2294}, +{-34.4526, -156.864, -21.2294},{-20.7751, -159.254, -21.2294},{-6.94232, -160.453, -21.2294},{6.94234, -160.453, -21.2294},{20.7751, -159.254, -21.2294},{34.4526, -156.864, -21.2294},{47.8726, -153.302, -21.2294},{60.9347, -148.594, -21.2294}, +{73.5415, -142.776, -21.2294},{85.5986, -135.89, -21.2293},{97.0158, -127.989, -21.2293},{107.708, -119.131, -21.2293},{117.595, -109.383, -21.2293},{126.603, -98.8175, -21.2293}}, +{{126.92, -100.675, -8.80126e-06},{117.833, -111.173, -9.71905e-06},{107.88, -120.854, -1.05654e-05},{97.1356, -129.648, -1.13342e-05},{85.6772, -137.49, -1.20197e-05},{73.5894, -144.321, -1.2617e-05},{60.961, -150.092, -1.31215e-05}, +{47.8849, -154.761, -1.35297e-05},{34.457, -158.293, -1.38384e-05},{20.7759, -160.662, -1.40455e-05},{6.94232, -161.851, -1.41495e-05},{-6.94231, -161.851, -1.41495e-05},{-20.776, -160.662, -1.40455e-05},{-34.457, -158.293, -1.38384e-05}, +{-47.8849, -154.761, -1.35297e-05},{-60.9611, -150.092, -1.31215e-05},{-73.5894, -144.321, -1.2617e-05},{-85.6772, -137.49, -1.20197e-05},{-97.1356, -129.648, -1.13342e-05},{-107.88, -120.854, -1.05654e-05},{-117.833, -111.173, -9.71905e-06}, +{-126.92, -100.675, -8.80126e-06}}, +{{-126.603, -98.8175, 21.2293},{-117.595, -109.383, 21.2293},{-107.708, -119.131, 21.2293},{-97.0158, -127.989, 21.2293},{-85.5985, -135.89, 21.2293},{-73.5415, -142.776, 21.2293},{-60.9347, -148.594, 21.2293},{-47.8725, -153.302, 21.2293}, +{-34.4526, -156.864, 21.2293},{-20.7751, -159.254, 21.2293},{-6.94232, -160.453, 21.2293},{6.94234, -160.453, 21.2293},{20.7751, -159.254, 21.2293},{34.4526, -156.864, 21.2293},{47.8726, -153.302, 21.2293},{60.9347, -148.594, 21.2293}, +{73.5415, -142.776, 21.2293},{85.5986, -135.89, 21.2293},{97.0158, -127.989, 21.2293},{107.708, -119.131, 21.2293},{117.595, -109.383, 21.2293},{126.603, -98.8175, 21.2293}}, +{{116.848, -104.014, 42.0925},{107.165, -113.965, 42.0925},{96.6378, -123.018, 42.0925},{85.3497, -131.102, 42.0925},{73.3891, -138.153, 42.0925},{60.8505, -144.116, 42.0925},{47.8326, -148.944, 42.0925},{34.4378, -152.598, 42.0925}, +{20.7718, -155.051, 42.0925},{6.94216, -156.282, 42.0925},{-6.94217, -156.282, 42.0925},{-20.7718, -155.051, 42.0925},{-34.4378, -152.598, 42.0925},{-47.8326, -148.944, 42.0925},{-60.8505, -144.116, 42.0925},{-73.3891, -138.153, 42.0925}, +{-85.3497, -131.102, 42.0925},{-96.6378, -123.018, 42.0925},{-107.165, -113.965, 42.0925},{-116.848, -104.014, 42.0925},{0,0,0},{0,0,0}}, +{{-110.95, -100.308, 62.2297},{-101.171, -110.163, 62.2297},{-90.5197, -119.07, 62.2297},{-79.0889, -126.95, 62.2297},{-66.9766, -133.737, 62.2297},{-54.2872, -139.371, 62.2297},{-41.1301, -143.805, 62.2297},{-27.6185, -146.999, 62.2297}, +{-13.869, -148.927, 62.2297},{0, -149.571, 62.2297},{13.869, -148.927, 62.2297},{27.6185, -146.999, 62.2297},{41.1301, -143.805, 62.2297},{54.2872, -139.371, 62.2297},{66.9766, -133.737, 62.2297},{79.0889, -126.95, 62.2297}, +{90.5197, -119.07, 62.2297},{101.171, -110.163, 62.2297},{110.95, -100.308, 62.2297},{0,0,0},{0,0,0},{0,0,0}}, +{{94.8345, -103.159, 81.2936},{84.1609, -112.037, 81.2936},{72.6612, -119.815, 81.2936},{60.4483, -126.417, 81.2936},{47.642, -131.779, 81.2936},{34.368, -135.846, 81.2936},{20.7567, -138.58, 81.2936},{6.94161, -139.954, 81.2936}, +{-6.94162, -139.954, 81.2936},{-20.7567, -138.58, 81.2936},{-34.368, -135.846, 81.2936},{-47.642, -131.779, 81.2936},{-60.4483, -126.417, 81.2936},{-72.6612, -119.815, 81.2936},{-84.1609, -112.037, 81.2936},{-94.8345, -103.159, 81.2936}, +{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0}}}}; + + +RotationMat rMat; + +Vector3D position_vec; +Vector3D rAxis(1,0,0); +const Vector3D xAxis(1,0,0); +const Vector3D yAxis(0,1,0); +const Vector3D zAxis(0,0,1); + +unsigned int angular_velocity; +float rotation; +float x_=0; +float y_=0; +float z_=0; +float diff_rotation=2; + +short longtitude; +short latitude; + +#define NUMPIXELS 178 +#define NUM_LINE 9 +#define NUM_TAPE 1 +Adafruit_DotStar strip(NUMPIXELS, DOTSTAR_RGB); + +DigitalOut decoder_in_a(p24); +DigitalOut decoder_in_b(p25); +DigitalOut decoder_in_c(p26); + +struct LedColor +{ + unsigned char r; + unsigned char g; + unsigned char b; +}; +struct LedColor ledcolor; + +void selectDecoderCh(unsigned int num_ch) +{ + decoder_in_a = num_ch & 0b1; + decoder_in_b = (num_ch>>1) & 0b1; + decoder_in_c = (num_ch>>2) & 0b1; +} + + +//回転 +void updateRotation(int i_tape, int i_line, int i_pixel) +{ + x_ = v_leds[i_tape][i_line][i_pixel][0];//x + y_ = v_leds[i_tape][i_line][i_pixel][1];//y + z_ = v_leds[i_tape][i_line][i_pixel][2];//z + v_leds[i_tape][i_line][i_pixel][0] = rMat.r1*x_+rMat.r2*y_+rMat.r3*z_; + v_leds[i_tape][i_line][i_pixel][1] = rMat.r4*x_+rMat.r5*y_+rMat.r6*z_; + v_leds[i_tape][i_line][i_pixel][2] = rMat.r7*x_+rMat.r8*y_+rMat.r9*z_; +} + + +void setPixelcolor(int i_lednum) +{ + // pc.printf("i_lednum:%d \n", i_lednum); + if(i_lednum >= 176 ) //最後の白色消す用 + { + strip.setPixelColor(i_lednum, + 0, //r + 0, //g + 0);//b + } + else if(longtitude>=0&&longtitude<45) + { + strip.setPixelColor(i_lednum, + pixels0_45[longtitude][latitude][0], //r + pixels0_45[longtitude][latitude][1], //g + pixels0_45[longtitude][latitude][2]);//b + /* + pc.printf("pixels0_45[0]:%d \n", pixels0_45[longtitude][latitude][0]); + pc.printf("pixels0_45[1]:%d \n", pixels0_45[longtitude][latitude][1]); + pc.printf("pixels0_45[2]:%d \n", pixels0_45[longtitude][latitude][2]); + */ + + } + else if(longtitude>=45&&longtitude<90) + { + strip.setPixelColor(i_lednum, + (uint8_t)pixels45_90[longtitude-45][latitude][0], //r + (uint8_t)pixels45_90[longtitude-45][latitude][1], //g + (uint8_t)pixels45_90[longtitude-45][latitude][2]);//b + /* + pc.printf("pixels45_90[0]:%d \n", pixels45_90[longtitude-45][latitude][0]); + pc.printf("pixels45_90[1]:%d \n", pixels45_90[longtitude-45][latitude][1]); + pc.printf("pixels45_90[2]:%d \n", pixels45_90[longtitude-45][latitude][2]); + */ + } + else if(longtitude>=90&&longtitude<135) + { + strip.setPixelColor(i_lednum, + pixels90_135[longtitude-90][latitude][0], //r + pixels90_135[longtitude-90][latitude][1], //g + pixels90_135[longtitude-90][latitude][2]);//b + /* + pc.printf("pixels90_135[0]:%d \n", pixels90_135[longtitude-90][latitude][0]); + pc.printf("pixels90_135[1]:%d \n", pixels90_135[longtitude-90][latitude][1]); + pc.printf("pixels90_135[2]:%d \n", pixels90_135[longtitude-90][latitude][2]); + */ + } + else if(longtitude>=135&&longtitude<180) + { + strip.setPixelColor(i_lednum, + pixels135_180[longtitude-135][latitude][0], //r + pixels135_180[longtitude-135][latitude][1], //g + pixels135_180[longtitude-135][latitude][2]);//b + /* + pc.printf("pixels135_180[0]:%d \n", pixels135_180[longtitude-135][latitude][0]); + pc.printf("pixels135_180[1]:%d \n", pixels135_180[longtitude-135][latitude][1]); + pc.printf("pixels135_180[2]:%d \n", pixels135_180[longtitude-135][latitude][2]); + */ + } + else if(longtitude>=180&&longtitude<225) + { + strip.setPixelColor(i_lednum, + pixels180_225[longtitude-135][latitude][0], //r + pixels180_225[longtitude-135][latitude][1], //g + pixels180_225[longtitude-135][latitude][2]);//b + } + else if(longtitude>=225&&longtitude<270) + { + strip.setPixelColor(i_lednum, + pixels225_270[longtitude-225][latitude][0], //r + pixels225_270[longtitude-225][latitude][1], //g + pixels225_270[longtitude-225][latitude][2]);//b + } + else if(longtitude>=270&&longtitude<315) + { + strip.setPixelColor(i_lednum, + pixels270_315[longtitude-270][latitude][0], //r + pixels270_315[longtitude-270][latitude][1], //g + pixels270_315[longtitude-270][latitude][2]);//b + } + else if(longtitude>=315&&longtitude<=360) + { + strip.setPixelColor(i_lednum, + pixels315_361[longtitude-315][latitude][0], //r + pixels315_361[longtitude-315][latitude][1], //g + pixels315_361[longtitude-315][latitude][2]);//b + } +} + +void set_strip_color(int i_tape, int i_line, int i_pixel, int i_lednum) +{ + //calc longtitude + position_vec.x = v_leds[i_tape][i_line][i_pixel][0]; + position_vec.y = v_leds[i_tape][i_line][i_pixel][1]; + position_vec.z = v_leds[i_tape][i_line][i_pixel][2]; + + if(position_vec.x > 0) + { + longtitude = (short)floor( angle(zAxis, position_vec) ); + } + else + { + longtitude = (short)floor( 360.0f - angle(zAxis, position_vec)); + } + + //calc latitude + position_vec.x = v_leds[i_tape][i_line][i_pixel][0]; + position_vec.y = v_leds[i_tape][i_line][i_pixel][1]; + position_vec.z = v_leds[i_tape][i_line][i_pixel][2]; + + latitude = (short)floor( angle(yAxis, position_vec) ); + + + + setPixelcolor(i_lednum); +} + +void init() +{ + angular_velocity=10; + + pc.baud(9600); + pc.printf("Hello World!\n"); + /* + mkdir("/sd/001.txt", 0777); + fp = fopen("/sd/001.txt","r"); + + if(fp == NULL) + { + error("Could not open file for read\n"); + } + */ + timer.start(); + + strip.begin(); //Initialize + for(int i_tape=0; i_tape<NUM_TAPE; i_tape++) + { + selectDecoderCh(i_tape); + strip.show(); //Turn all LEDs off ASAP + } +} + +int main() { + init(); + + while(1) + { + //回転ベクトル更新 + rMat.calMat(angular_velocity, rAxis.x, rAxis.y, rAxis.z); + + //バレーボール6枚 + for(int i_tape=0; i_tape<NUM_TAPE; i_tape++) + { + selectDecoderCh(i_tape); + //バレーボール1枚あたりのLEDの本数 + for(int i_line=0; i_line<NUM_LINE; i_line++) + { + switch(i_line) + { + case 0: + for(int i_pixel =0; i_pixel < LED_0_8_NUM ; i_pixel++) + { + updateRotation(i_tape, i_line, i_pixel); + set_strip_color(i_tape, i_line, i_pixel, i_pixel); + } + break; + case 1: + for(int i_pixel =0; i_pixel < LED_1_7_NUM ; i_pixel++) + { + updateRotation(i_tape, i_line, i_pixel); + set_strip_color(i_tape, i_line, i_pixel, i_pixel+16); + } + break; + case 2: + for(int i_pixel =0; i_pixel < LED_2_6_NUM ; i_pixel++) + { + updateRotation(i_tape, i_line, i_pixel); + set_strip_color(i_tape, i_line, i_pixel, i_pixel+35); + } + break; + case 3: + for(int i_pixel =0; i_pixel < LED_3_4_5_NUM ; i_pixel++) + { + updateRotation(i_tape, i_line, i_pixel); + set_strip_color(i_tape, i_line, i_pixel, i_pixel+55); + } + break; + case 4: + for(int i_pixel =0; i_pixel < LED_3_4_5_NUM ; i_pixel++) + { + set_strip_color(i_tape, i_line, i_pixel, i_pixel+77); + } + break; + case 5: + for(int i_pixel =0; i_pixel < LED_3_4_5_NUM ; i_pixel++) + { + updateRotation(i_tape, i_line, i_pixel); + set_strip_color(i_tape, i_line, i_pixel, i_pixel+99); + } + break; + case 6: + for(int i_pixel =0; i_pixel < LED_2_6_NUM ; i_pixel++) + { + updateRotation(i_tape, i_line, i_pixel); + set_strip_color(i_tape, i_line, i_pixel, i_pixel+121); + } + break; + case 7: + for(int i_pixel =0; i_pixel < LED_1_7_NUM ; i_pixel++) + { + updateRotation(i_tape, i_line, i_pixel); + set_strip_color(i_tape, i_line, i_pixel, i_pixel+141); + } + break; + case 8: + for(int i_pixel =0; i_pixel < LED_0_8_NUM ; i_pixel++) + { + updateRotation(i_tape, i_line, i_pixel); + set_strip_color(i_tape, i_line, i_pixel, i_pixel+160); + } + break; + } + } + //白色点灯回避用 + strip.setPixelColor(176,0,0,0); + strip.setPixelColor(177,0,0,0); + + strip.show(); + } + } +} + /* for(int i_tape=0; i_tape<NUM_TAPE; i_tape++) + { + selectDecoderCh(i_tape); + for(int i_pixel=0; i_pixel<NUMPIXELS; i_pixel++) + { + strip.setPixelColor(i_pixel, 100*i_pixel/NUMPIXELS, 100*(NUMPIXELS-i_pixel)/NUMPIXELS, 0); + } + strip.show(); + } + + for(int i_tape=0; i_tape<NUM_TAPE; i_tape++) + { + selectDecoderCh(i_tape); + for(int i_pixel=0; i_pixel<NUMPIXELS; i_pixel++) + { + strip.setPixelColor(i_pixel, 0, 100*i_pixel/NUMPIXELS, 100*(NUMPIXELS-i_pixel)/NUMPIXELS); + } + strip.show(); + } + */ + + /* + while(1) { + // testes=fgetc(fp); + // pc.printf("%d\n", (int)testes - 48); + wait(0.01); + + // pc.printf("sdData[9]: %d\n", (int)(sdData[9])); + + if(ontime == false) + { + fread(compareT_b, 1,3, fp); + + //fgets(compareT_b, 3+1, fp);//取ってくる個数+1 + pc.printf("Compare0: %d\n", (int)( compareT_b[0])); + pc.printf("Compare1: %d\n", (int)( compareT_b[1])); + pc.printf("Compare2: %d\n", (int)( compareT_b[2])); + compareT = (unsigned long)(compareT_b[0]) * 256 * 256 + (unsigned long)(compareT_b[1]) * 256 + (unsigned long)compareT_b[2];//符号拡張阻止 + //pc.putc(compareT); + pc.printf("Compare: %d\n", compareT); + + ontime = true; + } + + if( timer.read()*1000 > compareT)//compareTが現在の時間がcomparetTを超えたら + { + ontime = false; + + // SDカードをbyte_num分、読み取る (57Byte) + //fgets(sdData, byte_num+1+2, fp);//取ってくる個数+1 + fread(sdData, 1,byte_num, fp); + pc.printf("sdData[0]: %d\n", (int)(sdData[0])); + pc.printf("sdData[1]: %d\n", (int)(sdData[1])); + pc.printf("sdData[2]: %d\n", (int)(sdData[2])); + } + } + */ \ No newline at end of file