Skip to content

A toolkit to manipulate n-dimensional geometric curves in Python ➰

License

Notifications You must be signed in to change notification settings

espdev/scikit-curve

Repository files navigation

scikit-curve

PyPI version Supported Python versions BSD License Coverage Status Build status Docs status

⚠️ 🚧 UNDER DEVELOPMENT 🚧 ⚠️

A toolkit to manipulate n-dimensional geometric curves in Python.

Examples

import matplotlib.pyplot as plt

from skcurve.curves import lissajous
from skcurve.plot import curveplot
from skcurve import PreservedSpeedInterpolationGrid

curve = lissajous(p_count=51)

grid = PreservedSpeedInterpolationGrid(301)
curve_i = curve.interpolate(grid, method='hermite')

curveplot(curve_i, param='speed', show_normals=True, marker='.')

plt.show()

lissajous plot

import numpy as np
import matplotlib.pyplot as plt

from skcurve import Curve, Axis
from skcurve.plot import curveplot

t = np.linspace(0, 2*np.pi, 100)

x = np.cos(t)
y = np.sin(t)
z1 = x * y
z2 = x - y + z1

curve1 = Curve([x, y, z1])
curve2 = Curve([x, y, z2])

intersections = curve1.intersect(curve2)

ax = curveplot(curve1, param='curvature', linewidth=2).\
     curveplot(curve2, param='curvature', param_cmap='viridis', linewidth=2).axes

ix = []
iy = []
iz = []

for intersect in intersections:
    p = intersect.intersect_point
    print('Intersect:', p)

    ix.append(p[Axis.X])
    iy.append(p[Axis.Y])
    iz.append(p[Axis.Z])

ax.plot(ix, iy, iz, 'o', markerfacecolor='r', markeredgecolor='k', zorder=1000)
plt.show()
Intersect: Point([0.7068 0.7068 0.4991], ndim=3, dtype=float64)
Intersect: Point([-0.707  -0.707   0.4996], ndim=3, dtype=float64)

3d_curves plot