 VIOLENT  VOLUMES

## Interference of sine waves on a plane This mesh model can be easily modeled with 3DS wave modifier.
Here’s a sample code to achieve the same result with Rhino SDK.
The sample is taking three points of origin of sine waves.

```    Dim shit As New Mesh
Dim gridptsflat As New list (Of point3d)
Dim gridpts2D As New list (Of list (Of point3d))

Dim intervalx As Double = x / numx
Dim intervaly As Double = y / numy

Print(intervalx)
Print(intervaly)

'Grid
For i As Integer = 0 To numx
Dim gridpts1D As New list  (Of point3d)
For j As Integer = 0 To numy

Dim temppt As New point3d(intervalx * i, intervaly * j, 0)
Print(temppt.ToString)
Dim z1,z2,z3 As Double
'set Z
z1 = getSine(para1.item(0), para1.item(1), cp1.DistanceTo(temppt), para1.item(2))
z2 = getSine(para2.item(0), para2.item(1), cp2.DistanceTo(temppt), para2.item(2))
z3 = getSine(para3.item(0), para3.item(1), cp3.DistanceTo(temppt), para3.item(2))

Dim fo1 As Double = 1 - (cp1.DistanceTo(temppt) / para1.item(3))
If fo1 < 0 Then fo1 = 0
z1 = z1 * fo1

Dim  fo2 As Double = 1 - (cp2.DistanceTo(temppt) / para2.item(3))
If fo2 < 0 Then fo2 = 0
z2 = z2 * fo2

Dim  fo3 As Double = 1 - (cp3.DistanceTo(temppt) / para3.item(3))
If fo3 < 0 Then fo3 = 0
z3 = z3 * fo3

'set amp Z
temppt.Z = z1 + z2 + z3

'save pts

Next
Next

'Make Cloth
Dim remainder As Integer
For i As Integer = 0 To gridptsflat.count - numy - 3

math.divrem(i + 1, numy + 1, remainder)

If  i <> 0 And remainder = 0 Then
'Print("oh, shit")
Else
shit.Faces.AddFace(i, i + 1, i + numy + 2, i + numy + 1)
'Print(i & "," & i + 1 & "," & i + y + 2 & "," & i + y + 1)
End If
Next
Function getSine(wavelength As Double, amplitude As Double, inputx As Double, shifty As Double)
Dim result As Double
result = math.Sin(inputx / (wavelength / (2 * math.PI)) - shifty) * amplitude
Return result
End Function
```

Categorised as: Generative design

### One Comment

1. Leaphr says:

Hi,Kim, great work! it’s the best ripple effect I have ever seen done by rhino, but is it possible for you to share the .vb file or .3dm file? I’d like to use it in my grasshopper project, but I’m quiet a newbee in vb. could you please send the file to my email:puppylove411@msn.com and it will be a huge help for me to understand it, thanks a lot!