User Tools

Site Tools


4rpl:commands:signalgenerator

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
4rpl:commands:signalgenerator [2024/05/29 19:56] Grabz4rpl:commands:signalgenerator [2025/09/03 16:43] (current) – [Sine wave in any direction without gaps] kalli
Line 70: Line 70:
 </code> </code>
 ==== For triangle wave function ==== ==== For triangle wave function ====
-===  Time and Frequency === 
 <code c#> <code c#>
 value = 1f - 4f * (float)Mathf.Abs(Mathf.Round(t - 0.25f) - (t - 0.25f)); value = 1f - 4f * (float)Mathf.Abs(Mathf.Round(t - 0.25f) - (t - 0.25f));
Line 141: Line 140:
  1 ->signalType # type of signal generated  1 ->signalType # type of signal generated
  0.5 ->scale # control the maximum size of movement  0.5 ->scale # control the maximum size of movement
 +</code>
 +
 +==== Sine wave in any direction without gaps ====
 +{{ :4rpl:commands:sinewaveanydirection.png?nolink&600 |}}
 +
 +<code 4RPL> 
 +30 30 v2 165 91 v2 15 4.5 0 @getSinusoidCells ->list
 +<-list 0 do
 + <-list[i] ev2 dup2 getterrain 5 add setterrain
 +loop
 +
 +:getSingleLineCells # INPUTS: <-startCell <-endCell. OUTPUT: a list of cells.
 +->cell1
 +->cell0
 + <-cell1 <-cell0 sub ->dir
 + <-dir.0 abs <-dir.1 abs max ->length
 + <-length eq0 if 0 0 v2 else <-dir <-length asfloat div endif ->dirL
 + <-cell0
 + <-length 0 do
 + dup <-dirL add
 + loop
 + <-length 1 add listN
 +
 +:getSinusoidCells # INPUTS: <-startCell <-endCell <-amplitude <-intervals <-phaseShift01. OUTPUT: a list of cells.
 +->shift # FLOAT between 0 and 1 that will shift the signal from signalgenerator.
 +->intervals # Amount of signal intervals between first and last cell.
 +->ampl
 +->cell1
 +->cell0
 +
 +clearstack
 +<-cell0 <-cell1 @getSingleLineCells dup ->axisCells getlistcount ->axisLength
 +<-axisLength asfloat <-intervals div -1 pow ->freq 
 +
 +<-cell1 <-cell0 sub normalize ->dir
 +<-dir.1 <-dir.0 neg v2 <-ampl mul ->dirP
 +
 +<-cell0
 +<-axisLength 1 do
 + i <-freq <-shift 0 1 signalgenerator <-dirP mul <-axisCells[i] add @getSingleLineCells ListToStack
 +loop
 +list
 +
 </code> </code>
  
 <=[[4rpl:start| Index]] <=[[4rpl:start| Index]]
4rpl/commands/signalgenerator.1717012615.txt.gz · Last modified: 2025/02/14 14:56 (external edit)