<?php 

function iszf($p){  
    $t1 = array_shift($p);  
    foreach ($p as $key => $v) {  
        if($t1['0'] == $v['0']){  
            $h1[] = abs($t1['1']-$v['1']);  
        }elseif ($t1['1'] == $v['1']) {  
            $h1[] = abs($t1['0']-$v['0']);  
        }else{  
            $h1['duijue'] = sqrt(pow(abs($t1['0']-$v['0']),2)+pow(abs($t1['1']-$v['1']),2));  
        }  
    }  


    $t2 = array_shift($p);  
    foreach ($p as $key => $v) {  
        if($t2['0'] == $v['0']){  
            $h2[] = abs($t2['1']-$v['1']);  
        }elseif ($t2['1'] == $v['1']) {  
            $h2[] = abs($t2['0']-$v['0']);  
        }else{  
            $h2['duijue'] = sqrt(pow(abs($t2['0']-$v['0']),2)+pow(abs($t2['1']-$v['1']),2));  
        }  
    }  


    $t3 = array_shift($p); 
    foreach ($p as $key => $v) {  
        if($t3['0'] == $v['0']){  
            $h3[] = abs($t3['1']-$v['1']);  
        }elseif ($t3['1'] == $v['1']) {  
            $h3[] = abs($t3['0']-$v['0']);  
        }else{  
            $h3['duijue'] = sqrt(pow(abs($t3['0']-$v['0']),2)+pow(abs($t3['1']-$v['1']),2));  
        }  
    }  


    $dd = false;  
    if(array_key_exists('duijue',$h2)){  
        if($h2['duijue'] == $h1['duijue']){  
            if($h1['1'] ?? ''){
                if( $h1['0']== $h1['1'] ){
                    $dd = true;  
                }
            }
        }  
    }  
      
    if(array_key_exists('duijue',$h3)){  
        if($h3['duijue'] == $h1['duijue']){  
            if($h1['1'] ?? ''){
                if( $h1['0']== $h1['1'] ){
                    $dd = true;  
                }
            }
        }  
    }  
    return $dd;  
}  
  
$p[] = [0,0];  
$p[] = [6,6];
$p[] = [0,6];
$p[] = [6,0];
  

var_dump(iszf($p)); 

 

posted on 2018-05-03 16:26  阳光小白  阅读(205)  评论(0编辑  收藏  举报