0
\$\begingroup\$

The picture illustrates enter image description here

I cannot figure out the math on this. The "arrows" should move at the same speed in both examples.

\$\endgroup\$
0

1 Answer 1

1
\$\begingroup\$

You are moving at a constant speed in terms of the y-axis. To move a constant speed in terms of the vector direction, you would need to calculate the distance to be traveled (in purple in your first diagram), and if you know how far you want to go per run, divide the total distance by that distance to get how many loops it will take to traverse the vector to the goal position. Now divide the y-change by that number of loops and you now know the amount to add/subtract from the y in every increment. Now, use your formula: y=mx, and instead of incrementing y by 1, increment it by that incement value you just found. I hope you can understand all that.

The formula for distance is sqrt(|x1 - x2|^2 + |y1 - y2|^2).

\$\endgroup\$
0

Not the answer you're looking for? Browse other questions tagged .