void
CDrawArrowDemoView::DrawArrow(CPoint p1,CPoint p2,
double
theta,
int
length)
{
theta=3.1415926*theta/180;
double
Px,Py,P1x,P1y,P2x,P2y;
Px=p1.x-p2.x;
Py=p1.y-p2.y;
P1x=Px*
cos
(theta)-Py*
sin
(theta);
P1y=Px*
sin
(theta)+Py*
cos
(theta);
P2x=Px*
cos
(-theta)-Py*
sin
(-theta);
P2y=Px*
sin
(-theta)+Py*
cos
(-theta);
double
x1,x2;
x1=
sqrt
(P1x*P1x+P1y*P1y);
P1x=P1x*length/x1;
P1y=P1y*length/x1;
x2=
sqrt
(P2x*P2x+P2y*P2y);
P2x=P2x*length/x2;
P2y=P2y*length/x2;
P1x=P1x+p2.x;
P1y=P1y+p2.y;
P2x=P2x+p2.x;
P2y=P2y+p2.y;
CClientDC dc(
this
);
CPen pen,pen1,*oldpen;
pen.CreatePen(PS_SOLID, 2, RGB(0, 0, 0));
pen1.CreatePen(PS_SOLID, 2, RGB(0, 0, 255));
oldpen=dc.SelectObject(&pen);
dc.MoveTo(p1.x,p1.y);
dc.LineTo(p2.x,p2.y);
dc.SelectObject(&pen1);
dc.MoveTo(p2.x,p2.y);
dc.LineTo(P1x,P1y);
dc.MoveTo(p2.x,p2.y);
dc.LineTo(P2x,P2y);
dc.SelectObject(oldpen);
}