A want to model a several curves to have a perfect sinusoidal structures of specific integer frequencies. Is there any kind of generator for linear waves in curves?
Asked
Active
Viewed 175 times
2
-
Check this: https://blender.stackexchange.com/questions/47337/is-there-any-way-i-can-make-a-curve-and-or-a-mesh-from-a-wavefile – Jan Matys Oct 04 '18 at 22:01
-
1I don't understand how that relates. This topic is not related to .wav files, it is related to the structure of a physical wave. – Vane Voe Oct 04 '18 at 22:05
-
https://blender.stackexchange.com/questions/74410/graph-in-blender-a-function-of-two-variables/ and https://blender.stackexchange.com/questions/73741/how-can-i-create-a-3d-curve-saddle-shape/ – Duarte Farrajota Ramos Oct 04 '18 at 22:54
-
It creates a mesh, but what about a curve? It doesn't let me set the thickness to 0 even. – Vane Voe Oct 05 '18 at 01:00
1 Answers
3
Here is the script that would do this (you can set the value of startX, endX and cycles' while calling drawSineWave based on frequency and increase the resolution to take it closer to the perfect sine wave.)
import bpy
import bmesh
import math
def drawSineWave(resolution, startX, endX, cycles, amplitude):
bm = bmesh.new()
step = (endX - startX) / (resolution)
cycleSteps = resolution/cycles
x = startX
prevVert = None
for i in range(0, resolution+1):
magnitude = 2 * math.pi * (i % cycleSteps) / cycleSteps
y = amplitude * math.sin(magnitude)
vert = bm.verts.new([x, y, 0])
if(prevVert != None):
bm.edges.new([prevVert, vert])
x += step
prevVert = vert
mesh = bpy.data.meshes.new('sine')
obj = bpy.data.objects.new('sineObj', mesh)
bpy.context.scene.objects.link(obj)
bm.to_mesh(mesh)
obj.select = True
bpy.context.scene.objects.active = obj
bpy.ops.object.convert(target='CURVE')
drawSineWave(resolution = 100, startX = 0, endX = 4, cycles = 4, amplitude = 1)
Blender Dadaist
- 1,559
- 8
- 15
