Changeset 1566 for code/trunk/src/util
- Timestamp:
- Jun 8, 2008, 5:04:18 PM (17 years ago)
- Location:
- code/trunk/src/util
- Files:
-
- 2 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 } -
code/trunk/src/util/Math.h
r1564 r1566 62 62 _UtilExport orxonox::Vector2 get2DViewdirection(const orxonox::Vector3& myposition, const orxonox::Vector3& mydirection, const orxonox::Vector3& myorthonormal, const orxonox::Vector3& otherposition); 63 63 _UtilExport orxonox::Vector2 get2DViewcoordinates(const orxonox::Vector3& myposition, const orxonox::Vector3& mydirection, const orxonox::Vector3& myorthonormal, const orxonox::Vector3& otherposition); 64 _UtilExport orxonox::Vector3 getPredictedPosition(const orxonox::Vector3& myposition, float projectilespeed, const orxonox::Vector3& targetposition, const orxonox::Vector3& targetvelocity); 64 65 65 66 template <typename T>
Note: See TracChangeset
for help on using the changeset viewer.