How do I calculate a point on a ellipse’s circumference?

吃可爱长大的小学妹 提交于 2019-12-22 11:35:23

问题


I want to plot a point in elliptical curve in J2ME

I have values for X,Y,width,height and t.

X and Y are the position of the ellipse(according to J2ME) with respect to Canvas and t is angle with respect to the center of ellipse(I have an image representation of the problem , but unfortunate blog is not allowing to insert into discussion :) )

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

Is this equation correct? or for ellipse do we need to have some more calculations?


回答1:


If ( X, Y ) is the center of the ellipse, and width and height are the two axes, then the equation should be

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

The -1 multiplication to Math.sin is unnecessary if you have all t to draw the entire ellipse.



来源:https://stackoverflow.com/questions/9411861/how-do-i-calculate-a-point-on-a-ellipse-s-circumference

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!