나를 위해이 문제를 해결할 것입니다, 당신은 좌표 "목록"에 의해 무슨 뜻 이죠
function point_to_line_segment_distance($startX,$startY, $endX,$endY, $pointX,$pointY)
{
$r_numerator = ($pointX - $startX) * ($endX - $startX) + ($pointY - $startY) * ($endY - $startY);
$r_denominator = ($endX - $startX) * ($endX - $startX) + ($endY - $startY) * ($endY - $startY);
$r = $r_numerator/$r_denominator;
$px = $startX + $r * ($endX - $startX);
$py = $startY + $r * ($endY - $startY);
$closest_point_on_segment_X = $px;
$closest_point_on_segment_Y = $py;
$distance = user_bomb_distance_calc($closest_point_on_segment_X, $closest_point_on_segment_Y, $pointX, $pointY);
return array($distance, $closest_point_on_segment_X, $closest_point_on_segment_Y);
}
function user_bomb_distance_calc($uLat , $uLong , $bLat , $bLong)
{
$earthRadius = 6371; #km
$dLat = deg2rad((double)$bLat - (double) $uLat);
$dlong = deg2rad((double)$bLong - (double) $uLong);
$a = sin($dLat/2) * sin($dLat/2) + cos(deg2rad((double)$uLat)) * cos(deg2rad((double)$bLat)) * sin($dlong/2) * sin($dlong/2);
$c = 2 * atan2(sqrt($a), sqrt(1 - $a));
$distance = $earthRadius * $c;
$meter = 1000; //convert to meter 1KM = 1000M
return intval($distance * $meter) ;
}
. 6 명의 유효 숫자를 가진 두 사람 사이에 가능한 모든 좌표를 원하십니까? 또는 두 점 사이의 선 방정식을 원하십니까? 아니면 완전히 다른 것을 원합니까? –
예, 두 자리 사이에 가능한 모든 좌표가 5 자리 숫자로 충분합니다. 나는 나의 질문을 분명히 할 것이다. 감사. –
당신이 당신의 최종 용도와 당신이 이미 시도한 것을 포함한다면 그것은 SO 사용자에게 도움이 될 것입니다. 귀하의 계산은 엄청나게 많은 순열리스트를 산출 할 것입니다. 알고리즘이 더 잘 작동 할 때 왜 모든 것을 나열하고 싶습니까? – nickhar