Expressions

cwright's picture

with all the crash testing with expression stuff (atan2(x) and friends), I worked out some of the related expression parsing stuff in QC at large (for example, entering an expression in a number port evaluates correctly, etc etc).

Fascinated by this magic, I made the following new stuff in GLTools:

Basically, you enter an X, Y, and Z parametric equation, and it evaluates the curve and draws it. The pictured example draws a 700-segment helix.

(eventually, R, G, B, and A will also be parametric, and there'll be a blending, stencil, and width input to make it feature-complete with the other line patch).

Thoughts/requests? (If you think we're not working on a parametric surface patch for Kineme3D, you're crazy ;)

PreviewAttachmentSize
LineExpression.png
LineExpression.png118.05 KB

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

gtoledo3's picture
http://en.wikipedia.org/wiki/

http://en.wikipedia.org/wiki/Logo_(programming_language)

An extra option window for Logo :o) Penup, pendown....

cwright's picture
parameteric vs. procedural

turtle drawing is procedural (i.e. you feed commands one after the other). This is parametric (i.e. you feed it an equation, and it plots the equation in 3-space). While perhaps seeming similar, these are actually wildly different techniques.

We're just re-using Apple's expression evaluation stuff, which is parametric only. writing a procedural parser would be a lot more work...

gtoledo3's picture
Oh no, I do realize how

Oh no, I do realize how crazy different the two things are, and how this really didn't fit into the schema. It's just that any discussion on line drawing and Apple has to have some kind of reference to turtle... it is a law I think. All the same, I like the way it works. (warm apple II memories...)

It's interesting that you are talking about applying that to Kineme3D... it is an extremely logical and intuitive approach I think.

gtoledo3's picture
... this is nice... I'm

... this is nice... I'm wondering...

Is a texture/image input possible?

toneburst's picture
This is Nice...

Looking forward to the Parametric patch, in that case. Then maybe I can put that old Maths Surfaces QTZ I keep meaning to get back to to bed, finally....

;)

a|x

yanomano's picture
Variable input ?

wow Chris you rocks ! A good feature will be : Letter variable recognition with dynamic generation of the input that correspond (like the math expression patch)

cwright's picture
vars

It currently accepts variables (though it only sets "time" to the current patch time, and "t" from 0 to 1 to generate the curve).

Since the expressions are dynamic, rather than ports for variables (which can change each frame), we'd have a structure input that would take variable/value pairs, and set them accordingly. I think I'm planning on doing this before release -- this was just a mock-up to see if it would be usefully fast (it is), possible (it is), and interesting to kineme users (seems to be ;).

yanomano's picture
Yep, cool !

Yep, cool ! Do you think it will be possible to add start+end size ports (in case of Points expression) or Start/end thickness in case of lines Expression ?

PreviewAttachmentSize
flame.jpg
flame.jpg12.01 KB

gtoledo3's picture
Is it possible to have a

Is it possible to have a simple way of drawing lines from something like value historian, audio input, or any sorted structure... and being able to hook up the values to x/y/z inputs, or width/length?

Apologies if this strays too far outside of the zone of this discussion. It's just that we are talking about lines, and this is an idea I have been thinking of for the past bit...

cwright's picture
possibly

thickness could also be an expression. However, openGL's line drawing isn't very friendly when you do this.

For example:

Note the jagged cutouts around 45° -- that's where open GL change from drawing up-down lines to left-right lines (it can't do any other orientation) -- you don't see this with 1-pixel wide lines, but for anything else it'll be visible.

Anyone else interested in a Point Expression patch?

(I'm thinking that what you want might be more suited to Quartz drawing, which isn't really exposed in QC... it allows for nice drawing, but I'm not sure of its speed...)

PreviewAttachmentSize
hypnotize-blocks.png
hypnotize-blocks.png55.83 KB

gtoledo3's picture
What you are showing could

What you are showing could still be useful... if you lay two lines over one another with a slight start/end point difference, or perhaps rotate one of them a little, would it seemingly take the notches away?

cwright's picture
no

The notches are a property of drawing only horizontal/vertical-only lines. Rotation would just offset where the notches occur.

Ultimately, it breaks down to the following problem:

Draw a filled circle of radius r by only drawing horizontal or vertical lines of width r -- can't be done, the best you can do is a square with a side length of r .

I really think Quartz Drawing would be a more appropriate way to solve fancy vector graphics.

gtoledo3's picture
I see your point, most

I see your point, most definitely... what I mean is that if you have two circles with notches in the same place, and they are stacked exactly on top of one another, then you rotate one 5 degrees, the notches would occur offset. So, where there is a notch in the "top" circle, you would just see the circle below. You would only see "one" circle, or spiral, since the placement is exactly "on top" of one another, save for a minor rotation.... as long as the circles are the same color and x/y/z position (with just a lil' z rotation).

... so ultimately, if rotation does actually change where the notches occur.. the more of these you stack and rotate slightly, the smoother the look, no?

Sorry if I am blindly missing something or being tedious :o)

I agree with you about Quartz Drawing, and for me, your initial patch would be plenty enough to work with.

toneburst's picture
I'm with you

on that one. I'd love to see an implementation of NSBezier in QC- where you feed it a struct containing 3x 2D coords for each point, and it draws a nice smooth antialiased line, or solid shape, under programmatic control. There's a lot to be said for the beauty of smooth curved lines, even in 2D...

a|x

cwright's picture
miss interpretation

By offset, I meant offset on the curve, not offset on the screen (they'll always be around 45° in screen space). Rotation won't make the lines not horizontal/vertical, they are, regardless of rotation. (Imagine the particle system -- whenever you put it in a track ball, the particles still don't rotate any).

Stacking 2 curves on top of each other might luck out and have notches occur in different places, but it's a slow, sloppy solution, as the notches could still coincide from time to time.

gtoledo3's picture
slow and sloppy...

I guess that's what I was driving at more than anything... if there was a way to do that from a mathematical standpoint so that a perfect "notch" filling rotation could be easily, quickly, and reliably discerned. I thought if that was the case, then the plug in could be setup to draw offset lines that would look like one smooth, and no one would be the wiser.

Oh well, it was an idea (if perhaps not that reasonable of one... this one gets put on the list with "QC render buffer/delay upon entering desired frame rate + desired duration + desired image size" as well as "shadows".

gtoledo3's picture
Well, I don't know about

Well, I don't know about totally smooth... but that is where I was actually "heading" with my thread about "flat shading", eg, reducing the z with the shader.

I think that some bezier, and other curly and wavy lines can be made using this technique with 3D objects, or the kineme plane, with things like twister and gravity warp. I think the kineme plane might even be able to simulate that without glsl, if the length and width was setup correctly. and with appropriate gravity warp/twister/bendbox... not sure. Haven't tried it yet, just a hunch.