Jump to content

point sop to wrangle sop translation


Recommended Posts

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 by bonassus
Link to comment
Share on other sites

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 by f1480187
  • Like 1
Link to comment
Share on other sites

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 by f1480187
  • Like 2
Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...