Exemplo n.º 1
0
        public void ifDistanceIsVerticalOrHorizontal()
        {
            Assert.AreEqual <double>(0.5, CoordinateCalculator.getScale(new Point(0, 0), new Point(1, 0), 2),
                                     "The scale of 1/2 is correctely calculated");

            Assert.AreEqual <double>(0.5, CoordinateCalculator.getScale(new Point(0, 0), new Point(0, 1), 2),
                                     "The scale of 1/2 is correctely calculated");
        }
Exemplo n.º 2
0
        public void ifLengthIsZeroThenScaleIsZero()
        {
            Assert.AreEqual <double>(0, CoordinateCalculator.getScale(new Point(0, 0), new Point(0, 0), 0),
                                     "The scale of zero is correctely calculated");

            Assert.AreEqual <double>(0, CoordinateCalculator.getScale(new Point((float)3.25, (float)6.6666), new Point((float)8.99, (float)0.0005), 0),
                                     "The scale of zero is correctely calculated");
        }
Exemplo n.º 3
0
        private void DrawPosition(CoordinateCalculator corCalc, Graphics g)
        {
            var point    = _db.GetPosition();
            var projectd = corCalc.MapPoint(new PointF(Decimal.ToSingle(point.lng), Decimal.ToSingle(point.lat)));

            g.DrawLine(new Pen(Color.Red, 2), projectd.X - 6, projectd.Y, projectd.X + 6, projectd.Y);
            g.DrawLine(new Pen(Color.Red, 2), projectd.X, projectd.Y - 6, projectd.X, projectd.Y + 6);
        }
Exemplo n.º 4
0
        public void ifStartEndPointSameThenScaleIsZero()
        {
            Assert.AreEqual <double>(0, CoordinateCalculator.getScale(new Point(0, 0), new Point(0, 0), 20),
                                     "The scale of zero is correctely calculated");

            Assert.AreEqual <double>(0, CoordinateCalculator.getScale(new Point((float)5.14, (float)3.11), new Point((float)5.14, (float)3.11), 11.3),
                                     "The scale of zero is correctely calculated");
        }
