summaryrefslogblamecommitdiffstats
path: root/fiz/naloga/transformirane/pari.php
blob: 57e9542a03f384f69371773969c45ed0176840e5 (plain) (tree)













































                                                                                                                                                                                          
#!/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";
}
?>