3

I'm not a math person, but I use math curves in my animation work with Blender.

I would need this sin(x)+x "stairs" curve, but it should begin from the red dot being in the origin.

Ideally the "stairs" should be the height of 1.0 per each and the width of 1.0 from each other, but this is not required if it makes things too complicated.

How the formula should be edited in order to get that desired result?

BONUS, extra appreciation if some other methods are provided to make the vertical part of the "stairs", or the lines pointing upwards, to grow and shrink more exponentially than now. Like this.

enter image description here

4 Answers4

5

To get the red dot on the $y$-axis (where $x=0$) instead of at $x=\pi$, shift the variable $x$ by $-\pi$ to get $$\sin(x-(-\pi))+(x-(-\pi))=\sin(x+\pi)+(x+\pi).$$ To get the red dot on the $x$-axis (where $y=0)$ instead of at $y=\pi$, shift the whole function by $-\pi$ to get $$\sin(x+\pi)+(x+\pi)-\pi=\sin(x+\pi)+x.$$ To get steps of width $1$ instead of width $2\pi$, scale the variable $x$ by a factor $2\pi$ to get $$\sin\left(2\pi x+\pi\right)+2\pi x.$$ To get the steps of height $1$ instead of $2\pi$, scale the whole function down by a factor $2\pi$ to get $$\frac{\sin\left(2\pi x+\pi\right)+2\pi x}{2\pi}=\frac{1}{2\pi}\sin(2\pi x+\pi)+x.$$

Servaes
  • 63,261
  • 7
  • 75
  • 163
1

Input the below into desmos

$$x\ -\frac{1}{2}\ +\ \frac{1}{\pi}\sum_{n=1}^{a}\frac{\sin\left(2\pi nx\right)}{n}\ \left\{x\ge0\right\}$$

When prompted, add a slider for $a$. The larger your $a$ the better the stairs will look. You can change the $0$ in the curly brackets at the end to shift the stairs as you wish.

In case you wish to know more about where this expression came from, you can check out the following links:

Floor Function

Fourier Series

Fourier Series for the Floor function

Gaurav Chandan
  • 479
  • 4
  • 11
  • 1
    Here it is entered to Desmos: https://www.desmos.com/calculator/6pry3dlp6g - Very stairs-like! Event though quite hard to input into Blender nodes :/ - Thank you very much anyways! Learned some Desmos aspects like SUM – Manu Järvinen Jun 12 '23 at 11:44
1

Found a perfect answer to what I was looking for with the help of this - Result:

https://www.desmos.com/calculator/azirgqxnuw

enter image description here

  • I think this should be marked as the accepted answer because this is the only variant that allows freely adjusting the slopes. It's also recommended to include the data in the answer to make it available even if the referenced service is down. Here's one variant: h*(tanh(ax/w - a * floor(x/w) - a/2) / (2 * tanh(a/2)) + 1/2 + floor(x/w)) where a=20, w=1, h=1 – Mikko Rantalainen Jun 13 '23 at 13:12
  • @MikkoRantalainen Thank you. Okay, I shall mark this as the answer :) – Manu Järvinen Jun 14 '23 at 13:01
-1

Are you maybe looking for shifting the offset? Maybe something like

$$ \sin(x + \pi) + x $$

is good enough?

  • 2
    For my purposes this would be perfect! :) Thank you. I don't understand the Minus point of the answer. I shall explore the other answers as well, wonderful. – Manu Järvinen Jun 12 '23 at 11:13
  • I don't understand why this answer is downvoted. – uriyabsc Jun 12 '23 at 11:14
  • I would guess the minus vote is because this answer is technically incorrect in mathematical sense but I answered the most simple way that could work in Blender context – that is practical engineering instead of strictly correct in mathematical sense. – Mikko Rantalainen Jun 12 '23 at 11:16
  • 2
    The answer $x − \frac{1}{2 \pi} sin(2 \pi x)$ is the way to go if you want the optimal scale mentioned in the original question. – Mikko Rantalainen Jun 12 '23 at 11:18