Exemplo n.º 5
0
    // Use this for initialization
    void Start()
    {
        var sats = ParserTLE.ParseString("\r\nISS (ZARYA)             \r\n1 25544U 98067A   17258.66207433  .00002352  00000-0  42668-4 0  9996\r\n2 25544  51.6434 307.2969 0003696 276.6985 227.2383 15.54196035 75826\r\nTIANGONG 1              \r\n1 37820U 11053A   17259.54739255  .00058138  00000-0  24196-3 0  9994\r\n2 37820  42.7575 358.5910 0019922   5.9603 111.3279 15.84538366342438\r\nAGGIESAT 4              \r\n1 41313U 98067HP  17258.44077356  .00042699  00000-0  23727-3 0  9995\r\n2 41313  51.6381 257.8890 0003807 101.2846 258.8583 15.79044504 93164\r\nNODES 2                 \r\n1 41477U 98067HX  17259.43685587  .01745891  31111-2  98571-3 0  9990\r\n2 41477  51.6165 242.2525 0002417 106.9606 253.1612 16.19290091 76600\r\nNODES 1                 \r\n1 41478U 98067HY  17259.49295397  .00956277  55723-3  88097-3 0  9992\r\n2 41478  51.6183 243.4798 0003195  83.8364 276.3014 16.11800501 76590\r\nFLOCK 2E'-1             \r\n1 41479U 98067HZ  17259.06212448  .00036116  00000-0  25835-3 0  9999\r\n2 41479  51.6325 271.8323 0001157  14.1796 345.9235 15.73367650 76149\r\nFLOCK 2E'-3             \r\n1 41480U 98067JA  17259.41704939  .00041384  00000-0  30035-3 0  9992\r\n2 41480  51.6319 269.7242 0001960  26.2589 333.8509 15.72961681 76194\r\nFLOCK 2E'-2             \r\n1 41481U 98067JB  17259.44288770  .00042712  00000-0  29463-3 0  9995\r\n2 41481  51.6292 267.5779 0001158  63.8590 296.2528 15.74136671 76215\r\nFLOCK 2E'-4             \r\n1 41482U 98067JC  17259.38931460  .00076989  00000-0  44667-3 0  9996\r\n2 41482  51.6277 264.9284 0002851  67.6433 292.4869 15.77841040 76245\r\nFLOCK 2E-1              \r\n1 41483U 98067JD  17259.50885083  .00030602  00000-0  24000-3 0  9991\r\n2 41483  51.6344 271.1522 0003148  37.6267 322.4951 15.71273051 76047\r\nFLOCK 2E-2              \r\n1 41484U 98067JE  17259.39625517  .00039471  00000-0  27973-3 0  9998\r\n2 41484  51.6357 268.9149 0003418  46.8803 313.2481 15.73538606 76069\r\nFLOCK 2E-3              \r\n1 41486U 98067JG  17259.45362261  .00051238  00000-0  37975-3 0  9999\r\n2 41486  51.6336 273.0184 0003477  56.9950 303.1382 15.72368497 76037\r\nFLOCK 2E-4              \r\n1 41487U 98067JH  17259.43293316  .00030506  00000-0  23819-3 0  9999\r\n2 41487  51.6342 271.3578 0003948  69.1291 291.0130 15.71377561 76059\r\nFLOCK 2E-6              \r\n1 41563U 98067JM  17258.43992194  .00023410  00000-0  20044-3 0  9996\r\n2 41563  51.6342 279.7291 0000366  85.9717 274.1322 15.69317603 73924\r\nFLOCK 2E-5              \r\n1 41564U 98067JN  17259.41065253  .00027179  00000-0  23156-3 0  9996\r\n2 41564  51.6340 274.9725 0000592  48.0856 312.0191 15.69344774 74068\r\nFLOCK 2E-7              \r\n1 41565U 98067JP  17259.45896539  .00041995  00000-0  29451-3 0  9996\r\n2 41565  51.6335 268.4794 0004240  82.7120 277.4360 15.73751132 74056\r\nFLOCK 2E'-5             \r\n1 41567U 98067JR  17259.07438845  .00021444  00000-0  19137-3 0  9995\r\n2 41567  51.6354 278.7541 0004069 100.7144 259.4311 15.68359203 73859\r\nFLOCK 2E'-6             \r\n1 41568U 98067JS  17259.50910311  .00030945  00000-0  24824-3 0  9992\r\n2 41568  51.6336 272.5913 0003732  93.6391 266.5033 15.70722225 74004\r\nFLOCK 2E'-8             \r\n1 41569U 98067JT  17259.41142022  .00045954  00000-0  31736-3 0  9995\r\n2 41569  51.6317 268.1595 0002986  51.4134 308.7132 15.74073710 73930\r\nFLOCK 2E'-7             \r\n1 41570U 98067JU  17259.15190581  .00326900  00000-0  11184-2 0  9998\r\n2 41570  51.6332 263.3951 0006109  65.6729 294.4913 15.88285199 73995\r\nFLOCK 2E-9              \r\n1 41571U 98067JV  17259.10493146  .00049135  00000-0  32274-3 0  9993\r\n2 41571  51.6338 268.3764 0003513  76.6090 283.5301 15.75202360 73881\r\nFLOCK 2E-10             \r\n1 41572U 98067JW  17259.43790460  .00040058  00000-0  29117-3 0  9996\r\n2 41572  51.6332 269.8731 0004295  86.0198 274.1292 15.72933573 73898\r\nFLOCK 2E-12             \r\n1 41573U 98067JX  17259.44634512  .00045252  00000-0  30943-3 0  9993\r\n2 41573  51.6318 268.4001 0003562  89.2684 270.8723 15.74308568 73916\r\nFLOCK 2E-11             \r\n1 41574U 98067JY  17259.43303495  .00045358  00000-0  30983-3 0  9997\r\n2 41574  51.6309 267.5048 0004012  97.0920 263.0536 15.74330073 73922\r\nFLOCK 2E'-9             \r\n1 41575U 98067JZ  17259.42109348  .00051747  00000-0  32968-3 0  9992\r\n2 41575  51.6310 265.8894 0003384 102.4574 257.6804 15.75881081 73931\r\nFLOCK 2E'-10            \r\n1 41576U 98067KA  17259.04663571  .00042982  00000-0  28831-3 0  9999\r\n2 41576  51.6339 270.2669 0003738 104.6053 255.5361 15.74776751 73742\r\nFLOCK 2E'-11            \r\n1 41577U 98067KB  17259.43910863  .00042291  00000-0  30015-3 0  9992\r\n2 41577  51.6337 269.1541 0004120  90.8730 269.2741 15.73469385 73612\r\nFLOCK 2E'-12            \r\n1 41578U 98067KC  17259.40893504  .00050874  00000-0  32560-3 0  9995\r\n2 41578  51.6308 267.3432 0004939  80.8682 279.2876 15.75775858 73632\r\nFLOCK 2E'-13            \r\n1 41761U 98067KH  17259.09030231  .00016650  00000-0  18762-3 0  9996\r\n2 41761  51.6371 292.4464 0005059 248.1918 111.8538 15.62666949 57112\r\nFLOCK 2E'-14            \r\n1 41762U 98067KJ  17259.44658629  .00019477  00000-0  21522-3 0  9991\r\n2 41762  51.6383 290.3594 0004825 252.0732 107.9737 15.63046543 57171\r\nFLOCK 2E'-16            \r\n1 41763U 98067KK  17259.45272653  .00021392  00000-0  23075-3 0  9996\r\n2 41763  51.6387 289.6477 0004402 268.1222  91.9268 15.63598994 57140\r\nFLOCK 2E'-15            \r\n1 41764U 98067KL  17259.49110669  .00016312  00000-0  18459-3 0  9995\r\n2 41764  51.6382 290.6515 0004814 259.2917 100.7535 15.62576791 57135\r\nTIANGONG-2              \r\n1 41765U 16057A   17259.19774463  .00001950  00000-0  29267-4 0  9992\r\n2 41765  42.7843 174.3143 0002085 188.1494 334.0354 15.58804008 57188\r\nFLOCK 2E'-18            \r\n1 41769U 98067KM  17259.15433421  .00017075  00000-0  19269-3 0  9994\r\n2 41769  51.6381 292.1460 0004198 287.2844  72.7691 15.62611238 57081\r\nFLOCK 2E'-17            \r\n1 41776U 98067KN  17259.46199287  .00018562  00000-0  20783-3 0  9990\r\n2 41776  51.6391 290.4765 0004585 289.0414  71.0083 15.62744945 57126\r\nFLOCK 2E'-19            \r\n1 41777U 98067KP  17259.15914849  .00031129  00000-0  30210-3 0  9996\r\n2 41777  51.6365 287.6394 0003455 295.9144  64.1496 15.66048367 57091\r\nFLOCK 2E'-20            \r\n1 41782U 98067KQ  17259.52525685  .00020402  00000-0  20762-3 0  9992\r\n2 41782  51.6376 287.1235 0003486 294.4833  65.5799 15.65119517 57008\r\nBANXING-2               \r\n1 41834U 16057H   17258.81249130  .00016251  00000-0  13492-3 0  9997\r\n2 41834  42.7820 163.4597 0007059 175.3284 251.9219 15.69886081 51345\r\nSTARS-C                 \r\n1 41895U 98067KR  17259.14493371  .00052131  00000-0  47582-3 0  9994\r\n2 41895  51.6363 293.5585 0004399 338.6484  21.4328 15.67326335 42222\r\nTANCREDO-1              \r\n1 41931U 98067KT  17259.09152068  .00213113  00000-0  97356-3 0  9997\r\n2 41931  51.6301 284.8534 0004539   2.9311 357.1718 15.82593573 37906\r\nITF-2                   \r\n1 41932U 98067KU  17259.47249932  .00027256  00000-0  31060-3 0  9998\r\n2 41932  51.6400 295.7996 0003670 265.3256  94.7319 15.62032672 37792\r\nWASEDA-SAT3             \r\n1 41933U 98067KV  17259.15088613  .00027914  00000-0  30592-3 0  9991\r\n2 41933  51.6381 296.6211 0003516 270.1141  89.9451 15.63026120 37758\r\nAOBA-VELOX 3            \r\n1 41935U 98067KX  17259.30940959  .00032111  00000-0  35586-3 0  9993\r\n2 41935  51.6395 296.2020 0003199 273.7883  86.2745 15.62663435 37872\r\nOSNSAT                  \r\n1 41939U 98067KZ  17259.12189876  .00067811  00000-0  54141-3 0  9993\r\n2 41939  51.6352 291.1399 0003401 301.8086  58.2580 15.70481073 37170\r\nLEMUR-2-REDFERN-GOES    \r\n1 42059U 98067LA  17259.46699910  .00028201  00000-0  33476-3 0  9997\r\n2 42059  51.6383 297.9859 0006671 290.4189  69.6088 15.60934475 30251\r\nLEMUR-2-TRUTNA          \r\n1 42067U 98067LC  17259.19357411  .00048382  00000-0  47099-3 0  9991\r\n2 42067  51.6377 296.9002 0005487 302.2625  57.7838 15.65749823 30070\r\nLEMUR-2-AUSTINTACIOUS   \r\n1 42068U 98067LD  17259.49151412  .00034259  00000-0  38658-3 0  9997\r\n2 42068  51.6386 297.3993 0006194 291.2578  68.7755 15.62150016 30195\r\nLEMUR-2-TRUTNAHD        \r\n1 42069U 98067LE  17259.51233356  .00025476  00000-0  29771-3 0  9996\r\n2 42069  51.6394 297.5521 0005883 291.6169  68.4198 15.61408730 30240\r\nISS DEB                 \r\n1 42434U 98067LF  17259.46956901  .00227412  00000-0  13365-2 0  9999\r\n2 42434  51.6309 291.9363 0004754   3.7821 356.3214 15.77018387 26488\r\nTIANZHOU 1              \r\n1 42684U 17021A   17258.52795139  .00003636  00000-0  50476-4 0  9993\r\n2 42684  42.7842 178.2941 0001650 185.6588 173.2777 15.58806357 57079\r\nISS DEB                 \r\n1 42697U 98067LG  17259.14043462  .00188209  00000-0  14041-2 0  9996\r\n2 42697  51.6331 298.7694 0006241 353.5693   6.5224 15.71605930 20885\r\nHAVELSAT                \r\n1 42700U 98067LH  17259.41627837  .00024834  00000-0  32482-3 0  9998\r\n2 42700  51.6395 301.3980 0006277 318.2733  41.7780 15.58453362 19152\r\nSOMP 2                  \r\n1 42701U 98067LJ  17259.49209313  .00020141  00000-0  26796-3 0  9990\r\n2 42701  51.6394 301.1584 0006165 318.6081  41.4443 15.58139697 19151\r\nCOLUMBIA                \r\n1 42702U 98067LK  17259.37623948  .00062670  00000-0  70270-3 0  9991\r\n2 42702  51.6386 300.3788 0006488 325.9005  34.1571 15.62040602 19080\r\nSGSAT                   \r\n1 42703U 98067LL  17259.22710250  .00048423  00000-0  57533-3 0  9996\r\n2 42703  51.6380 301.6300 0001868 318.1448  41.9402 15.60666337 19043\r\nCXBN-2                  \r\n1 42704U 98067LM  17259.17872088  .00025021  00000-0  33128-3 0  9992\r\n2 42704  51.6399 302.8134 0001296 295.2251  64.8607 15.58140052 19032\r\nICECUBE                 \r\n1 42705U 98067LN  17259.41677008  .00033973  00000-0  43289-3 0  9999\r\n2 42705  51.6406 301.4123 0001155 293.6815  66.4057 15.58991246 19134\r\nPHOENIX                 \r\n1 42706U 98067LP  17259.16649725  .00024047  00000-0  31692-3 0  9994\r\n2 42706  51.6395 302.7348 0001522 330.7490  29.3417 15.58286796 19028\r\nX-CUBESAT               \r\n1 42707U 98067LQ  17259.35878552  .00026496  00000-0  34754-3 0  9990\r\n2 42707  51.6386 301.7647 0001666 334.8956  25.1956 15.58355264 19042\r\nQBEE50-LTU-OC           \r\n1 42708U 98067LR  17259.49036095  .00024961  00000-0  32874-3 0  9990\r\n2 42708  51.6387 301.1440 0001674 333.9112  26.1796 15.58282225 19029\r\nALTAIR PATHFINDER       \r\n1 42711U 98067LS  17259.41972892  .00016506  00000-0  23066-3 0  9999\r\n2 42711  51.6397 302.1684 0003312 247.0824 112.9818 15.56983828 18710\r\nSHARC                   \r\n1 42712U 98067LT  17259.42037427  .00011592  00000-0  16514-3 0  9997\r\n2 42712  51.6403 302.1788 0001446 257.8173 102.2657 15.56813986 18952\r\nZA-AEROSAT              \r\n1 42713U 98067LU  17259.45357709  .00020564  00000-0  27898-3 0  9995\r\n2 42713  51.6396 301.6485 0001186 258.8452 101.2406 15.57615670 18721\r\nLINK                    \r\n1 42714U 98067LV  17259.36689045  .00033552  00000-0  43193-3 0  9994\r\n2 42714  51.6390 301.8149 0001237 294.9290  65.1574 15.58724945 18825\r\nCSUNSAT 1               \r\n1 42715U 98067LW  17259.39537897  .00024281  00000-0  32720-3 0  9998\r\n2 42715  51.6395 302.0062 0003097 238.5585 121.5105 15.57683701 18713\r\nUPSAT                   \r\n1 42716U 98067LX  17258.38995576  .00026403  00000-0  34208-3 0  9990\r\n2 42716  51.6397 306.5451 0004826 322.0418  38.0234 15.58676454 18692\r\nSPACECUBE               \r\n1 42717U 98067LY  17259.37222561  .00026264  00000-0  34736-3 0  9999\r\n2 42717  51.6395 301.8547 0004719 324.3730  35.6947 15.58131588 18089\r\nHOOPOE                  \r\n1 42718U 98067LZ  17259.49016339  .00026446  00000-0  34547-3 0  9999\r\n2 42718  51.6391 301.1443 0004740 325.2876  34.7807 15.58456701 18104\r\nCHALLENGER              \r\n1 42721U 98067MA  17259.48804548  .00033088  00000-0  41903-3 0  9993\r\n2 42721  51.6384 301.1228 0007010 301.8179  58.2131 15.59143886 17805\r\nNJUST-1                 \r\n1 42722U 98067MB  17259.47687756  .00020836  00000-0  28506-3 0  9994\r\n2 42722  51.6394 301.8008 0007004 297.0393  62.9883 15.57359143 17794\r\nUNSW-ECO                \r\n1 42723U 98067MC  17259.38948863  .00030009  00000-0  39459-3 0  9996\r\n2 42723  51.6398 301.9707 0006866 299.0031  61.0273 15.58197404 17763\r\nDUTHSAT                 \r\n1 42724U 98067MD  17259.49815121  .00035472  00000-0  45198-3 0  9995\r\n2 42724  51.6397 301.1938 0006266 306.8742  53.1676 15.58951915 17709\r\nLILACSAT-1              \r\n1 42725U 98067ME  17259.34875902  .00025468  00000-0  34446-3 0  9991\r\n2 42725  51.6395 302.4481 0006103 302.5571  57.4831 15.57542575 17671\r\nNSIGHT-1                \r\n1 42726U 98067MF  17259.38096860  .00012948  00000-0  18639-3 0  9999\r\n2 42726  51.6404 302.6638 0006133 300.1057  59.9327 15.56397128 17684\r\nSNUSAT-1                \r\n1 42727U 98067MG  17259.47493448  .00024118  00000-0  32586-3 0  9992\r\n2 42727  51.6385 301.7829 0006559 259.2313 100.7941 15.57600256 17661\r\nQBITO                   \r\n1 42728U 98067MH  17259.33138590  .00027723  00000-0  36880-3 0  9998\r\n2 42728  51.6405 302.3362 0003784 319.1870  40.8838 15.57947731 17486\r\nAALTO-2                 \r\n1 42729U 98067MJ  17259.39536704  .00027499  00000-0  36592-3 0  9994\r\n2 42729  51.6397 302.0098 0003786 319.7157  40.3554 15.57945079 17502\r\nSUSAT                   \r\n1 42730U 98067MK  17259.33635476  .00025528  00000-0  34234-3 0  9998\r\n2 42730  51.6395 302.3641 0003771 316.6379  43.4316 15.57780521 17481\r\nI-INSPIRE II            \r\n1 42731U 98067ML  17259.38508736  .00031598  00000-0  41217-3 0  9995\r\n2 42731  51.6384 301.9313 0005548 245.5702 114.4712 15.58392180 17542\r\nPOLYITAN-2-SAU          \r\n1 42732U 98067MM  17259.13567635  .00024089  00000-0  32051-3 0  9995\r\n2 42732  51.6389 303.2648 0005856 242.1051 117.9348 15.58017456 17505\r\nSNUSAT-1B               \r\n1 42733U 98067MN  17259.40089780  .00025531  00000-0  34167-3 0  9999\r\n2 42733  51.6389 302.0380 0005756 245.1571 114.8823 15.57827052 17543\r\nEXALTA-1                \r\n1 42734U 98067MP  17259.51389149  .00025744  00000-0  33799-3 0  9990\r\n2 42734  51.6386 301.2940 0007665 272.2930  87.7185 15.58320609 17518\r\nAOXIANG-1               \r\n1 42735U 98067MQ  17259.47394435  .00021264  00000-0  28992-3 0  9992\r\n2 42735  51.6392 301.7801 0007560 293.0405  66.9789 15.57433101 18925\r\nBEEAGLESAT              \r\n1 42736U 98067MR  17259.53505380  .00021332  00000-0  28905-3 0  9993\r\n2 42736  51.6391 301.4396 0007464 293.5191  66.5016 15.57598427 17629\r\nATLANTIS                \r\n1 42737U 98067MS  17258.54712554  .00051386  00000-0  60636-3 0  9996\r\n2 42737  51.6377 305.3338 0007188 298.6894  61.3377 15.60793860 17379\r\nPROGRESS-MS 06          \r\n1 42756U 17033A   17258.52642144  .00002378  00000-0  43064-4 0  9990\r\n2 42756  51.6436 307.9738 0003676 275.6412 188.8006 15.54195380 14497\r\nISS DEB (ROSA)          \r\n1 42813U 98067MT  17258.59735590  .00053313  00000-0  66394-3 0  9990\r\n2 42813  51.6389 306.4234 0003623 299.4705  60.5926 15.59385582 12769\r\nSOYUZ-MS 05             \r\n1 42898U 17043A   17258.52642144  .00002378  00000-0  43064-4 0  9998\r\n2 42898  51.6436 307.9738 0003676 275.6412 188.8006 15.54195380  7609\r\nDRAGON CRS-12           \r\n1 42904U 17045A   17258.52642144  .00002378  00000-0  43064-4 0  9998\r\n2 42904  51.6436 307.9738 0003676 275.6412 188.8006 15.54195380  4952\r\nSOYUZ-MS 06             \r\n1 42937U 17054A   17258.52642144  .00002378  00000-0  43064-4 0  9994\r\n2 42937  51.6436 307.9738 0003676 275.6412 188.8006 15.54195380 75800")
                   //.Take(10)
                   .Select(s => this.InstantiateSatalite(s))
                   .ToList();

        this.DrawnSatalites.AddRange(sats);

        this.Calculator = new CoordinateCalculator(51.9839248, 5.9107478, 20, DateTime.UtcNow.AddDays(0.6));
    }
