SOURCE

console 命令行工具 X clear

                    
>
console
const x = 100
const y = 100
const width = 200
const height = 100
const rotate = 30

const div = document.getElementById('test')

div.style.position = 'absolute'
div.style.width = width +'px'
div.style.height = height +'px'
div.style.top = y +'px'
div.style.left = x +'px'
div.style.background = 'red'
div.style.transform = `rotate(${rotate}deg)`



const calcRotatedPoint = (prev, center, angle) => {
  angle /= 180 / Math.PI;
  return {
    x: (prev.x - center.x) * Math.cos(angle) - (prev.y - center.y) * Math.sin(angle) + center.x,
    y: (prev.x - center.x) * Math.sin(angle) + (prev.y - center.y) * Math.cos(angle) + center.y,
  };
};

document.addEventListener('click',(e)=>{
    const point = {
        x: e.clientX,
        y: e.clientY
    }

    const divTopLeft = {
        x,
        y
    }
    const divRightBottom = {
        x: x + width,
        y: y +height
    }

    const divCenter = {
        x: x + width / 2,
        y: y + height / 2 
    }

    const currentPoint =  calcRotatedPoint(point,divCenter,-rotate)
    console.log(point,currentPoint)
    const isInDiv = currentPoint.x > divTopLeft.x &&
                    currentPoint.x < divRightBottom.x &&
                    currentPoint.y > divTopLeft.y &&
                    currentPoint.y < divRightBottom.y
   console.log(isInDiv)
})
<div id="test"></div>