1. IMPORTANT:
    We launched a new online community and this space is now closed. This community will be available as a read-only resources until further notice.
    JOIN US HERE

superformula

Discussion in 'Building With Reaktor' started by Stalone, Apr 30, 2014.

  1. Stalone

    Stalone New Member

    Messages:
    12
    Code:
      function sf2d(n,a)
        u=[0:.001:2*pi];
        raux=abs(1/a(1).*abs(cos(n(1)*u/4))).^n(3)+abs(1/a(2).*abs(sin(n(1)*u/4))).^n(4);
        r=abs(raux).^(-1/n(2));
        x=r.*cos(u);
        y=r.*sin(u);
        plot(x,y);
      end
    can anyone divine a translation of this superformula algorithm into reaktor? on the surface it looks pretty simple and I wonder what kind of applications it could have.
    http://en.wikipedia.org/wiki/Superformula
     
  2. Stalone

    Stalone New Member

    Messages:
    12
    what does the inner parentheses mean? (cos(t)) i imagine that to be cos merged with m*u/4 or cos replacing m: cos*u/4
     
    Last edited: Apr 30, 2014
  3. Stalone

    Stalone New Member

    Messages:
    12
    is this ^ a xor?

    i don't understand this line "Also note that x^(-1/n) = 1/x^(1/n) and x^(1/n) is the nth root of x." so i'm afraid i'm misunderstanding everything else too
     
  4. salamanderanagram

    salamanderanagram NI Product Owner

    Messages:
    3,454
    ^ is a commonly used symbol in math notation.

    x^y means raise x to yth power. ie 2^4 = 2*2*2*2 = 16

    i suggest you use primary to do this math, the x^y modules in core are finicky.
     
  5. Stalone

    Stalone New Member

    Messages:
    12
    thanks guys. how far off am i? i don't see where n4 goes
     

    Attached Files:

    • sf.zip
      File size:
      2.6 KB
      Views:
      60
  6. Stalone

    Stalone New Member

    Messages:
    12
    i'm a bit lost in the details at this point. my solution seems to create a broken circle.
     

    Attached Files:

    • sf.zip
      File size:
      3.6 KB
      Views:
      59
  7. Stalone

    Stalone New Member

    Messages:
    12
    beautiful little code block. thanks again! hope this thread continues to educate
     
  8. herw

    herw NI Product Owner

    Messages:
    6,421
    ?
    aus_der_zwischenablage.jpg
     
    Last edited: May 1, 2014
  9. salamanderanagram

    salamanderanagram NI Product Owner

    Messages:
    3,454
    you could also get a cosine out of a sine wave by offsetting the phase (not that it's necessary as herw pointed out).
     
  10. salamanderanagram

    salamanderanagram NI Product Owner

    Messages:
    3,454
    jim, the sine/cosine module in primary is normalized to have an input from -1 to 1 instead of the usual -pi to pi, that's what's causing errors. divide the input by pi and it should work.

    i imagine this is to simplify making a sine wave out of the ramp oscillator and such tasks, but can be confusing for math.
     
  11. herw

    herw NI Product Owner

    Messages:
    6,421
    yes - and an intersting point is, that there is no analogue equivalent, so it is really digital sound design.
    Ciao herw
     
  12. Stalone

    Stalone New Member

    Messages:
    12
    how do you get the difference?

    with modulation on all the parameters and xy fade up to 99 you can get some decent approximations of psychedelic geometry
     
  13. gentleclockdivider

    gentleclockdivider NI Product Owner

    Messages:
    744

    Could you elaborate on this ?.
    I created a chebby shev shaper in core
    The firt 12 polynominals ...full of pow's ....no problem whatsoever .
     
  14. salamanderanagram

    salamanderanagram NI Product Owner

    Messages:
    3,454
    well sure. there's the obvious problem of x needing to be positive in core.

    further you can see one of the problems by raising .0001 to the 30th power, which gives you a value of 0 in primary (as it should) and a value of 1.34*10^34 in core.

    mind you, this is rarely important, but good to keep in mind if you are getting into deep math.
     
    Last edited: May 16, 2014