3

EDIT: Would be awesome if someone could explain in a comment what really goes on. We basically found out the answer by coincidences.

I'm trying to do line tests against an infinitely large cone, but I'm having trouble understanding what I'm doing wrong. I do get some sort of cone like object to show, but it looks... wrong.

    EDIT: This is the solution for line-testing a infinite cone.
    double Cone::lineTest(double lineOrigin[3],double dir[3],double maxDistance) 

    {
    //Returns the distance from line origin to the collision point
    //The object is located at 0,0,0 so the difference is the lineOrigin
         double a = pow(D[0], 2) + pow(D[1], 2) - pow(D[2], 2);
         double b = 2*(O[0]*D[0] + O[1]*D[1] - O[2]*D[2]);
         double c = pow(O[0], 2) + pow(O[1], 2) - pow(O[2], 2);
         double d = b * b - 4*a*c;

         if(d < 0) 
             { return MAX_DISTANCE; }  
         d = sqrt(d);
         double sol1 = (-b - d)/(2.0*a);
         if(sol1 > 0) 
             return sol1;

    return MAX_DISTANCE;
    }
sinsuren
  • 1,745
  • 2
  • 23
  • 26
NangiDev
  • 55
  • 6

0 Answers0