This commit is contained in:
李志鹏
2026-01-16 16:31:54 +08:00
parent 0add8bc412
commit 9b29939bfe
4 changed files with 46 additions and 10 deletions

View File

@@ -933,6 +933,23 @@ export function calculateCenterPoint(W, H, currentX, currentY, currentAngleDeg)
const Cy = currentY + (W / 2) * sinCurrent + (H / 2) * cosCurrent;
return { x: Cx, y: Cy };
}
/**
* 根据中心点坐标计算左上角坐标
* @param {number} W - 宽度
* @param {number} H - 高度
* @param {number} centerX - 中心点x坐标
* @param {number} centerY - 中心点y坐标
* @param {number} currentAngleDeg - 当前角度(度)
* @returns {Object} 左上角坐标 {x, y}
*/
export function calculateTopLeftPoint(W, H, centerX, centerY, currentAngleDeg) {
const currentAngle = (currentAngleDeg * Math.PI) / 180;
const cosCurrent = Math.cos(currentAngle);
const sinCurrent = Math.sin(currentAngle);
const Cx = centerX + (W / 2) * cosCurrent - (H / 2) * sinCurrent;
const Cy = centerY + (W / 2) * sinCurrent + (H / 2) * cosCurrent;
return { x: Cx, y: Cy };
}