您现在的位置是:主页 > news > 东莞网站建设曼哈顿信科/网推软件有哪些

东莞网站建设曼哈顿信科/网推软件有哪些

admin2025/6/6 5:49:23news

简介东莞网站建设曼哈顿信科,网推软件有哪些,html淘宝店铺网站模板,宜昌做网站公司有哪些方法今天中午,大家都在睡觉的时候,本人忙里偷闲找了点资料看了下,箭头算法终于到了最终版本了。非常感谢各位前辈在网上的资料,特别是MFC,JAVA的资料比较多。这里终于也可以告一段落了。 以下是C#的箭头算法,源代码如下&am…

东莞网站建设曼哈顿信科,网推软件有哪些,html淘宝店铺网站模板,宜昌做网站公司有哪些方法今天中午,大家都在睡觉的时候,本人忙里偷闲找了点资料看了下,箭头算法终于到了最终版本了。非常感谢各位前辈在网上的资料,特别是MFC,JAVA的资料比较多。这里终于也可以告一段落了。 以下是C#的箭头算法,源代码如下&am…

      今天中午,大家都在睡觉的时候,本人忙里偷闲找了点资料看了下,箭头算法终于到了最终版本了。非常感谢各位前辈在网上的资料,特别是MFC,JAVA的资料比较多。这里终于也可以告一段落了。

      以下是C#的箭头算法,源代码如下:

 1         /// <summary>
 2         /// 绘制箭头
 3         /// </summary>
 4         /// <param name="graphics"></param>
 5         /// <param name="startPoint">起始点</param>
 6         /// <param name="endPoint">终止点</param>
 7         private void DrawArrowHead(Graphics graphics, PointF startPoint, PointF endPoint)
 8         {
 9             double distance = Math.Abs(Math.Sqrt(
10                 (startPoint.X - endPoint.X) * (startPoint.X - endPoint.X) +
11                 (startPoint.Y - endPoint.Y) * (startPoint.Y - endPoint.Y)));
12 
13             if (distance == 0)
14             {
15                 return;
16             }
17 
18             double xa = endPoint.X + ArrowLength * ((startPoint.X - endPoint.X)
19                 + (startPoint.Y - endPoint.Y) / RelativeValue) / distance;
20             double ya = endPoint.Y + ArrowLength * ((startPoint.Y - endPoint.Y)
21                 - (startPoint.X - endPoint.X) / RelativeValue) / distance;
22             double xb = endPoint.X + ArrowLength * ((startPoint.X - endPoint.X)
23                 - (startPoint.Y - endPoint.Y) / RelativeValue) / distance;
24             double yb = endPoint.Y + ArrowLength * ((startPoint.Y - endPoint.Y)
25                 + (startPoint.X - endPoint.X) / RelativeValue) / distance;
26 
27             PointF[] polygonPoints =
28                 new PointF(endPoint.X , endPoint.Y), 
29                 new PointF( (float)xa   ,  (float)ya),
30                 new PointF( (float)xb   ,  (float)yb)};
31 
32             DrawArrowHead(graphics, polygonPoints);
33         }

 

 

1         private static void DrawArrowHead(Graphics graphics, PointF[] points)
2         {
3             graphics.DrawPolygon(Pens.Red, points);
4             graphics.FillPolygon(new SolidBrush(Color.Red), points);
5         }

 

 

      具体是通过终点Point的坐标,以及计算出的2个角的坐标,然后通过绘制多边形来绘制箭头。

 

显示效果如下:

 

       这个已经是最终版本的算法,误差几乎可以忽略。上面的方法是可以调用的,大家可以试下,希望能够对各位有所帮助..........