Created
August 5, 2017 17:34
-
-
Save bostelk/c18ed9090a33dedc22f5ef61fba0bb9a 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
def N_i_k(k): | |
if k == 1: | |
return "float N_i_"+str(k)+"(in float t, in float i) { return step(i,t) * step(t,i+1.); }" | |
else: | |
return "float N_i_"+str(k)+"(in float t, in float i) { return (t - i)/"+str(k-1)+".*N_i_"+str(k-1)+"(t, i) + (i + "+str(k)+".0 - t)/"+str(k-1)+".0*N_i_"+str(k-1)+"(t, i + 1.); }" | |
def bspline(order, num_count_points): | |
code = "" | |
for n in range(0,order): | |
code += N_i_k(n+1) + "\n" | |
code += "vec3 P_i(" | |
for n in range(1,num_count_points+1): | |
code += "vec3 p" + str(n) + ", " | |
code += "float t)\n" | |
code += "{\n" | |
code += " vec3 p = vec3(0.);\n" | |
for n in range(1,num_count_points+1): | |
code += " p += N_i_" + str(order)+ "(t, "+str(n)+".)*p"+str(n)+";\n" | |
code += " return p;\n" | |
code += "}\n" | |
return code | |
if __name__ == "__main__": | |
print(bspline(8, 2)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment