Drawing a line given the angle and a point on the line

柔情痞子 提交于 2019-12-06 07:56:04

Note that used line equation "in intercept segments" is not universal - does not work for horizontal and vertical lines. With intercept approach cases 0, Pi/2, Pi, 3*Pi/2 or -Pi/2 must be treated separately.

If you arrow_angle is for blue line:

c = -Sin(arrow_angle)
s = Cos(arrow_angle)

If you arrow_angle is for red line:

c = Cos(arrow_angle)
s = Sin(arrow_angle)

Then draw line through points

 (x1 - c * 4096, y1  - s * 4096) and (x1 + c * 4096, y1  + s * 4096)

(I used arbitrary large constant comparable with screen size)

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!