Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- deltaX = horizontal distance between source & target;
- deltaY = vertical distance between source & target;
- vMax = maximum launch speed (scalar);
- g = (positive) downward acceleration due to gravity (eg. 9.8 m/s^s);
- yMax = ceiling elevation - source elevation;
- b1 = vMax^2 - deltaY * g;
- discriminant = b1^2 - g^2 * (deltaX^2 + deltaY^2);
- T_min = sqrt((b1 - sqrt(discriminant)) * 2 / g^2);
- T_max = sqrt((b1 + sqrt(discriminant)) * 2 / g^2); // limit due to weapon power
- b2 = g * (2 * yMax - deltaY);
- T_max = min(T_max, sqrt((b2 + sqrt(b2^2 - (g^2 * deltaY^2)) * 2 / g^2)); // limit due to ceiling
- T_lowEnergy = sqrt(sqrt((deltaX^2 + deltaY^2) * 4 / g^2));
- launchVelocity.x = deltaX/T;
- launchVelocity.y = deltaY/T + T * g/2;
- p(t) = sourcePosition + t * launchVelocity + t^2 * gravityVector/2;
- (where gravityVector = (0, -g) )
Add Comment
Please, Sign In to add comment