[Closed] Wavelength with Sin
How do I implement the wavelength into this?
minVal = 5.0 -- (the wave will never go below this value)
maxVal = 30.0 -- (the wave will never go above this value)
clearlistener()
delete objects
-- /* -- -- -- BOUNCE (w/ Options) -- -- --*/
for i = 0 to 100 do
(
waveLength = (units.decodevalue "10.0cm")
variable = sin(i as float/.1)
range = maxVal-minVal
val = (if variable > 0 then variable else variable*(-1))*range
val += minVal
obj = box pos:[i*2,0,(val)] width:2 height:2 length:2 wirecolor:red
)
EDIT: My desired goal is to have the distance between each sin wave be controlled/equal to the supplied wavelength.
EDIT: Nothing to see here completely got lost while trying to figure out the issue.
Ignore my previous post. You want the width of the sine wave equal to the wavelength?
-Eric
Eric,
Yeah that is exactly what I’m after.
I want the length between each wave to be equal to the supplied wavelength.
Often I completely misunderstand people’s questions. But I can’t see how this time. I hope this is what you need:
minVal = 5.0 -- (the wave will never go below this value)
maxVal = 30.0 -- (the wave will never go above this value)
waveLength = units.decodeValue "32cm"
count = wavelength*2
ratio = (360./count)
clearlistener()
delete objects
-- /* -- -- -- BOUNCE (w/ Options) -- -- --*/
for i = 0 to count do
(
degs = (i*2*ratio)
variable = sin(degs)
range = maxVal-minVal
val = (if variable > 0 then variable else variable*(-1))*range
val += minVal
obj = box pos:[i*2,0,(val)] width:2 height:2 length:2 wirecolor:(if mod degs 90 == 0 then green else red)
)
Regards,
Eugenio
delete objects
amplitude = (units.decodevalue "15.0cm")
waveLength = (units.decodevalue "10.0cm")
boxsize = [1,1,1]*(units.decodevalue "1cm")
num = 20
step = waveLength/num
for n=0 to 9 do
(
for x=0 to num-1 do
(
z = abs(sin(180.0*x/num))*amplitude
obj = dummy pos:[(n*num + x)*step,0,z] boxsize:boxsize wirecolor:red
)
)
is it what you are looking for?
Yeah that is exactly what I’m after. Thanks guys for the quick help and responses.
I couldn’t wrap my head around why the wavelength was not working the way i thought it would.
Thanks
How do I adjust the decrease or increase in the given wave using DenisT code? Do I adjust the steping? So the wave decreased in amplitude and length over time.
See code for example.
-- /* -- -- -- SINE Simple (w/ Increase) -- -- --*/
for i = 1 to 600 do
(
val = (sin(i)*cos(i))*i*freq
obj = box pos:[i*2,0,(val)] width:2 height:2 length:2 wirecolor:red
)
there are actually two parameters who change the X-distribution: waveLength and num (number of point on the wave).
if you change the number of points it will change the step (distance between points along X axis)
Incrementally adjust them.
So over time the waves in general decrease or increase. *like the stock market
I got it going upward!..no wavelength decay yet.
delete objects
amplitude = (units.decodevalue "10.0cm")
waveLength = (units.decodevalue "20.0cm")
boxsize = [1,1,1]*(units.decodevalue "1cm")
decay = (units.decodevalue ".5cm")
num = 20
step = waveLength/num
for n=0 to 4 do
(
for x=0 to num-1 do
(
z = abs(sin(180.0*x/num))*amplitude*(decay*n)
obj = dummy pos:[(n*num + x)*step,0,z] boxsize:boxsize wirecolor:red
)
)