5
$\begingroup$

I'm new to geometry nodes and I want to do graph animation. I want to graph rises rapidly, the nearer gets to the middle high point and gets slowly down on both sides in the same way. This is what I want to get:

Enter image description here

Enter image description here

And this is what I've done so far:

Enter image description here

This is what I got with it.

And I know that I won't get the middle point with this function, but I don’t care now. I tried to find an answer on the Internet, but I couldn’t find anything. How can I do it?

$\endgroup$

2 Answers 2

9
$\begingroup$

TL;DNR: There's a blend file at the end with a node tree that creates a mirrored sigmoid function that accomplishes what you want.

You can accomplish roughly this with this node group:

Node Group

It generates this curve:

graph

Set keyframes on the amplitude value to change the height of the curve. That's your "certain number".

How it works

The upper framed nodes create a mesh line whose range runs from 0 to whatever maximum X value you set in the range input node.

The lower framed nodes create the function you want to plot. In this case it's merely $A*sin(f*x)$ over the range set in the top part; where $A$ is the amplitude value and $f$ is the frequencey value.

How to use it

By changing the Math nodes between the separateXYZ and combineXYZ nodes you can change the overall shape of the curve to the one you want.

If you want it centered on the origin, you can simply use a Transform node on the end to move it back, or do a bit of arithmetic on the x value of the coordinates to move it in the Set Postion node. I've done the later.

Your equation

You're looking for a symmetric variation of the sigmoid function $$ e^x / (e^x + 1) $$

You want the negative values to be in the range of around -4 to around 4 and the positive values to be in the reverse of that range. Multiply the result by your "certain number" to get a curve that looks like your drawing.

Here's a node group that gives you the negative half of the curve. Note that I've added the nodes to move the curve back so it ends on the origin.

Negative half of the sigmoid curve

result

Note that if you replace $e$ with multiples of $e$ you can make the curve more pronounced: Here I've replaced $e$ with $3e$:

more pronounced curve

Finally, by doing the curve twice, once with the x range fed to the function reversed you get this mess of nodes:

final version

and this result:

final curve

Controlling the width

It's designed to be symmetric and you can control the two points on the X axis using the Range input that's in the upper framed area. If you don't want symmetry you will have to do a bit of extra work.

Bonus for reading this far

Here's a blend file containing the final node group.

$\endgroup$
4
$\begingroup$

or you choose the simple way, with this very easy to understand and very easy to handle setup:

enter image description here

so...what you see is what you get... ;)

enter image description here

$\endgroup$
3
  • $\begingroup$ Very simple indeed. So simple that it can't be animated. The OP did write "I want to do graph animation." Also, not so simple when you're trying to eyeball match the described curve. And, of course, you can't control the width or the height without more nodes. $\endgroup$ Apr 6, 2022 at 14:38
  • 1
    $\begingroup$ @MartyFouts agreed, to a point.... but .. in Chris' defence it could be animated by mixing between 'shape key' manual curves, and/or between those and 0? And OP didn't specify a function? I liked your answer, too.. :) $\endgroup$
    – Robin Betts
    Apr 6, 2022 at 16:05
  • 1
    $\begingroup$ @RobinBetts OP described a function in words; and asked specifically for control of height and width. But your suggested changes would produce a very different answer than Chris' and not hardly as simple. This "answer" doesn't answer the question; so I don't think you've offered a defense. $\endgroup$ Apr 6, 2022 at 16:10

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .