python两个同切圆_求两个圆的交点
我試圖在Python中找到兩個(gè)圓之間的交集(使用Matplotlib),但是找不到任何值。在
為此,我為每個(gè)單獨(dú)的圓創(chuàng)建X和Y的列表(Matplotlib在繪制圓時(shí)將第一個(gè)參數(shù)作為X值,第二個(gè)參數(shù)作為Y值),然后相應(yīng)地使列表相交(例如,circle1x值與circle2x值)。在import numpy
import math
import matplotlib.pyplot as plt
import random
def origin_circle():
global x_points
global y_points
global r
global n
r=1
n=2**16
x_points=[(r*math.cos(t)) for t in numpy.linspace(0, 2*numpy.pi*r, n+1)]
y_points=[(r*math.sin(t)) for t in numpy.linspace(0, 2*numpy.pi*r, n+1)]
def new_circle(x_offset, y_offset):
global x_points1
global y_points1
x_points1=[x_offset+(r*math.cos(t)) for t in numpy.linspace(0, 2*numpy.pi*r, n+1)]
y_points1=[y_offset+(r*math.sin(t)) for t in numpy.linspace(0, 2*numpy.pi*r, n+1)]
origin_circle()
new_center= random.randint(0, len(x_points))
x_offset = x_points[new_center]
y_offset = y_points[new_center]
new_circle(x_offset, y_offset)
print(set(x_points1).intersection(set(x_points)))
print(set(y_points1).intersection(set(y_points)))
我希望返回值,但返回的集合為空。在
總結(jié)
以上是生活随笔為你收集整理的python两个同切圆_求两个圆的交点的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 微信小程序——操作数据库
- 下一篇: python实战扫码下载_实例:用 Py