## Math to Expr – for the expr experts

Jul 31, 2010 at 9:12pm

# 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 < = u <= pi
-pi < = v <= p

here is the shape and link where I got the equation

http://local.wasp.uwa.edu.au/~pbourke/geometry/tranguloid/

if anyone is up to it , I think this could help a lot of people that are searching for generating expr shapes.

thanks

#51589
Jul 31, 2010 at 11:00pm

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 < = value <= pi.

Now I want to hook it up to GL and see if it works!

``````
----------begin_max5_patcher----------
1281.3oc0Z00bahCE8Y2Y5+AML6CIs1TckDRnNsOr+K1ca6rCwljxN1fGCNq
a6r+2W8A9iXavjDajbdHXjDhiN5n68pq3Wu8MCBtqXUZY.5inufFL3WpRFXJ
SWxf0ELHXVxpwSSJMMLXbwrYo4UACqqrJcUkohG2Tz7jpweOK+g+dQ53JauK
wrP7PDHYgRYDAKGhXzvXo5uX0OIgXz2V+34KmkkOMsx79f0kdeQdUdxrTy65
2WjkLMXmGnXY05m.ut3rIl1Vb2+LhRC1seJy9ooenPHlKDRoot+6suQeUcY3
qmMV1FaHDXmxFr9lM9q1XiXpzorQzEhMlkVVl7P5grANjQ43HnUIh98ODQUW
d2GxUUn6P22p5gGoYEhPXHmnPQj5N7YTzPNFGIZlitKI+gfgnf6mVjT0.gAJ
U8YmqRWMeA5lwEk27a2C2hFgHgn2gz2a9gtvaUW028djsYjCKQ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Iv4fEDcxNGIxILGoSdHHR2.tNsZk3FivjNsff3lED6ql
Z.btYyMPmzbfa.WmHtW+jpt.0k+Gq5JLC
-----------end_max5_patcher-----------
``````
#185060
Aug 1, 2010 at 2:39am

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?

#185061
Aug 1, 2010 at 2:51am

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

– Pasted Max Patch, click to expand. –
#185062
Aug 1, 2010 at 7:25am

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

[expr (cos(\$f1) - 2 (cos(2(\$f1)))) (2 + cos(\$f2)) (2 + cos((\$f2) + 6.28318530718 / 3)) / 4]

-110

#185063
Aug 1, 2010 at 4:01pm

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…

– Pasted Max Patch, click to expand. –

[attachment=137898,893]

###### Attachments:
#185064
Aug 1, 2010 at 8:24pm

very cool!! seejayjames, ill try and pass it to a mesh, and post it if I get it.

#185065
Aug 1, 2010 at 10:48pm

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….

– Pasted Max Patch, click to expand. –
#185066
Aug 1, 2010 at 11:32pm

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.

#185067
Aug 1, 2010 at 11:35pm

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:

http://cycling74.com/2010/03/08/demystifying-expressions-in-jitter/

#185068
Aug 2, 2010 at 12:07am

Joshua thank you , that is the info i’ve been needing. :)

#185069
Aug 2, 2010 at 5:10am

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.

– Pasted Max Patch, click to expand. –
#185070
Nov 26, 2013 at 11:35pm

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…

– Pasted Max Patch, click to expand. –
#273893

You must be logged in to reply to this topic.