summaryrefslogtreecommitdiffstats
path: root/fiz/naloga/transformirane/pari.php
blob: 57e9542a03f384f69371773969c45ed0176840e5 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
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";
}
?>