![enter image description here](https://i.stack.imgur.com/LP1RS.jpg)Although this is an easy question, I might be thinking in a wrong way so could not find the correct way.

Imagine I have a line, say Line 1, starting from m\_StartPoint1 and ending at m\_EndPoint1. I want to draw another line, say Line 2, starting from m\_EndPoint1 and having a constant angle of alpha with Line 1. Basically my goal is to draw an arrow.

I am using the following code to calculate the x,y coordinates of Line 2.

```
 const float ARROW_ANGLE=-PI/8.0;
 wxPoint p;
 p.x=m_EndPoint.x+ARROW_LENGTH*sin(ARROW_ANGLE);
 p.y=m_EndPoint.y+ARROW_LENGTH*cos(ARROW_ANGLE);
 m_ArrowHead1=new CLine(m_EndPoint,p,color,PenWidth); //Draws a line from m_EndPoint to p

```

This calculation works well when the angle of Line 1 is less than 90 (in degrees). However, when the angle of line 1 changes the arrow does not show correctly. Basically the user should be able to draw Line 1 as he/she wants and arrow line should show correctly regardless of the angle of Line 1.

I have expressed line 1 as vector and got its angle through the following code:

```
class CVector2D
{
wxPoint m_StartPoint, m_EndPoint;
public:
CVector2D():m_StartPoint(),m_EndPoint()  {}
CVector2D(wxPoint p1, wxPoint p2):m_StartPoint(p1),m_EndPoint(p2)  {}

float GetSlope(void)
{
    return float(m_EndPoint.y-m_StartPoint.y)/float(m_EndPoint.x-m_StartPoint.x);
}

float GetSlopeAngleInRadians()
{
       /*Will return the angle of the vector in radians
   * The angle is the counterclockwise rotation therefore it is negative
    */
    float slope=GetSlope();
    float InRadians=atan2(float(m_EndPoint.y-m_StartPoint.y),float(m_EndPoint.x-m_StartPoint.x));
    if(InRadians<=0) return InRadians;
    return -(2*PI-InRadians);
}
 };

```

And then I tried to calculate with the following code:

```
CVector2D vector(m_StartPoint,m_EndPoint);
float vector_angle=vector.GetSlopeAngleInRadians();
float total_angle=vector_angle+ARROW_ANGLE;
wxPoint p;
p.x=m_EndPoint.x+ARROW_LENGTH*cos(total_angle);
p.y=m_EndPoint.y+ARROW_LENGTH*sin(total_angle);
m_ArrowHead1=new CLine(m_EndPoint,p,color,PenWidth);

```

However, this code did not work either. Any ideas will be appreciated.