## Parallel Lines using a Sine Node

Started by cyphyr, September 08, 2019, 12:50:00 pm

#### cyphyr

##### September 08, 2019, 12:50:00 pm
This is a simple node graph to create Parallel Lines.

It can be sued to create any kind of repeating parallel feature such as waves along a shore, ripples in the sand or parallel cloud banks.
The raw output is very small, the distance between the peaks is approximately 6.35m (I have no idea why).
The output can be scaled, rotated and moved with a transform node.
You can replace the X to Scalar with a Y to scalar or Z to scalar to produce Parallel Lines in those axis.

If you disable the X to scalar you get concentric circles

I hesitated to post this because although it works I don't feel I have the maths knowledge to properly explain "why" it works.
Maybe someone with better knowledge in that department can jump in
www.richardfraservfx.com
https://www.facebook.com/RichardFraserVFX/
/|\

Ryzen 9 3900X @3.79Ghz, 64Gb (TG4 benchmark 6:20)
Ryzen 9 5950X @3.4Ghz, 16Gb (TG4 benchmark 4:28)

#### Hetzen

##### October 10, 2019, 11:25:19 am #1
Thanks for posting this Richard.

I'll eventually get to the trig functions, but for now, if you want more control over the wave length, you can insert a multiply scalar after the X to Scalar to adjust the peaks.

Trig functions work in radians, so 2 x Pi x your X to Scalar will produce a full wave length across 1 meter.

#### N-drju

##### December 03, 2019, 03:42:03 pm #2
Thank you so much Richard! I've been looking for a way to set up some basic trigonometry in the TG scene! Sines and cosines being absolute basics.

Your example is very helpful and now I know what I have been missing. Converting a scalar to an "x" value now seems like something one would indeed do at the very start...

As to the "why it works" question (trigonometry-wise), I like to use this tool:

With the help of this visualiser, you can plan a function that you'd like to obtain in TG and then, little by little, translate it into blue nodes, the way you did!

And it doesn't really require that much of a mathematical knowledge either. All one has to do is to define a few values, and then pick a function from the "Keyboard" tab, where many such elements are listed.
"This year - a factory of semiconductors. Next year - a factory of whole conductors!"

#### Dune

##### December 04, 2019, 01:44:05 am #3
Ah, that is interesting. Never really built maths like that in TG to obtain a certain curve. Thanks for the link.

#### N-drju

##### December 04, 2019, 03:05:37 am #4
Come to think of it, one may also use this setup to make the plowed fields effect. You know, small, straight, undulating displacements.
"This year - a factory of semiconductors. Next year - a factory of whole conductors!"

#### Dune

##### December 04, 2019, 05:04:19 am #5
I use that a lot; just x to scalar, divide by some value to get width of rows, sinus, possibly a rotation, and a fractal warp, masking some ground texture.

#### Hetzen

##### December 06, 2019, 12:08:27 pm #6 Last Edit: December 06, 2019, 04:47:28 pm by Hetzen
You can also add some pinching to the peaks and widen the troughs to taste. The trig functions output -1 to 1. If you Add 1 and Multiply by 0.5 that range will become 0 to 1. Which is what a Bias or Gain node wants as an input. You can then vary the shape of the Cosine by adjusting the Bias or Gains second input. 0.5 is do nothing, towards 1 widens peaks and towards 0 flattens troughs.

I've attached my thoughts below.

#### Oshyan

##### December 06, 2019, 03:37:47 pm #7
I wonder if the Desmos graphing calculator (or another such free resource) would be a good addition to a general instruction/tools thread on function nodes somewhere in this forum area.

- Oshyan

#### Hetzen

##### December 06, 2019, 04:21:42 pm #8
Quote from: Oshyan on December 06, 2019, 03:37:47 pmI wonder if the Desmos graphing calculator (or another such free resource) would be a good addition to a general instruction/tools thread on function nodes somewhere in this forum area.

- Oshyan

Probably is, just inputting 'Cos X' is useful to see the shape.

#### Dune

##### December 07, 2019, 01:54:54 am #9
Might be handy to have an offline graph visualising method too.

#### N-drju

##### December 08, 2019, 03:45:48 am #10 Last Edit: December 08, 2019, 03:52:15 am by N-drju
Quote from: Oshyan on December 06, 2019, 03:37:47 pmI wonder if the Desmos graphing calculator (or another such free resource) would be a good addition to a general instruction/tools thread on function nodes somewhere in this forum area.

- Oshyan

But then of course, we need a brief instruction on how such a graph could be translated into a textural/displacement TG representation. It's all just maths. Since we have divide, subtract and other operators, it's just a matter of putting them in the right order!

EDIT: Just checked the graph for "arctan 4x = 1.5 cos y". I don't really understand how it is calculated. But imagine if we could translate this shape into series of displacement! Wow...
"This year - a factory of semiconductors. Next year - a factory of whole conductors!"

#### WAS

##### December 08, 2019, 01:32:12 pm #11
Quote from: Oshyan on December 06, 2019, 03:37:47 pmI wonder if the Desmos graphing calculator (or another such free resource) would be a good addition to a general instruction/tools thread on function nodes somewhere in this forum area.

- Oshyan

That's a great idea, with a little documentation on how to convert some basic formulas into TG to get people start similar to what N-drju was mentioning.

#### Hetzen

##### December 08, 2019, 02:33:02 pm #12
You can also use the scene I used to generate a cosine curve in the explained series. Attached below.

Right click on the internal network of the Cosine Generator node and you can use that as a test bed to try out some translations.

#### WAS

##### December 08, 2019, 06:23:38 pm #13
Quote from: Hetzen on December 08, 2019, 02:33:02 pmYou can also use the scene I used to generate a cosine curve in the explained series. Attached below.

Right click on the internal network of the Cosine Generator node and you can use that as a test bed to try out some translations.

Oh wow that's a good in-house idea, Hetzen.

#### N-drju

##### December 09, 2019, 04:29:46 am #14
Quote from: Hetzen on December 08, 2019, 02:33:02 pmYou can also use the scene I used to generate a cosine curve in the explained series. Attached below.

Right click on the internal network of the Cosine Generator node and you can use that as a test bed to try out some translations.

Now, the thing is that the waves cut through the "x" axis. Is it possible to elevate the entire equation so that it never takes on a negative "y" value?

For example, what would you say (and how would you build) the following function (or any simmilar) that essentially does exactly what is mentioned above?

"This year - a factory of semiconductors. Next year - a factory of whole conductors!"