11721206 发表于 2013-9-5 11:09:50

processing动态画三个轴的曲线

RawX = Sensor_X;
RawY = Sensor_Y;   // place the new raw datapoint at the end of the array
RawZ = Sensor_Z;
zoom = scaleBar.getPos();                      // get current waveform scale value
offset = map(zoom,0.5,1,300,0);                // calculate the offset needed at this scale
for (int i = 0; i < RawX.length-1; i++) {      // move the pulse waveform by
    RawX = RawX;                         // shifting all raw datapoints one pixel left
    float dummy = RawX * zoom + offset;       // adjust the raw data to the selected scale
    ScaledX = constrain(int(dummy),44,556);   // transfer the raw data array to the scaled array
}

       for (int i = 0; i < RawY.length-1; i++) {      // move the pulse waveform by
    RawY = RawY;                         // shifting all raw datapoints one pixel left
    float dummy = RawY * zoom + offset;       // adjust the raw data to the selected scale
    ScaledY = constrain(int(dummy),44,556);   // transfer the raw data array to the scaled array
}
    for (int i = 0; i < RawZ.length-1; i++) {      // move the pulse waveform by
    RawZ = RawZ;                         // shifting all raw datapoints one pixel left
    float dummy = RawZ * zoom + offset;       // adjust the raw data to the selected scale
    ScaledZ = constrain(int(dummy),44,556);   // transfer the raw data array to the scaled array
}




stroke(250,0,0);                               // red is a good color for the pulse waveform
noFill();
beginShape();                                  // using beginShape() renders fast
for (int x = 1;x<ScaledY.length-1;x++) {
   stroke(250,0,0);   
    vertex(x+1,ScaledX);

    stroke(0,255,0);
    vertex(x, ScaledY);
    stroke(0,0,255);
    vertex(x+10, ScaledZ);
    //draw a line connecting the data points
//    line(y, RawY,y+1,RawY);
//    line(z, RawZ,z+1,RawZ);
}






结果是这样。每次画两个轴以上就会出现前面的轴不显示,并且都是这么的密集!!
求大神解答,该如何改代码!thx













页: [1]
查看完整版本: processing动态画三个轴的曲线