Как нарисовать синусоиду


import org.junit.*;
import static org.junit.Assert.*;
import org.bytedeco.javacv.*;
import org.bytedeco.javacpp.*;
import java.io.*;
import java.util.Locale;
import static org.bytedeco.javacpp.opencv_core.*;
import static org.bytedeco.javacpp.opencv_imgproc.*;
import static org.bytedeco.javacpp.opencv_calib3d.*;
import static org.bytedeco.javacpp.opencv_objdetect.*;
import static org.bytedeco.javacpp.opencv_highgui.*;

public class Sinusoid {
    private static final int worldSize[] = { 1200, 800 };

    @Test
    public void drawSineWave() throws Exception
    {
        IplImage canvas = IplImage.create(worldSize[0], worldSize[1], IPL_DEPTH_8U, 3);
        cvZero(canvas);
        CvPoint pt1 = null, pt2 = null;
        for (int x = 0; x < worldSize[0]; x++)
        {
            pt1 = pt2;
            int amplitude = worldSize[1] / 9;
            int y = (int)(Math.sin(x * Math.PI / 180) * amplitude) + (worldSize[1] / 2);
            pt2 = cvPoint(x, y);
            if (pt1 != null && pt2 != null)
            {
                cvLine(canvas, pt1, pt2, CV_RGB(255, 255, 255), 2, CV_AA, 0);
            }
        }
        if (canvas != null) {
            cvSaveImage("canvas.png", canvas);
            cvReleaseImage(canvas);
        }
    }
}


P.S. Движение по синусоиде ничем не отличается от движения по косинусоиде.


        int half = worldSize[1] / 2;
        cvLine(canvas, cvPoint(0, half), cvPoint(worldSize[0] - 1, half), CV_RGB(255, 255, 255), 2, CV_AA, 0);

        int amplitude = worldSize[1] / 9;
        cvLine(canvas, cvPoint(0, amplitude + half), cvPoint(worldSize[0] - 1, amplitude + half), CV_RGB(0, 255, 0), 2, CV_AA, 0);
        cvLine(canvas, cvPoint(0, -amplitude + half), cvPoint(worldSize[0] - 1, -amplitude + half), CV_RGB(0, 255, 0), 2, CV_AA, 0);

        CvPoint pt1 = null, pt2 = null;
        for (int x = 0; x < worldSize[0]; x += 20)
        {
            pt1 = pt2;
            double radians = x * Math.PI / 180;
            int y = (int)(Math.sin(radians) * amplitude) + half;
            pt2 = cvPoint(x, y);
            if (pt1 != null && pt2 != null)
            {
                cvCircle(canvas, cvPoint((int) (x), (int) (y)), 3, CV_RGB(255, 0, 0), CV_FILLED, 8, 0);
            }
        }