Vector acceleration based on angle?

How can I accelerate something yet have it move in it’s angle?

Vector2f pos = new Vector2f(250,250);
float angle = 145;

Now I also got velo and accel

Vector2f velo = new Vector2f(0,0);
Vector2f accel = new Vector2f(1,1);

Now to accelerate I add accel to velo, then each time I move by adding velo to pos, but how do I make it so velo takes the angle into account? for example if you were to be at angle 45 and press the go button you would start moving at a velo of (1,-1) and that velo would be increased by (1,-1) for each pass that you hold the go button; However, if you were at angle 145 the velo and increase would be (1,1).

You should instead have a speed variable. Velocity is speed + angle (by using the deltaX and the deltaY). If you want a velocity vector, all you need to do is add the acceleration to it, then add it to the position. Otherwise, you could have a speed and angle variable and use trig to find the deltaX and deltaY:


pos.x += velocity * Math.cos(Math.toRadians(angle));
pos.y += velocity * Math.sin(Math.toRadians(angle));

EDIT: Fixed the wording. :smiley:

Thank you. ;D

You should probably read up on the difference between speed and velocity.

Ah yes thank you, I misused the terms.