查找与给定的中心点,半径和程度了一圈点 [英] Find the point on a circle with given center point, radius, and degree

查看:304
本文介绍了查找与给定的中心点,半径和程度了一圈点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

它已有10年我做任何这样的数学......我编程的2D游戏和移动的球员。当我移动玩家身边我试图来计算一个圆圈点从给定-360之间的正面或负面的角度(度)到360的球员的位置,屏幕为1280x720 200像素废除0,0为中心点屏幕。围绕这整个笛卡尔的球员动作坐标系。点我努力试图找到可以关闭屏幕。

It's been 10 years since I did any math like this... I am programming a game in 2D and moving a player around. As I move the player around I am trying to calculate the point on a circle 200 pixels away from the player position given a positive OR negative angle(degree) between -360 to 360. The screen is 1280x720 with 0,0 being the center point of the screen. The player moves around this entire Cartesian coordinate system. The point I am trying trying to find can be off screen.

我试过文章查找半径点和角度,但我不相信我理解什么是角,是因为我得到奇怪的结果当我通过角360到360到COS(角度)或仙(角度)。

I tried the formulas on article Find the point with radius and angle but I don't believe I am understanding what "Angle" is because I am getting weird results when I pass Angle as -360 to 360 into a Cos(angle) or Sin(angle).

例如,我有...


    在笛卡尔平面
  • 1280×720

  • 中心点(播放器的位置):

    • 令x =最小-640之间的一个数到最大640

    • 让Y =最低-360之间的一个数到最大360

    什么是上一圈返回X的公式?

    什么是上一圈返回Y中的公式?


    推荐答案

    您已经链接给X和Y圆上的相对于圆心<坐标点的简单的公式/ EM >。

    The simple equations you've linked to give the X and Y coordinates of the point on the circle relative to the center of the circle.

    X = R *余弦值(角度)结果
    Y = R *正弦值(角度)

    X = r * cosine(angle)
    Y = r * sine(angle)

    这将告诉您如何远点从圆的中心偏移。既然你有中心(X 圈子,Y <子>圈子),只需添加计算的偏移。

    This tells you how far the point is offset from the center of the circle. Since you have the coordinates of the center (xcircle, ycircle), simply add the calculated offset.

    点的圆上的坐标是:

    X = X 圈子 +(R *余弦(角度))结果
    Y = Y 圈子 +(R *正弦值(角度))

    X = xcircle + (r * cosine(angle))
    Y = ycircle + (r * sine(angle))

    这篇关于查找与给定的中心点,半径和程度了一圈点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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