Math to Expr - for the expr experts
I am trying to learn jit.expr Ive gone over the tutorials etc. it might be helpfull seeing how someone transfers a mathematical equation into a expr shape. That I think is the best way to learn.
so, if anyone wants to help here is an equation
x = 2 sin(3 u) / (2 + cos(v))
y = 2 (sin(u) + 2 sin(2 u)) / (2 + cos(v + 2 pi / 3))
z = (cos(u) - 2 cos(2 u)) (2 + cos(v)) (2 + cos(v + 2 pi / 3)) / 4
-pi
-pi
here is the shape and link where I got the equation
if anyone is up to it , I think this could help a lot of people that are searching for generating expr shapes.
thanks
my attempt, I don't know if it's right. Not an expr expert (say that 10 times fast) and don't know jit.expr that well. But I think all the bits are accounted for in the three [exprs].
If you want individual control over the u and v in each expression, you can add $f3, $f4, etc., up to $f9. As it is, there's one u and v float control box for each expr, plus a master one which does all 3 at once. All are restricted to -pi
Now I want to hook it up to GL and see if it works!
seejayjames thanks, very interesting how you can change the expr expression by adding different number variables, thanks to your patch I understand how that works much better.
but I also want to hook it up to the gl. that was my initial problem, getting the math equation to fit the particular jitter matrix language
by using norm 0,1 snorm 0,1 in... etc
but Like I said, thank you, your patch is helpful.
,,,,, can anyone help bringing this to the gl world?
I managed to get a shape out of this equation , wish is a lot easier.. (don't know if its correct)
http://local.wasp.uwa.edu.au/~pbourke/geometry/borg
i dont use [jit.expr] but [expr] cant do much more than what is noted in the helpfile.
and you have a lot of freedom with the syntax, no particular style is required.^^
z = (cos(u) - 2 cos(2 u)) (2 + cos(v)) (2 + cos(v + 2 pi / 3)) / 4
just reads
[expr (cos($f1) - 2 (cos(2($f1)))) (2 + cos($f2)) (2 + cos(($f2) + 6.28318530718 / 3)) / 4]
-110
well, sort of working :)
a rough attempt, using two [uzis] to make all the points manually. surely there are much better (and faster!) ways, my computer bogs down pretty soon with higher numbers of points. I imagine putting all the values into a matrix and using jit.gl.mesh would be better, or straight-up jit.expr would probably be best.
Though there are some other fun controls in there, have a go...
very cool!! seejayjames, ill try and pass it to a mesh, and post it if I get it.
grr, Still in need of jit.expr experts to help with this one.
I manage to get some type of shape (nothing like the shape of the math formula)
I tried translating the x and y of seeJames patch into a jit.expr but did not get anything to work so I added my jit.expr interpreation of the x and y to a Sphere and then got some type of shape....
I don't have time to dig into this completely, however, I believe that you can simply replace u with (snorm[0]*PI), and v with (snorm[1]*PI) for u,v in the range of -pi to pi.
This is essentially what happens in the jsglsurface-example.maxpat and associated JS. Find it in:
examples/jitter-examples/javascript/render/jsglsurface-example.maxpat
It demonstrates the translation of a few equations from Paul Bourke's website.
Also in your examples, you need to put quotes around each plane's expression if there are any spaces within the expression.
Please take some time with Andrew Benson's great expr tutorial:
Joshua thank you , that is the info i've been needing. :)
I don't know what Iam doing wrong, I tried to make the mathematical shape and this is what comes out .... it is better than last one but still lost.
I know it's been a while since anyone posted on this thread, but it's all new to me, so I thought I'd try and figure it out.
It looks like you forgot a single multiplication operator at the beginning of the expression for the second plane. And it's not clear what those additional snorm functions are between each of the quoted expressions. They don't appear to be necessary and they keep the whole thing from working properly.
Here's what I ended up with...