I would like to create an imaginary bounding sphere around an object. Giving the position of the object in GPS coordinates WGS84 format. And also giving the position in cartesian coordinates.
I have tried to convert degrees lon,lat,alt to radians, and use a function by Spketre, to convert them to Cartesian coordinates.
The problem is I'm doing sphere to sphere collision detection and what I have found that the positions that are converted from spherical to Cartesian are so near so that the sphere intersection method is returning true.
WGS84toXYZ(xAv, yAv, zAv, (m_sPosAV.GetLongitude()*math::pi) / 180, (m_sPosAV.GetLatitude()*math::pi) / 180, (m_sPosAV.GetAltitude()*math::pi) / 180); // lon direction Nort
WGS84toXYZ(xPoi, yPoi, zPoi, (poi.Position().GetLongitude()*math::pi) / 180, (poi.Position().GetLatitude()*math::pi) / 180, (poi.Position().GetAltitude()*math::pi) / 180); // lon direction Nort
Sphere avSphere;
Sphere poiSphere;
avSphere.position.x = xAv;
avSphere.position.y = yAv;
avSphere.position.z = zAv;
avSphere.radius = 1550;
poiSphere.position.x = xPoi;
poiSphere.position.y = yPoi;
poiSphere.position.z = zPoi;
poiSphere.radius = 1200;
if (doesItCollide(avSphere, poiSphere))
{
qDebug() << "collision";
}