cos() in Math Expression doesn't seem to work; JS does?

lunelson's picture

Hey,

this might be some kind of short-sightedness on my part but I tracked down a bug today to what seems to be an incorrectly (non-) functioning cos() in the Math Expression patch. In the info for the patch it seems to suggest that cos() should be supported and the code highlighting works, but it doesn't give the right output, at least here.

I've attached a comp with both JS versions and ME versions of the same formula. You can switch between them and see that the ME one does not compute.

PreviewAttachmentSize
Math Exp Cos Broken?.qtz5.08 KB

cwright's picture
Re: cos() in Math Expression doesn't seem to work; JS does?

Your math is wrong -- one expects degrees, the other radians.

If you put the following in for Mathematical expression, they're essentially the same: -c/2 * (cos(180*t/d) - 1) + b

lunelson's picture
Re: cos() in Math Expression doesn't seem to work; JS does?

Thanks,

I realize now too, that I could have found that with a search; I never dreamed that the functions would be defined differently in the two patches BTW, is there a particular "language" or spec for the Math Expression patch then? A reference one can turn to?

songcarver8's picture
Re: cos() in Math Expression doesn't seem to work; JS does?

This is a general opportunity for improvement I see in Quartz Composer — being able to know what type of units (and expected range) each port of a patch accepts.

usefuldesign.au's picture
Re: cos() in Math Expression doesn't seem to work; JS does?

Generally it's in the (limited) docs but, no, it's not available via the GUI with a mouseover or anything like that. Patch descriptions are pretty brief too for new users.