滑动轨迹 曲线 python_python – 计算轨迹(路径)中的转折点/枢轴点

本文介绍了如何使用Ramer-Douglas-Peucker (RDP) 算法来简化路径,并通过计算角度变化来确定轨迹中的转折点。通过Python实现,展示了从原始轨迹到简化轨迹的过程,并标识出转折点。
摘要由CSDN通过智能技术生成

您可以使用

Ramer-Douglas-Peucker (RDP) algorithm来简化路径。然后,您可以计算简化路径每段的方向变化。对应于方向最大变化的点可以称为转折点:

RDP算法的Python实现可以在on github中找到。

import matplotlib.pyplot as plt

import numpy as np

import os

import rdp

def angle(dir):

"""

Returns the angles between vectors.

Parameters:

dir is a 2D-array of shape (N,M) representing N vectors in M-dimensional space.

The return value is a 1D-array of values of shape (N-1,), with each value

between 0 and pi.

0 implies the vectors point in the same direction

pi/2 implies the vectors are orthogonal

pi implies the vectors point in opposite directions

"""

dir2 = dir[1:]

dir1 = dir[:-1]

return np.arccos((dir1*dir2).sum(axis=1)/(

np.sqrt((dir1**2).sum(axis=1)*(dir2**2).sum(axis=1))))

tolerance = 70

min_angle = np.pi*0.22

  • 0
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值