在度数上找到一个圆点? [英] finding a dot on a circle by degree?

查看:87
本文介绍了在度数上找到一个圆点?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我们有一个100x100的坐标系,如下图所示. 0,0是它的左上角,50,50是它的中心点,100,100是它的右下角,依此类推.

Let's say we have a 100x100 coordinate system, like the one below. 0,0 is its left-top corner, 50,50 is its center point, 100,100 is its bottom right corner, etc.

现在,我们需要从中心向外画一条线.我们知道线的角度,但是需要计算其终点的坐标. 您认为什么是最好的方法?

Now we need to draw a line from the center outwards. We know the angle of the line, but need to calculate the coordinates of its end point. What do you think would be the best way to do it?

例如,如果直线的角度为45度,则其终点坐标大约为75,15.

For example, if the angle of the line is 45 degrees, its end point coordinates would be roughly 75,15.

推荐答案

您需要使用三角函数sincos.

You need to use the trigonometric functions sin and cos.

类似这样的东西:

theta = 45
// theta = pi * theta / 180      // convert to radians.
radius = 50
centerX = 50
centerY = 50
p.x = centerX + radius * cos(theta)
p.y = centerY - radius * sin(theta)

请记住,大多数实现假定您正在使用弧度,并且y指向正数.

Keep in mind that most implementations assume that you're working with radians and have positive y pointing upwards.

这篇关于在度数上找到一个圆点?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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