[SOLVED]Rotation around a point

So i’m writing out a program to lock a camera to an entity or object in my game

The rotation works fine and seems to rotate correctly but the center about which it rotates is off.

I reckon i understand why it’s not working i just don’t know how to fix it

Here’s the code

public void lockCameraToEntity(Entity e,float x,float y,float z){
	float hyp = (float)Math.sqrt(x*x+z*z);
	this.pos.x=(float)(-(e.pos.x+x) + (Math.sin(Math.toRadians(e.rot.y))*hyp)+hyp);
	this.pos.y=-(e.pos.y+y);
	this.pos.z=(float)(-(e.pos.z+z) + (Math.cos(Math.toRadians(e.rot.y))*hyp)+hyp);
}

Well then, why is it not working?

Its ok i got it fixed now

The issue was that i was adding the hypotenuse to the offset of each axis when instead i should have been adding the x and z offset parsed to to function