首页 > 其他分享 >轨迹,简单轨迹

轨迹,简单轨迹

时间:2023-07-12 12:33:24浏览次数:42  
标签:random last track move 轨迹 简单 type

 

 

 

 

[{"x":0,"y":0,"type":"down","t":2687},{"x":5,"y":0,"type":"move","t":2756},{"x":11,"y":-1,"type":"move","t":2764},{"x":17,"y":-1,"type":"move","t":2773},{"x":24,"y":-2,"type":"move","t":2782},{"x":32,"y":-2,"type":"move","t":2789},{"x":39,"y":-2,"type":"move","t":2797},{"x":43,"y":-3,"type":"move","t":2805},{"x":49,"y":-4,"type":"move","t":2812},{"x":55,"y":-5,"type":"move","t":2821},{"x":59,"y":-5,"type":"move","t":2829},{"x":64,"y":-6,"type":"move","t":2836},{"x":68,"y":-6,"type":"move","t":2845},{"x":73,"y":-6,"type":"move","t":2852},{"x":75,"y":-6,"type":"move","t":2863},{"x":77,"y":-6,"type":"move","t":2868},{"x":79,"y":-6,"type":"move","t":2877},{"x":81,"y":-6,"type":"move","t":2885},{"x":82,"y":-6,"type":"move","t":2893},{"x":84,"y":-7,"type":"move","t":2900},{"x":86,"y":-7,"type":"move","t":2916},{"x":87,"y":-7,"type":"move","t":2933},{"x":88,"y":-7,"type":"move","t":2948},{"x":89,"y":-7,"type":"move","t":2965},{"x":90,"y":-7,"type":"move","t":2988},{"x":91,"y":-7,"type":"move","t":3005},{"x":92,"y":-8,"type":"move","t":3021},{"x":93,"y":-8,"type":"move","t":3036},{"x":93,"y":-8,"type":"move","t":3131},{"x":93,"y":-8,"type":"move","t":3146},{"x":93,"y":-8,"type":"up","t":3420}]

 

 

这个是样例, 根据这个样例用python生成随机轨迹, 入参是最后的x

 

 

 

import random

# 生成随机轨迹
def generate_random_track(last_x):
    track = []
    x = 0
    y = 0

    # 随机生成移动步数
    move_steps = random.randint(20, 30)

    # 计算每步的移动距离
    move_distance = (last_x - x) / move_steps

    # 生成随机移动轨迹
    for i in range(move_steps):
        x += move_distance
        y += random.randint(-1, 1)
        t = random.randint(500, 1000)
        track.append({"x": int(x), "y": y, "type": "move", "t": t})

    # 添加按下和释放动作
    track.insert(0, {"x": 0, "y": 0, "type": "down", "t": 1000})
    track.append({"x": int(last_x), "y": y, "type": "move", "t": random.randint(500, 1000)})
    track.append({"x": int(last_x), "y": y, "type": "up", "t": random.randint(1000, 1500)})

    return track

# 测试生成随机轨迹
last_x = 100  # 最后的x参数
random_track = generate_random_track(last_x)

# 打印生成的随机轨迹
for entry in random_track:
    print(entry)

 

标签:random,last,track,move,轨迹,简单,type
From: https://www.cnblogs.com/angdh/p/17547203.html

相关文章

  • 快速打开Sketch格式文件:仅需两个简单步骤!
    虽然Figma,sketch,xd都很好用,但是设计师在设计工作流中经常会遇到无法在这三者软件中自由导入导出的情况。但是只要我们转变一下思路,因为这三种软件都支持导入sketch格式,所以我们只要将文件格式转成sketch,就能自由的在不同软件间导入导出。 现在就有一个网站可以帮助你快速简......
  • java基础(二)-最简单的程序
    上节说到方法的主体由命令组成。或者***方法就是一组被赋予名称(方法名称)的命令***Java语言拥有适于各种场合的命令。每个命令都描述了一些操作。在每个命令的末尾,我们使用分号。举些粒子:命令名称命令描述(它做什么)System.out.println(1);在屏幕上显示数字1System......
  • 小程序开发这么简单,还需要App吗?
    微信小程序自2017年推出以来,其生态系统得到了迅速的发展和壮大。作为中国最大的社交平台之一,微信拥有庞大的用户基础。微信小程序作为微信生态系统的一部分,自然而然地吸引了大量用户。据对公开资料进行统计,2021年全网小程序数量已超700万,其中微信小程序开发者突破300万,小程序DAU......
  • AvaloniaUI 和 WPF 图形性能的简单测试.
     本文发布于:https://www.cnblogs.com/8u7tgyjire7890/p/17545599.html 原始代码来自于 Avalonia 示例程序https://github.com/AvaloniaUI/Avalonia/blob/master/samples/ControlCatalog/Pages/CustomDrawing.xaml.cs我将其修改为一个单独的Avalonia应用程序,同时将其翻......
  • ZeroMQ: Java 请求/响应和发布/订阅模式的简单实现
    转载于:https://blog.csdn.net/weixin_47951400/article/details/119142454 文章目录POM一、请求响应模式(ZMQ_REQ+ZMQ_REP)1.REP2.REQ3.测试REPREQ测试结果二、发布/订阅模式(ZMQ_PUB+ZMQ_SUB)1.PUB2.SUB3.测试PUBSUB测试结果 POM ......
  • 计算机cpu的多级缓存简单原理
    缓存级别L1高速缓存(最快内存),一般分为两种方式:指令缓存和数据缓存;一般大小在256KB~1MB之间。L2叫L1缓存慢,比L1会更大些,一般大小在256KB~8MB之间。L3最大的高速缓存存储单元,也是最慢的一个。它的范围从4MB到50MB以上。数据会从RAM依次流到L3高速缓存,然后是L2,最后是L1查找时,会......
  • 解决Python 轨迹纠偏算法的具体操作步骤
    Python轨迹纠偏算法实现指南简介在实际应用中,我们经常需要处理采集到的轨迹数据,例如GPS定位数据。由于各种原因,采集到的轨迹数据可能存在噪声、漂移或其他异常情况,因此需要进行轨迹纠偏算法的处理。本文将介绍如何使用Python实现轨迹纠偏算法。整体流程下面是实现Python轨迹纠......
  • 时间同步服务chrony的简单配置 (1)
    chrony配置手册一,chrony服务器的简介概述·chrony是一个开源自由的网络时间协议NTP的客户端和服务器软软件。它能让计算机保持系统时钟与时钟服务器(NTP)同步,因此让你的计算机保持精确的时间,Chrony也可以作为服务端软件为其他计算机提供时间同步服务。·chrony由两个程序组成,分......
  • 基于MPC的模型预测轨迹跟踪控制联合仿真simulink模型+carsim参数设置 效果如图 可选模
    基于MPC的模型预测轨迹跟踪控制联合仿真simulink模型+carsim参数设置效果如图可选模型说明文件和操作说明YID:13120652659026692......
  • Three_Phase_Rectifier_SimpleSVPWM:基于MATLAB/Simulink的三相电压型简单SVPWM整流器
    Three_Phase_Rectifier_SimpleSVPWM:基于MATLAB/Simulink的三相电压型简单SVPWM整流器仿真模型,输出电压开环控制。仿真条件:MATLAB/SimulinkR2015bID:7120649953967466......