Converting Python to Vex

   1842   2   0
User Avatar
Member
2 posts
Joined: Oct. 2014
Offline
Hello world!

So I have been using Houdini for a while, for work I am (for the first time) attempting to utilize wrangles and Vex. I'm now going on day three of trying to figure it out. I have a friend who knows Python and he helped me with the math and such, it's just now in the wrong language. I need help converting it into Vex.

Here is the python code

def func(N):
s = ''
for i in range(N):
angle = 360 * (i + 1) // N
s += ""
return s

for i in range(15):
print(func(i))
Chelsea Newman
Look Development Artist
ChelseaNewmanCG.com
chelnewman@gmail.com
User Avatar
Member
9380 posts
Joined: July 2007
Offline
your code doesn't produce anything as the function func() just accumulates nothing into s since
s += ""
so angle is not even used
I assume that line was supposed to be something like this
s += "%s " % angle

then the equivalent VEX code would be something like this (run in detail mode):
string func(int N){
    string s = "";
    for (int i=0; i<N; i++){
        int angle = 360 * (i + 1) / N;
        s += itoa(angle) + " ";
    }
    return s;
}

for (int i=0; i<15; i++){
    printf("%s\n", func(i));
}
Tomas Slancik
CG Supervisor
Framestore, NY
User Avatar
Member
2 posts
Joined: Oct. 2014
Offline
Thank you so much!
Chelsea Newman
Look Development Artist
ChelseaNewmanCG.com
chelnewman@gmail.com
  • Quick Links