I still think you need to understand basic trigonometry. But here is a simple introduction of how to use
cos to simulate a wave.
The basic wave formula is:
f(t) = A * sin( 2 * pi * f * t + phase )
- f is the frequency, which controls the number of times the waves repeats per unit time, f = 1/P where P is the number of periods.
- A is the amplitude of the wave, which represents the highest and lowest points of the wave.
- 2*pi is a scaling factor to be able to deal with the equation in terms of frequency and periods. (in other words, make it easier
and more intuitive).
- t is a parameter that represents time, or any other varying quantity.
The relation between a
cos and a
sin wave is only
pi/2 phase shift.
cos(t) = sin(t + pi/2 );
What you only need to do to make your object move, is to vary
t over time, inject it into the wave equation, and multiply your object possibly the
Y position with the computed result from the wave equation.
Implementing this is straightforward
float initx = 0;
float inity = 0;
Object.x = initx+ time;
Object.y = inity+ (a * sin(2 * PI * f * t + phase));
But keep in mind that this will not simulate how an object would float on water. The topic would be much more complicated. This will only simulate a sine wave.