Help me with this sine wave trig
BlitzMax Forums/BlitzMax Beginners Area/Help me with this sine wave trig
| ||
This should be reasonably simple but then again, so am I ^_^ I need the white dot to curve up and meet the red dot where I clicked i.e. I need to adjust the frequency of the wave. The most obvious way to do this is to scale the frequencyparameter in the formula: z = -Sin( frequency * x + horiz_displacement ) * amplitude + vertical_displacement ...by somehow basing the change on the distance clicked from the origin but nothing I've tried gets the correct result. |
| ||
to make the objects meet at the point where the mouse was clicked, you must force the sine function to be an integer number of half-waves along the vector your red object follows, from its beginning point to the point where the mouse was clicked. here... in your update method change the frequency to this: Local frequency:Float = n*180/dist_target ... where n is the integer number of half-wavelengths you want the white object to oscillate through until it intercepts the red object. I hope this is what you were after. |
| ||
Wow, that's some crazy maths. Still I like a challenge! After some hard thinking, the frequency you need is: Local frequency:Float = 180/x_targetEdit: Damn, Queller beat me to it! |
| ||
You guys are gold, thanks! |