什麼你所談論的是一個unwrap
算法,從而推廣(不特定的號碼360 ......你能做到這一點與M = 2弧度* PI)。這裏有一個在javascript:
/* symmetric modulo:
* y = smod(x,m) = x+k*m where k is an integer,
* and y is always in the range [-0.5,0.5)*m
*/
function smod(x, m)
{
return x-((Math.floor(x/m + 0.5))*m);
}
/* unwrap:
* for all i, y[i] = x[i] + k*m where k is an integer,
* and for i > 0, the increment y[i]-y[i-1] is in the
* range [-0.5,0.5)*m as in smod().
*
* the "init" parameter is optional (default to 0)
* and specifies the starting value for the unwrap state.
*/
function unwrap(x, m, init)
{
var yi = init || 0;
var y = [];
for (i = 0; i < x.length; ++i)
{
yi += smod(x[i]-yi, m);
y[i] = yi;
}
return y;
}
下面是一個輸出樣本:
js>unwrap([100, 200, 348, 359, 23, 37, 46, 10, 350, 190], 360)
100,200,348,359,383,397,406,370,350,190
另一個具有m = 100:
js>unwrap([99,1,7,60,80,22,30,20,90,88,61,23,2,87,50,12], 100, 1000)
999,1001,1007,960,980,1022,1030,1020,990,988,961,923,902,887,850,812
供參考:在C /爪哇/等。存在用於比特擴展的類似算法,其中輸入例如是16比特並且輸出是32比特,並且環繞模數m = 65536 =輸入值的跨度。你並不需要一個「SMOD」功能,只需使用已簽名的數學:
typedef short int16_t;
typedef long int32_t;
// do typedefs as appropriate on your CPU
int32_t unwrap_extend(int32_t prev, int16_t input)
{
int16_t delta = input - prev;
return prev + delta;
}
我想我明白你的問題,但對輸入的短例子和期望的產出,將有助於澄清事情極大。 – 2010-03-23 14:00:18
你能提供更多關於你所擁有的數據的信息嗎?你能提供一些樣本數據嗎?每一段數據是輪換還是隱含輪換的新程度?我可以看到,作爲一個具有模糊性的人,除非每個數據之間的程度差異存在限制。編輯:+1 @法官打我:) – Cam 2010-03-23 14:00:47
什麼假設可以作出關於角度的變化率?換句話說,你測量什麼物理角度? – 2010-03-23 14:48:48