3

我想在 J2ME 的椭圆曲线上绘制一个点

我有 X、Y、宽度、高度和 t 的值。

XY是椭圆(根据 J2ME)相对于 Canvas 的位置, t是相对于椭圆中心的角度(我有一个问题的图像表示,但不幸的是博客不允许插入讨论: ) )

int ePX = (X + width)+ (int) (width * Math.cos(Math.toRadians(t)));
int ePY = (Y + height)+ (int) (height * -Math.sin(Math.toRadians(t)));

这个等式正确吗?或者对于椭圆,我们需要更多的计算吗?

4

1 回答 1

11

如果( X, Y ) 是椭圆的中心,宽度和高度是两个轴,那么方程应该是

int ePX = X + (int) (width  * Math.cos(Math.toRadians(t)));
int ePY = Y + (int) (height * Math.sin(Math.toRadians(t)));

如果您t要绘制整个椭圆,则不需要对 Math.sin 进行 -1 乘法。

于 2012-02-23T11:33:32.657 回答