28. BWINF, Runde 1, Aufgabe 3: Wegfehler - Matthias Springer .DE
28. BWINF, Runde 1, Aufgabe 3: Wegfehler - Matthias Springer .DE
28. BWINF, Runde 1, Aufgabe 3: Wegfehler - Matthias Springer .DE
Erfolgreiche ePaper selbst erstellen
Machen Sie aus Ihren PDF Publikationen ein blätterbares Flipbook mit unserer einzigartigen Google optimierten e-Paper Software.
<strong>Aufgabe</strong> 3<br />
Stefan Hansch, Markus Wirsing, <strong>Matthias</strong> <strong>Springer</strong><br />
vector_direction[1] * vector_direction[1]);<br />
425 vector_direction[0] /= vector_length;<br />
426 vector_direction[1] /= vector_length;<br />
427<br />
428 // Zeichne die Strecke<br />
429 for (int i = 0; i < (int)ceil(vector_length) + 1; i++)<br />
430 {<br />
431 setPixel(x1 + (int)(vector_direction[0] * (double)i), y1 + (int)(<br />
vector_direction[1]* (double)i), r, g, b);<br />
432 }<br />
433 }<br />
434<br />
435 /// *************************************************<br />
436 /// * Setzt einen Pixel auf eine Farbe. *<br />
437 /// *************************************************<br />
438 void setPixel(int x, int y, int r, int g, int b)<br />
439 {<br />
440 // Ueberpruefe, ob der Pixel gueltig ist, d.h. in der Matrix liegt<br />
441<br />
442 if ((x > -1) && (x < proportions[0]) && (y > -1) && (y < proportions[1]))<br />
443 {<br />
444 matrix[x][y][0] = r;<br />
445 matrix[x][y][1] = g;<br />
446 matrix[x][y][2] = b;<br />
447 }<br />
448 }<br />
449<br />
450 /// *************************************************<br />
451 /// * Gibt zu einer x-Koordinate den Pixelwert aus. *<br />
452 /// *************************************************<br />
453 int convertCoordinateToPixelEast(double value)<br />
454 {<br />
455 double coord_difference = value - coord_left;<br />
456 double pixel_per_coordinate_quotient = (double)proportions[0] / (<br />
coord_right - coord_left);<br />
457<br />
458 return (int)(coord_difference * pixel_per_coordinate_quotient);<br />
459 }<br />
460<br />
461 /// *************************************************<br />
462 /// * Gibt zu einer y-Koordinate den Pixelwert aus. *<br />
463 /// *************************************************<br />
464 int convertCoordinateToPixelNorth(double value)<br />
465 {<br />
466 double coord_difference = value - coord_bottom;<br />
467 double pixel_per_coordinate_quotient = (double)proportions[1] / (<br />
coord_top - coord_bottom);<br />
468<br />
469 return proportions[1] - (int)(coord_difference *<br />
pixel_per_coordinate_quotient);<br />
470 }<br />
471<br />
472 /// *************************************************<br />
473 /// * Macht einen Eintrag in der Datenbank frei. *<br />
474 /// *************************************************<br />
475 // edit: nicht benoetigt!<br />
476 void insertDatabaseEntry(int index)<br />
477 {<br />
478 for (int i = db_count_entries; i > index; i--)<br />
479 {<br />
480 db_time[i] = db_time[i - 1];<br />
481 db_pos_x[i] = db_pos_x[i - 1];<br />
482 db_pos_y[i] = db_pos_y[i - 1];<br />
483 }<br />
484<br />
485 db_count_entries++;<br />
486 }<br />
487<br />
488 /// *************************************************<br />
489 /// * Berechnet die durschnittliche Geschwindigkeit.*<br />
490 /// *************************************************<br />
491 void db_calculateAverageDistance()<br />
492 {<br />
493 db_average_distance_per_time = 0.0;<br />
24