Mathematics – How to calculate the position of the turret after rotation


I'm trying to make a tank character for my game, but I could not calculate the bullets from the turret instead of the center of the tank.

I tried some stackoverflow solutions but I could not understand them correctly or they were not related to my problem.

this.angle = (rotation in radians) + Math.PI / 2
var x = -40 * Math.sin (this.angle) - -40 * Math.cos (this.angle);
var y = -40 * Math.cos (this.angle) + -40 * Math.sin (this.angle);

turretX = turretX - x;
turretY = turretY - y;

Now, as you can imagine, the position is always 40px wrong. That is what is expected since I try to change the values ​​of x and y, regardless of whether they are correct or not. How can I get the correct x, and?