I am facing a challenge with two rectangles that have pivots attached to them,
The task at hand is to align the green rectangle's position based on the rotation of the red rectangle.
The desired outcome should resemble the image provided:
Despite trying out various formulas, I haven't achieved success yet.
Details of red rectangle:
x=500, y=100, width=200, height=500, pivotX=100, pivotY=400
Details of green rectangle:
x=450, y=150, width=100, height=400, pivotX=50, pivotY=50
Here is an attempt I made:
var radians = (Math.PI / 180) * red.degree;
green.x += red.pivotX * Math.cos(radians) - red.pivotY * Math.sin(radians);
green.y += red.pivotX * Math.sin(radians) + red.pivotY * Math.cos(radians);
A big thank you to everyone who has offered their assistance!