Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Interesting Math Waves

Discussion in 'Scripting' started by lordconstant, Feb 12, 2015.

  1. lordconstant

    lordconstant

    Joined:
    Jul 4, 2013
    Posts:
    389
    hi,

    I am a making a game with procedurally generated point bubbles using different combinations of mathematical waves such as sin, cos & tan. I was wondering if anyone knew of any cool looking ones i can implement into my game.

    Thanks in advance.

    Current Waves:

    Code (CSharp):
    1. float GenerateSmallBumps(){
    2.         return Mathf.Cos(Mathf.Clamp(Mathf.Tan(Time.time), -1, 1)) * curSpawnRadius;
    3.     }
    4.    
    5.     float GenerateSinWave(){
    6.         return Mathf.Sin(Time.time) * curSpawnRadius;
    7.     }
    8.  
    9.     float GeneratePingPong(){
    10.         return Mathf.PingPong(Time.time, curSpawnRadius) - (curSpawnRadius/2);
    11.     }
    12.  
    13.     float GenerateTanWave(){
    14.         return Mathf.Tan(Mathf.Clamp(Mathf.Cos(Time.time), -0.3f, 0.3f)) * curSpawnRadius;
    15.     }
    16.  
    17.     float GenerateCosWave(){
    18.         return Mathf.Cos(Time.time) * curSpawnRadius;
    19.     }
    20.  
    21.     float GenerateSinXCos(){
    22.         return (Mathf.Cos(Time.time) * Mathf.Sin(Time.time)) * curSpawnRadius;
    23.     }
    24.  
    25.     float GenerateSinXCosXTan(){
    26.         return Mathf.Exp(Mathf.Sin(Time.time)) * curSpawnRadius;
    27.     }
    28.  
    29.     float GenerateCeilSin(){
    30.         return Mathf.Ceil(Mathf.Sin(Time.time) * curSpawnRadius);
    31.     }
    32.  
    33.     float GenerateResrictedSin(){
    34.         return Mathf.Clamp(Mathf.Sin(Time.time), -0.8f, 0.8f) * curSpawnRadius;
    35.     }
    36.  
    37.     float GeneratePingPongXSin(){
    38.         return (Mathf.PingPong(Time.time, curSpawnRadius) * Mathf.Sin(Time.time));
    39.     }
    40.  
    41.     float GenerateSignWave(){
    42.         return Mathf.Sign(Time.time) * curSpawnRadius;
    43.     }
     
  2. hpjohn

    hpjohn

    Joined:
    Aug 14, 2012
    Posts:
    2,190
    Perlin
     
  3. lordconstant

    lordconstant

    Joined:
    Jul 4, 2013
    Posts:
    389
    Thank You.
    I was using perlin in a different area and it never even occured for me to use it XD
     
  4. quizcanners

    quizcanners

    Joined:
    Feb 6, 2015
    Posts:
    107
    Cool stuff
     
  5. Kiwasi

    Kiwasi

    Joined:
    Dec 5, 2013
    Posts:
    16,860
    In general any wave can be built by adding sine curves of various frequencies and phases.
     
  6. cranky

    cranky

    Joined:
    Jun 11, 2014
    Posts:
    180
    And amplitudes ;). Hobbyist musician here.