Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 9450


Ignore:
Timestamp:
Nov 19, 2012, 7:25:00 AM (12 years ago)
Author:
jo
Message:

Cleanup.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/spaceNavigation/src/modules/overlays/hud/HUDNavigation.cc

    r9444 r9450  
    499499        // munSpeed*time = lengthBetween(wePosition, targetPosition + targetSpeed*time)
    500500        // from this we extract:
    501         float a = pow(targetSpeed.length(),2) - pow(this->currentMunitionSpeed_,2);
     501        float a = targetSpeed.squaredLength() - this->currentMunitionSpeed_ * this->currentMunitionSpeed_;
    502502        float b = 2*((targetPosition.x - wePosition.x)*targetSpeed.x
    503503                    +(targetPosition.y - wePosition.y)*targetSpeed.y
    504504                    +(targetPosition.z - wePosition.z)*targetSpeed.z);
    505         float c = pow((targetPosition-wePosition).length(),2);
     505        float c = (wePosition-targetPosition).squaredLength();
    506506
    507507        // calculate smallest time solution, in case it exists
    508         if(pow(b,2) - 4*a*c < 0)
     508        float det = b * b - 4 * a * c;
     509        if(det < 0)
    509510            return NULL;
    510         float time = (-b - sqrt(pow(b,2) - 4*a*c))/(2*a);
    511         orxout()<< "TIME 1: " << time1 <<endl;
     511        float time = (-b - sqrt(det))/(2*a);
     512        orxout()<< "TIME 2: " << time1 <<endl;
    512513        if(time < 0)
    513             time = (-b + sqrt(pow(b,2) - 4*a*c))/(2*a);
     514            time = (-b + sqrt(det))/(2*a);
    514515        if(time < 0)
    515516            return NULL;
Note: See TracChangeset for help on using the changeset viewer.