极客工坊

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 9583|回复: 0

三轴加速度曲线

[复制链接]
发表于 2013-9-5 16:08:59 | 显示全部楼层 |阅读模式
我在processing中,通过串口读数据,画图,得出来的结果是这样。这是为什么么?
代码是:
RawX[RawX.length-1] = Sensor_X;
  RawY[RawY.length-1] = Sensor_Y;   // place the new raw datapoint at the end of the array
  RawZ[RawZ.length-1] = 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[i] = RawX[i+1];                         // shifting all raw datapoints one pixel left
    float dummy = RawX[i] * zoom + offset;       // adjust the raw data to the selected scale
    ScaledX[i] = 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[i] = RawY[i+1];                         // shifting all raw datapoints one pixel left
    float dummy = RawY[i] * zoom + offset;       // adjust the raw data to the selected scale
    ScaledY[i] = 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[i] = RawZ[i+1];                         // shifting all raw datapoints one pixel left
    float dummy = RawZ[i] * zoom + offset;       // adjust the raw data to the selected scale
    ScaledZ[i] = 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 < RawX.length-1;x++) {
    stroke(255,0,0);     
    vertex(x+10, ScaledX[x]);
  }
  endShape();
    beginShape();                                  // using beginShape() renders fast
  for (int x = 1; x < RawY.length-1;x++) {
    stroke(0,255,0);     
    vertex(x+10, ScaledY[x]);
  }
  endShape();
    beginShape();                                  // using beginShape() renders fast
  for (int x = 1; x < RawZ.length-1;x++) {
    stroke(0,0,255);     
    vertex(x+10, ScaledZ[x]);
  }
  endShape();



本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?注册

x
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则 需要先绑定手机号

Archiver|联系我们|极客工坊

GMT+8, 2024-4-19 13:11 , Processed in 0.048717 second(s), 18 queries .

Powered by Discuz! X3.4 Licensed

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表