比对了网上一些旋转门算法的代码实现,总觉得跟原文表达的不一样,应该有很多前辈实现了,请帮忙解惑下。看到的原文如下:
One of the lines is drawn from the last recorded value plus 8 through whichever value maximizes the slope of the line. This is the top dotted line in Figure 2. The other dotted line is drawn from the last recorded value minus 8 through whichever value minimizes the slope of the line. The third line is drawn between the last recorded value and the new value. This is the solid line in Figure 2. The previous value is recorded if the slope of the top dotted line is greater than the slope of the solid line or the slope of the solid line is greater than the slope of the bottom dotted line.
我的理解是:假设E = 8,当前值为CurVal,上一个保存的值为LastVal,当前值的前一个值为LastVal
K1 = (CurVal - (LastSave+E))/(CurTime - LastSaveTime)(取最大值)
K2 = (CurVal - (LastSave - E))/(CurTime - LastSaveTime)(取最小值)
K = (CurVal - LastSave)/(CurTime - LastSaveTime)
如果K1>K或K>K2 保存LastVal的值 。
另外还有一个问题:第一个值(Val1)是要保存的,此时K1,K是不是应该根据第二个值(Val2)更新为:
K1 = (Val2- (Val1+E))/(Val2Time- ValTime
K2 = (Val2- (Val1- E))/(Val2Time- ValTime)
以上两个问题请高手帮忙澄清下。谢谢!
------解决方案--------------------------------------------------------
问题太简单了还是没描述清除呢,怎么没人回复呢。