Exemplo n.º 6
0
        public void DrawLocation(Graphics g, CoordinateCalculator cCalc)
        {
            Sgp4Data position    = SatFunctions.getSatPositionAtTime(Tle, new EpochTime(TimeKeeper.Now()), Sgp4.wgsConstant.WGS_84);
            var      point       = SatFunctions.calcSatSubPoint(new EpochTime(TimeKeeper.Now()), position, Sgp4.wgsConstant.WGS_84);
            var      mappedPoint = cCalc.MapPoint(new PointF((float)point.getLongitude(), (float)point.getLatitude()));

            mappedPoint = new PointF((float)Math.Round(mappedPoint.X), (float)Math.Round(mappedPoint.Y));

            g.DrawImage(Properties.Resources.satellite, mappedPoint.X - 25, mappedPoint.Y - 25, 50, 50);
            var font = new Font("Times New Roman", 18, FontStyle.Bold, GraphicsUnit.Pixel);

            g.DrawString(Name, font, new SolidBrush(Color.OrangeRed), mappedPoint.X, mappedPoint.Y + 15);
        }
Exemplo n.º 7
0
        private void DrawGrid(CoordinateCalculator corCalc, Graphics g)
        {
            var fontSize = (float)Math.Round(0.013888888888889 * _panel.Width + 5);
            var font     = new Font("Times New Roman", fontSize, FontStyle.Bold, GraphicsUnit.Pixel);

            for (var i = 60; i >= -60; i -= 30)
            {
                var start = corCalc.MapPoint(new PointF(-180, i));
                var end   = corCalc.MapPoint(new PointF(180, i));

                g.DrawString($"{i}°", font, new SolidBrush(Color.White), start);
                g.DrawLine(new Pen(Color.LightGray, 1), start, end);
            }

            for (var i = -180; i <= 180; i += 30)
            {
                var start = corCalc.MapPoint(new PointF(i, 90));
                var end   = corCalc.MapPoint(new PointF(i, -90));

                g.DrawString($"{i}°", font, new SolidBrush(Color.White), new PointF(start.X, start.Y + 20));
                g.DrawLine(new Pen(Color.LightGray, 1), start, end);
            }
        }
