summaryrefslogtreecommitdiffstats
path: root/fiz/naloga/transformirane/pari.php
diff options
context:
space:
mode:
Diffstat (limited to 'fiz/naloga/transformirane/pari.php')
-rwxr-xr-xfiz/naloga/transformirane/pari.php46
1 files changed, 46 insertions, 0 deletions
diff --git a/fiz/naloga/transformirane/pari.php b/fiz/naloga/transformirane/pari.php
new file mode 100755
index 0000000..57e9542
--- /dev/null
+++ b/fiz/naloga/transformirane/pari.php
@@ -0,0 +1,46 @@
+#!/usr/bin/env php
+<?php
+$meritev = $argv[1];
+$positions_unpa = explode("\n", file_get_contents($meritev.".tsv"));
+$fields_unpa = explode("\n", file_get_contents("../meritve-polje/".$meritev.".tsv"));
+$positions = [];
+foreach ($positions_unpa as $position) {
+ if ($position == "")
+ continue;
+ $posdata = explode("\t", $position);
+ $positions[$posdata[1]] = ["frame" => $posdata[0], "x" => $posdata[2], "y" => $posdata[3]];
+}
+$fields = [];
+$iter = 0;
+foreach ($fields_unpa as $field) {
+ if ($field == "")
+ continue;
+ $fiedata = explode("\t", $field);
+ if (!$iter++)
+ $starting_time = $fiedata[0];
+ $fields[intval($fiedata[0]) - intval($starting_time)] = ["x" => $fiedata[2], "y" => $fiedata[3], "z" => $fiedata[4], "izpusti" => str_contains($field, "izpusti") ? true : false];
+}
+foreach ($positions as $position_time => $position) {
+ $closest = [];
+ foreach ($fields as $field_time => $field) {
+ $closest[$field_time] = abs($position_time - $field_time);
+ }
+ asort($closest);
+ if (isset($fields[key($closest)]["taken"]))
+ continue;
+ $fields[key($closest)]["taken"] = true;
+ if ($fields[key($closest)]["izpusti"])
+ continue;
+ echo key($closest)/1000 ."\t"
+ .$position["x"]."\t"
+ .$position["y"]."\t"
+ .$fields[key($closest)]["x"]."\t"
+ .$fields[key($closest)]["y"]."\t"
+ .$fields[key($closest)]["z"]."\t"
+ .sqrt($fields[key($closest)]["x"]**2
+ +$fields[key($closest)]["y"]**2
+ +$fields[key($closest)]["z"]**2)."\t"
+ .explode("\t", shell_exec("../a.out enkrat 0.088 ".$position["x"]." ".$position["y"]." 30"))[3]."\t"
+ ."\n";
+}
+?>