title: Velocity at an angle
body: <p>I'm trying to find the velocity at an angle.</p>
  
  <p>To do this I'm trying to use a triangle, but I'm running into road blocks. </p>
  
  <p>This is the code that moves the object</p>
  
  <pre><code>Velocity = new Vector3((float)Math.Cos(MathC.AngleToPoint(EnemyObject.transform.position, PlayerPosition)),
                (float)Math.Sin(MathC.AngleToPoint(EnemyObject.transform.position, PlayerPosition)), 0);
  </code></pre>
  
  <p>This is the AngleToPoint method </p>
  
  <pre><code>public static double AngleToPoint(Vector3 startingPoint, Vector3 endPoint)
  {
      double hypotenuse = LineLength(startingPoint, endPoint);
      double adjacent = LineLength(startingPoint, new Vector3(endPoint.x, startingPoint.y, 0));
      double opposite = LineLength(endPoint,  new Vector3(endPoint.x, startingPoint.y, 0));
  
      double angle = adjacent / hypotenuse;
  
  
      return Math.Acos(DegreeToRadian(angle));
  
  }
  </code></pre>
  
  <p>And this is the LineLength method</p>
  
  <pre><code>public static float LineLength(Vector2 point1, Vector2 point2)
  {
      return Math.Abs((float)Math.Sqrt(Math.Pow((point2.x - point1.x), 2)+Math.Pow((point2.y - point1.y),2)));
  
  }
  </code></pre>
  
  <p>I am getting a lot of NaN errors, and the movement does not behave how I want it to.</p>