Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/opengl/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
OpenGL-jogl中的正弦波和余弦波(JAVA)_Java_Opengl_Jogl_Trigonometry - Fatal编程技术网

OpenGL-jogl中的正弦波和余弦波(JAVA)

OpenGL-jogl中的正弦波和余弦波(JAVA),java,opengl,jogl,trigonometry,Java,Opengl,Jogl,Trigonometry,我正试图编码一个正弦和余弦波来显示在我的面板上。我正在我的EventListener类中尝试创建一个方法drawCurves 曲线GleventListener: package firstAttempt; import javax.media.opengl.GL; import javax.media.opengl.GLAutoDrawable; import javax.media.opengl.GLEventListener; import javax.media.opengl.glu.

我正试图编码一个正弦和余弦波来显示在我的面板上。我正在我的EventListener类中尝试创建一个方法drawCurves

曲线GleventListener:

package firstAttempt;

import javax.media.opengl.GL;
import javax.media.opengl.GLAutoDrawable;
import javax.media.opengl.GLEventListener;
import javax.media.opengl.glu.GLU;

/**
 * For now we will focus only two of the GLEventListeners init() and display().
 */
public class CurvesGLEventListener implements GLEventListener {

    /**
     * Interface to the GLU library.
     */
    private GLU glu;

    /**
     * Take care of initialization here.
     */
    public void init(GLAutoDrawable drawable) {
        GL gl = drawable.getGL();
        glu = new GLU();

        gl.glClearColor(0.0f, 0.0f, 0.0f, 1.0f);

        gl.glViewport(0, 0, 900, 550);
        gl.glMatrixMode(GL.GL_PROJECTION);
        gl.glLoadIdentity();
        glu.gluOrtho2D(0.0, 900.0, 0.0, 550.0);
    }

    /**
     * Take care of drawing here.
     */
    public void display(GLAutoDrawable drawable) {

        GL gl = drawable.getGL();

        drawCurves();

    }

    public void reshape(GLAutoDrawable drawable, int x, int y, int width,
            int height) {
    }

    public void displayChanged(GLAutoDrawable drawable,
            boolean modeChanged, boolean deviceChanged) {
    }
    private void drawCurves() {
            /**
             * Here is where I need to implement the method
             **/
    }
}
有人建议我,基于这种观点,我应该使用以下方法绘制波浪图:

(x, (Math.sin(x/60.0)*100.0))
(x, (Math.cos(x/60.0)*100.0))

你能帮我实现这个方法吗?一个好主意似乎是,该方法使用一个参数,例如int whichOne来声明每次绘制的波。

好吧,我不打算为您编写代码,但是,似乎有一个使用贝塞尔样条线的可行方法。当然它在Lua中,但是您应该能够将它转换为java方法