Skip to content

Instantly share code, notes, and snippets.

@zeffii
Last active August 29, 2015 14:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zeffii/fe7bc98ca6e8bf27b26b to your computer and use it in GitHub Desktop.
Save zeffii/fe7bc98ca6e8bf27b26b to your computer and use it in GitHub Desktop.
# credit to author: http://blog.marmakoide.org/?cat=4
import numpy as np
def sv_main(n=256, k=5, f=3):
in_sockets = [
['s', 'n', n],
['s', 'k', k],
['s', 'f', f]]
golden_angle = np.pi * (f - np.sqrt(k))
theta = golden_angle * np.arange(n)
z = np.linspace(1 - 1.0 / n, 1.0 / n - 1, n)
r = np.sqrt(1 - z * z)
points = np.zeros((n, 3))
# points[:,0] = radius * np.cos(theta)
# points[:,1] = radius * np.sin(theta)
# points[:,2] = z
new_Vector = [r*np.cos(theta), r*np.sin(theta), z]
points[:,] = np.array(new_Vector).transpose()
# out boilerplate
out_sockets = [
['v', 'Vecs', [points.tolist()]],
]
return in_sockets, out_sockets
# credit to author: http://blog.marmakoide.org/?cat=4
import numpy
def sv_main(n=256):
in_sockets = [
['s', 'num points', n]]
golden_angle = numpy.pi * (3 - numpy.sqrt(5))
theta = golden_angle * numpy.arange(n)
z = numpy.linspace(1 - 1.0 / n, 1.0 / n - 1, n)
radius = numpy.sqrt(1 - z * z)
points = numpy.zeros((n, 3))
points[:,0] = radius * numpy.cos(theta)
points[:,1] = radius * numpy.sin(theta)
points[:,2] = z
# out boilerplate
out_sockets = [
['v', 'Vecs', [points.tolist()]],
]
return in_sockets, out_sockets
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment