Missing Convert option (?)

I am currently trying to implement automatic eye tracking in an animation I am making in order to get familiar with synfig.

As far as I can tell, in order to do what I want properly, I need to be able to transform an (x,y) location with the inverse of the Spherize distortion, without using the distortion layer itself (i.e., just by using the math functions provided by Convert). While investigating this, I found that there is almost no real documentation of the internals of the Spherize distortion, so I have decided to try to document it by making a much simpler animation which calculates the distortion and its inverse using Convert.

I have run into a big problem while trying to do this. There doesn’t seem to be any way to convert an angle into a real value (for example, its size in radians). Or visa versa. Am I missing something here?

It is possible to convert a real number into an angle by using the Scale Convert value type.

Angle = Link (angle) * Scalar (real)
then link the scalar to a Real Value (i.e. the radius of a circle)
So when you change the radius of the circle, the angle changes by the amount of Link.
The inverse (Real = Angle (radians)) has not been coded. Not a real problem to code because Angles are real numbers internally.
Also, it is interesting the Vector spherized = ValueNodeSpherize(Vector Link, Real radius, Vector origin) convert type. It can be useful for some things. You’re invited to code the Value Node Convert class. Although it is C++ it is fair easy to code (if you know the math formulation) because looking the other convert types gives you enough hints to create your own one.
AnglefromReal.sifz (567 Bytes)

Ah, yes, I didn’t think of doing that. Thanks for the info. OTOH, I’m more interested in the opposite conversion, which I understand I’ll have to code for myself (and submit as a patch).

I don’t find that in the 0.62.01 source code — is it currently in the bleeding edge code or did I misunderstand and you are proposing I write it?

Actually, I was thinking that I wouldn’t need to recode Spherize inside my eye-tracking animation if I had a way to “transformed-link” (x,y) locations from a given Z value (or more exactly, from a given layer inside the layer tree) as they would be transformed by the render process at a given different layer higher up in the rendering process. But I can’t think of how I could even fit that into the data model that I see (because there is no “Layer” data type), without even thinking about how much work it might be within the current code framework.

Yes. It would be a good exercise :slight_smile:

No no, it doesn’t exists. But it might be interesting to code.

There is no “Layer” data Type. So at the moment it is not possible to retrieve the Layer’s position in the stack to be used by a value node.
I’m curious what’s the setup that you are preparing where you need that kind of Conversions. Maybe if you explain it a bit we can find an alternative way to produce the same effect.

Maybe you don’t have noticed but the ducks (not the lines that connect the ducks) are transformed when displayed in the canvas under the influence of a spherize layer. Also you can link the spherize amount with a derived value of the Z depth of the layer (which at the end is responsible of the layer’s stack position for an initial layer’s position in the stack. Does those hints help?

I was planning, as an exercise (and maybe a how-to for others), to produce an animation with a face with two eyes (reusing the blinking eyelids example) and a nose and in addition a fly whose position is Random centered on the nose with a radius which decreases in time until the landing frame (when it will be zero). However, I want the eyes to automatically track the fly’s position. I understand I can approximate this by animating the fly with sampled waypoints from the Random path and manually fixing the eyes to track the same waypoints but that isn’t the point of the exercise :slight_smile:.

It’s pretty simple math to find the (x,y) locations of the eye pupil as a function of the location of the fly, the radius of the eyeball, and the values of z for the plane in which the fly is located and for the plane of the center of the eyeballs. But then I need to invert the Spherize distortion used in the eye example so that after the distortion the (x,y) locations will be correct.