Given:
- $\theta$ (a negative angle)
- $v_0$ (initial velocity)
- $y_0$ (initial height)
- $g$ (acceleration of gravity)
I want to find the range of a projectile (ignoring wind resistance)
Hours of searching have given no useful results. Those that I thought were useful turned out to be incapable of accounting for negative angles. This formula in particular returns a range of 0 if the angle is 0, which simply doesn't make sense.
For example:
- $\theta=-12.5$°
- $v_0=100$m/s
- $y_0=1.65$m
- $g=9.80665$
Assuming a projectile is launched at angle $\theta$ from horizontal from a height $y_0$ above the ground, where the ground is assumed to be represented by the line $y = 0.$ The measurement of the angle is such that $\theta = 0$ if the projectile initially is moving horizontally to the right, and otherwise the angle is measured in a counterclockwise direction from "horizontal to the right," so small positive angles are upward and small negative angles are downward.
The objective is to calculate the horizontal distance $d$ from the launch point to the point where the projectile hits the ground, that is, when the $y$ coordinate of the projectile reaches zero.
One way to compute $d$ is first to compute $t_f - t_i,$ the time that elapses from when the projectile is launched until the projectile hits the ground. We can arbitrarily set $t_i = 0.$ If the initial angle $\theta$ were positive, the projectile would first have to rise to the height where it stops rising, and then fall from that height to the ground. The upward velocity at time $t$ after the launch is $$v_y(t) = v_0 \sin\theta - gt.$$ If $t_0$ is the time such that $v_y(t_0) = 0,$ then $$t_0 = \frac{v_0 \sin\theta}{g}.$$ The height of the projectile at that time is $$y(t_0) = y_0 + \frac{v_0^2\sin^2\theta}{2g}.$$ The projectile then falls this far in the interval of time $t_f - t_0,$ that is, $$\frac12 g(t_f - t_0)^2 = y_0 + \frac{v_0^2\sin^2\theta}{2g},$$ and therefore \begin{align} t_f &= t_0 + \sqrt{\frac2g\left(y_0 + \frac{v_0^2\sin^2\theta}{2g}\right)} \\ &= \frac{v_0 \sin\theta}{g} + \sqrt{\frac{2y_0}{g} + \frac{v_0^2\sin^2\theta}{g^2}}. \end{align}
Arbitrarily setting the $x$ coordinate of the starting point to $0,$ the horizontal position of the projectile at any time $t$ is $$x(t) = v_0 t \cos\theta.$$ The desired distance $d$ is simply the $x$ coordinate at time $t_f$ (when the projectile hits the ground), so \begin{align} d &= v_0 t_f \cos\theta \\ &= v_0 \left( \frac{v_0 \sin\theta}{g} + \sqrt{\frac{2y_0}{g} + \frac{v_0^2\sin^2\theta}{g^2}} \right) \cos\theta \\ &= \frac{v_0 \cos\theta}{g} \left( v_0 \sin\theta + \sqrt{2gy_0 + v_0^2\sin^2\theta} \right). \tag1 \end{align}
In the case $y_0 = 0,$ the square root in $(1)$ is just $v_0 \sin\theta,$ and the formula can be simplified to the form $\frac{v_0^2 \sin(2\theta)}{g}$ which is often given as the range of a projectile.
In the case where $\sin\theta \neq 0,$ we can pull a factor of $v_0\sin\theta$ out of the expression in parentheses in $(1)$ to get $$ d = \frac{v_0^2\sin\theta\cos\theta}{g} \left( 1 + \sqrt{\frac{2y_0g}{v_0^2\sin^2\theta} + 1} \right). $$
Then, using the fact that $\sin\theta\cos\theta = \frac{\sin(2\theta)}{2},$ we get the formula you found on Wikipedia. But if $\theta = 0$ then $\sin\theta = 0$ and the Wikipedia formula has a division by zero, hence it does not evaluate to zero--it does not evaluate at all.