通过贝塞尔曲线移动物体,结合旋转

发布于 2024-12-15 18:22:25 字数 260 浏览 4 评论 0原文

我的引擎 (AndEngine) 提供了通过贝塞尔曲线路径移动对象的修改器,只需提供 3 或 4 点坐标即可。

在我的比赛中,我会用确定的三分来移动一些小鸟。然而,它看起来很假,因为鸟总是指向一个方向。

这看起来像是一个数学问题,但我认为我应该在 StackOverflow 上发布而不是 Math Exchange:How to certain therotationangle (in radian or Degree) for the Birds at a time?

My engine (AndEngine) provides the modifier to move an object by Bezier Curve path, just by providing 3 or 4 points co-ordinate.

In my game, I move some birds with determined 3 points. However, it looks fake because the birds always point to a direction.

This looks like a mathematical question, but I think I should post at StackOverflow instead of Math Exchange: How to determine the rotation angle (in radian or degree) for the birds at a time?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

玻璃人 2024-12-22 18:22:25

您将取两个点,例如 P1 和 P2,并找到它们之间的角度,然后以该角度旋转您的鸟,

    deltaX = nextPointX - YourBirdX;
    deltaY = NextPointY - YourBirdY;
    degree = ((Math.atan2(deltaY, deltaX)));
    angle = degree * 180 / 3.14;

    if(angle<0)
    {
        angle = 360+angle;
    }

我希望这会对您有所帮助。

You will take two points say P1 and P2 and will find the angle between them and then rotate you bird on that angle

    deltaX = nextPointX - YourBirdX;
    deltaY = NextPointY - YourBirdY;
    degree = ((Math.atan2(deltaY, deltaX)));
    angle = degree * 180 / 3.14;

    if(angle<0)
    {
        angle = 360+angle;
    }

I hope this will help you.

感受沵的脚步 2024-12-22 18:22:25

(bezier(path,position + epsilon) - bezier(path,position))/epsilon怎么样?或者,如果您想要不带 epsilon 的值,请查找贝塞尔曲线的一阶导数。

What about (bezier(path, position + epsilon) - bezier(path, position)) / epsilon? Or, if you want it without the epsilon, look up the first derivation of a bezier curve.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文