gxc-math/lib/src/functions/index.ts
Andrey Kernichniy 4dbba31ed5
All checks were successful
CI / build (push) Successful in 29s
Release package version 0.0.3
Added Matrix2d class, update Transform class
2026-03-15 00:14:45 +07:00

15 lines
581 B
TypeScript

import { Rectangle, Transform } from "../models";
export const degToRad = (deg: number) => (deg * Math.PI) / 180;
export const radToDeg = (radians: number) => radians * (180 / Math.PI);
export const getBounds = (rectangle: Rectangle, transform: Transform) => {
const { top, left, bottom, right } = rectangle;
const matrix2d = transform.toMatrix2D();
const topLeft = matrix2d.transformPoint({ x: left, y: top });
const bottomRight = matrix2d.transformPoint({ x: right, y: bottom });
return Rectangle.fromPoints(topLeft.x, topLeft.y, bottomRight.x, bottomRight.y);
};