python 极坐标 多边形点 画多边形 规则多边形 取圆上的若干点

极坐标多边形 https://blog.csdn.net/qq_30638831/article/details/79938841
极坐标转直角坐标 https://blog.csdn.net/qq_32425195/article/details/105233463

1。直角坐标转极坐标

import cmath

cn = complex(3,4)

cmath.polar(cn) #返回长度和弧度

2.极坐标转直角坐标

cn1 = cmath.rect(2, cmath.pi)

cn1.real,cn1.imag

import geopandas
from geopandas import GeoSeries
from shapely.geometry import Polygon
import matplotlib.pyplot as plt


def draw_a_poly(quyu):
    """
    用geopandas画一个多边形
    :param quyu: 二维list
    :return: 无
    """
    p = Polygon(quyu)
    g = GeoSeries(p)
    g.plot()
    plt.show()


import cmath


def get_poly(rad, num_p):
    """
    返回规则num_p边行的各个点
    :param rad: 几何中心到顶点的距离
    :param num_p: 有多少边
    :return: 二维list  N*2
    """
    r = [rad for i in range(num_p)]
    theta = [cmath.pi / num_p * 2 * i for i in range(num_p)]
    ploy = [[cmath.rect(*i).real, cmath.rect(*i).imag] for i in zip(r, theta)]
    return ploy


draw_a_poly(get_poly(2, 16))



在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/x1131230123/article/details/113363764