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?
$\begingroup$
$\endgroup$
4
-
$\begingroup$ Check this: blender.stackexchange.com/questions/47337/… $\endgroup$– Jan MatysCommented Oct 4, 2018 at 22:01
-
1$\begingroup$ I don't understand how that relates. This topic is not related to .wav files, it is related to the structure of a physical wave. $\endgroup$– Vane VoeCommented Oct 4, 2018 at 22:05
-
$\begingroup$ blender.stackexchange.com/questions/74410/… and blender.stackexchange.com/questions/73741/… $\endgroup$– Duarte Farrajota Ramos ♦Commented Oct 4, 2018 at 22:54
-
$\begingroup$ It creates a mesh, but what about a curve? It doesn't let me set the thickness to 0 even. $\endgroup$– Vane VoeCommented Oct 5, 2018 at 1:00
Add a comment
|
1 Answer
$\begingroup$
$\endgroup$
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)