image-js
Version:
Image processing and manipulation in JavaScript
21 lines • 758 B
JavaScript
/**
* Rotate a point around a center by a given angle.
* @param point - The point to rotate
* @param rotationCenter - The center of rotation
* @param angle - The angle of rotation in radians
* @returns The rotated point
*/
export function rotatePoint(point, rotationCenter, angle) {
const angleCos = Math.cos(angle);
const angleSin = Math.sin(angle);
const column = point.column * angleCos -
point.row * angleSin +
(1 - angleCos) * rotationCenter.column +
rotationCenter.row * angleSin;
const row = point.column * angleSin +
point.row * angleCos +
(1 - angleCos) * rotationCenter.row -
rotationCenter.column * angleSin;
return { column, row };
}
//# sourceMappingURL=operations.js.map