【问题标题】:How to calculate coordinates of the gunpoint如何计算枪口的坐标
【发布时间】:2017-11-03 23:26:25
【问题描述】:

一天中的任何时候都很好!我有一些精灵:

A 点的坐标为Actor.x; Actor.y

AB length = 96
BC length = 86
AC length = 42

All calculations are approximate, I made it with help the ruler in Photoshop.

Sprite 始终朝向鼠标,角度(以弧度为单位)存储在 Actor.direction 变量中。我用比例绘制精灵0.3

所有子弹都指向鼠标(即Bullet.direction == Actor.direction)。我需要在B 点创建项目符号。如何计算任意角度的B 点的坐标?

UPD

如果我要在坐标中创建子弹:

x = Actor.x + 96 * math.cos(Actor.direction) * 0.3
y = Actor.y + 96 * math.sin(Actor.direction) * 0.3

我明白了:

请原谅我的英语不好!这不是我的母语。提前谢谢!

【问题讨论】:

    标签: math geometry love2d


    【解决方案1】:

    cs = math.cos(Actor.direction)
    sn = math.sin(Actor.direction)
    

    点 B 将从 A 移动

    dx = - 42 * sn + 86 * cs
    dy = 42 * cs + 86 * sn
    

    也许你需要在两个 42 岁之前换星座

    (我没有考虑规模)

    【讨论】:

    • 非常感谢!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-10-25
    • 1970-01-01
    • 2023-01-29
    • 2015-06-17
    • 2014-05-12
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多