DrakeGraves [Lexaloffle Blog Feed]https://www.lexaloffle.com/bbs/?uid=26327 Finding a specific point along a sine wave <p>Hello erreybuddy. I don't have a specific project I'm working on or anything, but it's been bothering me that I don't understand how this works. I do have a pixel that oscillates properly, but I do not understand my own code, so I don't know how to approach having the pixel <em>start</em> at a different point in the oscillation cycle, without the amplitude changing. Here's my current code.</p> <div> <div class=scrollable_with_touch style="width:100%; max-width:800px; overflow:auto; margin-bottom:12px"> <table style="width:100%" cellspacing=0 cellpadding=0> <tr><td background=/gfx/code_bg1.png width=16><div style="width:16px;display:block"></div></td> <td background=/gfx/code_bg0.png> <div style="font-family : courier; color: #000000; display:absolute; padding-left:10px; padding-top:4px; padding-bottom:4px; "> <pre> f=0 function _update() f+=5 y = sin((f)/100) * 8 +64 end function _draw() cls() pset(64,y,7) end </pre></div></td> <td background=/gfx/code_bg1.png width=16><div style="width:16px;display:block"></div></td> </tr></table></div></div> <p>If any smarty-pantses could explain why this code works to me like I'm a child, or how to have the pixel start at another point along the wave without changing amplitude (the x and y values of the top and bottom of its current pattern of movement), that'd be great.</p> <p>I do feel bad asking for something without contributing to the community. Hopefully someday I can give back a little. Thank you all.</p> https://www.lexaloffle.com/bbs/?tid=30264 https://www.lexaloffle.com/bbs/?tid=30264 Wed, 15 Nov 2017 14:44:39 UTC