This repository has been archived on 2023-11-03. You can view files and clone it, but cannot push or open issues or pull requests.
GINPA/Modele/calcul.c

38 lines
1.8 KiB
C

#include "calcul.h"
double distance(Coordonnees const* const a, Coordonnees const* const b)
{
const double ratio = PI / 180.0;
/* Conversion des latitudes & longitudes en radians */
const double latA = a->lat * ratio;
const double latB = b->lat * ratio;
const double lonA = a->lon * ratio;
const double lonB = b->lon * ratio;
const double arg = sqrt(pow(sin((latA - latB) / 2), 2) + cos(latA) * cos(latB) * pow(sin((lonA - lonB) / 2), 2));
return 2 * RAYON * asin(arg);
}
/*Coordonnees getOrigin(const Coordonnees *const pointCentral, const double echelle, const uint16_t screenWidth, const uint16_t screenHeight)
{
const double distance = sqrt(pow(screenWidth * (0.02646 * 1.0e-2) / 2.0, 2.0) + pow(screenHeight * (0.02646 * 1.0e-2) / 2.0, 2.0)) * echelle;
//const double angle = atan((screenHeight / 2.0) / (screenWidth / 2.0));
const double angle = PI / 4;
//const double latitude_distante = asin(sin(pointCentral->lat) * cos(distance / RAYON) + cos(pointCentral->lat) * sin(distance / RAYON) * cos(angle));
//const double longitude_distante = pointCentral->lon + atan2(sin(angle) * sin(distance / RAYON) * cos(pointCentral->lat), cos(distance / RAYON) - sin(pointCentral->lat) * sin(latitude_distante));
const double latitude_distante = 360 / (2 * PI) * asin(((sin(((pointCentral->lat * PI) / 180)) * cos((distance / RAYON))) + ((cos(((pointCentral->lat * PI) / 180)) * sin(distance / 3440.06))) * cos(((angle * PI) / 180))));
const double longitude_distante = (pointCentral->lon + 360 / (2 * PI) * atan2(((sin(((angle * PI) / 180)) * sin((distance / 3440.06))) * cos(((latitude_distante * PI) / 180))), (cos((distance / 3440.06)) - (sin(((latitude_distante * PI) / 180)) * sin(((latitude_distante * PI) / 180))))));
printf("%f / %f\n", latitude_distante, longitude_distante);
return (Coordonnees){latitude_distante, longitude_distante};
}*/