It became half vacant where this average speed will be used. But as was margin of interpretation, I imagined the following situation:
Based on the statement
Every 5 minutes I go 10 kilometers per hour
I created a function that takes a time in minutes and a distance in kilometers and returns the average speed. And then you would "want" to check how long, going at calculated speed, would it take to travel the distance returned by the function distancia()
.
Plus I include the solution for that other one of yours question, which is basically create variables for latitudes and longitudes. If it does not fit your needs let us know in the comments.
<?php
$latitude_origem = -4.077559;
$longitude_origem = -63.127536;
$latitude_destino = -4.063721;
$longitude_destino = -63.038268;
function distancia($lat1, $lon1, $lat2, $lon2) {
$lat1 = deg2rad($lat1);
$lat2 = deg2rad($lat2);
$lon1 = deg2rad($lon1);
$lon2 = deg2rad($lon2);
$dist = (6371 * acos( cos( $lat1 ) * cos( $lat2 ) * cos( $lon2 - $lon1 ) + sin( $lat1 ) * sin($lat2) ) );
$dist = number_format($dist, 2, '.', '');
return $dist;
}
/**
@param $tempo um numero, representando os minutos
@param $distancia um double representando a distancia percorrida em $tempo
(distancia em quilometros)
@return double velocidade em quilometros por hora (Km/h)
*/
function converterParaKmHora($tempo, $distancia){
//60 representa a quantidade de minutos em uma hora
$velocidade_km_hora = ($distancia * 60) / $tempo;
return $velocidade_km_hora;
}
$velocidade_media = converterParaKmHora(5, 10);
$distancia_entre_pontos = distancia($latitude_origem, $longitude_origem , $latitude_destino, $longitude_destino);
echo $distancia_entre_pontos . " Km<br />";
echo $velocidade_media . " Km/h<br />";
echo ($distancia_entre_pontos/$velocidade_media) . " horas para completar o percurso<br />";
If 5 minutes is to 10km how many kilometres is to 60 minutes solves the expression that will get the result: 5x = 60 * 10; 5x = 600; x = 600 / 5 = 120 KM ...
– Rafael Salomão
V is speed, S is space, t is time. General formula for uniform motion
V=S/t
replacing getsV=10/5
thereforeV= 2Km/min
calculating the space travelled in one hourS=v*t
thereforeS=2*60=120km
– user60252
From "head" an hour has how many 5minutes? answer: 12, so it is 12*10=120
– user60252
Your question is not clear enough taking into account the code presented!
– user60252