在椭圆的边缘移动对象 [英] Move an object on the edge of an ellipse
问题描述
我有一些绘画问题.
我代表一个具有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!
推荐答案
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屋!