majinpu Posted June 15, 2017 Share Posted June 15, 2017 Hi there! A few days ago I saw a video on youtube talking about the collatz conjecture and I decided to recreate it inside Houdini using VEX. I have almost completed it. But I got stuck at one point. here is the link https://www.youtube.com/watch?v=LqKpkdRRLZw&feature=youtu.be The process is pretty simple. I have just followed what the video says. Here's what I did. First thing, I just scatter some points, and create a random integer attribute called "numbers". Then I set another attributes that is called type, that just takes my number and modulate by 2. so I can separate my even number from odd number. Then i put a solver. go inside. After this I say, if type equal 0 (even) add 1 to @P.x and to @P.Y. If equal to 1 (odd) subtract 1 from @P.x and add 1 to @P.y At the end I lookup for the number if it's equal to 0 or 2 I remove the point. So far so good. but if you have a look in the video link at 3:40 it shows the pattern changing from straight lines to curved lines. At 3:24 is talking about adding some sort of degrees based on the direction the point is going. but I don't know how to achieve that!! Somebody has got any Idea on how to do that? I have attached my hip file. THANK YOU A LOT!! MY VEX2.hiplc Quote Link to comment Share on other sites More sharing options...
konstantin magnus Posted June 15, 2017 Share Posted June 15, 2017 (edited) Good find! After a pointgenerate node I put this in a pointwrangle. The while loop draws new curve segments until num reaches 1. And dir defines where the curves bend to. int i = chi('steps'); float spread_l = chf('Left'); float spread_r = chf('Right'); i@num = @ptnum; vector pos = @P; vector dir = {0, 1, 0}; int prim = addprim(0, "polyline"); while(@num > 1 && i > 0){ i -= 1; // break if(@num % 2 == 0){ @num /= 2; dir.x += spread_r; } else{ @num = (@num * 3) + 1; dir.x -= spread_l; } dir = normalize(dir); pos += dir; int pt = addpoint(0, pos); addvertex(0, prim, pt); } collatz_conjecture.hipnc Edited June 15, 2017 by konstantin magnus added some color variation and jitter to the hip 1 Quote Link to comment Share on other sites More sharing options...
majinpu Posted June 15, 2017 Author Share Posted June 15, 2017 you're the man!! thank you konstantine!! TOP Quote Link to comment Share on other sites More sharing options...
majinpu Posted June 15, 2017 Author Share Posted June 15, 2017 this is very cool! but I can't understand how it work especially hereù dir = normalize(dir); pos += dir; int pt = addpoint(0, pos); addvertex(0, prim, pt); Quote Link to comment Share on other sites More sharing options...
majinpu Posted June 15, 2017 Author Share Posted June 15, 2017 I mean, what is doing the normalize function? Quote Link to comment Share on other sites More sharing options...
Sepu Posted June 15, 2017 Share Posted June 15, 2017 (edited) I havent seen what @konstantin did, but when you normalize a vector meaning you make sure that you vector is of length 1 . Edited June 15, 2017 by Sepu 1 Quote Link to comment Share on other sites More sharing options...
majinpu Posted June 15, 2017 Author Share Posted June 15, 2017 ok. got it. but why is he doing that? Quote Link to comment Share on other sites More sharing options...
Sepu Posted June 15, 2017 Share Posted June 15, 2017 put a visualizer on your wrangle and look at what is happening that way you can see exactly what dir is doing when isnt normalize, and I believe it will make sense to you, look at the geo spreadsheet. you can see all the wacky numbers, etc. Most of the time you will want your vector to be normalized to make math operations. 1 Quote Link to comment Share on other sites More sharing options...
majinpu Posted June 15, 2017 Author Share Posted June 15, 2017 I got it !! thanks Sepu! before I removed the dir = normalize(dir) and I understood that we are simply normalizing the dir every iteration and starting with a new P every time. so the points are not moving exponentially!!! thanks a lot guys!! I learned a lot today Quote Link to comment Share on other sites More sharing options...
majinpu Posted June 15, 2017 Author Share Posted June 15, 2017 sorry sepu... how do you set the visualize Quote Link to comment Share on other sites More sharing options...
Sepu Posted June 15, 2017 Share Posted June 15, 2017 (edited) select and hold X on the node that you want to visualize Edited June 15, 2017 by Sepu 1 Quote Link to comment Share on other sites More sharing options...
majinpu Posted June 15, 2017 Author Share Posted June 15, 2017 i have created it but i can't understand hot to set the dir for visualization Quote Link to comment Share on other sites More sharing options...
Sepu Posted June 15, 2017 Share Posted June 15, 2017 (edited) dir is declared as a vector right, so you need to change it to Type : Marker Style : vector Add what kind of Attribute you want to visualize, P, N, etc or it can be your own attribute as well, which in this case is dir. As you can see the visualize node allows to look at thing in different ways. Depending of your needs you will change that. Edited June 15, 2017 by Sepu 1 Quote Link to comment Share on other sites More sharing options...
majinpu Posted June 15, 2017 Author Share Posted June 15, 2017 ok got it!! thanks sepu! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.