Sinusverlauf mit sich ändernder Frequenz

korona

Mitglied
Hallo zusammen,
ich das Problem, dass ich keinen Sinusverlauf mit sich linear ändernder (kleiner werdender) Frequenz hinbekomme.
Beginnen soll es mit 236px und einer Periode und dann linear bis zu einer Pixel 2360 immer kleiner werden.

Code:
import ij.*;
import ij.plugin.*;
import ij.process.*;
import ij.ImagePlus;
import ij.plugin.PlugIn;
import ij.process.ImageProcessor;
import ij.gui.*;
import java.awt.*;


public class Sinusverlauf_6 implements PlugIn{

    int width = 7016;
    int height = (int) (width/1.414);

    public void run(String arg){
    ImagePlus myImPlus = IJ.createImage("Sinusverlauf_6", "8-bit", width, height, 1);
    ImageProcessor ip = myImPlus.getProcessor();

        double a = 255.0/2;
        double p = 236;
        double c = 1;
        double d = 255.0/2;


        // funkioniert   ----------------------------------------------
        for (double i = 0; i <= 236; i+=0.1) {

            double wert2 =a*Math.sin((2*Math.PI/p)*i+Math.PI/c)+d;
            int sin2 = (int) wert2;
            Rectangle roib = ip.getRoi();
            ip.setRoi(roib);
            ip.setRoi((int)i,0 , 1,472);
            ip.setValue(sin2);
            ip.fill();
            ip.putPixel((int)i,sin2+600 , 0);
        }

        // funktioniert nicht ------------------------------------------------

        double length = 2360;
        double small = 236;
        double periods = (length/small)+1;

        for (double i = 0; i <= length; i +=0.1){
            for (int j = 0; j < periods; j++) {


            double wert2 =a*Math.sin((2*Math.PI*j/length)*i+Math.PI/c)+d;
            
            int sin2 = (int) wert2;
            Rectangle roib = ip.getRoi();
            ip.setRoi(roib);
            ip.setRoi((int)i,950 , 1,472);
            ip.setValue(sin2);
            ip.fill();
            ip.putPixel((int)i,sin2+1800 , 0);

            }
        }

    myImPlus.show();
    }
}

Das ist einer meiner Versuche.
Die einzelnen Frequenzen werden zwar gezeichnet aber alle übereinander und der S/W Verlauf zeigt auch nur eine Frequenz.

Gruß
 

Neue Beiträge

Zurück