Changeset 1566 for code/trunk/src/util/Math.cc
- Timestamp:
- Jun 8, 2008, 5:04:18 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk/src/util/Math.cc
r1564 r1566 106 106 return orxonox::Vector2(-sin(angle) * radius, cos(angle) * radius); 107 107 } 108 109 orxonox::Vector3 getPredictedPosition(const orxonox::Vector3& myposition, float projectilespeed, const orxonox::Vector3& targetposition, const orxonox::Vector3& targetvelocity) 110 { 111 float squaredProjectilespeed = projectilespeed * projectilespeed; 112 orxonox::Vector3 distance = targetposition - myposition; 113 float a = distance.squaredLength(); 114 float b = 2 * (distance.x + distance.y + distance.z) * (targetvelocity.x + targetvelocity.y + targetvelocity.z); 115 float c = targetvelocity.squaredLength(); 116 117 float temp = 4*squaredProjectilespeed*c + a*a - 4*b*c; 118 if (temp < 0) 119 return orxonox::Vector3::ZERO; 120 121 temp = sqrt(temp); 122 float time = (temp + a) / (2 * (squaredProjectilespeed - b)); 123 return (targetposition + targetvelocity * time); 124 }
Note: See TracChangeset
for help on using the changeset viewer.