Exemplo n.º 8
0
        private void Redraw(object sender, EventArgs e)
        {
            var graphics = _graphicsBuffer.Graphics;

            graphics.Clear(Color.White);
            graphics.DrawImage(Properties.Resources.world, 0, 0, _panel.Width + 1, _panel.Height + 1);
            var corCalc = new CoordinateCalculator(_panel.Size);

            DrawGrid(corCalc, graphics);
            DrawPosition(corCalc, graphics);

            if (_satellites.MainSatellite != null)
            {
                _satellites.MainSatellite.DrawLine(graphics, corCalc);
            }

            foreach (var satellite in _satellites.SelectedSatellites)
            {
                satellite.DrawLocation(graphics, corCalc);
            }

            _graphicsBuffer.Render(_panelGraphics);
        }
Exemplo n.º 9
0
        private void DrawLineSet(EpochTime startTime, List <One_Sgp4.Sgp4Data> data, Color c, CoordinateCalculator cCalc, Graphics g)
        {
            foreach (var point in data)
            {
                startTime.addMinutes(0.01);
                var position        = SatFunctions.calcSatSubPoint(startTime, point, Sgp4.wgsConstant.WGS_84);
                var pointOverGround = cCalc.MapPoint(new PointF((float)position.getLongitude(), (float)position.getLatitude()));


                g.FillRectangle(new SolidBrush(c), new RectangleF(pointOverGround, new Size(1, 1)));
            }
        }
 // Use this for initialization
 void Start()
 {
     this.Calculator = GameObject.Find("Main Camera").GetComponent <GameManager>().Calculator;
 }
