相关疑难解决方法(0)

寻找两个圆的交点

我试图在 Python(使用 Matplotlib)中找到两个圆圈之间的交点,但无法取回任何值。

我通过为每个单独的圆创建 X 和 Y 的列表来做到这一点(Matplotlib 在绘制圆时将第一个参数作为 X 值,第二个作为 Y 值),然后相应地将列表相交(例如, circle1 x 值与 circle2 x 值)。

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)) …
Run Code Online (Sandbox Code Playgroud)

python set-intersection

5
推荐指数
1
解决办法
1万
查看次数

标签 统计

python ×1

set-intersection ×1