Forums > MaxMSP

Math to Expr – for the expr experts

July 31, 2010 | 9:12 pm

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

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


July 31, 2010 | 11:00 pm

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!

August 1, 2010 | 2:39 am

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?

August 1, 2010 | 2:51 am

I managed to get a shape out of this equation , wish is a lot easier.. (don’t know if its correct)

— Pasted Max Patch, click to expand. —
August 1, 2010 | 7:25 am

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]


August 1, 2010 | 4:01 pm

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


  1. scr_shot_trianguloid.PNG


August 1, 2010 | 8:24 pm

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

August 1, 2010 | 10:48 pm

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. —
August 1, 2010 | 11:32 pm

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:


It demonstrates the translation of a few equations from Paul Bourke’s website.

August 1, 2010 | 11:35 pm

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:

August 2, 2010 | 12:07 am

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

August 2, 2010 | 5:10 am

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. —
November 26, 2013 | 11:35 pm

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. —
Viewing 13 posts - 1 through 13 (of 13 total)

Forums > MaxMSP