Using Blender's Python API, I took an object (in this case, an extruded plane), duplicated it, translated it to new XYZ coordinates with Z being the result of the combination of sine and cosine values, and randomly adjusted the scale along the Z axis.
I also did a rotation of the object along its Z axis using the randrange method from the random library and multiplying it by pi/2. if we remember from high school math, pi/2 = 90 degrees. So i essentially randomly picked 0, 90, 180 and 270 degrees.
Hopefully you can see by the code below what happens where. If you are curious about more, leave a comment and I will expound a bit more
Code below:
import bpy
from math import *
from random import *
def makeWaves(prefObj = "Plane", span = 20):
if bpy.context.object.mode != "OBJECT":
bpy.ops.object.editmode_toggle()
selectOriginal(prefObj)
for y in range(-span, span):
for x in range(-span, span):
z = ((sin(x) + cos(y)) + (abs(random() * (cos(x) * sin(y)) )) )/ 2.0 bpy.ops.object.duplicate_move(TRANSFORM_OT_translate={"value": (x*1.91, y*1.91, z)})
bpy.ops.transform.resize(value=(1.0,1.0,randrange(90, 125) / 100))
bpy.ops.transform.rotate(value= randrange(0,4,1) * (pi /2), axis = (0,0,1), constraint_axis=(False,False, True))
selectOriginal(prefObj)
return print ("Finished")
def selectOriginal(prefObj):
bpy.ops.object.select_all(action="DESELECT")
bpy.data.objects[prefObj].select = True
makeWaves()