Solved How to calculate new position based on angle?

Hello, how can I calculate any coordinate from a rotated image?

Here a simple image of a gun, I know the number ‘1’ (origin), ‘2’ (any start position from image) and the ‘angle’ (rotated). So I want to know the ‘3’ (the new position from start position).

http://s4.postimg.org/5jo9x6rst/calc.png

I think I can do this with Vector2 calc with angle, but my final position is not the correct position. I think I’m forgetting something.

A little note info would help, as you have not stated what you are using, what you have tried etc.

There is many ways to do this, you are wanting to rotate an object around a local coordinate right?

https://www.google.com/#q=point+rotated+about+point+2d

I created a rectangle shape with the gun and I decreased the bullet velocity to 0, so I can see where each bullet is spawned.
The top-center of the gun is the start position (and where each bullet must spawn) and the crossing of pink lines is the origin of the sprite.

Here my method where I’m trying to calculate:

	public Vector2 getWeaponPosition()
	{
		float angle = weapon.getRotation()*MathUtils.PI/180; //To Radians
		
		float ox = weapon.getX()+weapon.getWidth()/2; //Ori x
		float oy = weapon.getY(); //Ori y
		
		float px = weapon.getX()+weapon.getWidth()/2; //Start X
		float py = weapon.getY()+weapon.getHeight(); //Start Y
		
		Vector2 newPos = new Vector2();
		newPos.x = MathUtils.cos(angle) * (px-ox) - MathUtils.sin(angle) * (py-oy) + ox;
		newPos.y = MathUtils.sin(angle) * (px-ox) + MathUtils.cos(angle) * (py-oy) + oy;
		
		return newPos;
	}

http://s9.postimg.org/4xanky8jj/aaaa.png

The gun follows the mouse position perfectly.

**I’m using radians because MathUtils use radians.

Solved, found the solluiton on MrPork topic about direction.