以角度vb.net绘制线 [英] Drawing lines at angle vb.net

查看:94
本文介绍了以角度vb.net绘制线的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以在vb.net上找到很多关于如何画线的示例.

I can find plenty of examples of how to draw a line in vb.net online.

但是我找不到关于如何以特定角度绘制线条的任何示例.

I however I cannot find any examples of how to draw lines at a specific angle.

有人可以告诉我该怎么做吗?

Could someone tell me how to do this?

推荐答案

您需要使用sin/cos进行一些数学运算.

You'll need to do a bit of math using sin/cos.

x1y1 =行的起始位置
angleInRadians =转换为弧度的直线上的角度

x1, y1 = starting position of line
angleInRadians = angle on the line converted to Radians

x2 = lineLength * Math.Cos(angleInRadians) + x1
y2 = lineLength * Math.Sin(angleInRadians) + y1

然后您可以从(x1y1)到(x2y2)画一条线.

Then you can draw a line from (x1, y1) to (x2, y2).

这篇关于以角度vb.net绘制线的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