예전 학창시절에 만들었던건데.. 자료가 있길래 올려본다.

class SC_Arrow
{
public:
dxy_t sc_Begin, sc_End;
double sc_Angle;
dxy_t sc_LeftPoint, sc_RightPoint;
dxy_t sc_Increasement;
public:
SC_Arrow() {}
SC_Arrow(dxy_t Begin,dxy_t End,CDC* pDC,float Angle = 20.)
{
sc_Begin = Begin;
sc_End = End;
sc_Angle = Angle/180*PI;

sc_Increasement.x = (sc_End.x - sc_Begin.x)*(-1./10.);
sc_Increasement.y = (sc_End.y - sc_Begin.y)*(-1./10.);


sc_LeftPoint.x = cos(sc_Angle)*sc_Increasement.x - sin(sc_Angle)*sc_Increasement.y;
sc_LeftPoint.y = sin(sc_Angle)*sc_Increasement.x + cos(sc_Angle)*sc_Increasement.y;
sc_LeftPoint.x = sc_LeftPoint.x + sc_End.x;
sc_LeftPoint.y = sc_LeftPoint.y + sc_End.y;
sc_RightPoint.x = cos(sc_Angle)*sc_Increasement.x + sin(sc_Angle)*sc_Increasement.y;
sc_RightPoint.y = -sin(sc_Angle)*sc_Increasement.x + cos(sc_Angle)*sc_Increasement.y;
sc_RightPoint.x = sc_RightPoint.x + sc_End.x;
sc_RightPoint.y = sc_RightPoint.y + sc_End.y;

pDC->MoveTo(long(sc_Begin.x+0.5), long(sc_Begin.y+0.5));
pDC->LineTo(long(sc_End.x+0.5), long(sc_End.y+0.5));
pDC->LineTo(long(sc_LeftPoint.x+0.5), long(sc_LeftPoint.y+0.5));
pDC->MoveTo(long(sc_End.x+0.5), long(sc_End.y+0.5));
pDC->LineTo(long(sc_RightPoint.x+0.5),long(sc_RightPoint.y+0.5));
}
SC_Arrow(CPoint Begin,CPoint End,CDC* pDC,float Angle = 20.)
{
sc_Begin.x = Begin.x;
sc_Begin.y = Begin.y;
sc_End.x = End.x;
sc_End.y = End.y;
sc_Angle = Angle/180*PI;

sc_Increasement.x = (sc_End.x - sc_Begin.x)*(-1./10.);
sc_Increasement.y = (sc_End.y - sc_Begin.y)*(-1./10.);


sc_LeftPoint.x = cos(sc_Angle)*sc_Increasement.x - sin(sc_Angle)*sc_Increasement.y;
sc_LeftPoint.y = sin(sc_Angle)*sc_Increasement.x + cos(sc_Angle)*sc_Increasement.y;
sc_LeftPoint.x = sc_LeftPoint.x + sc_End.x;
sc_LeftPoint.y = sc_LeftPoint.y + sc_End.y;
sc_RightPoint.x = cos(sc_Angle)*sc_Increasement.x + sin(sc_Angle)*sc_Increasement.y;
sc_RightPoint.y = -sin(sc_Angle)*sc_Increasement.x + cos(sc_Angle)*sc_Increasement.y;
sc_RightPoint.x = sc_RightPoint.x + sc_End.x;
sc_RightPoint.y = sc_RightPoint.y + sc_End.y;

pDC->MoveTo(long(sc_Begin.x+0.5), long(sc_Begin.y+0.5));
pDC->LineTo(long(sc_End.x+0.5), long(sc_End.y+0.5));
pDC->LineTo(long(sc_LeftPoint.x+0.5), long(sc_LeftPoint.y+0.5));
pDC->MoveTo(long(sc_End.x+0.5), long(sc_End.y+0.5));
pDC->LineTo(long(sc_RightPoint.x+0.5),long(sc_RightPoint.y+0.5));
}
SC_Arrow(double Beginx,double Beginy,double Endx,double Endy ,CDC* pDC,float Angle = 20.)
{
sc_Begin.x = Beginx;
sc_Begin.y = Beginy;
sc_End.x = Endx;
sc_End.y = Endy;
sc_Angle = Angle/180*PI;

sc_Increasement.x = (sc_End.x - sc_Begin.x)*(-1./10.);
sc_Increasement.y = (sc_End.y - sc_Begin.y)*(-1./10.);


sc_LeftPoint.x = cos(sc_Angle)*sc_Increasement.x - sin(sc_Angle)*sc_Increasement.y;
sc_LeftPoint.y = sin(sc_Angle)*sc_Increasement.x + cos(sc_Angle)*sc_Increasement.y;
sc_LeftPoint.x = sc_LeftPoint.x + sc_End.x;
sc_LeftPoint.y = sc_LeftPoint.y + sc_End.y;
sc_RightPoint.x = cos(sc_Angle)*sc_Increasement.x + sin(sc_Angle)*sc_Increasement.y;
sc_RightPoint.y = -sin(sc_Angle)*sc_Increasement.x + cos(sc_Angle)*sc_Increasement.y;
sc_RightPoint.x = sc_RightPoint.x + sc_End.x;
sc_RightPoint.y = sc_RightPoint.y + sc_End.y;

pDC->MoveTo(long(sc_Begin.x+0.5), long(sc_Begin.y+0.5));
pDC->LineTo(long(sc_End.x+0.5), long(sc_End.y+0.5));
pDC->LineTo(long(sc_LeftPoint.x+0.5), long(sc_LeftPoint.y+0.5));
pDC->MoveTo(long(sc_End.x+0.5), long(sc_End.y+0.5));
pDC->LineTo(long(sc_RightPoint.x+0.5),long(sc_RightPoint.y+0.5));
}
};

+ Recent posts