# TP Conditional Expressions Help

 Thread Tools Search this Thread Display Modes
 04 April 2013 mstarktv Frequenter   portfolio Michael Stark FX artist Pixomondo USA TP Conditional Expressions Help I'm practicing all of the fun I can have with TP's expression node. It's not that it's new to me, but Conditional Expressions are. I'm starting off really basic, just to understand the concept. I am hung up on only one thing which is how to say something is I guess "true" or "fulfilled". For example, the expression I'm trying to write is something that says "if a particle's velocity exceeds x velocity, then it's true/fulfilled and now go into the group that it's wired to". I know there is already a Condition threshold, but I'm using this for practice. The problem I'm having is that I'm confused as to how I would write this in the expression. I'm looking at Max's Conditional Functions Reference, but it's still not making sense. On my first go I wrote "if(v1 > p) then(p=o)" v1 = particle velocity p = float value o = true output I know this is incorrect because it doesn't work but I hope you can see my logic in writing it this way. My general thinking is correct, but I'm confused as to how to execute it. Any help would be much appreciated Thanks! share quote
 04 April 2013 3ak Know-it-All if you're using speed (scalar) then ``if(speed > threshold, 1, 0)`` will be enough, where "speed" and "threshold" are scalar inputs and you have 1 scalar output. you can use velocity: ``if(length(vel) > threshold, 1, 0)`` where "vel" is vector input and "threshold" - scalar and you have 1 scalar output But it will be faster to calculate length of velocity via nodes. share quote
 04 April 2013 mstarktv Frequenter   portfolio Michael Stark FX artist Pixomondo USA Awesome, this works So I seem to have been floating around the right idea. I'm a bit confused as to the "1,0" part of the expression. My basic understanding is 1 is on 0 is off. I guess what I mean is that: if the vector length is greater than the threshold, what does the 1 and 0 add to the expression? I'm looking through the documentation but can't seem to find an obvious answer. :/ Thank you for all the help by the way ***UPDATE**** So after some digging, it seems using the 1,0 is called a "ternary operator". If the thing is true the return is 1 else it's 0. now to figure out how to write it out long form. Last edited by mstarktv : 04 April 2013 at 07:35 PM. share quote
 04 April 2013 3ak Know-it-All Yes, it's just if-then-else but using different statement - if(condition, use this if evaluates to true, otherwise). You can use several nested if needed. All these expressions are the same as in expression controllers (except for some time variables - tp has it's own Time variable) share quote
 04 April 2013 CGTalk Moderation Expert Thread automatically closed This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum. __________________ CGTalk Policy/Legalities Note that as CGTalk Members, you agree to the terms and conditions of using this website. share quote

 Posting Rules You may not post new threads You may not post replies You may not post attachments You may not edit your posts vB code is On Smilies are On [IMG] code is On HTML code is Off CGSociety Society of Digital Artists www.cgsociety.org Powered by vBulletinCopyright ©2000 - 2006, Jelsoft Enterprises Ltd.