I've gone over this again and again, and my result is obviously wrong when viewed in-action. Here's the initial formula I converted (first one):
http://en.wikipedia.org/wiki/Range_of_a_projectile
and here's my C# code:
float CalculateMaximumRange() {
float g = Physics.gravity.y;
float y = origin.position.y;
float v = projectileSpeed;
float a = 45;
float vSin = v * Mathf.Sin(a);
float vCos = v * Mathf.Cos(a);
float sqrt = Mathf.Sqrt(vSin * vSin + 2 * g * y);
return Mathf.Abs((vCos / g) * (vSin + sqrt));
}
Does anyone see what I did wrong?