Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
timeDelta = currentTime - lastTime;
// If more than a certain amount of time exists between 2 commands, add a command to stop after the last
if (timeDelta > 10000) {
commands.set(lastTime + timeDelta + 1, [new VorzeA10CycloneCmd(0, true)]);
}
// We still need to calulate the Launch speed from the commands to set vorze speed.
positionDelta = Math.abs(currentPosition - lastPosition);
speed = Math.floor(25000 * Math.pow(((timeDelta * 90) / positionDelta), -1.05));
commands.set(currentTime, [new VorzeA10CycloneCmd(speed, lastPosition > currentPosition)]);
lastTime = currentTime;
lastPosition = currentPosition;
}
// Make sure we stop the Vorze at the end
commands.set(lastTime + 100, [new VorzeA10CycloneCmd(0, true)]);
return commands;
}
for (const aCommand of aCommands) {
currentTime = aCommand.Time;
currentPosition = aCommand.Position;
timeDelta = currentTime - lastTime;
// If more than a certain amount of time exists between 2 commands, add a command to stop after the last
if (timeDelta > 10000) {
commands.set(lastTime + timeDelta + 1, [new VorzeA10CycloneCmd(0, true)]);
}
// We still need to calulate the Launch speed from the commands to set vorze speed.
positionDelta = Math.abs(currentPosition - lastPosition);
speed = Math.floor(25000 * Math.pow(((timeDelta * 90) / positionDelta), -1.05));
commands.set(currentTime, [new VorzeA10CycloneCmd(speed, lastPosition > currentPosition)]);
lastTime = currentTime;
lastPosition = currentPosition;
}
// Make sure we stop the Vorze at the end
commands.set(lastTime + 100, [new VorzeA10CycloneCmd(0, true)]);
return commands;
}