How to translate a math equation in processing ?

edited November 2016 in How To...

Hello, I'm new in processing. I'm trying to create a variation on Fermat spiral based on an equation and then export it in PDF. I have the code to create a Fermat spiral (several existing example exist) but I can't control it as I would do using an equation. I was wondering if there is a way to simply "translate" an equation into processing ?

Capture d’écran 2016-11-15 à 16.35.02

Thanks for your tips and help !

Tagged:

Answers

  • Answer ✓
    void setup() {
      size(500, 500);
      noLoop(); 
    }
    
    void draw() {
      translate(width / 2, height / 2); // centre origin
      strokeWeight(.1);
      scale(25);
    
      for (float u = 0 ; u < 10 * PI ; u += .1) {
        // cube root is same as raising to power of 1/3 so...
        // the 100/55th root is same as raising to power of 55/100
        float x = pow(u, .55) * cos(u);
        float y = pow(u, .55) * sin(u);
        point(x, y);
      }
    }
    
  • Impressive, many thanks !!

  • edited November 2016 Answer ✓

    If you are dealing a lot with evaluating mathematical expressions in the future, @Quark 's QScript also supports mathematical expression evaluation.

  • Answer ✓

    The Jasmine library is faster than QScript for evaluating mathematical equations.

    In this case, both these libraries are a bit over-the-top, and I would go with koogs code.

  • @quark @jeremydouglass: Thank you for your relevant answers. I will certainly try the solutions you proposed.

Sign In or Register to comment.