public static Structures.Vector2 CalcAngle(Structures.Vector3 src, Structures.Vector3 dist) { Structures.Vector3 delta = new Structures.Vector3() { x = dist.x - src.x, y = dist.y - src.y, z = dist.z - src.z, }; float magn = (float)Math.Sqrt( (delta.x * delta.x) + (delta.y * delta.y) + (delta.z * delta.z) ); Structures.Vector2 returnAngle = new Structures.Vector2() { x = (float)(Math.Atan2(delta.y, delta.x) * (180f / 3.14f)), y = (float)(-Math.Atan2(delta.z, magn) * (180f / 3.14f)), }; return(returnAngle); }
public static float VectorDistance(Structures.Vector3 src, Structures.Vector3 dist, bool noZ = false) { if (!noZ) { double distance = Math.Sqrt( ((dist.x - src.x) * (dist.x - src.x)) + ((dist.y - src.y) * (dist.y - src.y)) + ((dist.z - src.z) * (dist.z - src.z)) ); distance = Math.Round(distance, 4); return((float)distance); } else { double distance = Math.Sqrt( ((dist.x - src.x) * (dist.x - src.x)) + ((dist.y - src.y) * (dist.y - src.y)) ); distance = Math.Round(distance, 4); return((float)distance); } }
public static Structures.Vector2 ToVector2(this Structures.Vector3 angle) { return(new Structures.Vector2(angle.x, angle.y)); }