我写了这段代码,我不知道为什么它返回NAN
<?PHP cordsdist($_POST['1x'], $_POST['1y'], $_POST['1z'],
$_POST['2x'], $_POST['2y'], $_POST['2z']);
function cordsdist ($x1, $y1, $z1, $x2, $y2, $z2) {
$v1 = $x1 - $x2 * 2;
$v2 = $y1 - $y2 * 2;
$v3 = $z1 - $z2 * 2;
$dist = sqrt($v1 + $v2 + $v3);
echo $dist;
// [ v1 ] [ v2 ] [ v3 ]
// Distance = √[ (x1 − x2)2 + (y1 − y2)2 + (z1 − z2)2 ]
} ?>