Exemplo n.º 11
0
 public void DrawLine(Graphics g, CoordinateCalculator cCalc)
 {
     DrawLineSet(new EpochTime(TimeKeeper.Now().AddMinutes(-30)), CalculatePositionList(-30, 0), Color.Red, cCalc, g);
     DrawLineSet(new EpochTime(TimeKeeper.Now()), CalculatePositionList(0, 90), Color.Yellow, cCalc, g);
 }
Exemplo n.º 12
0
 public void testScaleCalculation()
 {
     Assert.AreEqual <double>(2.5, CoordinateCalculator.getScale(new Point(0, 0), new Point(3, 4), 2),
                              "The scale of 5/2 is correctely calculated");
 }
Exemplo n.º 13
0
        static void Main(string[] args)
        {
            Grid     Playfield = new Grid();
            AIModule enemyAI   = new AIModule();

            logger = new Logger();

            string coordinate;
            int    aiX, aiY;

            Console.WriteLine("-----");
            Console.WriteLine("Greetings, commander! Welcome to the next iteration of Battleship board game implementation.");
            Console.WriteLine("Write a letter and a digit to shoot to a field! For example: A5");

            while (!isOver)
            {
                while (!isOver)
                {
                    coordinate = Console.ReadLine();

                    try
                    {
                        if (Playfield.EnemyMap[CoordinateCalculator.GetX(coordinate), CoordinateCalculator.GetY(coordinate)].State == State.basic)
                        {
                            if (Playfield.EnemyMap[CoordinateCalculator.GetX(coordinate), CoordinateCalculator.GetY(coordinate)].Shoot())
                            {
                                logger.AppendLog("You hit the enemy ship!");
                            }
                            else
                            {
                                logger.AppendLog("Miss...");
                            }
                            logger.DumpLog();
                            break;
                        }
                        Console.WriteLine("You already shot there! Try again.");
                    }
                    catch (IndexOutOfRangeException)
                    {
                        Console.WriteLine("You shot outside of the map area. The sea is not quite impressed.");
                        break;
                    }
                }

                while (!isOver)
                {
                    aiX = enemyAI.Aim();
                    aiY = enemyAI.Aim();
                    if (Playfield.PlayerMap[aiX, aiY].State == State.basic)
                    {
                        if (Playfield.PlayerMap[aiX, aiY].Shoot())
                        {
                            logger.AppendLog("Enemy hit one of your ships!");
                        }
                        else
                        {
                            logger.AppendLog("Enemy missed the shot.");
                        }
                        logger.DumpLog();
                        break;
                    }
                }

                Console.ReadKey();
                if (!isOver)
                {
                    Playfield.DrawGrid();
                }
            }
        }
Exemplo n.º 14
0
 public void testDistanceCalculation()
 {
     Assert.AreEqual <double>(5, CoordinateCalculator.euclideanDistance(new Point(1, 2), new Point(4, 6)),
                              "the distance of 5 between points (1,2), and (4,6) is calculated correctely");
 }
 // Use this for initialization
 void Start()
 {
     this.Calculator           = GameObject.Find("Main Camera").GetComponent <GameManager>().Calculator;
     this.LineRenderer         = this.gameObject.GetComponent <LineRenderer>();
     this.LineRenderer.enabled = false;
 }
 // Use this for initialization
 void Start()
 {
     this.mainCalculator = GameObject.Find("Main Camera").GetComponent <GameManager> ().Calculator;
     this.txtDate        = this.gameObject.GetComponent <Text> ();
 }
