#! /usr/bin/gawk -f # Last edited on 2023-09-19 09:06:39 by stolfi # Reads a file "{IMGNAME}.ipts" with coordinates of four reference points # named "P0" through "P3" or "Q0" through "Q3". Writes to standard output # one line with the average distance between all six pairs of those points. BEGIN { split("", x) split("", y) } /^[PQ][0-3]/{ i = substr($1,2,1)+0 x[i]=$2 y[i]=$3 } END{ sd = 0 for (i = 0; i < 4; i++) { for (j = 0; j < i; j++) { dx = x[i]-x[j] dy = y[i]-y[j] sd += sqrt(dx*dx + dy*dy) } } printf " %6.1f\n", sd/6 }