Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
using using UnityEngine;
using System.Collections;
using System.Collections.Generic;
class MathHelper {
float static CalcAngleOfElevation (Vector3 from, Vector3 to, float v, float g) {
float x = (to - from).z;
float y = (to - from).y;
float v2 = v * v;
float v4 = v2 * v2;
float fac = v4 - g*(g*x*x + 2*y*v2);
if(fac < 0) {
return Mathf.Infinity;
}
float theta = -Mathf.Atan((v2-Mathf.Sqrt(fac))/(g*x)) * Mathf.Rad2Deg;
while(theta < 0) theta += 360f;
return theta;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment