简体   繁体   English

Python查找两个坐标之间的距离

[英]Python Find distance between two coordinates

I'm working with a range of 0 to 255. 我正在使用0到255的范围。

My data would be a set of numbers within this range. 我的数据是这个范围内的一组数字。

Except I need the difference between 除了我需要的区别

255 & 0 = 1
254 & 5 = 7

So in a sense this range is a circular set, and 255 and 0 are the pole. 所以从某种意义上说,这个范围是一个圆形集合,255和0是极点。

Is there some function / easy way to do this? 有没有一些功能/简单的方法来做到这一点? Or do I need to take the second half of the range and assign it some value to be calculated against? 或者我是否需要采用范围的后半部分并为其分配一些值来计算? ie 255 becomes 255 - 254 if it is being compared against [1 - 127.4] 即如果与[1 - 127.4]进行比较,则255变为255 - 254

def diff256(a, b):
  return min((a - b) % 256, (b - a) % 256)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用OSM和python查找两个坐标之间的路径和距离? - How to find path and distance between two coordinates using OSM and python? Python 距离(以英里为单位)到两个 gps 坐标之间的欧几里得距离 - Python distance in miles to euclidean distance between two gps coordinates 查找 GPS 坐标集之间的最短距离 - Python - Find the Shortest Distance between sets of GPS Coordinates - Python 在坐标python之间的最近距离处加入两个数据帧 - Join two dataframes on closest distance between coordinates python 如何使用python获取两个地理坐标之间的行驶距离? - How to get the driving distance between two geographical coordinates using python? 定期设置最小距离的两个坐标之间的转换(Python) - Transition between two coordinates set with minimum distance periodically (Python) 查找两帧之间的移动距离——python - Find movement distance between two frames -- python 计算地球上两个坐标之间的距离 - Calculate distance between two coordinates on a globe 如何在 Python 中找到两个一维数组之间的马氏距离? - How to find Mahalanobis distance between two 1D arrays in Python? 如何找到两个圆之间的距离。 OPENCV.Python - How to find distance between two circle. OPENCV.Python
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM