python - VPython 上的数组中的延迟信息
问题描述
我正在做一个项目,我将角度值临时存储到一个数组中,在视觉模拟中使用它们,然后在显示更新后删除这些值。
我正在尝试创建相同值的相同数组,但是我希望它们延迟一定的量(我希望该量是可变的)。我该怎么做呢?我已经考虑在开始时对数组进行零填充,但是 numpy 零填充不允许附加值。
解决方案
您可以在 vpython 程序中使用 % modulo 运算符作为变量延迟。在 vpython 程序中,您通常有一个以给定帧速率永远运行的模拟循环。
delay = 30 # configurable delay
cnt = 0
while True:
rate(30) # vpython simulation runs at 30 frames per second (fps)
cnt += 1
if cnt % delay == 0: # delay one second (delay/30fps = 1 second)
# do what you want with your array when the delay time has been reached.
else:
# do something else
约翰
推荐阅读
- sql - pg_dump 结束后执行命令
- c# - 使用卡付款时出现 PayPal 错误 10752 错误消息
- sql-server - 我们应该使用 bigint 作为人工密钥吗?
- javascript - 所有圆圈计数器显示相同的数据(如何让每个圆圈显示它自己的计数器数据值)
- c# - 如何在 HTML 的 HiddenField 值中添加新行?
- sql-server - 如何在excel工作簿中重置现有的sql server连接
- java - 在 SpringBoot 中使用嵌入式存根/虚拟应用程序进行测试
- amazon-web-services - 有没有办法将 CloudWatch 指标流式传输到 Lambda?
- javascript - 如何对集合中的多个值进行比较?
- azure - 如何从 Azure 区块链即服务中提取仲裁日志文件