generative modeling for Rhino
I found myself wanting to write sign(x) in an expression, and there doesn't seem to be an easy way to do it; I'm going to use a conditional instead.
Sin(x) you mean?
I think it refers to the SIGN transfer function of Fortran days.
Where you could specify two variables Sign(x,y) which would change the sign of x if y was different.
sign(1,2) = 1
sign(1,-2) = -1
sign(-1,2) = 1
sign(-1,-2) = -1
I was thinking more of the more modern sign() function, where:
-1 if x < 0
sign(x) = 0 if x = 0
1 if x > 0
This can be used as a sign transfer function by multiplication:
sign(x) * whatever
I ended up writing something like "if(x>0,1,-1)", which worked, but isn't very elegant.
A very late note in this thread; this is called the "signum" function, usually denoted "sgn," though some computer languages make it "sign." See http://mathworld.wolfram.com/Sign.html. I still wish Grasshopper included it.
Try to use if(x<0,-1,0)+if(x>0,1,0) , why would be not ....
...or if(x=0,0,x/abs(x)) ......