Exemplo n.º 17
0
    public void Drawing()
    {
        //Default colors
        color black = new color(0, 0, 0, ColorHandler.colorMaxValue);

        color white = new color(ColorHandler.colorMaxValue, ColorHandler.colorMaxValue, ColorHandler.colorMaxValue, ColorHandler.colorMaxValue);

        //Initialization of graphics and opening painting window
        Sdl.SDL_Event ev = new Sdl.SDL_Event();

        Sdl.SDL_Init(Sdl.SDL_INIT_VIDEO);
        System.IntPtr screen = Sdl.SDL_SetVideoMode(0, 0, 0, Sdl.SDL_ANYFORMAT);
        if (screen == IntPtr.Zero)
        {
            System.Console.WriteLine("Nem sikerult megnyitni az ablakot!\n");
            return;
        }
        Sdl.SDL_WM_SetCaption("SDL peldaprogram", "SDL peldaprogram");

        //Sets NeightbourHandler
        NeightbourhoodFactory nfactory = new NeightbourhoodFactory();
        NeightbourHandler     nh       = nfactory.produce(mesh, neighbourhood);
        //Sets MatrixHandler and ColorHandler
        MatrixHandler game = new QuadraticMatrixHandler(random, nh, ageT);
        ColorHandler  ch   = new ColorHandler(random);

        //Gets sizes of screen
        int width  = Screen.PrimaryScreen.Bounds.Width;
        int height = Screen.PrimaryScreen.Bounds.Height;

        //Calculates main datas
        int       cellSize     = 10;
        const int half         = ColorHandler.colorMaxValue / 2;
        const int state_number = 2;
        int       n            = width / cellSize;
        int       m            = height / cellSize;
        int       del          = 0;
        int       delt         = max(n, m) * 2;

        //Sets CoordinateCalculator
        CoordinateCalculatorFactory factory = new CoordinateCalculatorFactory();
        CoordinateCalculator        cc      = factory.produce(mesh);

        //Sets sizes of the matrix to fill the full monitor
        if (mesh == MeshType.PENTAGON10)
        {
            n = n * 2;
            m = m * 2;
        }
        else if (mesh == MeshType.PENTAGON11)
        {
            m = m * 2;
        }
        else if (mesh == MeshType.PENTAGON12)
        {
            m = m * 2;
        }
        else if (mesh == MeshType.RECTANGLE_SQUARE)
        {
            m = m * 2;
        }
        else if (mesh == MeshType.SQUARE_TRIANGLE1)
        {
            m = m * 2;
        }
        else if (mesh == MeshType.SQUARE_TRIANGLE2)
        {
            m = m * 4;
        }
        else if (mesh == MeshType.HEXAGON_TRIANGLE1)
        {
            m = m * 3;
        }
        else if (mesh == MeshType.DODECAGON_TRIANGLE)
        {
            m = m * 3;
        }
        else if (mesh == MeshType.HEXAGON_TRIANGLE2)
        {
            m = m * 5;
        }
        else if (mesh == MeshType.HEXAGON_SQUARE_TRIANGLE)
        {
            m = m * 2;
        }
        else if (mesh == MeshType.DODECAGON_HEXAGON_SQUARE)
        {
            m = m * 2;
        }

        //Generates random matrix as default
        double probability = 0.3;
        ModuloIndexableList <ModuloIndexableList <int> > cell_matrix =
            game.generate_random_matrix(n, m, probability);

        if (matrix == MatrixType.ONE_POINT)
        {
            cell_matrix = game.generate_matrix(n, m);
        }

        //Adds state rules in order of states
        List <List <int> > rule = new List <List <int> >();

        rule.Add(borns);
        rule.Add(survives);

        //Generating and setting colors
        List <color> colors = ch.generate_colors_();
        int          index1 = random.Next(0, colors.Count);
        color        c1     = colors[index1];
        Dictionary <color, List <color> > color_matrix = ch.generate_colors();
        List <color> cls    = color_matrix[c1];
        int          index2 = random.Next(0, cls.Count);
        color        col    = cls[index2];
        color        col1   = white;
        color        col2   = black;

        int wt = random.Next(0, 6);

        if (wt == 0)
        {
            col1 = c1;
            col2 = ch.generate_dark(col);
        }
        else if (wt == 1)
        {
            col1 = ch.generate_light(col);
            col2 = c1;
        }
        else if (wt == 2)
        {
            col1 = col;
            col2 = c1;
        }
        else if (wt == 3)
        {
            col1 = c1;
            col2 = col;
        }
        else if (wt == 4)
        {
            col1 = c1;
            col2 = ch.generate_light(col);
        }
        if (wt == 5)
        {
            col1 = ch.generate_dark(col);
            col2 = c1;
        }
        Sdl.SDL_WaitEvent(out ev);
        //Drawing loop
        while (ev.type != Sdl.SDL_QUIT && ev.type != Sdl.SDL_KEYDOWN)
        {
            if (ev.type == Sdl.SDL_KEYDOWN)
            {
                System.Console.WriteLine("Billentyű észlelve.");
                Sdl.SDL_Quit();
            }
            else if (ev.type == Sdl.SDL_MOUSEBUTTONDOWN)
            {
                System.Console.WriteLine("Egér észlelve.");
                Sdl.SDL_Quit();
            }

            for (int i = 0; i < n; i++)
            {
                for (int j = 0; j < m; j++)
                {
                    if (mesh == MeshType.SQUARE)
                    {
                        short x1 = (short)(i * cellSize + 1);
                        short y1 = (short)(j * cellSize + 1);
                        short x2 = (short)((i + 1) * cellSize);
                        short y2 = (short)((j + 1) * cellSize);

                        // drawing quadratic mesh with age
                        if (ageT)
                        {
                            List <color> cols = ch.generate_age_colors();
                            if (cell_matrix[i][j] == 0)
                            {
                                Tao.Sdl.SdlGfx.boxRGBA(screen, x1, y1, x2, y2,
                                                       (byte)(black.red), (byte)(black.green), (byte)(black.blue), (byte)(black.alpha));
                            }
                            else
                            {
                                int ix = cell_matrix[i][j] % cols.Count;
                                if (ix < 0)
                                {
                                    ix = ix + cols.Count;
                                }
                                Tao.Sdl.SdlGfx.boxRGBA(screen, x1, y1, x2, y2,
                                                       (byte)((cols[ix]).red), (byte)((cols[ix]).green), (byte)((cols[ix]).blue), (byte)(cols[ix].alpha));
                            }
                        }
                        else
                        {
                            // drawing quadratic mesh without age
                            if (cell_matrix[i][j] == 1)
                            {
                                Tao.Sdl.SdlGfx.boxRGBA(screen, x1, y1, x2, y2,
                                                       (byte)(col2.red), (byte)(col2.green), (byte)(col2.blue), (byte)(col2.alpha));
                            }
                            else if (cell_matrix[i][j] == 0)
                            {
                                Tao.Sdl.SdlGfx.boxRGBA(screen, x1, y1, x2, y2,
                                                       (byte)(col1.red), (byte)(col1.green), (byte)(col1.blue), (byte)(col1.alpha));
                            }
                        }
                    }
                    else
                    {
                        // drawing another mesh
                        List <Tuple <double, double> > points = cc.calculate_polygon_coordinates(i, j);
                        short[] vx = new short[points.Count];
                        short[] vy = new short[points.Count];
                        for (int k = 0; k < points.Count; k++)
                        {
                            double xx = points[k].Item1;
                            double yy = points[k].Item2;
                            xx = xx * cellSize;
                            yy = yy * cellSize;
                            if (mesh == MeshType.TRIANGLE)
                            {
                                //to have better rates of sides and hights
                                xx = xx * Math.Sqrt(3);
                                //to set the middle into the middle
                                xx = xx - width / 14;
                                yy = yy - height / 21;
                            }
                            else if (mesh == MeshType.HEXAGON)
                            {
                                xx = xx * 2;
                                //to set the middle into the middle
                                xx = xx - 2 * width / 9;
                                yy = yy - height / 35;
                            }
                            else if (mesh == MeshType.PENTAGON1)
                            {
                                //to set the middle into the middle
                                yy = yy - height / 3;
                            }
                            else if (mesh == MeshType.PENTAGON3)
                            {
                                //to set the middle into the middle
                                xx = xx - width / 2;
                                yy = yy - height;
                            }
                            else if (mesh == MeshType.PENTAGON11)
                            {
                                //to set the middle into the middle
                                xx = xx - 1.75 * width;
                            }
                            else if (mesh == MeshType.PENTAGON14)
                            {
                                xx = xx * 2;
                                //to set the middle into the middle
                                xx = xx - 2 * width / 9 - width / 4;
                                yy = yy - height / 35;
                                yy = 2 * yy + height / 8;
                            }
                            else if (mesh == MeshType.RECTANGLE1)
                            {
                                //to set the middle into the middle
                                //rotating by 45 degrees
                                double zz = Math.Sqrt(2) / 2 * xx + Math.Sqrt(3) / 2 * yy;
                                xx = -Math.Sqrt(3) / 2 * xx + Math.Sqrt(2) / 2 * yy + (3 / 2) * width + 2 * width / 5;
                                yy = zz - height / 2 - height / 4;
                                xx = xx + width / 12;
                            }
                            else if (mesh == MeshType.RECTANGLE2)
                            {
                                //to set the middle into the middle
                                xx = xx - width / 2;
                            }
                            else if ((mesh == MeshType.TILED_RECTANGLE1) || (mesh == MeshType.RECTANGLE_SQUARE))
                            {
                                //to set the middle into the middle
                                //rotating by 45 degrees
                                double zz = Math.Sqrt(2) / 2 * xx + Math.Sqrt(3) / 2 * yy;
                                xx = -Math.Sqrt(3) / 2 * xx + Math.Sqrt(2) / 2 * yy + (3 / 2) * width + 2 * width / 5;
                                yy = zz - height / 2 - height / 4;
                                if (mesh == MeshType.TILED_RECTANGLE1)
                                {
                                    xx = xx + width / 8;
                                }
                                else
                                {
                                    xx = xx - width / 8;
                                    yy = yy - height / 12;
                                }
                            }
                            else if ((mesh == MeshType.SQUARE_TRIANGLE1) || (mesh == MeshType.SQUARE_TRIANGLE2))
                            {
                                //to set the middle into the middle
                                yy = yy - height / 8;
                            }

                            else if ((mesh == MeshType.HEXAGON_SQUARE_TRIANGLE) || (mesh == MeshType.DODECAGON_HEXAGON_SQUARE))
                            {
                                xx = xx * 2;
                                yy = yy * 2;
                                //to set the middle into the middle
                                xx = xx - width / 2;
                                yy = yy - height / 12;
                            }
                            else if (mesh == MeshType.HEXAGON_TRIANGLE2)
                            {
                                //to set the middle into the middle
                                xx = xx - 2 * width / 3;
                                yy = yy - 3 * height;
                            }
                            int   xt = (int)xx;
                            int   yt = (int)yy;
                            short xs = (short)xt;
                            short ys = (short)yt;
                            vx[k] = xs;
                            vy[k] = ys;
                            if ((mesh == MeshType.TRIANGLE) || (mesh == MeshType.HEXAGON))
                            {
                                vx[k] = ys;
                                vy[k] = xs;
                            }
                        }
                        if (ageT)
                        {
                            // drawing mesh with age
                            List <color> cols = ch.generate_age_colors();
                            if (cell_matrix[i][j] == 0)
                            {
                                Tao.Sdl.SdlGfx.filledPolygonRGBA(screen, vx, vy, points.Count,
                                                                 (byte)(black.red), (byte)(black.green), (byte)(black.blue), (byte)(black.alpha));
                            }
                            else
                            {
                                int ix = cell_matrix[i][j] % cols.Count;
                                if (ix < 0)
                                {
                                    ix = ix + cols.Count;
                                }
                                Tao.Sdl.SdlGfx.filledPolygonRGBA(screen, vx, vy, points.Count,
                                                                 (byte)((cols[ix]).red), (byte)((cols[ix]).green), (byte)((cols[ix]).blue), (byte)(cols[ix].alpha));
                            }
                        }
                        else
                        {
                            // drawing mesh without age
                            if (cell_matrix[i][j] == 1)
                            {
                                Tao.Sdl.SdlGfx.filledPolygonRGBA(screen, vx, vy, points.Count,
                                                                 (byte)(col2.red), (byte)(col2.green), (byte)(col2.blue), (byte)(col2.alpha));
                            }
                            else if (cell_matrix[i][j] == 0)
                            {
                                Tao.Sdl.SdlGfx.filledPolygonRGBA(screen, vx, vy, points.Count,
                                                                 (byte)(col1.red), (byte)(col1.green), (byte)(col1.blue), (byte)(col1.alpha));
                            }
                        }
                    }
                }
            }

            if (del == delt)
            {
                //Generates new beginning matrix with new colors
                if (matrix == MatrixType.RANDOM)
                {
                    cell_matrix = game.generate_random_matrix(n, m, probability);
                }
                else if (matrix == MatrixType.ONE_POINT)
                {
                    cell_matrix = game.generate_matrix(n, m);
                    del         = 0;
                }
                wt = random.Next(0, 6);
                if (wt == 0)
                {
                    col1 = c1;
                    col2 = ch.generate_dark(col);
                }
                else if (wt == 1)
                {
                    col1 = ch.generate_light(col);
                    col2 = c1;
                }
                else if (wt == 2)
                {
                    col1 = col;
                    col2 = c1;
                }
                else if (wt == 3)
                {
                    col1 = c1;
                    col2 = col;
                }
                else if (wt == 4)
                {
                    col1 = c1;
                    col2 = ch.generate_light(col);
                }
                if (wt == 5)
                {
                    col1 = ch.generate_dark(col);
                    col2 = c1;
                }
            }
            else
            {
                cell_matrix = game.new_matrix(cell_matrix, rule);
            }

            /* Flips drawings */
            Sdl.SDL_Flip(screen);
            Sdl.SDL_WaitEvent(out ev);
            System.Threading.Thread.Sleep(1000);

            del = del + 1;
        }

        /* closing window */
        Sdl.SDL_Quit();
        return;
    }
