SciPy's spatial Modul beinhaltet zum Beispiel eine Methode um die konvexe Hülle von Punkten finden zu können. Es ist ein front-end für QHull.
import numpy as np
from scipy.spatial import ConvexHull
pts = np.random.normal(size=(100,2))
chull = ConvexHull(pts)
chull.vertices
array([15, 21, 60, 73, 39, 96, 0, 44, 19], dtype=int32)
%matplotlib inline
import matplotlib.pyplot as plt
for simplex in chull.simplices:
plt.plot(pts[simplex, 0], pts[simplex, 1], "g-", lw=2, zorder=1)
plt.scatter(pts[:,0], pts[:,1], zorder=2)
<matplotlib.collections.PathCollection at 0x7f0fdf7dde50>
import sympy as sy
from sympy.geometry import Point, Segment, Circle, Line, Triangle
Setting permissions of DOT_SAGE directory so only you can read and write it.
x = Point(0, 0)
y = Point(1, 1)
z = Point(2, 2)
zp = Point(1, 0)
Point.is_collinear(x, y, z)
True
Point.is_collinear(x, y, zp)
False
seg1 = Segment(x, z)
seg2 = Segment(y, zp)
seg1.intersection(seg2)
[Point(1, 1)]
seg1.midpoint
Point(1, 1)
c = Circle(x, 5)
l = Line(Point(5, -5), Point(5, 5))
c.is_tangent(l)
True
l2 = Line(Point(2, -4), Point(3, -2))
c.intersection(l2)
[Point(-sqrt(61)/5 + 16/5, -2*sqrt(61)/5 - 8/5), Point(sqrt(61)/5 + 16/5, -8/5 + 2*sqrt(61)/5)]