Changeset 9450
- Timestamp:
- Nov 19, 2012, 7:25:00 AM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/spaceNavigation/src/modules/overlays/hud/HUDNavigation.cc
r9444 r9450 499 499 // munSpeed*time = lengthBetween(wePosition, targetPosition + targetSpeed*time) 500 500 // from this we extract: 501 float a = pow(targetSpeed.length(),2) - pow(this->currentMunitionSpeed_,2);501 float a = targetSpeed.squaredLength() - this->currentMunitionSpeed_ * this->currentMunitionSpeed_; 502 502 float b = 2*((targetPosition.x - wePosition.x)*targetSpeed.x 503 503 +(targetPosition.y - wePosition.y)*targetSpeed.y 504 504 +(targetPosition.z - wePosition.z)*targetSpeed.z); 505 float c = pow((targetPosition-wePosition).length(),2);505 float c = (wePosition-targetPosition).squaredLength(); 506 506 507 507 // 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) 509 510 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; 512 513 if(time < 0) 513 time = (-b + sqrt( pow(b,2) - 4*a*c))/(2*a);514 time = (-b + sqrt(det))/(2*a); 514 515 if(time < 0) 515 516 return NULL;
Note: See TracChangeset
for help on using the changeset viewer.