0

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";
    }
Cœur
  • 37,241
  • 25
  • 195
  • 267
andre
  • 63
  • 2
  • 9
  • you need also the object size ... if you got bounding sphere/box (in `[m]`) for example .... if not you need to compute it by going through all the Mesh vertexes and remembering min,max coordinate values (for axis aligned mesh) or fit the sphere with fitting .... You need to better specify what data about your object you have... Also if you consider other physical properties (like air stream from the jet turbines ... you need to specify it too) – Spektre Dec 22 '16 at 11:11
  • btw If this is for the flights then I would use standards instead of mesh dimensions like [Airborne Collision Avoidance System (ACAS)](http://www.skybrary.aero/index.php/Airborne_Collision_Avoidance_System_(ACAS)) so set the sphere radius to 600ft or 850ft and just convert to radians or degrees for your current position (it will be ellipsoid or sphere with biggest radius ....) ... unless your planes are some jumbo jet monster bigger then specs ... – Spektre Dec 22 '16 at 11:18
  • If your task is for some commercial system you might consider consulting real pilots. While I was doing ATC simulation module for training system (for real pilots) I was trained by Airline pilots and instructors for about 3 months just to get the hence of the problems and procedures behind Air traffic. It helped a lot (without it as pure programmer you have no clue what you are missing or even doing). – Spektre Dec 22 '16 at 11:26
  • @Spektre Thanks a lot. So I just have one GPS point, how would I compute the bounding sphere without the need of object size and the mesh vertices. Just a simple bounding sphere for collision detection ? – andre Dec 22 '16 at 11:32
  • If I have altitude, speed, and heading, how would I define a bounding sphere ? – andre Dec 22 '16 at 11:42
  • @Spektre Please I need your help :) – andre Dec 22 '16 at 13:29
  • first you must determine the sphere radius as I mentioned before so either it is your craft biggest dimension half size or some safety distance (like from the ACAS specification). If you want to use this bounding sphere in Cartesian coordinates then you need just he center point (which is your location) and this distance. If you want this sphere to be in spherical ccordinates then you need to convert the radius to angles in longitudal and latitudal local axis.That can be done with use of `XYZtoWGS84` conversion routine or by computing the actual radius in each axis and compute from arc length – Spektre Dec 22 '16 at 13:39
  • The sphere radius is 300ft. So I just need a center which is my location and a radius _ – andre Dec 22 '16 at 13:42
  • in Cartesian yes.... in WGS84 spherical you need to decide if you want ellipsoid (which will be closest to the Cartesian sphere) or just sphere (which will be more like ellipsoid in Cartessian). As you are using this only in Cartesian then the radius and center is enough. Just do not forget to convert the 300ft to meters or what ever common units you are using.... – Spektre Dec 22 '16 at 14:16
  • @Spektre can you take a look at that problem. I have the data and the units now. http://stackoverflow.com/questions/41286107/collision-detection-between-two-objects – andre Dec 22 '16 at 15:06
  • The sphere collision always detect a collision here is my data. xAv = 4070722.2674118499, yAv = 1187280.7521421891, zAv = 4748556.5635749763 xPoi = 4000524.7708611945, yPoi = 1293081.4373654183, zPoi = 4780356.3598615918 avSphere.radius = 1550000; //1550000m poiSphere.radius = 1000000; // 100000m – andre Dec 23 '16 at 10:09
  • Why is that a problem? the points are 130km distant so that is much closer then your 1550+1000km sphere radiuses .... hence always collision present. You are not thinking about what are you doing! You just put the numbers in "some" code and hoping it would do what you want. That is not how programing works ... – Spektre Dec 23 '16 at 10:47

0 Answers0