You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

寻找满足斜率范围条件的最长连续离散点链

离散点最长连续链求解任务

数据集

以下是待处理的离散点数据集:

序号y值x值
01.0000001000.000000
10.9994151000.000287
20.9994201000.000358
30.9993761000.000609
40.9992391000.000788
50.9990111000.000967
61.0003891000.001433
70.9998711000.001756
80.9950701000.002723
90.9966831000.003404

任务要求

从上述数据集中找出最长的连续点链,链中相邻两点连线的斜率绝对值需小于给定阈值 epsilon=0.4。数据已做归一化处理,用于缩放正切计算结果。

现有代码片段

正切值计算函数

def tangent(df, pt1, pt2):
    y = df.iloc[pt2]['y'] - df.iloc[pt1]['y']
    x = df.iloc[pt2]['x'] - df.iloc[pt1]['x']

    return x/y

斜率检测草稿代码

import math

index = 1
while index < df.shape[0]:
    if abs(math.tan(tangent(df, index-1, index) * math.pi)) < epsilon:
        print("result:", index)
        
    index += 1

内容的提问来源于stack exchange,提问作者bugrahaskan

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.03 11:15:29