Exemplo n.º 18
0
    public Settings(MeshType mesh)
    {
        this.mesh = mesh;
        Console.WriteLine(mesh);
        Text  = "Beállítások";
        sizeX = 660;
        sizeY = 340;
        Size  = new Size(sizeX, sizeY);

        //Cancelling button
        cancel           = new CheckBox();
        cancel.Text      = "Mégsem";
        cancel.Parent    = this;
        cancel.Location  = new Point(100, 215);
        cancel.BackColor = Color.Coral;
        cancel.Show();
        cancel.Visible = true;
        Controls.Add(cancel);

        //Okey button
        ok           = new CheckBox();
        ok.Text      = "OK";
        ok.Parent    = this;
        ok.Location  = new Point(400, 215);
        ok.BackColor = Color.Coral;
        ok.Show();
        ok.Visible = true;
        Controls.Add(ok);

        //Labels of panels
        Label matrixLabel = new Label();

        matrixLabel.Parent    = this;
        matrixLabel.Text      = "Kezdőmátrix";
        matrixLabel.Location  = new Point(30, 30);
        matrixLabel.BackColor = Color.Coral;

        Label neighbourhoodLabel = new Label();

        neighbourhoodLabel.Parent    = this;
        neighbourhoodLabel.Text      = "Szomszédság";
        neighbourhoodLabel.Location  = new Point(240, 30);
        neighbourhoodLabel.BackColor = Color.Coral;

        //Starting matrix is empty, expect of the middle point
        pointRb          = new RadioButton();
        pointRb.Parent   = this;
        pointRb.Location = new Point(30, 30);
        pointRb.Text     = "Egy pont";
        pointRb.Checked  = false;

        //Strationg matrix is filled by random
        randomRb          = new RadioButton();
        randomRb.Parent   = this;
        randomRb.Location = new Point(30, 60);
        randomRb.Text     = "Véletlen";
        randomRb.Checked  = false;

        matrixPanel           = new Panel();
        matrixPanel.Parent    = this;
        matrixPanel.Location  = new Point(30, 30);
        matrixPanel.Text      = "";
        matrixPanel.BackColor = Color.Coral;
        matrixPanel.Controls.Add(pointRb);
        matrixPanel.Controls.Add(randomRb);
        matrixPanel.AutoSize = true;

        CoordinateCalculatorFactory factory = new CoordinateCalculatorFactory();
        CoordinateCalculator        cc      = factory.produce(mesh);

        //Neighbours are cells joining by side
        if (cc.hasUlam())
        {
            ulamRb          = new RadioButton();
            ulamRb.Parent   = this;
            ulamRb.Location = new Point(150, 30);
            ulamRb.Text     = "Ulam";
            ulamRb.Checked  = false;
        }
        //Neighbours are cells joining by side or by diagonally
        if (cc.hasConway())
        {
            conwayRb          = new RadioButton();
            conwayRb.Parent   = this;
            conwayRb.Location = new Point(150, 60);
            conwayRb.Text     = "Conway";
            conwayRb.Checked  = false;
        }
        //Neighbours are cells at knight move
        if (cc.hasKnight())
        {
            knightRb          = new RadioButton();
            knightRb.Parent   = this;
            knightRb.Location = new Point(150, 90);
            knightRb.Text     = "Lóugrás";
            knightRb.Checked  = false;
        }
        //Neighbours are cells joining by side or by diagonally
        if (cc.hasGreatConway())
        {
            greatConwayRb          = new RadioButton();
            greatConwayRb.Parent   = this;
            greatConwayRb.Location = new Point(150, 120);
            greatConwayRb.Text     = "Nagy Conway";
            greatConwayRb.Checked  = false;
        }
        //Neighbours are cells that would join by side or by diagonally
        //if the cells would be pentagons
        if (cc.hasOblique())
        {
            obliqueRb          = new RadioButton();
            obliqueRb.Parent   = this;
            obliqueRb.Location = new Point(150, 150);
            obliqueRb.Text     = "Ferde";
            obliqueRb.Checked  = false;
        }
        neighbourhoodPanel           = new Panel();
        neighbourhoodPanel.Parent    = this;
        neighbourhoodPanel.Location  = new Point(150, 30);
        neighbourhoodPanel.Text      = "";
        neighbourhoodPanel.BackColor = Color.Coral;

        neighbourhoodPanel.Controls.Add(ulamRb);
        neighbourhoodPanel.Controls.Add(conwayRb);
        neighbourhoodPanel.Controls.Add(knightRb);
        neighbourhoodPanel.Controls.Add(greatConwayRb);
        neighbourhoodPanel.Controls.Add(obliqueRb);

        neighbourhoodPanel.AutoSize = true;



        //The eventhandler of the buttons is the function OnChanged(object sender, EventArgs e)
        cancel.CheckedChanged += new EventHandler(OnChanged);
        ok.CheckedChanged     += new EventHandler(OnChanged);
        Paint += new PaintEventHandler(OnPaint);
        CenterToScreen();
    }