在椭圆的边缘移动对象 [英] Move an object on the edge of an ellipse

查看:92
本文介绍了在椭圆的边缘移动对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一些绘画问题.

我代表一个具有X和Y坐标的对象.我想在一个椭圆(一个圆)的边缘上移动这个对象.我想知道的是这种方法,我需要在每次更新中对这些X和Y值进行处理,以使其看起来像是圆周运动.

I represent an object with an X and a Y coordinate. I would like to move this object around on the edge of an ellipse (a circle). What i would like to know, is the method, what i need to do with theese X and Y values in every update, to look like a circular movement.

我希望它不会重复(我尝试过每个关键字,我能想到的).任何帮助将不胜感激!

I hope it's not a duplicate (I tried every keyword, what i could think of). Any help would be appreciated!

推荐答案

parameter 以原点为中心的椭圆的方程式为:

The parametric equations for an ellipse centred at the origin are:

x = A * cos(t)
y = B * sin(t)

因此,在每一帧上,将t的当前值插入这些方程式,即可获得所需的坐标.

So on every frame, you plug the current value of t into those equations, and you get the required coordinates.

这篇关于在椭圆的边缘移动对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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