zoukankan      html  css  js  c++  java
  • 使用python在极坐标中生成一条直线

    在测试雷达时,往往需要测试雷达的数据是否准确,这时就需要在雷达图中显示一条标准的直线作为对比。

    "create a wall"
    import numpy as np
    import matplotlib.pyplot as plt
    import sys
    
    def main(distance):
        theta = np.arange(-45 / 180 * np.pi, 45 / 180 * np.pi, 1 / 180 * np.pi)
    
        tmp = np.cos(theta)
    
    
        wall = distance / tmp
        with open("dis.csv",mode = 'w') as file:
            counter = 0
            s = ''
            for n in wall:
                s += str("%d,"%n)
                counter += 1
    
            while counter < 360:
                s += "0,"
                counter += 1
    
            file.write(s)
            file.close()
        lin = np.linspace(distance+1000,distance+1000,len(theta))
    
        plt.polar(theta, wall)
        plt.polar(theta, lin)
        plt.show()
    
    if __name__ == "__main__":
        main(int(sys.argv[1]))
    

    想生成一条3m的直线,只需要输入:

    python buildwall.py 3000
    

    即可

  • 相关阅读:
    标准粒子群算法(PSO)
    Java开发中的23种设计模式详解
    分布式事务
    sjk 分页
    有用吗2
    有用吗1
    存储过程
    在虚拟机Linux安装Redis
    ajax调用WebAPI添加数据
    SVN安装和使用(简单版)
  • 原文地址:https://www.cnblogs.com/WeyneChen/p/6670603.html
Copyright © 2011-2022 走看看