Tim*_*Tim 4 javascript java opengl drawing jogl
我使用这种方法完美地绘制一个完整的圆圈(可能是我从内存中写入的代码文本中的拼写错误):
drawCircle(GLAutodrawble drawble){
GL gl = drawble.getGL();
gl.glTranslatef(0.0f,0.0f,-7.0f);
gl.glBeginf(GL_LINE_LOOP);
gl.glColorf(0.0f,0.0f,0.0);
final dobule PI = 3.141592654;
double angle = 0.0;
int points = 100;
for(int i =0; i < points;i++){
angle = 2 * PI * i / points;
gl.glVertexf((float)Math.cos(angle),(float)Math.sin(angle));
}
gl.glScalef(1.0f,1.0f,0.0f);
gl.glEnd();
}
Run Code Online (Sandbox Code Playgroud)
我想使用相同的原则来制作一个半圈的方法,我不知道我应该怎么做cos sin的东西.任何人都可以看看并帮助我.
谢谢所有想看看问题的人!
替换:
angle = 2 * PI * i / points;
Run Code Online (Sandbox Code Playgroud)
用:
angle = PI * i / points;
Run Code Online (Sandbox Code Playgroud)
注意我删除了2乘法器,因为2*PI是360(以度为单位),这是一个完整的圆.PI(180度)是半圈
| 归档时间: |
|
| 查看次数: |
9271 次 |
| 最近记录: |