简体   繁体   English

我如何找到给定点的最大长度并使程序在最大长度到达中间的那个点之后停止?

[英]how do i find the greatest length from a given point and make the program stop after that point with the greatest length hits the middle?

My program makes 30 randomly generated points that spawn from the edge of the map that move towards the center.我的程序制作了 30 个随机生成的点,这些点从地图的边缘向中心移动。 My program works fine, but how would I find the largest length of these points and then say "if the largest length hits the middle, reset?我的程序运行良好,但是我如何找到这些点的最大长度,然后说“如果最大长度到达中间,则重置?

I just dont know how我只是不知道如何

biggestLength = 0

lengthList = []
after = 1

length = math.sqrt(dx * dx + dy * dy)

lengthList.append(length)
biggestLength = lengthList[0]
if len(lengthList) == 30:
    while x < 30:
        if lengthList[after] > biggestLength:
            lengthList[after] = biggestLength
        after += 1
        x += 1
    lastWaste = lengthList.index(biggestLength)
    print (biggestLength)
    lengthList = []

列表的最大值可以通过max获得:

biggestLength = max(lengthList)

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

相关问题 如何使程序停止并从最低到最大打印输入? - How to make a program stop and print inputs from lowest to greatest? 如何在 Python 中找到矩阵的最大数的索引? - How do I find the index of the greatest number of a matrix in Python? 如何在不计算小数点的情况下找到十进制数的长度? - How do I find the length of a decimal number without counting the decimal point? 如何测量像素点上比例尺的长度? - How do I measure the length of the scale bar in pixel point? 如何从 Python 列表中找到最大的项目 - How to find greatest item from list in Python 在列表长度达到一定限制后如何停止附加值? - How to stop appending values after length of list hits a certain limit? 找不到字符串中最大长度的空格 - Having trouble finding the greatest length of whitespace in string 如何在包含 Python 中的整数和字符串的列表中找到最大的 integer 的索引? - How do I find find the index of the greatest integer in a list that contains integers and strings in Python? 如何在给定长度的曲线的每个点上 plot 法向量? - How to plot normal vectors in each point of the curve with a given length? 在KMeans聚类之后查找聚类的长度(与聚类关联的点数)(scikit learn) - Find length of cluster (how many point associated with cluster) after KMeans clustering (scikit learn)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM