Mobius stripΒΆ
Given the following parametrization of a Mobius strip
where and .
Define uniformly spaced samples in parameters and .
>>> import numpy as np
>>> s = np.linspace(0.0, 2 * np.pi, 1000)[None, :]
>>> t = np.linspace(-1.0, 1.0, 50)[:, None]
Evaluate the above parametric equations using parameter samples s
and t
.
>>> x = (1 + 0.5 * t * np.cos(0.5 * s)) * np.cos(s)
>>> y = (1 + 0.5 * t * np.cos(0.5 * s)) * np.sin(s)
>>> z = 0.5 * t * np.sin(0.5 * s)
>>> P = np.stack([x, y, z], axis=-1)
Calculate normals.
>>> N = np.cross(np.gradient(P, axis=1), np.gradient(P, axis=0))
>>> N /= np.sqrt(np.sum(N ** 2, axis=-1))[:, :, None]
Visualize.
>>> import pptk
>>> v = pptk.viewer(P)
>>> v.attributes(0.5 * (N.reshape(-1, 3) + 1))
>>> v.set(point_size=0.001)
Visualization of a mobius strip using pptk.viewer() .
Points are colored by normal directions.
And the latter three images are views along the -x, +y and -z directions. |