Answer the question
In order to leave comments, you need to log in
How to implement vector movement?
Hello, dear users of the site toster.ru.
I have a question for you:
How can I implement the movement of a point in C ++, for example, with x and y coordinates along a vector?
I know I should be better at math, but please explain. Thanks for any help. If it is important, then I use SDL render to display the point.
Answer the question
In order to leave comments, you need to log in
let R be the radius vector specifying the position (its coordinates are equal to the coordinates of the point), D - the unit vector specifying the direction, v - the scalar specifying the speed.
R(t1) = R(t0) + dR //current position = previous position + position change.
dR = v * D * (t1 - t0)
code in pseudocode
R = R0;
while true
{
draw_point(R);
R += v * D * dt;
delay(dt);
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question