optimization of the detection algorithem.
BOOK update.
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
import 'dart:math';
|
||||
import 'dart:ui';
|
||||
|
||||
/// The one scoring rule for a shot on the default target (assets/target.png,
|
||||
/// 1200x1200). Saving, the preview and the target view all use it, so a shot
|
||||
/// scores the same everywhere.
|
||||
///
|
||||
/// A shot counts for the best ring its edge touches: the distance from the
|
||||
/// centre to the bullet's centre, minus the bullet's radius, is compared with
|
||||
/// the outer edge of each ring.
|
||||
class TargetScoring {
|
||||
TargetScoring._();
|
||||
|
||||
static const Offset center = Offset(601, 598);
|
||||
static const double bulletRadius = 25;
|
||||
|
||||
/// Outer edge of ring 10, 9, ... 1, measured from [center].
|
||||
static const List<double> rings = [
|
||||
14, 70, 125, 180, 235, 290, 345, 400, 455, 510,
|
||||
];
|
||||
|
||||
/// Score of a shot whose centre is at [bullet] (default target coordinates).
|
||||
static int scoreAt(Offset bullet) {
|
||||
final edge = (bullet - center).distance - bulletRadius;
|
||||
for (int i = 0; i < rings.length; i++) {
|
||||
if (edge <= rings[i]) return 10 - i;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/// Where to draw a shot that was scored by hand, in direction [angle]
|
||||
/// (radians): the middle of the band of positions [scoreAt] gives [score]
|
||||
/// for, so the dot always scores what was entered.
|
||||
static Offset positionFor(int score, double angle) {
|
||||
final s = score.clamp(0, 10);
|
||||
// Distance of the bullet's edge from the centre, middle of the band
|
||||
final double edge;
|
||||
if (s == 10) {
|
||||
edge = (-bulletRadius + rings[0]) / 2; // bullet over the centre
|
||||
} else if (s == 0) {
|
||||
edge = rings.last + 30; // just outside the target
|
||||
} else {
|
||||
edge = (rings[9 - s] + rings[10 - s]) / 2;
|
||||
}
|
||||
final distance = edge + bulletRadius;
|
||||
return center + Offset(cos(angle), sin(angle)) * distance;
|
||||
}
|
||||
}
|
||||
+20
-10
@@ -1029,6 +1029,26 @@ class AppTranslations {
|
||||
'Slovenian': 'Tukaj se bodo prikazale shranjene tarče in tvoja statistika',
|
||||
'German': 'Hier erscheinen gespeicherte Scheiben und deine Statistik',
|
||||
},
|
||||
'Statistics / History: your form and progress graph, or the list of all your sessions.': {
|
||||
'English': 'Statistics / History: your form and progress graph, or the list of all your sessions.',
|
||||
'Slovenian': 'Statistika / Zgodovina: tvoja forma in graf napredka ali seznam vseh tvojih sej.',
|
||||
'German': 'Statistik / Verlauf: deine Form und der Fortschrittsgraf oder die Liste aller Einheiten.',
|
||||
},
|
||||
'History: All / Trainings / Tournaments chooses which sessions are listed, with any number of shots.': {
|
||||
'English': 'History: All / Trainings / Tournaments chooses which sessions are listed, with any number of shots.',
|
||||
'Slovenian': 'Zgodovina: Vse / Treningi / Tekmovanja izbere, katere seje so na seznamu, ne glede na število strelov.',
|
||||
'German': 'Verlauf: Alle / Trainings / Wettkämpfe wählt, welche Einheiten gelistet werden, mit beliebiger Schusszahl.',
|
||||
},
|
||||
'Period: this month, last 3 months, this year, all or your own dates. Statistics and History both use it.': {
|
||||
'English': 'Period: this month, last 3 months, this year, all or your own dates. Statistics and History both use it.',
|
||||
'Slovenian': 'Obdobje: ta mesec, zadnji 3 meseci, to leto, vse ali tvoji datumi. Uporabljata ga Statistika in Zgodovina.',
|
||||
'German': 'Zeitraum: dieser Monat, letzte 3 Monate, dieses Jahr, alle oder eigene Daten. Statistik und Verlauf nutzen ihn beide.',
|
||||
},
|
||||
'Tap a session to see all its targets on one target.': {
|
||||
'English': 'Tap a session to see all its targets on one target.',
|
||||
'Slovenian': 'Tapni sejo, da vidiš vse njene tarče na eni tarči.',
|
||||
'German': 'Tippe auf eine Einheit, um alle ihre Scheiben auf einer Scheibe zu sehen.',
|
||||
},
|
||||
'Trainings / Tournaments: choose which sessions the statistics count.': {
|
||||
'English': 'Trainings / Tournaments: choose which sessions the statistics count.',
|
||||
'Slovenian': 'Treningi / Tekmovanja: izberi, katere seje šteje statistika.',
|
||||
@@ -1039,11 +1059,6 @@ class AppTranslations {
|
||||
'Slovenian': 'Streli 1–5: statistika primerja le tarče z enakim številom strelov. Sive številke še nimajo tarč.',
|
||||
'German': 'Schüsse 1–5: Die Statistik vergleicht nur Scheiben mit gleicher Schusszahl. Graue Zahlen haben noch keine Scheiben.',
|
||||
},
|
||||
'Tap a session to see all its targets with the selected number of shots on one target.': {
|
||||
'English': 'Tap a session to see all its targets with the selected number of shots on one target.',
|
||||
'Slovenian': 'Tapni sejo za prikaz vseh njenih tarč z izbranim številom strelov na eni tarči.',
|
||||
'German': 'Tippe auf eine Einheit, um alle ihre Scheiben mit der gewählten Schusszahl auf einer Scheibe zu sehen.',
|
||||
},
|
||||
'Three dots on the right or long press: session details, single targets, rename and delete.': {
|
||||
'English': 'Three dots on the right or long press: session details, single targets, rename and delete.',
|
||||
'Slovenian': 'Tri pike na desni ali dolg pritisk: podrobnosti seje, posamezne tarče, preimenovanje in brisanje.',
|
||||
@@ -1065,11 +1080,6 @@ class AppTranslations {
|
||||
'Slovenian': 'Graf: povprečje strela (leva os) in število točk (desna os). Mesec prikaže vsako sejo meseca, Leto eno točko na mesec; s puščicami greš nazaj po mesecih ali letih. Tapni ali povleci po njem za vrednosti.',
|
||||
'German': 'Diagramm: Schussdurchschnitt (linke Achse) und Punktzahl (rechte Achse). Monat zeigt jede Einheit eines Monats, Jahr einen Punkt pro Monat; mit den Pfeilen gehst du zu früheren Monaten oder Jahren. Tippe oder ziehe darauf, um die Werte zu sehen.',
|
||||
},
|
||||
'Period (next to History): this month, last 3 months, this year, all or your own dates. The top card and the list both use it.': {
|
||||
'English': 'Period (next to History): this month, last 3 months, this year, all or your own dates. The top card and the list both use it.',
|
||||
'Slovenian': 'Obdobje (zraven Zgodovine): ta mesec, zadnji 3 meseci, to leto, vse ali svoji datumi. Uporabljata ga zgornja kartica in seznam.',
|
||||
'German': 'Zeitraum (neben Verlauf): dieser Monat, letzte 3 Monate, dieses Jahr, alles oder eigene Daten. Die obere Karte und die Liste verwenden ihn beide.',
|
||||
},
|
||||
'Period': {
|
||||
'English': 'Period',
|
||||
'Slovenian': 'Obdobje',
|
||||
|
||||
Reference in New Issue
Block a user