Originally posted by: Enrique
Hi,
your contribution is excellent.
don't you have a fragment of code to conect a arrow to a ellipse? naturally in the tangent between the ellipse and the line (arrow).
bye
ReplyOriginally posted by: Petko Popov
As I see in the code fragments, few people know the _hypot function... It is presumably more effective than the construction sqrt(x*x+y*y) (or else why would it be included in the C runtime library :)). And for sure it looks fancier in code.
ReplyOriginally posted by: Alfonso Bastias
Simply and excelent... Congratulation
Reply
Originally posted by: kavitha
when the window is maximized all r erased ??
Reply
Originally posted by: Gene Stolarov
Some time ago I had to do something similar.
That was in the days of the P60 and I didn't
want to use sin/cos.
Here is a version without it:
void CArrowView::DrawArrow(CDC *pDC, CPoint from, CPoint to)
{ int Wings = 20;
CPoint dlta(to.x - from.x, to.y - from.y);
int len = int(sqrt(dlta.x * dlta.x + dlta.y * dlta.y));
if (!len) len = 1;
double mltpl = double(Wings) / double(len);
CPoint A(to.x - int(mltpl * dlta.x), to.y - int(mltpl * dlta.y));
CPoint pts[3];
pts[0] = to;
mltpl /= 2;
pts[1] = CPoint(A.x - int(mltpl * dlta.y), A.y + int(mltpl * dlta.x));
pts[2] = CPoint(A.x + int(mltpl * dlta.y), A.y - int(mltpl * dlta.x));
pDC->Polygon(pts, 3);
}
Originally posted by: Vladimir N
Add 0.5 in all arguments' expressions of LineTo and MoveTo
Such a way it will ROUND(!!!) the value:
LineTo(2.999, 3.9999) now is drawn as LineTo(2, 3)
and
LineTo(2.999+0.5, 3.9999+0.5) is drawn as LineTo(3, 4)
Originally posted by: Petko Popov
Nice job.
There's a large number of possible enhancements, which doesn't take anything from the merits of the original article.
- It can be required to draw an arrow at one of the ends.
- It can be required to draw open arrows or solid arrows.
- It can be required that the size of the arrow is scaled to the size of the line.
- There are some sub-expressions that can be calculated in intermediate variables to improve speed.
- To get extreme performance, it is possible to pre-calculate the values of the sin/arctan functions in static tables (for atan2 there must be a logic that will handle the limit values). Since the arrows are small, roundoff errors are not an issue.