PDA

View Full Version : need help with a simple expression



Archigram
03-04-2013, 12:11 PM
Hi,

I am a novice at expressions and need to figure out the proper syntax of a conditional statement along the lines below. (I've used a hybrid language to explain what I want):

if X(K,t) >= 43, then return 2000; if X(K,t)<=0, return 6300; otherwise return (43-K,t)*100) + 2000

In other words, I need to stack 2 IF statements (or maybe COND statements?) in the same expression. Do I need to use a sub-expression?

Many thanks

RebelHill
03-04-2013, 12:21 PM
(X(K,t)) >= 43 ? 2000 : ( (X(k,t)) <= 0 ? 6300 : ((43 - K,t)*100)+2000 )

(I think)

or put another way to illustrate expression syntax

normally...


if A > B
return X
else
if C < D
return Y
else
return Z

As notated by LW expression "vocab"...


A > B ?
X
:
C < D ?
Y
:
Z

Which written then as an expression would be...

A > B ? X : (C < D ? Y : Z)

Archigram
03-04-2013, 12:29 PM
Thanks for the quick response. But I'm getting "unresolved function reference X()"

By the way, I am entering this on the Modifiers tab under expressions.

RebelHill
03-04-2013, 12:32 PM
Well ofc... X(K,t) would be a function, which delivers a value... Im presuming u have that resolved already.

If not, then what exactly is X(K,t) supposed to be?

Archigram
03-04-2013, 12:34 PM
I have a null named K, yes. do I need to do something to the X channel?

RebelHill
03-04-2013, 01:20 PM
what??

that doesnt really help... So u have a null named K, great... but what is X(K,t) supposed to represent??

Is it meant to mean... the X(position) of (null)K at (time)t ??

If so then its written as...

[K.Position.X]

Archigram
03-04-2013, 01:24 PM
Sorry-- I guess I am dense about this stuff. I thought X(K,t) would be the value of the position channel of the object K at a given time. That is how I have programmed expressions in the past-- to take a value from a channel as input.

RebelHill
03-04-2013, 01:31 PM
done so where... in LW?

Generall... X(K,t)... would be taken to mean...

Call function X with parameters K and t.

Archigram
03-04-2013, 01:50 PM
Ok, Yes in my Layout scene I have added a null and called it K so I could use its X position channel to control a series of other channels. In my previous experience with LW expressions, I have selected the channel I want controlled, gone to in the Modify tab in the Graph Editor, and added an Relativity expression, such as this from a previous animation: 33 - (11*(X(T1,t)-Y(T1,t)))

Maybe I've been confused about the REI expressions and others with different syntax. Again, sorry to try your patience and I appreciate your efforts to help.

RebelHill
03-04-2013, 02:18 PM
Yeah... relativity uses a different syntax (and given the norms used elsewhere, not just in LW) quite unintuitive/alien.

Give the expression builder in graph editor a peek, that'll help u get going.

Archigram
03-04-2013, 02:22 PM
OK thanks again. I'm not a programmer, so I found it slow going in the expression builder, but I will give that my full attention.