bonassus Posted January 9, 2017 Share Posted January 9, 2017 (edited) I'm new trying to learn the basics of using the Wrangle sop. As a test I used an expression from the expression cook book in the Houdini docs. So there is a line and a point sop. In the position fields of the point sop the expressions are: X: cos(@ptnum *5) Y:@ptnum/400 Z: sin(@ptnum *5) this makes a spiral from the line. I want to do the same thing with the attribwrangle. So naively i tried: @P.x = cos(@ptnum *5); @P.y = @ptnum/400; @P.z = sin(@ptnum *5); What this did to the line was interesting. but was not the same as what the point sop did. I think if some one could explain how this is done it would help me a bit. thanks very much, b Edited January 9, 2017 by bonassus Quote Link to comment Share on other sites More sharing options...
f1480187 Posted January 9, 2017 Share Posted January 9, 2017 (edited) Expressions are always floats. @ptnum is an integer attribute in VEX, even if you omit type (which will be defaulted to f@foo for some random attributes). You should use floats to avoid integer arithmetic. Here is plain and stupid example: 3 / 2 == 1 3.0 / 2.0 == 1.5 3.0 / 2 == 1.5 3 / 2.0 == 1.5 (float) 3 / 2 == 1.5 3 / (float) 2 == 1.5 int_var / int_var == integer_result int_var / float_var == float_result float_var / int_var == float_result Edited January 9, 2017 by f1480187 1 Quote Link to comment Share on other sites More sharing options...
bonassus Posted January 9, 2017 Author Share Posted January 9, 2017 f489187, Thank you for your response. I did forget the values types. So I cast the values to float. Now I get something new but still not what the point sop is doing. see pics. thanks again Quote Link to comment Share on other sites More sharing options...
f1480187 Posted January 9, 2017 Share Posted January 9, 2017 (edited) 1. You need to convert operands, not result. cos(3 / 2) == cos(1) cos(3.0 / 2) == cos(1.5) 2. In that case, it's more like a frequency problem (spiral swirls too much). Expression's sin() expect degrees, VEX's sin() working with radians. You need to convert expression's example to radians, since it was set up to output big values. cos(radians(3.0 / 2)) point_to_wrangle.hipnc Edited January 9, 2017 by f1480187 2 Quote Link to comment Share on other sites More sharing options...
bonassus Posted January 9, 2017 Author Share Posted January 9, 2017 Yes! Radians not degrees, of course. Thank you for the point in the right direction. this did the trick. @P.x = cos(radians(@ptnum *5)); @P.y = (float)@ptnum/400; @P.z = sin(radians(@ptnum *5)); 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.