random 一个点A  ,再random个点B
让点A往点B的方向画线,然后再画两边的线形成箭头MoveTo(pointA);
LineTo(pointB);这个直线我会,但是箭头该如何实现呢? (要实现可以给定角度,画出两边的线的形成箭头) 
该用什么公式? 

解决方案 »

  1.   

    呵呵,用GDI++可以轻易实现,DrawLine可以指定线形
      

  2.   

    呵呵,用GDI++可以轻易实现,DrawLine可以指定线形可是我用的是dc 画的,我的想法是,
                              H1
     A -------------*------------> B
                    C         H2把B 作为圆的中心点,然后 CB 作为圆的中心到圆边的长度, 并且设置 CB 为 0 度计算, 然后在让B 往 +5度  -5度的方向画线,
    不知道该怎么做,要用什么算法? cos sine tan ??? 这个我不懂,
      

  3.   

    void DrawArrow(CDC *pdc,CPoint m_One, CPoint m_Two)
    {

      double slopy , cosy , siny;
      double Par = 10.0;  //length of Arrow (>)
      slopy = atan2( ( m_One.y - m_Two.y ),
        ( m_One.x - m_Two.x ) );
      cosy = cos( slopy );
      siny = sin( slopy ); //need math.h for these functions  //draw a line between the 2 endpoint
      pdc->MoveTo( m_One );
      pdc->LineTo( m_Two );  //here is the tough part - actually drawing the arrows
      //a total of 6 lines drawn to make the arrow shape
      pdc->MoveTo( m_One);
      pdc->LineTo( m_One.x + int( - Par * cosy - ( Par / 2.0 * siny ) ),
        m_One.y + int( - Par * siny + ( Par / 2.0 * cosy ) ) );
      pdc->LineTo( m_One.x + int( - Par * cosy + ( Par / 2.0 * siny ) ),
        m_One.y - int( Par / 2.0 * cosy + Par * siny ) ); 
      pdc->LineTo( m_One );  
      /*/-------------similarly the the other end-------------/*/
      pdc->MoveTo( m_Two );
      pdc->LineTo( m_Two.x + int( Par * cosy - ( Par / 2.0 * siny ) ),
        m_Two.y + int( Par * siny + ( Par / 2.0 * cosy ) ) );
      pdc->LineTo( m_Two.x + int( Par * cosy + Par / 2.0 * siny ),
        m_Two.y - int( Par / 2.0 * cosy - Par * siny ) );
      pdc->LineTo( m_Two );}无意找到了个老外写的,很好用,分享,结贴