1
$\begingroup$

UPDATE:

What I want is that given two points A and B, which are not in a straight line, I want a method thats gives me m and n. M and N are a couple of variables that adds to the previous coordinates. Therefore A' is (x0+m, y0+n). This method is going to be called a lot of times, to finally create a sinusoidal trajectory.

My main problem is that I don't really know how to put a sin equation with slope.

http://imageshack.us/photo/my-images/848/38386776.png/

I would be grateful if you could help me out with the pseudocode of the method thats obtains m and n values. This method has access to the actual coordinates.

Thank you very much.


OLD POST:

Ok...if I didn't explain my self... I have a particle in a point A (X0, Y0) and I want to move it in a small increment toward point B (X1, Y1). So my new point will be A' which will be at coordinates (X0+m, Y0+n).

I'm totally blocked trying to find a way of obtaining m and n in order to form a sinusoidal wave that moves from one point to another.

Please, notice that it moves in very small intervals, I mean m and n are really small. For example, if the distance between A and B is 1000px, the values for m and n would be between 1 and 5 px.

Thank you very much.

  • 0
    what value should the sine have in B?2012-04-10
  • 3
    There is an infinite number of sinusoidal waves which can be drawn between 2 points in the plane. You need to be a lot more restrictive in your requirements. If you are more restrictive, and if you understand basic trigonometry, you may solve the problem yourself. If don't understand basic trigonometry try editing your question and someone may help.2012-04-10
  • 1
    What will really help is if you *draw a picture* and show us what you want to do.2012-04-10
  • 0
    Drawing a picture did, indeed, make your question much clearer. Thank you!2012-04-10
  • 0
    However it's not as simple as adding 'm' and 'n' to the `x,y` coordinates of the sine wave. You can only achieve a *translation* (that is, an up/down/left/right shift) with that. Rotations require a more complicated calculation using trigonometry, which you can do using a *rotation matrix*. See answer.2012-04-10
  • 0
    I know that there are pretty much sinusoidal wave. I don't actually require precission. I wanted an image to move forming a kind of wave, so any random sinusoidal should work...2012-04-10

3 Answers 3