Guest User

Untitled

a guest
Dec 16th, 2017
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. deltaX = horizontal distance between source & target;
  2. deltaY = vertical distance between source & target;
  3. vMax = maximum launch speed (scalar);
  4. g = (positive) downward acceleration due to gravity (eg. 9.8 m/s^s);
  5. yMax = ceiling elevation - source elevation;
  6.  
  7. b1 = vMax^2 - deltaY * g;
  8. discriminant = b1^2 - g^2 * (deltaX^2 + deltaY^2);
  9. T_min = sqrt((b1 - sqrt(discriminant)) * 2 / g^2);
  10.  
  11. T_max = sqrt((b1 + sqrt(discriminant)) * 2 / g^2); // limit due to weapon power
  12. b2 = g * (2 * yMax - deltaY);
  13. T_max = min(T_max, sqrt((b2 + sqrt(b2^2 - (g^2 * deltaY^2)) * 2 / g^2)); // limit due to ceiling
  14.  
  15. T_lowEnergy = sqrt(sqrt((deltaX^2 + deltaY^2) * 4 / g^2));
  16.  
  17. launchVelocity.x = deltaX/T;
  18. launchVelocity.y = deltaY/T + T * g/2;
  19.  
  20. p(t) = sourcePosition + t * launchVelocity + t^2 * gravityVector/2;
  21. (where gravityVector = (0, -g) )
Add Comment
Please, Sign In to add comment