列车位置计算浮点数误差
This commit is contained in:
parent
2e3fc1a1f2
commit
bdefc71cef
@ -1 +1 @@
|
||||
Subproject commit 56e1948393aa51e0bf16d754292a211f348df161
|
||||
Subproject commit e4c55ea4b6f9f5f875d59fc5bba51fc21bc8ef97
|
@ -637,9 +637,10 @@ export class Train extends JlGraphic {
|
||||
}
|
||||
const offset = this.states.headOffset / allLength; // 百分比偏移
|
||||
let offsetL = totalLength * offset;
|
||||
// 0.01为保证浮点数计算误差
|
||||
const indexP = lengths.findIndex((l) => {
|
||||
offsetL -= l;
|
||||
return offsetL <= 0;
|
||||
return offsetL <= 0.001;
|
||||
});
|
||||
const startP = points[indexP];
|
||||
const endP = points[indexP + 1];
|
||||
|
Loading…
Reference in New Issue
Block a user