Page 1 of 1

Static Plus or Minus

Posted: Mon Apr 30, 2012 12:17 am
by ColorMeImpressed
I've been trying to create a function to act as a static plus or minus sign, but I keep getting an error saying there is an unhandled exception.
Here's the code:

Code: Select all

startshape box

staticsign()= if(rand_static()>.5,1,-1)

shape box
{
	SQUARE[h (2*staticsign()) b 1 sat 1]
}
Any idea what's going on or how to create a better static plus or minus?

Thanks

Re: Static Plus or Minus

Posted: Tue May 01, 2012 7:52 am
by MtnViewJohn
I get the exception too.

If you want a different static sign at each location then you have to actually invoke rand_static() each time:

Code: Select all

startshape box

sign(n) = if(n>.5,1,-1)

shape box
{
   SQUARE[h (2*sign(rand_static())) b 1 sat 1]
}
However, this code gives an error when it shouldn't. I will fix this and send out beta4 in a few days.

Re: Static Plus or Minus

Posted: Tue May 01, 2012 11:04 am
by MtnViewJohn
Try this:

Code: Select all

startshape box

sign(n) = if(n>.5,1,-1)

shape box
{
   SQUARE[h (2*sign(rand_static(1))) b 1 sat 1]
}
Changing rand_static() to rand_static(1) works around the bug in beta3.

Re: Static Plus or Minus

Posted: Tue May 01, 2012 4:52 pm
by ColorMeImpressed
It's working great now. Thanks a lot!

Re: Static Plus or Minus

Posted: Sat Jun 02, 2012 9:19 am
by murph
I am seeing a syntax error when functions are defined... as above. I first saw it while trying out
the demo code from the Symmetry pages...
a_from_bAc( _b, _A, _c) = sqrt(_b^2 + _c^2 - 2* _b*_c*cos(_A)) also when I tried the Ack function from the
documentation:
// Ackerman function
ack(m, n) =
if(m == 0,
n+1,
if(n == 0,
ack(m-1, 1),
ack(m-1, ack(m, n-1))
)
)

How did you get the following to work? :
startshape box

sign(n) = if(n>.5,1,-1)

shape box
{
SQUARE[h (2*sign(rand_static(1))) b 1 sat 1]
}

Re: Static Plus or Minus

Posted: Sat Jun 02, 2012 12:12 pm
by MtnViewJohn
Are you sure that you have the latest beta release? I just tried

Code: Select all

startshape box

sign(n) = if(n>.5,1,-1)

shape box
{
   SQUARE[h (2*sign(rand_static(1))) b 1 sat 1]
}
On Windows, Mac, and Unix and it worked fine. Are you running v3 beta4? What is the number in parentheses when you bring up the About dialog?

Re: Static Plus or Minus

Posted: Sat Jun 02, 2012 6:12 pm
by murph
cfg...Help..About... : 3.0a (v23)

How does this relate to alpha, beta, etc.? I thought I had a recent version; but guess I should download again..
I just checked my download folder and found a ...install3.0beta4.exe dated may 7... Maybe I never ran it.. :(
Just ran it. I'm probably all set.. at least the wallpaper sampler rendered!! as a p1.. Which is what i was
originally trying to accomplish. Thanks. Embarassed.... ;)

Re: Static Plus or Minus

Posted: Sat Jun 02, 2012 11:33 pm
by MtnViewJohn
No worries. I've done that before.