Steve Cullum Posted July 8, 2008 Share Posted July 8, 2008 I'm using an expression in my node net work to drive some object copies based on the rotation value of a tube. What I want is the copy SOP to add 1 to the number of copies every 60 degrees. So at 60 its 1 at 120 its 2 at 180 its 3 etc... Here is what I got: if(ch("../xform1/rz") % 60,0,++1) But this resets my channel to 0 if rz is not divisible by 60, so the result is always 1. How do I say 'Do nothing' as opposed to 'Do Zero' in my expression? Quote Link to comment Share on other sites More sharing options...
SpencerL Posted July 8, 2008 Share Posted July 8, 2008 I'm using an expression in my node net work to drive some object copies based on the rotation value of a tube. What I want is the copy SOP to add 1 to the number of copies every 60 degrees. So at 60 its 1 at 120 its 2 at 180 its 3 etc...Here is what I got: if(ch("../xform1/rz") % 60,0,++1) But this resets my channel to 0 if rz is not divisible by 60, so the result is always 1. How do I say 'Do nothing' as opposed to 'Do Zero' in my expression? Will this work? The trun() expression converts your number to an integer rounding down. trunc(ch("../xform1/rz")/60) Quote Link to comment Share on other sites More sharing options...
Steve Cullum Posted July 8, 2008 Author Share Posted July 8, 2008 Will this work? The trun() expression converts your number to an integer rounding down. trunc(ch("../xform1/rz")/60) Thanks! that's got it. Quote Link to comment Share on other sites More sharing options...
antoinedurr Posted July 11, 2008 Share Posted July 11, 2008 Thanks! that's got it. Might want to use floor() instead of trunc() -- trunc() truncates, removing the portion to the right of the decimal point, whereas floor() uses the largest integer that is less than or equal to the floating point value. Using trunc() instead of floor() will hiccup between 0 and -60 (resulting in the same answer (0) as 0 to +60 when what you probably want is -1). -- Antoine 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.