Draw Triangle end of Vector

  atan2, c++, opengl, vector

I need to draw a triangle on a vector. I use SDL and OpenGL. For the triangle I know that the angle is 30 degrees. How can i use it with the atan2f function?The Picture is how it should look but my arrow wont appear.

void DrawVector(Vector2f vector, Point2f startingPoint) {
    Point2f p1{ vector.x, vector.y };
    Point2f p2{atan2f(p1.x,p1.y) ,atan2f(p1.y,p1.x)};
    Point2f p3{ atan2f(p2.x,p2.y),atan2f(p2.y,p2.x) };


    DrawLine(startingPoint.x, startingPoint.y, startingPoint.x+ vector.x, startingPoint.y + vector.y, 1.f);
    FillTriangle(p1, p2, p3);

}

Vector result

Source: Windows Questions C++

LEAVE A COMMENT