Last active
August 29, 2015 14:00
-
-
Save zeffii/fe7bc98ca6e8bf27b26b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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