标题翻译
Drawing a ellipse using parametric equations in Java
问题
我尝试了下面的代码,但它并没有按预期工作,请帮忙。
for(int i = 0; i < 20; i++){
double angle = i * 2 * Math.PI / 20;
int rdif = (int) Math.round(yradius * Math.cos(angle));
int row = ycenter + rdif;
int cdif = (int) Math.round(xradius * Math.sin(angle));
int col = xcenter + cdif;
index[row][col] = '*';
}
xcenter 是 10,
ycenter 是 10,
xradius 是 5,
yradius 是 3
请查看输出图像:
<img src="https://i.stack.imgur.com/L9WqI.png" width="300">
英文翻译
I am trying code below but it is not working as expected, please help.
for(int i =0;i<20;i++){
double angle = i * 2 * Math.PI/20;
int rdif = (int) Math.round(yradius * Math.cos(angle));
int row = ycenter + rdif;
int cdif = (int) Math.round(xradius * Math.sin(angle));
int col = xcenter + cdif;
index[row][col] = '*';
}
xcenter is 10,
ycenter is 10,
xradius is 5,
yradius is 3
Check the image for output:
<img src="https://i.stack.imgur.com/L9WqI.png" width="300">
专注分享java语言的经验与见解,让所有开发者获益!
评论