# How to normalize angles from points in java

What is the velocity of a translating projectile in 2D?

What I'm trying to do

Get the slope at a constant speed for both X & Y Coordinates though I don't have an understanding on how to use Vectors in programming so I'm going off this guys equations but with both X & Y since I don't understand vectors. I can't tell at this point if there a direction or coordinate.

What I've done so far

What I need help with

What do I have to put in as Syntax to normalize these 2 points even though their coordinates (Based off the answer on the given thread)

• Learn vectors, you aren't going anywhere if you don't. – liggiorgio Jun 4 '16 at 22:31

From this I can guess that code you could use would be something like this:

//Setup the positions of the player and the target position
Vector2 targetPos = new Vector2(Gdx.input.getX(), Gdx.input.getY());
Vector2 playerPos = new Vector2(Player.x, Player.y);

//Now create the vector from the player to the target
Vector2 toTargetVec = new Vector2(targetPos(targetPos.sub(playerPos)));
Vector2 directionalVec = new Vector2(toTargetVec.nor());

//Set the projectile's position
projectileX = Player.x;
projectileY = Player.y;

//Now we use this to start the projectile moving towards the target
projectileVX = directionalVec.x * projectileSpeed;
projectileVY = directionalVec.y * projectileSpeed;


I would highly recommend you learn how vectors work, they're used a lot in game programming.

PS. If you want to find the angle of the projectile, here's how:

projectileAngle = toTargetVec.angle();