0

I have a line (DrawLine-Event) with the points (a,b) (c,d) and now I want to calculate the angle of it but I don't know how.

I tried it like this:

double atan = ((d - b) / c - a)) * Math.PI / 180;
double solution = Math.Atan(atan);
int angle = Convert.ToInt32(Math.Round(solution * 180 / Math.PI));
NightShadeQueen
  • 3,284
  • 3
  • 24
  • 37
bravobyte
  • 33
  • 1
  • 6

1 Answers1

1

You can use Vector.AngleBetween Method to get the angle

private Double angleBetweenExample()
{
    Vector vector1 = new Vector(20, 30);
    Vector vector2 = new Vector(45, 70);
    Double angleBetween;

    // angleBetween is approximately equal to 0.9548
    angleBetween = Vector.AngleBetween(vector1, vector2);

    return angleBetween;

}
NASSER
  • 5,900
  • 7
  • 38
  • 57