如何用LineTo 画直线和箭头? random 一个点A ,再random个点B让点A往点B的方向画线,然后再画两边的线形成箭头MoveTo(pointA);LineTo(pointB);这个直线我会,但是箭头该如何实现呢? (要实现可以给定角度,画出两边的线的形成箭头) 该用什么公式? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 呵呵,用GDI++可以轻易实现,DrawLine可以指定线形 呵呵,用GDI++可以轻易实现,DrawLine可以指定线形可是我用的是dc 画的,我的想法是, H1 A -------------*------------> B C H2把B 作为圆的中心点,然后 CB 作为圆的中心到圆边的长度, 并且设置 CB 为 0 度计算, 然后在让B 往 +5度 -5度的方向画线,不知道该怎么做,要用什么算法? cos sine tan ??? 这个我不懂, 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 );}无意找到了个老外写的,很好用,分享,结贴 vc添加ocx控件 高手急救!!关于属性页和属性表令人混乱的问题~~~ 在MDI工程中,如何得到视图对应的子边框窗口对象的指针? 为什么有时需要显性数据转型,有时却不需要呢? 请教:如何更改xml节点的属性?(昨天的帖子没写清楚) WaitForInputIdle错误 如何从oracle的本地网络服务名(在客户端配置)得到其对应的机器名和数据库名? 由于工作需要,我想求购一些有关VTK使用的书籍和资料 软件使用权问题?ktv点歌系统 IANA是什么的简称? vc ado 连接 access ,open close 速度,这样的数据是否可以? 请教使用过SkinMagic的兄弟!
H1
A -------------*------------> B
C H2把B 作为圆的中心点,然后 CB 作为圆的中心到圆边的长度, 并且设置 CB 为 0 度计算, 然后在让B 往 +5度 -5度的方向画线,
不知道该怎么做,要用什么算法? cos sine tan ??? 这个我不懂,
{
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 );}无意找到了个老外写的,很好用,分享,结贴