Parametric CurveΒΆ

This is a comparison to the Parametric Curve Matplotlib example.

../../_images/param_demo.png
import numpy as np
from matplotlib import pyplot as plt
import s3dlib.surface as s3d
import s3dlib.cmap_utilities as cmu

#.. Matplotlib Examples: Parametric Curve

# 1. Define function to examine .....................................

def parametric_curve(t) :
    #...   0 < t < 1
    r_0, twists = .25, 4
    z = ( 2*t -1 ) 
    r = r_0 + (1-r_0)*z**2
    theta = twists*np.pi*z
    x = r*np.sin(theta)
    y = r*np.cos(theta)
    return x,y,z

# 2. Setup and map line .............................................

line = s3d.ParametricLine(6,parametric_curve)

# 3. Construct figure, add surface, and plot ........................

fig = plt.figure(figsize=plt.figaspect(1))
ax = plt.axes(projection='3d')
ax.set_aspect('equal')
s3d.auto_scale(ax,line)

ax.add_collection3d(line)
ax.legend()

plt.show()