how to perform "if...then" in VOP SOP? [SOLVED]

   11455   5   1
User Avatar
Member
479 posts
Joined: Dec. 2009
Offline
in a VOP SOP context, suppose I have a vector A and it is piped into a “vector to float” node to get its components, A_x, A_y, A_z

And I want to create a new vector B by feeding the x and y components of A into it based on some conditions. the z component of B will always be zero.

what I want to do is:
1. evaluate if A_x and A_y are both equal to zero
2. if they are, then
2.1 set A_x=0 and pipe it into B_x, and
2.2 set A_y=1 and pipe it into B_y
3. if they aren't, then pipe A_x into B_x and A_y into B_y.

may I ask how to do it?

Thanks!
Edited by - March 27, 2011 04:48:51

Attachments:
Capture.PNG (25.1 KB)

User Avatar
Member
479 posts
Joined: Dec. 2009
Offline
tried a little bit and it seems the way as shown below works

anyway, pls suggest a better solution if there is

thanks!

Attachments:
2.PNG (46.3 KB)

User Avatar
Member
242 posts
Joined: Jan. 2008
Offline
Just a note.
There is a AND node in VOPS returning 1 if all inputs are 1(TRUE) else returning 0(False).
User Avatar
Member
479 posts
Joined: Dec. 2009
Offline
thanks, mawi!

However, according to the help file (http://www.sidefx.com/docs/houdini11.0/nodes/vop/and): [sidefx.com] “This operator performs a logical “and” operation between its inputs and returns 1 (if all inputs are non-zero) or 0 (if at least one input is zero). ”

So, this node may not be able to differentiate the following two situations:
1. both inputs are zero
2. one of the input is zero and the other is not

therefore, I'm not sure how to use Add node for my task. can you give a hint?

Thanks!
User Avatar
Member
242 posts
Joined: Jan. 2008
Offline
Sorry.
It was a note based on the picture of your network and not a complete solution to your problem.

You are adding the result of two compare nodes just to see if they sum to 2.
Instead you could use a AND node to directly check if both compare nodes are TRUE.
User Avatar
Member
479 posts
Joined: Dec. 2009
Offline
oh, got it, thanks a lot, mawi!

so the VOP network can be simplified as the following:

Attachments:
1.PNG (29.5 KB)

  • Quick Links